The next generation Cloud Servers powered by OpenStack is a fast, reliable, and scalable cloud compute solution that lets you provision servers in the Rackspace cloud in minutes.
Cloud Servers provides the core features of the OpenStack Compute API v2 and also deploys certain Rackspace extensions. The OpenStack Compute API and the Rackspace extensions are known collectively as API v2.
The simple exercises in this guide help you get started with the API v2.
For each exercise in this guide, you choose one of the following methods to make API v2 calls:
The nova client, with the optional supernova client. We recommend that you use the nova client to run simple commands that make API v2 calls. The optional supernova client lets you use the nova client with multiple OpenStack nova environments. These open-source Python clients run on Linux or Mac OS X systems and are easy to learn and use. You can specify a debug parameter on any nova or supernova command to show the underlying API v2 request for the command. This is a good way to become familiar with the API v2 requests.
See the section called “How the nova and supernova Clients Work”.
cURL commands. If you are familiar with or want to learn cURL commands, choose this method. With cURL, you send HTTP requests with embedded API v2 calls from the command line. The cURL examples in this guide include request bodies that are in JSON format. See the section called “How cURL Commands Work”.
If you like, you can use cURL in one example and switch to the nova or supernova client in the next example. If you choose to use a cURL command for any example, you must export the environment variables required to run the cURL examples. See the section called “Step 5. (Optional) Export Environment Variables to Run cURL Commands”.
Each example, whether nova client or cURL, points you to the next step in the process.
To use the API v2, it helps to be familiar with HTTP/1.1, RESTful web services, the Rackspace Cloud Servers service, and JSON or XML data serialization formats.
We welcome feedback, comments, and bug reports at http://www.rackspace.com/support/.
How does Cloud Servers work?
Select a size for your Cloud Server
Cloud Server sizes are measured by the amount of physical memory reserved for your instance and range from 512 MB to 30 GB. The size of the server is known as its flavor.
Select your operating system
Choose from a variety of popular Linux® or Windows distributions. The operating system for a server is known as its image.
Your server is online in just a few minutes
You can upgrade or remove each Cloud Server as your needs change. You can manage your Cloud Servers through the Rackspace Cloud Control Panel or through a program or script that calls the API v2, which requires some coding effort.
The simple exercises in this guide help you get started with the API v2 by showing you how to access the API through nova client commands or cURL commands.
The nova client is an open-source Python client that lets you run simple commands to make API v2 calls. This client is easy to learn and use. Each nova client command runs cURL commands that embed API v2 requests. You can run the nova client from a desktop machine or remote system, such as a Cloud Server.
You install the nova client on a Linux distribution or on Mac OS X. You install the nova client in the section called “Step 2. Install the nova Client with the Cloud Networks Extension”.
To configure the nova client, you update your bash profile to set and export nova environment variables.
The optional supernova client lets you to use the nova client with multiple OpenStack nova environments. For example, if you maintain multiple Cloud Servers accounts or call different cloud services, you can export a different set of environment variables for each environment. Then, when you run supernova, you pass a parameter that indicates which environment you want to use.
Though this guide does not explicitly show supernova client
commands, you can easily modify the examples in this guide for
supernova. The supernova client commands are identical to the
nova client commands except that you include the parameter in
each supernova command that indicates which environment you
are sourcing. For example, you might run the following
supernova command to source the
production environment and list
images:
$ supernova production image-list
You install the supernova client through the supernova package in the section called “Step 3. (Optional) Install the supernova Client”.
After you install the client, you must create a supernova profile that defines nova environment variables for one or more environments.
![]() | Note |
|---|---|
You can specify a debug parameter on any nova or supernova command to show the underlying API request for the command. This is a good way to become familiar with the API requests. |
Rackspace does not maintain the nova and supernova clients, which are considered to be software in development.
cURL is a command-line tool that you can use to interact with REST interfaces. cURL lets you to transmit and receive HTTP requests and responses from the command line or a shell script, which enables you to work with the API directly. It is available for Linux distributions, Mac OS X, and Windows. For information about cURL, see http://curl.haxx.se/.
To use XML requests and responses, see the section called “XML Requests and Responses”.
To run the cURL request examples shown in this guide, copy each example from the HTML version of this guide directly to the command line or a script.
The following command is an example cURL command that provisions a server with an isolated network:
$ curl https://dfw.servers.api.rackspacecloud.com/v2/$account/servers \
-X POST \
-H "X-Auth-Project-Id: $account" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "X-Auth-Token: $token" \
-d '{"server": {"name": "my_server_with_network", "imageRef": "d42f821e-c2d1-4796-9f07-af5ed7912d0e", "flavorRef": "2", "max_count": 1, "min_count": 1, "networks": [{"uuid": "538a112a-34d1-47ff-bf1e-c40639e886e2"}, {"uuid": "00000000-0000-0000-0000-000000000000"}, {"uuid": "11111111-1111-1111-1111-111111111111"}]}}' \
| python -m json.tool![]() | Note |
|---|---|
The carriage returns in the cURL request examples are
escaped with a backslash ( |
The cURL examples in this guide use the following command-line options:
| Option | Description |
|---|---|
-d
|
Sends the specified data in a POST request to the HTTP server. Use this option to send a JSON or XML request body to the server. |
-H
|
Specifies an extra HTTP header in the
request. You can specify any number of extra
headers. Precede each header with the
Common headers in Rackspace API requests are:
|
-i
|
Includes the HTTP header in the output. |
-s
|
Silent or quiet mode. Does not show progress or error messages. Makes cURL mute. |
-T
|
Transfers the specified local file to the remote URL. |
-X
|
Specifies the request method to use when communicating with the HTTP server. The specified request is used instead of the default method, which is GET. |
![]() | json.tool |
|---|---|
For commands that return a response, you can append the following code to the command to call the json.tool to pretty-print output: | python -m json.tool To use the json.tool, import the json module. For information about the json.tool, see json — JSON encoder and decoder. If you run a Python version older than 2.6, import the simplejson module and use the simplejson.tool. For information about the simple.json tool, see simplejson — JSON encoder and decoder. If you do not want to pretty-print JSON output, omit this code. |
The following example shows a cURL command that specifies an XML request body and returns an XML response. The command creates a server:
Example 1. cURL Command Example: XML Request and Response
$ curl -i https://dfw.servers.api.rackspacecloud.com/v2/$account/servers.xml \-X POST \ -H "X-Auth-Project-Id: $account" \ -H "Content-Type: application/xml" \
-H "Accept: application/xml" \
-H "X-Auth-Token: $token" \ -T server_post_req.xml
| ppxml
![]()
The example, Example 1, “cURL Command Example: XML Request and Response”, includes the following changes:
| Append |
| The |
| The |
| If the request requires a request body, specify
it in XML format. In this example, the XML body is
passed in the
|
| To pretty-print the XML output, set the $ alias ppxml='python -c "import sys, xml.dom.minidom; print xml.dom.minidom.parseString(sys.stdin.read()).toprettyxml()"' Then,
append the |
The following example shows the contents of the
server_post_req.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<server xmlns="http://docs.openstack.org/compute/api/v1.1"
imageRef="3afe97b2-26dc-49c5-a2cc-a2fc8d80c001" flavorRef="2"
name="api-test-server-xml2">
<metadata>
<meta key="My Server Name">API Test Server XML</meta>
</metadata>
<personality>
<file path="/etc/banner.txt">
ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp
dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k
IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs
c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g
QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo
ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv
dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy
c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6
b25zLiINCg0KLVJpY2hhcmQgQmFjaA==</file>
</personality>
<networks>
<uuid>0ef47ac7-6797-4e01-8a47-ed26ec3aaa56</uuid>
<uuid>00000000-0000-0000-0000-000000000000</uuid>
<uuid>11111111-1111-1111-1111-111111111111</uuid>
</networks>
</server>
Output: The cURL command returns information about the new server in XML format, as shown in the following example:
<?xml version='1.0' encoding='UTF-8'?>
<server
xmlns:OS-DCF="http://docs.openstack.org/compute/ext/disk_config/api/v1.1"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns="http://docs.openstack.org/compute/api/v1.1"
id="ed5c7754-29b6-45fa-96cb-ab64958c8c0a" adminPass="Dd5pNZtpVVQ3"
OS-DCF:diskConfig="AUTO">
<metadata/>
<atom:link
href="https://dfw.servers.api.rackspacecloud.com/v2/010101/servers/ed5c7754-29b6-45fa-96cb-ab64958c8c0a"
rel="self"/>
<atom:link
href="https://dfw.servers.api.rackspacecloud.com/010101/servers/ed5c7754-29b6-45fa-96cb-ab64958c8c0a"
rel="bookmark"/>
</server>
Next generation Cloud Servers is part of the Rackspace Cloud and your use through the API will be billed as per the pricing schedule at http://www.rackspace.com/cloud/public/servers/pricing.
The Service Level Agreement (SLA) for Cloud Servers is available at http://www.rackspace.com/cloud/legal/sla/#cloud_servers.

![[Note]](/servers-v2-cs-gettingstarted/common/images/admon/note.png)





