Merge pull request #388 from mslacken/add-comp-yaml

Add comp yaml
This commit is contained in:
Christian Goll
2022-04-14 13:57:10 +02:00
committed by GitHub
7 changed files with 77 additions and 14 deletions

View File

@@ -38,7 +38,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "Cluster", node.ClusterName.Source(), node.ClusterName.Print()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "Cluster", 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(), "Profiles", "--", strings.Join(node.Profiles, ","))
fmt.Printf("%-20s %-18s %-12s %t\n", node.Id.Get(), "Discoverable", node.Discoverable.Source(), node.Discoverable.PrintB()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "Discoverable", node.Discoverable.Source(), node.Discoverable.PrintB())
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "Container", node.ContainerName.Source(), node.ContainerName.Print()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "Container", node.ContainerName.Source(), node.ContainerName.Print())
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "KernelOverride", node.Kernel.Override.Source(), node.Kernel.Override.Print()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "KernelOverride", node.Kernel.Override.Source(), node.Kernel.Override.Print())
@@ -56,6 +56,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "IpmiGateway", node.Ipmi.Gateway.Source(), node.Ipmi.Gateway.Print()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "IpmiGateway", node.Ipmi.Gateway.Source(), node.Ipmi.Gateway.Print())
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "IpmiUserName", node.Ipmi.UserName.Source(), node.Ipmi.UserName.Print()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "IpmiUserName", node.Ipmi.UserName.Source(), node.Ipmi.UserName.Print())
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "IpmiInterface", node.Ipmi.Interface.Source(), node.Ipmi.Interface.Print()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "IpmiInterface", node.Ipmi.Interface.Source(), node.Ipmi.Interface.Print())
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "IpmiWrite", node.Ipmi.Interface.Source(), node.Ipmi.Write.Print())
for keyname, key := range node.Tags { for keyname, key := range node.Tags {
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "Tag["+keyname+"]", key.Source(), key.Print()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "Tag["+keyname+"]", key.Source(), key.Print())
@@ -69,8 +70,8 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":NETMASK", netdev.Netmask.Source(), netdev.Netmask.Print()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":NETMASK", netdev.Netmask.Source(), netdev.Netmask.Print())
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":GATEWAY", netdev.Gateway.Source(), netdev.Gateway.Print()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":GATEWAY", netdev.Gateway.Source(), netdev.Gateway.Print())
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":TYPE", netdev.Type.Source(), netdev.Type.Print()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":TYPE", netdev.Type.Source(), netdev.Type.Print())
fmt.Printf("%-20s %-18s %-12s %t\n", node.Id.Get(), name+":ONBOOT", netdev.OnBoot.Source(), netdev.OnBoot.PrintB()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":ONBOOT", netdev.OnBoot.Source(), netdev.OnBoot.PrintB())
fmt.Printf("%-20s %-18s %-12s %t\n", node.Id.Get(), name+":DEFAULT", netdev.Default.Source(), netdev.Default.PrintB()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":DEFAULT", netdev.Default.Source(), netdev.Default.PrintB())
for keyname, key := range netdev.Tags { for keyname, key := range netdev.Tags {
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":TAG["+keyname+"]", key.Source(), key.Print()) fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name+":TAG["+keyname+"]", key.Source(), key.Print())
} }

View File

@@ -47,6 +47,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "IpmiGateway", profile.Ipmi.Gateway.Print()) fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "IpmiGateway", profile.Ipmi.Gateway.Print())
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "IpmiUserName", profile.Ipmi.UserName.Print()) fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "IpmiUserName", profile.Ipmi.UserName.Print())
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "IpmiInterface", profile.Ipmi.Interface.Print()) fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "IpmiInterface", profile.Ipmi.Interface.Print())
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "IpmiWrite", profile.Ipmi.Write.PrintB())
for keyname, key := range profile.Tags { for keyname, key := range profile.Tags {
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "Tag["+keyname+"]", key.Print()) fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "Tag["+keyname+"]", key.Print())
@@ -58,8 +59,8 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), name+":GATEWAY", netdev.Gateway.Print()) fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), name+":GATEWAY", netdev.Gateway.Print())
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), name+":HWADDR", netdev.Hwaddr.Print()) fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), name+":HWADDR", netdev.Hwaddr.Print())
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), name+":TYPE", netdev.Hwaddr.Print()) fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), name+":TYPE", netdev.Hwaddr.Print())
fmt.Printf("%-20s %-18s %t\n", profile.Id.Get(), name+":ONBOOT", netdev.OnBoot.PrintB()) fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), name+":ONBOOT", netdev.OnBoot.PrintB())
fmt.Printf("%-20s %-18s %t\n", profile.Id.Get(), name+":DEFAULT", netdev.Default.PrintB()) fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), name+":DEFAULT", netdev.Default.PrintB())
for keyname, key := range netdev.Tags { for keyname, key := range netdev.Tags {
fmt.Printf("%-20s %-18s %-12s %s\n", profile.Id.Get(), name+":TAG["+keyname+"]", key.Source(), key.Print()) fmt.Printf("%-20s %-18s %-12s %s\n", profile.Id.Get(), name+":TAG["+keyname+"]", key.Source(), key.Print())
} }

View File

@@ -88,6 +88,24 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
n.ClusterName.Set(node.ClusterName) n.ClusterName.Set(node.ClusterName)
n.Ipxe.Set(node.Ipxe) n.Ipxe.Set(node.Ipxe)
n.Init.Set(node.Init) n.Init.Set(node.Init)
// backward compatibility for old Ipmi config
n.Ipmi.Ipaddr.Set(node.IpmiIpaddr)
n.Ipmi.Netmask.Set(node.IpmiNetmask)
n.Ipmi.Port.Set(node.IpmiPort)
n.Ipmi.Gateway.Set(node.IpmiGateway)
n.Ipmi.UserName.Set(node.IpmiUserName)
n.Ipmi.Password.Set(node.IpmiPassword)
n.Ipmi.Interface.Set(node.IpmiInterface)
n.Ipmi.Write.Set(node.IpmiWrite)
// delete deprectated structures so that they do not get unmarshalled
node.IpmiIpaddr = ""
node.IpmiNetmask = ""
node.IpmiGateway = ""
node.IpmiUserName = ""
node.IpmiPassword = ""
node.IpmiInterface = ""
node.IpmiWrite = ""
if node.Ipmi != nil { if node.Ipmi != nil {
n.Ipmi.Ipaddr.Set(node.Ipmi.Ipaddr) n.Ipmi.Ipaddr.Set(node.Ipmi.Ipaddr)
n.Ipmi.Netmask.Set(node.Ipmi.Netmask) n.Ipmi.Netmask.Set(node.Ipmi.Netmask)
@@ -96,13 +114,20 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
n.Ipmi.UserName.Set(node.Ipmi.UserName) n.Ipmi.UserName.Set(node.Ipmi.UserName)
n.Ipmi.Password.Set(node.Ipmi.Password) n.Ipmi.Password.Set(node.Ipmi.Password)
n.Ipmi.Interface.Set(node.Ipmi.Interface) n.Ipmi.Interface.Set(node.Ipmi.Interface)
n.Ipmi.Write.SetB(node.Ipmi.Write) n.Ipmi.Write.Set(node.Ipmi.Write)
} }
n.SystemOverlay.SetSlice(node.SystemOverlay) n.SystemOverlay.SetSlice(node.SystemOverlay)
n.RuntimeOverlay.SetSlice(node.RuntimeOverlay) n.RuntimeOverlay.SetSlice(node.RuntimeOverlay)
n.Root.Set(node.Root) n.Root.Set(node.Root)
n.AssetKey.Set(node.AssetKey) n.AssetKey.Set(node.AssetKey)
n.Discoverable.Set(node.Discoverable) n.Discoverable.Set(node.Discoverable)
// backward compatibility
n.Kernel.Args.Set(node.KernelArgs)
n.Kernel.Override.Set(node.KernelOverride)
n.Kernel.Override.Set(node.KernelVersion)
node.KernelArgs = ""
node.KernelOverride = ""
node.KernelVersion = ""
if node.Kernel != nil { if node.Kernel != nil {
n.Kernel.Args.Set(node.Kernel.Args) n.Kernel.Args.Set(node.Kernel.Args)
@@ -198,7 +223,7 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
n.Ipmi.UserName.SetAlt(config.NodeProfiles[p].Ipmi.UserName, p) n.Ipmi.UserName.SetAlt(config.NodeProfiles[p].Ipmi.UserName, p)
n.Ipmi.Password.SetAlt(config.NodeProfiles[p].Ipmi.Password, p) n.Ipmi.Password.SetAlt(config.NodeProfiles[p].Ipmi.Password, p)
n.Ipmi.Interface.SetAlt(config.NodeProfiles[p].Ipmi.Interface, p) n.Ipmi.Interface.SetAlt(config.NodeProfiles[p].Ipmi.Interface, p)
n.Ipmi.Write.SetB(config.NodeProfiles[p].Ipmi.Write) n.Ipmi.Write.SetAlt(config.NodeProfiles[p].Ipmi.Write, p)
} }
n.SystemOverlay.SetAltSlice(config.NodeProfiles[p].SystemOverlay, p) n.SystemOverlay.SetAltSlice(config.NodeProfiles[p].SystemOverlay, p)
n.RuntimeOverlay.SetAltSlice(config.NodeProfiles[p].RuntimeOverlay, p) n.RuntimeOverlay.SetAltSlice(config.NodeProfiles[p].RuntimeOverlay, p)
@@ -291,6 +316,13 @@ func (config *nodeYaml) FindAllProfiles() ([]NodeInfo, error) {
p.ContainerName.Set(profile.ContainerName) p.ContainerName.Set(profile.ContainerName)
p.Ipxe.Set(profile.Ipxe) p.Ipxe.Set(profile.Ipxe)
p.Init.Set(profile.Init) p.Init.Set(profile.Init)
// backward compatibility
p.Kernel.Args.Set(profile.KernelArgs)
p.Kernel.Override.Set(profile.KernelOverride)
p.Kernel.Override.Set(profile.KernelVersion)
profile.KernelArgs = ""
profile.KernelOverride = ""
profile.KernelVersion = ""
if profile.Kernel != nil { if profile.Kernel != nil {
p.Kernel.Args.Set(profile.Kernel.Args) p.Kernel.Args.Set(profile.Kernel.Args)
if profile.Kernel.Override != "" { if profile.Kernel.Override != "" {
@@ -299,6 +331,23 @@ func (config *nodeYaml) FindAllProfiles() ([]NodeInfo, error) {
p.Kernel.Override.Set(profile.Kernel.Version) p.Kernel.Override.Set(profile.Kernel.Version)
} }
} }
// backward compatibility for old Ipmi config
p.Ipmi.Ipaddr.Set(profile.IpmiIpaddr)
p.Ipmi.Netmask.Set(profile.IpmiNetmask)
p.Ipmi.Port.Set(profile.IpmiPort)
p.Ipmi.Gateway.Set(profile.IpmiGateway)
p.Ipmi.UserName.Set(profile.IpmiUserName)
p.Ipmi.Password.Set(profile.IpmiPassword)
p.Ipmi.Interface.Set(profile.IpmiInterface)
p.Ipmi.Write.Set(profile.IpmiWrite)
// delete deprectated structures so that they do not get unmarshalled
profile.IpmiIpaddr = ""
profile.IpmiNetmask = ""
profile.IpmiGateway = ""
profile.IpmiUserName = ""
profile.IpmiPassword = ""
profile.IpmiInterface = ""
profile.IpmiWrite = ""
if profile.Ipmi != nil { if profile.Ipmi != nil {
p.Ipmi.Netmask.Set(profile.Ipmi.Netmask) p.Ipmi.Netmask.Set(profile.Ipmi.Netmask)
p.Ipmi.Port.Set(profile.Ipmi.Port) p.Ipmi.Port.Set(profile.Ipmi.Port)
@@ -306,7 +355,7 @@ func (config *nodeYaml) FindAllProfiles() ([]NodeInfo, error) {
p.Ipmi.UserName.Set(profile.Ipmi.UserName) p.Ipmi.UserName.Set(profile.Ipmi.UserName)
p.Ipmi.Password.Set(profile.Ipmi.Password) p.Ipmi.Password.Set(profile.Ipmi.Password)
p.Ipmi.Interface.Set(profile.Ipmi.Interface) p.Ipmi.Interface.Set(profile.Ipmi.Interface)
p.Ipmi.Write.SetB(profile.Ipmi.Write) p.Ipmi.Write.Set(profile.Ipmi.Write)
} }
p.RuntimeOverlay.SetSlice(profile.RuntimeOverlay) p.RuntimeOverlay.SetSlice(profile.RuntimeOverlay)
p.SystemOverlay.SetSlice(profile.SystemOverlay) p.SystemOverlay.SetSlice(profile.SystemOverlay)

View File

@@ -23,6 +23,17 @@ type NodeConf struct {
ClusterName string `yaml:"cluster name,omitempty"` ClusterName string `yaml:"cluster name,omitempty"`
ContainerName string `yaml:"container name,omitempty"` ContainerName string `yaml:"container name,omitempty"`
Ipxe string `yaml:"ipxe template,omitempty"` Ipxe string `yaml:"ipxe template,omitempty"`
KernelVersion string `yaml:"kernel version,omitempty"`
KernelOverride string `yaml:"kernel override,omitempty"`
KernelArgs string `yaml:"kernel args,omitempty"`
IpmiUserName string `yaml:"ipmi username,omitempty"`
IpmiPassword string `yaml:"ipmi password,omitempty"`
IpmiIpaddr string `yaml:"ipmi ipaddr,omitempty"`
IpmiNetmask string `yaml:"ipmi netmask,omitempty"`
IpmiPort string `yaml:"ipmi port,omitempty"`
IpmiGateway string `yaml:"ipmi gateway,omitempty"`
IpmiInterface string `yaml:"ipmi interface,omitempty"`
IpmiWrite string `yaml:"ipmi write,omitempty"`
RuntimeOverlay []string `yaml:"runtime overlay,omitempty"` RuntimeOverlay []string `yaml:"runtime overlay,omitempty"`
SystemOverlay []string `yaml:"system overlay,omitempty"` SystemOverlay []string `yaml:"system overlay,omitempty"`
Kernel *KernelConf `yaml:"kernel,omitempty"` Kernel *KernelConf `yaml:"kernel,omitempty"`
@@ -45,7 +56,7 @@ type IpmiConf struct {
Port string `yaml:"port,omitempty"` Port string `yaml:"port,omitempty"`
Gateway string `yaml:"gateway,omitempty"` Gateway string `yaml:"gateway,omitempty"`
Interface string `yaml:"interface,omitempty"` Interface string `yaml:"interface,omitempty"`
Write bool `yaml:"write,omitempty"` Write string `yaml:"write,omitempty"`
} }
type KernelConf struct { type KernelConf struct {
Version string `yaml:"version,omitempty"` Version string `yaml:"version,omitempty"`

View File

@@ -1,6 +1,7 @@
package node package node
import ( import (
"fmt"
"regexp" "regexp"
"strings" "strings"
) )
@@ -254,8 +255,8 @@ func (ent *Entry) PrintComb() string {
/* /*
same as GetB() same as GetB()
*/ */
func (ent *Entry) PrintB() bool { func (ent *Entry) PrintB() string {
return ent.GetB() return fmt.Sprintf("%t", ent.GetB())
} }
/* /*

View File

@@ -79,7 +79,7 @@ func (config *nodeYaml) NodeUpdate(node NodeInfo) error {
config.Nodes[nodeID].Ipmi.UserName = node.Ipmi.UserName.GetReal() config.Nodes[nodeID].Ipmi.UserName = node.Ipmi.UserName.GetReal()
config.Nodes[nodeID].Ipmi.Password = node.Ipmi.Password.GetReal() config.Nodes[nodeID].Ipmi.Password = node.Ipmi.Password.GetReal()
config.Nodes[nodeID].Ipmi.Interface = node.Ipmi.Interface.GetReal() config.Nodes[nodeID].Ipmi.Interface = node.Ipmi.Interface.GetReal()
config.Nodes[nodeID].Ipmi.Write = node.Ipmi.Write.GetB() config.Nodes[nodeID].Ipmi.Write = node.Ipmi.Write.GetReal()
} }
config.Nodes[nodeID].RuntimeOverlay = node.RuntimeOverlay.GetRealSlice() config.Nodes[nodeID].RuntimeOverlay = node.RuntimeOverlay.GetRealSlice()
config.Nodes[nodeID].SystemOverlay = node.SystemOverlay.GetRealSlice() config.Nodes[nodeID].SystemOverlay = node.SystemOverlay.GetRealSlice()
@@ -185,7 +185,7 @@ func (config *nodeYaml) ProfileUpdate(profile NodeInfo) error {
config.NodeProfiles[profileID].Ipmi.UserName = profile.Ipmi.UserName.GetReal() config.NodeProfiles[profileID].Ipmi.UserName = profile.Ipmi.UserName.GetReal()
config.NodeProfiles[profileID].Ipmi.Password = profile.Ipmi.Password.GetReal() config.NodeProfiles[profileID].Ipmi.Password = profile.Ipmi.Password.GetReal()
config.NodeProfiles[profileID].Ipmi.Interface = profile.Ipmi.Interface.GetReal() config.NodeProfiles[profileID].Ipmi.Interface = profile.Ipmi.Interface.GetReal()
config.NodeProfiles[profileID].Ipmi.Write = profile.Ipmi.Interface.GetB() config.NodeProfiles[profileID].Ipmi.Write = profile.Ipmi.Interface.GetReal()
} }
config.NodeProfiles[profileID].RuntimeOverlay = profile.RuntimeOverlay.GetRealSlice() config.NodeProfiles[profileID].RuntimeOverlay = profile.RuntimeOverlay.GetRealSlice()
config.NodeProfiles[profileID].SystemOverlay = profile.SystemOverlay.GetRealSlice() config.NodeProfiles[profileID].SystemOverlay = profile.SystemOverlay.GetRealSlice()

View File

@@ -245,7 +245,7 @@ func BuildOverlayIndir(nodeInfo node.NodeInfo, overlayNames []string, outputDir
tstruct.Ipmi.UserName = nodeInfo.Ipmi.UserName.Get() tstruct.Ipmi.UserName = nodeInfo.Ipmi.UserName.Get()
tstruct.Ipmi.Password = nodeInfo.Ipmi.Password.Get() tstruct.Ipmi.Password = nodeInfo.Ipmi.Password.Get()
tstruct.Ipmi.Interface = nodeInfo.Ipmi.Interface.Get() tstruct.Ipmi.Interface = nodeInfo.Ipmi.Interface.Get()
tstruct.Ipmi.Write = nodeInfo.Ipmi.Write.GetB() tstruct.Ipmi.Write = nodeInfo.Ipmi.Write.Get()
tstruct.RuntimeOverlay = nodeInfo.RuntimeOverlay.Print() tstruct.RuntimeOverlay = nodeInfo.RuntimeOverlay.Print()
tstruct.SystemOverlay = nodeInfo.SystemOverlay.Print() tstruct.SystemOverlay = nodeInfo.SystemOverlay.Print()
tstruct.NetDevs = make(map[string]*node.NetDevs) tstruct.NetDevs = make(map[string]*node.NetDevs)