[Openstack-operators] Getting help with Python API

Matt Fischer matt at mattfischer.com
Thu Jul 7 02:04:57 UTC 2016


When you make the API calls you're going to get back a list python objects
which you need to iterate. I believe some APIs will let you ask for
specific fields only, but this is simple enough:

    keystone = client.Client(username=Username, password=Password,
tenant_name=Tenant,
        auth_url='http://%s:5000/v2.0' % (Ip))
    tenants = keystone.tenants.list()
    tenant_ids = []
    for tenant in tenants:
        tenant_ids.append(tenant.id)

Then you can process the tenant_ids list, of course once you done that
you've lost the context of the object (like the name of the tenant).

For stuff like this the docs are your best bet along with introspecting the
objects using the interactive python shell:

http://docs.openstack.org/developer/python-keystoneclient/

On Wed, Jul 6, 2016 at 12:53 PM, Jared Wilkinson <JWilkinson at ebsco.com>
wrote:

> Hey folks,
>
>
>
> I am in the process of teaching myself Python and I have done a couple of
> free online courses but still have a fairly rudimentary understanding of
> Python, especially when it comes to using the OpenStack SDK. I was hoping
> you guys could point me to a mailing list for getting help with using the
> Python API calls in custom scripts. Specifically, something as simple as,
> return a list of all the tenant IDs (only) and push that send that to nova
> quota show and return just the CPU, memory, and storage metrics.
>
>
>
> I can get the list of tenants from Keystone, but I can’t get it to just
> send me the list of IDs (we are using v2 of identity). I have read the
> documentation, but nothing there seems to help (or I am not quite strong
> enough in my Python skills to understand it) for this specific instance.
>
>
>
> Any direction would be appreciated.
>
>
> Thanks,
>
> Jared
>
>
>
> *Jared Wilkinson* | Senior Infrastructure Engineer – Team Lead
>
> jwilkinson at ebsco.com | (W) 205/981-4018 | (M) 205/259-9802
>
> 5724 US Highway 280 East, Birmingham, AL 35242, USA
>
> _______________________________________________
> OpenStack-operators mailing list
> OpenStack-operators at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-operators
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-operators/attachments/20160706/7cf83a31/attachment.html>


More information about the OpenStack-operators mailing list