2011-02-26 05:04:40 -04:00
|
|
|
The :mod:`novaclient` Python API
|
2011-01-25 14:01:22 -06:00
|
|
|
==================================
|
|
|
|
|
2011-02-26 05:04:40 -04:00
|
|
|
.. module:: novaclient
|
2011-02-08 09:27:22 -04:00
|
|
|
:synopsis: A client for the OpenStack Nova API.
|
2011-08-08 13:20:44 -07:00
|
|
|
|
2011-02-26 05:04:40 -04:00
|
|
|
.. currentmodule:: novaclient
|
2011-01-25 14:01:22 -06:00
|
|
|
|
|
|
|
Usage
|
|
|
|
-----
|
|
|
|
|
2013-12-16 14:07:24 +08:00
|
|
|
First create a client instance with your credentials::
|
2011-01-25 14:01:22 -06:00
|
|
|
|
2013-12-16 14:07:24 +08:00
|
|
|
>>> from novaclient.client import Client
|
|
|
|
>>> nova = Client(VERSION, USERNAME, PASSWORD, PROJECT_ID, AUTH_URL)
|
2011-01-25 14:01:22 -06:00
|
|
|
|
2013-12-16 14:07:24 +08:00
|
|
|
Here ``VERSION`` can be: ``1.1``, ``2`` and ``3``.
|
2011-01-25 14:01:22 -06:00
|
|
|
|
2014-07-01 16:36:46 +01:00
|
|
|
Alternatively, you can create a client instance using the keystoneclient
|
|
|
|
session API::
|
|
|
|
|
|
|
|
>>> from keystoneclient.auth.identity import v2
|
|
|
|
>>> from keystoneclient import session
|
|
|
|
>>> from novaclient.client import Client
|
|
|
|
>>> auth = v2.Password(auth_url=AUTH_URL,
|
|
|
|
username=USERNAME,
|
|
|
|
password=PASSWORD,
|
|
|
|
tenant_name=PROJECT_ID)
|
|
|
|
>>> sess = session.Session(auth=auth)
|
|
|
|
>>> nova = client.Client(VERSION, session=sess)
|
|
|
|
|
|
|
|
For more information on this keystoneclient API, see `Using Sessions`_.
|
|
|
|
|
|
|
|
.. _Using Sessions: http://docs.openstack.org/developer/python-keystoneclient/using-sessions.html
|
|
|
|
|
2013-12-16 14:07:24 +08:00
|
|
|
Then call methods on its managers::
|
2011-01-25 14:01:22 -06:00
|
|
|
|
2011-02-08 09:27:22 -04:00
|
|
|
>>> nova.servers.list()
|
2011-01-25 14:01:22 -06:00
|
|
|
[<Server: buildslave-ubuntu-9.10>]
|
|
|
|
|
2011-02-08 09:27:22 -04:00
|
|
|
>>> nova.flavors.list()
|
2011-01-25 14:01:22 -06:00
|
|
|
[<Flavor: 256 server>,
|
|
|
|
<Flavor: 512 server>,
|
|
|
|
<Flavor: 1GB server>,
|
|
|
|
<Flavor: 2GB server>,
|
|
|
|
<Flavor: 4GB server>,
|
|
|
|
<Flavor: 8GB server>,
|
|
|
|
<Flavor: 15.5GB server>]
|
|
|
|
|
2011-02-08 09:27:22 -04:00
|
|
|
>>> fl = nova.flavors.find(ram=512)
|
|
|
|
>>> nova.servers.create("my-server", flavor=fl)
|
2011-01-25 14:01:22 -06:00
|
|
|
<Server: my-server>
|
|
|
|
|
2013-12-16 14:07:24 +08:00
|
|
|
Reference
|
|
|
|
---------
|
|
|
|
|
2011-01-25 14:01:22 -06:00
|
|
|
For more information, see the reference:
|
|
|
|
|
|
|
|
.. toctree::
|
|
|
|
:maxdepth: 2
|
2011-08-08 13:20:44 -07:00
|
|
|
|
2011-02-08 09:27:22 -04:00
|
|
|
ref/index
|
2013-12-18 16:04:58 +08:00
|
|
|
ref/v1_1/index
|
2013-12-18 16:29:50 +08:00
|
|
|
ref/v3/index
|