Add document for using quantum client by python or cli invocation.
After this patch, we should see output at http://docs.openstack.org/developer/python-quantumclient/. Change-Id: I908c0d0e7f80a6eb73e97ee30eaab1bfbfec1e61
This commit is contained in:
parent
f0a9235586
commit
2a45b707bd
@ -1,17 +1,40 @@
|
||||
Python bindings to the OpenStack Network API
|
||||
============================================
|
||||
|
||||
This is a client for OpenStack Network API. Contents:
|
||||
In order to use the python quantum client directly, you must first obtain an auth token and identify which endpoint you wish to speak to. Once you have done so, you can use the API like so::
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
>>> from quantumclient.quantum import client
|
||||
>>> quantum = client.Client('2.0', endpoint_url=OS_URL, token=OS_TOKEN)
|
||||
>>> network = {'name': 'mynetwork', 'admin_state_up': True}
|
||||
>>> quantum.create_network({'network':network})
|
||||
>>> networks = quantum.list_networks(name='mynetwork')
|
||||
>>> print networks
|
||||
>>> quantum.delete_network(name='mynetwork')
|
||||
|
||||
api/autoindex
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
Command-line Tool
|
||||
=================
|
||||
In order to use the CLI, you must provide your OpenStack username, password, tenant, and auth endpoint. Use the corresponding configuration options (``--os-username``, ``--os-password``, ``--os-tenant-name``, and ``--os-auth-url``) or set them in environment variables::
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
export OS_USERNAME=user
|
||||
export OS_PASSWORD=pass
|
||||
export OS_TENANT_NAME=tenant
|
||||
export OS_AUTH_URL=http://auth.example.com:5000/v2.0
|
||||
|
||||
The command line tool will attempt to reauthenticate using your provided credentials for every request. You can override this behavior by manually supplying an auth token using ``--os-url`` and ``--os-auth-token``. You can alternatively set these environment variables::
|
||||
|
||||
export OS_URL=http://quantum.example.org:9696/
|
||||
export OS_TOKEN=3bcc3d3a03f44e3d8377f9247b0ad155
|
||||
|
||||
If quantum server does not require authentication, besides these two arguments or environment variables (We can use any value as token.), we need manually supply ``--os-auth-strategy`` or set the environment variable::
|
||||
|
||||
export OS_AUTH_STRATEGY=noauth
|
||||
|
||||
Once you've configured your authentication parameters, you can run ``quantum -h`` to see a complete listing of available commands.
|
||||
|
||||
Release Notes
|
||||
=============
|
||||
|
||||
2.0
|
||||
-----
|
||||
* support Quantum API 2.0
|
||||
|
@ -26,7 +26,7 @@ API_VERSIONS = {
|
||||
|
||||
|
||||
def make_client(instance):
|
||||
"""Returns an identity service client.
|
||||
"""Returns an quantum client.
|
||||
"""
|
||||
quantum_client = utils.get_client_class(
|
||||
API_NAME,
|
||||
@ -49,3 +49,15 @@ def make_client(instance):
|
||||
else:
|
||||
raise exceptions.UnsupportedVersion("API version %s is not supported" %
|
||||
instance._api_version[API_NAME])
|
||||
|
||||
|
||||
def Client(api_version, *args, **kwargs):
|
||||
"""Return an quantum client.
|
||||
@param api_version: only 2.0 is supported now
|
||||
"""
|
||||
quantum_client = utils.get_client_class(
|
||||
API_NAME,
|
||||
api_version,
|
||||
API_VERSIONS,
|
||||
)
|
||||
return quantum_client(*args, **kwargs)
|
||||
|
Loading…
x
Reference in New Issue
Block a user