paramters in node
This commit is contained in:
@@ -325,6 +325,20 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
n.NetDevs[SetNetDev].Default.SetB(true)
|
||||
}
|
||||
|
||||
if SetValue != "" {
|
||||
if SetParam == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "You must include the '--param' option\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, ok := n.Params[SetParam]; !ok {
|
||||
var nd node.ParamEntry
|
||||
n.Params[SetParam] = &nd
|
||||
}
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Value %s\n", n.Id.Get(), SetParam, SetValue)
|
||||
n.Params[SetParam].Value.Set(SetValue)
|
||||
}
|
||||
|
||||
err := nodeDB.NodeUpdate(n)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
|
||||
@@ -41,6 +41,8 @@ var (
|
||||
SetDiscoverable bool
|
||||
SetUndiscoverable bool
|
||||
SetRoot string
|
||||
SetParam string
|
||||
SetValue string
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -74,6 +76,9 @@ func init() {
|
||||
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().StringVarP(&SetParam, "param", "p", "", "Define custom parameter")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetValue, "value", "", "", "Set custom parameter value")
|
||||
|
||||
baseCmd.PersistentFlags().BoolVarP(&SetNodeAll, "all", "a", false, "Set all nodes")
|
||||
|
||||
baseCmd.PersistentFlags().BoolVarP(&SetYes, "yes", "y", false, "Set 'yes' to all questions asked")
|
||||
|
||||
Reference in New Issue
Block a user