Skip to content

Commit

Permalink
Don't set default for optional CtlplaneNetmask
Browse files Browse the repository at this point in the history
Signed-off-by: Brendan Shephard <[email protected]>
  • Loading branch information
bshephar committed Dec 18, 2024
1 parent f3ff42b commit 0e8304a
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 27 deletions.
4 changes: 0 additions & 4 deletions api/bases/baremetal.openstack.org_openstackbaremetalsets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,6 @@ spec:
description: CtlplaneInterface - Interface on the provisioned nodes
to use for ctlplane network
type: string
ctlplaneNetmask:
description: 'CtlplaneNetmask - Netmask to use for ctlplane network
(TODO: acquire this is another manner?)'
type: string
deploymentSSHSecret:
description: DeploymentSSHSecret - Name of secret holding the cloud-admin
ssh keys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,6 @@ spec:
description: CtlplaneInterface - Interface on the provisioned nodes
to use for ctlplane network
type: string
ctlplaneNetmask:
description: 'CtlplaneNetmask - Netmask to use for ctlplane network
(TODO: acquire this is another manner?)'
type: string
deploymentSSHSecret:
description: DeploymentSSHSecret - Name of secret holding the cloud-admin
ssh keys
Expand Down
20 changes: 2 additions & 18 deletions pkg/openstackbaremetalset/baremetalhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,9 @@ func BaremetalHostProvision(
if networkDataSecret == nil {

// Check IP version and set template variables accordingly
ipAddr, ipNet, err := net.ParseCIDR(ctlPlaneIP)
ipAddr, _, err := net.ParseCIDR(ctlPlaneIP)
if err != nil {
// TODO: Remove this conversion once all usage sets ctlPlaneIP in CIDR format.
ipAddr = net.ParseIP(ctlPlaneIP)
if ipAddr == nil {
return err
}

var ipPrefix int
if ipAddr.To4() != nil {
ipPrefix, _ = net.IPMask(net.ParseIP(instance.Spec.CtlplaneNetmask).To4()).Size()
} else {
ipPrefix, _ = net.IPMask(net.ParseIP(instance.Spec.CtlplaneNetmask).To16()).Size()
}
_, ipNet, err = net.ParseCIDR(fmt.Sprintf("%s/%d", ipAddr, ipPrefix))
if err != nil {
return err
}
return err
}

CtlplaneIPVersion := "ipv6"
Expand All @@ -127,7 +112,6 @@ func BaremetalHostProvision(
templateParameters["CtlplaneIp"] = ipAddr
templateParameters["CtlplaneInterface"] = instance.Spec.CtlplaneInterface
templateParameters["CtlplaneGateway"] = instance.Spec.CtlplaneGateway
templateParameters["CtlplaneNetmask"] = net.IP(ipNet.Mask)
if len(instance.Spec.BootstrapDNS) > 0 {
templateParameters["CtlplaneDns"] = instance.Spec.BootstrapDNS
} else {
Expand Down
1 change: 0 additions & 1 deletion templates/openstackbaremetalset/cloudinit/networkdata
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ networks:
id: {{ .CtlplaneInterface }}
type: {{ .CtlplaneIpVersion }}
ip_address: {{ .CtlplaneIp }}
netmask: "{{ .CtlplaneNetmask }}"
{{- if (index . "CtlplaneGateway") }}
routes:
- network: {{ if eq .CtlplaneIpVersion "ipv6" }}"::"{{ else }}0.0.0.0{{ end }}
Expand Down

0 comments on commit 0e8304a

Please sign in to comment.