Skip to content

Commit

Permalink
Merge pull request #520 from terraform-providers/f-vsphere-datastore-…
Browse files Browse the repository at this point in the history
…cluster-vm-anti-affinity-rule-resource

r/datastore_cluster_vm_anti_affinity_rule: New resource
  • Loading branch information
vancluever authored May 11, 2018
2 parents 1ef325a + e370f1f commit 2fd74c7
Show file tree
Hide file tree
Showing 7 changed files with 1,087 additions and 29 deletions.
28 changes: 28 additions & 0 deletions vsphere/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1022,3 +1022,31 @@ func testGetComputeClusterVMAntiAffinityRule(s *terraform.State, resourceName st

return resourceVSphereComputeClusterVMAntiAffinityRuleFindEntry(cluster, name)
}

// testGetDatastoreClusterVMAntiAffinityRule is a convenience method to fetch a
// VM anti-affinity rule from a datastore cluster.
func testGetDatastoreClusterVMAntiAffinityRule(s *terraform.State, resourceName string) (*types.ClusterAntiAffinityRuleSpec, error) {
vars, err := testClientVariablesForResource(
s,
fmt.Sprintf("%s.%s", resourceVSphereDatastoreClusterVMAntiAffinityRuleName, resourceName),
)
if err != nil {
return nil, err
}

if vars.resourceID == "" {
return nil, errors.New("resource ID is empty")
}

podID, key, err := resourceVSphereDatastoreClusterVMAntiAffinityRuleParseID(vars.resourceID)
if err != nil {
return nil, err
}

pod, err := storagepod.FromID(vars.client, podID)
if err != nil {
return nil, err
}

return resourceVSphereDatastoreClusterVMAntiAffinityRuleFindEntry(pod, key)
}
2 changes: 1 addition & 1 deletion vsphere/internal/helper/storagepod/storage_pod_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func Create(f *object.Folder, name string) (*object.StoragePod, error) {
// ApplyDRSConfiguration takes a types.StorageDrsConfigSpec and applies it
// against the specified StoragePod.
func ApplyDRSConfiguration(client *govmomi.Client, pod *object.StoragePod, spec types.StorageDrsConfigSpec) error {
log.Printf("[DEBUG] Applying storage DRS configuration against datastore clsuter %q", pod.InventoryPath)
log.Printf("[DEBUG] Applying storage DRS configuration against datastore cluster %q", pod.InventoryPath)
mgr := object.NewStorageResourceManager(client.Client)
ctx, cancel := context.WithTimeout(context.Background(), provider.DefaultAPITimeout)
defer cancel()
Expand Down
57 changes: 29 additions & 28 deletions vsphere/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,34 +88,35 @@ func Provider() terraform.ResourceProvider {
},

ResourcesMap: map[string]*schema.Resource{
"vsphere_compute_cluster": resourceVSphereComputeCluster(),
"vsphere_compute_cluster_host_group": resourceVSphereComputeClusterHostGroup(),
"vsphere_compute_cluster_vm_affinity_rule": resourceVSphereComputeClusterVMAffinityRule(),
"vsphere_compute_cluster_vm_anti_affinity_rule": resourceVSphereComputeClusterVMAntiAffinityRule(),
"vsphere_compute_cluster_vm_dependency_rule": resourceVSphereComputeClusterVMDependencyRule(),
"vsphere_compute_cluster_vm_group": resourceVSphereComputeClusterVMGroup(),
"vsphere_compute_cluster_vm_host_rule": resourceVSphereComputeClusterVMHostRule(),
"vsphere_custom_attribute": resourceVSphereCustomAttribute(),
"vsphere_datacenter": resourceVSphereDatacenter(),
"vsphere_datastore_cluster": resourceVSphereDatastoreCluster(),
"vsphere_distributed_port_group": resourceVSphereDistributedPortGroup(),
"vsphere_distributed_virtual_switch": resourceVSphereDistributedVirtualSwitch(),
"vsphere_drs_vm_override": resourceVSphereDRSVMOverride(),
"vsphere_dpm_host_override": resourceVSphereDPMHostOverride(),
"vsphere_file": resourceVSphereFile(),
"vsphere_folder": resourceVSphereFolder(),
"vsphere_ha_vm_override": resourceVSphereHAVMOverride(),
"vsphere_host_port_group": resourceVSphereHostPortGroup(),
"vsphere_host_virtual_switch": resourceVSphereHostVirtualSwitch(),
"vsphere_license": resourceVSphereLicense(),
"vsphere_tag": resourceVSphereTag(),
"vsphere_tag_category": resourceVSphereTagCategory(),
"vsphere_virtual_disk": resourceVSphereVirtualDisk(),
"vsphere_virtual_machine": resourceVSphereVirtualMachine(),
"vsphere_nas_datastore": resourceVSphereNasDatastore(),
"vsphere_storage_drs_vm_override": resourceVSphereStorageDrsVMOverride(),
"vsphere_vmfs_datastore": resourceVSphereVmfsDatastore(),
"vsphere_virtual_machine_snapshot": resourceVSphereVirtualMachineSnapshot(),
"vsphere_compute_cluster": resourceVSphereComputeCluster(),
"vsphere_compute_cluster_host_group": resourceVSphereComputeClusterHostGroup(),
"vsphere_compute_cluster_vm_affinity_rule": resourceVSphereComputeClusterVMAffinityRule(),
"vsphere_compute_cluster_vm_anti_affinity_rule": resourceVSphereComputeClusterVMAntiAffinityRule(),
"vsphere_compute_cluster_vm_dependency_rule": resourceVSphereComputeClusterVMDependencyRule(),
"vsphere_compute_cluster_vm_group": resourceVSphereComputeClusterVMGroup(),
"vsphere_compute_cluster_vm_host_rule": resourceVSphereComputeClusterVMHostRule(),
"vsphere_custom_attribute": resourceVSphereCustomAttribute(),
"vsphere_datacenter": resourceVSphereDatacenter(),
"vsphere_datastore_cluster": resourceVSphereDatastoreCluster(),
"vsphere_datastore_cluster_vm_anti_affinity_rule": resourceVSphereDatastoreClusterVMAntiAffinityRule(),
"vsphere_distributed_port_group": resourceVSphereDistributedPortGroup(),
"vsphere_distributed_virtual_switch": resourceVSphereDistributedVirtualSwitch(),
"vsphere_drs_vm_override": resourceVSphereDRSVMOverride(),
"vsphere_dpm_host_override": resourceVSphereDPMHostOverride(),
"vsphere_file": resourceVSphereFile(),
"vsphere_folder": resourceVSphereFolder(),
"vsphere_ha_vm_override": resourceVSphereHAVMOverride(),
"vsphere_host_port_group": resourceVSphereHostPortGroup(),
"vsphere_host_virtual_switch": resourceVSphereHostVirtualSwitch(),
"vsphere_license": resourceVSphereLicense(),
"vsphere_tag": resourceVSphereTag(),
"vsphere_tag_category": resourceVSphereTagCategory(),
"vsphere_virtual_disk": resourceVSphereVirtualDisk(),
"vsphere_virtual_machine": resourceVSphereVirtualMachine(),
"vsphere_nas_datastore": resourceVSphereNasDatastore(),
"vsphere_storage_drs_vm_override": resourceVSphereStorageDrsVMOverride(),
"vsphere_vmfs_datastore": resourceVSphereVmfsDatastore(),
"vsphere_virtual_machine_snapshot": resourceVSphereVirtualMachineSnapshot(),
},

DataSourcesMap: map[string]*schema.Resource{
Expand Down
Loading

0 comments on commit 2fd74c7

Please sign in to comment.