Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Provider VDC and VM Group data sources, VM Placement policies resource+data source and support for VM Placement policies in VDCs #904

Merged
merged 102 commits into from
Sep 23, 2022

Conversation

adambarreiro
Copy link
Collaborator

@adambarreiro adambarreiro commented Aug 23, 2022

This PR solves issue #898.
This PR requires vmware/go-vcloud-director#502 and vmware/go-vcloud-director#504.

Context

The goal is to solve #898. To achieve that, we need to handle references to VM Placement Policies in a new attribute vm_placement_policy_ids in the VDC resources and data sources. As we don't have that mechanism, we need a new data source to fetch them: vcd_vm_placement_policy. At same time, to fetch these VM Placement Policies we need a reference to its associated Provider VDC, as one can have same name VM Placement Policies belonging to different Provider VDCs, hence a new data source vcd_provider_vdc is also required.

For the sake of automating the testing of all of these, the vcd_vm_placement_policy resource has been implemented as well. To create them we also need the vcd_vm_group data source which is also created in this PR.

That's why this PR adds so many things (the three mentioned data sources + new resource + new attribute in VDC), as they are part of the same story.

Features and improvements

  • vcd_org_vdc deprecates default_vm_sizing_policy_id because the name is incorrect, as this attribute is currently holding Sizing Policies, Placement Policies or vGPU Policies. A new attribute default_compute_policy_id has been added to replace it, which represents a more accurate behaviour (A Compute Policy is a superset of the three types mentioned).

    The idea is also that the logic considers default_vm_sizing_policy_id as a fallback of default_compute_policy_id if the latter is not populated. This can be done as they hold the same value (in the end is just the name which is incorrect).

  • vcd_org_vdc has a new attribute vm_placement_policy_ids to support VM Placement policies of the corresponding VDC.

  • New data source vcd_vm_placement_policy to fetch VM Placement Policies given a name and a Provider VDC URN.

  • New resource vcd_vm_placement_policy to create VM Placement Policies given a name, a Provider VDC URN and a set of VM groups or Logical VM Groups.

  • As previous data source requires a Provider VDC URN, a vcd_provider_vdc data source has been added to fetch this. Now pVDCs can be obtained with a name.

  • New data source vcd_vm_group to fetch VM Groups to be used to create VM Placement Policies.

Minor refactors

  • Moved ifIdIsPartOfSlice(id string, ids []string) bool from resource_vcd_org_vdc.go to structure.go as it is an generic/utility function, changed its name and signature to contains(sliceToSearch []string, searched string) bool which is more readable.
  • Tried to improve a bit the readability of vcd_org_vdc part that handles Compute Policies and reduce duplicated code, with not much luck.

Testing

Tests require a new field in vcd_test_config.json:

"vcd": {
    ...
    "nsxtProviderVdc": {
        ...
        "placementPolicyVmGroup": "testVmGroup",
    }
}
  • Manual playing done for vcd_vm_group data source.
  • Manual playing done for vcd_provider_vdc data source.
  • Manual playing done for vcd_vm_placement_policy resource and data source.
  • Manual playing done for vcd_org_vdc with VM Sizing Policies, VM Placement policies and playing with the default Compute Policy
  • Acc tests pass in VCD 10.3
  • Acc tests pass in VCD 10.4

Signed-off-by: abarreiro <abarreiro@vmware.com>
@adambarreiro adambarreiro self-assigned this Aug 23, 2022
abarreiro added 10 commits August 24, 2022 10:21
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
abarreiro added 9 commits August 26, 2022 11:37
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
@adambarreiro adambarreiro changed the title Add VM Placement policies support Add Provider VDC data source, VM Placement policies data source and support for VM Placement policies in VDCs Aug 29, 2022
abarreiro added 6 commits August 29, 2022 15:00
Signed-off-by: abarreiro <abarreiro@vmware.com>
Fix
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
fmt
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Copy link
Contributor

@dataclouder dataclouder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small changes needed

vcd/resource_vcd_org_vdc_with_all_compute_policies_test.go Outdated Show resolved Hide resolved
vcd/resource_vcd_org_vdc_with_vm_placement_policy_test.go Outdated Show resolved Hide resolved
website/docs/d/provider_vdc.html.markdown Outdated Show resolved Hide resolved
website/docs/d/provider_vdc.html.markdown Outdated Show resolved Hide resolved
website/docs/d/provider_vdc.html.markdown Outdated Show resolved Hide resolved
website/docs/d/provider_vdc.html.markdown Show resolved Hide resolved
website/docs/d/provider_vdc.html.markdown Outdated Show resolved Hide resolved
website/docs/d/provider_vdc.html.markdown Outdated Show resolved Hide resolved
abarreiro added 2 commits September 15, 2022 08:10
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
website/docs/d/provider_vdc.html.markdown Outdated Show resolved Hide resolved
website/docs/r/org_vdc.html.markdown Outdated Show resolved Hide resolved
abarreiro added 2 commits September 15, 2022 14:19
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
abarreiro added 2 commits September 21, 2022 14:36
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants