wwctl commands without NodeInfo
mostly remove Get and calls for the id Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
committed by
Jonathon Anderson
parent
28a7b9fe84
commit
457c7c16b1
@@ -2,7 +2,6 @@ package add
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
apiprofile "github.com/warewulf/warewulf/internal/pkg/api/profile"
|
||||
@@ -12,24 +11,10 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/warewulf/warewulf/internal/pkg/api/routes/wwapiv1"
|
||||
"github.com/warewulf/warewulf/internal/pkg/api/util"
|
||||
)
|
||||
|
||||
func CobraRunE(vars *variables) func(cmd *cobra.Command, args []string) (err error) {
|
||||
return func(cmd *cobra.Command, args []string) (err error) {
|
||||
// run converters for different types
|
||||
for _, c := range vars.Converters {
|
||||
if err := c(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// remove the default network as the all network values are assigned
|
||||
// to this network
|
||||
if vars.netName != "" {
|
||||
netDev := *vars.profileConf.NetDevs["UNDEF"]
|
||||
vars.profileConf.NetDevs[vars.netName] = &netDev
|
||||
delete(vars.profileConf.NetDevs, "UNDEF")
|
||||
}
|
||||
// remove the UNDEF network as all network values are assigned
|
||||
// to this network
|
||||
if !node.ObjectIsEmpty(vars.profileConf.NetDevs["UNDEF"]) {
|
||||
@@ -60,33 +45,16 @@ func CobraRunE(vars *variables) func(cmd *cobra.Command, args []string) (err err
|
||||
return fmt.Errorf("partition and disk must be specified")
|
||||
}
|
||||
delete(vars.profileConf.Disks, "UNDEF")
|
||||
|
||||
buffer, err := yaml.Marshal(vars.profileConf)
|
||||
if err != nil {
|
||||
wwlog.Error("Cant marshall nodeInfo", err)
|
||||
os.Exit(1)
|
||||
wwlog.Error("Can't marshall nodeInfo", err)
|
||||
return err
|
||||
}
|
||||
set := wwapiv1.ProfileSetParameter{
|
||||
set := wwapiv1.NodeAddParameter{
|
||||
NodeConfYaml: string(buffer[:]),
|
||||
NetdevDelete: vars.SetNetDevDel,
|
||||
AllProfiles: vars.SetNodeAll,
|
||||
Force: vars.SetForce,
|
||||
ProfileNames: args,
|
||||
NodeNames: args,
|
||||
Force: true,
|
||||
}
|
||||
|
||||
if !vars.SetYes {
|
||||
// The checks run twice in the prompt case.
|
||||
// Avoiding putting in a blocking prompt in an API.
|
||||
_, _, err = apiprofile.ProfileSetParameterCheck(&set, false)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
yes := util.ConfirmationPrompt(fmt.Sprintf("Are you sure you add the profile %s", args))
|
||||
if !yes {
|
||||
return
|
||||
}
|
||||
}
|
||||
return apiprofile.AddProfile(&set)
|
||||
return apiprofile.ProfileAdd(&set)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user