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
def profile_rename profile, name
pbm = profile.instance_variable_get(:@connection)
pm = pbm.serviceContent.profileManager
spec = PBM::PbmCapabilityProfileUpdateSpec(
:name => name,
pm.PbmUpdate(:profileId => profile.profileId, :updateSpec => spec)
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