| 1 |
=========================================== |
| 2 |
Python bindings to the OpenStack Magnum API |
| 3 |
=========================================== |
| 4 |
|
| 5 |
This is a client for the OpenStack Magnum API. It includes a Python |
| 6 |
API (the :mod:`magnumclient` module) and a command-line script |
| 7 |
(installed as :program:`magnum`). |
| 8 |
|
| 9 |
Python API |
| 10 |
========== |
| 11 |
|
| 12 |
To use python-magnumclient in a project, create a client instance |
| 13 |
using the keystoneauth session API:: |
| 14 |
|
| 15 |
from keystoneauth1.identity import v3 |
| 16 |
from keystoneauth1 import session |
| 17 |
from keystoneclient.v3 import client |
| 18 |
|
| 19 |
from magnumclient.client import Client |
| 20 |
|
| 21 |
magnum_endpoint = "http://magnum.example.com:9511/v1" |
| 22 |
|
| 23 |
auth = v3.Password(auth_url='http://my.keystone.com:5000/v3', |
| 24 |
username='myuser', |
| 25 |
password='mypassword', |
| 26 |
project_name='myproject', |
| 27 |
user_domain_id='default', |
| 28 |
project_domain_id='default') |
| 29 |
sess = session.Session(auth=auth) |
| 30 |
|
| 31 |
magnum = Client('1', endpoint_override=magnum_endpoint, session=sess) |
| 32 |
magnum.clusters.list() |
| 33 |
|
| 34 |
For more information on keystoneauth API, see `Using Sessions`_. |
| 35 |
|
| 36 |
.. _Using Sessions: https://docs.openstack.org/keystoneauth/latest/using-sessions.html |
| 37 |
|
| 38 |
Command-line tool |
| 39 |
================= |
| 40 |
|
| 41 |
In order to use the CLI, you must provide your OpenStack username, |
| 42 |
password, project name, user domain ID, project domain ID, and auth |
| 43 |
endpoint. Use the corresponding configuration options (--os-username, |
| 44 |
--os-password, --os-project-name, --os-project-domain-id, |
| 45 |
--os-user-domain-id, and --os-auth-url) or set them in environment |
| 46 |
variables:: |
| 47 |
|
| 48 |
export OS_USERNAME=myuser |
| 49 |
export OS_PASSWORD=mypassword |
| 50 |
export OS_PROJECT_NAME=myproject |
| 51 |
export OS_USER_DOMAIN_ID=default |
| 52 |
export OS_PROJECT_DOMAIN_ID=default |
| 53 |
export OS_AUTH_URL=http://my.keystone.com:5000/v3 |
| 54 |
|
| 55 |
From there, all shell commands take the form:: |
| 56 |
|
| 57 |
magnum <command> [arguments...] |
| 58 |
|
| 59 |
Run :program:`magnum help` to see a complete listing of available |
| 60 |
commands. Run :program:`magnum help <command>` to get detailed help |
| 61 |
for that command. |