feat: add support for storage policies#697
Open
pascalinthecloud wants to merge 3 commits intovmware:mainfrom
Open
feat: add support for storage policies#697pascalinthecloud wants to merge 3 commits intovmware:mainfrom
pascalinthecloud wants to merge 3 commits intovmware:mainfrom
Conversation
Collaborator
|
CI is failing. Be sure to run "make generate" and push to your fork. Also, please sign your commits per the contributing guidelines. Thanks! |
a5ad88b to
a1eb4e3
Compare
Author
|
Hey, |
a1eb4e3 to
fa65dfc
Compare
Collaborator
|
Hi @pascalinthecloud 👋🏻 - I'm hoping to be able to review and test e2e later this week. Ryan |
… and VM creation Signed-off-by: Pascal T. <pascal@toepke.dev>
Signed-off-by: Pascal T. <pascal@toepke.dev>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Pascal T. <pascal@toepke.dev>
fa65dfc to
ac915b9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds per-disk storage policy support to the
vsphere-isobuilder (and the sharedDiskConfigused byvsphere-clone).A new optional
storage_policyfield on eachstorage {}block accepts a vSphere storage policy name. At build time the plugin resolves the name to a profile UUID via the Policy-Based Management (PBM) API and attaches aVirtualMachineDefinedProfileSpecto the disk's device config spec. The VM home files (.vmx,.nvram, etc.) are also placed under the same policy viaVirtualMachineConfigSpec.VmProfile, which the vSphere API requires whenever any disk carries a per-disk profile. If the field is left empty the behaviour is unchanged — the datastore's default policy applies.The PBM client is initialised lazily on first use from the existing VIM25 session, so no new connection or credential is needed.
Example usage:
Type
fix: Bug Fixfeat: Feature or Enhancementdocs: Documentationrefactor: Refactoringchore: Build, Dependencies, Workflows, etc.other: Other (Please describe.)Breaking Changes?
The new field is optional. Existing templates without
storage_policyare unaffected.Tests
New unit tests:
driver/disk_test.goTestAddStorageDevices_WithStoragePolicyVirtualMachineDefinedProfileSpecis attached to the correct disk'sVirtualDeviceConfigSpec; absent on disks without a policydriver/vm_test.goTestVirtualMachineDriver_CreateVM_WithStoragePolicyCreateVMsucceeds end-to-end via the govmomi simulator when a disk carries aStoragePolicyID, exercising theVmProfilebranch of the VM config speciso/step_create_test.goTestStepCreateVM_Run_WithStoragePolicyStoragePolicyIDon the driver diskiso/step_create_test.goTestStepCreateVM_Run_StoragePolicyNotFoundOutput:
The feature was also validated against a live vCenter with a real storage policy.
Documentation
docs-partials/builder/vsphere/common/DiskConfig-not-required.mdxwas updated with the newstorage_policyfield. This partial is shared betweenvsphere-isoandvsphere-clonedocs.Issue References
Closes #18
Release Note
Additional Information
Implementation notes:
govmomi/pbm) is already an indirect dependency viagovmomi— no new module dependency is introduced.Runstep), not duringPrepare, so the error message includes the vCenter-side policy name and is actionable.VirtualMachineConfigSpec.VmProfileis set to the first disk's policy when any disk carries a policy. This is required by the vSphere API and mirrors the behaviour of other tools (Terraform provider, govc). If disks have mixed policies the VM home uses the first disk's policy; a dedicated VM-home policy field can be added in a follow-up.