API updates and fixes to CLI

This commit is contained in:
Gregory Kurtzer
2020-12-01 23:34:24 -08:00
parent 2f5fa95d14
commit 43ad7e570c
26 changed files with 168 additions and 163 deletions

View File

@@ -3,14 +3,12 @@ package build
import (
"github.com/hpcng/warewulf/internal/pkg/kernel"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/overlay"
"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 {
var nodes []node.NodeInfo
showHelp := true
@@ -46,7 +44,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
wwlog.Printf(wwlog.INFO, "Building VNFS images...\n")
for _, node := range nodes {
set[node.Vnfs.String()] ++
set[node.Vnfs.Get()]++
}
for e := range set {
vnfs.Build(e, buildForce)
@@ -60,7 +58,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
wwlog.Printf(wwlog.INFO, "Building Kernel images...\n")
for _, node := range nodes {
set[node.KernelVersion.String()] ++
set[node.KernelVersion.Get()]++
}
for e := range set {
kernel.Build(e)
@@ -71,14 +69,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
wwlog.Printf(wwlog.INFO, "Building System Overlays...\n")
showHelp = false
overlay.SystemBuild(nodes, buildForce)
// overlay.SystemBuild(nodes, buildForce)
}
if buildRuntimeOverlay == true || buildAll == true {
wwlog.Printf(wwlog.INFO, "Building Runtime Overlays...n")
showHelp = false
overlay.RuntimeBuild(nodes, buildForce)
// overlay.RuntimeBuild(nodes, buildForce)
}
if showHelp == true {

View File

@@ -34,22 +34,28 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "Warewulf", "Enable CMD", c.Services.Warewulfd.EnableCmd)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "Warewulf", "Restart CMD", c.Services.Warewulfd.RestartCmd)
fmt.Printf("%-15s %15s : %s = %t\n", c.Id, "DHCPD", "Enabled", c.Services.Dhcp.Enabled)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "DHCPD", "Template", c.Services.Dhcp.Template)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "DHCPD", "ConfigFile", c.Services.Dhcp.ConfigFile)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "DHCPD", "RangeStart", c.Services.Dhcp.RangeStart)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "DHCPD", "RangeEnd", c.Services.Dhcp.RangeEnd)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "DHCPD", "Enable CMD", c.Services.Dhcp.EnableCmd)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "DHCPD", "Restart CMD", c.Services.Dhcp.RestartCmd)
fmt.Printf("%-15s %15s : %s = %t\n", c.Id, "TFTP", "Enabled", c.Services.Tftp.Enabled)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "TFTP", "TftpRoot", c.Services.Tftp.TftpRoot)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "TFTP", "Enable CMD", c.Services.Tftp.EnableCmd)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "TFTP", "Restart CMD", c.Services.Tftp.RestartCmd)
fmt.Printf("%-15s %15s : %s = %t\n", c.Id, "NFS", "Enabled", c.Services.Nfs.Enabled)
for _, e := range c.Services.Nfs.Exports {
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "NFS", "Exports", e)
if c.Services.Dhcp.Enabled == true {
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "DHCPD", "Template", c.Services.Dhcp.Template)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "DHCPD", "ConfigFile", c.Services.Dhcp.ConfigFile)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "DHCPD", "RangeStart", c.Services.Dhcp.RangeStart)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "DHCPD", "RangeEnd", c.Services.Dhcp.RangeEnd)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "DHCPD", "Enable CMD", c.Services.Dhcp.EnableCmd)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "DHCPD", "Restart CMD", c.Services.Dhcp.RestartCmd)
}
fmt.Printf("%-15s %15s : %s = %t\n", c.Id, "TFTP", "Enabled", c.Services.Tftp.Enabled)
if c.Services.Tftp.Enabled == true {
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "TFTP", "TftpRoot", c.Services.Tftp.TftpRoot)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "TFTP", "Enable CMD", c.Services.Tftp.EnableCmd)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "TFTP", "Restart CMD", c.Services.Tftp.RestartCmd)
}
fmt.Printf("%-15s %15s : %s = %t\n", c.Id, "NFS", "Enabled", c.Services.Nfs.Enabled)
if c.Services.Nfs.Enabled == true {
for _, e := range c.Services.Nfs.Exports {
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "NFS", "Exports", e)
}
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "NFS", "Enable CMD", c.Services.Nfs.EnableCmd)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "NFS", "Restart CMD", c.Services.Nfs.RestartCmd)
}
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "NFS", "Enable CMD", c.Services.Nfs.EnableCmd)
fmt.Printf("%-15s %15s : %s = %s\n", c.Id, "NFS", "Restart CMD", c.Services.Nfs.RestartCmd)
}
} else {

View File

@@ -24,19 +24,18 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
if len(args) == 0 {
args = append(args, "localhost")
}
if SetAll == true {
var tmp []node.ControllerInfo
tmp, err = nodeDB.FindAllControllers()
controllers, err = nodeDB.FindAllControllers()
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
for _, c := range tmp {
controllers = append(controllers, c)
}
} else if len(args) > 0 {
} else {
var tmp []node.ControllerInfo
tmp, err = nodeDB.FindAllControllers()
if err != nil {
@@ -51,10 +50,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
}
} else {
cmd.Usage()
os.Exit(1)
}
for _, c := range controllers {

View File

@@ -4,17 +4,17 @@ import "github.com/spf13/cobra"
var (
baseCmd = &cobra.Command{
Use: "add",
Short: "Add a new node group",
Long: "Add a new node group ",
RunE: CobraRunE,
Args: cobra.MinimumNArgs(1),
Use: "add",
Short: "Add a new node group",
Long: "Add a new node group ",
RunE: CobraRunE,
Args: cobra.MinimumNArgs(1),
}
SetController string
)
func init() {
baseCmd.PersistentFlags().StringVarP(&SetController, "controller", "c", "default", "Controller to add group to")
baseCmd.PersistentFlags().StringVarP(&SetController, "controller", "c", "localhost", "Controller to add group to")
}

View File

@@ -6,7 +6,6 @@ import (
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra"
"os"
"reflect"
"strings"
)
@@ -23,23 +22,30 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
if ShowAll == true {
for _, group := range groups {
v := reflect.ValueOf(group)
typeOfS := v.Type()
fmt.Printf("################################################################################\n")
for i := 0; i< v.NumField(); i++ {
fmt.Printf("%-25s %s = %v\n", group.Id, typeOfS.Field(i).Name, v.Field(i).Interface())
}
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "Id", group.Id.Source(), group.Id.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "Controller", group.Cid.Source(), group.Cid.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "DomainName", group.DomainName.Source(), group.DomainName.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "VNFS", group.Vnfs.Source(), group.Vnfs.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "KernelVersion", group.KernelVersion.Source(), group.KernelVersion.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "KernelArgs", group.KernelArgs.Source(), group.KernelArgs.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "RuntimeOverlay", group.RuntimeOverlay.Source(), group.RuntimeOverlay.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "SystemOverlay", group.SystemOverlay.Source(), group.SystemOverlay.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "IPMI Netmask", group.IpmiNetmask.Source(), group.IpmiNetmask.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "IPMI UserName", group.IpmiUserName.Source(), group.IpmiUserName.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "IPMI Password", group.IpmiPassword.Source(), group.IpmiPassword.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "Ipxe", group.Ipxe.Source(), group.Ipxe.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", group.Id.Get(), "Profiles", "group", strings.Join(group.Profiles, ","))
}
} else {
fmt.Printf("%-22s %-16s %-16s %s\n", "GROUP NAME", "DOMAINNAME", "CONTROLLER", "PROFILES")
for _, g := range groups {
fmt.Printf("%-22s %-16s %-16s %s\n", g.Id, g.DomainName, g.Cid, strings.Join(g.Profiles, ","))
fmt.Printf("%-22s %-16s %-16s %s\n", g.Id.Get(), g.DomainName.Get(), g.Cid.Get(), strings.Join(g.Profiles, ","))
}
}
return nil
}

View File

@@ -25,19 +25,18 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
if len(args) == 0 {
args = append(args, "default")
}
if SetGroupAll == true {
var tmp []node.GroupInfo
tmp, err = nodeDB.FindAllGroups()
groups, err = nodeDB.FindAllGroups()
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
for _, g := range tmp {
groups = append(groups, g)
}
} else if len(args) > 0 {
} else {
var tmp []node.GroupInfo
tmp, err = nodeDB.FindAllGroups()
if err != nil {
@@ -47,15 +46,11 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
for _, a := range args {
for _, g := range tmp {
if g.Id == a {
if g.Id.Get() == a {
groups = append(groups, g)
}
}
}
} else {
cmd.Usage()
os.Exit(1)
}
for _, g := range groups {
@@ -63,7 +58,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetDomainName != "" {
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting domain name to: %s\n", g.Id, SetDomainName)
g.DomainName = SetDomainName
g.DomainName.SetGroup(SetDomainName)
err := nodeDB.GroupUpdate(g)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -73,7 +68,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetVnfs != "" {
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting VNFS to: %s\n", g.Id, SetVnfs)
g.Vnfs = SetVnfs
g.Vnfs.SetGroup(SetVnfs)
err := nodeDB.GroupUpdate(g)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -83,7 +78,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetKernel != "" {
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting kernel to: %s\n", g.Id, SetKernel)
g.KernelVersion = SetKernel
g.KernelVersion.SetGroup(SetKernel)
err := nodeDB.GroupUpdate(g)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -93,7 +88,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetIpmiNetmask != "" {
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting IPMI username to: %s\n", g.Id, SetIpmiNetmask)
g.IpmiNetmask = SetIpmiNetmask
g.IpmiNetmask.SetGroup(SetIpmiNetmask)
err := nodeDB.GroupUpdate(g)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -103,7 +98,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetIpmiUsername != "" {
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting IPMI username to: %s\n", g.Id, SetIpmiUsername)
g.IpmiUserName = SetIpmiUsername
g.IpmiUserName.SetGroup(SetIpmiUsername)
err := nodeDB.GroupUpdate(g)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -113,7 +108,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetIpmiPassword != "" {
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting IPMI password to: %s\n", g.Id, SetIpmiPassword)
g.IpmiPassword = SetIpmiPassword
g.IpmiPassword.SetGroup(SetIpmiPassword)
err := nodeDB.GroupUpdate(g)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -123,7 +118,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetSystemOverlay != "" {
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting system overlay to: %s\n", g.Id, SetSystemOverlay)
g.SystemOverlay = SetSystemOverlay
g.SystemOverlay.SetGroup(SetSystemOverlay)
err := nodeDB.GroupUpdate(g)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -133,7 +128,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetRuntimeOverlay != "" {
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting runtime overlay to: %s\n", g.Id, SetRuntimeOverlay)
g.RuntimeOverlay = SetRuntimeOverlay
g.RuntimeOverlay.SetGroup(SetRuntimeOverlay)
err := nodeDB.GroupUpdate(g)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)

View File

@@ -28,7 +28,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
for _, node := range nodes {
if node.KernelVersion.Defined() == true {
set[node.KernelVersion.Get()] ++
set[node.KernelVersion.Get()]++
}
}
@@ -41,14 +41,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
for _, node := range nodes {
wwlog.Printf(wwlog.DEBUG, "evaluating node/kernel: %s/%s\n", node.Fqdn.Get(), node.KernelVersion.String())
wwlog.Printf(wwlog.DEBUG, "evaluating node/kernel: %s/%s\n", node.Fqdn.Get(), node.KernelVersion.Get())
if node.KernelVersion.Defined() == true {
set[node.KernelVersion.Get()] ++
set[node.KernelVersion.Get()]++
}
}
} else if len(args) == 1 {
set[args[0]] ++
set[args[0]]++
} else {
cmd.Usage()
os.Exit(1)
@@ -64,4 +64,4 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
return nil
}
}

View File

@@ -19,7 +19,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodemap := make(map[string]int)
for _, n := range nodes {
nodemap[n.KernelVersion.String()] ++
nodemap[n.KernelVersion.Get()]++
}
images, _ := ioutil.ReadDir(config.KernelParentDir())
@@ -31,11 +31,11 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if util.IsDir(path.Join(config.KernelParentDir(), file.Name())) {
var kernel_size int64
var kmods_size int64
if util.IsFile( config.KernelImage(file.Name())) {
if util.IsFile(config.KernelImage(file.Name())) {
s, _ := os.Stat(config.KernelImage(file.Name()))
kernel_size = s.Size() / 1024
}
if util.IsFile( config.KmodsImage(file.Name())) {
if util.IsFile(config.KmodsImage(file.Name())) {
s, _ := os.Stat(config.KmodsImage(file.Name()))
kmods_size = s.Size() / 1024
}
@@ -48,6 +48,5 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
return nil
}
}

View File

@@ -4,19 +4,19 @@ import "github.com/spf13/cobra"
var (
baseCmd = &cobra.Command{
Use: "add",
Short: "Add new node",
Long: "Add new node ",
RunE: CobraRunE,
Args: cobra.MinimumNArgs(1),
Use: "add",
Short: "Add new node",
Long: "Add new node ",
RunE: CobraRunE,
Args: cobra.MinimumNArgs(1),
}
SetGroup string
SetGroup string
SetController string
)
func init() {
baseCmd.PersistentFlags().StringVarP(&SetGroup, "group", "g", "default", "Group to add nodes to")
baseCmd.PersistentFlags().StringVarP(&SetController, "controller", "c", "default", "Controller to add nodes to")
baseCmd.PersistentFlags().StringVarP(&SetController, "controller", "c", "localhost", "Controller to add nodes to")
}
// GetRootCommand returns the root cobra.Command for the application.

View File

@@ -21,7 +21,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodeList, err := nodeDB.SearchByNameList(args)
for _, n := range nodeList {
if SetGroup != "" && SetGroup != n.Gid.String() {
if SetGroup != "" && SetGroup != n.Gid.Print() {
wwlog.Printf(wwlog.DEBUG, "skipping node of different group: %s/%s\n", n.Gid, n.Id)
continue
}

View File

@@ -32,22 +32,22 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if ShowAll == true {
for _, node := range nodes {
fmt.Printf("################################################################################\n")
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "Id", node.Id.Source(), node.Id.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "Comment", node.Comment.Source(), node.Comment.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "GroupName", node.Gid.Source(), node.Gid.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "DomainName", node.DomainName.Source(), node.DomainName.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "Id", node.Id.Source(), node.Id.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "Comment", node.Comment.Source(), node.Comment.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "GroupName", node.Gid.Source(), node.Gid.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "DomainName", node.DomainName.Source(), node.DomainName.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "Profiles (Group)", "group", strings.Join(node.GroupProfiles, ","))
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "Profiles (Node)", "node", strings.Join(node.Profiles, ","))
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "Vnfs", node.Vnfs.Source(), node.Vnfs.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "KernelVersion", node.KernelVersion.Source(), node.KernelVersion.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "KernelArgs", node.KernelArgs.Source(), node.KernelArgs.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "RuntimeOverlay", node.RuntimeOverlay.Source(), node.RuntimeOverlay.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "SystemOverlay", node.SystemOverlay.Source(), node.SystemOverlay.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "Ipxe", node.Ipxe.Source(), node.Ipxe.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "IpmiIpaddr", node.IpmiIpaddr.Source(), node.IpmiIpaddr.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "IpmiNetmask", node.IpmiNetmask.Source(), node.IpmiNetmask.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "IpmiUserName", node.IpmiUserName.Source(), node.IpmiUserName.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "Vnfs", node.Vnfs.Source(), node.Vnfs.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "KernelVersion", node.KernelVersion.Source(), node.KernelVersion.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "KernelArgs", node.KernelArgs.Source(), node.KernelArgs.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "RuntimeOverlay", node.RuntimeOverlay.Source(), node.RuntimeOverlay.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "SystemOverlay", node.SystemOverlay.Source(), node.SystemOverlay.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "Ipxe", node.Ipxe.Source(), node.Ipxe.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "IpmiIpaddr", node.IpmiIpaddr.Source(), node.IpmiIpaddr.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "IpmiNetmask", node.IpmiNetmask.Source(), node.IpmiNetmask.Print())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "IpmiUserName", node.IpmiUserName.Source(), node.IpmiUserName.Print())
for name, netdev := range node.NetDevs {
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), name+":IPADDR", "node", netdev.Ipaddr)
@@ -83,7 +83,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Println(strings.Repeat("=", 80))
for _, node := range nodes {
fmt.Printf("%-22s %-16s %-20s %-20s\n", node.Fqdn.Get(), node.IpmiIpaddr.String(), node.IpmiUserName.String(), node.IpmiPassword.String())
fmt.Printf("%-22s %-16s %-20s %-20s\n", node.Fqdn.Get(), node.IpmiIpaddr.Print(), node.IpmiUserName.Print(), node.IpmiPassword.Print())
}
} else if ShowLong == true {
@@ -91,7 +91,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Println(strings.Repeat("=", 120))
for _, node := range nodes {
fmt.Printf("%-22s %-12s %-26s %-35s %s\n", node.Fqdn.Get(), node.Gid.String(), node.KernelVersion.String(), node.Vnfs.String(), node.SystemOverlay.String()+"/"+node.RuntimeOverlay.String())
fmt.Printf("%-22s %-12s %-26s %-35s %s\n", node.Fqdn.Get(), node.Gid.Print(), node.KernelVersion.Print(), node.Vnfs.Print(), node.SystemOverlay.Print()+"/"+node.RuntimeOverlay.Print())
}
} else {
@@ -99,7 +99,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Println(strings.Repeat("=", 80))
for _, node := range nodes {
fmt.Printf("%-22s %-30s %s\n", node.Fqdn.Get(), node.Vnfs.String(), strings.Join(append(node.GroupProfiles, node.Profiles...), ","))
fmt.Printf("%-22s %-30s %s\n", node.Fqdn.Get(), node.Vnfs.Print(), strings.Join(append(node.GroupProfiles, node.Profiles...), ","))
}
}

View File

@@ -34,13 +34,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
for _, node := range nodeList {
if node.IpmiIpaddr.String() == "" {
if node.IpmiIpaddr.Get() == "" {
wwlog.Printf(wwlog.ERROR, "%s: No IPMI IP address\n", node.HostName)
continue
}
ipmiCmd := power.IPMI{
HostName: node.IpmiIpaddr.String(),
HostName: node.IpmiIpaddr.Get(),
User: "ADMIN",
Password: "ADMIN",
AuthType: "MD5",

View File

@@ -36,13 +36,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var powerCmd power.PowerOnInterface
if node.IpmiIpaddr.String() == "" {
if node.IpmiIpaddr.Get() == "" {
wwlog.Printf(wwlog.ERROR, "%s: No IPMI IP address\n", node.HostName)
continue
}
ipmiCmd := power.IPMI{
HostName: node.IpmiIpaddr.String(),
HostName: node.IpmiIpaddr.Get(),
User: "ADMIN",
Password: "ADMIN",
AuthType: "MD5",

View File

@@ -34,13 +34,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
for _, node := range nodeList {
if node.IpmiIpaddr.String() == "" {
if node.IpmiIpaddr.Get() == "" {
wwlog.Printf(wwlog.ERROR, "%s: No IPMI IP address\n", node.HostName)
continue
}
ipmiCmd := power.IPMI{
HostName: node.IpmiIpaddr.String(),
HostName: node.IpmiIpaddr.Get(),
User: "ADMIN",
Password: "ADMIN",
AuthType: "MD5",

View File

@@ -44,12 +44,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
for _, n := range nodes {
wwlog.Printf(wwlog.VERBOSE, "Evaluating node: %s\n", n.Fqdn.String())
wwlog.Printf(wwlog.VERBOSE, "Evaluating node: %s\n", n.Fqdn.Get())
if SetVnfs != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting vnfs to: %s\n", n.Fqdn.String(), SetVnfs)
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting vnfs to: %s\n", n.Fqdn.Get(), SetVnfs)
n.Vnfs.Set(SetVnfs)
n.Vnfs.SetNode(SetVnfs)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -57,9 +57,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SetKernel != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting kernel to: %s\n", n.Fqdn.String(), SetKernel)
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting kernel to: %s\n", n.Fqdn.Get(), SetKernel)
n.KernelVersion.Set(SetKernel)
n.KernelVersion.SetNode(SetKernel)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -67,9 +67,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SetDomainName != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting domain name to: %s\n", n.Fqdn, SetDomainName)
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting domain name to: %s\n", n.Fqdn.Get(), SetDomainName)
n.DomainName.Set(SetDomainName)
n.DomainName.SetNode(SetDomainName)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -77,9 +77,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SetIpxe != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting iPXE template to: %s\n", n.Fqdn, SetIpxe)
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting iPXE template to: %s\n", n.Fqdn.Get(), SetIpxe)
n.Ipxe.Set(SetIpxe)
n.Ipxe.SetNode(SetIpxe)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -87,9 +87,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SetRuntimeOverlay != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting runtime overlay to: %s\n", n.Fqdn, SetRuntimeOverlay)
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting runtime overlay to: %s\n", n.Fqdn.Get(), SetRuntimeOverlay)
n.RuntimeOverlay.Set(SetRuntimeOverlay)
n.RuntimeOverlay.SetNode(SetRuntimeOverlay)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -97,9 +97,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SetSystemOverlay != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting system overlay to: %s\n", n.Fqdn, SetSystemOverlay)
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting system overlay to: %s\n", n.Fqdn.Get(), SetSystemOverlay)
n.SystemOverlay.Set(SetSystemOverlay)
n.SystemOverlay.SetNode(SetSystemOverlay)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -107,9 +107,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SetHostname != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting hostname to: %s\n", n.Fqdn, SetHostname)
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting hostname to: %s\n", n.Fqdn.Get(), SetHostname)
n.HostName.Set(SetHostname)
n.HostName.SetNode(SetHostname)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -117,9 +117,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SetIpmiIpaddr != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP address to: %s\n", n.Fqdn, SetIpmiIpaddr)
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP address to: %s\n", n.Fqdn.Get(), SetIpmiIpaddr)
n.IpmiIpaddr.Set(SetIpmiIpaddr)
n.IpmiIpaddr.SetNode(SetIpmiIpaddr)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -127,9 +127,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SetIpmiNetmask != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI netmask to: %s\n", n.Fqdn, SetIpmiNetmask)
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI netmask to: %s\n", n.Fqdn.Get(), SetIpmiNetmask)
n.IpmiNetmask.Set(SetIpmiNetmask)
n.IpmiNetmask.SetNode(SetIpmiNetmask)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -137,9 +137,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SetIpmiUsername != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP username to: %s\n", n.Fqdn, SetIpmiUsername)
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP username to: %s\n", n.Fqdn.Get(), SetIpmiUsername)
n.IpmiUserName.Set(SetIpmiUsername)
n.IpmiUserName.SetNode(SetIpmiUsername)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -147,9 +147,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SetIpmiPassword != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP password to: %s\n", n.Fqdn, SetIpmiPassword)
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP password to: %s\n", n.Fqdn.Get(), SetIpmiPassword)
n.IpmiPassword.Set(SetIpmiPassword)
n.IpmiPassword.SetNode(SetIpmiPassword)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)

View File

@@ -25,9 +25,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
for _, node := range nodes {
if SystemOverlay == true && node.SystemOverlay.String() == args[0] {
if SystemOverlay == true && node.SystemOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
} else if node.RuntimeOverlay.String() == args[0] {
} else if node.RuntimeOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
}
}
@@ -59,4 +59,4 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
return nil
}
}

View File

@@ -64,9 +64,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var updateNodes []node.NodeInfo
for _, node := range nodes {
if SystemOverlay == true && node.SystemOverlay.String() == overlayName {
if SystemOverlay == true && node.SystemOverlay.Get() == overlayName {
updateNodes = append(updateNodes, node)
} else if node.RuntimeOverlay.String() == overlayName {
} else if node.RuntimeOverlay.Get() == overlayName {
updateNodes = append(updateNodes, node)
}
}
@@ -81,4 +81,4 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
return nil
}
}

View File

@@ -8,8 +8,6 @@ import (
"os"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
cmd.Help()
@@ -48,9 +46,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var updateNodes []node.NodeInfo
for _, node := range nodes {
if SystemOverlay == true && node.SystemOverlay.String() == args[0] {
if SystemOverlay == true && node.SystemOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
} else if node.RuntimeOverlay.String() == args[0] {
} else if node.RuntimeOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
}
}
@@ -64,6 +62,5 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
return nil
}
}

View File

@@ -110,9 +110,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var updateNodes []node.NodeInfo
for _, node := range nodes {
if SystemOverlay == true && node.SystemOverlay.String() == args[0] {
if SystemOverlay == true && node.SystemOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
} else if node.RuntimeOverlay.String() == args[0] {
} else if node.RuntimeOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
}
}
@@ -127,4 +127,4 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
return nil
}
}

View File

@@ -107,9 +107,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var updateNodes []node.NodeInfo
for _, node := range nodes {
if SystemOverlay == true && node.SystemOverlay.String() == args[0] {
if SystemOverlay == true && node.SystemOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
} else if node.RuntimeOverlay.String() == args[0] {
} else if node.RuntimeOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
}
}

View File

@@ -60,9 +60,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var updateNodes []node.NodeInfo
for _, node := range nodes {
if SystemOverlay == true && node.SystemOverlay.String() == overlayName {
if SystemOverlay == true && node.SystemOverlay.Get() == overlayName {
updateNodes = append(updateNodes, node)
} else if node.RuntimeOverlay.String() == overlayName {
} else if node.RuntimeOverlay.Get() == overlayName {
updateNodes = append(updateNodes, node)
}
}
@@ -78,4 +78,4 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
return nil
}
}

View File

@@ -15,8 +15,7 @@ import (
func CobraRunE(cmd *cobra.Command, args []string) error {
config := config.New()
var overlaySourceDir string
// mode := uint32(strconv.ParseUint(PermMode, 8, 32))
// mode := uint32(strconv.ParseUint(PermMode, 8, 32))
if SystemOverlay == true {
overlaySourceDir = config.SystemOverlaySource(args[0])
@@ -57,9 +56,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var updateNodes []node.NodeInfo
for _, node := range nodes {
if SystemOverlay == true && node.SystemOverlay.String() == args[0] {
if SystemOverlay == true && node.SystemOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
} else if node.RuntimeOverlay.String() == args[0] {
} else if node.RuntimeOverlay.Get() == args[0] {
updateNodes = append(updateNodes, node)
}
}
@@ -74,4 +73,4 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
return nil
}
}

View File

@@ -24,6 +24,10 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
if len(args) == 0 {
args = append(args, "default")
}
if SetAll == true {
var tmp []node.ProfileInfo
tmp, err = nodeDB.FindAllProfiles()
@@ -36,7 +40,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
profiles = append(profiles, p)
}
} else if len(args) > 0 {
} else {
var tmp []node.ProfileInfo
tmp, err = nodeDB.FindAllProfiles()
if err != nil {
@@ -51,10 +55,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
}
} else {
cmd.Usage()
os.Exit(1)
}
for _, p := range profiles {

View File

@@ -7,6 +7,7 @@ import (
"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"
@@ -39,6 +40,7 @@ func init() {
rootCmd.AddCommand(group.GetCommand())
rootCmd.AddCommand(profile.GetCommand())
rootCmd.AddCommand(service.GetCommand())
rootCmd.AddCommand(ready.GetCommand())
}

View File

@@ -133,8 +133,16 @@ func ConfigureDHCP() error {
}
fmt.Printf("Enabling and restarting the DHCP services\n")
util.ExecInteractive("/bin/sh", "-c", controller.Services.Dhcp.EnableCmd)
util.ExecInteractive("/bin/sh", "-c", controller.Services.Dhcp.RestartCmd)
if controller.Services.Dhcp.EnableCmd != "" {
util.ExecInteractive("/bin/sh", "-c", controller.Services.Dhcp.EnableCmd)
} else {
util.ExecInteractive("/bin/sh", "-c", "systemctl enable dhcpd")
}
if controller.Services.Dhcp.RestartCmd != "" {
util.ExecInteractive("/bin/sh", "-c", controller.Services.Dhcp.RestartCmd)
} else {
util.ExecInteractive("/bin/sh", "-c", "systemctl restart dhcpd")
}
} else {
err = tmpl.Execute(os.Stdout, d)

View File

@@ -9,7 +9,7 @@ var (
baseCmd = &cobra.Command{
Use: "service",
Short: "Initialize Warewulf services",
Long: "Warewulf Initialization",
Long: "Warewulf Service Initialization",
}
)