Skip to content

Commit

Permalink
Set osctlplane defaults for PhysNet and OpenStackRelease
Browse files Browse the repository at this point in the history
Set defaults via the new way for PhysNet and OpenStackRelease
via the webhook.Defaulter.
  • Loading branch information
stuggi committed Nov 22, 2021
1 parent 1ecf8fc commit cddc84b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
22 changes: 22 additions & 0 deletions api/v1beta1/openstackcontrolplane_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"

controlplane "github.com/openstack-k8s-operators/osp-director-operator/pkg/controlplane"
)

// OpenStackControlPlaneDefaults -
type OpenStackControlPlaneDefaults struct {
OpenStackClientImageURL string
OpenStackRelease string
}

var openstackControlPlaneDefaults OpenStackControlPlaneDefaults
Expand Down Expand Up @@ -117,4 +120,23 @@ func (r *OpenStackControlPlane) Default() {
r.Spec.OpenStackClientImageURL = openstackControlPlaneDefaults.OpenStackClientImageURL
}

//
// set default PhysNetworks name/prefix if non speficied
//
if len(r.Spec.PhysNetworks) == 0 {
r.Spec.PhysNetworks = []Physnet{
{
Name: controlplane.DefaultOVNChassisPhysNetName,
MACPrefix: controlplane.DefaultOVNChassisPhysNetMACPrefix,
},
}
}

//
// set default OpenStackRelease
//
if r.Spec.OpenStackRelease == "" {
r.Spec.OpenStackRelease = openstackControlPlaneDefaults.OpenStackRelease
}

}
2 changes: 2 additions & 0 deletions config/default/manager_default_images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ spec:
value: quay.io/openstack-k8s-operators/provision-ip-discovery-agent:0.0.1
- name: APACHE_IMAGE_URL_DEFAULT
value: registry.redhat.io/rhel8/httpd-24:latest
- name: OPENSTACK_RELEASE_DEFAULT
value: 16.2
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
- name: datacentre2
macPrefix: fa:16:3b
virtualMachineRoles:
Controller:
controller:
baseImageVolumeName: controller-base-img
cores: 6
ctlplaneInterface: enp2s0
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ func main() {

openstackControlPlaneDefaults := ospdirectorv1beta1.OpenStackControlPlaneDefaults{
OpenStackClientImageURL: os.Getenv("OPENSTACKCLIENT_IMAGE_URL_DEFAULT"),
OpenStackRelease: os.Getenv("OPENSTACK_RELEASE_DEFAULT"),
}

if err = (&ospdirectorv1beta1.OpenStackControlPlane{}).SetupWebhookWithManager(mgr, openstackControlPlaneDefaults); err != nil {
Expand Down

0 comments on commit cddc84b

Please sign in to comment.