adding netname option back
This commit is contained in:
@@ -49,8 +49,8 @@ type NodeConf struct {
|
||||
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" lopt:"tagadd" comment:"base key"`
|
||||
TagsDel []string `lopt:"tagdel" comment:"remove this tags"` // does not go to disk only to wire
|
||||
Keys map[string]string `yaml:"keys,omitempty"` // Reverse compatibility
|
||||
TagsDel []string `yaml:"tagsdel,omitempty" lopt:"tagdel" comment:"remove this tags"` // should not go to disk only to wire
|
||||
Keys map[string]string `yaml:"keys,omitempty"` // Reverse compatibility
|
||||
}
|
||||
|
||||
type IpmiConf struct {
|
||||
@@ -63,7 +63,7 @@ type IpmiConf struct {
|
||||
Interface string `yaml:"interface,omitempty" lopt:"ipmiinterface" comment:"Set the node's IPMI interface (defaults: 'lan')"`
|
||||
Write string `yaml:"write,omitempty" lopt:"ipmiwrite" comment:"Enable the write of impi configuration (yes/no)"`
|
||||
Tags map[string]string `yaml:"tags,omitempty" lopt:"ipmitagadd" comment:"add ipmitags"`
|
||||
TagsDel []string `lopt:"ipmitagdel" comment:"remove ipmitags"` // does not go to disk only to wire
|
||||
TagsDel []string `yaml:"tagsdel,omitempty" lopt:"ipmitagdel" comment:"remove ipmitags"` // should not go to disk only to wire
|
||||
}
|
||||
type KernelConf struct {
|
||||
Version string `yaml:"version,omitempty"`
|
||||
@@ -85,7 +85,7 @@ type NetDevs struct {
|
||||
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" lopt:"nettagadd" comment:"network tags"`
|
||||
TagsDel []string `lopt:"nettagdel" comment:"delete network tags"` // does not go to disk only to wire
|
||||
TagsDel []string `yaml:"tagsdel,omitempty" lopt:"nettagdel" comment:"delete network tags"` // should not go to disk only to wire
|
||||
}
|
||||
|
||||
/******
|
||||
|
||||
@@ -81,6 +81,8 @@ func (ent *Entry) SetB(val bool) {
|
||||
func (ent *Entry) SetSlice(val []string) {
|
||||
if len(val) == 0 {
|
||||
return
|
||||
} else if len(val) == 1 && val[0] == "" { // check also for an "empty" slice
|
||||
return
|
||||
}
|
||||
if val[0] == "UNDEF" || val[0] == "DELETE" || val[0] == "UNSET" || val[0] == "--" {
|
||||
ent.value = []string{}
|
||||
|
||||
@@ -142,12 +142,14 @@ func (nodeConf *NodeConf) CreateFlags(baseCmd *cobra.Command, excludeList []stri
|
||||
for i := 0; i < nodeInfoVal.Elem().NumField(); i++ {
|
||||
if nodeInfoType.Elem().Field(i).Tag.Get("comment") != "" &&
|
||||
!util.InSlice(excludeList, nodeInfoType.Elem().Field(i).Tag.Get("lopt")) {
|
||||
createFlags(baseCmd, excludeList, nodeInfoType.Elem().Field(i), nodeInfoVal.Elem().Field(i))
|
||||
field := nodeInfoVal.Elem().Field(i)
|
||||
createFlags(baseCmd, excludeList, nodeInfoType.Elem().Field(i), &field)
|
||||
} else if nodeInfoType.Elem().Field(i).Type.Kind() == reflect.Ptr {
|
||||
nestType := reflect.TypeOf(nodeInfoVal.Elem().Field(i).Interface())
|
||||
nestVal := reflect.ValueOf(nodeInfoVal.Elem().Field(i).Interface())
|
||||
for j := 0; j < nestType.Elem().NumField(); j++ {
|
||||
createFlags(baseCmd, excludeList, nestType.Elem().Field(j), nestVal.Elem().Field(j))
|
||||
field := nestVal.Elem().Field(j)
|
||||
createFlags(baseCmd, excludeList, nestType.Elem().Field(j), &field)
|
||||
}
|
||||
} else if nodeInfoType.Elem().Field(i).Type == reflect.TypeOf(map[string]*NetDevs(nil)) {
|
||||
netMap := nodeInfoVal.Elem().Field(i).Interface().(map[string]*NetDevs)
|
||||
@@ -156,7 +158,8 @@ func (nodeConf *NodeConf) CreateFlags(baseCmd *cobra.Command, excludeList []stri
|
||||
netType := reflect.TypeOf(netMap["default"])
|
||||
netVal := reflect.ValueOf(netMap["default"])
|
||||
for j := 0; j < netType.Elem().NumField(); j++ {
|
||||
createFlags(baseCmd, excludeList, netType.Elem().Field(j), netVal.Elem().Field(j))
|
||||
field := netVal.Elem().Field(j)
|
||||
createFlags(baseCmd, excludeList, netType.Elem().Field(j), &field)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,7 +169,7 @@ func (nodeConf *NodeConf) CreateFlags(baseCmd *cobra.Command, excludeList []stri
|
||||
Helper function to create the different PerisitantFlags() for different types.
|
||||
*/
|
||||
func createFlags(baseCmd *cobra.Command, excludeList []string,
|
||||
myType reflect.StructField, myVal reflect.Value) {
|
||||
myType reflect.StructField, myVal *reflect.Value) {
|
||||
if myType.Tag.Get("lopt") != "" {
|
||||
if myType.Type.Kind() == reflect.String {
|
||||
ptr := myVal.Addr().Interface().(*string)
|
||||
|
||||
Reference in New Issue
Block a user