diff options
author | Akihiro Motoki <amotoki@gmail.com> | 2019-05-10 10:54:03 +0900 |
---|---|---|
committer | Akihiro Motoki <amotoki@gmail.com> | 2019-05-10 11:00:42 +0900 |
commit | dc10f44128b26e7c964957c5e9c8d00ff91a3c0e (patch) | |
tree | 4f2f8299a01f526f553307b9e9749dc83dad53d6 | |
parent | 209e1801ace8ef68b8061a194a89b28cc72152c7 (diff) | |
download | python-neutronclient-dc10f44128b26e7c964957c5e9c8d00ff91a3c0e.tar.gz |
doc: Remove prompt from python binding examples
The current python binding examples have prompts of python
interactive mode, but these prompts make it difficult to
copy-and-paste the examples. This commit removes them.
Change-Id: Ia5d35fbb585ed0d0d11c8d035196981e9dd46785
-rw-r--r-- | doc/source/reference/index.rst | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/doc/source/reference/index.rst b/doc/source/reference/index.rst index ee47610..5678d65 100644 --- a/doc/source/reference/index.rst +++ b/doc/source/reference/index.rst @@ -33,23 +33,23 @@ information on this keystoneauth API, see `Using Sessions`_. .. code-block:: python - >>> from keystoneauth1 import identity - >>> from keystoneauth1 import session - >>> from neutronclient.v2_0 import client - >>> username='username' - >>> password='password' - >>> project_name='demo' - >>> project_domain_id='default' - >>> user_domain_id='default' - >>> auth_url='http://auth.example.com:5000/v3' - >>> auth = identity.Password(auth_url=auth_url, - ... username=username, - ... password=password, - ... project_name=project_name, - ... project_domain_id=project_domain_id, - ... user_domain_id=user_domain_id) - >>> sess = session.Session(auth=auth) - >>> neutron = client.Client(session=sess) + from keystoneauth1 import identity + from keystoneauth1 import session + from neutronclient.v2_0 import client + username='username' + password='password' + project_name='demo' + project_domain_id='default' + user_domain_id='default' + auth_url='http://auth.example.com:5000/v3' + auth = identity.Password(auth_url=auth_url, + username=username, + password=password, + project_name=project_name, + project_domain_id=project_domain_id, + user_domain_id=user_domain_id) + sess = session.Session(auth=auth) + neutron = client.Client(session=sess) If you are using Identity v2.0 API (DEPRECATED), create an auth plugin using the appropriate parameters and `keystoneauth1.identity` will handle Identity @@ -58,38 +58,38 @@ like the previous example. .. code-block:: python - >>> auth = identity.Password(auth_url=auth_url, - ... username=username, - ... password=password, - ... project_name=project_name) - >>> # create a Session and a Neutronclient + auth = identity.Password(auth_url=auth_url, + username=username, + password=password, + project_name=project_name) + # create a Session and a Neutronclient 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) + 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. .. code-block:: python - >>> from neutronclient.v2_0 import client - >>> neutron = client.Client(endpoint_url='http://192.168.206.130:9696/', - ... token='d3f9226f27774f338019aa2611112ef6') + from neutronclient.v2_0 import client + neutron = client.Client(endpoint_url='http://192.168.206.130:9696/', + token='d3f9226f27774f338019aa2611112ef6') You can get ``X-Openstack-Request-Id`` as ``request_ids`` from the result. .. code-block:: python - >>> network = {'name': 'mynetwork', 'admin_state_up': True} - >>> neutron.create_network({'network':network}) - >>> networks = neutron.list_networks(name='mynetwork') - >>> print networks.request_ids - ['req-978a0160-7ab0-44f0-8a93-08e9a4e785fa'] + network = {'name': 'mynetwork', 'admin_state_up': True} + neutron.create_network({'network':network}) + networks = neutron.list_networks(name='mynetwork') + print networks.request_ids + # -> ['req-978a0160-7ab0-44f0-8a93-08e9a4e785fa'] |