Params-->Keys
This commit is contained in:
@@ -59,8 +59,8 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
fmt.Printf("%-20s %-18s %-12s %t\n", node.Id.Get(), name+":DEFAULT", netdev.Default.Source(), netdev.Default.PrintB())
|
fmt.Printf("%-20s %-18s %-12s %t\n", node.Id.Get(), name+":DEFAULT", netdev.Default.Source(), netdev.Default.PrintB())
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, param := range node.Params {
|
for name, key := range node.Keys {
|
||||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name, param.Source(), param.Print())
|
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), name, key.Source(), key.Print())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -326,33 +326,32 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if SetValue != "" {
|
if SetValue != "" {
|
||||||
if SetParam == "" {
|
if SetKey == "" {
|
||||||
wwlog.Printf(wwlog.ERROR, "You must include the '--param' option\n")
|
wwlog.Printf(wwlog.ERROR, "You must include the '--key/-k' option\n")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := n.Params[SetParam]; !ok {
|
if _, ok := n.Keys[SetKey]; !ok {
|
||||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Value %s\n", n.Id.Get(), SetParam, SetValue)
|
|
||||||
var nd node.Entry
|
var nd node.Entry
|
||||||
n.Params[SetParam] = &nd
|
n.Keys[SetKey] = &nd
|
||||||
}
|
}
|
||||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Value %s\n", n.Id.Get(), SetParam, SetValue)
|
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Value %s\n", n.Id.Get(), SetKey, SetValue)
|
||||||
n.Params[SetParam].Set(SetValue)
|
n.Keys[SetKey].Set(SetValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
if SetParamDel == true {
|
if SetKeyDel == true {
|
||||||
if SetParam == "" {
|
if SetKey == "" {
|
||||||
wwlog.Printf(wwlog.ERROR, "You must include the '--param' option\n")
|
wwlog.Printf(wwlog.ERROR, "You must include the '--key/-k' option\n")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := n.Params[SetParam]; !ok {
|
if _, ok := n.Keys[SetKey]; !ok {
|
||||||
wwlog.Printf(wwlog.ERROR, "Custom parameter doesn't exist: %s\n", SetParam)
|
wwlog.Printf(wwlog.ERROR, "Custom parameter doesn't exist: %s\n", SetKey)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Deleting custom parameter: %s\n", n.Id.Get(), SetNetDev)
|
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Deleting custom parameter: %s\n", n.Id.Get(), SetNetDev)
|
||||||
delete(n.Params, SetParam)
|
delete(n.Keys, SetKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := nodeDB.NodeUpdate(n)
|
err := nodeDB.NodeUpdate(n)
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ var (
|
|||||||
SetDiscoverable bool
|
SetDiscoverable bool
|
||||||
SetUndiscoverable bool
|
SetUndiscoverable bool
|
||||||
SetRoot string
|
SetRoot string
|
||||||
SetParam string
|
SetKey string
|
||||||
SetValue string
|
SetValue string
|
||||||
SetParamDel bool
|
SetKeyDel bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -77,9 +77,10 @@ func init() {
|
|||||||
baseCmd.PersistentFlags().BoolVar(&SetNetDevDel, "netdel", false, "Delete the node's network device")
|
baseCmd.PersistentFlags().BoolVar(&SetNetDevDel, "netdel", false, "Delete the node's network device")
|
||||||
baseCmd.PersistentFlags().BoolVar(&SetNetDevDefault, "netdefault", false, "Set this network to be default")
|
baseCmd.PersistentFlags().BoolVar(&SetNetDevDefault, "netdefault", false, "Set this network to be default")
|
||||||
|
|
||||||
baseCmd.PersistentFlags().StringVarP(&SetParam, "param", "p", "", "Define custom parameter")
|
baseCmd.PersistentFlags().StringVarP(&SetKey, "key", "k", "", "Define custom key")
|
||||||
baseCmd.PersistentFlags().StringVarP(&SetValue, "value", "", "", "Set custom parameter value")
|
baseCmd.PersistentFlags().BoolVar(&SetKeyDel, "keydel", false, "Delete custom key")
|
||||||
baseCmd.PersistentFlags().BoolVar(&SetParamDel, "paramdel", false, "Delete custom parameter")
|
|
||||||
|
baseCmd.PersistentFlags().StringVarP(&SetValue, "value", "", "", "Set value")
|
||||||
|
|
||||||
baseCmd.PersistentFlags().BoolVarP(&SetNodeAll, "all", "a", false, "Set all nodes")
|
baseCmd.PersistentFlags().BoolVarP(&SetNodeAll, "all", "a", false, "Set all nodes")
|
||||||
|
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
fmt.Printf("%-20s %-18s %t\n", profile.Id.Get(), name+":DEFAULT", netdev.Default.PrintB())
|
fmt.Printf("%-20s %-18s %t\n", profile.Id.Get(), name+":DEFAULT", netdev.Default.PrintB())
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, param := range profile.Params {
|
for name, key := range profile.Keys {
|
||||||
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), name, param.Print())
|
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), name, key.Print())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -242,32 +242,32 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if SetValue != "" {
|
if SetValue != "" {
|
||||||
if SetParam == "" {
|
if SetKey == "" {
|
||||||
wwlog.Printf(wwlog.ERROR, "You must include the '--param' option\n")
|
wwlog.Printf(wwlog.ERROR, "You must include the '--key/-k' option\n")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := p.Params[SetParam]; !ok {
|
if _, ok := p.Keys[SetKey]; !ok {
|
||||||
var nd node.Entry
|
var nd node.Entry
|
||||||
p.Params[SetParam] = &nd
|
p.Keys[SetKey] = &nd
|
||||||
}
|
}
|
||||||
wwlog.Printf(wwlog.VERBOSE, "Profile: %s:%s, Setting Value %s\n", p.Id.Get(), SetParam, SetValue)
|
wwlog.Printf(wwlog.VERBOSE, "Profile: %s:%s, Setting Value %s\n", p.Id.Get(), SetKey, SetValue)
|
||||||
p.Params[SetParam].Set(SetValue)
|
p.Keys[SetKey].Set(SetValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
if SetParamDel == true {
|
if SetKeyDel == true {
|
||||||
if SetParam == "" {
|
if SetKey == "" {
|
||||||
wwlog.Printf(wwlog.ERROR, "You must include the '--param' option\n")
|
wwlog.Printf(wwlog.ERROR, "You must include the '--key/-k' option\n")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := p.Params[SetParam]; !ok {
|
if _, ok := p.Keys[SetKey]; !ok {
|
||||||
wwlog.Printf(wwlog.ERROR, "Custom parameter doesn't exist: %s\n", SetParam)
|
wwlog.Printf(wwlog.ERROR, "Custom key doesn't exist: %s\n", SetKey)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Deleting custom parameter: %s\n", p.Id.Get(), SetNetDev)
|
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Deleting custom key: %s\n", p.Id.Get(), SetNetDev)
|
||||||
delete(p.Params, SetParam)
|
delete(p.Keys, SetKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := nodeDB.ProfileUpdate(p)
|
err := nodeDB.ProfileUpdate(p)
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ var (
|
|||||||
SetNetDevDefault bool
|
SetNetDevDefault bool
|
||||||
SetInit string
|
SetInit string
|
||||||
SetRoot string
|
SetRoot string
|
||||||
SetParam string
|
SetKey string
|
||||||
SetValue string
|
SetValue string
|
||||||
SetParamDel bool
|
SetKeyDel bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -66,9 +66,10 @@ func init() {
|
|||||||
baseCmd.PersistentFlags().BoolVar(&SetNetDevDel, "netdel", false, "Delete the node's network device")
|
baseCmd.PersistentFlags().BoolVar(&SetNetDevDel, "netdel", false, "Delete the node's network device")
|
||||||
baseCmd.PersistentFlags().BoolVar(&SetNetDevDefault, "netdefault", false, "Set this network to be default")
|
baseCmd.PersistentFlags().BoolVar(&SetNetDevDefault, "netdefault", false, "Set this network to be default")
|
||||||
|
|
||||||
baseCmd.PersistentFlags().StringVarP(&SetParam, "param", "p", "", "Define custom parameter")
|
baseCmd.PersistentFlags().StringVarP(&SetKey, "key", "k", "", "Define custom key")
|
||||||
baseCmd.PersistentFlags().StringVarP(&SetValue, "value", "", "", "Set custom parameter value")
|
baseCmd.PersistentFlags().BoolVar(&SetKeyDel, "keydel", false, "Delete custom key")
|
||||||
baseCmd.PersistentFlags().BoolVar(&SetParamDel, "paramdel", false, "Delete custom parameter")
|
|
||||||
|
baseCmd.PersistentFlags().StringVarP(&SetValue, "value", "", "", "Set value")
|
||||||
|
|
||||||
baseCmd.PersistentFlags().BoolVarP(&SetAll, "all", "a", false, "Set all profiles")
|
baseCmd.PersistentFlags().BoolVarP(&SetAll, "all", "a", false, "Set all profiles")
|
||||||
baseCmd.PersistentFlags().BoolVarP(&SetForce, "force", "f", false, "Force configuration (even on error)")
|
baseCmd.PersistentFlags().BoolVarP(&SetForce, "force", "f", false, "Force configuration (even on error)")
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
|
|||||||
|
|
||||||
wwlog.Printf(wwlog.DEBUG, "In node loop: %s\n", nodename)
|
wwlog.Printf(wwlog.DEBUG, "In node loop: %s\n", nodename)
|
||||||
n.NetDevs = make(map[string]*NetDevEntry)
|
n.NetDevs = make(map[string]*NetDevEntry)
|
||||||
n.Params = make(map[string]*Entry)
|
n.Keys = make(map[string]*Entry)
|
||||||
n.SystemOverlay.SetDefault("default")
|
n.SystemOverlay.SetDefault("default")
|
||||||
n.RuntimeOverlay.SetDefault("default")
|
n.RuntimeOverlay.SetDefault("default")
|
||||||
n.Ipxe.SetDefault("default")
|
n.Ipxe.SetDefault("default")
|
||||||
@@ -95,12 +95,12 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
|
|||||||
n.NetDevs[devname].Default.SetB(netdev.Default)
|
n.NetDevs[devname].Default.SetB(netdev.Default)
|
||||||
}
|
}
|
||||||
|
|
||||||
for paramname, param := range node.Params {
|
for keyname, key := range node.Keys {
|
||||||
if _, ok := n.Params[paramname]; !ok {
|
if _, ok := n.Keys[keyname]; !ok {
|
||||||
var param Entry
|
var key Entry
|
||||||
n.Params[paramname] = ¶m
|
n.Keys[keyname] = &key
|
||||||
}
|
}
|
||||||
n.Params[paramname].Set(param)
|
n.Keys[keyname].Set(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, p := range n.Profiles {
|
for _, p := range n.Profiles {
|
||||||
@@ -144,12 +144,12 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
|
|||||||
n.NetDevs[devname].Default.SetAltB(netdev.Default, p)
|
n.NetDevs[devname].Default.SetAltB(netdev.Default, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
for paramname, param := range config.NodeProfiles[p].Params {
|
for keyname, key := range config.NodeProfiles[p].Keys {
|
||||||
if _, ok := n.Params[paramname]; !ok {
|
if _, ok := n.Keys[keyname]; !ok {
|
||||||
var param Entry
|
var key Entry
|
||||||
n.Params[paramname] = ¶m
|
n.Keys[keyname] = &key
|
||||||
}
|
}
|
||||||
n.Params[paramname].SetAlt(param, p)
|
n.Keys[keyname].SetAlt(key, p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +177,7 @@ func (config *nodeYaml) FindAllProfiles() ([]NodeInfo, error) {
|
|||||||
for name, profile := range config.NodeProfiles {
|
for name, profile := range config.NodeProfiles {
|
||||||
var p NodeInfo
|
var p NodeInfo
|
||||||
p.NetDevs = make(map[string]*NetDevEntry)
|
p.NetDevs = make(map[string]*NetDevEntry)
|
||||||
p.Params = make(map[string]*Entry)
|
p.Keys = make(map[string]*Entry)
|
||||||
|
|
||||||
p.Id.Set(name)
|
p.Id.Set(name)
|
||||||
p.Comment.Set(profile.Comment)
|
p.Comment.Set(profile.Comment)
|
||||||
@@ -212,12 +212,12 @@ func (config *nodeYaml) FindAllProfiles() ([]NodeInfo, error) {
|
|||||||
p.NetDevs[devname].Default.SetB(netdev.Default)
|
p.NetDevs[devname].Default.SetB(netdev.Default)
|
||||||
}
|
}
|
||||||
|
|
||||||
for paramname, param := range profile.Params {
|
for keyname, key := range profile.Keys {
|
||||||
if _, ok := p.Params[paramname]; !ok {
|
if _, ok := p.Keys[keyname]; !ok {
|
||||||
var param Entry
|
var key Entry
|
||||||
p.Params[paramname] = ¶m
|
p.Keys[keyname] = &key
|
||||||
}
|
}
|
||||||
p.Params[paramname].Set(param)
|
p.Keys[keyname].Set(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Validate or die on all inputs
|
// TODO: Validate or die on all inputs
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ type NodeConf struct {
|
|||||||
Discoverable bool `yaml:"discoverable,omitempty"`
|
Discoverable bool `yaml:"discoverable,omitempty"`
|
||||||
Profiles []string `yaml:"profiles,omitempty"`
|
Profiles []string `yaml:"profiles,omitempty"`
|
||||||
NetDevs map[string]*NetDevs `yaml:"network devices,omitempty"`
|
NetDevs map[string]*NetDevs `yaml:"network devices,omitempty"`
|
||||||
Params map[string]string `yaml:"parameters,omitempty"`
|
Keys map[string]string `yaml:"keys,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type NetDevs struct {
|
type NetDevs struct {
|
||||||
@@ -83,7 +83,7 @@ type NodeInfo struct {
|
|||||||
Profiles []string
|
Profiles []string
|
||||||
GroupProfiles []string
|
GroupProfiles []string
|
||||||
NetDevs map[string]*NetDevEntry
|
NetDevs map[string]*NetDevEntry
|
||||||
Params map[string]*Entry
|
Keys map[string]*Entry
|
||||||
}
|
}
|
||||||
|
|
||||||
type NetDevEntry struct {
|
type NetDevEntry struct {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ func (config *nodeYaml) NodeUpdate(node NodeInfo) error {
|
|||||||
config.Nodes[nodeID].Profiles = node.Profiles
|
config.Nodes[nodeID].Profiles = node.Profiles
|
||||||
config.Nodes[nodeID].NetDevs = make(map[string]*NetDevs)
|
config.Nodes[nodeID].NetDevs = make(map[string]*NetDevs)
|
||||||
|
|
||||||
config.Nodes[nodeID].Params = make(map[string]string)
|
config.Nodes[nodeID].Keys = make(map[string]string)
|
||||||
|
|
||||||
for devname, netdev := range node.NetDevs {
|
for devname, netdev := range node.NetDevs {
|
||||||
var newdev NetDevs
|
var newdev NetDevs
|
||||||
@@ -89,8 +89,8 @@ func (config *nodeYaml) NodeUpdate(node NodeInfo) error {
|
|||||||
config.Nodes[nodeID].NetDevs[devname].Default = netdev.Default.GetRealB()
|
config.Nodes[nodeID].NetDevs[devname].Default = netdev.Default.GetRealB()
|
||||||
}
|
}
|
||||||
|
|
||||||
for paramname, param := range node.Params {
|
for keyname, key := range node.Keys {
|
||||||
config.Nodes[nodeID].Params[paramname] = param.GetReal()
|
config.Nodes[nodeID].Keys[keyname] = key.GetReal()
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -158,7 +158,7 @@ func (config *nodeYaml) ProfileUpdate(profile NodeInfo) error {
|
|||||||
config.NodeProfiles[profileID].Profiles = profile.Profiles
|
config.NodeProfiles[profileID].Profiles = profile.Profiles
|
||||||
config.NodeProfiles[profileID].NetDevs = make(map[string]*NetDevs)
|
config.NodeProfiles[profileID].NetDevs = make(map[string]*NetDevs)
|
||||||
|
|
||||||
config.NodeProfiles[profileID].Params = make(map[string]string)
|
config.NodeProfiles[profileID].Keys = make(map[string]string)
|
||||||
|
|
||||||
for devname, netdev := range profile.NetDevs {
|
for devname, netdev := range profile.NetDevs {
|
||||||
var newdev NetDevs
|
var newdev NetDevs
|
||||||
@@ -172,8 +172,8 @@ func (config *nodeYaml) ProfileUpdate(profile NodeInfo) error {
|
|||||||
config.NodeProfiles[profileID].NetDevs[devname].Default = netdev.Default.GetRealB()
|
config.NodeProfiles[profileID].NetDevs[devname].Default = netdev.Default.GetRealB()
|
||||||
}
|
}
|
||||||
|
|
||||||
for paramname, param := range profile.Params {
|
for keyname, key := range profile.Keys {
|
||||||
config.NodeProfiles[profileID].Params[paramname] = param.GetReal()
|
config.NodeProfiles[profileID].Keys[keyname] = key.GetReal()
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ type TemplateStruct struct {
|
|||||||
IpmiUserName string
|
IpmiUserName string
|
||||||
IpmiPassword string
|
IpmiPassword string
|
||||||
NetDevs map[string]*node.NetDevs
|
NetDevs map[string]*node.NetDevs
|
||||||
Params map[string]string
|
Keys map[string]string
|
||||||
AllNodes []node.NodeInfo
|
AllNodes []node.NodeInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ func buildOverlay(nodeList []node.NodeInfo, overlayType string) error {
|
|||||||
t.IpmiUserName = n.IpmiUserName.Get()
|
t.IpmiUserName = n.IpmiUserName.Get()
|
||||||
t.IpmiPassword = n.IpmiPassword.Get()
|
t.IpmiPassword = n.IpmiPassword.Get()
|
||||||
t.NetDevs = make(map[string]*node.NetDevs)
|
t.NetDevs = make(map[string]*node.NetDevs)
|
||||||
t.Params = make(map[string]string)
|
t.Keys = make(map[string]string)
|
||||||
for devname, netdev := range n.NetDevs {
|
for devname, netdev := range n.NetDevs {
|
||||||
var nd node.NetDevs
|
var nd node.NetDevs
|
||||||
t.NetDevs[devname] = &nd
|
t.NetDevs[devname] = &nd
|
||||||
@@ -161,8 +161,8 @@ func buildOverlay(nodeList []node.NodeInfo, overlayType string) error {
|
|||||||
t.NetDevs[devname].Type = netdev.Type.Get()
|
t.NetDevs[devname].Type = netdev.Type.Get()
|
||||||
t.NetDevs[devname].Default = netdev.Default.GetB()
|
t.NetDevs[devname].Default = netdev.Default.GetB()
|
||||||
}
|
}
|
||||||
for paramname, param := range n.Params {
|
for keyname, key := range n.Keys {
|
||||||
t.Params[paramname] = param.Get()
|
t.Keys[keyname] = key.Get()
|
||||||
}
|
}
|
||||||
t.AllNodes = allNodes
|
t.AllNodes = allNodes
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user