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

SPBM storage policy enablement for VM provisioning. #881

Closed
wants to merge 11 commits into from

Conversation

mnshtiwari
Copy link

Storage policy can be applied to VM and virtual disk in Create and Update operations.
Website docs added for the code changes.

Storage policy can be applied to VM and virtual disk in Create and Update operations.
Website docs added for the code changes.

Adding the docs related to storage policy for website.

ng description in docs of data source storage policy.
@ghost ghost added size/l Relative Sizing: Large documentation Type: Documentation labels Oct 23, 2019
@hashibot hashibot added the enhancement Type: Enhancement label Oct 23, 2019
Copy link
Contributor

@markpeek markpeek left a comment

Choose a reason for hiding this comment

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

LGTM

// pbmClientFromGovmomiClient creates a new pbm client from given govmomi client.
// Can we have it in govmomi client as a field similar to tag client?
// We should not create a new pbm client every time we need it.
func pbmClientFromGovmomiClient(ctx context.Context, client *govmomi.Client) (*pbm.Client, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree this would be better create the pbm client as part of the global config. Given the current structure, I think its ok to leave here for now. There is another feature in progress that needs some modification to the client structure, so I'll see about including the pbm client in that work.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just merged a PR that adds the pbm client to the vSphereClient.

Copy link
Author

Choose a reason for hiding this comment

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

Is there a way to get vSphereClient from govmomi.Client?
We have govmomi.Client handle in VM operations and need pbm.Client from it. The vSphereClient struct will have pbm.Client.

if err != nil {
return err
}
vmMOID := vm.Reference().Value
Copy link
Contributor

Choose a reason for hiding this comment

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

We've got a convenience function to simplify getting the MOID from the UUID you can use here.

Copy link
Contributor

@bill-rich bill-rich left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for the submission!

I added a couple comments outside of the review. One other thing I'd like to add before merging this PR is acceptance tests for the data source and updating the create and update tests for the virtual machine.

@markpeek
Copy link
Contributor

@bill-rich thank you for the review. Since there isn't a terraform way to create a SPBM policy (possible future work), how would you suggest structuring the acceptance tests to allow querying the data source and the VM tests?

@bill-rich
Copy link
Contributor

@markpeek Since we can't create the SPBM, for now I'd recommend having the tests use an env variable to specify an existing one. You can add it here. Ideally we can create most test fixtures at test time, but (as you can see in that file), we've got quite a few exceptions.

bill-rich and others added 8 commits October 30, 2019 17:53
Sometimes govmomi will return a PortGroup spec where the failure
criteria property of the nic teaming policy can be nil.

When this happens we crash because the code doesn't check for this case.

Addresses the crash in hashicorp#869
…_govmomi_tags

Switch to govmomi tags client
Storage policy can be applied to VM and virtual disk in Create and Update operations.
Website docs added for the code changes.

Adding the docs related to storage policy for website.

ng description in docs of data source storage policy.
@mnshtiwari
Copy link
Author

@bill-rich I am trying to run the Virtual Machine acceptance tests before adding the tests related to storage policy. I went through the "tf-vsphere-devrc.mk.example" and added the env variables for storage policy.

Is there any guideline or requirement of vSphere infrastructure to run the tests? For example, VC should have 2 clusters with each 3 hosts each and certain type of datastores. Any pointers in this regard will be very helpful.

@markpeek
Copy link
Contributor

@bill-rich @mnshtiwari I know there are people wanting to use this functionality but it looks like this has stalled. What needs to be done to get this merged?

@bill-rich
Copy link
Contributor

@mnshtiwari @markpeek I'm currently working on a document to describe the environment requirements to run the acceptance tests, and am hoping to have it ready to share by the end of the week. Once that is ready, hopefully it'll be easier to get this finished up.

@mnshtiwari
Copy link
Author

@mnshtiwari @markpeek I'm currently working on a document to describe the environment requirements to run the acceptance tests, and am hoping to have it ready to share by the end of the week. Once that is ready, hopefully it'll be easier to get this finished up.

Thanks @markpeek.

@bill-rich
Copy link
Contributor

Since the process of getting the acceptance test environment requirements is taking a while, I can help out and get the acceptance tests written. That way we can get this merged and not be blocking.

@mnshtiwari
Copy link
Author

Since the process of getting the acceptance test environment requirements is taking a while, I can help out and get the acceptance tests written. That way we can get this merged and not be blocking.

Thanks @bill-rich . I would start adding tests keeping in mind the requirements for storage policy tests. I'll put new env variables as required.
Testing storage policy would require a vSAN cluster to be present in vSphere. So it will be added as requirement for it in env variables.
I'll update the pull request with all these changes and you can advise and review the test cases.

@bill-rich
Copy link
Contributor

@mnshtiwari & @markpeek Please take a look at https://github.com/terraform-providers/terraform-provider-vsphere/tree/pr/881 and let me know what you think of the added tests.

@mnshtiwari
Copy link
Author

mnshtiwari commented Dec 20, 2019

@mnshtiwari & @markpeek Please take a look at https://github.com/terraform-providers/terraform-provider-vsphere/tree/pr/881 and let me know what you think of the added tests.

Tests look good. Two points to add:

1- Need to add read and set the property "storage_policy_id" in "flattenVirtualMachineConfigInfo" for test to work. Only expand is added for now. Should I add this in a new pull request?
2- Need to add similar test for virtual disk.

One question I have about running tests. As stated in docs,
make testacc TESTARGS="-run=TestAccVSphereVirtualMachine"
will run the tests under this category. To run a specific test, e.g. "TestAccVSphereVirtualMachine_spbm", will the below work:
make testacc TESTARGS="-run=TestAccVSphereVirtualMachine_spbm"

…orm-provider-vsphere into f-spbm-support

Adding storage policy Read in virtual machine resource.
@ghost ghost added size/xxl Relative Sizing: Extra-Extra-Large and removed size/l Relative Sizing: Large labels Jan 16, 2020
@bill-rich
Copy link
Contributor

I was looking over the PR, and I think you're right @mnshtiwari, we need to get the reading and updating of virtual machine storage policies added before we can release. I had to spend a little time getting familiar with the PR again (sorry, its been a while). If anyone on your side has the bandwidth to get that implemented, I can take a look first thing. Otherwise, I'll look at taking care of it since I've been blocking for so long. Either way, I'm holding the release for this PR so that we can get it out ASAP.

@bill-rich
Copy link
Contributor

We ran into a problem with the rest client with govmomi, so we had to revert the earlier PR. I see you've pulled in those changes. I'd like to switch to govmomi, but it'll take a little investigation. I'm looking into that now and will provide updates by tomorrow.

@markpeek
Copy link
Contributor

@bill-rich were you able to look at the changes @mnshtiwari made to address your review request on reading and updating the virtual machine storage policies? Also, what is the govmomi issue? Is there an Issue opened for it in the gvmomi repo?

Copy link
Contributor

@bill-rich bill-rich left a comment

Choose a reason for hiding this comment

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

LGTM

bill-rich added a commit that referenced this pull request Jan 24, 2020
…pport

Pulling in additional acceptance tests and doc updates
@bill-rich
Copy link
Contributor

Merged via CLI to pull in a few additional changes such as acceptance tests.

@bill-rich bill-rich closed this Jan 24, 2020
@mnshtiwari
Copy link
Author

LGTM

Thanks Bill for your help.

@Rodrigo0461
Copy link

Hi all.
For default, my repo it take the 1.16 version (last release) then I get this error

vsphere_virtual_machine.xxxxl_node: ServerFaultCode: NoPermission
can anybody help me?

ty

@Koleon
Copy link

Koleon commented Feb 6, 2020

@Rodrigo0461 getting similar error while deploying VM via module.

Error: disk.0: validation failed (ServerFaultCode: NoPermission)

  on .terraform/modules/misp/vsphere_virtual_machine_linux.tf line 8, in resource "vsphere_virtual_machine" "virtual_machine_linux":
    8: resource "vsphere_virtual_machine" "virtual_machine_linux" {

With this, works without problem.

terraform {
  required_providers {
    vsphere = "= 1.15"
  }
}

@mnshtiwari
Copy link
Author

@Rodrigo0461 getting similar error while deploying VM via module.

Error: disk.0: validation failed (ServerFaultCode: NoPermission)

  on .terraform/modules/misp/vsphere_virtual_machine_linux.tf line 8, in resource "vsphere_virtual_machine" "virtual_machine_linux":
    8: resource "vsphere_virtual_machine" "virtual_machine_linux" {

With this, works without problem.

terraform {
  required_providers {
    vsphere = "= 1.15"
  }
}

Can we get vCenter vpxd log where the call "CreateVM_Task" is failing?

@mnshtiwari
Copy link
Author

@Rodrigo0461 getting similar error while deploying VM via module.

Error: disk.0: validation failed (ServerFaultCode: NoPermission)

  on .terraform/modules/misp/vsphere_virtual_machine_linux.tf line 8, in resource "vsphere_virtual_machine" "virtual_machine_linux":
    8: resource "vsphere_virtual_machine" "virtual_machine_linux" {

With this, works without problem.

terraform {
  required_providers {
    vsphere = "= 1.15"
  }
}

Can we get vCenter vpxd log where the call "CreateVM_Task" is failing?

Also what type of datastore is being used? VMFS, NFS or vSAN?

@ghost ghost locked and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Type: Documentation enhancement Type: Enhancement size/xxl Relative Sizing: Extra-Extra-Large
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants