Add IpmiNetmask configuration

This commit is contained in:
Gregory Kurtzer
2020-12-01 18:03:22 -08:00
parent 37eaa979ec
commit 581bc929e0
11 changed files with 121 additions and 78 deletions

View File

@@ -90,6 +90,16 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
}
if SetIpmiNetmask != "" {
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting IPMI username to: %s\n", g.Id, SetIpmiNetmask)
g.IpmiNetmask = SetIpmiNetmask
err := nodeDB.GroupUpdate(g)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
}
if SetIpmiUsername != "" {
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting IPMI username to: %s\n", g.Id, SetIpmiUsername)
@@ -154,7 +164,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
}
if len(groups) > 0 {

View File

@@ -4,23 +4,24 @@ import "github.com/spf13/cobra"
var (
baseCmd = &cobra.Command{
Use: "set",
Short: "Set group configurations",
Long: "Set group configurations ",
RunE: CobraRunE,
Use: "set",
Short: "Set group configurations",
Long: "Set group configurations ",
RunE: CobraRunE,
}
SetVnfs string
SetKernel string
SetDomainName string
SetIpxe string
SetVnfs string
SetKernel string
SetDomainName string
SetIpxe string
SetRuntimeOverlay string
SetSystemOverlay string
SetClearNodes bool
SetIpmiUsername string
SetIpmiPassword string
SetGroupAll bool
SetAddProfile []string
SetDelProfile []string
SetSystemOverlay string
SetClearNodes bool
SetIpmiNetmask string
SetIpmiUsername string
SetIpmiPassword string
SetGroupAll bool
SetAddProfile []string
SetDelProfile []string
)
func init() {
@@ -30,6 +31,7 @@ func init() {
baseCmd.PersistentFlags().StringVarP(&SetIpxe, "ipxe", "P", "", "Set the node's iPXE template name")
baseCmd.PersistentFlags().StringVarP(&SetRuntimeOverlay, "runtime", "R", "", "Set the node's runtime overlay")
baseCmd.PersistentFlags().StringVarP(&SetSystemOverlay, "system", "S", "", "Set the node's system overlay")
baseCmd.PersistentFlags().StringVar(&SetIpmiNetmask, "ipminetmask", "", "Set the node's IPMI netmask")
baseCmd.PersistentFlags().StringVar(&SetIpmiUsername, "ipmiuser", "", "Set the node's IPMI username")
baseCmd.PersistentFlags().StringVar(&SetIpmiPassword, "ipmipass", "", "Set the node's IPMI password")

View File

@@ -9,8 +9,6 @@ import (
"strings"
)
func CobraRunE(cmd *cobra.Command, args []string) error {
var err error
var nodes []node.NodeInfo
@@ -31,7 +29,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
if ShowAll == true {
for _, node := range nodes {
fmt.Printf("################################################################################\n")
@@ -47,23 +44,24 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "KernelArgs", node.KernelArgs.Source(), node.KernelArgs.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "RuntimeOverlay", node.RuntimeOverlay.Source(), node.RuntimeOverlay.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "SystemOverlay", node.SystemOverlay.Source(), node.SystemOverlay.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "IpmiUserName", node.IpmiUserName.Source(), node.IpmiUserName.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "IpmiIpaddr", node.IpmiIpaddr.Source(), node.IpmiIpaddr.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "Ipxe", node.Ipxe.Source(), node.Ipxe.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "IpmiIpaddr", node.IpmiIpaddr.Source(), node.IpmiIpaddr.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "IpmiNetmask", node.IpmiNetmask.Source(), node.IpmiNetmask.String())
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), "IpmiUserName", node.IpmiUserName.Source(), node.IpmiUserName.String())
for name, netdev := range node.NetDevs {
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), name +":IPADDR", "node", netdev.Ipaddr)
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), name +":NETMASK", "node", netdev.Netmask)
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), name +":GATEWAY", "node", netdev.Gateway)
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), name +":HWADDR", "node", netdev.Hwaddr)
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), name+":IPADDR", "node", netdev.Ipaddr)
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), name+":NETMASK", "node", netdev.Netmask)
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), name+":GATEWAY", "node", netdev.Gateway)
fmt.Printf("%-20s %-18s %8s: %s\n", node.Fqdn.Get(), name+":HWADDR", "node", netdev.Hwaddr)
}
// v := reflect.ValueOf(node)
// typeOfS := v.Type()
// for i := 0; i< v.NumField(); i++ {
// //TODO: Fix for NetDevs and Interface should print Fprint() method
// fmt.Printf("%-25s %s = %#v\n", node.Fqdn.Get(), typeOfS.Field(i).Name, v.Field(i).Interface())
// }
// typeOfS := v.Type()
// for i := 0; i< v.NumField(); i++ {
// //TODO: Fix for NetDevs and Interface should print Fprint() method
// fmt.Printf("%-25s %s = %#v\n", node.Fqdn.Get(), typeOfS.Field(i).Name, v.Field(i).Interface())
// }
}
} else if ShowNet == true {
@@ -93,7 +91,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
fmt.Println(strings.Repeat("=", 120))
for _, node := range nodes {
fmt.Printf("%-22s %-12s %-26s %-35s %s\n", node.Fqdn.Get(), node.Gid.String(), node.KernelVersion.String(), node.Vnfs.String(), node.SystemOverlay.String() +"/"+ node.RuntimeOverlay.String())
fmt.Printf("%-22s %-12s %-26s %-35s %s\n", node.Fqdn.Get(), node.Gid.String(), node.KernelVersion.String(), node.Vnfs.String(), node.SystemOverlay.String()+"/"+node.RuntimeOverlay.String())
}
} else {
@@ -106,6 +104,5 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
return nil
}

View File

@@ -126,6 +126,16 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
}
if SetIpmiNetmask != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI netmask to: %s\n", n.Fqdn, SetIpmiNetmask)
n.IpmiNetmask.Set(SetIpmiNetmask)
err := nodeDB.NodeUpdate(n)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
}
if SetIpmiUsername != "" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP username to: %s\n", n.Fqdn, SetIpmiUsername)
@@ -170,8 +180,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SetNetDevDel == true {
if SetNetDev == "" {
wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n")
@@ -292,4 +300,4 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
return nil
}
}

View File

@@ -4,31 +4,32 @@ import "github.com/spf13/cobra"
var (
baseCmd = &cobra.Command{
Use: "set",
Short: "Set node configurations",
Long: "Set node configurations ",
RunE: CobraRunE,
Use: "set",
Short: "Set node configurations",
Long: "Set node configurations ",
RunE: CobraRunE,
}
SetVnfs string
SetKernel string
SetNetDev string
SetIpaddr string
SetNetmask string
SetGateway string
SetHwaddr string
SetNetDevDel bool
SetDomainName string
SetIpxe string
SetVnfs string
SetKernel string
SetNetDev string
SetIpaddr string
SetNetmask string
SetGateway string
SetHwaddr string
SetNetDevDel bool
SetDomainName string
SetIpxe string
SetRuntimeOverlay string
SetSystemOverlay string
SetHostname string
SetIpmiIpaddr string
SetIpmiUsername string
SetIpmiPassword string
SetNodeAll bool
SetYes bool
SetAddProfile []string
SetDelProfile []string
SetSystemOverlay string
SetHostname string
SetIpmiIpaddr string
SetIpmiNetmask string
SetIpmiUsername string
SetIpmiPassword string
SetNodeAll bool
SetYes bool
SetAddProfile []string
SetDelProfile []string
)
func init() {
@@ -39,7 +40,8 @@ func init() {
baseCmd.PersistentFlags().StringVarP(&SetRuntimeOverlay, "runtime", "R", "", "Set the node's runtime overlay")
baseCmd.PersistentFlags().StringVarP(&SetSystemOverlay, "system", "S", "", "Set the node's system overlay")
baseCmd.PersistentFlags().StringVarP(&SetHostname, "hostname", "N", "", "Set the node's hostname")
baseCmd.PersistentFlags().StringVar(&SetIpmiIpaddr, "ipmi", "", "Set the node's IPMI address")
baseCmd.PersistentFlags().StringVar(&SetIpmiIpaddr, "ipmi", "", "Set the node's IPMI IP address")
baseCmd.PersistentFlags().StringVar(&SetIpmiNetmask, "ipminetmask", "", "Set the node's IPMI netmask")
baseCmd.PersistentFlags().StringVar(&SetIpmiUsername, "ipmiuser", "", "Set the node's IPMI username")
baseCmd.PersistentFlags().StringVar(&SetIpmiPassword, "ipmipass", "", "Set the node's IPMI password")

View File

@@ -119,6 +119,16 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
}
if SetIpmiNetmask != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiNetmask)
p.IpmiNetmask = SetIpmiNetmask
err := nodeDB.ProfileUpdate(p)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
os.Exit(1)
}
}
if SetIpmiUsername != "" {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting IPMI username to: %s\n", p.Id, SetIpmiUsername)
@@ -161,4 +171,4 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
return nil
}
}

View File

@@ -4,21 +4,21 @@ import "github.com/spf13/cobra"
var (
baseCmd = &cobra.Command{
Use: "set",
Short: "Set profile configurations",
Long: "Profile configurations ",
RunE: CobraRunE,
Use: "set",
Short: "Set profile configurations",
Long: "Profile configurations ",
RunE: CobraRunE,
}
SetAll bool
SetVnfs string
SetKernel string
SetDomainName string
SetIpxe string
SetAll bool
SetVnfs string
SetKernel string
SetDomainName string
SetIpxe string
SetRuntimeOverlay string
SetSystemOverlay string
SetIpmiUsername string
SetIpmiPassword string
SetSystemOverlay string
SetIpmiNetmask string
SetIpmiUsername string
SetIpmiPassword string
)
func init() {
@@ -28,6 +28,7 @@ func init() {
baseCmd.PersistentFlags().StringVarP(&SetIpxe, "ipxe", "P", "", "Set the node's iPXE template name")
baseCmd.PersistentFlags().StringVarP(&SetRuntimeOverlay, "runtime", "R", "", "Set the node's runtime overlay")
baseCmd.PersistentFlags().StringVarP(&SetSystemOverlay, "system", "S", "", "Set the node's system overlay")
baseCmd.PersistentFlags().StringVar(&SetIpmiNetmask, "ipminetmask", "", "Set the node's IPMI netmask")
baseCmd.PersistentFlags().StringVar(&SetIpmiUsername, "ipmiuser", "", "Set the node's IPMI username")
baseCmd.PersistentFlags().StringVar(&SetIpmiPassword, "ipmipass", "", "Set the node's IPMI password")