Update examples and rewrite api quick start to make current

Closes-Bug: #1206956

Change-Id: I6f5155569a283b62996afc067ff4391dbd601fd1
Author: Diane Fleming
This commit is contained in:
Diane Fleming 2013-11-06 16:02:54 -06:00 committed by Andreas Jaeger
parent e35c2f4a5b
commit d8bfc49e77
8 changed files with 601 additions and 435 deletions

View File

@ -21,18 +21,6 @@
<artifactId>clouddocs-maven-plugin</artifactId>
<version>1.11.1</version>
<executions>
<!--<execution>
<id>goal1</id>
<goals>
<goal>generate-pdf</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<highlightSource>false</highlightSource>
<sectionAutolabel>0</sectionAutolabel>
<sectionLabelIncludesComponentLabel>0</sectionLabelIncludesComponentLabel>
</configuration>
</execution>-->
<execution>
<id>goal2</id>
<goals>
@ -45,19 +33,6 @@
<disqusShortname>os-apiquickstart</disqusShortname>
<enableGoogleAnalytics>1</enableGoogleAnalytics>
<googleAnalyticsId>UA-17511903-1</googleAnalyticsId>
<!--<generateToc>
appendix toc,title
article/appendix nop
article toc,title
book title,figure,table,example,equation
chapter toc,title
part toc,title
preface toc,title
qandadiv toc
qandaset toc
reference toc,title
set toc,title
</generateToc>-->
<!-- The following elements sets the autonumbering of sections in output for chapter numbers but no numbered sections-->
<webhelpIncludeSearchTab>false</webhelpIncludeSearchTab>
<chapterAutolabel>0</chapterAutolabel>
@ -68,21 +43,16 @@
<mkdir
dir="${project.build.directory}/docbkx/webhelp/api-quick-start-onepager/content"/>
<echo
file="${project.build.directory}/docbkx/webhelp/api-quick-start-onepager/content/deleteme.html">
&lt;html xmlns="http://www.w3.org/1999/xhtml">
&lt;body>
&lt;div id="content">
&lt;p>foo bar baz&lt;/p>
&lt;/div>
&lt;/body>
&lt;/html>
</echo>
file="${project.build.directory}/docbkx/webhelp/api-quick-start-onepager/content/deleteme.html"
> &lt;html xmlns="http://www.w3.org/1999/xhtml">
&lt;body> &lt;div id="content"> &lt;p>foo bar
baz&lt;/p> &lt;/div> &lt;/body> &lt;/html> </echo>
</preProcess>
<postProcess>
<delete
file="${project.build.directory}/docbkx/webhelp/api-quick-start-onepager/content/deleteme.html"/>
file="${project.build.directory}/docbkx/webhelp/api-quick-start-onepager/content/deleteme.html"
/>
</postProcess>
</configuration>
</execution>
</executions>
@ -90,9 +60,7 @@
<!-- These parameters apply to pdf and webhelp -->
<xincludeSupported>true</xincludeSupported>
<sourceDirectory>src/docbkx</sourceDirectory>
<includes>
api-quick-start-onepager.xml
</includes>
<includes> api-quick-start-onepager.xml </includes>
<!--<canonicalUrlBase>http://docs.openstack.org/api/api-quick-start/content/</canonicalUrlBase>-->
<profileSecurity>reviewer</profileSecurity>
<branding>openstack</branding>

View File

@ -3,256 +3,158 @@
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xlink="http://www.w3.org/1999/xlink"
xml:id="Compute_API_Quick_Start" version="5.0">
<title>OpenStack API Quick Start</title>
<para>The OpenStack system has several key projects that are
separate installations but can work together depending on your
cloud needs: OpenStack Compute, OpenStack Object Storage,
OpenStack Identity Service, and OpenStack Image Store. With
the <link xlink:href="http://www.trystack.org/">TryStack</link> OpenStack installation, the OpenStack Compute,
OpenStack Identity, and OpenStack Image Store projects are all
working together in the background of the installation. </para>
<section xml:id="Openstack-API-Concepts-a09234">
<title>OpenStack APIs</title>
<para>To authenticate access to OpenStack services, you issue an
authentication request to the OpenStack Identity Service. You
must supply a payload of credentials in the authentication
request.</para>
<para>Credentials are usually a combination of your user name and
password, and optionally, the name or ID of the tenant in
which your cloud runs. Ask your cloud administrator for your
user name, password, and tenant so that you can generate
authentication tokens. Alternatively, you can supply a token
rather than a user name and password.</para>
<para>A token is typically valid for 24 hours. When you send API
requests, you include the token in the
<literal>X-Auth-Token</literal> header. You must generate
another token if you interact with your cloud through API
endpoints rather than through a client. </para>
<title>OpenStack API Introduction</title>
<para>This page covers the basics for talking to your
OpenStack cloud through the Compute API after authorizing
with the Identity Service API. You can then build a cloud
by launching images and assigning metadata to instances,
all through the API. For an API reference of all the
possible commands, see the <link
xlink:href="http://docs.openstack.org/api/openstack-compute/2/content/"
>OpenStack Compute API v2 specification</link> and
the <link
xlink:href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/"
>Identity Service 2.0 specification</link> published
at <link xlink:href="http://docs.openstack.org/api"
>docs.openstack.org/api</link>. </para>
<orderedlist>
<title>Authentication and API request workflow</title>
<listitem>
<para>Request an authentication token from the Identity
Service endpoint that your cloud administrator gave
you. Send a payload of credentials in the
request:</para>
<informaltable rules="all" width="85%">
<col width="30%"/>
<col width="20%"/>
<col width="50%"/>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>username (Optional)</td>
<td>xsd:string</td>
<td>The user name. If you do not provide a
user name and password, you must provide a
token.</td>
</tr>
<tr>
<td>password (Optional)</td>
<td>xsd:string</td>
<td>The password for the user.</td>
</tr>
<tr>
<td>tenantName (Optional)</td>
<td>xsd:string</td>
<td>The tenant name. Both the
<parameter>tenantId</parameter> and
<parameter>tenantName</parameter> are
optional, but should not be specified
together. If both attributes are
specified, the server responds with a
<errorcode>400</errorcode>
<errorname>Bad Request</errorname>.</td>
</tr>
<tr>
<td>tenantId (Optional)</td>
<td>capi:UUID</td>
<td>The tenant ID. Both the
<parameter>tenantId</parameter> and
<parameter>tenantName</parameter> are
optional, but should not be specified
together. If both attributes are
specified, the server responds with a
<errorcode>400</errorcode>
<errorname>Bad Request</errorname>.</td>
</tr>
<tr>
<td>token (Optional)</td>
<td>capi:UUID</td>
<td>A token. If you do not provide a token,
you must provide a user name and
password.</td>
</tr>
</tbody>
</informaltable>
<para>If the request succeeds, the server returns an
authentication token.</para>
</listitem>
<listitem>
<para>Send API requests and include the token in the
<literal>X-Auth-Token</literal> header. Continue
to send API requests with that token until the job
completes or a <errorcode>401</errorcode>
<errortext>Unauthorized</errortext> error occurs.</para>
</listitem>
<listitem>
<para>If the <errorcode>401</errorcode>
<errortext>Unauthorized</errortext> error occurs,
request another token.</para>
</listitem>
</orderedlist>
<para>The examples in this section use cURL commands. For
information about cURL, see <link
xlink:href="http://curl.haxx.se/"
>http://curl.haxx.se/</link>. For information about the
OpenStack APIs, see <link
xlink:href="http://api.openstack.org/api-ref.html"
>OpenStack API Reference</link>.</para>
<?hard-pagebreak?>
<section xml:id="authenticate">
<title>Authenticate</title>
<para>For a typical OpenStack deployment that runs the
Identity Service, use a cURL command like the following
command to request a token:</para>
<screen><?db-font-size 70%?><prompt>$</prompt> <userinput>curl -i 'http://127.0.0.1:5000/v2.0/tokens' -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '{"auth": {"tenantName": "admin", "passwordCredentials": {"username": "admin", "password": "devstack"}}}'</userinput></screen>
<para>If the request succeeds, you receive a <returnvalue>200
OK</returnvalue> response followed by a response body
that contains a token in the form
<code>"id":"<replaceable>token</replaceable>"</code>
and an expiration date and time in the form
<code>"expires":"<replaceable>datetime</replaceable>"</code>.</para>
<para>The following example shows a successful
response:</para>
<screen><?db-font-size 75%?><computeroutput>HTTP/1.1 200 OK
Vary: X-Auth-Token
Content-Type: application/json
Content-Length: 5858
Date: Wed, 06 Nov 2013 20:06:24 GMT</computeroutput></screen>
<screen><?db-font-size 60%?><computeroutput><xi:include href="get_credentials_resp.json" parse="text"/></computeroutput></screen>
<note>
<para>If you do not know your tenant name or ID, you can
send an authentication request with an empty tenant,
as follows:</para>
<screen><?db-font-size 70%?><prompt>$</prompt> <userinput>curl -i 'http://127.0.0.1:5000/v2.0/tokens' -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '{"auth": {"tenantName": "", "passwordCredentials": {"username": "admin", "password": "devstack"}}}'</userinput></screen>
</note>
</section>
<section xml:id="Getting-Credentials-a00665">
<title>Getting Credentials</title>
<para>Credentials are a combination of your user name,
password, and what tenant (or project) your cloud is
running under. You only need to generate an additional
token if you are interacting with your cloud directly with
API endpoints, and not with a client. Your cloud
administrator can give you a user name and a password as
well as your tenant identifier so you can generate
authorization tokens. You can also get the tenant ID from
the Dashboard URLs, for example
https://trystack.org/dash/296/images/ indicates a tenant
ID of 296. </para>
<para>These tokens are typically good for 24 hours, and when
the token expires, you will find out with a 401
(Unauthorized) error and can request another token
programmatically. The general work flow goes something
like this: </para>
<orderedlist>
<listitem>
<para>Begin API requests by asking for an
authorization token from the endpoint your cloud
administrator gave you, typically
http://hostname:port/v2.0/tokens. You send your
user name, password, and what group or account you
are with (the "tenant" in auth-speak). </para>
<para><programlisting language="bash" role="gutter: false">curl -k -X 'POST' -v https://arm.trystack.org:5443/v2.0/tokens -d '{"auth":{"passwordCredentials":{"username": "joecool", "password":"coolword"}, "tenantId":"5"}}' -H 'Content-type: application/json'</programlisting></para>
</listitem>
<listitem>
<para>The server returns a response in which the
24-hours token is contained. Use that token to
send API requests with the X-Auth-Token included
as an header field.</para>
<para><programlisting language="bash" role="gutter: false">curl -k -D - -H "X-Auth-Token: 7d2f63fd-4dcc-4752-8e9b-1d08f989cc00" -X 'GET' -v https://arm.trystack.org:9774/v1.1/296/extensions -H 'Content-type: application/json' </programlisting></para>
</listitem>
<listitem>
<para>Repeatedly send API requests with that token in
the X-Auth-Token header until either: 1) the job's
done or 2) you get a 401 (Unauthorized) code in
return. </para>
</listitem>
<listitem>
<para>Request a token again when you get a 401
response or until the script's job is done.</para>
</listitem>
</orderedlist>
<para>For a typical OpenStack deployment running the Identity
Service you can request a token with this command in cURL
if you know your
tenantId:<programlisting language="bash" role="gutter: false">
$ curl -X 'POST' -v
https://arm.trystack.org:5443/v2.0/tokens -d
'{"auth":{"passwordCredentials":{"username": "joecool", "password":"coolword"}, "tenantId":"5"}}' -H 'Content-type: application/json'
</programlisting></para>
<para>In return, you should get a 200 OK response with a token
in the form of "id":
"cd427a33-bb4a-4079-a6d7-0ae148bdeda9" and an expiration
date 24 hours from now. Here's what it looks like, the
exact response may vary from cloud-to-cloud:</para>
<para>
<programlisting language="bash" role="gutter: false">
{
"access": {
"serviceCatalog": [
{
"endpoints": [
{
"adminURL": "https://arm.trystack.org:9774/v1.1/1",
"internalURL": "https://arm.trystack.org:9774/v1.1/1",
"publicURL": "https://arm.trystack.org:9774/v1.1/1",
"region": "RegionOne"
}
],
"name": "nova",
"type": "compute"
},
{
"endpoints": [
{
"adminURL": "https://GLANCE_API_IS_NOT_DISCLOSED/v1.1/1",
"internalURL": "https://GLANCE_API_IS_NOT_DISCLOSED/v1.1/1",
"publicURL": "https://GLANCE_API_IS_NOT_DISCLOSED/v1.1/1",
"region": "RegionOne"
}
],
"name": "glance",
"type": "image"
},
{
"endpoints": [
{
"adminURL": "https://arm.trystack.org:5443/v2.0",
"internalURL": "https://keystone.trystack.org:5000/v2.0",
"publicURL": "https://keystone.trystack.org:5000/v2.0",
"region": "RegionOne"
}
],
"name": "keystone",
"type": "identity"
}
],
"token": {
"expires": "2012-02-15T19:32:21",
"id": "5df9d45d-d198-4222-9b4c-7a280aa35666",
"tenant": {
"id": "1",
"name": "admin"
}
},
"user": {
"id": "14",
"name": "joecool",
"roles": [
{
"id": "2",
"name": "Member",
"tenantId": "1"
}
]
}
}
} </programlisting></para>
<para>If you don't know your tenantId, you can send a request
with an empty tenantId, such as this JSON example:</para>
<programlisting language="bash" role="gutter: false">
'{"auth":{"passwordCredentials":{"username": "joecool", "password":"coolword"}, "tenantId":""}}'
</programlisting>
<para>Then, with the auth token that returns, fill in a request using the X-Auth-Token header as an authentication to get your tenantId:</para>
<programlisting>curl -H "X-Auth-Token:6de6d45d-d198-4222-9b4c-7a280aa24888" http://arm.trystack.org:5000/v2.0/tenants</programlisting>
<para>In return, you get a list of
tenants:<programlisting language="bash" role="gutter: false">{
"tenants_links": [],
"tenants": [
{
"enabled": "true",
"description": "joecool",
"name": "joecool",
"id": "tenantnnnnnn"
}
]
}</programlisting></para>
<para>Use the resulting token to make a new POST request
containing the tenantId so you can retrieve
endpoints:</para>
<programlisting language="bash" role="gutter: false">curl -k -X 'POST' -v http://arm.trystack.org:5000/v2.0/tokens -d
'{"auth":{"passwordCredentials":{"username": "usern4me", "password":"passwerd"}, "tenantId":"tenantnnnnnn"}}' -H 'Content-type: application/json'</programlisting>
<para> The resulting JSON contains a list of endpoints, for
example:
<programlisting language="bash" role="gutter: false">{
"endpoints": [
{
"adminURL": "http://10.225.0.8:8774/v2/tenantnnnnnn",
"region": "Calxeda-AUS1",
"internalURL": "http://10.225.0.8:8774/v2/tenantnnnnnn",
"publicURL": "http://208.123.85.197:8774/v2/tenantnnnnnn"
}
],
"endpoints_links": [],
"type": "compute",
"name": "nova"
}</programlisting></para>
<para>In addition, you can see a valid token matched to your
user and
tenantId:<programlisting language="bash" role="gutter: false">{
"access": {
"token": {
"expires": "2012-10-31T17: 13: 12Z",
"id": "new_token***",
"tenant": {
"enabled": true,
"id": "tenantnnnnnn",
"name": "joecool",
"description": "joecool"
}
}
}</programlisting></para>
<section xml:id="send-api-requests">
<title>Send API requests</title>
<para>This section shows how to make some Identity Service and
Compute API calls. For a complete list of Identity Service
API calls, see <link
xlink:href="http://api.openstack.org/api-ref-identity.html"
>Identity Service APIs</link>. For a complete list of
Compute API calls, see <link
xlink:href="http://api.openstack.org/api-ref-compute.html"
>Compute APIs and Extensions</link>.</para>
<para>Use the Identity Service API to request a list of
tenants, as follows:</para>
<screen><?db-font-size 70%?><prompt>$</prompt> <userinput>curl -i -X GET http://166.78.21.23:35357/v2.0/tenants -H "User-Agent: python-keystoneclient" -H "X-Auth-Token: <replaceable>token</replaceable>"</userinput></screen>
<screen><?db-font-size 60%?><computeroutput><xi:include href="tenants_list_resp.json" parse="text"/></computeroutput></screen>
<para>Use the Identity Service API to request a list of
endpoints, as follows:</para>
<screen><?db-font-size 70%?><prompt>$</prompt> <userinput>curl -i -X GET http://166.78.21.23:35357/v2.0/endpoints -H "User-Agent: python-keystoneclient" -H "X-Auth-Token: <replaceable>token</replaceable>"</userinput></screen>
<screen><?db-font-size 60%?><computeroutput><xi:include href="endpoints-list-resp.json" parse="text"/></computeroutput></screen>
<para>Use the Compute API to list servers, as follows:</para>
<screen><?db-font-size 70%?><prompt>$</prompt> <userinput>curl -v -H "X-Auth-Token:<replaceable>token</replaceable>" http://208.123.85.197:8774/v2/<replaceable>tenant_id</replaceable>/servers</userinput></screen>
<screen><?db-font-size 60%?><computeroutput><xi:include href="server-post-resp.json" parse="text"/></computeroutput></screen>
</section>
<section xml:id="Sending-Requests-to-API-a09879">
<title>Sending Requests to the API</title>
<para>You have a couple of options for sending requests to
OpenStack through an API. Developers and testers may
prefer to use cURL, the command-line tool from <link
xlink:href="http://curl.haxx.se/"
>http://curl.haxx.se/</link>. With cURL you can send
HTTP requests and receive responses back from the command
line. </para>
<para>If you like to use a more graphical interface, the REST
client for Firefox also works well for testing and trying
out commands, see <link
xlink:href="https://addons.mozilla.org/en-US/firefox/addon/restclient/"
>https://addons.mozilla.org/en-US/firefox/addon/restclient/</link>.
You can also download and install rest-client, a Java
application to test RESTful web services, from <link
xlink:href="http://code.google.com/p/rest-client/"
>http://code.google.com/p/rest-client/</link>. </para>
<para>You need to generate a token as shown above if you use
cURL or a REST client. </para>
<para>It's also recommended that you install and use a
Command-Line-Client (CLI) such as python-novaclient, which
is documented in <link xlink:href="http://docs.openstack.org/cli/quick-start/content/index.html">CLI guide</link>. </para>
<para>Here's an example of curl commands that can check your list of servers. </para>
<programlisting>curl -v -H "X-Auth-Token:<replaceable>tokengoeshere</replaceable>" http://208.123.85.197:8774/v2/<replaceable>tenantnnnnnn</replaceable>/servers</programlisting>
<para>Here's what you get in return if you have a running server.</para>
<programlisting>{
"servers": [
{
"id": "server***",
"links": [
{
"href": "http://208.123.85.197:8774/v2/tenantnnnnnn/servers/server***",
"rel": "self"
},
{
"href": "http://208.123.85.197:8774/tenantnnnnnn/servers/server***",
"rel": "bookmark"
}
],
"name": "Staging Server"
}
]
}</programlisting>
</section>
</section>

View File

@ -3,11 +3,49 @@
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:html="http://www.w3.org/1999/xhtml"
version="5.0"
xmlns:html="http://www.w3.org/1999/xhtml" version="5.0"
xml:id="openstack-api-quick-start">
<title>OpenStack API Quick Start</title>
<?dbhtml stop-chunking?>
<para>Although you install each OpenStack service separately, the
OpenStack services work together to meet your cloud needs:
Identity Service, Compute, Image Service, Block Storage
Service, Networking, Object Storage, Orchestration, and
Metering. With the <link xlink:href="http://www.trystack.org/"
>TryStack</link> OpenStack installation, these services
work together in the background of the installation.</para>
<para>After you authenticate through the Identity Service, you can
use the other OpenStack APIs to create and manage resources in
your OpenStack cloud. You can launch instances from images and
assign metadata to instances through the Compute API or the
nova command-line client.</para>
<para>To begin sending API requests, use one of the following
methods:</para>
<itemizedlist>
<listitem>
<para><emphasis role="bold">cURL</emphasis></para>
<para>A command-line tool that lets you send HTTP requests
and receive responses. See <xref
linkend="Compute_API_Quick_Start"/>.</para>
</listitem>
<listitem>
<para><emphasis role="bold">OpenStack command-line
clients</emphasis></para>
<para>Each OpenStack project provides a command-line
client that enables you to access its API through
easy-to-use commands. See <xref linkend="cli-intro"/>.</para>
</listitem>
<listitem>
<para><emphasis role="bold">REST clients</emphasis></para>
<para>Both Mozilla and Google provide browser-based
graphical interfaces for REST. For Firefox, see <link
xlink:href="https://addons.mozilla.org/en-US/firefox/addon/restclient/"
>RESTClient</link>. For Chrome, see <link
xlink:href="http://code.google.com/p/rest-client/"
>rest-client</link>.</para>
</listitem>
</itemizedlist>
<xi:include href="api-quick-start-intro.xml"/>
<xi:include href="cli-uses.xml"/>
<xi:include href="cli-uses.xml"/>
</chapter>

View File

@ -1,148 +1,169 @@
<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://docbook.org/ns/docbook"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xlink="http://www.w3.org/1999/xlink"
xml:id="Setting-Up-Python-novaclient"
xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="cli-intro"
version="5.0">
<title>Setting Up python-novaclient</title>
<para>For more serious scripting work, you can use a client like the
python-novaclient client. The python-novaclient implements
Compute API through a command-line interface. You only need a
user name and password to use the python-novaclient tool. </para>
<para>Installing the python-novaclient gives you a <code>nova</code> shell command that enables
Compute API interactions from the command line. You install the client, and then provide
your user name and password, set as environment variables for convenience, and then you
can have the ability to send commands to your cloud on the command-line.</para>
<para>To install python-novaclient, install from Pypi
like so. </para>
<programlisting language="bash" role="gutter: false">
$ pip install python-novaclient
</programlisting>
<para>The <link xlink:href="http://docs.openstack.org/cli/quick-start/content/index.html">CLI guide</link> offers more detailed install
instructions including how to source your credentials.</para>
<section xml:id="Listing-Images-a09140"><title>Listing Images</title><para>Before you can go about the business of building your cloud, you
want to know what images are available to you by asking
the image service what kinds of configurations are
available. The image service could be compared to iTunes
for your cloud - you can view the playlist of images
before using your favorite image to create a new instance
in the cloud. To get the list of images, their names,
status, and ID, use this command:
<programlisting language="bash" role="gutter: false">
$ nova image-list
+----+--------------------------------------+--------+--------+
| ID | Name | Status | Server |
+----+--------------------------------------+--------+--------+
| 12 | natty-server-cloudimg-amd64-kernel | ACTIVE | |
| 13 | natty-server-cloudimg-amd64 | ACTIVE | |
| 14 | oneiric-server-cloudimg-amd64-kernel | ACTIVE | |
| 15 | oneiric-server-cloudimg-amd64 | ACTIVE | |
+----+--------------------------------------+--------+--------+
</programlisting></para>
<para>Next you need to know the relative sizes of each of these. </para>
<para>With the information about what is available to you, you can choose the combination of image and flavor to create your virtual servers and launch instances. </para></section>
<section xml:id="Listing-Flavors"><title>Listing Flavors</title>
<para>You also need to know the ID of the flavor
To get the list of flavors, their names,
status, and ID, use this command:</para>
<programlisting language="bash" role="gutter: false">
$ nova flavor-list
+----+-----------+-----------+------+-----------+------+-------+-------------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor |
+----+-----------+-----------+------+-----------+------+-------+-------------+
| 1 | m1.tiny | 512 | 0 | N/A | 0 | 1 | |
| 2 | m1.small | 2048 | 20 | N/A | 0 | 1 | |
| 3 | m1.medium | 4096 | 40 | N/A | 0 | 2 | |
| 4 | m1.large | 8192 | 80 | N/A | 0 | 4 | |
| 5 | m1.xlarge | 16384 | 160 | N/A | 0 | 8 | |
+----+-----------+-----------+------+-----------+------+-------+-------------+
</programlisting>
<para>With the information about what is available to you, you can choose the combination of image and flavor to create your virtual servers and launch instances. </para></section>
<section xml:id="Listing-Images-a01518"><title>Launching Instances </title>
<para> To launch a server, you choose an image you want to match
up to a size, find the ID for the image and the ID for the
flavor so you can size it, and create the command with the
IDs. From the information we got previously, we know that
an Ubuntu Natty image has an ID of 13, and if you want to
start small with about 2 GB of memory and 20 GB of disk
space, you'd choose the m1.small flavor which has an ID of
2 when using the 1.1 API on TryStack. Put those parameters
in with the "boot" command and you can create a new
virtual server. <note>
<para>When using an endpoint that supports 1.1 of the
Compute API, you can launch instances with an ID.
When using an endpoint that supports v2 of the
Compute API, you must use the UUID to launch an
instance.</para>
</note></para>
<para>
<programlisting language="bash" role="gutter: false">
$ nova boot --flavor=2 --image=13 testserver
+-----------+--------------------------------------+
| Property | Value |
+-----------+--------------------------------------+
| adminPass | **************** |
| created | 2011-09-01T21:40:41Z |
| flavor | m1.small |
| hostId | |
| id | 1805 |
| image | natty |
| metadata | {} |
| name | testserver |
| progress | 0 |
| status | BUILD |
| updated | 2011-09-01T21:40:41Z |
| uuid | ce044452-f22e-4ea4-a3ec-d1cde80cf996 |
+-----------+--------------------------------------+
</programlisting>
</para>
<para>Now, you can view this server in your new cloud by using the nova list
command:<programlisting language="bash" role="gutter: false">
$ nova list
+------+------------+--------+--------------------------------+
| ID | Name | Status | Networks |
+------+------------+--------+--------------------------------+
| 1805 | testserver | ACTIVE | private=10.4.96.81 |
+------+------------+--------+--------------------------------+
</programlisting></para>
<para>There are three statuses you may see - ACTIVE, BUILDING, and UNKNOWN. The BUILDING status is transient and you likely will not see it. If you see UNKNOWN, run <code>nova list</code> again until it goes away.</para>
<para>To view all the information about a particular server, use
<code>nova show</code> with the ID of the server that
you got from the nova list command.</para>
<programlisting language="bash" role="gutter: false">
$ nova show 1805
+-----------------+----------------------------------------------------------+
| Property | Value |
+-----------------+----------------------------------------------------------+
| created | 2011-09-01T21:40:41Z |
| flavor | m1.small |
| hostId | 58a7430169aa42cde5ce2456b0cb5bb5ac1ab0703bab6420e8a49e6e |
| id | 1805 |
| image | natty |
| metadata | {} |
| name | testserver |
| private network | 10.4.96.81 |
| progress | 100 |
| status | ACTIVE |
| updated | 2011-09-01T21:40:46Z |
| uuid | ce044452-f22e-4ea4-a3ec-d1cde80cf996 |
+-----------------+----------------------------------------------------------+
</programlisting>
<para>You can now launch that image again, but add more information to the server when you
boot it so that you can more easily identify it amongst your ever-growing elastic cloud.
Use the -meta option with a key=value pair, where you can make up the string for both the
key and the value. For example, you could add a description and also the creator of the
server.
<programlisting language="bash" role="gutter: false">$ nova boot --flavor=2 --image=13 testserver --meta description='Use for testing purposes' --meta creator=joecool</programlisting></para>
</section></section>
<title>OpenStack command-line clients</title>
<para>For scripting work, you can use a command-line client like
the <systemitem role="client">python-novaclient</systemitem>
client. This client enables you to use the Compute API through
a command-line interface. </para>
<para>For information about the command-line clients, see <link
xlink:href="http://docs.openstack.org/user-guide/content/"
><citetitle>OpenStack End User
Guide</citetitle></link> and <link
xlink:href="http://docs.openstack.org/user-guide-admin/content/"
><citetitle>OpenStack Admin User
Guide</citetitle></link>.</para>
<section xml:id="cli_clients_install">
<title>Install the clients</title>
<para>Use <command>pip</command> to install the OpenStack
clients on a Mac OS X or Linux system. It is easy and
ensures that you get the latest version of the client from
the <link xlink:href="http://pypi.python.org/pypi">Python
Package Index</link>. Also, <command>pip</command>
lets you update or remove a package. After you install the
clients, you must source an <filename
xmlns:raxm="http://docs.rackspace.com/api/metadata"
>openrc</filename> file to set required environment
variables before you can request OpenStack services
through the clients or the APIs. For complete information
about the OpenStack clients including how to source the
<filename>openrc</filename> file, see <link
xlink:href="http://docs.openstack.org/user-guide/content/"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:html="http://www.w3.org/1999/xhtml"
><citetitle>OpenStack End User
Guide</citetitle></link> and <link
xlink:href="http://docs.openstack.org/user-guide-admin/content/"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:html="http://www.w3.org/1999/xhtml"
><citetitle>OpenStack Admin User
Guide</citetitle></link>.</para>
<para>You must install each client separately.</para>
<para>Run the following command to install or update a client
package:</para>
<screen><?db-font-size 70%?><prompt>$</prompt> <userinput>sudo pip install [--upgrade] python-<replaceable>PROJECT</replaceable>client</userinput></screen>
<para>Where <replaceable>PROJECT</replaceable> is the project
name.</para>
<para>For example, to install the nova client, run the
following command:</para>
<screen><?db-font-size 70%?><prompt>$</prompt> <userinput>sudo pip install python-novaclient</userinput></screen>
<para>To update the nova client, run the following
command:</para>
<screen><?db-font-size 70%?><prompt>$</prompt> <userinput>sudo pip install --upgrade python-novaclient</userinput></screen>
<para>To remove the nova client, run the following
command:</para>
<screen><?db-font-size 70%?><prompt>$</prompt> <userinput>sudo pip uninstall python-novaclient</userinput></screen>
<para>Before you can issue client commands, you must download
and source the <filename>openrc</filename> file to set
environment variables.</para>
</section>
<section xml:id="list-images">
<title>Launch an instance</title>
<para>To launch instances, you must choose a name, an image,
and a flavor for your instance. </para>
<para>To list available images, call the Compute API through
the nova client, as follows:</para>
<screen><?db-font-size 70%?><prompt>$</prompt> <userinput>nova image-list</userinput></screen>
<screen><?db-font-size 60%?><computeroutput>+--------------------------------------+---------------------------------+--------+--------+
| ID | Name | Status | Server |
+--------------------------------------+---------------------------------+--------+--------+
| 949c80c8-b4ac-4315-844e-69f9bef39ed1 | cirros-0.3.1-x86_64-uec | ACTIVE | |
| 2d96f33d-ff66-4cac-b377-820cdf51204a | cirros-0.3.1-x86_64-uec-kernel | ACTIVE | |
| eda9e5cb-4c8c-4e88-b580-7fac80ad8e78 | cirros-0.3.1-x86_64-uec-ramdisk | ACTIVE | |
+--------------------------------------+---------------------------------+--------+--------+</computeroutput></screen>
<para>To list flavors, run the following command:</para>
<screen><?db-font-size 70%?><prompt>$</prompt> <userinput>nova flavor-list</userinput></screen>
<screen><?db-font-size 60%?><computeroutput>+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1 | m1.tiny | 512 | 0 | 0 | | 1 | 1.0 | True |
| 2 | m1.small | 2048 | 20 | 0 | | 1 | 1.0 | True |
| 3 | m1.medium | 4096 | 40 | 0 | | 2 | 1.0 | True |
| 4 | m1.large | 8192 | 80 | 0 | | 4 | 1.0 | True |
| 42 | m1.nano | 64 | 0 | 0 | | 1 | 1.0 | True |
| 5 | m1.xlarge | 16384 | 160 | 0 | | 8 | 1.0 | True |
| 84 | m1.micro | 128 | 0 | 0 | | 1 | 1.0 | True |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+</computeroutput> </screen>
<para>To launch an instance, note the IDs of your desired
image and flavor. </para>
<para>To launch an instance named
<literal>my_instance</literal>, run the <command>nova
boot</command> command with the image and flavor IDs
and the server name, as follows:</para>
<screen><?db-font-size 70%?><prompt>$</prompt> <userinput>nova boot --image 949c80c8-b4ac-4315-844e-69f9bef39ed1 --flavor 2 my_instance</userinput></screen>
<screen><?db-font-size 60%?><computeroutput>+-------------------------------------+--------------------------------------+
| Property | Value |
+-------------------------------------+--------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | nova |
| OS-EXT-SRV-ATTR:host | None |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None |
| OS-EXT-SRV-ATTR:instance_name | instance-00000001 |
| OS-EXT-STS:power_state | 0 |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| accessIPv4 | |
| accessIPv6 | |
| adminPass | XysUgJRnkB2y |
| config_drive | |
| created | 2013-11-07T17:34:16Z |
| flavor | m1.small |
| hostId | |
| id | 66129319-1f1d-420d-a226-bf9fc5ea0138 |
| image | cirros-0.3.1-x86_64-uec |
| key_name | None |
| metadata | {} |
| name | my_instance |
| progress | 0 |
| security_groups | [{u'name': u'default'}] |
| status | BUILD |
| tenant_id | 604bbe45ac7143a79e14f3158df67091 |
| updated | 2013-11-07T17:34:16Z |
| user_id | 3273a50d6cfb4a2ebc75e83cb86e1554 |
+-------------------------------------+--------------------------------------+</computeroutput></screen>
<para>Use the <command>nova list</command> command to view
your server:</para>
<screen><?db-font-size 70%?><prompt>$</prompt> <userinput>nova list</userinput></screen>
<screen><?db-font-size 60%?><computeroutput>+--------------------------------------+-------------+--------+------------+-------------+------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+-------------+--------+------------+-------------+------------------+
| 66129319-1f1d-420d-a226-bf9fc5ea0138 | my_instance | ACTIVE | None | Running | private=10.0.0.2 |
+--------------------------------------+-------------+--------+------------+-------------+------------------+</computeroutput></screen>
<para>To view details for a specified server, use the
<command>nova show</command> command. Include the ID
of the server:</para>
<screen><?db-font-size 70%?><prompt>$</prompt> <userinput>nova show 66129319-1f1d-420d-a226-bf9fc5ea0138</userinput></screen>
<screen><?db-font-size 60%?><computeroutput>+-------------------------------------+----------------------------------------------------------------+
| Property | Value |
+-------------------------------------+----------------------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | nova |
| OS-EXT-SRV-ATTR:host | devstack-grizzly |
| OS-EXT-SRV-ATTR:hypervisor_hostname | devstack-grizzly |
| OS-EXT-SRV-ATTR:instance_name | instance-00000001 |
| OS-EXT-STS:power_state | 1 |
| OS-EXT-STS:task_state | None |
| OS-EXT-STS:vm_state | active |
| accessIPv4 | |
| accessIPv6 | |
| config_drive | |
| created | 2013-11-07T17:34:16Z |
| flavor | m1.small (2) |
| hostId | d57e6f9f7885c615794b4d5a87103509620b6a7f567f7e7bd57e97a2 |
| id | 66129319-1f1d-420d-a226-bf9fc5ea0138 |
| image | cirros-0.3.1-x86_64-uec (949c80c8-b4ac-4315-844e-69f9bef39ed1) |
| key_name | None |
| metadata | {} |
| name | my_instance |
| private network | 10.0.0.2 |
| progress | 0 |
| security_groups | [{u'name': u'default'}] |
| status | ACTIVE |
| tenant_id | 604bbe45ac7143a79e14f3158df67091 |
| updated | 2013-11-07T17:34:32Z |
| user_id | 3273a50d6cfb4a2ebc75e83cb86e1554 |
+-------------------------------------+----------------------------------------------------------------+</computeroutput></screen>
</section>
</section>

View File

@ -0,0 +1,52 @@
{
"endpoints":[
{
"adminurl":"http://166.78.21.23:3333",
"service_id":"95ce5af0aab747e497925a5be1d88b6b",
"region":"RegionOne",
"publicurl":"http://166.78.21.23:3333",
"id":"406cae0574614d829adcbdcf16b4949b",
"internalurl":"http://166.78.21.23:3333"
},
{
"adminurl":"http://166.78.21.23:8773/services/Admin",
"service_id":"5f1f74decf1f4478a962bcc64fc085bf",
"region":"RegionOne",
"publicurl":"http://166.78.21.23:8773/services/Cloud",
"id":"14c4ae919d4045b78154744f8de08bc8",
"internalurl":"http://166.78.21.23:8773/services/Cloud"
},
{
"adminurl":"http://166.78.21.23:8776/v1/$(tenant_id)s",
"service_id":"1d95b26ad4744e6bb0010f3755655986",
"region":"RegionOne",
"publicurl":"http://166.78.21.23:8776/v1/$(tenant_id)s",
"id":"c2c8807f17f544f2a4e813adce7997a4",
"internalurl":"http://166.78.21.23:8776/v1/$(tenant_id)s"
},
{
"adminurl":"http://166.78.21.23:35357/v2.0",
"service_id":"f7c3f51731df49cf876c816b96dba615",
"region":"RegionOne",
"publicurl":"http://166.78.21.23:5000/v2.0",
"id":"f872f18d21ac4a57ae6337bf7c3b4ff0",
"internalurl":"http://166.78.21.23:5000/v2.0"
},
{
"adminurl":"http://166.78.21.23:9292",
"service_id":"675b9a6b5d9140d794f0ca72414ed688",
"region":"RegionOne",
"publicurl":"http://166.78.21.23:9292",
"id":"9883108c61af480c8715448086ec59b0",
"internalurl":"http://166.78.21.23:9292"
},
{
"internalurl":"http://166.78.21.23:8774/v2/$(tenant_id)s",
"adminurl":"http://166.78.21.23:8774/v2/$(tenant_id)s",
"service_id":"ea8d30c196904f569645bb5f6558b7dc",
"region":"RegionOne",
"id":"552b1ad2d28a42c6a80f908c6047fc06",
"publicurl":"http://166.78.21.23:8774/v2/$(tenant_id)s"
}
]
}

View File

@ -0,0 +1,132 @@
{
"access":{
"token":{
"issued_at":"2013-11-06T20:06:24.113908",
"expires":"2013-11-07T20:06:24Z",
"id":"{token}",
"tenant":{
"description":null,
"enabled":true,
"id":"604bbe45ac7143a79e14f3158df67091",
"name":"admin"
}
},
"serviceCatalog":[
{
"endpoints":[
{
"adminURL":"http://166.78.21.23:8774/v2/604bbe45ac7143a79e14f3158df67091",
"region":"RegionOne",
"internalURL":"http://166.78.21.23:8774/v2/604bbe45ac7143a79e14f3158df67091",
"id":"9851cb538ce04283b770820acc24e898",
"publicURL":"http://166.78.21.23:8774/v2/604bbe45ac7143a79e14f3158df67091"
}
],
"endpoints_links":[
],
"type":"compute",
"name":"nova"
},
{
"endpoints":[
{
"adminURL":"http://166.78.21.23:3333",
"region":"RegionOne",
"internalURL":"http://166.78.21.23:3333",
"id":"0bee9a113d294dda86fc23ac22dce1e3",
"publicURL":"http://166.78.21.23:3333"
}
],
"endpoints_links":[
],
"type":"s3",
"name":"s3"
},
{
"endpoints":[
{
"adminURL":"http://166.78.21.23:9292",
"region":"RegionOne",
"internalURL":"http://166.78.21.23:9292",
"id":"4b6e9ece7e25479a8f7bb07eb58845af",
"publicURL":"http://166.78.21.23:9292"
}
],
"endpoints_links":[
],
"type":"image",
"name":"glance"
},
{
"endpoints":[
{
"adminURL":"http://166.78.21.23:8776/v1/604bbe45ac7143a79e14f3158df67091",
"region":"RegionOne",
"internalURL":"http://166.78.21.23:8776/v1/604bbe45ac7143a79e14f3158df67091",
"id":"221a2df63537400e929c0ce7184c5d68",
"publicURL":"http://166.78.21.23:8776/v1/604bbe45ac7143a79e14f3158df67091"
}
],
"endpoints_links":[
],
"type":"volume",
"name":"cinder"
},
{
"endpoints":[
{
"adminURL":"http://166.78.21.23:8773/services/Admin",
"region":"RegionOne",
"internalURL":"http://166.78.21.23:8773/services/Cloud",
"id":"356f334fdb7045f7a35b0eebe26fca53",
"publicURL":"http://166.78.21.23:8773/services/Cloud"
}
],
"endpoints_links":[
],
"type":"ec2",
"name":"ec2"
},
{
"endpoints":[
{
"adminURL":"http://166.78.21.23:35357/v2.0",
"region":"RegionOne",
"internalURL":"http://166.78.21.23:5000/v2.0",
"id":"10f3816574c14a5eb3d455b8a72dc9b0",
"publicURL":"http://166.78.21.23:5000/v2.0"
}
],
"endpoints_links":[
],
"type":"identity",
"name":"keystone"
}
],
"user":{
"username":"admin",
"roles_links":[
],
"id":"3273a50d6cfb4a2ebc75e83cb86e1554",
"roles":[
{
"name":"admin"
}
],
"name":"admin"
},
"metadata":{
"is_admin":0,
"roles":[
"b0d525aa42784ee0a3df1730aabdcecd"
]
}
}
}

View File

@ -0,0 +1,16 @@
{
"server": {
"adminPass": "MVk5HPrazHcG",
"id": "5bbcc3c4-1da2-4437-a48a-66f15b1b13f9",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/servers/5bbcc3c4-1da2-4437-a48a-66f15b1b13f9",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/5bbcc3c4-1da2-4437-a48a-66f15b1b13f9",
"rel": "bookmark"
}
]
}
}

View File

@ -0,0 +1,37 @@
{
"tenants_links":[
],
"tenants":[
{
"description":null,
"enabled":true,
"id":"3eddf34c2f814bd5bc50a382f8fba1c6",
"name":"demo"
},
{
"description":null,
"enabled":true,
"id":"604bbe45ac7143a79e14f3158df67091",
"name":"admin"
},
{
"description":null,
"enabled":true,
"id":"78323d3574e6421b98fe5894475c69fe",
"name":"service"
},
{
"description":null,
"enabled":true,
"id":"da73856734d84ec29958b048d8708d82",
"name":"invisible_to_admin"
},
{
"description":null,
"enabled":true,
"id":"ee30a93eaade41acbcf210780dd7a0ba",
"name":"alt_demo"
}
]
}