Creating Resource Pools and Port Groups via CLI

August 17, 2014 Brian Cunnie

Creating a VMware vSphere resource pool is easily accomplished via the vSphere Web Client; however, the creation of multiple resource pools quickly devolves into a clickfest, and introduces the possibility of manual error.

This blog post describes how we created dozens of resource pools for the Cloud Foundry development environment using rvc. This blog post also describes the creation of VMware vSphere distributed port groups.

You will need a working understanding of the Ruby programming language and its gems.

Note to Windows Users

Windows users should stop reading this blog post and instead use VMware’s PowerCLI. PowerCLI has tools to create a resource pools and port groups via the command line.

Installing nokogiri 1.5.5 and rvc

rvc requires a downgraded nokogiri 1.5.5 (to avoid this issue), and the nokogiri install is tricky. These are the steps we followed on our OS X 10.9.4 workstation. Note that we assume that homebrew is installed and that we’re using a ruby manager such as rvm, rbenv, or chruby (we use chruby). We use ruby 2.1.2p95.

We followed these nokogiri instructions, but we updated the paths for libxml2 and libxslt (see below)

First we install libxml2, libxslt:

brew install libxml2 libxslt
brew link libxml2 libxslt

Then we install libiconv:

mkdir /tmp/junk.$$; pushd /tmp/junk.$$
tar xvfz libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
sudo make install

Then we install nokogiri 1.5.5:

gem install nokogiri -v 1.5.5 --

Finally we install rvc:

gem install rvc

Creating One Resource Pool

Our vCenter’s information follows:

  • hostname:
  • User name: root
  • Password: our-secret-password
  • Datacenter: Datacenter (not very original, we know)
  • Cluster: Cluster (again, not very original)

[note: we are curious of rvc’s behavior when the user name contains an ‘@’ symbol (e.g. administrator@vsphere.local instead of root), most common when the vCenter Server is Windows-based. If rvc doesn’t work properly, or you need to invoke in a special manner, please let us know.]

We connect to our vcenter via rvc:

$ rvc
Install the "ffi" gem for better tab completion.
The authenticity of host '' can't be established.
Public key fingerprint is e2699564b5eb672abbf5fbc78586e472ad1fedd9bd4082b98334c23959979b64.
Are you sure you want to continue connecting (y/n)? y
Warning: Permanently added '' (vim) to the list of known hosts
Welcome to RVC. Try the 'help' command.
VMRC is not installed. You will be unable to view virtual machine consoles. Use the vmrc.install command to install it.
0 /

We can now create our resource pool test_rp using the following incantation in our rvc shell. There are shorter incantations, but this one most closely mimics the creation of a resource pool via the web client interface using the default options (e.g. no cpu limit, no memory limit):

resource_pool.create test_rp / --cpu-reservation 0 --cpu-limit 18446744073709551615 --cpu-expandable --mem-limit 18446744073709551615 --mem-reservation 0 --mem-expandable

We verify that the resource pool test_rp has been created by using the vSphere Web Client and browsing to vCenter → Resource Pools

Creating Additional Resource Pools

In order to create additional resource pools, we use rvc’s shell’s feature which lets you use Ruby to invoke rvc’s underlying method. We instruct rvc to execute a line as Ruby code by pre-pending a ‘/’ in front of the line.

Note that we first cd into our cluster (“Cluster”) in order to use rvc’s special variable this, which corresponds to the object that represents the directory we’re in (i.e. the cluster).

In this example, we create the port groups test_rp1, test_rp2, test_rp3, and test_rp4:

# need to `cd` to be able to use `this`
cd /
/pools = %w(test_rp1 test_rp2 test_rp3 test_rp4)
/pools.each do |pool| resource_pool.create(pool,this,{ cpu_limit: -1, cpu_reservation: 0, cpu_expandable: true, cpu_shares: 'normal', mem_limit: -1, mem_reservation: 0, mem_expandable: true, mem_shares: 'normal' }) end

Creating a Distributed Port Group

We have a distributed virtual switch that we have already created: DSwitch

We will create a new distributed port group: DPortGroup by using rvc’s shell:

vds.create_portgroup / DPortGroup

Assigning a VLAN to a Distributed Port Group

We find we often need to assign a specific VLAN to distributed port group. In this example, we assign VLAN 400 to the port group DPortGroup

vds.vlan_switchtag / 400

About the Author


More Content by Brian Cunnie
Cloud Foundry UAA: Onwards and Upwards into the Cloud
Cloud Foundry UAA: Onwards and Upwards into the Cloud

During the last two quarters, Cloud Foundry at Pivotal has revamped its identity management team and are pr...

Gartner Panel Reveals Stark Differences in Container Based PaaS Options
Gartner Panel Reveals Stark Differences in Container Based PaaS Options

This week’s Gartner panel on PaaS marked an important milestone in market education on fundamentally differ...

Enter curious. Exit smarter.

Register Now