[Openstack-docs] Fwd: Re: [openstack-dev] [Neutron] Using Python-Neutronclient from Python - docstrings needed?

Andreas Jaeger aj at suse.com
Sun Feb 9 08:30:09 UTC 2014


Rajdeep, let's open a separate thread for this with the documentation team.

Documentation team, have a look at the guide.

I think this complements the SDK chapter we have at:
http://docs.openstack.org/user-guide/content/ch_sdk.html

Can we merge contents here?

Btw. I'm not sure whether using the OpenStack branding on the guide is
really fine. Anybody that can chime in here?

Andreas

-------- Original Message --------
Subject: 	Re: [openstack-dev] [Neutron] Using Python-Neutronclient from
Python - docstrings needed?
Date: 	Sat, 8 Feb 2014 20:10:13 -0800 (PST)
From: 	Rajdeep Dua <dua_rajdeep at yahoo.com>
Reply-To: 	Rajdeep Dua <dua_rajdeep at yahoo.com>, "OpenStack Development
Mailing List \(not for usage questions\)"
<openstack-dev at lists.openstack.org>
To: 	OpenStack Development Mailing List (not for usage questions)
<openstack-dev at lists.openstack.org>



Sean,
We have written a few docs for writing these samples

http://python-api-guide.cfapps.io/content/neutron.html

You can find get the source
here https://github.com/rajdeepd/openstack-samples

Thanks
Rajdeep


On Sunday, February 9, 2014 12:57 AM, "Collins, Sean"
<Sean_Collins2 at cable.comcast.com> wrote:
Hi,

I was writing a small script yesterday to parse a list of IP blocks and
create security groups and rules, by using python-neutronclient.

To be honest, it was very difficult - even though I have actually
written extensions to Python-Neutronclient for the QoS API.

For those that are trying to use the client from inside their code,
they end up getting zero help as to how to actually call any of the
functions, and what parameters they take.


    >>> neutron = client.Client('2.0', auth_url=os.environ['OS_AUTH_URL'],
    ...                            tenant_id=os.environ['OS_TENANT_ID'],
    ...                            username=os.environ['OS_USERNAME'],
    ...                            password=os.environ['OS_PASSWORD'])
    >>> help(neutron)

  |  create_credential = <function with_params>
  |
  |  create_firewall = <function with_params>
  |
  |  create_firewall_policy = <function with_params>
  |
  |  create_firewall_rule = <function with_params>
  |
  |  create_floatingip = <function with_params>
  |
  |  create_health_monitor = <function with_params>
  |
  |  create_ikepolicy = <function with_params>
  |
  |  create_ipsec_site_connection = <function with_params>
  |
  |  create_ipsecpolicy = <function with_params>
  |
  |  create_member = <function with_params>
  |
  |  create_metering_label = <function with_params>


Since there was nothing there, I decided to go check the source of
python-neutronclient and see if there are any examples.

https://github.com/openstack/python-neutronclient/blob/master/doc/source/index.rst

If you read closely enough, you'll find out that the function takes a
dictionary, that looks very similar to the request/response examples
listed in the API documentation. So, I went over and checked it out.

http://docs.openstack.org/api/openstack-network/2.0/content/POST_security-groups-v2.0_createSecGroup_v2.0_security-groups_security-groups-ext.html

So from there, I was able to remember enough that each of these
functions takes a single argument, that is a dictionary, that mimics
the same structure that you see in the API documentation, so from there
it was just some experimentation to get the structure right.

Honestly it wasn't easy to remember all this stuff, since
it had been a couple months since I had worked with
python-neutronclient, and it had been from inside the library itself.

This was my first experience using it "on the outside" and it was pretty
tough - so I'm going to try and look into how we can improve the
docstrings for the client object, to make it a bit easier to figure out.

Thoughts?

-- 
Sean M. Collins
_______________________________________________
OpenStack-dev mailing list
OpenStack-dev at lists.openstack.org <mailto:OpenStack-dev at lists.openstack.org>
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev



-- 
 Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
  SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
   GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
    GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126


-------------- next part --------------
_______________________________________________
OpenStack-dev mailing list
OpenStack-dev at lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev



More information about the Openstack-docs mailing list