UI Updates with a few minor fixups scattered here and there
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
package hosts
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
"bytes"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
@@ -15,12 +16,17 @@ type TemplateStruct struct {
|
||||
PrevHostFile string
|
||||
Ipaddr string
|
||||
Fqdn string
|
||||
AllNodes []node.NodeInfo
|
||||
AllNodes []node.NodeInfo
|
||||
}
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
var replace TemplateStruct
|
||||
|
||||
if SetShow == false && SetPersist == false {
|
||||
fmt.Println(cmd.Help())
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if util.IsFile("/etc/warewulf/hosts.tmpl") == false {
|
||||
wwlog.Printf(wwlog.WARN, "Template not found, not updating host file\n")
|
||||
return nil
|
||||
@@ -50,7 +56,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
wwlog.Printf(wwlog.WARN, "%s\n", err)
|
||||
} else {
|
||||
// if /etc/hosts.ww does not exist, backup /etc/hosts to /etc/hosts.wwbackup
|
||||
if ! util.IsFile("/etc/hosts.wwbackup") {
|
||||
if !util.IsFile("/etc/hosts.wwbackup") {
|
||||
err = util.CopyFile("/etc/hosts", "/etc/hosts.wwbackup")
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
|
||||
@@ -5,15 +5,18 @@ import "github.com/spf13/cobra"
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "hosts",
|
||||
Short: "NFS configuration",
|
||||
Long: "NFS Config",
|
||||
RunE: CobraRunE,
|
||||
Short: "Update the /etc/hosts file",
|
||||
Long: "Write out the /etc/hosts file based on the Warewulf template (hosts.tmpl) in the\n" +
|
||||
"Warewulf configuration directory.",
|
||||
RunE: CobraRunE,
|
||||
}
|
||||
SetShow bool
|
||||
SetShow bool
|
||||
SetPersist bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().BoolVarP(&SetShow, "show", "s", false, "Show configuration (don't update)")
|
||||
baseCmd.PersistentFlags().BoolVar(&SetShow, "persist", false, "Persist the configuration and initialize the service")
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
|
||||
Reference in New Issue
Block a user