WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / VSAN / Extending RVC to support renaming VM Storage Policies

Extending RVC to support renaming VM Storage Policies

03.18.2014 by William Lam // 1 Comment

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

More from my site

  • Feedback on default behavior for VM Storage Policy
  • Minimum permissions to view VM Storage Policies
  • SPBM APIs are now included in pyvmomi (vSphere SDK for Python)
  • Exploring VSAN APIs Part 6 – Modifying Virtual Machine VM Storage Policy
  • How to upgrade to the latest VSAN Beta Refresh of RVC on Windows?

Categories // VSAN, vSphere Tags // rvc, spbm, vm storage policy, vm storage profile

Comments

  1. *protectedavnish30jn says

    09/09/2020 at 3:03 am

    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.

    Reply

Thanks for the comment!Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025