Cleanups and minor fixups

This commit is contained in:
Gregory Kurtzer
2020-12-13 22:45:08 -08:00
parent 487f45f7a9
commit 62a1abaab3
16 changed files with 73 additions and 44 deletions

View File

@@ -1,17 +1,17 @@
package system
package configure
import (
"fmt"
"github.com/hpcng/warewulf/internal/app/wwctl/system/dhcp"
"github.com/hpcng/warewulf/internal/app/wwctl/system/tftp"
"github.com/hpcng/warewulf/internal/app/wwctl/configure/dhcp"
"github.com/hpcng/warewulf/internal/app/wwctl/configure/tftp"
"github.com/spf13/cobra"
"os"
)
var (
baseCmd = &cobra.Command{
Use: "system",
Short: "Initialize Warewulf services",
Use: "configure",
Short: "Configure Warewulf services",
Long: "Warewulf Service Initialization",
RunE: CobraRunE,
}

View File

@@ -24,7 +24,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
container.Build(c, BuildForce)
output, err := container.Build(c, BuildForce)
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not build container %s: %s\n", c, err)
os.Exit(1)
} else {
fmt.Printf("%-20s: %s\n", c, output)
}
}
if SetDefault == true {

View File

@@ -36,5 +36,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
fmt.Printf("Rebuilding container...\n")
output, err := container.Build(containerName, false)
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not build container %s: %s\n", containerName, err)
os.Exit(1)
} else {
fmt.Printf("%s\n", output)
}
return nil
}

View File

@@ -52,7 +52,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
fmt.Printf("Building container: %s\n", name)
container.Build(name, true)
output, err := container.Build(name, true)
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not build container %s: %s\n", name, err)
os.Exit(1)
} else {
fmt.Printf("%s: %s\n", name, output)
}
if SetDefault == true {
nodeDB, err := node.New()

View File

@@ -12,10 +12,12 @@ import (
func CobraRunE(cmd *cobra.Command, args []string) error {
for _, arg := range args {
err := kernel.Build(arg)
output, err := kernel.Build(arg)
if err != nil {
wwlog.Printf(wwlog.ERROR, "Failed building kernel: %s\n", err)
os.Exit(1)
} else {
fmt.Printf("%s: %s\n", arg, output)
}
}

View File

@@ -102,6 +102,17 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SetDiscoverable == true {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting node to discoverable\n", n.Id.Get())
n.Discoverable.SetB(true)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
}
}
nodeDB.Persist()

View File

@@ -10,13 +10,14 @@ var (
RunE: CobraRunE,
Args: cobra.MinimumNArgs(1),
}
SetGroup string
SetController string
SetNetDev string
SetIpaddr string
SetNetmask string
SetGateway string
SetHwaddr string
SetGroup string
SetController string
SetNetDev string
SetIpaddr string
SetNetmask string
SetGateway string
SetHwaddr string
SetDiscoverable bool
)
func init() {
@@ -27,6 +28,7 @@ func init() {
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")
baseCmd.PersistentFlags().StringVarP(&SetHwaddr, "hwaddr", "H", "", "Set the node's network device HW address")
baseCmd.PersistentFlags().BoolVar(&SetDiscoverable, "discoverable", false, "Make this node discoverable")
}

View File

@@ -1,6 +1,7 @@
package wwctl
import (
"github.com/hpcng/warewulf/internal/app/wwctl/configure"
"github.com/hpcng/warewulf/internal/app/wwctl/container"
"github.com/hpcng/warewulf/internal/app/wwctl/kernel"
"github.com/hpcng/warewulf/internal/app/wwctl/node"
@@ -8,7 +9,6 @@ import (
"github.com/hpcng/warewulf/internal/app/wwctl/profile"
"github.com/hpcng/warewulf/internal/app/wwctl/ready"
"github.com/hpcng/warewulf/internal/app/wwctl/server"
"github.com/hpcng/warewulf/internal/app/wwctl/system"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/spf13/cobra"
@@ -38,7 +38,7 @@ func init() {
rootCmd.AddCommand(kernel.GetCommand())
// rootCmd.AddCommand(group.GetCommand())
rootCmd.AddCommand(profile.GetCommand())
rootCmd.AddCommand(system.GetCommand())
rootCmd.AddCommand(configure.GetCommand())
rootCmd.AddCommand(ready.GetCommand())
rootCmd.AddCommand(server.GetCommand())