Various fixes found in testing

This commit is contained in:
Gregory Kurtzer
2021-12-29 17:16:53 -08:00
parent 00d8d42e9d
commit 9f53bca1bf
9 changed files with 84 additions and 24 deletions

View File

@@ -94,11 +94,13 @@ files: all
cp -r etc/dhcp $(DESTDIR)/etc/warewulf/
cp -r etc/ipxe $(DESTDIR)/etc/warewulf/
cp -r overlays $(DESTDIR)/var/warewulf/
chmod +x $(DESTDIR)/var/warewulf/overlays/system/default/init
chmod 600 $(DESTDIR)/var/warewulf/overlays/system/default/etc/ssh/ssh*
chmod 644 $(DESTDIR)/var/warewulf/overlays/system/default/etc/ssh/ssh*.pub.ww
mkdir -p $(DESTDIR)/var/warewulf/overlays/system/default/warewulf/bin/
cp wwctl $(DESTDIR)/usr/bin/
mkdir -p $(DESTDIR)/var/warewulf/overlays/wwinit/bin/
mkdir -p $(DESTDIR)/var/warewulf/overlays/wwinit/warewulf/bin/
chmod +x $(DESTDIR)/var/warewulf/overlays/wwinit/init
chmod 600 $(DESTDIR)/var/warewulf/overlays/wwinit/etc/ssh/ssh*
chmod 644 $(DESTDIR)/var/warewulf/overlays/wwinit/etc/ssh/ssh*.pub.ww
mkdir -p $(DESTDIR)/var/warewulf/overlays/wwinit/warewulf/bin/
install -m 0755 wwctl $(DESTDIR)/usr/bin/
mkdir -p $(DESTDIR)/usr/lib/firewalld/services
install -c -m 0644 include/firewalld/warewulf.xml $(DESTDIR)/usr/lib/firewalld/services
mkdir -p $(DESTDIR)/usr/lib/systemd/system

View File

@@ -168,10 +168,15 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetNetName != "" {
if _, ok := n.NetDevs[SetNetName]; !ok {
var nd node.NetDevEntry
n.NetDevs[SetNetName] = &nd
SetNetOnBoot = "yes"
if len(n.NetDevs) == 0 {
SetNetDefault = "yes"
}
n.NetDevs[SetNetName] = &nd
if SetNetDev == "" {
n.NetDevs[SetNetName].Device.Set(SetNetName)
}
@@ -255,6 +260,27 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
}
if SetNetDefault != "" {
if SetNetName == "" {
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
os.Exit(1)
}
if SetNetDefault == "yes" || SetNetDefault == "y" || SetNetDefault == "1" || SetNetDefault == "true" {
// Set all other devices to non-default
for _, n := range n.NetDevs {
n.Default.SetB(false)
}
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting DEFAULT\n", n.Id.Get(), SetNetName)
n.NetDevs[SetNetName].Default.SetB(true)
} else {
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Unsetting DEFAULT\n", n.Id.Get(), SetNetName)
n.NetDevs[SetNetName].Default.SetB(false)
}
}
if SetNetDevDel {
if SetNetName == "" {
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")

View File

@@ -44,6 +44,7 @@ var (
SetHwaddr string
SetType string
SetNetOnBoot string
SetNetDefault string
SetNetDevDel bool
SetClusterName string
SetIpxe string
@@ -138,6 +139,7 @@ func init() {
baseCmd.PersistentFlags().StringVarP(&SetHwaddr, "hwaddr", "H", "", "Set the node's network device HW address")
baseCmd.PersistentFlags().StringVarP(&SetType, "type", "T", "", "Set the node's network device type")
baseCmd.PersistentFlags().StringVar(&SetNetOnBoot, "onboot", "", "Enable/disable device (yes/no)")
baseCmd.PersistentFlags().StringVar(&SetNetDefault, "default", "", "Enable/disable device as default (yes/no)")
baseCmd.PersistentFlags().BoolVar(&SetNetDevDel, "netdel", false, "Delete the node's network device")

View File

@@ -138,10 +138,15 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
if SetNetName != "" {
if _, ok := p.NetDevs[SetNetName]; !ok {
var nd node.NetDevEntry
p.NetDevs[SetNetName] = &nd
SetNetOnBoot = "yes"
if len(p.NetDevs) == 0 {
SetNetDefault = "yes"
}
p.NetDevs[SetNetName] = &nd
if SetNetDev == "" {
p.NetDevs[SetNetName].Device.Set(SetNetName)
}
@@ -215,14 +220,35 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
if SetNetOnBoot == "yes" || SetNetOnBoot == "y" || SetNetOnBoot == "1" || SetNetOnBoot == "true" {
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Setting ONBOOT\n", p.Id.Get(), SetNetName)
wwlog.Printf(wwlog.VERBOSE, "Profile: %s:%s, Setting ONBOOT\n", p.Id.Get(), SetNetName)
p.NetDevs[SetNetName].OnBoot.SetB(true)
} else {
wwlog.Printf(wwlog.VERBOSE, "Node: %s:%s, Unsetting ONBOOT\n", p.Id.Get(), SetNetName)
wwlog.Printf(wwlog.VERBOSE, "Profile: %s:%s, Unsetting ONBOOT\n", p.Id.Get(), SetNetName)
p.NetDevs[SetNetName].OnBoot.SetB(false)
}
}
if SetNetDefault != "" {
if SetNetName == "" {
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")
os.Exit(1)
}
if SetNetDefault == "yes" || SetNetDefault == "y" || SetNetDefault == "1" || SetNetDefault == "true" {
// Set all other devices to non-default
for _, n := range p.NetDevs {
n.Default.SetB(false)
}
wwlog.Printf(wwlog.VERBOSE, "Profile: %s:%s, Setting DEFAULT\n", p.Id.Get(), SetNetName)
p.NetDevs[SetNetName].Default.SetB(true)
} else {
wwlog.Printf(wwlog.VERBOSE, "Profile: %s:%s, Unsetting DEFAULT\n", p.Id.Get(), SetNetName)
p.NetDevs[SetNetName].Default.SetB(false)
}
}
if SetNetDevDel {
if SetNetDev == "" {
wwlog.Printf(wwlog.ERROR, "You must include the '--netname' option\n")

View File

@@ -58,6 +58,7 @@ var (
SetHwaddr string
SetType string
SetNetOnBoot string
SetNetDefault string
SetNetDevDel bool
SetDiscoverable bool
SetUndiscoverable bool
@@ -121,6 +122,7 @@ func init() {
baseCmd.PersistentFlags().StringVarP(&SetHwaddr, "hwaddr", "H", "", "Set the node's network device HW address")
baseCmd.PersistentFlags().StringVarP(&SetType, "type", "T", "", "Set the node's network device type")
baseCmd.PersistentFlags().StringVar(&SetNetOnBoot, "onboot", "", "Enable/disable device (yes/no)")
baseCmd.PersistentFlags().StringVar(&SetNetDefault, "default", "", "Enable/disable device as default (yes/no)")
baseCmd.PersistentFlags().BoolVar(&SetNetDevDel, "netdel", false, "Delete the node's network device")

View File

@@ -87,7 +87,6 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
n.NetDevs[devname] = &netdev
}
n.NetDevs[devname].Name.Set(devname)
n.NetDevs[devname].Device.Set(netdev.Device)
n.NetDevs[devname].Ipaddr.Set(netdev.Ipaddr)
n.NetDevs[devname].Netmask.Set(netdev.Netmask)
@@ -95,6 +94,7 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
n.NetDevs[devname].Gateway.Set(netdev.Gateway)
n.NetDevs[devname].Type.Set(netdev.Type)
n.NetDevs[devname].OnBoot.SetB(netdev.OnBoot)
n.NetDevs[devname].Default.SetB(netdev.Default)
}
for keyname, key := range node.Keys {
@@ -148,6 +148,7 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) {
n.NetDevs[devname].Gateway.SetAlt(netdev.Gateway, p)
n.NetDevs[devname].Type.SetAlt(netdev.Type, p)
n.NetDevs[devname].OnBoot.SetAltB(netdev.OnBoot, p)
n.NetDevs[devname].Default.SetAltB(netdev.Default, p)
}
for keyname, key := range config.NodeProfiles[p].Keys {
@@ -213,7 +214,6 @@ func (config *nodeYaml) FindAllProfiles() ([]NodeInfo, error) {
wwlog.Printf(wwlog.DEBUG, "Updating profile netdev: %s\n", devname)
p.NetDevs[devname].Name.Set(devname)
p.NetDevs[devname].Device.Set(netdev.Device)
p.NetDevs[devname].Ipaddr.Set(netdev.Ipaddr)
p.NetDevs[devname].Netmask.Set(netdev.Netmask)
@@ -221,6 +221,7 @@ func (config *nodeYaml) FindAllProfiles() ([]NodeInfo, error) {
p.NetDevs[devname].Gateway.Set(netdev.Gateway)
p.NetDevs[devname].Type.Set(netdev.Type)
p.NetDevs[devname].OnBoot.SetB(netdev.OnBoot)
p.NetDevs[devname].Default.SetB(netdev.Default)
}
for keyname, key := range profile.Keys {

View File

@@ -39,16 +39,16 @@ type NodeConf struct {
}
type NetDevs struct {
Name string
Type string `yaml:"type,omitempty"`
OnBoot bool `yaml:"onboot"`
Device string `yaml:"device"`
Type string
OnBoot bool
Device string
Hwaddr string
Ipaddr string
IpCIDR string
Prefix string
IpCIDR string `yaml:"ipcidr,omitempty"`
Prefix string `yaml:"prefix,omitempty"`
Netmask string
Gateway string `yaml:"gateway,omitempty"`
Gateway string `yaml:"gateway"`
Default bool
}
/******
@@ -92,16 +92,16 @@ type NodeInfo struct {
}
type NetDevEntry struct {
Name Entry
Type Entry `yaml:"type,omitempty"`
OnBoot Entry `yaml:"onboot"`
Device Entry `yaml:"device"`
Type Entry
OnBoot Entry
Device Entry
Hwaddr Entry
Ipaddr Entry
IpCIDR Entry
Prefix Entry
Netmask Entry
Gateway Entry `yaml:"gateway,omitempty"`
Gateway Entry
Default Entry
}
func init() {

View File

@@ -91,6 +91,7 @@ func (config *nodeYaml) NodeUpdate(node NodeInfo) error {
config.Nodes[nodeID].NetDevs[devname].Gateway = netdev.Gateway.GetReal()
config.Nodes[nodeID].NetDevs[devname].Type = netdev.Type.GetReal()
config.Nodes[nodeID].NetDevs[devname].OnBoot = netdev.OnBoot.GetRealB()
config.Nodes[nodeID].NetDevs[devname].Default = netdev.Default.GetRealB()
}
for keyname, key := range node.Keys {
@@ -177,6 +178,7 @@ func (config *nodeYaml) ProfileUpdate(profile NodeInfo) error {
config.NodeProfiles[profileID].NetDevs[devname].Gateway = netdev.Gateway.GetReal()
config.NodeProfiles[profileID].NetDevs[devname].Type = netdev.Type.GetReal()
config.NodeProfiles[profileID].NetDevs[devname].OnBoot = netdev.OnBoot.GetRealB()
config.NodeProfiles[profileID].NetDevs[devname].Default = netdev.Default.GetRealB()
}
for keyname, key := range profile.Keys {

View File

@@ -187,7 +187,6 @@ func BuildOverlay(nodeInfo node.NodeInfo, overlayName string) error {
for devname, netdev := range nodeInfo.NetDevs {
var nd node.NetDevs
tstruct.NetDevs[devname] = &nd
tstruct.NetDevs[devname].Name = devname
tstruct.NetDevs[devname].Device = netdev.Device.Get()
tstruct.NetDevs[devname].Hwaddr = netdev.Hwaddr.Get()
tstruct.NetDevs[devname].Ipaddr = netdev.Ipaddr.Get()