Renamed vnfs to container, finished VNFS and kernel refactoring
This commit is contained in:
8
Makefile
8
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package vnfs
|
||||
package container
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -1,4 +1,4 @@
|
||||
package vnfs
|
||||
package container
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -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 {
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
defaultCachePath = "/var/warewulf/vnfs-cache/oci/"
|
||||
defaultCachePath = "/var/warewulf/container-cache/oci/"
|
||||
blobPrefix = "blobs"
|
||||
rootfsPrefix = "rootfs"
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
{{IncludeFromVnfs $.Self.Vnfs "/etc/group"}}
|
||||
{{IncludeFrom $.Container "/etc/group"}}
|
||||
{{Include "/etc/group"}}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
root::0:0:root:/root:/bin/bash
|
||||
{{IncludeFromVnfs $.Self.Vnfs "/etc/passwd"}}
|
||||
{{IncludeFrom $.Container "/etc/passwd"}}
|
||||
{{Include "/etc/passwd"}}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{{$.Self.Id}}
|
||||
{{$.Id}}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
NETWORKING=yes
|
||||
HOSTNAME={{$.Self.Id}}
|
||||
HOSTNAME={{$.Id}}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user