Merge "Reorganize documentation structure"
This commit is contained in:
commit
aec8e8d0b7
@ -1,29 +0,0 @@
|
||||
..
|
||||
Copyright 2015 OpenStack Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
not use this file except in compliance with the License. You may obtain
|
||||
a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
Developer Guide
|
||||
===============
|
||||
|
||||
In the Developer Guide, you will find information on Neutron's Client lower level
|
||||
programming APIs.
|
||||
|
||||
|
||||
Programming HowTos and Tutorials
|
||||
--------------------------------
|
||||
.. toctree::
|
||||
:maxdepth: 3
|
||||
|
||||
client_command_extensions
|
@ -1,59 +1,36 @@
|
||||
Python bindings to the OpenStack Network API
|
||||
============================================
|
||||
===============================================
|
||||
Python bindings to the OpenStack Networking API
|
||||
===============================================
|
||||
|
||||
In order to use the python neutron 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::
|
||||
This is a client for OpenStack Networking API. There is a :doc:`Python API
|
||||
<usage/library>` (the neutronclient module), and a :doc:`command-line script
|
||||
<usage/cli>` (installed as **neutron**). Each implements the entire OpenStack
|
||||
Networking API.
|
||||
|
||||
>>> import logging
|
||||
>>> from neutronclient.neutron import client
|
||||
>>> logging.basicConfig(level=logging.DEBUG)
|
||||
>>> neutron = client.Client('2.0', endpoint_url=OS_URL, token=OS_TOKEN)
|
||||
>>> neutron.format = 'json'
|
||||
>>> network = {'name': 'mynetwork', 'admin_state_up': True}
|
||||
>>> neutron.create_network({'network':network})
|
||||
>>> networks = neutron.list_networks(name='mynetwork')
|
||||
>>> print networks
|
||||
>>> network_id = networks['networks'][0]['id']
|
||||
>>> neutron.delete_network(network_id)
|
||||
Using neturonclient
|
||||
-------------------
|
||||
|
||||
Alternatively, if you have a username and password, authentication is done
|
||||
against the public endpoint. You must also specify a tenant that is associated
|
||||
with the user::
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
>>> from neutronclient.v2_0 import client
|
||||
>>> username='adminUser'
|
||||
>>> password='secretword'
|
||||
>>> tenant_name='openstackDemo'
|
||||
>>> auth_url='http://192.168.206.130:5000/v2.0'
|
||||
>>> neutron = client.Client(username=username, password=password,
|
||||
... tenant_name=tenant_name, auth_url=auth_url)
|
||||
>>>nets = neutron.list_networks()
|
||||
usage/cli
|
||||
usage/library
|
||||
|
||||
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::
|
||||
Developer Guide
|
||||
---------------
|
||||
|
||||
export OS_USERNAME=user
|
||||
export OS_PASSWORD=pass
|
||||
export OS_TENANT_NAME=tenant
|
||||
export OS_AUTH_URL=http://auth.example.com:5000/v2.0
|
||||
In the Developer Guide, you will find information on Neutron’s client
|
||||
lower level programming details or APIs.
|
||||
|
||||
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::
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
export OS_URL=http://neutron.example.org:9696/
|
||||
export OS_TOKEN=3bcc3d3a03f44e3d8377f9247b0ad155
|
||||
devref/client_command_extensions
|
||||
|
||||
If neutron 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 ``neutron -h`` to see a complete listing of available commands.
|
||||
|
||||
|
||||
Developer Docs
|
||||
==============
|
||||
History
|
||||
-------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
devref/index
|
||||
history
|
||||
|
55
doc/source/usage/cli.rst
Normal file
55
doc/source/usage/cli.rst
Normal file
@ -0,0 +1,55 @@
|
||||
======================
|
||||
Command-line Interface
|
||||
======================
|
||||
|
||||
The **neutron** shell utility interacts with OpenStack Networking API from the
|
||||
command-line. It supports the entire features of OpenStack Networking API.
|
||||
|
||||
Basic Usage
|
||||
-----------
|
||||
|
||||
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``), but it is easier to set them in environment variables.
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
export OS_USERNAME=user
|
||||
export OS_PASSWORD=pass
|
||||
export OS_TENANT_NAME=tenant
|
||||
export OS_AUTH_URL=http://auth.example.com:5000/v2.0
|
||||
|
||||
Once you've configured your authentication parameters, you can run **neutron**
|
||||
commands. All commands take the form of:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
neutron <command> [arguments...]
|
||||
|
||||
Run **neutron help** to get a full list of all possible commands, and run
|
||||
**neutron help <command>** to get detailed help for that command.
|
||||
|
||||
Using with keystone token
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The command-line tool will attempt to re-authenticate 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.
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
export OS_URL=http://neutron.example.org:9696/
|
||||
export OS_TOKEN=3bcc3d3a03f44e3d8377f9247b0ad155
|
||||
|
||||
Using noauth mode
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
If neutron 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.
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
export OS_AUTH_STRATEGY=noauth
|
38
doc/source/usage/library.rst
Normal file
38
doc/source/usage/library.rst
Normal file
@ -0,0 +1,38 @@
|
||||
========================
|
||||
neutronclient Python API
|
||||
========================
|
||||
|
||||
Basic Usage
|
||||
-----------
|
||||
|
||||
First create a client instance.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
>>> from neutronclient.v2_0 import client
|
||||
>>> username='adminUser'
|
||||
>>> password='secretword'
|
||||
>>> tenant_name='openstackDemo'
|
||||
>>> auth_url='http://192.168.206.130:5000/v2.0'
|
||||
>>> neutron = client.Client(username=username,
|
||||
... password=password,
|
||||
... tenant_name=tenant_name,
|
||||
... auth_url=auth_url)
|
||||
|
||||
Now you can call various methods on the client instance.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
>>> network = {'name': 'mynetwork', 'admin_state_up': True}
|
||||
>>> neutron.create_network({'network':network})
|
||||
>>> networks = neutron.list_networks(name='mynetwork')
|
||||
>>> print networks
|
||||
>>> network_id = networks['networks'][0]['id']
|
||||
>>> neutron.delete_network(network_id)
|
||||
|
||||
Alternatively, you can create a client instance using an auth token
|
||||
and a service endpoint URL directly.
|
||||
|
||||
>>> from neutronclient.v2_0 import client
|
||||
>>> neutron = client.Client(endpoint_url='http://192.168.206.130:9696/',
|
||||
token='d3f9226f27774f338019aa2611112ef6')
|
Loading…
Reference in New Issue
Block a user