With rackspaces providing its compute service based on OpenStack, its possible to control your servers using the openstack nova client and its fairly simple to do.
You start by installing the openstack-novaclient (these examples are done on fedora 17). For now python-setuptools is needed here as a dependency.
> sudo yum install python-setuptools python-novaclient
Create the file ~/rackspacerc, this file will be used to setup our environment anytime we want to use nova, it should look something like this
export OS_USERNAME=username
export OS_PASSWORD=passwd
export OS_AUTH_URL=https://identity.api.rackspacecloud.com/v2.0/
export OS_REGION_NAME=DFW
export OS_TENANT_NAME=1234567
export NOVA_SERVICE_NAME=cloudServersOpenStack
A word about some of these settings and where to get their values
OS_USERNAME : This is your login name for your rackspace Open Cloud account
OS_PASSWORD : Your password….
OS_AUTH_URL : this is the url to the rackspaces identity managment server, if you have a rackspace.co.uk account then this should be set to https://lon.identity.api.rackspacecloud.com/v2.0/ , leave it as above if your rackspace account is .com
OS_REGION_NAME : the code for the data center in which you want to control servers (DFW is Dallas, ORD Chicago, LON London), Use DFW or ORD if rackspace.com or LON if rackspace.co.uk
OS_TENANT_NAME : the id for your account, you can get this in the top right hand corner of the control panel when you log in
Once you have created the file ~/rackspacerc you simply have to setup the environment in your current shell (Note : you have to run this command in any new terminals you want to use Nova in), alternativly you could put the contents of this file into ~/.bashrc (if using bash)
> source ~/rackspacerc
Now your ready, lets go
List all of your running servers
> nova list
List all available images
> nova image-list +--------------------------------------+----------------------------+--------+--------+ | ID | Name | Status | Server | +--------------------------------------+----------------------------+--------+--------+ | 0d589460-f177-4b0f-81c1-8ab8903ac7d8 | Arch 2011.10 | ACTIVE | | | 03318d19-b6e6-4092-9b5c-4758ee0ada60 | CentOS 5.6 | ACTIVE | | | a3a2c42f-575f-4381-9c6d-fcd3b7d07d17 | CentOS 6.0 | ACTIVE | | | 0cab6212-f231-4abd-9c70-608d0d0e04ba | CentOS 6.2 | ACTIVE | | | c195ef3b-9195-4474-b6f7-16e5bd86acd0 | CentOS 6.3 | ACTIVE | | | a10eacf7-ac15-4225-b533-5744f1fe47c1 | Debian 6 (Squeeze) | ACTIVE | | | bca91446-e60e-42e7-9e39-0582e7e20fb9 | Fedora 16 (Verne) | ACTIVE | | | d42f821e-c2d1-4796-9f07-af5ed7912d0e | Fedora 17 (Beefy Miracle) | ACTIVE | | <snip/>
List all of the available flavors
> nova flavor-list +----+-------------------------+-----------+------+-----------+------+-------+-------------+ | ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | +----+-------------------------+-----------+------+-----------+------+-------+-------------+ | 2 | 512MB Standard Instance | 512 | 20 | N/A | 512 | 1 | 2.0 | | 3 | 1GB Standard Instance | 1024 | 40 | N/A | 1024 | 1 | 3.0 | | 4 | 2GB Standard Instance | 2048 | 80 | N/A | 2048 | 2 | 6.0 | | 5 | 4GB Standard Instance | 4096 | 160 | N/A | 2048 | 2 | 10.0 | | 6 | 8GB Standard Instance | 8192 | 320 | N/A | 2048 | 4 | 15.0 | | 7 | 15GB Standard Instance | 15360 | 620 | N/A | 2048 | 6 | 20.0 | | 8 | 30GB Standard Instance | 30720 | 1200 | N/A | 2048 | 8 | 30.0 | +----+-------------------------+-----------+------+-----------+------+-------+-------------+
Boot a server, get imageid and flavourid from above(highlighted), this command should also output a Admin password, make sure you take note of this for later.
> nova boot --image d42f821e-c2d1-4796-9f07-af5ed7912d0e --flavor 3 fedora_17_instance +-------------------------+--------------------------------------+ | Property | Value | +-------------------------+--------------------------------------+ | OS-DCF:diskConfig | AUTO | | OS-EXT-STS:power_state | 0 | | OS-EXT-STS:task_state | scheduling | | OS-EXT-STS:vm_state | building | | accessIPv4 | | | accessIPv6 | | | adminPass | k8KigVmJ2h5T | <-- root password | created | 2012-08-17T20:19:54Z | | flavor | 1GB Standard Instance | | hostId | | | id | c7ed6132-3dcf-49e9-8001-ff88fa5337ae | <-- instance id | image | Fedora 17 (Beefy Miracle) | | metadata | {} | | name | fedora_17_instance | | progress | 0 | | rax-bandwidth:bandwidth | [] | | status | BUILD | | tenant_id | ****** | | updated | 2012-08-17T20:19:54Z | | user_id | ****** | +-------------------------+--------------------------------------+
This can take a little time, go make some tea and come back, check the status of your server by runing nova list, we’ll see it change to a status of ACTIVE when its ready
> nova list +--------------------------------------+--------------------+--------+---------------------------------------------------------------------------------------+ | ID | Name | Status | Networks | +--------------------------------------+--------------------+--------+---------------------------------------------------------------------------------------+ | c7ed6132-3dcf-49e9-8001-ff88fa5337ae | fedora_17_instance | ACTIVE | public=2001:4800:780e:0510:7451:3c99:ff04:5211, 198.101.242.17; private=10.180.15.158 | +--------------------------------------+--------------------+--------+---------------------------------------------------------------------------------------+
Shortly after it changes into the ACTIVE state you can ssh to your instance, nova list should show you a public ip address to use(highlighted above), the password you’ll be prompted for is the admin password from earlier.
> ssh root@198.101.242.17 > # Do something useful > exit
Don’t forget to delete the server if your done with it
> nova delete c7ed6132-3dcf-49e9-8001-ff88fa5337ae
If deleted you should see it dissapear from nova list (It could take a minute or two)
> nova list