This is a work in progress API shift as the data structure has changed and I'm cleaning the interface.

This commit is contained in:
Gregory Kurtzer
2020-12-03 07:34:26 -08:00
parent 931a3cce05
commit eaf6bb1196
23 changed files with 665 additions and 825 deletions

View File

@@ -11,7 +11,7 @@ import (
func CobraRunE(cmd *cobra.Command, args []string) error {
var err error
var profiles []node.ProfileInfo
var profiles []node.NodeInfo
nodeDB, err := node.New()
if err != nil {
@@ -19,29 +19,18 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
if err != nil {
wwlog.Printf(wwlog.ERROR, "Cloud not get nodeList: %s\n", err)
os.Exit(1)
}
if len(args) == 0 {
args = append(args, "default")
}
if SetAll == true {
var tmp []node.ProfileInfo
tmp, err = nodeDB.FindAllProfiles()
profiles, err = nodeDB.FindAllProfiles()
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
for _, p := range tmp {
profiles = append(profiles, p)
}
} else {
var tmp []node.ProfileInfo
var tmp []node.NodeInfo
tmp, err = nodeDB.FindAllProfiles()
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -50,7 +39,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
for _, a := range args {
for _, p := range tmp {
if p.Id == a {
if p.Id.Get() == a {
profiles = append(profiles, p)
}
}
@@ -59,10 +48,20 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
for _, p := range profiles {
if SetComment != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting comment to: %s\n", p.Id, SetComment)
p.Comment.Set(SetComment)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
}
if SetDomainName != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting domain name to: %s\n", p.Id, SetDomainName)
p.DomainName = SetDomainName
p.DomainName.Set(SetDomainName)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -72,7 +71,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetVnfs != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting VNFS to: %s\n", p.Id, SetVnfs)
p.Vnfs = SetVnfs
p.Vnfs.Set(SetVnfs)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -82,7 +81,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetKernel != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting Kernel version to: %s\n", p.Id, SetKernel)
p.KernelVersion = SetKernel
p.KernelVersion.Set(SetKernel)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -92,7 +91,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetIpxe != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting iPXE template to: %s\n", p.Id, SetIpxe)
p.Ipxe = SetIpxe
p.Ipxe.Set(SetIpxe)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -102,7 +101,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetRuntimeOverlay != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting runtime overlay to: %s\n", p.Id, SetRuntimeOverlay)
p.RuntimeOverlay = SetRuntimeOverlay
p.RuntimeOverlay.Set(SetRuntimeOverlay)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -112,7 +111,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetSystemOverlay != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting system overlay to: %s\n", p.Id, SetSystemOverlay)
p.SystemOverlay = SetSystemOverlay
p.SystemOverlay.Set(SetSystemOverlay)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -122,7 +121,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetIpmiNetmask != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiNetmask)
p.IpmiNetmask = SetIpmiNetmask
p.IpmiNetmask.Set(SetIpmiNetmask)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -132,7 +131,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetIpmiUsername != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiUsername)
p.IpmiUserName = SetIpmiUsername
p.IpmiUserName.Set(SetIpmiUsername)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
@@ -142,7 +141,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetIpmiPassword != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiPassword)
p.IpmiPassword = SetIpmiPassword
p.IpmiPassword.Set(SetIpmiPassword)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)