From 2f2580e81b627d5b845e027152a0f7040db70518 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Tue, 12 Apr 2022 17:59:22 +0200 Subject: [PATCH] be more verbose --- .gitignore | 2 ++ .../update_configuration.go | 28 +++++++++++-------- cmd/update_configuration/vers42/nodes.conf | 19 +++++-------- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 1262a976..6c69adbb 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ /bash_completion /man_page /config_defaults +/update_configuration # other created files /man_pages @@ -24,3 +25,4 @@ _dist/ config warewulf-*.tar.gz Defaults.mk + diff --git a/cmd/update_configuration/update_configuration.go b/cmd/update_configuration/update_configuration.go index 853cc320..6729cdec 100644 --- a/cmd/update_configuration/update_configuration.go +++ b/cmd/update_configuration/update_configuration.go @@ -5,6 +5,7 @@ import ( "fmt" "io/ioutil" "os" + "reflect" "github.com/hpcng/warewulf/cmd/update_configuration/vers42" "github.com/hpcng/warewulf/cmd/update_configuration/vers43" @@ -16,6 +17,8 @@ import ( var nowrite bool var confFile string +const actvers int = 43 + type nodeVersionOnly struct { WWInternal int `yaml:"WW_INTERNAL"` } @@ -39,6 +42,7 @@ func saveConf(conf interface{}) { fmt.Printf("Could not get file mode: %s\n", err) os.Exit(1) } + fmt.Printf("writing configuration file %s as type %s\n", confFile, reflect.TypeOf(conf)) err = ioutil.WriteFile(confFile, out, info.Mode()) if err != nil { fmt.Printf("Could not write file: %s\n", err) @@ -72,17 +76,19 @@ func main() { fmt.Printf("Could open file %v\n", err) os.Exit(1) } - if startVers == 0 { - var getConf nodeVersionOnly - fmt.Printf("Unmarshaling the node configuration\n") - err = yaml.Unmarshal(data, &getConf) - if err != nil { - fmt.Printf("Could not unmarshall: %v\n", err) - } - fmt.Printf("Got version %v in %s\n", getConf.WWInternal, confFile) - if getConf.WWInternal == 0 { - startVers = 42 - } + var getConf nodeVersionOnly + fmt.Printf("Unmarshaling the node configuration\n") + err = yaml.Unmarshal(data, &getConf) + if err != nil { + fmt.Printf("Could not unmarshall: %v\n", err) + } + fmt.Printf("Got version %v in %s\n", getConf.WWInternal, confFile) + if getConf.WWInternal == actvers { + fmt.Printf("On actual version, bailing out\n") + os.Exit(0) + } + if startVers == 0 && getConf.WWInternal == 0 { + startVers = 42 } var conf42 vers42.NodeYaml conf42.NodeProfiles = make(map[string]*vers42.NodeConf) diff --git a/cmd/update_configuration/vers42/nodes.conf b/cmd/update_configuration/vers42/nodes.conf index ea8a2073..792e48a2 100644 --- a/cmd/update_configuration/vers42/nodes.conf +++ b/cmd/update_configuration/vers42/nodes.conf @@ -1,16 +1,12 @@ nodeprofiles: default: comment: This profile is automatically included for each node - runtime overlay: - - generic - discoverable: "false" + runtime overlay: "generic" + discoverable: false leap: comment: openSUSE leap - kernel: - override: 5.14.21 - ipmi: - netmask: 255.255.255.0 - discoverable: "false" + kernel version: "5.14.21" + ipmi netmask: "255.255.255.0" keys: foo: baar network devices: @@ -18,10 +14,9 @@ nodeprofiles: gateway: 1.1.1.1 nodes: node01: - system overlay: - - nodeover - discoverable: "true" + system overlay: "nodeoverlay" + discoverable: true network devices: eth0: ipaddr: 1.2.3.4 - default: "true" + default: true