From 76a8b2c135b168d5e0f23e3c8c006ff5f24df83e Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Mon, 9 Nov 2020 10:32:30 -0800 Subject: [PATCH] Minor fixups for OCI implementation --- Makefile | 3 ++- cmd/wwbuild/vnfs-oci.go | 14 ++++++++++++- etc/nodes.conf | 2 +- internal/pkg/assets/assets.go | 38 +++++++++++++++++++++-------------- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index ed683a43..9247e807 100644 --- a/Makefile +++ b/Makefile @@ -46,12 +46,13 @@ files: all install -d -m 0755 /var/warewulf/ install -d -m 0755 /etc/warewulf/ install -d -m 0755 /etc/warewulf/ipxe - install -d -m 0755 /var/lib/tftpboot/warewulf/pxe/ + install -d -m 0755 /var/lib/tftpboot/warewulf/ipxe/ install -m 0640 etc/dhcpd.conf /etc/dhcp/dhcpd.conf install -m 0644 etc/nodes.conf /etc/warewulf/nodes.conf install -m 0644 etc/warewulf.conf /etc/warewulf/warewulf.conf install -m 0644 etc/ipxe/default.ipxe /etc/warewulf/ipxe/default.ipxe 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/ diff --git a/cmd/wwbuild/vnfs-oci.go b/cmd/wwbuild/vnfs-oci.go index 4c35793f..7d15555f 100644 --- a/cmd/wwbuild/vnfs-oci.go +++ b/cmd/wwbuild/vnfs-oci.go @@ -26,7 +26,7 @@ func vnfsOciBuild(OciPath string, wg *sync.WaitGroup) { os.Exit(1) } - ociDestination := fmt.Sprintf("%s/oci/vnfs/%s", LocalStateDir, path.Base(sourcePath)) + ociDestination := fmt.Sprintf("%s/oci/vnfs/hash/%s", LocalStateDir, path.Base(sourcePath)) name, err := os.Readlink(vnfsDestination) if err == nil { @@ -46,6 +46,11 @@ func vnfsOciBuild(OciPath string, wg *sync.WaitGroup) { fmt.Printf("ERROR: %s\n", err) return } + err = os.MkdirAll(LocalStateDir+"/oci/vnfs/name", 0755) + if err != nil { + fmt.Printf("ERROR: %s\n", err) + return + } err = buildVnfs(sourcePath, ociDestination) if err != nil { @@ -58,6 +63,13 @@ func vnfsOciBuild(OciPath string, wg *sync.WaitGroup) { fmt.Printf("ERROR: %s\n", err) os.Exit(1) } + + err = os.Symlink(sourcePath, LocalStateDir+"/oci/vnfs/name/"+path.Base(OciPath)) + if err != nil { + fmt.Printf("ERROR: %s\n", err) + os.Exit(1) + } + err = os.Rename(vnfsDestination+"-link", vnfsDestination) log.Printf("Completed building VNFS: %s\n", path.Base(OciPath)) diff --git a/etc/nodes.conf b/etc/nodes.conf index b5a10c32..6affbecc 100644 --- a/etc/nodes.conf +++ b/etc/nodes.conf @@ -29,7 +29,7 @@ nodegroups: ipmi ipaddr: x.x.x.x netdevs: eth0: - hwaddr: 00:0c:29:c3:bf:42 + hwaddr: 00:0c:29:23:8b:48 ipaddr: 192.168.1.100 netmask: 255.255.255.0 gateway: 192.168.1.1 diff --git a/internal/pkg/assets/assets.go b/internal/pkg/assets/assets.go index bcca7172..190b485a 100644 --- a/internal/pkg/assets/assets.go +++ b/internal/pkg/assets/assets.go @@ -4,6 +4,9 @@ import ( "fmt" "gopkg.in/yaml.v2" "io/ioutil" + "path" + "strings" + // "os" // "os" @@ -13,6 +16,7 @@ import ( ) const ConfigFile = "/etc/warewulf/nodes.conf" +const LocalStateDir = "/var/warewulf" func init() { //TODO: Check to make sure nodes.conf is found @@ -26,23 +30,23 @@ type nodeYaml struct { type nodeGroup struct { Comment string Vnfs string - Ipxe string `yaml:"ipxe template"` - SystemOverlay string `yaml:"system overlay""` - RuntimeOverlay string `yaml:"runtime overlay""` - DomainSuffix string `yaml:"domain suffix"` - KernelVersion string `yaml:"kernel version"` + Ipxe string `yaml:"ipxe template"` + SystemOverlay string `yaml:"system overlay""` + RuntimeOverlay string `yaml:"runtime overlay""` + DomainSuffix string `yaml:"domain suffix"` + KernelVersion string `yaml:"kernel version"` Nodes map[string]nodeEntry } type nodeEntry struct { Hostname string Vnfs string - Ipxe string `yaml:"ipxe template"` - SystemOverlay string `yaml:"system overlay"` - RuntimeOverlay string `yaml:"runtime overlay"` - DomainSuffix string `yaml:"domain suffix"` - KernelVersion string `yaml:"kernel version"` - IpmiIpaddr string `yaml:"ipmi ipaddr"` + Ipxe string `yaml:"ipxe template"` + SystemOverlay string `yaml:"system overlay"` + RuntimeOverlay string `yaml:"runtime overlay"` + DomainSuffix string `yaml:"domain suffix"` + KernelVersion string `yaml:"kernel version"` + IpmiIpaddr string `yaml:"ipmi ipaddr"` NetDevs map[string]netDevs } @@ -60,7 +64,7 @@ type NodeInfo struct { DomainName string Fqdn string Vnfs string - Ipxe string + Ipxe string SystemOverlay string RuntimeOverlay string KernelVersion string @@ -97,7 +101,6 @@ func FindAllNodes() ([]NodeInfo, error) { n.Ipxe = group.Ipxe n.NetDevs = node.NetDevs - if node.KernelVersion != "" { n.KernelVersion = node.KernelVersion } @@ -117,7 +120,6 @@ func FindAllNodes() ([]NodeInfo, error) { n.Ipxe = node.Ipxe } - if n.RuntimeOverlay == "" { n.RuntimeOverlay = "default" } @@ -134,6 +136,12 @@ func FindAllNodes() ([]NodeInfo, error) { n.Fqdn = node.Hostname } + if strings.HasPrefix(n.Vnfs, "docker://") { + //TODO: This is a kludge and shouldn't be done here. We need to go back + // and do this from a "vnfs" interface or package + n.Vnfs = LocalStateDir + "/oci/vnfs/name/" + path.Base(n.Vnfs) + } + ret = append(ret, n) } } @@ -286,4 +294,4 @@ func ListRuntimeOverlays() ([]string, error) { return ret, nil } - */ +*/