From 8c11c2b304a5695d2e424cbc81da125665049c75 Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Sun, 6 Dec 2020 00:47:00 -0800 Subject: [PATCH] Renamed `vnfs` to `container`, finished VNFS and kernel refactoring --- Makefile | 8 +- etc/ipxe/default.ipxe | 7 +- etc/nodes.conf | 2 +- etc/warewulf.conf | 4 +- internal/app/warewulfd/response/ipxe.go | 20 +++-- internal/app/warewulfd/response/kernel.go | 4 +- internal/app/warewulfd/response/kmods.go | 4 +- internal/app/warewulfd/response/vnfs.go | 34 ------- internal/app/warewulfd/warewulfd.go | 2 +- internal/app/wwctl/build/main.go | 4 +- internal/app/wwctl/build/root.go | 24 ++--- internal/app/wwctl/node/add/root.go | 2 +- internal/app/wwctl/node/list/main.go | 6 +- internal/app/wwctl/node/set/main.go | 18 ++-- internal/app/wwctl/node/set/root.go | 8 +- internal/app/wwctl/profile/list/main.go | 2 +- internal/app/wwctl/profile/set/main.go | 18 ++-- internal/app/wwctl/profile/set/root.go | 8 +- internal/app/wwctl/ready/main.go | 6 +- internal/app/wwctl/root.go | 4 +- internal/app/wwctl/vnfs/build/main.go | 79 ---------------- internal/app/wwctl/vnfs/build/root.go | 28 ------ internal/app/wwctl/vnfs/list/main.go | 89 ------------------- internal/app/wwctl/vnfs/list/root.go | 25 ------ internal/app/wwctl/vnfs/pull/main.go | 54 ----------- internal/app/wwctl/vnfs/pull/root.go | 26 ------ internal/app/wwctl/vnfs/root.go | 29 ------ internal/pkg/{vnfs => container}/build.go | 2 +- internal/pkg/{vnfs => container}/pull.go | 2 +- internal/pkg/{vnfs => container}/vnfs.go | 4 +- internal/pkg/node/constructors.go | 6 +- internal/pkg/node/datastructure.go | 4 +- internal/pkg/node/modifiers.go | 4 +- internal/pkg/oci/cache.go | 2 +- internal/pkg/overlay/funcmap.go | 20 ++--- internal/pkg/overlay/overlay.go | 54 ++++++----- internal/pkg/vnfs_old/docker.go | 2 +- internal/pkg/vnfs_old/vnfs.go | 8 +- overlays/runtime/default/etc/group.ww | 2 +- overlays/runtime/default/etc/passwd.ww | 2 +- overlays/system/default/etc/hostname.ww | 2 +- .../sysconfig/network-scripts/ifcfg-eth0.ww | 8 +- .../system/default/etc/sysconfig/network.ww | 2 +- overlays/system/default/ipmi.ww | 8 +- 44 files changed, 143 insertions(+), 504 deletions(-) delete mode 100644 internal/app/warewulfd/response/vnfs.go delete mode 100644 internal/app/wwctl/vnfs/build/main.go delete mode 100644 internal/app/wwctl/vnfs/build/root.go delete mode 100644 internal/app/wwctl/vnfs/list/main.go delete mode 100644 internal/app/wwctl/vnfs/list/root.go delete mode 100644 internal/app/wwctl/vnfs/pull/main.go delete mode 100644 internal/app/wwctl/vnfs/pull/root.go delete mode 100644 internal/app/wwctl/vnfs/root.go rename internal/pkg/{vnfs => container}/build.go (98%) rename internal/pkg/{vnfs => container}/pull.go (97%) rename internal/pkg/{vnfs => container}/vnfs.go (95%) diff --git a/Makefile b/Makefile index 0384ddca..4675addf 100644 --- a/Makefile +++ b/Makefile @@ -49,16 +49,16 @@ files: all install -d -m 0755 /etc/warewulf/ipxe install -d -m 0755 /var/lib/tftpboot/warewulf/ipxe/ cp -r etc/* /etc/warewulf/ - cp -r tftpboot/* /var/lib/tftpboot/warewulf/ipxe/ - restorecon -r /var/lib/tftpboot/warewulf +# cp -r tftpboot/* /var/lib/tftpboot/warewulf/ipxe/ +# restorecon -r /var/lib/tftpboot/warewulf cp -r overlays /var/warewulf/ chmod +x /var/warewulf/overlays/system/default/init mkdir -p /var/warewulf/overlays/system/default/warewulf/bin/ cp wwclient /var/warewulf/overlays/system/default/warewulf/bin/ services: files - sudo systemctl enable tftp - sudo systemctl restart tftp +# sudo systemctl enable tftp +# sudo systemctl restart tftp warewulfd: cd cmd/warewulfd; go build -mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../warewulfd diff --git a/etc/ipxe/default.ipxe b/etc/ipxe/default.ipxe index 2df1f61c..42daae76 100644 --- a/etc/ipxe/default.ipxe +++ b/etc/ipxe/default.ipxe @@ -4,12 +4,15 @@ echo echo ================================================================================ echo Warewulf v4 now booting: {{.Fqdn}} echo +echo Container: {{.ContainerName}} +echo Kernel: {{.KernelVersion}} +echo KernelArgs: {{.KernelArgs}} echo set base http://{{.Ipaddr}}:{{.Port}} -kernel ${base}/kernel/{{.Hwaddr}} {{.Kernelargs}} || reboot -initrd ${base}/vnfs/{{.Hwaddr}} || reboot +kernel ${base}/kernel/{{.Hwaddr}} {{.KernelArgs}} || reboot +initrd ${base}/container/{{.Hwaddr}} || reboot initrd ${base}/kmods/{{.Hwaddr}} || reboot initrd ${base}/overlay-system/{{.Hwaddr}} || reboot boot || reboot diff --git a/etc/nodes.conf b/etc/nodes.conf index fb24e894..83b14876 100644 --- a/etc/nodes.conf +++ b/etc/nodes.conf @@ -1,7 +1,7 @@ nodeprofiles: default: comment: "This profile is automatically included for each node" - vnfs: "" + container name: "" kernel version: "" kernel args: crashkernel=no quiet diff --git a/etc/warewulf.conf b/etc/warewulf.conf index 380c6d55..eb8c4eba 100644 --- a/etc/warewulf.conf +++ b/etc/warewulf.conf @@ -9,8 +9,8 @@ dhcp: range start: 192.168.1.150 range end: 192.168.1.200 template: default - systemd name: dhcp-server + systemd name: dhcpd tftp: enabled: true tftproot: /var/lib/tftpboot - systemd name: tftp-server + systemd name: tftp diff --git a/internal/app/warewulfd/response/ipxe.go b/internal/app/warewulfd/response/ipxe.go index d4efa341..794159b5 100644 --- a/internal/app/warewulfd/response/ipxe.go +++ b/internal/app/warewulfd/response/ipxe.go @@ -13,13 +13,14 @@ import ( ) type iPxeTemplate struct { - Hostname string - Fqdn string - Vnfs string - Hwaddr string - Ipaddr string - Port string - Kernelargs string + Hostname string + Fqdn string + ContainerName string + Hwaddr string + Ipaddr string + Port string + KernelArgs string + KernelVersion string } func IpxeSend(w http.ResponseWriter, req *http.Request) { @@ -70,8 +71,9 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) { replace.Port = strconv.Itoa(conf.Warewulf.Port) replace.Hostname = node.Id.Get() replace.Hwaddr = url[2] - replace.Vnfs = node.Vnfs.Get() - replace.Kernelargs = node.KernelArgs.Get() + replace.ContainerName = node.ContainerName.Get() + replace.KernelArgs = node.KernelArgs.Get() + replace.KernelVersion = node.KernelVersion.Get() err = tmpl.Execute(w, replace) if err != nil { diff --git a/internal/app/warewulfd/response/kernel.go b/internal/app/warewulfd/response/kernel.go index a7683617..e530de98 100644 --- a/internal/app/warewulfd/response/kernel.go +++ b/internal/app/warewulfd/response/kernel.go @@ -1,7 +1,7 @@ package response import ( - "github.com/hpcng/warewulf/internal/pkg/config" + "github.com/hpcng/warewulf/internal/pkg/kernel" "log" "net/http" ) @@ -16,7 +16,7 @@ func KernelSend(w http.ResponseWriter, req *http.Request) { } if node.KernelVersion.Defined() == true { - fileName := config.KernelImage(node.KernelVersion.Get()) + fileName := kernel.KernelImage(node.KernelVersion.Get()) err := sendFile(w, fileName, node.Id.Get()) if err != nil { diff --git a/internal/app/warewulfd/response/kmods.go b/internal/app/warewulfd/response/kmods.go index c4366008..4622b3b2 100644 --- a/internal/app/warewulfd/response/kmods.go +++ b/internal/app/warewulfd/response/kmods.go @@ -1,7 +1,7 @@ package response import ( - "github.com/hpcng/warewulf/internal/pkg/config" + "github.com/hpcng/warewulf/internal/pkg/kernel" "log" "net/http" ) @@ -16,7 +16,7 @@ func KmodsSend(w http.ResponseWriter, req *http.Request) { } if node.KernelVersion.Defined() == true { - fileName := config.KmodsImage(node.KernelVersion.Get()) + fileName := kernel.KmodsImage(node.KernelVersion.Get()) err := sendFile(w, fileName, node.Id.Get()) if err != nil { diff --git a/internal/app/warewulfd/response/vnfs.go b/internal/app/warewulfd/response/vnfs.go deleted file mode 100644 index 38ac1c60..00000000 --- a/internal/app/warewulfd/response/vnfs.go +++ /dev/null @@ -1,34 +0,0 @@ -package response - -import ( - "github.com/hpcng/warewulf/internal/pkg/vnfs" - "log" - "net/http" -) - -func VnfsSend(w http.ResponseWriter, req *http.Request) { - - node, err := getSanity(req) - if err != nil { - w.WriteHeader(404) - log.Panicln(err) - return - } - - if node.Vnfs.Defined() == true { - vnfsImage := vnfs.ImageFile(node.Vnfs.Get()) - - err = sendFile(w, vnfsImage, node.Id.Get()) - if err != nil { - log.Printf("ERROR1: %s\n", err) - w.WriteHeader(503) - } else { - log.Printf("SEND: %15s: %s\n", node.Id.Get(), vnfsImage) - } - } else { - w.WriteHeader(503) - log.Printf("ERROR: No VNFS set for node %s\n", node.Id.Get()) - } - - return -} diff --git a/internal/app/warewulfd/warewulfd.go b/internal/app/warewulfd/warewulfd.go index dbdacebe..a6805d2a 100644 --- a/internal/app/warewulfd/warewulfd.go +++ b/internal/app/warewulfd/warewulfd.go @@ -14,7 +14,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error { http.HandleFunc("/ipxe/", response.IpxeSend) http.HandleFunc("/kernel/", response.KernelSend) http.HandleFunc("/kmods/", response.KmodsSend) - http.HandleFunc("/vnfs/", response.VnfsSend) + http.HandleFunc("/container/", response.ContainerSend) http.HandleFunc("/overlay-system/", response.SystemOverlaySend) http.HandleFunc("/overlay-runtime", response.RuntimeOverlaySend) diff --git a/internal/app/wwctl/build/main.go b/internal/app/wwctl/build/main.go index 4bb827af..257fa477 100644 --- a/internal/app/wwctl/build/main.go +++ b/internal/app/wwctl/build/main.go @@ -1,9 +1,9 @@ package build import ( + "github.com/hpcng/warewulf/internal/pkg/container" "github.com/hpcng/warewulf/internal/pkg/kernel" "github.com/hpcng/warewulf/internal/pkg/node" - "github.com/hpcng/warewulf/internal/pkg/vnfs" "github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/spf13/cobra" "os" @@ -47,7 +47,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error { set[node.Vnfs.Get()]++ } for e := range set { - vnfs.Build(e, buildForce) + container.Build(e, buildForce) } } diff --git a/internal/app/wwctl/build/root.go b/internal/app/wwctl/build/root.go index 32329651..dd8f29cc 100644 --- a/internal/app/wwctl/build/root.go +++ b/internal/app/wwctl/build/root.go @@ -6,24 +6,24 @@ import ( var ( baseCmd = &cobra.Command{ - Use: "build", - Short: "Warewulf build subcommand", - Long: "Warewulf build is used to build VNFS, kernel, and system-overlay objects for\n" + - "provisioning. The default usage will be to build and/or update anything\n" + - "that seems to be needed.", - RunE: CobraRunE, + Use: "build", + Short: "Warewulf build subcommand", + Long: "Warewulf build is used to build VNFS, kernel, and system-overlay objects for\n" + + "provisioning. The default usage will be to build and/or update anything\n" + + "that seems to be needed.", + RunE: CobraRunE, } - buildVnfs bool - buildKernel bool + buildVnfs bool + buildKernel bool buildRuntimeOverlay bool - buildSystemOverlay bool - buildAll bool - buildForce bool + buildSystemOverlay bool + buildAll bool + buildForce bool ) func init() { - baseCmd.PersistentFlags().BoolVarP(&buildVnfs, "vnfs", "V", false, "Build and/or update VNFS images.") + baseCmd.PersistentFlags().BoolVarP(&buildVnfs, "container", "V", false, "Build and/or update VNFS images.") baseCmd.PersistentFlags().BoolVarP(&buildKernel, "kernel", "K", false, "Build and/or update Kernel images.") baseCmd.PersistentFlags().BoolVarP(&buildRuntimeOverlay, "runtime", "R", false, "Build and/or update runtime overlays") baseCmd.PersistentFlags().BoolVarP(&buildSystemOverlay, "system", "S", false, "Build and/or update system overlays") diff --git a/internal/app/wwctl/node/add/root.go b/internal/app/wwctl/node/add/root.go index f794ef80..99a4a75c 100644 --- a/internal/app/wwctl/node/add/root.go +++ b/internal/app/wwctl/node/add/root.go @@ -22,7 +22,7 @@ var ( func init() { baseCmd.PersistentFlags().StringVarP(&SetGroup, "group", "g", "default", "Group to add nodes to") baseCmd.PersistentFlags().StringVarP(&SetController, "controller", "c", "localhost", "Controller to add nodes to") - baseCmd.PersistentFlags().StringVarP(&SetNetDev, "netdev", "n", "eth0", "Define the network device to configure") + baseCmd.PersistentFlags().StringVarP(&SetNetDev, "netdev", "N", "eth0", "Define the network device to configure") baseCmd.PersistentFlags().StringVarP(&SetIpaddr, "ipaddr", "I", "", "Set the node's network device IP address") baseCmd.PersistentFlags().StringVarP(&SetNetmask, "netmask", "M", "", "Set the node's network device netmask") baseCmd.PersistentFlags().StringVarP(&SetGateway, "gateway", "G", "", "Set the node's network device gateway") diff --git a/internal/app/wwctl/node/list/main.go b/internal/app/wwctl/node/list/main.go index 5cc65f95..b2103686 100644 --- a/internal/app/wwctl/node/list/main.go +++ b/internal/app/wwctl/node/list/main.go @@ -50,7 +50,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error { fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "ClusterName", node.ClusterName.Source(), node.ClusterName.Print()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "Profiles", "--", strings.Join(node.Profiles, ",")) - fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "Vnfs", node.Vnfs.Source(), node.Vnfs.Print()) + fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "ContainerName", node.ContainerName.Source(), node.ContainerName.Print()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "KernelVersion", node.KernelVersion.Source(), node.KernelVersion.Print()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "KernelArgs", node.KernelArgs.Source(), node.KernelArgs.Print()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "RuntimeOverlay", node.RuntimeOverlay.Source(), node.RuntimeOverlay.Print()) @@ -99,11 +99,11 @@ func CobraRunE(cmd *cobra.Command, args []string) error { } } else if ShowLong == true { - fmt.Printf("%-22s %-26s %-35s %s\n", "NODE NAME", "KERNEL VERSION", "VNFS IMAGE", "OVERLAYS (S/R)") + fmt.Printf("%-22s %-26s %-35s %s\n", "NODE NAME", "KERNEL VERSION", "CONTAINER", "OVERLAYS (S/R)") fmt.Println(strings.Repeat("=", 120)) for _, node := range nodes { - fmt.Printf("%-22s %-26s %-35s %s\n", node.Id.Get(), node.KernelVersion.Print(), node.Vnfs.Print(), node.SystemOverlay.Print()+"/"+node.RuntimeOverlay.Print()) + fmt.Printf("%-22s %-26s %-35s %s\n", node.Id.Get(), node.KernelVersion.Print(), node.ContainerName.Print(), node.SystemOverlay.Print()+"/"+node.RuntimeOverlay.Print()) } } else { diff --git a/internal/app/wwctl/node/set/main.go b/internal/app/wwctl/node/set/main.go index 37b94e39..a6dba01b 100644 --- a/internal/app/wwctl/node/set/main.go +++ b/internal/app/wwctl/node/set/main.go @@ -2,9 +2,9 @@ package set import ( "fmt" + "github.com/hpcng/warewulf/internal/pkg/container" "github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/util" - "github.com/hpcng/warewulf/internal/pkg/vnfs" "github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/manifoldco/promptui" "github.com/spf13/cobra" @@ -44,17 +44,17 @@ func CobraRunE(cmd *cobra.Command, args []string) error { os.Exit(1) } - if SetVnfs != "" { - if vnfs.ValidSource(SetVnfs) == true { - imageFile := vnfs.ImageFile(SetVnfs) + if SetContainer != "" { + if container.ValidSource(SetContainer) == true { + imageFile := container.ImageFile(SetContainer) if util.IsFile(imageFile) == false { - wwlog.Printf(wwlog.ERROR, "VNFS has not been built: %s\n", SetVnfs) + wwlog.Printf(wwlog.ERROR, "Container has not been built: %s\n", SetContainer) if SetForce == false { os.Exit(1) } } } else { - wwlog.Printf(wwlog.ERROR, "VNFS does not exist: %s\n", SetVnfs) + wwlog.Printf(wwlog.ERROR, "Container does not exist: %s\n", SetContainer) if SetForce == false { os.Exit(1) } @@ -74,10 +74,10 @@ func CobraRunE(cmd *cobra.Command, args []string) error { os.Exit(1) } } - if SetVnfs != "" { - wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting vnfs to: %s\n", n.Id.Get(), SetVnfs) + if SetContainer != "" { + wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting container name to: %s\n", n.Id.Get(), SetContainer) - n.Vnfs.Set(SetVnfs) + n.ContainerName.Set(SetContainer) err := nodeDB.NodeUpdate(n) if err != nil { wwlog.Printf(wwlog.ERROR, "%s\n", err) diff --git a/internal/app/wwctl/node/set/root.go b/internal/app/wwctl/node/set/root.go index aa21b77c..24cb0f73 100644 --- a/internal/app/wwctl/node/set/root.go +++ b/internal/app/wwctl/node/set/root.go @@ -10,7 +10,7 @@ var ( RunE: CobraRunE, } SetComment string - SetVnfs string + SetContainer string SetKernel string SetNetDev string SetIpaddr string @@ -35,9 +35,9 @@ var ( func init() { baseCmd.PersistentFlags().StringVar(&SetComment, "comment", "", "Set a comment for this node") - baseCmd.PersistentFlags().StringVarP(&SetVnfs, "vnfs", "V", "", "Set node Virtual Node File System (VNFS)") + baseCmd.PersistentFlags().StringVarP(&SetContainer, "container", "C", "", "Set the container (VNFS) for this node") baseCmd.PersistentFlags().StringVarP(&SetKernel, "kernel", "K", "", "Set Kernel version for nodes") - baseCmd.PersistentFlags().StringVarP(&SetClusterName, "cluster", "C", "", "Set the node's cluster name") + baseCmd.PersistentFlags().StringVarP(&SetClusterName, "cluster", "c", "", "Set the node's cluster group") baseCmd.PersistentFlags().StringVarP(&SetIpxe, "ipxe", "P", "", "Set the node's iPXE template name") baseCmd.PersistentFlags().StringVarP(&SetRuntimeOverlay, "runtime", "R", "", "Set the node's runtime overlay") baseCmd.PersistentFlags().StringVarP(&SetSystemOverlay, "system", "S", "", "Set the node's system overlay") @@ -49,7 +49,7 @@ func init() { baseCmd.PersistentFlags().StringSliceVarP(&SetAddProfile, "addprofile", "p", []string{}, "Add Profile(s) to node") baseCmd.PersistentFlags().StringSliceVarP(&SetDelProfile, "delprofile", "r", []string{}, "Remove Profile(s) to node") - baseCmd.PersistentFlags().StringVarP(&SetNetDev, "netdev", "n", "", "Define the network device to configure") + baseCmd.PersistentFlags().StringVarP(&SetNetDev, "netdev", "N", "", "Define the network device to configure") baseCmd.PersistentFlags().StringVarP(&SetIpaddr, "ipaddr", "I", "", "Set the node's network device IP address") baseCmd.PersistentFlags().StringVarP(&SetNetmask, "netmask", "M", "", "Set the node's network device netmask") baseCmd.PersistentFlags().StringVarP(&SetGateway, "gateway", "G", "", "Set the node's network device gateway") diff --git a/internal/app/wwctl/profile/list/main.go b/internal/app/wwctl/profile/list/main.go index 20acec5a..1c4e8762 100644 --- a/internal/app/wwctl/profile/list/main.go +++ b/internal/app/wwctl/profile/list/main.go @@ -37,7 +37,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error { fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "Comment", profile.Comment.Print()) fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "ClusterName", profile.ClusterName.Print()) - fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "Vnfs", profile.Vnfs.Print()) + fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "ContainerName", profile.ContainerName.Print()) fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "KernelVersion", profile.KernelVersion.Print()) fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "KernelArgs", profile.KernelArgs.Print()) fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "RuntimeOverlay", profile.RuntimeOverlay.Print()) diff --git a/internal/app/wwctl/profile/set/main.go b/internal/app/wwctl/profile/set/main.go index f4058894..c146574b 100644 --- a/internal/app/wwctl/profile/set/main.go +++ b/internal/app/wwctl/profile/set/main.go @@ -2,9 +2,9 @@ package set import ( "fmt" + "github.com/hpcng/warewulf/internal/pkg/container" "github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/util" - "github.com/hpcng/warewulf/internal/pkg/vnfs" "github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/manifoldco/promptui" "github.com/spf13/cobra" @@ -48,17 +48,17 @@ func CobraRunE(cmd *cobra.Command, args []string) error { } } - if SetVnfs != "" { - if vnfs.ValidSource(SetVnfs) == true { - imageFile := vnfs.ImageFile(SetVnfs) + if SetContainer != "" { + if container.ValidSource(SetContainer) == true { + imageFile := container.ImageFile(SetContainer) if util.IsFile(imageFile) == false { - wwlog.Printf(wwlog.ERROR, "VNFS has not been built: %s\n", SetVnfs) + wwlog.Printf(wwlog.ERROR, "Container has not been built: %s\n", SetContainer) if SetForce == false { os.Exit(1) } } } else { - wwlog.Printf(wwlog.ERROR, "VNFS does not exist: %s\n", SetVnfs) + wwlog.Printf(wwlog.ERROR, "Container name does not exist: %s\n", SetContainer) if SetForce == false { os.Exit(1) } @@ -88,10 +88,10 @@ func CobraRunE(cmd *cobra.Command, args []string) error { os.Exit(1) } } - if SetVnfs != "" { - wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting VNFS to: %s\n", p.Id, SetVnfs) + if SetContainer != "" { + wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting Container name to: %s\n", p.Id, SetContainer) - p.Vnfs.Set(SetVnfs) + p.ContainerName.Set(SetContainer) err := nodeDB.ProfileUpdate(p) if err != nil { wwlog.Printf(wwlog.ERROR, "%s\n", err) diff --git a/internal/app/wwctl/profile/set/root.go b/internal/app/wwctl/profile/set/root.go index d841534c..cd610b94 100644 --- a/internal/app/wwctl/profile/set/root.go +++ b/internal/app/wwctl/profile/set/root.go @@ -12,7 +12,7 @@ var ( SetAll bool SetForce bool SetComment string - SetVnfs string + SetContainer string SetKernel string SetClusterName string SetIpxe string @@ -31,9 +31,9 @@ var ( func init() { baseCmd.PersistentFlags().StringVar(&SetComment, "comment", "", "Set a comment for this node") - baseCmd.PersistentFlags().StringVarP(&SetVnfs, "vnfs", "V", "", "Set node Virtual Node File System (VNFS)") + baseCmd.PersistentFlags().StringVarP(&SetContainer, "container", "C", "", "Set the container (VNFS) for this node") baseCmd.PersistentFlags().StringVarP(&SetKernel, "kernel", "K", "", "Set Kernel version for nodes") - baseCmd.PersistentFlags().StringVarP(&SetClusterName, "cluster", "C", "", "Set the node's cluster name") + baseCmd.PersistentFlags().StringVarP(&SetClusterName, "cluster", "c", "", "Set the node's cluster group") baseCmd.PersistentFlags().StringVarP(&SetIpxe, "ipxe", "P", "", "Set the node's iPXE template name") baseCmd.PersistentFlags().StringVarP(&SetRuntimeOverlay, "runtime", "R", "", "Set the node's runtime overlay") baseCmd.PersistentFlags().StringVarP(&SetSystemOverlay, "system", "S", "", "Set the node's system overlay") @@ -41,7 +41,7 @@ func init() { baseCmd.PersistentFlags().StringVar(&SetIpmiUsername, "ipmiuser", "", "Set the node's IPMI username") baseCmd.PersistentFlags().StringVar(&SetIpmiPassword, "ipmipass", "", "Set the node's IPMI password") - baseCmd.PersistentFlags().StringVarP(&SetNetDev, "netdev", "n", "", "Define the network device to configure") + baseCmd.PersistentFlags().StringVarP(&SetNetDev, "netdev", "N", "", "Define the network device to configure") baseCmd.PersistentFlags().StringVarP(&SetIpaddr, "ipaddr", "I", "", "Set the node's network device IP address") baseCmd.PersistentFlags().StringVarP(&SetNetmask, "netmask", "M", "", "Set the node's network device netmask") baseCmd.PersistentFlags().StringVarP(&SetGateway, "gateway", "G", "", "Set the node's network device gateway") diff --git a/internal/app/wwctl/ready/main.go b/internal/app/wwctl/ready/main.go index 1369b7fc..fec73de0 100644 --- a/internal/app/wwctl/ready/main.go +++ b/internal/app/wwctl/ready/main.go @@ -3,10 +3,10 @@ package ready import ( "fmt" "github.com/hpcng/warewulf/internal/pkg/config" + "github.com/hpcng/warewulf/internal/pkg/container" "github.com/hpcng/warewulf/internal/pkg/kernel" "github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/util" - "github.com/hpcng/warewulf/internal/pkg/vnfs" "github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/spf13/cobra" "os" @@ -36,8 +36,8 @@ func CobraRunE(cmd *cobra.Command, args []string) error { var runtimeo_good bool status := true - if node.Vnfs.Get() != "" { - vnfsImage := vnfs.ImageFile(node.Vnfs.Get()) + if node.ContainerName.Get() != "" { + vnfsImage := container.ImageFile(node.ContainerName.Get()) if util.IsFile(vnfsImage) == true { vnfs_good = true diff --git a/internal/app/wwctl/root.go b/internal/app/wwctl/root.go index 03efec60..72119651 100644 --- a/internal/app/wwctl/root.go +++ b/internal/app/wwctl/root.go @@ -1,13 +1,13 @@ package wwctl import ( + "github.com/hpcng/warewulf/internal/app/wwctl/container" "github.com/hpcng/warewulf/internal/app/wwctl/kernel" "github.com/hpcng/warewulf/internal/app/wwctl/node" "github.com/hpcng/warewulf/internal/app/wwctl/overlay" "github.com/hpcng/warewulf/internal/app/wwctl/profile" "github.com/hpcng/warewulf/internal/app/wwctl/ready" "github.com/hpcng/warewulf/internal/app/wwctl/service" - "github.com/hpcng/warewulf/internal/app/wwctl/vnfs" "github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/spf13/cobra" @@ -32,7 +32,7 @@ func init() { rootCmd.AddCommand(overlay.GetCommand()) // rootCmd.AddCommand(controller.GetCommand()) - rootCmd.AddCommand(vnfs.GetCommand()) + rootCmd.AddCommand(container.GetCommand()) rootCmd.AddCommand(node.GetCommand()) rootCmd.AddCommand(kernel.GetCommand()) // rootCmd.AddCommand(group.GetCommand()) diff --git a/internal/app/wwctl/vnfs/build/main.go b/internal/app/wwctl/vnfs/build/main.go deleted file mode 100644 index fa2330e1..00000000 --- a/internal/app/wwctl/vnfs/build/main.go +++ /dev/null @@ -1,79 +0,0 @@ -package build - -import ( - "github.com/hpcng/warewulf/internal/pkg/vnfs" - "github.com/hpcng/warewulf/internal/pkg/wwlog" - "github.com/spf13/cobra" - "os" -) - -func CobraRunE(cmd *cobra.Command, args []string) error { - - for _, arg := range args { - if vnfs.ValidSource(arg) == false { - wwlog.Printf(wwlog.ERROR, "VNFS name does not exist: %s\n", arg) - os.Exit(1) - } - - vnfs.Build(arg, BuildForce) - } - - /* - var nodes []node.NodeInfo - set := make(map[string]int) - - n, err := node.New() - if err != nil { - wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err) - os.Exit(1) - } - - if len(args) == 1 && ByNode == true { - var err error - nodes, err = n.SearchByName(args[0]) - if err != nil { - wwlog.Printf(wwlog.ERROR, "Could not find nodes for search term: %s\n", args[0]) - os.Exit(1) - } - - for _, node := range nodes { - if node.Vnfs.Defined() == true { - set[node.Vnfs.Get()]++ - } - } - - } else if BuildAll == true { - var err error - nodes, err = n.FindAllNodes() - if err != nil { - wwlog.Printf(wwlog.ERROR, "Could not get list of nodes: %s\n", err) - os.Exit(1) - } - - for _, node := range nodes { - if node.Vnfs.Defined() == true { - wwlog.Printf(wwlog.VERBOSE, "Adding VNFS to list: %s (%s)\n", node.Vnfs.Get(), node.Id.Get()) - set[node.Vnfs.Get()]++ - } - } - - } else if len(args) == 1 { - set[args[0]]++ - } else { - cmd.Usage() - os.Exit(1) - } - - for v := range set { - fmt.Printf("Building VNFS: %s\n", v) - err := vnfs.Build(v, BuildForce) - if err != nil { - wwlog.Printf(wwlog.ERROR, "%s\n", err) - os.Exit(1) - } - } - - */ - - return nil -} diff --git a/internal/app/wwctl/vnfs/build/root.go b/internal/app/wwctl/vnfs/build/root.go deleted file mode 100644 index 50dbdfdc..00000000 --- a/internal/app/wwctl/vnfs/build/root.go +++ /dev/null @@ -1,28 +0,0 @@ -package build - -import "github.com/spf13/cobra" - -var ( - baseCmd = &cobra.Command{ - Use: "build (vnfs location | node search pattern)", - Short: "VNFS Image Build", - Long: "VNFS kernel images", - RunE: CobraRunE, - Args: cobra.RangeArgs(0,1), - - } - BuildForce bool - BuildAll bool - ByNode bool -) - -func init() { - baseCmd.PersistentFlags().BoolVarP(&BuildAll, "all", "a", false, "(re)Build all VNFS images for all nodes") - baseCmd.PersistentFlags().BoolVarP(&BuildForce, "force", "f", false, "Force rebuild, even if it isn't necessary") - baseCmd.PersistentFlags().BoolVarP(&ByNode, "node", "n", false, "Build VNFS for a particular node(s)") -} - -// GetRootCommand returns the root cobra.Command for the application. -func GetCommand() *cobra.Command { - return baseCmd -} \ No newline at end of file diff --git a/internal/app/wwctl/vnfs/list/main.go b/internal/app/wwctl/vnfs/list/main.go deleted file mode 100644 index 2499fbac..00000000 --- a/internal/app/wwctl/vnfs/list/main.go +++ /dev/null @@ -1,89 +0,0 @@ -package list - -import ( - "fmt" - "github.com/hpcng/warewulf/internal/pkg/node" - "github.com/hpcng/warewulf/internal/pkg/util" - "github.com/hpcng/warewulf/internal/pkg/vnfs" - "github.com/hpcng/warewulf/internal/pkg/wwlog" - "github.com/spf13/cobra" - "os" -) - -func CobraRunE(cmd *cobra.Command, args []string) error { - - sources, err := vnfs.ListSources() - if err != nil { - wwlog.Printf(wwlog.ERROR, "%s\n", err) - os.Exit(1) - } - - nconfig, _ := node.New() - nodes, _ := nconfig.FindAllNodes() - nodemap := make(map[string]int) - - for _, n := range nodes { - nodemap[n.Vnfs.Get()]++ - } - - fmt.Printf("%-35s %-6s %-6s\n", "VNFS NAME", "BUILT", "NODES") - for _, source := range sources { - image := vnfs.ImageFile(source) - - if nodemap[source] == 0 { - nodemap[source] = 0 - } - fmt.Printf("%-35s %-6t %-6d\n", source, util.IsFile(image), nodemap[source]) - - } - - /* - nconfig, _ := node.New() - nodes, _ := nconfig.FindAllNodes() - nodemap := make(map[string]int) - - for _, n := range nodes { - nodemap[n.Vnfs.Get()]++ - } - - images, _ := ioutil.ReadDir(config.VnfsImageParentDir()) - - fmt.Printf("%-38s %-16s %s\n", "VNFS Name", "VNFS SIZE(k)", "NODES") - fmt.Println(strings.Repeat("=", 80)) - - for _, file := range images { - v, err := vnfs.Load(file.Name()) - if err == nil { - var vnfs_size int64 - if util.IsFile(config.VnfsImage(file.Name())) { - s, _ := os.Stat(config.VnfsImage(file.Name())) - vnfs_size = s.Size() / 1024 - } - - if nodemap[v.Source] > 0 { - fmt.Printf("%-38s %-16d %d\n", v.Source, vnfs_size, nodemap[v.Source]) - } else { - fmt.Printf("%-38s %-16d %d\n", v.Source, vnfs_size, 0) - } - - } - continue - - if util.IsDir(path.Join(config.VnfsImageParentDir(), file.Name())) { - var vnfs_size int64 - if util.IsFile(config.VnfsImage(file.Name())) { - s, _ := os.Stat(config.VnfsImage(file.Name())) - vnfs_size = s.Size() / 1024 - } - - if nodemap[file.Name()] > 0 { - fmt.Printf("%-38s %-16d %d\n", file.Name(), vnfs_size, nodemap[file.Name()]) - } else { - fmt.Printf("%-38s %-16d %d\n", file.Name(), vnfs_size, 0) - } - } - } - */ - - return nil -} diff --git a/internal/app/wwctl/vnfs/list/root.go b/internal/app/wwctl/vnfs/list/root.go deleted file mode 100644 index 80216bb9..00000000 --- a/internal/app/wwctl/vnfs/list/root.go +++ /dev/null @@ -1,25 +0,0 @@ -package list - -import "github.com/spf13/cobra" - -var ( - baseCmd = &cobra.Command{ - Use: "list", - Short: "List VNFS images", - Long: "List VNFS images ", - RunE: CobraRunE, - } - SystemOverlay bool - BuildAll bool -) - -func init() { - //baseCmd.PersistentFlags().BoolVarP(&SystemOverlay, "system", "s", false, "Show System Overlays as well") - //baseCmd.PersistentFlags().BoolVarP(&BuildAll, "all", "a", false, "Build all overlays (runtime and system)") - -} - -// GetRootCommand returns the root cobra.Command for the application. -func GetCommand() *cobra.Command { - return baseCmd -} diff --git a/internal/app/wwctl/vnfs/pull/main.go b/internal/app/wwctl/vnfs/pull/main.go deleted file mode 100644 index b85466fe..00000000 --- a/internal/app/wwctl/vnfs/pull/main.go +++ /dev/null @@ -1,54 +0,0 @@ -package pull - -import ( - "fmt" - "github.com/hpcng/warewulf/internal/pkg/util" - "github.com/hpcng/warewulf/internal/pkg/vnfs" - "github.com/hpcng/warewulf/internal/pkg/wwlog" - "github.com/spf13/cobra" - "os" - "path" -) - -func CobraRunE(cmd *cobra.Command, args []string) error { - var name string - uri := args[0] - - if len(args) == 2 { - name = args[1] - } else { - name = path.Base(uri) - fmt.Printf("Setting VNFS name: %s\n", name) - } - - if vnfs.ValidName(name) == false { - wwlog.Printf(wwlog.ERROR, "VNFS name contains illegal characters: %s\n", name) - os.Exit(1) - } - - fullPath := vnfs.SourceDir(name) - - if util.IsDir(fullPath) == true { - if SetForce == true { - wwlog.Printf(wwlog.WARN, "Overwriting existing VNFS\n") - err := os.RemoveAll(fullPath) - if err != nil { - wwlog.Printf(wwlog.ERROR, "%s\n", err) - os.Exit(1) - } - } else if SetUpdate == true { - wwlog.Printf(wwlog.WARN, "Updating existing VNFS\n") - } else { - wwlog.Printf(wwlog.ERROR, "VNFS Name exists, specify --force, --update, or choose a different name: %s\n", name) - os.Exit(1) - } - } - - err := vnfs.PullURI(uri, name) - if err != nil { - wwlog.Printf(wwlog.ERROR, "Could not pull image: %s\n", err) - os.Exit(1) - } - - return nil -} diff --git a/internal/app/wwctl/vnfs/pull/root.go b/internal/app/wwctl/vnfs/pull/root.go deleted file mode 100644 index 93d88329..00000000 --- a/internal/app/wwctl/vnfs/pull/root.go +++ /dev/null @@ -1,26 +0,0 @@ -package pull - -import "github.com/spf13/cobra" - -var ( - baseCmd = &cobra.Command{ - Use: "pull", - Short: "Pull Source OCI VNFS images", - Long: "Pull Source OCI VNFS images ", - RunE: CobraRunE, - Args: cobra.MinimumNArgs(1), - } - SetForce bool - SetUpdate bool -) - -func init() { - baseCmd.PersistentFlags().BoolVarP(&SetForce, "force", "f", false, "Force overwrite of an existing VNFS") - baseCmd.PersistentFlags().BoolVarP(&SetUpdate, "update", "u", false, "Update and overwrite an existing VNFS") - -} - -// GetRootCommand returns the root cobra.Command for the application. -func GetCommand() *cobra.Command { - return baseCmd -} diff --git a/internal/app/wwctl/vnfs/root.go b/internal/app/wwctl/vnfs/root.go deleted file mode 100644 index 0b10b5c2..00000000 --- a/internal/app/wwctl/vnfs/root.go +++ /dev/null @@ -1,29 +0,0 @@ -package vnfs - -import ( - "github.com/hpcng/warewulf/internal/app/wwctl/vnfs/build" - "github.com/hpcng/warewulf/internal/app/wwctl/vnfs/list" - "github.com/hpcng/warewulf/internal/app/wwctl/vnfs/pull" - "github.com/spf13/cobra" -) - -var ( - baseCmd = &cobra.Command{ - Use: "vnfs", - Short: "VNFS image management", - Long: "Virtual Node File System (VNFS) image management", - } - test bool -) - -func init() { - baseCmd.AddCommand(build.GetCommand()) - baseCmd.AddCommand(list.GetCommand()) - baseCmd.AddCommand(pull.GetCommand()) - -} - -// GetRootCommand returns the root cobra.Command for the application. -func GetCommand() *cobra.Command { - return baseCmd -} diff --git a/internal/pkg/vnfs/build.go b/internal/pkg/container/build.go similarity index 98% rename from internal/pkg/vnfs/build.go rename to internal/pkg/container/build.go index 101d6b7c..80ce972e 100644 --- a/internal/pkg/vnfs/build.go +++ b/internal/pkg/container/build.go @@ -1,4 +1,4 @@ -package vnfs +package container import ( "fmt" diff --git a/internal/pkg/vnfs/pull.go b/internal/pkg/container/pull.go similarity index 97% rename from internal/pkg/vnfs/pull.go rename to internal/pkg/container/pull.go index f9fd75aa..b559c4fe 100644 --- a/internal/pkg/vnfs/pull.go +++ b/internal/pkg/container/pull.go @@ -1,4 +1,4 @@ -package vnfs +package container import ( "context" diff --git a/internal/pkg/vnfs/vnfs.go b/internal/pkg/container/vnfs.go similarity index 95% rename from internal/pkg/vnfs/vnfs.go rename to internal/pkg/container/vnfs.go index ac40fc9e..0a3e6991 100644 --- a/internal/pkg/vnfs/vnfs.go +++ b/internal/pkg/container/vnfs.go @@ -1,4 +1,4 @@ -package vnfs +package container import ( "github.com/hpcng/warewulf/internal/pkg/config" @@ -31,7 +31,7 @@ func RootFsDir(name string) string { } func ImageParentDir() string { - return path.Join(config.LocalStateDir, "provision/vnfs/") + return path.Join(config.LocalStateDir, "provision/container/") } func ImageFile(name string) string { diff --git a/internal/pkg/node/constructors.go b/internal/pkg/node/constructors.go index 70070760..c7baedaa 100644 --- a/internal/pkg/node/constructors.go +++ b/internal/pkg/node/constructors.go @@ -59,7 +59,7 @@ func (self *nodeYaml) FindAllNodes() ([]NodeInfo, error) { n.Id.Set(nodename) n.Comment.Set(node.Comment) - n.Vnfs.Set(node.Vnfs) + n.ContainerName.Set(node.ContainerName) n.KernelVersion.Set(node.KernelVersion) n.KernelArgs.Set(node.KernelArgs) n.ClusterName.Set(node.ClusterName) @@ -97,7 +97,7 @@ func (self *nodeYaml) FindAllNodes() ([]NodeInfo, error) { n.Comment.SetAlt(self.NodeProfiles[p].Comment, pstring) n.ClusterName.SetAlt(self.NodeProfiles[p].ClusterName, pstring) - n.Vnfs.SetAlt(self.NodeProfiles[p].Vnfs, pstring) + n.ContainerName.SetAlt(self.NodeProfiles[p].ContainerName, pstring) n.KernelVersion.SetAlt(self.NodeProfiles[p].KernelVersion, pstring) n.KernelArgs.SetAlt(self.NodeProfiles[p].KernelArgs, pstring) n.Ipxe.SetAlt(self.NodeProfiles[p].Ipxe, pstring) @@ -140,7 +140,7 @@ func (self *nodeYaml) FindAllProfiles() ([]NodeInfo, error) { p.Id.Set(name) p.Comment.Set(profile.Comment) - p.Vnfs.Set(profile.Vnfs) + p.ContainerName.Set(profile.ContainerName) p.Ipxe.Set(profile.Ipxe) p.KernelVersion.Set(profile.KernelVersion) p.KernelArgs.Set(profile.KernelArgs) diff --git a/internal/pkg/node/datastructure.go b/internal/pkg/node/datastructure.go index 8cf4219a..cd7ea2eb 100644 --- a/internal/pkg/node/datastructure.go +++ b/internal/pkg/node/datastructure.go @@ -19,7 +19,7 @@ type NodeConf struct { Comment string `yaml:"comment,omitempty"` Disabled bool `yaml:"disabled,omitempty"` ClusterName string `yaml:"cluster name,omitempty"` - Vnfs string `yaml:"vnfs,omitempty"` + ContainerName string `yaml:"container name,omitempty"` Ipxe string `yaml:"ipxe template,omitempty"` KernelVersion string `yaml:"kernel version,omitempty"` KernelArgs string `yaml:"kernel args,omitempty"` @@ -60,7 +60,7 @@ type NodeInfo struct { Cid Entry Comment Entry ClusterName Entry - Vnfs Entry + ContainerName Entry Ipxe Entry KernelVersion Entry KernelArgs Entry diff --git a/internal/pkg/node/modifiers.go b/internal/pkg/node/modifiers.go index 49bf6f06..9b5773f4 100644 --- a/internal/pkg/node/modifiers.go +++ b/internal/pkg/node/modifiers.go @@ -54,7 +54,7 @@ func (self *nodeYaml) NodeUpdate(node NodeInfo) error { } self.Nodes[nodeID].Comment = node.Comment.GetReal() - self.Nodes[nodeID].Vnfs = node.Vnfs.GetReal() + self.Nodes[nodeID].ContainerName = node.ContainerName.GetReal() self.Nodes[nodeID].ClusterName = node.ClusterName.GetReal() self.Nodes[nodeID].Ipxe = node.Ipxe.GetReal() self.Nodes[nodeID].KernelVersion = node.KernelVersion.GetReal() @@ -125,7 +125,7 @@ func (self *nodeYaml) ProfileUpdate(profile NodeInfo) error { return errors.New("Profile name does not exist: " + profileID) } self.NodeProfiles[profileID].Comment = profile.Comment.GetReal() - self.NodeProfiles[profileID].Vnfs = profile.Vnfs.GetReal() + self.NodeProfiles[profileID].ContainerName = profile.ContainerName.GetReal() self.NodeProfiles[profileID].Ipxe = profile.Ipxe.GetReal() self.NodeProfiles[profileID].ClusterName = profile.ClusterName.GetReal() self.NodeProfiles[profileID].KernelVersion = profile.KernelVersion.GetReal() diff --git a/internal/pkg/oci/cache.go b/internal/pkg/oci/cache.go index 369efaf4..1f4231b4 100644 --- a/internal/pkg/oci/cache.go +++ b/internal/pkg/oci/cache.go @@ -10,7 +10,7 @@ import ( ) const ( - defaultCachePath = "/var/warewulf/vnfs-cache/oci/" + defaultCachePath = "/var/warewulf/container-cache/oci/" blobPrefix = "blobs" rootfsPrefix = "rootfs" ) diff --git a/internal/pkg/overlay/funcmap.go b/internal/pkg/overlay/funcmap.go index 7843a4ae..fbc08f85 100644 --- a/internal/pkg/overlay/funcmap.go +++ b/internal/pkg/overlay/funcmap.go @@ -1,7 +1,7 @@ package overlay import ( - "github.com/hpcng/warewulf/internal/pkg/vnfs" + "github.com/hpcng/warewulf/internal/pkg/container" "github.com/hpcng/warewulf/internal/pkg/wwlog" "io/ioutil" "path" @@ -17,24 +17,24 @@ func templateFileInclude(path string) string { return strings.TrimSuffix(string(content), "\n") } -func templateVnfsFileInclude(vnfsname string, filepath string) string { - wwlog.Printf(wwlog.DEBUG, "Including VNFS file into template: %s: %s\n", vnfsname, filepath) +func templateContainerFileInclude(containername string, filepath string) string { + wwlog.Printf(wwlog.DEBUG, "Including VNFS file into template: %s: %s\n", containername, filepath) - if vnfsname == "" { - wwlog.Printf(wwlog.WARN, "VNFS not set for template import request: %s: %s\n", vnfsname, filepath) + if containername == "" { + wwlog.Printf(wwlog.WARN, "VNFS not set for template import request: %s: %s\n", containername, filepath) return "" } - if vnfs.ValidSource(vnfsname) == false { - wwlog.Printf(wwlog.WARN, "Template required VNFS does not exist: %s\n", vnfsname) + if container.ValidSource(containername) == false { + wwlog.Printf(wwlog.WARN, "Template required VNFS does not exist: %s\n", containername) return "" } - vnfsDir := vnfs.RootFsDir(vnfsname) + containerDir := container.RootFsDir(containername) - wwlog.Printf(wwlog.DEBUG, "Including file from VNFS: %s:%s\n", vnfsDir, filepath) + wwlog.Printf(wwlog.DEBUG, "Including file from container: %s:%s\n", containerDir, filepath) - content, err := ioutil.ReadFile(path.Join(vnfsDir, filepath)) + content, err := ioutil.ReadFile(path.Join(containerDir, filepath)) if err != nil { wwlog.Printf(wwlog.ERROR, "Template include: %s\n", err) diff --git a/internal/pkg/overlay/overlay.go b/internal/pkg/overlay/overlay.go index 9f1e938b..3ac359a4 100644 --- a/internal/pkg/overlay/overlay.go +++ b/internal/pkg/overlay/overlay.go @@ -18,18 +18,16 @@ import ( ) type TemplateStruct struct { - Self struct { - Id string - Hostname string - GroupName string - Vnfs string - IpmiIpaddr string - IpmiNetmask string - IpmiUserName string - IpmiPassword string - NetDevs map[string]*node.NetDevs - } - AllNodes []node.NodeInfo + Id string + Hostname string + GroupName string + Container string + IpmiIpaddr string + IpmiNetmask string + IpmiUserName string + IpmiPassword string + NetDevs map[string]*node.NetDevs + AllNodes []node.NodeInfo } func BuildSystemOverlay(nodeList []node.NodeInfo) error { @@ -131,22 +129,22 @@ func buildOverlay(nodeList []node.NodeInfo, overlayType string) error { wwlog.Printf(wwlog.DEBUG, "Processing overlay for node: %s\n", n.Id.Get()) - t.Self.Id = n.Id.Get() - t.Self.Hostname = n.Id.Get() - t.Self.Vnfs = n.Vnfs.Get() - t.Self.IpmiIpaddr = n.IpmiIpaddr.Get() - t.Self.IpmiNetmask = n.IpmiNetmask.Get() - t.Self.IpmiUserName = n.IpmiUserName.Get() - t.Self.IpmiPassword = n.IpmiPassword.Get() - t.Self.NetDevs = make(map[string]*node.NetDevs) + t.Id = n.Id.Get() + t.Hostname = n.Id.Get() + t.Container = n.ContainerName.Get() + t.IpmiIpaddr = n.IpmiIpaddr.Get() + t.IpmiNetmask = n.IpmiNetmask.Get() + t.IpmiUserName = n.IpmiUserName.Get() + t.IpmiPassword = n.IpmiPassword.Get() + t.NetDevs = make(map[string]*node.NetDevs) for devname, netdev := range n.NetDevs { var nd node.NetDevs - t.Self.NetDevs[devname] = &nd - t.Self.NetDevs[devname].Hwaddr = netdev.Hwaddr.Get() - t.Self.NetDevs[devname].Ipaddr = netdev.Ipaddr.Get() - t.Self.NetDevs[devname].Netmask = netdev.Netmask.Get() - t.Self.NetDevs[devname].Gateway = netdev.Gateway.Get() - t.Self.NetDevs[devname].Type = netdev.Type.Get() + t.NetDevs[devname] = &nd + t.NetDevs[devname].Hwaddr = netdev.Hwaddr.Get() + t.NetDevs[devname].Ipaddr = netdev.Ipaddr.Get() + t.NetDevs[devname].Netmask = netdev.Netmask.Get() + t.NetDevs[devname].Gateway = netdev.Gateway.Get() + t.NetDevs[devname].Type = netdev.Type.Get() } t.AllNodes = allNodes @@ -203,8 +201,8 @@ func buildOverlay(nodeList []node.NodeInfo, overlayType string) error { destFile := strings.TrimSuffix(location, ".ww") tmpl, err := template.New(path.Base(location)).Funcs(template.FuncMap{ - "Include": templateFileInclude, - "IncludeFromVnfs": templateVnfsFileInclude, + "Include": templateFileInclude, + "IncludeFrom": templateContainerFileInclude, }).ParseGlob(path.Join(OverlayDir, destFile+".ww*")) if err != nil { wwlog.Printf(wwlog.ERROR, "%s\n", err) diff --git a/internal/pkg/vnfs_old/docker.go b/internal/pkg/vnfs_old/docker.go index a060c406..46bf8111 100644 --- a/internal/pkg/vnfs_old/docker.go +++ b/internal/pkg/vnfs_old/docker.go @@ -14,7 +14,7 @@ func BuildDocker(vnfs VnfsObject, buildForce bool) { wwlog.Printf(wwlog.VERBOSE, "Building OCI Container: %s\n", vnfs.Source) OciCacheDir := config.LocalStateDir + "/oci" - VnfsHashDir := config.LocalStateDir + "/oci/vnfs" + VnfsHashDir := config.LocalStateDir + "/oci/container" c, err := oci.NewCache(oci.OptSetCachePath(OciCacheDir)) if err != nil { diff --git a/internal/pkg/vnfs_old/vnfs.go b/internal/pkg/vnfs_old/vnfs.go index 32454fb9..79ae7a02 100644 --- a/internal/pkg/vnfs_old/vnfs.go +++ b/internal/pkg/vnfs_old/vnfs.go @@ -24,8 +24,8 @@ func Load(name string) (VnfsObject, error) { var ret VnfsObject if name == "" { - wwlog.Printf(wwlog.DEBUG, "Called vnfs.Load() without a name, returning error\n") - return ret, errors.New("Called vnfs.Load() without a VNFS name") + wwlog.Printf(wwlog.DEBUG, "Called container.Load() without a name, returning error\n") + return ret, errors.New("Called container.Load() without a VNFS name") } pathFriendlyName := CleanName(name) @@ -69,8 +69,8 @@ func New(source string) (VnfsObject, error) { var ret VnfsObject if source == "" { - wwlog.Printf(wwlog.DEBUG, "Called vnfs.Load() without a name, returning error\n") - return ret, errors.New("Called vnfs.Load() without a VNFS name") + wwlog.Printf(wwlog.DEBUG, "Called container.Load() without a name, returning error\n") + return ret, errors.New("Called container.Load() without a VNFS name") } if util.IsFile(ret.Config) { diff --git a/overlays/runtime/default/etc/group.ww b/overlays/runtime/default/etc/group.ww index ca59dd40..8005528f 100644 --- a/overlays/runtime/default/etc/group.ww +++ b/overlays/runtime/default/etc/group.ww @@ -1,2 +1,2 @@ -{{IncludeFromVnfs $.Self.Vnfs "/etc/group"}} +{{IncludeFrom $.Container "/etc/group"}} {{Include "/etc/group"}} diff --git a/overlays/runtime/default/etc/passwd.ww b/overlays/runtime/default/etc/passwd.ww index bd653b8a..e436e34b 100644 --- a/overlays/runtime/default/etc/passwd.ww +++ b/overlays/runtime/default/etc/passwd.ww @@ -1,3 +1,3 @@ root::0:0:root:/root:/bin/bash -{{IncludeFromVnfs $.Self.Vnfs "/etc/passwd"}} +{{IncludeFrom $.Container "/etc/passwd"}} {{Include "/etc/passwd"}} diff --git a/overlays/system/default/etc/hostname.ww b/overlays/system/default/etc/hostname.ww index 5bbffc40..b195826a 100644 --- a/overlays/system/default/etc/hostname.ww +++ b/overlays/system/default/etc/hostname.ww @@ -1 +1 @@ -{{$.Self.Id}} +{{$.Id}} diff --git a/overlays/system/default/etc/sysconfig/network-scripts/ifcfg-eth0.ww b/overlays/system/default/etc/sysconfig/network-scripts/ifcfg-eth0.ww index ce5ae245..a2fbee93 100644 --- a/overlays/system/default/etc/sysconfig/network-scripts/ifcfg-eth0.ww +++ b/overlays/system/default/etc/sysconfig/network-scripts/ifcfg-eth0.ww @@ -1,8 +1,8 @@ DEVICE=eth0 NAME=eth0 -IPADDR={{$.Self.NetDevs.eth0.Ipaddr}} -NETMASK={{$.Self.NetDevs.eth0.Netmask}} -GATEWAY={{$.Self.NetDevs.eth0.Gateway}} -HWADDR={{$.Self.NetDevs.eth0.Hwaddr}} +IPADDR={{$.NetDevs.eth0.Ipaddr}} +NETMASK={{$.NetDevs.eth0.Netmask}} +GATEWAY={{$.NetDevs.eth0.Gateway}} +HWADDR={{$.NetDevs.eth0.Hwaddr}} BOOTPROTO=static ONBOOT=yes diff --git a/overlays/system/default/etc/sysconfig/network.ww b/overlays/system/default/etc/sysconfig/network.ww index bcbd324d..08ba4073 100644 --- a/overlays/system/default/etc/sysconfig/network.ww +++ b/overlays/system/default/etc/sysconfig/network.ww @@ -1,2 +1,2 @@ NETWORKING=yes -HOSTNAME={{$.Self.Id}} +HOSTNAME={{$.Id}} diff --git a/overlays/system/default/ipmi.ww b/overlays/system/default/ipmi.ww index afd051bb..672ab940 100755 --- a/overlays/system/default/ipmi.ww +++ b/overlays/system/default/ipmi.ww @@ -8,10 +8,10 @@ if [ ! -e /dev/ipmi0 ]; then ls -la /dev/ipmi0 fi -IP="{{$.Self.IpmiIpaddr}}" -NETMASK="{{$.Self.IpmiNetmask}}" -USER="{{$.Self.IpmiUserName}}" -PASS="{{$.Self.IpmiPassword}}" +IP="{{$.IpmiIpaddr}}" +NETMASK="{{$.IpmiNetmask}}" +USER="{{$.IpmiUserName}}" +PASS="{{$.IpmiPassword}}" echo IP is $IP echo NETMASK is $NETMASK