<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Title" content="">
<meta name="Keywords" content="">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"MS 明朝";}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:-webkit-standard;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:Calibri;
color:windowtext;}
span.msoIns
{mso-style-type:export-only;
mso-style-name:"";
text-decoration:underline;
color:teal;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">Thanks. I finally figured it out with the help of someone with a bit more Python knowledge than I have. I wasn’t able to figure out that the list was a list of arrays on my own. I would
try to get the type for each one of the items in the list (which was the list of tenants, ids, etc), but it would return that it was ‘<class 'keystoneclient.v2_0.tenants.Tenant'>’ and I didn’t know what to do with that since I expected something like <type
‘dict’> since that’s what it looked like when I just printed the line. After he pointed me to the fact it was an array (still not sure how to determine that other than just recognizing the output), I was able to pull the id just as you referenced.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">Now on to figure out the new python-openstackclient API so I can use that instead!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><b><span style="font-family:Helvetica;color:#767171">Jared Wilkinson</span></b><span style="font-family:Calibri;color:black"> | Senior Infrastructure Engineer – Team Lead</span><span style="font-size:11.0pt;font-family:-webkit-standard;color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Helvetica;color:#7F7F7F">jwilkinson@ebsco.com | (W) 205/981-4018 | (M) 205/259-9802</span><span style="color:black"><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Helvetica;color:#7F7F7F">5724 US Highway 280 East, Birmingham, AL 35242, USA</span><span style="font-size:11.0pt;font-family:Calibri"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-family:Calibri;color:black">From: </span>
</b><span style="font-family:Calibri;color:black"><tadowguy@gmail.com> on behalf of Matt Fischer <matt@mattfischer.com><br>
<b>Date: </b>Wednesday, July 6, 2016 at 9:04 PM<br>
<b>To: </b>Jared Wilkinson <JWilkinson@ebsco.com><br>
<b>Cc: </b>"openstack-operators@lists.openstack.org" <openstack-operators@lists.openstack.org><br>
<b>Subject: </b>Re: [Openstack-operators] Getting help with Python API<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">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:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> keystone = client.Client(username=Username, password=Password, tenant_name=Tenant,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> auth_url='http://%s:5000/v2.0' % (Ip))<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"> tenants = keystone.tenants.list()<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> tenant_ids = []<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> for tenant in tenants:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> tenant_ids.append(<a href="http://tenant.id">tenant.id</a>)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">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).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">For stuff like this the docs are your best bet along with introspecting the objects using the interactive python shell:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="http://docs.openstack.org/developer/python-keystoneclient/">http://docs.openstack.org/developer/python-keystoneclient/</a><o:p></o:p></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Wed, Jul 6, 2016 at 12:53 PM, Jared Wilkinson <<a href="mailto:JWilkinson@ebsco.com" target="_blank">JWilkinson@ebsco.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt">Hey folks,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt">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.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt">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.
</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt">Any direction would be appreciated.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt"><br>
Thanks,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt">Jared</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><b><span style="font-family:Helvetica;color:#767171">Jared Wilkinson</span></b><span style="color:black"> | Senior Infrastructure Engineer – Team Lead</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:Helvetica;color:#7F7F7F"><a href="mailto:jwilkinson@ebsco.com" target="_blank">jwilkinson@ebsco.com</a> | (W) <a href="tel:205%2F981-4018" target="_blank">205/981-4018</a>
| (M) <a href="tel:205%2F259-9802" target="_blank">205/259-9802</a></span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:Helvetica;color:#7F7F7F">5724 US Highway 280 East, Birmingham, AL 35242, USA</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
OpenStack-operators mailing list<br>
<a href="mailto:OpenStack-operators@lists.openstack.org">OpenStack-operators@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-operators" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-operators</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>