terraform-provider-vcd icon indicating copy to clipboard operation
terraform-provider-vcd copied to clipboard

VDC VM placement policies

Open cbotha opened this issue 2 years ago β€’ 3 comments

Community Note

  • Please vote on this issue by adding a πŸ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

New or Affected Resource(s)

  • vcd_org_vdc

Desperately need the capability to add pre-created VM placement policies to VDCs. UI flow = Resources > Organisation VDCs > Select VDC Name > Policies > VM Placement > ADD policy


### References

<!---
Information about referencing Github Issues: https://help.github.com/articles/basic-writing-and-formatting-syntax/#referencing-issues-and-pull-requests

Are there any other GitHub issues (open or closed) or pull requests that should be linked here? Vendor blog posts or documentation? For example:

--->

* Issue #0000

cbotha avatar Aug 09 '22 07:08 cbotha

Hi @cbotha, thanks for the suggestion. We will be implementing this new feature in PR #904.

Best regards.

adambarreiro avatar Aug 23 '22 14:08 adambarreiro

Hi, glad this feature is also made available. Will it be possible to list and choose a placement policy as a tenant administrator? I would like to test this feature if possible.

Piedro1 avatar Sep 12 '22 21:09 Piedro1

Hi @cbotha @Piedro1, the request suggested here has been merged to the main branch. It is still not officially released, but you can build the Provider from the source code and try it out. We can help with that if required.

Please note that the complete journey for VM Placement Policies is not 100% complete though, we still need to onboard them to the VM resource/data source to be able to use them. What we merged so far enables users to assign VM Placement Policies to VDCs, creating VM Placement Policies and fetching them.

adambarreiro avatar Sep 23 '22 11:09 adambarreiro

Hello,

Since v3.8.0, released a few days ago, both vcd_vapp_vm and vcd_vm support assigning and reading VM Placement Policies (also they can be assigned to VDCs for that purpose, and created with the new vcd_vm_placement_policy resource)

Please have a look at the changelog here for the list with all the new features and improvements on this regard.

Thanks for the feature request and best regards.

adambarreiro avatar Nov 28 '22 12:11 adambarreiro

Hi

Thanks for the update.

I tried the new provider this morning, but I can’t seem to get it working. In my case I would like to add an existing placement policy to a new VDC upon creation.

I added the following to my plan:

data "vcd_provider_vdc" "pvdc" { name = local.tenant.vdc_pvdc_name }

data "vcd_vm_group" "vmgroup-windows" { name = "WindowsVMgroup" provider_vdc_id = data.vcd_provider_vdc.pvdc.id }

data "vcd_vm_placement_policy" "Existing-policy-1" { name = "Windows" provider_vdc_id = data.vcd_provider_vdc.pvdc.id }

However, it seems like it doesn't like the fact that our PVDC has numerous resource pools backing it

Error: could not find any VM Group with name WindowsVMgroup and pVDC urn:vcloud:providervdc:8cad2615-b37c-4d64-8e1c-2a324be2f8e2: could not get VM Group: more than one Resource Pool found for the pVDC: urn:vcloud:providervdc:8cad2615-b37c-4d64-8e1c-2a324be2f8e2

cbotha avatar Dec 01 '22 10:12 cbotha

Thanks for the feedback, @cbotha, really appreciated. Will check that one.

adambarreiro avatar Dec 01 '22 10:12 adambarreiro

@cbotha I can confirm you that this is indeed a bug present in v3.8.0. PR #948 should fix it, as well as adding an improved way to retrieve VM Placement Policies for tenants (who can't see Provider VDC details).

Would it be possible to try out that branch?

adambarreiro avatar Dec 02 '22 15:12 adambarreiro

@adambarreiro On another note but still placement policy related. I've also been trying to add placement policies to VMs and vAPPS as a tenant. However I noticed that I required a PVDC data point which I can only obtain as a System admin. Is there a way to make use of "placement_policy_id" as an org admin (tenant perspective)?

cbotha avatar Dec 06 '22 11:12 cbotha

Regarding PR#948. Would love to try it out indeed. Do you guide handy of how to make use of this branch?

cbotha avatar Dec 06 '22 11:12 cbotha

@cbotha , Do you have Go compiler? If yes - then you could checkout that PR branch and do make install in the root directory of provider If not - I can help and build you a provider binary from that branch. I just need to know what architecture you are on

Didainius avatar Dec 06 '22 12:12 Didainius

@Didainius No complier unfortunately. I'm using an intel based Mac

cbotha avatar Dec 06 '22 12:12 cbotha

Ok. I have built the plugin with code of PR #948 for you and put it into one drive. This is a link to macOS Intel binary -> https://onevmw-my.sharepoint.com/:u:/g/personal/dserplis_vmware_com/ERSOH4aEbJFIo5aogoLwLlIBez2L-9rTlsI1OflHlTVjzQ?e=1lRWFI

It should be placed in the path as per my below example path (replace _YOUR_USERNAME_ with your name). Name of the file must be kept as it is.

Doing a terraform init with the version directive being bound to 3.8.1 should pick it up.

$ tree ~/.terraform.d

/Users/_YOUR_USERNAME_/.terraform.d
β”œβ”€β”€ checkpoint_cache
β”œβ”€β”€ checkpoint_signature
└── plugins
    └── registry.terraform.io
        └── vmware
            └── vcd
                └── 3.8.1
                    └── darwin_amd64
                        └── terraform-provider-vcd_v3.8.1

Didainius avatar Dec 06 '22 13:12 Didainius

https://github.com/vmware/terraform-provider-vcd/issues/898#issuecomment-1335408057. @Didainius and @adambarreiro Provider 3.8.1 indeed addresses my issue with adding placement policies to a VDC. Thanks!

I'm also interested in testing below. @adambarreiro mentioned "as well as adding an improved way to retrieve VM Placement Policies for tenants (who can't see Provider VDC details)." Where can I find some docs or guidance on how to retrieve and use placement polices as a tenant with 3.8.1?

cbotha avatar Dec 06 '22 14:12 cbotha

@cbotha , The updated docs are in the pull request with code (not very convenient to read) -> https://github.com/vmware/terraform-provider-vcd/pull/948/files#diff-27a45d60496303f9879e488d3001850c476b43fffe9e2c6ae934b8e6d68db6a4R43-R64

Didainius avatar Dec 06 '22 14:12 Didainius

@Didainius and @adambarreiro Thanks! this indeed also solved this issue. Any idea when these changes will be available in the official provider? Will there be a version bump to 3.8.1?

cbotha avatar Dec 07 '22 09:12 cbotha

@Didainius and @adambarreiro Thanks! this indeed also solved this issue. Any idea when these changes will be available in the official provider? Will there be a version bump to 3.8.1?

Yep. We will release 3.8.1 with these fixes. We still have to do some more testing, but it should be out in 1-2 weeks.

Didainius avatar Dec 07 '22 11:12 Didainius

@cbotha , v3.8.1 is now released

Didainius avatar Dec 14 '22 09:12 Didainius