2011-02-08 08:54:34 -04:00
|
|
|
Python bindings to the OpenStack Nova API
|
2011-01-25 14:01:22 -06:00
|
|
|
==================================================
|
|
|
|
|
2011-02-08 08:54:34 -04:00
|
|
|
This is a client for the OpenStack Nova API. There's a Python API (the
|
2011-02-26 05:04:40 -04:00
|
|
|
``novaclient`` module), and a command-line script (``nova``). Each
|
2011-02-08 08:54:34 -04:00
|
|
|
implements 100% of the OpenStack Nova API.
|
2011-01-25 14:01:22 -06:00
|
|
|
|
2011-02-08 08:54:34 -04:00
|
|
|
[PENDING] `Full documentation is available`__.
|
2011-01-25 14:01:22 -06:00
|
|
|
|
2011-02-26 05:04:40 -04:00
|
|
|
__ http://packages.python.org/python-novaclient/
|
2011-01-25 14:01:22 -06:00
|
|
|
|
2011-12-01 22:13:07 -05:00
|
|
|
You'll also probably want to read `OpenStack Compute Developer Guide API`__ --
|
|
|
|
the first bit, at least -- to get an idea of the concepts. Rackspace is doing
|
|
|
|
the cloud hosting thing a bit differently from Amazon, and if you get the
|
|
|
|
concepts this library should make more sense.
|
2011-01-25 14:01:22 -06:00
|
|
|
|
2011-12-01 22:13:07 -05:00
|
|
|
__ http://docs.openstack.org/api/
|
2011-01-25 14:01:22 -06:00
|
|
|
|
2011-12-01 22:13:07 -05:00
|
|
|
The project is hosted on `Launchpad`_, where bugs can be filed. The code is
|
|
|
|
hosted on `Github`_. Patches must be submitted using `Gerrit`_, *not* Github
|
|
|
|
pull requests.
|
2011-01-25 14:01:22 -06:00
|
|
|
|
2011-12-01 22:13:07 -05:00
|
|
|
.. _Github: https://github.com/openstack/python-novaclient
|
|
|
|
.. _Launchpad: https://launchpad.net/python-novaclient
|
|
|
|
.. _Gerrit: http://wiki.openstack.org/GerritWorkflow
|
2011-02-08 08:54:34 -04:00
|
|
|
|
|
|
|
This code a fork of `Jacobian's python-cloudservers`__ If you need API support
|
2011-12-15 11:59:06 +01:00
|
|
|
for the Rackspace API solely or the BSD license, you should use that repository.
|
2011-02-26 05:04:40 -04:00
|
|
|
python-client is licensed under the Apache License like the rest of OpenStack.
|
2011-02-08 08:54:34 -04:00
|
|
|
|
2011-01-25 14:01:22 -06:00
|
|
|
__ http://github.com/jacobian/python-cloudservers
|
|
|
|
|
|
|
|
.. contents:: Contents:
|
|
|
|
:local:
|
|
|
|
|
|
|
|
Command-line API
|
|
|
|
----------------
|
|
|
|
|
2011-02-24 13:54:10 -04:00
|
|
|
Installing this package gets you a shell command, ``nova``, that you
|
2011-01-25 14:01:22 -06:00
|
|
|
can use to interact with any Rackspace compatible API (including OpenStack).
|
|
|
|
|
2011-02-08 08:54:34 -04:00
|
|
|
You'll need to provide your OpenStack username and API key. You can do this
|
2011-12-01 22:13:07 -05:00
|
|
|
with the ``--username``, ``--password`` and ``--projectid`` params, but it's
|
|
|
|
easier to just set them as environment variables::
|
2011-01-25 14:01:22 -06:00
|
|
|
|
2011-02-14 14:27:21 -08:00
|
|
|
export NOVA_USERNAME=openstack
|
2011-11-09 07:10:46 -08:00
|
|
|
export NOVA_PASSWORD=yadayada
|
2011-06-13 16:16:58 +04:00
|
|
|
export NOVA_PROJECT_ID=myproject
|
2011-01-25 14:01:22 -06:00
|
|
|
|
2011-08-07 14:00:23 -05:00
|
|
|
You will also need to define the authentication url with ``--url`` and the
|
2011-08-08 13:20:44 -07:00
|
|
|
version of the API with ``--version``. Or set them as an environment
|
2011-08-07 14:00:23 -05:00
|
|
|
variables as well::
|
2011-01-25 14:01:22 -06:00
|
|
|
|
2011-08-12 23:47:25 -07:00
|
|
|
export NOVA_URL=http://example.com:8774/v1.1/
|
|
|
|
export NOVA_VERSION=1.1
|
|
|
|
|
|
|
|
If you are using Keystone, you need to set the NOVA_URL to the keystone
|
|
|
|
endpoint::
|
|
|
|
|
|
|
|
export NOVA_URL=http://example.com:5000/v2.0/
|
2011-08-08 13:20:44 -07:00
|
|
|
|
2011-09-07 13:30:20 -07:00
|
|
|
Since Keystone can return multiple regions in the Service Catalog, you
|
2011-10-19 10:54:27 -07:00
|
|
|
can specify the one you want with ``--region_name`` (or
|
2011-09-07 13:30:20 -07:00
|
|
|
``export NOVA_REGION_NAME``). It defaults to the first in the list returned.
|
2011-09-02 12:07:18 -07:00
|
|
|
|
2011-08-08 13:20:44 -07:00
|
|
|
You'll find complete documentation on the shell by running
|
2011-02-24 13:54:10 -04:00
|
|
|
``nova help``::
|
2011-08-07 14:00:23 -05:00
|
|
|
|
2011-11-09 07:18:22 -08:00
|
|
|
usage: nova [--username USERNAME] [--password PASSWORD] [--projectid PROJECTID]
|
2011-09-07 13:30:20 -07:00
|
|
|
[--url URL] [--version VERSION] [--region_name NAME]
|
2011-11-09 07:10:46 -08:00
|
|
|
[--endpoint_name NAME]
|
2011-08-07 14:00:23 -05:00
|
|
|
<subcommand> ...
|
2011-01-25 14:01:22 -06:00
|
|
|
|
2011-02-08 08:54:34 -04:00
|
|
|
Command-line interface to the OpenStack Nova API.
|
2011-01-25 14:01:22 -06:00
|
|
|
|
|
|
|
Positional arguments:
|
|
|
|
<subcommand>
|
2011-07-08 10:57:27 -07:00
|
|
|
add-fixed-ip Add a new fixed IP address to a servers network.
|
2011-10-11 04:07:08 +00:00
|
|
|
add-floating-ip Add a floating IP address to a server.
|
2012-01-13 13:36:01 +00:00
|
|
|
aggregate-add-host Add the host to the specified aggregate
|
|
|
|
aggregate-create Create a new aggregate with the specified details
|
|
|
|
aggregate-delete Delete the aggregate by its id
|
|
|
|
aggregate-details Show details of the specified aggregate
|
|
|
|
aggregate-list Print a list of all aggregates
|
|
|
|
aggregate-remove-host
|
|
|
|
Remove the specified host from the specfied
|
|
|
|
aggregate
|
|
|
|
aggregate-set-metadata
|
|
|
|
Update the metadata associated with the aggregate
|
|
|
|
aggregate-update Update the aggregate's name and optionally
|
2012-02-14 22:04:14 +00:00
|
|
|
availability zone
|
2011-08-05 10:38:29 -05:00
|
|
|
backup Backup a server.
|
2011-01-25 14:01:22 -06:00
|
|
|
backup-schedule Show or edit the backup schedule for a server.
|
|
|
|
backup-schedule-delete
|
|
|
|
Delete the backup schedule for a server.
|
|
|
|
boot Boot a new server.
|
|
|
|
delete Immediately shut down and delete a server.
|
2012-01-19 19:57:04 -05:00
|
|
|
flavor-create Create a new flavor
|
|
|
|
flavor-delete Delete a specific flavor
|
2011-01-25 14:01:22 -06:00
|
|
|
flavor-list Print a list of available 'flavors' (sizes of
|
|
|
|
servers).
|
2011-10-11 04:07:08 +00:00
|
|
|
floating-ip-create Allocate a floating IP to the current tenant.
|
|
|
|
floating-ip-delete De-allocate a floating IP from the current tenant.
|
|
|
|
floating-ip-list List allocated floating IPs for the current tenant.
|
2012-01-09 14:49:12 -08:00
|
|
|
floating-ip-pool-list
|
|
|
|
List all floating ip pools.
|
2011-12-29 00:35:29 +00:00
|
|
|
get-vnc-console Get a vnc console for a server
|
2011-01-25 14:01:22 -06:00
|
|
|
help Display help about this program or one of its
|
|
|
|
subcommands.
|
2012-02-14 22:56:42 +00:00
|
|
|
host-update Update the host status or maintenance mode
|
|
|
|
host-action Perform a power action on the host
|
2011-01-25 14:01:22 -06:00
|
|
|
image-create Create a new image by taking a snapshot of a running
|
|
|
|
server.
|
|
|
|
image-delete Delete an image.
|
|
|
|
image-list Print a list of available images to boot from.
|
|
|
|
ip-share Share an IP address from the given IP group onto a
|
|
|
|
server.
|
|
|
|
ip-unshare Stop sharing an given address with a server.
|
|
|
|
ipgroup-create Create a new IP group.
|
|
|
|
ipgroup-delete Delete an IP group.
|
|
|
|
ipgroup-list Show IP groups.
|
|
|
|
ipgroup-show Show details about a particular IP group.
|
2011-10-05 16:25:31 +04:00
|
|
|
keypair-add Create a new key pair for use with instances
|
|
|
|
keypair-delete Delete keypair by its id
|
|
|
|
keypair-list Show a list of keypairs for a user
|
2011-01-25 14:01:22 -06:00
|
|
|
list List active servers.
|
2012-03-13 23:18:41 -07:00
|
|
|
lock Lock a server
|
2012-02-14 22:04:14 +00:00
|
|
|
migrate Migrate a server to a new host.
|
2011-01-25 14:01:22 -06:00
|
|
|
reboot Reboot a server.
|
|
|
|
rebuild Shutdown, re-image, and re-boot a server.
|
2011-07-08 10:57:27 -07:00
|
|
|
remove-fixed-ip Remove an IP address from a server.
|
2011-10-11 04:07:08 +00:00
|
|
|
remove-floating-ip Remove a floating IP address from a server.
|
2011-01-25 14:01:22 -06:00
|
|
|
rename Rename a server.
|
|
|
|
rescue Rescue a server.
|
|
|
|
resize Resize a server.
|
|
|
|
resize-confirm Confirm a previous resize.
|
|
|
|
resize-revert Revert a previous resize (and return to the previous
|
|
|
|
VM).
|
|
|
|
root-password Change the root password for a server.
|
2011-10-11 22:10:23 +00:00
|
|
|
secgroup-add-group-rule
|
2011-10-11 22:30:48 +00:00
|
|
|
Add a source group rule to a security group.
|
2011-10-11 07:48:55 +00:00
|
|
|
secgroup-add-rule Add a rule to a security group.
|
|
|
|
secgroup-create Create a new security group.
|
|
|
|
secgroup-delete Delete a security group.
|
2011-10-11 22:10:23 +00:00
|
|
|
secgroup-delete-group-rule
|
|
|
|
Delete a source group rule from a security group.
|
2011-10-11 07:48:55 +00:00
|
|
|
secgroup-delete-rule
|
|
|
|
Delete a rule from a security group.
|
|
|
|
secgroup-list List security groups for the curent tenant.
|
|
|
|
secgroup-list-rules List rules for a security group.
|
2011-01-25 14:01:22 -06:00
|
|
|
show Show details about the given server.
|
2011-10-19 10:54:27 -07:00
|
|
|
suspend Suspend a server.
|
2012-03-13 23:18:41 -07:00
|
|
|
unlock Unlock a server.
|
2011-10-19 10:54:27 -07:00
|
|
|
unpause Unpause a server.
|
2011-01-25 14:01:22 -06:00
|
|
|
unrescue Unrescue a server.
|
2012-01-22 18:56:39 -05:00
|
|
|
usage-list List usage data for all tenants
|
2011-09-29 08:09:50 -07:00
|
|
|
volume-attach Attach a volume to a server.
|
|
|
|
volume-create Add a new volume.
|
|
|
|
volume-delete Remove a volume.
|
|
|
|
volume-detach Detach a volume from a server.
|
|
|
|
volume-list List all the volumes.
|
|
|
|
volume-show Show details about a volume.
|
2011-11-09 10:36:16 -08:00
|
|
|
volume-snapshot-create
|
|
|
|
Add a new snapshot.
|
|
|
|
volume-snapshot-delete
|
|
|
|
Remove a snapshot.
|
|
|
|
volume-snapshot-list
|
|
|
|
List all the snapshots.
|
|
|
|
volume-snapshot-show
|
|
|
|
Show details about a snapshot.
|
2012-01-20 15:08:53 -08:00
|
|
|
x509-create-cert Create x509 cert for a user in tenant
|
|
|
|
x509-get-root-cert Fetches the x509 root cert.
|
2011-01-25 14:01:22 -06:00
|
|
|
|
2011-10-05 16:25:31 +04:00
|
|
|
|
2011-01-25 14:01:22 -06:00
|
|
|
Optional arguments:
|
2011-02-14 14:27:21 -08:00
|
|
|
--username USERNAME Defaults to env[NOVA_USERNAME].
|
2011-11-09 07:18:22 -08:00
|
|
|
--password PASSWORD Defaults to env[NOVA_PASSWORD].
|
|
|
|
--projectid PROJECTID Defaults to env[NOVA_PROJECT_ID].
|
2011-02-14 14:27:21 -08:00
|
|
|
--url AUTH_URL Defaults to env[NOVA_URL] or
|
2011-01-25 14:01:22 -06:00
|
|
|
https://auth.api.rackspacecloud.com/v1.0
|
2011-08-07 14:00:23 -05:00
|
|
|
if undefined.
|
2011-12-15 23:10:59 +00:00
|
|
|
--version VERSION Accepts 1.1, defaults to env[NOVA_VERSION].
|
2011-09-07 13:30:20 -07:00
|
|
|
--region_name NAME The region name in the Keystone Service Catalog
|
|
|
|
to use after authentication. Defaults to first
|
|
|
|
in the list returned.
|
2011-01-25 14:01:22 -06:00
|
|
|
|
2011-02-24 13:54:10 -04:00
|
|
|
See "nova help COMMAND" for help on a specific command.
|
2011-08-08 13:20:44 -07:00
|
|
|
|
2011-01-25 14:01:22 -06:00
|
|
|
Python API
|
|
|
|
----------
|
|
|
|
|
2011-02-08 08:54:34 -04:00
|
|
|
[PENDING] There's also a `complete Python API`__.
|
2011-01-25 14:01:22 -06:00
|
|
|
|
2011-02-26 05:04:40 -04:00
|
|
|
__ http://packages.python.org/python-novaclient/
|
2011-01-25 14:01:22 -06:00
|
|
|
|
|
|
|
By way of a quick-start::
|
|
|
|
|
2011-02-26 05:04:40 -04:00
|
|
|
>>> import novaclient
|
2011-11-09 07:10:46 -08:00
|
|
|
>>> nt = novaclient.OpenStack(USERNAME, PASSWORD, PROJECT_ID [, AUTH_URL])
|
2011-02-08 08:54:34 -04:00
|
|
|
>>> nt.flavors.list()
|
2011-01-25 14:01:22 -06:00
|
|
|
[...]
|
2011-02-08 08:54:34 -04:00
|
|
|
>>> nt.servers.list()
|
2011-01-25 14:01:22 -06:00
|
|
|
[...]
|
2011-02-08 08:54:34 -04:00
|
|
|
>>> s = nt.servers.create(image=2, flavor=1, name='myserver')
|
2011-08-08 13:20:44 -07:00
|
|
|
|
2011-01-25 14:01:22 -06:00
|
|
|
... time passes ...
|
2011-08-08 13:20:44 -07:00
|
|
|
|
2011-01-25 14:01:22 -06:00
|
|
|
>>> s.reboot()
|
2011-08-08 13:20:44 -07:00
|
|
|
|
2011-01-25 14:01:22 -06:00
|
|
|
... time passes ...
|
2011-08-08 13:20:44 -07:00
|
|
|
|
2011-01-25 14:01:22 -06:00
|
|
|
>>> s.delete()
|
|
|
|
|
2011-08-10 16:16:38 -07:00
|
|
|
Quick-start using keystone::
|
|
|
|
|
|
|
|
# use v2.0 auth with http://example.com:5000/v2.0/")
|
|
|
|
>>> from novaclient.v1_1 import client
|
|
|
|
>>> nt = client.Client(USER, PASS, TENANT, AUTH_URL)
|
|
|
|
>>> nt.flavors.list()
|
|
|
|
[...]
|
|
|
|
>>> nt.servers.list()
|
|
|
|
[...]
|
|
|
|
>>> nt.keypairs.list()
|
|
|
|
[...]
|
2011-10-19 10:54:27 -07:00
|
|
|
|
2011-01-25 14:01:22 -06:00
|
|
|
What's new?
|
|
|
|
-----------
|
|
|
|
|
2011-02-26 05:04:40 -04:00
|
|
|
[PENDING] See `the release notes <http://packages.python.org/python-novaclient/releases.html>`_.
|