-
Notifications
You must be signed in to change notification settings - Fork 453
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
Conversation
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.
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
@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? |
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.
@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. |
@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? |
@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. |
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. |
@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? One question I have about running tests. As stated in docs, |
…orm-provider-vsphere into f-spbm-support Adding storage policy Read in virtual machine resource.
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. |
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. |
@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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…pport Pulling in additional acceptance tests and doc updates
Merged via CLI to pull in a few additional changes such as acceptance tests. |
Thanks Bill for your help. |
Hi all.
ty |
@Rodrigo0461 getting similar error while deploying VM via module.
With this, works without problem.
|
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? |
Storage policy can be applied to VM and virtual disk in Create and Update operations.
Website docs added for the code changes.