I was recently using RVC (Ruby vSphere Console) to setup one of my VSAN lab environments and I had noticed that in the SPBM namespace, that you could create and delete a VM Storage Policy, but you could not rename an existing one. The great thing about RVC is that it is very extensible and I thought it would be useful to have a spbm.profile_rename command, so I decided to build it!
The management of VM Storage Policies is performed through the SPBM API and there is a method called PbmUpdate() which allows you to rename an existing VM Storage Policy. In my environment, I exclusively use the VCSA (vCenter Server Appliance) and in the /root directory, you should see a .rvc directory. To extend the SPBM namepace, you just need to create a new file called spbm.rb which should contain the following snippet of code:
opts :profile_rename do summary "Rename a VM Storage Profile" arg :profile, nil, :lookup => RbVmomi::PBM::PbmCapabilityProfile arg :name, "New name", :type => :string end def profile_rename profile, name _catch_spbm_resets(nil) do pbm = profile.instance_variable_get(:@connection) pm = pbm.serviceContent.profileManager spec = PBM::PbmCapabilityProfileUpdateSpec( :name => name, ) pm.PbmUpdate(:profileId => profile.profileId, :updateSpec => spec) end end
Once you have saved the file, you can now connect to RVC and you should see a new command called spbm.profile_rename which takes an existing VM Storage Policy and the new name of the policy.
Here is an example of what that would look like where I have a VM Storage Policy called "Platinum" and I want to rename it to "Adamantium":
spbm.profile_rename localhost/Datacenter/storage/vmprofiles/Platinum/ Adamantium
avnish30jn says
How do you reapply the storage policy after updating it as it's status is shown as Out of date if the policy is updated.