From c8617266abee4208638cf50ddedf5d8c01b849e2 Mon Sep 17 00:00:00 2001 From: rabi Date: Mon, 18 Mar 2024 08:10:07 +0530 Subject: [PATCH] Add PreprovisioningNetworkDataName to baremetalset spec This is the name of the Secret in the local namespace containing network configuration (e.g content of network_data.json) which is passed to the preprovisioning image. It is also passed to the Config Drive if not overridden by specifying NetworkData. Signed-off-by: rabi --- api/bases/baremetal.openstack.org_openstackbaremetalsets.yaml | 4 ++++ api/v1beta1/openstackbaremetalset_types.go | 3 +++ .../bases/baremetal.openstack.org_openstackbaremetalsets.yaml | 4 ++++ pkg/openstackbaremetalset/baremetalhost.go | 3 +++ 4 files changed, 14 insertions(+) diff --git a/api/bases/baremetal.openstack.org_openstackbaremetalsets.yaml b/api/bases/baremetal.openstack.org_openstackbaremetalsets.yaml index 1a620f3..caedfcd 100644 --- a/api/bases/baremetal.openstack.org_openstackbaremetalsets.yaml +++ b/api/bases/baremetal.openstack.org_openstackbaremetalsets.yaml @@ -85,6 +85,10 @@ spec: type: string type: object x-kubernetes-map-type: atomic + preprovisioningNetworkDataName: + description: PreprovisioningNetworkDataName - NetwoData Secret + name for Preprovisining in the local namespace + type: string userData: description: UserData - Host User Data properties: diff --git a/api/v1beta1/openstackbaremetalset_types.go b/api/v1beta1/openstackbaremetalset_types.go index 7e81d31..56e8df5 100644 --- a/api/v1beta1/openstackbaremetalset_types.go +++ b/api/v1beta1/openstackbaremetalset_types.go @@ -37,6 +37,9 @@ type InstanceSpec struct { // +kubebuilder:validation:Optional // NetworkData - Host Network Data NetworkData *corev1.SecretReference `json:"networkData,omitempty"` + // +kubebuilder:validation:Optional + // PreprovisioningNetworkDataName - NetwoData Secret name for Preprovisining in the local namespace + PreprovisioningNetworkDataName string `json:"preprovisioningNetworkDataName,omitempty"` } // Allowed automated cleaning modes diff --git a/config/crd/bases/baremetal.openstack.org_openstackbaremetalsets.yaml b/config/crd/bases/baremetal.openstack.org_openstackbaremetalsets.yaml index 1a620f3..caedfcd 100644 --- a/config/crd/bases/baremetal.openstack.org_openstackbaremetalsets.yaml +++ b/config/crd/bases/baremetal.openstack.org_openstackbaremetalsets.yaml @@ -85,6 +85,10 @@ spec: type: string type: object x-kubernetes-map-type: atomic + preprovisioningNetworkDataName: + description: PreprovisioningNetworkDataName - NetwoData Secret + name for Preprovisining in the local namespace + type: string userData: description: UserData - Host User Data properties: diff --git a/pkg/openstackbaremetalset/baremetalhost.go b/pkg/openstackbaremetalset/baremetalhost.go index d452df0..14bec92 100644 --- a/pkg/openstackbaremetalset/baremetalhost.go +++ b/pkg/openstackbaremetalset/baremetalhost.go @@ -205,6 +205,9 @@ func BaremetalHostProvision( // Ensure AutomatedCleaningMode is set as per spec foundBaremetalHost.Spec.AutomatedCleaningMode = metal3v1.AutomatedCleaningMode(instance.Spec.AutomatedCleaningMode) + // Ensure PreprovisioningNetworkDataName is set as per spec + foundBaremetalHost.Spec.PreprovisioningNetworkDataName = instance.Spec.BaremetalHosts[hostName].PreprovisioningNetworkDataName + // // Ensure the image url is up to date unless already provisioned //