added more values

This commit is contained in:
Christian Goll
2022-07-05 22:03:08 +02:00
parent a37fa71de0
commit 29573e26ad
5 changed files with 61 additions and 105 deletions

View File

@@ -32,43 +32,16 @@ var (
return node_names, cobra.ShellCompDirectiveNoFileComp
},
}
SetKernelOverride string
SetNetName string
SetNetDev string
SetNetmask string
SetGateway string
SetHwaddr string
SetType string
SetNetOnBoot string
SetNetPrimary string
SetNetDevDel bool
SetClusterName string
SetIpxe string
SetInitOverlay string
SetRuntimeOverlay []string
SetSystemOverlay []string
SetIpmiIpaddr string
SetIpmiNetmask string
SetIpmiPort string
SetIpmiGateway string
SetIpmiUsername string
SetIpmiPassword string
SetIpmiInterface string
SetIpmiWrite string
SetNodeAll bool
SetYes bool
SetProfile string
SetAddProfile []string
SetDelProfile []string
SetForce bool
SetDiscoverable bool
SetUndiscoverable bool
SetTags []string
SetDelTags []string
SetNetTags []string
SetNetDelTags []string
OptionStrMap map[string]*string
KernelStrMapmap map[string]*string
KernelStrMap map[string]*string
)
func init() {
@@ -87,41 +60,28 @@ func init() {
}); err != nil {
log.Println(err)
}
baseCmd.PersistentFlags().StringVarP(&SetKernelOverride, "kerneloverride", "K", "", "Set kernel override version for nodes")
if err := baseCmd.RegisterFlagCompletionFunc("kerneloverride", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
list, _ := kernel.ListKernels()
return list, cobra.ShellCompDirectiveNoFileComp
}); err != nil {
log.Println(err)
}
baseCmd.PersistentFlags().StringVarP(&SetClusterName, "cluster", "c", "", "Set the node's cluster group")
baseCmd.PersistentFlags().StringVar(&SetIpxe, "ipxe", "", "Set the node's iPXE template name")
baseCmd.PersistentFlags().StringVarP(&SetInitOverlay, "wwinit", "O", "", "Set the node's initialization overlay")
baseCmd.PersistentFlags().StringSliceVarP(&SetRuntimeOverlay, "runtime", "R", []string{}, "Set the node's runtime overlay")
if err := baseCmd.RegisterFlagCompletionFunc("runtime", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
list, _ := overlay.FindOverlays()
return list, cobra.ShellCompDirectiveNoFileComp
}); err != nil {
log.Println(err)
}
baseCmd.PersistentFlags().StringSliceVarP(&SetSystemOverlay, "system", "S", []string{}, "Set the node's system overlay")
if err := baseCmd.RegisterFlagCompletionFunc("system", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
list, _ := overlay.FindOverlays()
return list, cobra.ShellCompDirectiveNoFileComp
}); err != nil {
log.Println(err)
}
baseCmd.PersistentFlags().StringVar(&SetIpmiIpaddr, "ipmiaddr", "", "Set the node's IPMI IP address")
baseCmd.PersistentFlags().StringVar(&SetIpmiNetmask, "ipminetmask", "", "Set the node's IPMI netmask")
baseCmd.PersistentFlags().StringVar(&SetIpmiPort, "ipmiport", "", "Set the node's IPMI port")
baseCmd.PersistentFlags().StringVar(&SetIpmiGateway, "ipmigateway", "", "Set the node's IPMI gateway")
baseCmd.PersistentFlags().StringVar(&SetIpmiUsername, "ipmiuser", "", "Set the node's IPMI username")
baseCmd.PersistentFlags().StringVar(&SetIpmiPassword, "ipmipass", "", "Set the node's IPMI password")
baseCmd.PersistentFlags().StringVar(&SetIpmiInterface, "ipmiinterface", "", "Set the node's IPMI interface (defaults: 'lan')")
baseCmd.PersistentFlags().StringVar(&SetIpmiWrite, "ipmiwrite", "", "Enable/disable the write of impi configuration (yes/no)")
/*
baseCmd.PersistentFlags().StringSliceVar(&SetAddProfile, "addprofile", []string{}, "Add Profile(s) to node")
baseCmd.PersistentFlags().StringSliceVar(&SetDelProfile, "delprofile", []string{}, "Remove Profile(s) to node")
baseCmd.PersistentFlags().StringVarP(&SetProfile, "profile", "P", "", "Set the node's profile members (comma separated)")
*/
if err := baseCmd.RegisterFlagCompletionFunc("profile", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
var list []string
nodeDB, _ := node.New()
@@ -133,13 +93,6 @@ func init() {
}); err != nil {
log.Println(err)
}
baseCmd.PersistentFlags().StringVarP(&SetNetDev, "netdev", "N", "", "Set the node's network device")
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().StringVarP(&SetType, "type", "T", "", "Set the node's network device type")
baseCmd.PersistentFlags().StringVar(&SetNetOnBoot, "onboot", "", "Enable/disable device (yes/no)")
baseCmd.PersistentFlags().StringVar(&SetNetPrimary, "primary", "", "Enable/disable device as primary (yes/no)")
baseCmd.PersistentFlags().BoolVar(&SetNetDevDel, "netdel", false, "Delete the node's network device")
baseCmd.PersistentFlags().StringSliceVar(&SetNetTags, "nettag", []string{}, "Define custom tag to network device (key=value)")
@@ -152,8 +105,7 @@ func init() {
baseCmd.PersistentFlags().BoolVarP(&SetYes, "yes", "y", false, "Set 'yes' to all questions asked")
baseCmd.PersistentFlags().BoolVarP(&SetForce, "force", "f", false, "Force configuration (even on error)")
baseCmd.PersistentFlags().BoolVar(&SetDiscoverable, "discoverable", false, "Make this node discoverable")
baseCmd.PersistentFlags().BoolVar(&SetUndiscoverable, "undiscoverable", false, "Remove the discoverable flag")
//baseCmd.PersistentFlags().BoolVar(&SetUndiscoverable, "undiscoverable", false, "Remove the discoverable flag")
}

View File

@@ -114,7 +114,7 @@ func (config *NodeYaml) FindAllNodes() ([]NodeInfo, error) {
n.Ipmi.UserName.Set(node.Ipmi.UserName)
n.Ipmi.Password.Set(node.Ipmi.Password)
n.Ipmi.Interface.Set(node.Ipmi.Interface)
n.Ipmi.Write.Set(node.Ipmi.Write)
n.Ipmi.Write.SetB(node.Ipmi.Write)
}
n.SystemOverlay.SetSlice(node.SystemOverlay)
n.RuntimeOverlay.SetSlice(node.RuntimeOverlay)
@@ -231,7 +231,7 @@ func (config *NodeYaml) FindAllNodes() ([]NodeInfo, error) {
n.Ipmi.UserName.SetAlt(config.NodeProfiles[p].Ipmi.UserName, p)
n.Ipmi.Password.SetAlt(config.NodeProfiles[p].Ipmi.Password, p)
n.Ipmi.Interface.SetAlt(config.NodeProfiles[p].Ipmi.Interface, p)
n.Ipmi.Write.SetAlt(config.NodeProfiles[p].Ipmi.Write, p)
n.Ipmi.Write.SetAltB(config.NodeProfiles[p].Ipmi.Write, p)
}
n.SystemOverlay.SetAltSlice(config.NodeProfiles[p].SystemOverlay, p)
n.RuntimeOverlay.SetAltSlice(config.NodeProfiles[p].RuntimeOverlay, p)
@@ -366,7 +366,7 @@ func (config *NodeYaml) FindAllProfiles() ([]NodeInfo, error) {
p.Ipmi.UserName.Set(profile.Ipmi.UserName)
p.Ipmi.Password.Set(profile.Ipmi.Password)
p.Ipmi.Interface.Set(profile.Ipmi.Interface)
p.Ipmi.Write.Set(profile.Ipmi.Write)
p.Ipmi.Write.SetB(profile.Ipmi.Write)
}
p.RuntimeOverlay.SetSlice(profile.RuntimeOverlay)
p.SystemOverlay.SetSlice(profile.SystemOverlay)

View File

@@ -20,12 +20,15 @@ NodeConf is the datastructure which is stored on disk.
*/
type NodeConf struct {
Comment string `yaml:"comment,omitempty" lopt:"comment" comment:"Set arbitrary string comment"`
ClusterName string `yaml:"cluster name,omitempty"`
ClusterName string `yaml:"cluster name,omitempty" lopt:"cluster" sopt:"c" comment:"Set cluster group"`
ContainerName string `yaml:"container name,omitempty" lopt:"container" sopt:"C" comment:"Set container name"`
Ipxe string `yaml:"ipxe template,omitempty"`
Ipxe string `yaml:"ipxe template,omitempty" lopt:"ipxe" comment:"Set the iPXE template name"`
// Deprecated start
// Kernel settings here are deprecated and here for backward comptability
KernelVersion string `yaml:"kernel version,omitempty"`
KernelOverride string `yaml:"kernel override,omitempty"`
KernelArgs string `yaml:"kernel args,omitempty"`
// Ipmi settings herer are deprecated and here for backward comptability
IpmiUserName string `yaml:"ipmi username,omitempty"`
IpmiPassword string `yaml:"ipmi password,omitempty"`
IpmiIpaddr string `yaml:"ipmi ipaddr,omitempty"`
@@ -34,48 +37,49 @@ type NodeConf struct {
IpmiGateway string `yaml:"ipmi gateway,omitempty"`
IpmiInterface string `yaml:"ipmi interface,omitempty"`
IpmiWrite string `yaml:"ipmi write,omitempty"`
RuntimeOverlay []string `yaml:"runtime overlay,omitempty"`
SystemOverlay []string `yaml:"system overlay,omitempty"`
// Deprecated end
RuntimeOverlay []string `yaml:"runtime overlay,omitempty" lopt:"runtime" sopt:"R" comment:"Set the runtime overlay"`
SystemOverlay []string `yaml:"system overlay,omitempty" lopt:"wwinit" sopt:"O" comment:"Set the system overlay"`
Kernel *KernelConf `yaml:"kernel,omitempty"`
Ipmi *IpmiConf `yaml:"ipmi,omitempty"`
Init string `yaml:"init,omitempty" lopt:"init" sopt:"i" comment:"Define the init process to boot the container"`
Root string `yaml:"root,omitempty" lopt:"root" comment:"Define the rootfs" `
AssetKey string `yaml:"asset key,omitempty" lopt:"asset" comment:"Set the node's Asset tag (key)"`
Discoverable string `yaml:"discoverable,omitempty"`
Profiles []string `yaml:"profiles,omitempty"`
Discoverable string `yaml:"discoverable,omitempty" lopt:"discoverable" comment:"Make discoverable in given network (yes/no)"`
Profiles []string `yaml:"profiles,omitempty" lopt:"profile" sopt:"P" comment:"Set the node's profile members (comma separated)"`
NetDevs map[string]*NetDevs `yaml:"network devices,omitempty"`
Tags map[string]string `yaml:"tags,omitempty"`
Keys map[string]string `yaml:"keys,omitempty"` // Reverse compatibility
}
type IpmiConf struct {
UserName string `yaml:"username,omitempty"`
Password string `yaml:"password,omitempty"`
Ipaddr string `yaml:"ipaddr,omitempty"`
Netmask string `yaml:"netmask,omitempty"`
Port string `yaml:"port,omitempty"`
Gateway string `yaml:"gateway,omitempty"`
Interface string `yaml:"interface,omitempty"`
Write string `yaml:"write,omitempty"`
UserName string `yaml:"username,omitempty" lopt:"ipmiuser" comment:"Set the IPMI username"`
Password string `yaml:"password,omitempty" lopt:"ipmipass" comment:"Set the IPMI password"`
Ipaddr string `yaml:"ipaddr,omitempty" lopt:"ipmiaddr" comment:"Set the IPMI IP address"`
Netmask string `yaml:"netmask,omitempty" lopt:"ipminetmask" comment:"Set the IPMI netmask"`
Port string `yaml:"port,omitempty" lopt:"ipmiport" comment:"Set the IPMI port"`
Gateway string `yaml:"gateway,omitempty" lopt:"ipmigateway" comment:"Set the IPMI gateway"`
Interface string `yaml:"interface,omitempty" lopt:"ipmiinterface" comment:"Set the node's IPMI interface (defaults: 'lan')"`
Write bool `yaml:"write,omitempty" lopt:"ipmiwrite" comment:"Enable the write of impi configuration (yes/no)"`
}
type KernelConf struct {
Version string `yaml:"version,omitempty"`
Version string `yaml:"version,omitempty lopt:"kerneloverride" sopt:"K" comment:"Set kernel override version`
Override string `yaml:"override,omitempty"`
Args string `yaml:"args,omitempty" lopt:"kernelargs" sopt:"A" comment:"Set Kernel argument"`
}
type NetDevs struct {
Type string `yaml:"type,omitempty"`
OnBoot string `yaml:"onboot,omitempty"`
Device string `yaml:"device,omitempty"`
Hwaddr string `yaml:"hwaddr,omitempty"`
Ipaddr string `yaml:"ipaddr,omitempty" comment:"IPv4 address" sopt:"I" lopt:"ipaddr"`
Type string `yaml:"type,omitempty" lopt:"type" sopt:"T" comment:"Set device type of given network"`
OnBoot string `yaml:"onboot,omitempty" lopt:"onboot" comment:"Enable/disable network device (yes/no)")`
Device string `yaml:"device,omitempty" lopt:"netdev" sopt:"N" comment:"Set the device for given network"`
Hwaddr string `yaml:"hwaddr,omitempty" lopt:"hwaddr" sopt:"H" comment:"Set the device's HW address for given network`
Ipaddr string `yaml:"ipaddr,omitempty" comment:"IPv4 address in given network" sopt:"I" lopt:"ipaddr"`
IpCIDR string `yaml:"ipcidr,omitempty"`
Ipaddr6 string `yaml:"ip6addr,omitempty"`
Prefix string `yaml:"prefix,omitempty"`
Netmask string `yaml:"netmask,omitempty"`
Gateway string `yaml:"gateway,omitempty"`
Primary string `yaml:"primary,omitempty"`
Netmask string `yaml:"netmask,omitempty" lopt:"netmask" sopt:"M" comment:"Set the networks netmask"`
Gateway string `yaml:"gateway,omitempty" lopt:"gateway" sopt:"G" comment:"Set the node's network device gateway"`
Primary string `yaml:"primary,omitempty" lopt:"primary" comment:"Enable/disable network device as primary (yes/no)")`
Default string `yaml:"default,omitempty"` /* backward compatibility */
Tags map[string]string `yaml:"tags,omitempty"`
}

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.Password = node.Ipmi.Password.GetReal()
config.Nodes[nodeID].Ipmi.Interface = node.Ipmi.Interface.GetReal()
config.Nodes[nodeID].Ipmi.Write = node.Ipmi.Write.GetReal()
config.Nodes[nodeID].Ipmi.Write = node.Ipmi.Write.GetB()
}
config.Nodes[nodeID].RuntimeOverlay = node.RuntimeOverlay.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.Password = profile.Ipmi.Password.GetReal()
config.NodeProfiles[profileID].Ipmi.Interface = profile.Ipmi.Interface.GetReal()
config.NodeProfiles[profileID].Ipmi.Write = profile.Ipmi.Interface.GetReal()
config.NodeProfiles[profileID].Ipmi.Write = profile.Ipmi.Interface.GetB()
}
config.NodeProfiles[profileID].RuntimeOverlay = profile.RuntimeOverlay.GetRealSlice()
config.NodeProfiles[profileID].SystemOverlay = profile.SystemOverlay.GetRealSlice()

View File

@@ -86,7 +86,7 @@ func InitStruct(nodeInfo node.NodeInfo) TemplateStruct {
tstruct.Ipmi.UserName = nodeInfo.Ipmi.UserName.Get()
tstruct.Ipmi.Password = nodeInfo.Ipmi.Password.Get()
tstruct.Ipmi.Interface = nodeInfo.Ipmi.Interface.Get()
tstruct.Ipmi.Write = nodeInfo.Ipmi.Write.Get()
tstruct.Ipmi.Write = nodeInfo.Ipmi.Write.GetB()
tstruct.RuntimeOverlay = nodeInfo.RuntimeOverlay.Print()
tstruct.SystemOverlay = nodeInfo.SystemOverlay.Print()
tstruct.NetDevs = make(map[string]*node.NetDevs)