Akihiro Motoki dd8f157aa7 Reorganize documentation structure
This reorganization is to make it easier to add more contents.
It move the usage of CLI and python binding to separate pages.

Change-Id: I39e0d1d18010dfd1c687c573619a09331f12241a
2015-12-01 15:46:54 +09:00

1.2 KiB

neutronclient Python API

Basic Usage

First create a client instance.

>>> 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.

>>> 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')