Skip to content

Commit ff15ea9

Browse files
committed
enables storage policy in failure domain
1 parent a2bac7b commit ff15ea9

File tree

7 files changed

+79
-24
lines changed

7 files changed

+79
-24
lines changed

apis/v1alpha3/conversion.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,8 @@ func Convert_v1beta1_VSphereMachineSpec_To_v1alpha3_VSphereMachineSpec(in *infra
4747
func Convert_v1beta1_VSphereVMSpec_To_v1alpha3_VSphereVMSpec(in *infrav1.VSphereVMSpec, out *VSphereVMSpec, s conversion.Scope) error {
4848
return autoConvert_v1beta1_VSphereVMSpec_To_v1alpha3_VSphereVMSpec(in, out, s)
4949
}
50+
51+
// This is required as the v1beta1 topology has an additional `storagePolicy` field.
52+
func Convert_v1beta1_Topology_To_v1alpha3_Topology(in *infrav1.Topology, out *Topology, s conversion.Scope) error {
53+
return autoConvert_v1beta1_Topology_To_v1alpha3_Topology(in, out, s)
54+
}

apis/v1alpha3/zz_generated.conversion.go

Lines changed: 28 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha4/conversion.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,8 @@ func Convert_v1beta1_VSphereMachineSpec_To_v1alpha4_VSphereMachineSpec(in *infra
4646
func Convert_v1beta1_VSphereVMSpec_To_v1alpha4_VSphereVMSpec(in *infrav1.VSphereVMSpec, out *VSphereVMSpec, s conversion.Scope) error {
4747
return autoConvert_v1beta1_VSphereVMSpec_To_v1alpha4_VSphereVMSpec(in, out, s)
4848
}
49+
50+
// This is required as the v1beta1 topology has an additional `storagePolicy` field.
51+
func Convert_v1beta1_Topology_To_v1alpha4_Topology(in *infrav1.Topology, out *Topology, s conversion.Scope) error {
52+
return autoConvert_v1beta1_Topology_To_v1alpha4_Topology(in, out, s)
53+
}

apis/v1alpha4/zz_generated.conversion.go

Lines changed: 28 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1beta1/vspherefailuredomain_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ type Topology struct {
8585
// virtual machine is created/located.
8686
// +optional
8787
Datastore string `json:"datastore,omitempty"`
88+
89+
// StoragePolicy is the name of the policy that is used to target a datastore
90+
// in which the virtual machine is created/located.
91+
// +optional
92+
StoragePolicy string `json:"storagePolicy,omitempty"`
8893
}
8994

9095
// FailureDomainHosts has information required for placement of machines on VSphere hosts.

config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspherefailuredomains.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ spec:
368368
items:
369369
type: string
370370
type: array
371+
storagePolicy:
372+
description: |-
373+
StoragePolicy is the name of the policy that is used to target a datastore
374+
in which the virtual machine is created/located.
375+
type: string
371376
required:
372377
- datacenter
373378
type: object

pkg/services/vimmachine.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ func (v *VimMachineService) generateOverrideFunc(ctx context.Context, vimMachine
432432
if vsphereDeploymentZone.Spec.PlacementConstraint.ResourcePool != "" {
433433
vm.Spec.ResourcePool = vsphereDeploymentZone.Spec.PlacementConstraint.ResourcePool
434434
}
435+
if vsphereFailureDomain.Spec.Topology.StoragePolicy != "" {
436+
vm.Spec.StoragePolicyName = vsphereFailureDomain.Spec.Topology.StoragePolicy
437+
}
435438
if vsphereFailureDomain.Spec.Topology.Datastore != "" {
436439
vm.Spec.Datastore = vsphereFailureDomain.Spec.Topology.Datastore
437440
}

0 commit comments

Comments
 (0)