Category: cloud

Setting up python-openstackclient with Rackspace

I finally got around to switching to python-openstackclient after using python-novaclient and supernova for a number of years. Here’s a quick way to get it set up if you’re using Rackspace as a public cloud OpenStack provider and want to use multiple clouds or regions from one client.

Install python-openstackclient:

pip install python-openstackclient

Create a directory to hold your cloud config file:

mkdir -p $HOME/.config/openstack

Generate a clouds.yaml file, but make sure to put valid information for logging in (make sure to use your password instead of API key):

cat <<EOF > $HOME/.config/openstack/clouds.yaml
    cloud: rackspace
      auth_url: ''
      project_id: rackspace-account-number
      username: rackspace-account-username
      password: rackspace-account-password
    region_name: DFW,ORD,IAD,LON,SYD,HKG

When running the openstack client command, you’ll need to specify the cloud you want to use, and then specify the region you want to call. By default, if –os-region-name isn’t specified, it will use the first entry set in region_name. To list servers in an account:

openstack --os-cloud rackspace --os-region-name=IAD server list

To boot a quick server, first grab the flavor id and image id that you want to boot:

openstack --os-cloud rackspace --os-region-name=IAD flavor list
openstack --os-cloud rackspace --os-region-name=IAD image list

Then take the values you want and boot the server:

openstack --os-cloud rackspace --os-region-name=IAD server create --image <image-uuid> --flavor <flavor-name> --key-name my_key mytestserver

If for any reason you get an error that states the following:

No module named openstack.common

Check and see if you have some older Rackspace novaclient pip packages installed and remove them with pip uninstall:

positron:~ ant$ pip freeze | grep ext

For more information on configuration options, check out the python-openstackclient configuration docs.