Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions api/govmomi/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ const (
)

// VirtualMachineCloneSpec is information used to clone a virtual machine.
// +kubebuilder:validation:XValidation:rule="!(has(self.datastore) && has(self.datastoreCluster))",message="datastore and datastoreCluster cannot both be set"
type VirtualMachineCloneSpec struct {
// Template is the name, inventory path, managed object reference or the managed
// object ID of the template used to clone the virtual machine.
Expand Down Expand Up @@ -181,6 +182,12 @@ type VirtualMachineCloneSpec struct {
// +optional
Datastore string `json:"datastore,omitempty"`

// DatastoreCluster is the name, inventory path, managed object reference or the managed
// object ID of the datastore cluster (StoragePod) in which the virtual machine is created/located
// using Storage DRS.
// +optional
DatastoreCluster string `json:"datastoreCluster,omitempty"`

// StoragePolicyName of the storage policy to use with this
// Virtual Machine
// +optional
Expand Down
6 changes: 6 additions & 0 deletions api/govmomi/v1beta1/vspherefailuredomain_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type FailureDomain struct {
}

// Topology describes a given failure domain using vSphere constructs.
// +kubebuilder:validation:XValidation:rule="!(has(self.datastore) && has(self.datastoreCluster))",message="datastore and datastoreCluster cannot both be set"
type Topology struct {
// Datacenter as the failure domain.
// +kubebuilder:validation:Required
Expand Down Expand Up @@ -92,6 +93,11 @@ type Topology struct {
// virtual machine is created/located.
// +optional
Datastore string `json:"datastore,omitempty"`

// DatastoreCluster is the name or inventory path of the datastore cluster (StoragePod)
// in which the virtual machine is created/located using Storage DRS.
// +optional
DatastoreCluster string `json:"datastoreCluster,omitempty"`
}

// NetworkConfiguration defines a network configuration that should be used when consuming
Expand Down
4 changes: 4 additions & 0 deletions api/govmomi/v1beta1/zz_generated.conversion.go

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

4 changes: 4 additions & 0 deletions api/govmomi/v1beta2/condition_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ const (
// DatastoreNotFoundV1Beta1Reason (Severity=Error) documents that the datastore in the topology for the Failure Domain
// associated to the VSphereDeploymentZone is misconfigured.
DatastoreNotFoundV1Beta1Reason = "DatastoreNotFound"

// DatastoreClusterNotFoundV1Beta1Reason (Severity=Error) documents that the datastore cluster in the topology for the Failure Domain
// associated to the VSphereDeploymentZone is misconfigured.
DatastoreClusterNotFoundV1Beta1Reason = "DatastoreClusterNotFound"
)

const (
Expand Down
9 changes: 9 additions & 0 deletions api/govmomi/v1beta2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ const (
)

// VirtualMachineCloneSpec is information used to clone a virtual machine.
// +kubebuilder:validation:XValidation:rule="!(has(self.datastore) && has(self.datastoreCluster))",message="datastore and datastoreCluster cannot both be set"
type VirtualMachineCloneSpec struct {
// template is the name, inventory path, managed object reference or the managed
// object ID of the template used to clone the virtual machine.
Expand Down Expand Up @@ -195,6 +196,14 @@ type VirtualMachineCloneSpec struct {
// +kubebuilder:validation:MaxLength=2048
Datastore string `json:"datastore,omitempty"`

// datastoreCluster is the name, inventory path, managed object reference or the managed
// object ID of the datastore cluster (StoragePod) in which the virtual machine is created/located
// using Storage DRS.
// +optional
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=2048
DatastoreCluster string `json:"datastoreCluster,omitempty"`

// storagePolicyName of the storage policy to use with this
// Virtual Machine
// +optional
Expand Down
3 changes: 3 additions & 0 deletions api/govmomi/v1beta2/vspheredeploymentzone_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ const (
// VSphereDeploymentZoneFailureDomainDatastoreNotFoundReason surfaces when the failure domain's datastore for a VSphereDeploymentZone is not found.
VSphereDeploymentZoneFailureDomainDatastoreNotFoundReason = "DatastoreNotFound"

// VSphereDeploymentZoneFailureDomainDatastoreClusterNotFoundReason surfaces when the failure domain's datastore cluster for a VSphereDeploymentZone is not found.
VSphereDeploymentZoneFailureDomainDatastoreClusterNotFoundReason = "DatastoreClusterNotFound"

// VSphereDeploymentZoneFailureDomainNetworkNotFoundReason surfaces when the failure domain's network for a VSphereDeploymentZone is not found.
VSphereDeploymentZoneFailureDomainNetworkNotFoundReason = "NetworkNotFound"

Expand Down
8 changes: 8 additions & 0 deletions api/govmomi/v1beta2/vspherefailuredomain_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type FailureDomain struct {
}

// Topology describes a given failure domain using vSphere constructs.
// +kubebuilder:validation:XValidation:rule="!(has(self.datastore) && has(self.datastoreCluster))",message="datastore and datastoreCluster cannot both be set"
type Topology struct {
// datacenter as the failure domain.
// +required
Expand Down Expand Up @@ -106,6 +107,13 @@ type Topology struct {
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=2048
Datastore string `json:"datastore,omitempty"`

// datastoreCluster is the name or inventory path of the datastore cluster (StoragePod)
// in which the virtual machine is created/located using Storage DRS.
// +optional
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=2048
DatastoreCluster string `json:"datastoreCluster,omitempty"`
}

// NetworkConfiguration defines a network configuration that should be used when consuming
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ spec:
Datastore is the name or inventory path of the datastore in which the
virtual machine is created/located.
type: string
datastoreCluster:
description: |-
DatastoreCluster is the name or inventory path of the datastore cluster (StoragePod)
in which the virtual machine is created/located using Storage DRS.
type: string
hosts:
description: Hosts has information required for placement of machines
on VSphere hosts.
Expand Down Expand Up @@ -292,6 +297,9 @@ spec:
required:
- datacenter
type: object
x-kubernetes-validations:
- message: datastore and datastoreCluster cannot both be set
rule: '!(has(self.datastore) && has(self.datastoreCluster))'
zone:
description: Zone defines the name and type of a zone
properties:
Expand Down Expand Up @@ -403,6 +411,13 @@ spec:
maxLength: 2048
minLength: 1
type: string
datastoreCluster:
description: |-
datastoreCluster is the name or inventory path of the datastore cluster (StoragePod)
in which the virtual machine is created/located using Storage DRS.
maxLength: 2048
minLength: 1
type: string
hosts:
description: hosts has information required for placement of machines
on VSphere hosts.
Expand Down Expand Up @@ -651,6 +666,9 @@ spec:
required:
- datacenter
type: object
x-kubernetes-validations:
- message: datastore and datastoreCluster cannot both be set
rule: '!(has(self.datastore) && has(self.datastoreCluster))'
zone:
description: zone defines the name and type of a zone
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ spec:
Datastore is the name, inventory path, managed object reference or the managed
object ID of the datastore in which the virtual machine is created/located.
type: string
datastoreCluster:
description: |-
DatastoreCluster is the name, inventory path, managed object reference or the managed
object ID of the datastore cluster (StoragePod) in which the virtual machine is created/located
using Storage DRS.
type: string
diskGiB:
description: |-
DiskGiB is the size of a virtual machine's disk, in GiB.
Expand Down Expand Up @@ -726,6 +732,9 @@ spec:
- network
- template
type: object
x-kubernetes-validations:
- message: datastore and datastoreCluster cannot both be set
rule: '!(has(self.datastore) && has(self.datastoreCluster))'
status:
description: VSphereMachineStatus defines the observed state of VSphereMachine.
properties:
Expand Down Expand Up @@ -1102,6 +1111,14 @@ spec:
maxLength: 2048
minLength: 1
type: string
datastoreCluster:
description: |-
datastoreCluster is the name, inventory path, managed object reference or the managed
object ID of the datastore cluster (StoragePod) in which the virtual machine is created/located
using Storage DRS.
maxLength: 2048
minLength: 1
type: string
diskGiB:
description: |-
diskGiB is the size of a virtual machine's disk, in GiB.
Expand Down Expand Up @@ -1770,6 +1787,9 @@ spec:
- network
- template
type: object
x-kubernetes-validations:
- message: datastore and datastoreCluster cannot both be set
rule: '!(has(self.datastore) && has(self.datastoreCluster))'
status:
description: status is the observed state of VSphereMachine.
minProperties: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ spec:
Datastore is the name, inventory path, managed object reference or the managed
object ID of the datastore in which the virtual machine is created/located.
type: string
datastoreCluster:
description: |-
DatastoreCluster is the name, inventory path, managed object reference or the managed
object ID of the datastore cluster (StoragePod) in which the virtual machine is created/located
using Storage DRS.
type: string
diskGiB:
description: |-
DiskGiB is the size of a virtual machine's disk, in GiB.
Expand Down Expand Up @@ -743,6 +749,9 @@ spec:
- network
- template
type: object
x-kubernetes-validations:
- message: datastore and datastoreCluster cannot both be set
rule: '!(has(self.datastore) && has(self.datastoreCluster))'
required:
- spec
type: object
Expand Down Expand Up @@ -920,6 +929,14 @@ spec:
maxLength: 2048
minLength: 1
type: string
datastoreCluster:
description: |-
datastoreCluster is the name, inventory path, managed object reference or the managed
object ID of the datastore cluster (StoragePod) in which the virtual machine is created/located
using Storage DRS.
maxLength: 2048
minLength: 1
type: string
diskGiB:
description: |-
diskGiB is the size of a virtual machine's disk, in GiB.
Expand Down Expand Up @@ -1593,6 +1610,9 @@ spec:
- network
- template
type: object
x-kubernetes-validations:
- message: datastore and datastoreCluster cannot both be set
rule: '!(has(self.datastore) && has(self.datastoreCluster))'
type: object
required:
- template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ spec:
Datastore is the name, inventory path, managed object reference or the managed
object ID of the datastore in which the virtual machine is created/located.
type: string
datastoreCluster:
description: |-
DatastoreCluster is the name, inventory path, managed object reference or the managed
object ID of the datastore cluster (StoragePod) in which the virtual machine is created/located
using Storage DRS.
type: string
diskGiB:
description: |-
DiskGiB is the size of a virtual machine's disk, in GiB.
Expand Down Expand Up @@ -726,6 +732,9 @@ spec:
- network
- template
type: object
x-kubernetes-validations:
- message: datastore and datastoreCluster cannot both be set
rule: '!(has(self.datastore) && has(self.datastoreCluster))'
status:
description: VSphereVMStatus defines the observed state of VSphereVM.
properties:
Expand Down Expand Up @@ -1115,6 +1124,14 @@ spec:
maxLength: 2048
minLength: 1
type: string
datastoreCluster:
description: |-
datastoreCluster is the name, inventory path, managed object reference or the managed
object ID of the datastore cluster (StoragePod) in which the virtual machine is created/located
using Storage DRS.
maxLength: 2048
minLength: 1
type: string
diskGiB:
description: |-
diskGiB is the size of a virtual machine's disk, in GiB.
Expand Down Expand Up @@ -1751,6 +1768,9 @@ spec:
- network
- template
type: object
x-kubernetes-validations:
- message: datastore and datastoreCluster cannot both be set
rule: '!(has(self.datastore) && has(self.datastoreCluster))'
status:
description: status is the observed state of VSphereVM.
minProperties: 1
Expand Down
13 changes: 13 additions & 0 deletions controllers/vspheredeploymentzone_controller_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ func (r vsphereDeploymentZoneReconciler) reconcileTopology(ctx context.Context,
}
}

if datastoreCluster := topology.DatastoreCluster; datastoreCluster != "" {
if _, err := deploymentZoneCtx.AuthSession.Finder.DatastoreCluster(ctx, datastoreCluster); err != nil {
deprecatedv1beta1conditions.MarkFalse(deploymentZoneCtx.VSphereDeploymentZone, infrav1.VSphereFailureDomainValidatedV1Beta1Condition, infrav1.DatastoreClusterNotFoundV1Beta1Reason, clusterv1.ConditionSeverityError, "datastore cluster %s is misconfigured", datastoreCluster)
conditions.Set(deploymentZoneCtx.VSphereDeploymentZone, metav1.Condition{
Type: infrav1.VSphereDeploymentZoneFailureDomainValidatedCondition,
Status: metav1.ConditionFalse,
Reason: infrav1.VSphereDeploymentZoneFailureDomainDatastoreClusterNotFoundReason,
Message: fmt.Sprintf("datastore cluster %s is misconfigured", datastoreCluster),
})
return pkgerrors.Wrapf(err, "unable to find datastore cluster %s", datastoreCluster)
}
}

for _, network := range topology.Networks {
if _, err := deploymentZoneCtx.AuthSession.Finder.Network(ctx, network); err != nil {
deprecatedv1beta1conditions.MarkFalse(deploymentZoneCtx.VSphereDeploymentZone, infrav1.VSphereFailureDomainValidatedV1Beta1Condition, infrav1.NetworkNotFoundV1Beta1Reason, clusterv1.ConditionSeverityError, "network %s is not found", network)
Expand Down
Loading