Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give preference to PreprovisioningNetworkDataName #202

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions pkg/openstackbaremetalset/baremetalhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,21 @@ func BaremetalHostProvision(

}

if networkDataSecret == nil {
//
// Provision the BaremetalHost
//
foundBaremetalHost := &metal3v1.BareMetalHost{}
err := helper.GetClient().Get(ctx, types.NamespacedName{Name: bmh, Namespace: instance.Spec.BmhNamespace}, foundBaremetalHost)
if err != nil {
return err
}

preProvNetworkData := foundBaremetalHost.Spec.PreprovisioningNetworkDataName
if preProvNetworkData == "" {
preProvNetworkData = instance.Spec.BaremetalHosts[hostName].PreprovisioningNetworkDataName
}

if networkDataSecret == nil && preProvNetworkData == "" {

// Check IP version and set template variables accordingly
ipAddr, ipNet, err := net.ParseCIDR(ctlPlaneIP)
Expand Down Expand Up @@ -181,15 +195,6 @@ func BaremetalHostProvision(
}
}

//
// Provision the BaremetalHost
//
foundBaremetalHost := &metal3v1.BareMetalHost{}
err := helper.GetClient().Get(ctx, types.NamespacedName{Name: bmh, Namespace: instance.Spec.BmhNamespace}, foundBaremetalHost)
if err != nil {
return err
}

op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), foundBaremetalHost, func() error {
// Set our ownership labels so we can watch this resource and also indicate that this BMH
// belongs to the particular OSBMS.Spec.BaremetalHosts entry we have passed to this function.
Expand All @@ -205,11 +210,7 @@ func BaremetalHostProvision(
// Ensure AutomatedCleaningMode is set as per spec
foundBaremetalHost.Spec.AutomatedCleaningMode = metal3v1.AutomatedCleaningMode(instance.Spec.AutomatedCleaningMode)

// Ensure PreprovisioningNetworkDataName is set as per spec
preprovNetworkData := instance.Spec.BaremetalHosts[hostName].PreprovisioningNetworkDataName
if preprovNetworkData != "" {
foundBaremetalHost.Spec.PreprovisioningNetworkDataName = preprovNetworkData
}
foundBaremetalHost.Spec.PreprovisioningNetworkDataName = preProvNetworkData

//
// Ensure the image url is up to date unless already provisioned
Expand Down