Add IPMI configurations and cleaned up nodes.conf
This commit is contained in:
@@ -1,34 +1,15 @@
|
||||
nodegroups:
|
||||
group_1:
|
||||
comment: This is the group 1
|
||||
vnfs: /var/chroots/centos-7
|
||||
system overlay: default
|
||||
default:
|
||||
comment: This is the default group
|
||||
vnfs: docker://warewulf/centos-8
|
||||
runtime overlay: default
|
||||
domain suffix: group1
|
||||
nodes:
|
||||
n0000:
|
||||
hostname: localtest
|
||||
kernel version: 3.10.0-1127.el7.x86_64
|
||||
kernel args: crashkernel=no quiet
|
||||
system overlay: test
|
||||
netdevs:
|
||||
eth0:
|
||||
hwaddr: xx:xx:xx:xx:xx:aa
|
||||
ipaddr: 192.168.1.1
|
||||
netmask: 255.255.255.0
|
||||
gateway: 192.168.1.1
|
||||
group_2:
|
||||
comment: This is the group 2
|
||||
vnfs: docker://warewulf/centos-7
|
||||
system overlay: default
|
||||
runtime overlay: default
|
||||
domain suffix: group2
|
||||
kernel version: 3.10.0-1127.el7.x86_64
|
||||
domain suffix: default
|
||||
kernel version: ""
|
||||
kernel args: crashkernel=no quiet
|
||||
nodes:
|
||||
n0000:
|
||||
hostname: n0000
|
||||
ipmi ipaddr: x.x.x.x
|
||||
kernel args: crashkernel=no
|
||||
netdevs:
|
||||
eth0:
|
||||
hwaddr: 00:0c:29:23:8b:48
|
||||
@@ -37,21 +18,36 @@ nodegroups:
|
||||
gateway: 192.168.1.1
|
||||
type: ethernet
|
||||
ib0:
|
||||
hwaddr: xx:xx:xx:xx:xx:xx
|
||||
ipaddr: x.x.x.x
|
||||
netmask: x.x.x.x
|
||||
gateway: x.x.x.x
|
||||
hwaddr: aa:bb:cc:dd:ee:a0
|
||||
ipaddr: 192.168.10.100
|
||||
netmask: 255.255.255.0
|
||||
type: infiniband
|
||||
n0001:
|
||||
hostname: n0001
|
||||
ipmi ipaddr: x.x.x.x
|
||||
netdevs:
|
||||
eth0:
|
||||
hwaddr: xx:xx:xx:xx:xx:xx
|
||||
hwaddr: aa:bb:cc:dd:ee:b0
|
||||
ipaddr: 192.168.1.101
|
||||
netmask: 255.255.255.0
|
||||
gateway: 192.168.1.1
|
||||
ib0:
|
||||
hwaddr: xx:xx:xx:xx:xx:xx
|
||||
ipaddr: x.x.x.x
|
||||
netmask: x.x.x.x
|
||||
hwaddr: aa:bb:cc:dd:ee:b1
|
||||
ipaddr: 192.168.10.100
|
||||
netmask: 255.255.255.0
|
||||
group_1:
|
||||
comment: This is the group 1
|
||||
vnfs: /var/chroots/centos-7
|
||||
runtime overlay: default
|
||||
domain suffix: group1
|
||||
nodes:
|
||||
n0000:
|
||||
hostname: localtest
|
||||
kernel version: 3.10.0-1127.el7.x86_64
|
||||
system overlay: test
|
||||
netdevs:
|
||||
eth0:
|
||||
hwaddr: aa:bb:cc:dd:ee:c0
|
||||
ipaddr: 192.168.2.100
|
||||
netmask: 255.255.255.0
|
||||
gateway: 192.168.2.1
|
||||
|
||||
@@ -163,6 +163,65 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
if SetIpmiIpaddr != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting IPMI IP address to: %s\n", g.Id, SetIpmiIpaddr)
|
||||
err := nodeDB.SetGroupVal(g.Id, "ipmiipaddr", SetIpmiIpaddr)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if SetClearNodes == true {
|
||||
nodes, err := nodeDB.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
for _, n := range nodes {
|
||||
_ = nodeDB.SetNodeVal(g.Id, n.Id, "ipmiipaddr", "")
|
||||
}
|
||||
}
|
||||
}
|
||||
if SetIpmiUsername != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting IPMI IP username to: %s\n", g.Id, SetIpmiUsername)
|
||||
err := nodeDB.SetGroupVal(g.Id, "ipmiusername", SetIpmiUsername)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if SetClearNodes == true {
|
||||
nodes, err := nodeDB.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
for _, n := range nodes {
|
||||
_ = nodeDB.SetNodeVal(g.Id, n.Id, "ipmiusername", "")
|
||||
}
|
||||
}
|
||||
}
|
||||
if SetIpmiPassword != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Group: %s, Setting IPMI IP password to: %s\n", g.Id, SetIpmiPassword)
|
||||
err := nodeDB.SetGroupVal(g.Id, "ipmipassword", SetIpmiPassword)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if SetClearNodes == true {
|
||||
nodes, err := nodeDB.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
for _, n := range nodes {
|
||||
_ = nodeDB.SetNodeVal(g.Id, n.Id, "ipmipassword", "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@ var (
|
||||
SetSystemOverlay string
|
||||
SetHostname string
|
||||
SetClearNodes bool
|
||||
SetIpmiIpaddr string
|
||||
SetIpmiUsername string
|
||||
SetIpmiPassword string
|
||||
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -26,6 +30,10 @@ 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(&SetIpmiIpaddr, "ipmi", "", "Set the node's IPMI address")
|
||||
baseCmd.PersistentFlags().StringVar(&SetIpmiUsername, "ipmiuser", "", "Set the node's IPMI username")
|
||||
baseCmd.PersistentFlags().StringVar(&SetIpmiPassword, "ipmipass", "", "Set the node's IPMI password")
|
||||
|
||||
baseCmd.PersistentFlags().BoolVarP(&SetClearNodes, "clear", "c", false, "Clear node configurations when setting parent group")
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,30 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if SetIpmiIpaddr != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP address to: %s\n", n.Fqdn, SetIpmiIpaddr)
|
||||
err := nodeDB.SetNodeVal(n.Gid, n.Id, "ipmiipaddr", SetIpmiIpaddr)
|
||||
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)
|
||||
err := nodeDB.SetNodeVal(n.Gid, n.Id, "ipmiusername", SetIpmiUsername)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if SetIpmiPassword != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting IPMI IP password to: %s\n", n.Fqdn, SetIpmiPassword)
|
||||
err := nodeDB.SetNodeVal(n.Gid, n.Id, "ipmipassword", SetIpmiPassword)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,10 @@ var (
|
||||
SetRuntimeOverlay string
|
||||
SetSystemOverlay string
|
||||
SetHostname string
|
||||
SetIpmiIpaddr string
|
||||
SetIpmiUsername string
|
||||
SetIpmiPassword string
|
||||
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -32,6 +36,9 @@ 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", "H", "", "Set the node's hostname")
|
||||
baseCmd.PersistentFlags().StringVar(&SetIpmiIpaddr, "ipmi", "", "Set the node's IPMI address")
|
||||
baseCmd.PersistentFlags().StringVar(&SetIpmiUsername, "ipmiuser", "", "Set the node's IPMI username")
|
||||
baseCmd.PersistentFlags().StringVar(&SetIpmiPassword, "ipmipass", "", "Set the node's IPMI password")
|
||||
|
||||
baseCmd.PersistentFlags().StringVarP(&SetNetDev, "netdev", "n", "", "Define the network device to configure")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetIpaddr, "ipaddr", "I", "", "Set the node's network device IP address")
|
||||
|
||||
@@ -39,7 +39,7 @@ type nodeGroup struct {
|
||||
}
|
||||
|
||||
type nodeEntry struct {
|
||||
Hostname string
|
||||
Hostname string `yaml:"hostname,omitempty"`
|
||||
Vnfs string `yaml:"vnfs,omitempty"`
|
||||
Ipxe string `yaml:"ipxe template,omitempty"`
|
||||
SystemOverlay string `yaml:"system overlay,omitempty"`
|
||||
@@ -54,11 +54,11 @@ type nodeEntry struct {
|
||||
}
|
||||
|
||||
type netDevs struct {
|
||||
Type string
|
||||
Type string `yaml:"type,omitempty"`
|
||||
Hwaddr string
|
||||
Ipaddr string
|
||||
Netmask string
|
||||
Gateway string
|
||||
Gateway string`yaml:"gateway,omitempty"`
|
||||
}
|
||||
|
||||
type NodeInfo struct {
|
||||
@@ -219,6 +219,13 @@ func (self *nodeYaml) SetGroupVal(groupID string, entry string, value string) er
|
||||
case "RUNTIMEOVERLAY":
|
||||
util.ValidateOrDie("Runtime Overlay", entry, "^[a-zA-Z0-9-._]*$")
|
||||
self.NodeGroups[groupID].RuntimeOverlay = value
|
||||
case "IPMIUSERNAME":
|
||||
util.ValidateOrDie("IPMI Username", entry, "^[a-zA-Z0-9-._]*$")
|
||||
self.NodeGroups[groupID].IpmiUserName = value
|
||||
case "IPMIPASSWORD":
|
||||
util.ValidateOrDie("IPMI Password", entry, "^[a-zA-Z0-9-._]*$")
|
||||
self.NodeGroups[groupID].IpmiPassword = value
|
||||
|
||||
}
|
||||
} else {
|
||||
return errors.New("Group does not exist: " +groupID)
|
||||
@@ -257,6 +264,16 @@ func (self *nodeYaml) SetNodeVal(groupID string, nodeID string, entry string, va
|
||||
case "HOSTNAME":
|
||||
util.ValidateOrDie("Hostname", entry, "^[a-zA-Z0-9-._]*$")
|
||||
self.NodeGroups[groupID].Nodes[nodeID].Hostname = value
|
||||
case "IPMIIPADDR":
|
||||
util.ValidateOrDie("IPMI IP Address", entry, "^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$")
|
||||
self.NodeGroups[groupID].Nodes[nodeID].IpmiIpaddr = value
|
||||
case "IPMIUSERNAME":
|
||||
util.ValidateOrDie("IPMI Username", entry, "^[a-zA-Z0-9-._]*$")
|
||||
self.NodeGroups[groupID].Nodes[nodeID].IpmiUserName = value
|
||||
case "IPMIPASSWORD":
|
||||
util.ValidateOrDie("IPMI Password", entry, "^[a-zA-Z0-9-._]*$")
|
||||
self.NodeGroups[groupID].Nodes[nodeID].IpmiPassword = value
|
||||
|
||||
}
|
||||
} else {
|
||||
return errors.New("Node does not exist: " +groupID+ "/" +nodeID)
|
||||
@@ -423,6 +440,9 @@ func (self *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
|
||||
if n.Ipxe == "" {
|
||||
n.Ipxe = "default"
|
||||
}
|
||||
if n.HostName == "" {
|
||||
n.HostName = nodename
|
||||
}
|
||||
|
||||
if n.DomainName != "" {
|
||||
n.Fqdn = node.Hostname + "." + n.DomainName
|
||||
|
||||
Reference in New Issue
Block a user