Clean up and optimize the node and profile sets

This commit is contained in:
Gregory Kurtzer
2020-12-22 21:18:38 -08:00
parent 780fb4faa8
commit 7aee24e5c1
2 changed files with 41 additions and 256 deletions

View File

@@ -66,175 +66,87 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetComment != "" { if SetComment != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting comment to: %s\n", n.Id.Get(), SetComment) wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting comment to: %s\n", n.Id.Get(), SetComment)
n.Comment.Set(SetComment) n.Comment.Set(SetComment)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetContainer != "" { if SetContainer != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting container name to: %s\n", n.Id.Get(), SetContainer) wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting container name to: %s\n", n.Id.Get(), SetContainer)
n.ContainerName.Set(SetContainer) n.ContainerName.Set(SetContainer)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetInit != "" { if SetInit != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting init command to: %s\n", n.Id.Get(), SetInit) wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting init command to: %s\n", n.Id.Get(), SetInit)
n.Init.Set(SetInit) n.Init.Set(SetInit)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetRoot != "" { if SetRoot != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting root to: %s\n", n.Id.Get(), SetRoot) wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting root to: %s\n", n.Id.Get(), SetRoot)
n.Root.Set(SetRoot) n.Root.Set(SetRoot)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetKernel != "" { if SetKernel != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting kernel to: %s\n", n.Id.Get(), SetKernel) wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting kernel to: %s\n", n.Id.Get(), SetKernel)
n.KernelVersion.Set(SetKernel) n.KernelVersion.Set(SetKernel)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetKernelArgs != "" { if SetKernelArgs != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting kernel args to: %s\n", n.Id.Get(), SetKernelArgs) wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting kernel args to: %s\n", n.Id.Get(), SetKernelArgs)
n.KernelArgs.Set(SetKernelArgs) n.KernelArgs.Set(SetKernelArgs)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetClusterName != "" { if SetClusterName != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting cluster name to: %s\n", n.Id.Get(), SetClusterName) wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting cluster name to: %s\n", n.Id.Get(), SetClusterName)
n.ClusterName.Set(SetClusterName) n.ClusterName.Set(SetClusterName)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetIpxe != "" { if SetIpxe != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting iPXE template to: %s\n", n.Id.Get(), SetIpxe) wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting iPXE template to: %s\n", n.Id.Get(), SetIpxe)
n.Ipxe.Set(SetIpxe) n.Ipxe.Set(SetIpxe)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetRuntimeOverlay != "" { if SetRuntimeOverlay != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting runtime overlay to: %s\n", n.Id.Get(), SetRuntimeOverlay) wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting runtime overlay to: %s\n", n.Id.Get(), SetRuntimeOverlay)
n.RuntimeOverlay.Set(SetRuntimeOverlay) n.RuntimeOverlay.Set(SetRuntimeOverlay)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetSystemOverlay != "" { if SetSystemOverlay != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting system overlay to: %s\n", n.Id.Get(), SetSystemOverlay) wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting system overlay to: %s\n", n.Id.Get(), SetSystemOverlay)
n.SystemOverlay.Set(SetSystemOverlay) n.SystemOverlay.Set(SetSystemOverlay)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetIpmiIpaddr != "" { if SetIpmiIpaddr != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP address to: %s\n", n.Id.Get(), SetIpmiIpaddr) wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP address to: %s\n", n.Id.Get(), SetIpmiIpaddr)
n.IpmiIpaddr.Set(SetIpmiIpaddr) n.IpmiIpaddr.Set(SetIpmiIpaddr)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetIpmiNetmask != "" { if SetIpmiNetmask != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI netmask to: %s\n", n.Id.Get(), SetIpmiNetmask) wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI netmask to: %s\n", n.Id.Get(), SetIpmiNetmask)
n.IpmiNetmask.Set(SetIpmiNetmask) n.IpmiNetmask.Set(SetIpmiNetmask)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetIpmiGateway != "" { if SetIpmiGateway != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI gateway to: %s\n", n.Id.Get(), SetIpmiGateway) wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI gateway to: %s\n", n.Id.Get(), SetIpmiGateway)
n.IpmiGateway.Set(SetIpmiGateway) n.IpmiGateway.Set(SetIpmiGateway)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetIpmiUsername != "" { if SetIpmiUsername != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP username to: %s\n", n.Id.Get(), SetIpmiUsername) wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP username to: %s\n", n.Id.Get(), SetIpmiUsername)
n.IpmiUserName.Set(SetIpmiUsername) n.IpmiUserName.Set(SetIpmiUsername)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetIpmiPassword != "" { if SetIpmiPassword != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP password to: %s\n", n.Id.Get(), SetIpmiPassword) wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP password to: %s\n", n.Id.Get(), SetIpmiPassword)
n.IpmiPassword.Set(SetIpmiPassword) n.IpmiPassword.Set(SetIpmiPassword)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetDiscoverable == true { if SetDiscoverable == true {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting node to discoverable\n", n.Id.Get()) wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting node to discoverable\n", n.Id.Get())
n.Discoverable.SetB(true) n.Discoverable.SetB(true)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetUndiscoverable == true { if SetUndiscoverable == true {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting node to undiscoverable\n", n.Id.Get()) wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting node to undiscoverable\n", n.Id.Get())
n.Discoverable.SetB(false) n.Discoverable.SetB(false)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if len(SetAddProfile) > 0 { if len(SetAddProfile) > 0 {
@@ -242,22 +154,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, adding profile to '%s'\n", n.Id.Get(), p) wwlog.Printf(wwlog.VERBOSE, "Node: %s, adding profile to '%s'\n", n.Id.Get(), p)
n.Profiles = util.SliceAddUniqueElement(n.Profiles, p) n.Profiles = util.SliceAddUniqueElement(n.Profiles, p)
} }
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if len(SetDelProfile) > 0 { if len(SetDelProfile) > 0 {
for _, p := range SetDelProfile { for _, p := range SetDelProfile {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, deleting profile from '%s'\n", n.Id.Get(), p) wwlog.Printf(wwlog.VERBOSE, "Node: %s, deleting profile from '%s'\n", n.Id.Get(), p)
n.Profiles = util.SliceRemoveElement(n.Profiles, p) n.Profiles = util.SliceRemoveElement(n.Profiles, p)
} }
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetNetDevDel == true { if SetNetDevDel == true {
@@ -272,13 +175,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} }
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Deleting network device: %s\n", n.Id.Get(), SetNetDev) wwlog.Printf(wwlog.VERBOSE, "Node: %s, Deleting network device: %s\n", n.Id.Get(), SetNetDev)
delete(n.NetDevs, SetNetDev) delete(n.NetDevs, SetNetDev)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetIpaddr != "" { if SetIpaddr != "" {
if SetNetDev == "" { if SetNetDev == "" {
@@ -292,13 +189,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} }
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Ipaddr to: %s\n", n.Id.Get(), SetNetDev, SetIpaddr) wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting Ipaddr to: %s\n", n.Id.Get(), SetNetDev, SetIpaddr)
n.NetDevs[SetNetDev].Ipaddr.Set(SetIpaddr) n.NetDevs[SetNetDev].Ipaddr.Set(SetIpaddr)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetNetmask != "" { if SetNetmask != "" {
if SetNetDev == "" { if SetNetDev == "" {
@@ -312,13 +203,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} }
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting netmask to: %s\n", n.Id.Get(), SetNetDev, SetNetmask) wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting netmask to: %s\n", n.Id.Get(), SetNetDev, SetNetmask)
n.NetDevs[SetNetDev].Netmask.Set(SetNetmask) n.NetDevs[SetNetDev].Netmask.Set(SetNetmask)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetGateway != "" { if SetGateway != "" {
if SetNetDev == "" { if SetNetDev == "" {
@@ -332,13 +217,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} }
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting gateway to: %s\n", n.Id.Get(), SetNetDev, SetGateway) wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting gateway to: %s\n", n.Id.Get(), SetNetDev, SetGateway)
n.NetDevs[SetNetDev].Gateway.Set(SetGateway) n.NetDevs[SetNetDev].Gateway.Set(SetGateway)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetHwaddr != "" { if SetHwaddr != "" {
if SetNetDev == "" { if SetNetDev == "" {
@@ -352,13 +231,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} }
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting HW address to: %s\n", n.Id.Get(), SetNetDev, SetHwaddr) wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting HW address to: %s\n", n.Id.Get(), SetNetDev, SetHwaddr)
n.NetDevs[SetNetDev].Hwaddr.Set(SetHwaddr) n.NetDevs[SetNetDev].Hwaddr.Set(SetHwaddr)
err := nodeDB.NodeUpdate(n) }
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err) err := nodeDB.NodeUpdate(n)
os.Exit(1) if err != nil {
} wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
} }
} }

View File

@@ -70,145 +70,72 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetComment != "" { if SetComment != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting comment to: %s\n", p.Id, SetComment) wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting comment to: %s\n", p.Id, SetComment)
p.Comment.Set(SetComment) p.Comment.Set(SetComment)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetClusterName != "" { if SetClusterName != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting cluster name to: %s\n", p.Id, SetClusterName) wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting cluster name to: %s\n", p.Id, SetClusterName)
p.ClusterName.Set(SetClusterName) p.ClusterName.Set(SetClusterName)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetContainer != "" { if SetContainer != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting Container name to: %s\n", p.Id, SetContainer) wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting Container name to: %s\n", p.Id, SetContainer)
p.ContainerName.Set(SetContainer) p.ContainerName.Set(SetContainer)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetInit != "" { if SetInit != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting init command to: %s\n", p.Id, SetInit) wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting init command to: %s\n", p.Id, SetInit)
p.Init.Set(SetInit) p.Init.Set(SetInit)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetRoot != "" { if SetRoot != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting root to: %s\n", p.Id, SetRoot) wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting root to: %s\n", p.Id, SetRoot)
p.Root.Set(SetRoot) p.Root.Set(SetRoot)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetKernel != "" { if SetKernel != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting Kernel to: %s\n", p.Id, SetKernel) wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting Kernel to: %s\n", p.Id, SetKernel)
p.KernelVersion.Set(SetKernel) p.KernelVersion.Set(SetKernel)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetKernelArgs != "" { if SetKernelArgs != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting Kernel args to: %s\n", p.Id, SetKernelArgs) wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting Kernel args to: %s\n", p.Id, SetKernelArgs)
p.KernelArgs.Set(SetKernelArgs) p.KernelArgs.Set(SetKernelArgs)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetIpxe != "" { if SetIpxe != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting iPXE template to: %s\n", p.Id, SetIpxe) wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting iPXE template to: %s\n", p.Id, SetIpxe)
p.Ipxe.Set(SetIpxe) p.Ipxe.Set(SetIpxe)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetRuntimeOverlay != "" { if SetRuntimeOverlay != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting runtime overlay to: %s\n", p.Id, SetRuntimeOverlay) wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting runtime overlay to: %s\n", p.Id, SetRuntimeOverlay)
p.RuntimeOverlay.Set(SetRuntimeOverlay) p.RuntimeOverlay.Set(SetRuntimeOverlay)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetSystemOverlay != "" { if SetSystemOverlay != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting system overlay to: %s\n", p.Id, SetSystemOverlay) wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting system overlay to: %s\n", p.Id, SetSystemOverlay)
p.SystemOverlay.Set(SetSystemOverlay) p.SystemOverlay.Set(SetSystemOverlay)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetIpmiNetmask != "" { if SetIpmiNetmask != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiNetmask) wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiNetmask)
p.IpmiNetmask.Set(SetIpmiNetmask) p.IpmiNetmask.Set(SetIpmiNetmask)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetIpmiGateway != "" { if SetIpmiGateway != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiGateway) wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiGateway)
p.IpmiGateway.Set(SetIpmiGateway) p.IpmiGateway.Set(SetIpmiGateway)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetIpmiUsername != "" { if SetIpmiUsername != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiUsername) wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiUsername)
p.IpmiUserName.Set(SetIpmiUsername) p.IpmiUserName.Set(SetIpmiUsername)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetIpmiPassword != "" { if SetIpmiPassword != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiPassword) wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiPassword)
p.IpmiPassword.Set(SetIpmiPassword) p.IpmiPassword.Set(SetIpmiPassword)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetNetDevDel == true { if SetNetDevDel == true {
@@ -223,14 +150,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} }
wwlog.Printf(wwlog.VERBOSE, "Profile %s: Deleting network device: %s\n", p.Id.Get(), SetNetDev) wwlog.Printf(wwlog.VERBOSE, "Profile %s: Deleting network device: %s\n", p.Id.Get(), SetNetDev)
delete(p.NetDevs, SetNetDev) delete(p.NetDevs, SetNetDev)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetIpaddr != "" { if SetIpaddr != "" {
if SetNetDev == "" { if SetNetDev == "" {
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n") wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
@@ -243,14 +165,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} }
wwlog.Printf(wwlog.VERBOSE, "Profile '%s': Setting IP address to: %s:%s\n", p.Id.Get(), SetNetDev, SetHwaddr) wwlog.Printf(wwlog.VERBOSE, "Profile '%s': Setting IP address to: %s:%s\n", p.Id.Get(), SetNetDev, SetHwaddr)
p.NetDevs[SetNetDev].Ipaddr.Set(SetIpaddr) p.NetDevs[SetNetDev].Ipaddr.Set(SetIpaddr)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetNetmask != "" { if SetNetmask != "" {
if SetNetDev == "" { if SetNetDev == "" {
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n") wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
@@ -263,14 +180,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} }
wwlog.Printf(wwlog.VERBOSE, "Profile '%s': Setting netmask to: %s:%s\n", p.Id.Get(), SetNetDev, SetHwaddr) wwlog.Printf(wwlog.VERBOSE, "Profile '%s': Setting netmask to: %s:%s\n", p.Id.Get(), SetNetDev, SetHwaddr)
p.NetDevs[SetNetDev].Netmask.Set(SetNetmask) p.NetDevs[SetNetDev].Netmask.Set(SetNetmask)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetGateway != "" { if SetGateway != "" {
if SetNetDev == "" { if SetNetDev == "" {
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n") wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
@@ -283,14 +195,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} }
wwlog.Printf(wwlog.VERBOSE, "Profile '%s': Setting gateway to: %s:%s\n", p.Id.Get(), SetNetDev, SetHwaddr) wwlog.Printf(wwlog.VERBOSE, "Profile '%s': Setting gateway to: %s:%s\n", p.Id.Get(), SetNetDev, SetHwaddr)
p.NetDevs[SetNetDev].Gateway.Set(SetGateway) p.NetDevs[SetNetDev].Gateway.Set(SetGateway)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if SetHwaddr != "" { if SetHwaddr != "" {
if SetNetDev == "" { if SetNetDev == "" {
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n") wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
@@ -303,15 +210,14 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
} }
wwlog.Printf(wwlog.VERBOSE, "Profile '%s': Setting HW address to: %s:%s\n", p.Id.Get(), SetNetDev, SetHwaddr) wwlog.Printf(wwlog.VERBOSE, "Profile '%s': Setting HW address to: %s:%s\n", p.Id.Get(), SetNetDev, SetHwaddr)
p.NetDevs[SetNetDev].Hwaddr.Set(SetHwaddr) p.NetDevs[SetNetDev].Hwaddr.Set(SetHwaddr)
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
} }
if len(profiles) > 0 { if len(profiles) > 0 {