Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #676 from hjensas/ipv6-network-data-template
Browse files Browse the repository at this point in the history
Pass instanceSpec.CtlPlaneIP in CIDR notation
  • Loading branch information
openshift-merge-bot[bot] authored Feb 17, 2024
2 parents 5fbae4f + 3df0f94 commit 8e422b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions pkg/deployment/baremetal.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,23 @@ func DeployBaremetalSet(
ipSet, ok := ipSets[hostName]
instanceSpec := baremetalSet.Spec.BaremetalHosts[hostName]
if !ok {
// TODO: Change this to raise an error instead.
// NOTE(hjensas): Hardcode /24 here, this used to rely on
// baremetalSet.Spec.CtlplaneNetmask's default value ("255.255.255.0").
utils.LogForObject(helper, "IPAM Not configured for use, skipping", instance)
instanceSpec.CtlPlaneIP = node.Ansible.AnsibleHost
instanceSpec.CtlPlaneIP = fmt.Sprintf("%s/24", node.Ansible.AnsibleHost)
} else {
for _, res := range ipSet.Status.Reservation {
if strings.ToLower(string(res.Network)) == CtlPlaneNetwork {
instanceSpec.CtlPlaneIP = res.Address
_, ipNet, err := net.ParseCIDR(res.Cidr)
if err != nil {
return err
}
ipPrefix, _ := ipNet.Mask.Size()
instanceSpec.CtlPlaneIP = fmt.Sprintf("%s/%d", res.Address, ipPrefix)
baremetalSet.Spec.CtlplaneGateway = *res.Gateway
baremetalSet.Spec.BootstrapDNS = dnsAddresses
baremetalSet.Spec.DNSSearchDomains = []string{res.DNSDomain}
_, ipNet, err := net.ParseCIDR(res.Cidr)
if err == nil {
baremetalSet.Spec.CtlplaneNetmask = net.IP(ipNet.Mask).String()
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/openstackdataplanenodeset_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ var _ = Describe("DataplaneNodeSet Webhook", func() {
},
BaremetalHosts: map[string]baremetalv1.InstanceSpec{
"compute-0": {
CtlPlaneIP: "192.168.1.12",
CtlPlaneIP: "192.168.1.12/24",
},
},
}
Expand All @@ -87,7 +87,7 @@ var _ = Describe("DataplaneNodeSet Webhook", func() {
},
BaremetalHosts: map[string]baremetalv1.InstanceSpec{
"compute-0": {
CtlPlaneIP: "192.168.1.12",
CtlPlaneIP: "192.168.1.12/24",
},
},
}
Expand Down

0 comments on commit 8e422b3

Please sign in to comment.