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")

View File

@@ -46,6 +46,7 @@ func (self *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
n.Cid.Set(controllername)
n.HostName.Set(node.Hostname)
n.IpmiIpaddr.Set(node.IpmiIpaddr)
n.IpmiNetmask.Set(node.IpmiNetmask)
n.DomainName.Set(node.DomainName)
n.Vnfs.Set(node.Vnfs)
n.KernelVersion.Set(node.KernelVersion)
@@ -61,6 +62,7 @@ func (self *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
n.KernelVersion.SetGroup(group.KernelVersion)
n.KernelArgs.SetGroup(group.KernelArgs)
n.Ipxe.SetGroup(group.Ipxe)
n.IpmiNetmask.SetGroup(group.IpmiNetmask)
n.IpmiUserName.SetGroup(group.IpmiUserName)
n.IpmiPassword.SetGroup(group.IpmiPassword)
n.SystemOverlay.SetGroup(group.SystemOverlay)
@@ -88,6 +90,7 @@ func (self *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
n.KernelVersion.SetProfile(self.NodeProfiles[p].KernelVersion)
n.KernelArgs.SetProfile(self.NodeProfiles[p].KernelArgs)
n.Ipxe.SetProfile(self.NodeProfiles[p].Ipxe)
n.IpmiNetmask.SetProfile(self.NodeProfiles[p].IpmiNetmask)
n.IpmiUserName.SetProfile(self.NodeProfiles[p].IpmiUserName)
n.IpmiPassword.SetProfile(self.NodeProfiles[p].IpmiPassword)
n.SystemOverlay.SetProfile(self.NodeProfiles[p].SystemOverlay)
@@ -124,6 +127,7 @@ func (self *nodeYaml) FindAllGroups() ([]GroupInfo, error) {
g.Vnfs = group.Vnfs
g.KernelVersion = group.KernelVersion
g.KernelArgs = group.KernelArgs
g.IpmiNetmask = group.IpmiNetmask
g.IpmiPassword = group.IpmiPassword
g.IpmiUserName = group.IpmiUserName
g.SystemOverlay = group.SystemOverlay
@@ -214,6 +218,7 @@ func (self *nodeYaml) FindAllProfiles() ([]ProfileInfo, error) {
p.Ipxe = profile.Ipxe
p.KernelVersion = profile.KernelVersion
p.KernelArgs = profile.KernelArgs
p.IpmiNetmask = profile.IpmiNetmask
p.IpmiUserName = profile.IpmiUserName
p.IpmiPassword = profile.IpmiPassword
p.DomainName = profile.DomainName

View File

@@ -21,6 +21,7 @@ type ProfileConf struct {
Ipxe string `yaml:"ipxe template,omitempty"`
KernelVersion string `yaml:"kernel version,omitempty"`
KernelArgs string `yaml:"kernel args,omitempty"`
IpmiNetmask string `yaml:"ipmi netmask,omitempty"`
IpmiUserName string `yaml:"ipmi username,omitempty"`
IpmiPassword string `yaml:"ipmi password,omitempty"`
DomainName string `yaml:"domain name,omitempty"`
@@ -76,6 +77,7 @@ type GroupConf struct {
Ipxe string `yaml:"ipxe template,omitempty"`
KernelVersion string `yaml:"kernel version,omitempty"`
KernelArgs string `yaml:"kernel args,omitempty"`
IpmiNetmask string `yaml:"ipmi netmask,omitempty"`
IpmiUserName string `yaml:"ipmi username,omitempty"`
IpmiPassword string `yaml:"ipmi password,omitempty"`
RuntimeOverlay string `yaml:"runtime overlay files,omitempty"`
@@ -96,6 +98,7 @@ type NodeConf struct {
IpmiUserName string `yaml:"ipmi username,omitempty"`
IpmiPassword string `yaml:"ipmi password,omitempty"`
IpmiIpaddr string `yaml:"ipmi ipaddr,omitempty"`
IpmiNetmask string `yaml:"ipmi netmask,omitempty"`
RuntimeOverlay string `yaml:"runtime overlay files,omitempty"`
SystemOverlay string `yaml:"system overlay files,omitempty"`
Profiles []string `yaml:"profiles,omitempty"`
@@ -136,6 +139,7 @@ type NodeInfo struct {
KernelVersion NodeInfoEntry
KernelArgs NodeInfoEntry
IpmiIpaddr NodeInfoEntry
IpmiNetmask NodeInfoEntry
IpmiUserName NodeInfoEntry
IpmiPassword NodeInfoEntry
RuntimeOverlay NodeInfoEntry
@@ -194,6 +198,7 @@ type GroupInfo struct {
Ipxe string
KernelVersion string
KernelArgs string
IpmiNetmask string
IpmiUserName string
IpmiPassword string
DomainName string
@@ -209,6 +214,7 @@ type ProfileInfo struct {
Ipxe string
KernelVersion string
KernelArgs string
IpmiNetmask string
IpmiUserName string
IpmiPassword string
DomainName string

View File

@@ -81,6 +81,7 @@ func (self *nodeYaml) NodeUpdate(node NodeInfo) error {
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].KernelVersion = node.KernelVersion.GetReal()
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].KernelArgs = node.KernelArgs.GetReal()
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].IpmiIpaddr = node.IpmiIpaddr.GetReal()
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].IpmiNetmask = node.IpmiNetmask.GetReal()
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].IpmiUserName = node.IpmiUserName.GetReal()
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].IpmiPassword = node.IpmiPassword.GetReal()
self.Controllers[controllerID].NodeGroups[groupID].Nodes[nodeID].RuntimeOverlay = node.RuntimeOverlay.GetReal()
@@ -150,6 +151,7 @@ func (self *nodeYaml) GroupUpdate(group GroupInfo) error {
self.Controllers[controllerID].NodeGroups[groupID].KernelVersion = group.KernelVersion
self.Controllers[controllerID].NodeGroups[groupID].KernelArgs = group.KernelArgs
self.Controllers[controllerID].NodeGroups[groupID].Ipxe = group.Ipxe
self.Controllers[controllerID].NodeGroups[groupID].IpmiNetmask = group.IpmiNetmask
self.Controllers[controllerID].NodeGroups[groupID].IpmiUserName = group.IpmiUserName
self.Controllers[controllerID].NodeGroups[groupID].IpmiPassword = group.IpmiPassword
self.Controllers[controllerID].NodeGroups[groupID].RuntimeOverlay = group.RuntimeOverlay
@@ -276,6 +278,7 @@ func (self *nodeYaml) ProfileUpdate(profile ProfileInfo) error {
self.NodeProfiles[profileID].Vnfs = profile.Vnfs
self.NodeProfiles[profileID].Ipxe = profile.Ipxe
self.NodeProfiles[profileID].KernelVersion = profile.KernelVersion
self.NodeProfiles[profileID].IpmiNetmask = profile.IpmiNetmask
self.NodeProfiles[profileID].IpmiUserName = profile.IpmiUserName
self.NodeProfiles[profileID].IpmiPassword = profile.IpmiPassword
self.NodeProfiles[profileID].RuntimeOverlay = profile.RuntimeOverlay

View File

@@ -8,11 +8,11 @@ if [ ! -e /dev/ipmi0 ]; then
ls -la /dev/ipmi0
fi
IP="{{.IpmiIpaddr}}"
NETMASK="{{.NetDevs.eth0.Netmask}}"
GATEWAY="{{.NetDevs.eth0.Gateway}}"
USER="{{.IpmiUserName}}"
PASS="{{.IpmiPassword}}"
IP="{{.Self.IpmiIpaddr}}"
NETMASK="{{.Self.IpmiNetmask}}"
GATEWAY="{{.Self.NetDevs.eth0.Gateway}}"
USER="{{.Self.IpmiUserName}}"
PASS="{{.Self.IpmiPassword}}"
echo IP is $IP
echo NETMASK is $NETMASK