Skip to content

Commit

Permalink
Merge pull request #252 from rabi/api_refactor
Browse files Browse the repository at this point in the history
Add OpenStackBaremetalSetTemplateSpec
  • Loading branch information
openshift-merge-bot[bot] authored Jan 6, 2025
2 parents 34b0d04 + b07f6e3 commit 927fdf8
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 44 deletions.
22 changes: 13 additions & 9 deletions api/v1beta1/openstackbaremetalset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ const (
CleaningModeMetadata AutomatedCleaningMode = "metadata"
)

// OpenStackBaremetalSetSpec defines the desired state of OpenStackBaremetalSet
type OpenStackBaremetalSetSpec struct {
// +kubebuilder:validation:Optional
// BaremetalHosts - Map of hostname to Instance Spec for all nodes to provision
BaremetalHosts map[string]InstanceSpec `json:"baremetalHosts,omitempty"`
type OpenStackBaremetalSetTemplateSpec struct {
// +kubebuilder:validation:Optional
// OSImage - OS qcow2 image Name
OSImage string `json:"osImage,omitempty"`
Expand Down Expand Up @@ -84,9 +80,6 @@ type OpenStackBaremetalSetSpec struct {
DeploymentSSHSecret string `json:"deploymentSSHSecret"`
// CtlplaneInterface - Interface on the provisioned nodes to use for ctlplane network
CtlplaneInterface string `json:"ctlplaneInterface"`
// CtlplaneGateway - IP of gateway for ctrlplane network (TODO: acquire this is another manner?)
// +kubebuilder:validation:Optional
CtlplaneGateway string `json:"ctlplaneGateway,omitempty"`
// +kubebuilder:validation:Optional
// CtlplaneNetmask - Netmask to use for ctlplane network (TODO: acquire this is another manner?)
CtlplaneNetmask string `json:"ctlplaneNetmask,omitempty"`
Expand All @@ -108,6 +101,16 @@ type OpenStackBaremetalSetSpec struct {
// +kubebuilder:default=cloud-admin
// CloudUser to be configured for remote access
CloudUserName string `json:"cloudUserName"`
}

// OpenStackBaremetalSetSpec defines the desired state of OpenStackBaremetalSet
type OpenStackBaremetalSetSpec struct {
// +kubebuilder:validation:Optional
// BaremetalHosts - Map of hostname to Instance Spec for all nodes to provision
BaremetalHosts map[string]InstanceSpec `json:"baremetalHosts,omitempty"`
// CtlplaneGateway - IP of gateway for ctrlplane network (TODO: acquire this is another manner?)
// +kubebuilder:validation:Optional
CtlplaneGateway string `json:"ctlplaneGateway,omitempty"`
// DomainName is the domain name that will be set on the underlying Metal3 BaremetalHosts (TODO: acquire this is another manner?)
// +kubebuilder:validation:Optional
DomainName string `json:"domainName,omitempty"`
Expand All @@ -118,7 +121,8 @@ type OpenStackBaremetalSetSpec struct {
// +kubebuilder:validation:Optional
// DNSSearchDomains - initial DNS nameserver values to set on the BaremetalHosts when they are provisioned.
// Note that subsequent deployment will overwrite these values
DNSSearchDomains []string `json:"dnsSearchDomains,omitempty"`
DNSSearchDomains []string `json:"dnsSearchDomains,omitempty"`
OpenStackBaremetalSetTemplateSpec `json:",inline"`
}

// OpenStackBaremetalSetStatus defines the observed state of OpenStackBaremetalSet
Expand Down
56 changes: 36 additions & 20 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 18 additions & 15 deletions tests/functional/openstackbaremetalset_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,7 @@ var _ = Describe("BaremetalSet Test", func() {
})
It("should have the Spec fields initialized", func() {
baremetalSetInstance := GetBaremetalSet(baremetalSetName)
spec := baremetalv1.OpenStackBaremetalSetSpec{
BaremetalHosts: map[string]baremetalv1.InstanceSpec{
"compute-0": {
CtlPlaneIP: "10.0.0.1",
UserData: nil,
NetworkData: nil,
BmhLabelSelector: nil,
},
},
coreSpec := baremetalv1.OpenStackBaremetalSetTemplateSpec{
OSImage: "",
OSContainerImageURL: "",
ApacheImageURL: "",
Expand All @@ -83,7 +75,6 @@ var _ = Describe("BaremetalSet Test", func() {
ProvisioningInterface: "",
DeploymentSSHSecret: "mysecret",
CtlplaneInterface: "eth0",
CtlplaneGateway: "",
BmhNamespace: baremetalSetName.Namespace,
BmhLabelSelector: map[string]string{"app": "openstack"},
HardwareReqs: baremetalv1.HardwareReqs{
Expand All @@ -100,11 +91,23 @@ var _ = Describe("BaremetalSet Test", func() {
SSDReq: baremetalv1.DiskSSDReq{SSD: false, ExactMatch: false},
},
},
PasswordSecret: nil,
CloudUserName: "cloud-admin",
DomainName: "",
BootstrapDNS: nil,
DNSSearchDomains: nil,
PasswordSecret: nil,
CloudUserName: "cloud-admin",
}
spec := baremetalv1.OpenStackBaremetalSetSpec{
BaremetalHosts: map[string]baremetalv1.InstanceSpec{
"compute-0": {
CtlPlaneIP: "10.0.0.1",
UserData: nil,
NetworkData: nil,
BmhLabelSelector: nil,
},
},
CtlplaneGateway: "",
DomainName: "",
BootstrapDNS: nil,
DNSSearchDomains: nil,
OpenStackBaremetalSetTemplateSpec: coreSpec,
}
Expect(baremetalSetInstance.Spec).Should(Equal(spec))
})
Expand Down

0 comments on commit 927fdf8

Please sign in to comment.