<div dir="ltr">Hello Amit,<div><br></div><div>    Happy to hear the code snip helped, I am using Python3 and the build in configparser: <a href="https://docs.python.org/3/library/configparser.html">https://docs.python.org/3/library/configparser.html</a>. If you are using Python2 the syntax is slightly different.</div><div><br></div><div>I have a config file that looks like this:</div><div>--snip--</div><div><div>[DEFAULT]</div><div>verify_certs = false</div><div><br></div><div>[influxdb]</div><div>host = <influx_host></div><div>port = 8086</div><div>database_name = openstackstackstats</div><div>username = openstack</div><div>password = <password></div><div><br></div><div>[allocation_ratio]</div><div>cpu_allocation_ratio = 6.0</div><div>ram_allocation_ratio = 2.0</div><div>disk_allocation_ratio = 2.0</div><div>#<a href="https://blueprints.launchpad.net/nova/+spec/add-ratio-to-hypervisor-show">https://blueprints.launchpad.net/nova/+spec/add-ratio-to-hypervisor-show</a></div><div>#<a href="https://review.openstack.org/#/c/350344/1/specs/ocata/implemented/add-ratio-to-hypervisor-show.rst">https://review.openstack.org/#/c/350344/1/specs/ocata/implemented/add-ratio-to-hypervisor-show.rst</a></div><div>#This values are provided via the API in Ocata</div></div><div>--snip--</div><div><br></div><div><br></div><div>Then in my code I have the following, the "config" variable below is the configobj that gets passed into the method "<span style="font-size:12.8px">def _create_connection(self, cloud_params, configobj):"</span></div><div>--snip--</div><div>....</div><div>import configparser</div><div>....</div><div><div>def main():</div><div><br></div><div>    config_paths = [</div><div>        '/etc/openstackstats.conf',</div><div>        '%s/openstackstats.conf' % (os.path.expanduser("~")),</div><div>    ]</div><div><br></div><div>    options = parse_options()</div><div>    ....</div><div><br></div><div>    log.debug("Default config file search paths:")</div><div>    for cfg in config_paths:</div><div>        log.debug("Will attempt to load: %s" % (cfg))</div><div><br></div><div>    ....</div><div>    config = configparser.ConfigParser()</div><div>    configs_found = config.read(config_paths)</div><div><br></div><div>    if len(configs_found) < 1:</div><div>        log.critical("No configuration files found")</div><div>        sys.exit(1)</div><div><br></div><div>    for cfg in configs_found:</div><div>        log.debug("Loaded configuration: %s" % (cfg))</div><div><br></div><div>    cloud_params = _load_openrc(log)</div><div>    stats = StatsManager(cloud_params, config)</div><div>    stats.processstats()</div></div><div>--snip--</div><div><br></div><div>I hope this helps :)</div><div><br></div><div>Michael</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 4, 2017 at 9:05 AM, Amit Kumar <span dir="ltr"><<a href="mailto:ebiibe82@gmail.com" target="_blank">ebiibe82@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks Michael for providing the code snippet. It was of great help. I was doing things as expected but missed to set interface in profile.<div><br></div><div>Could you please provide some reference to what configparser object. I am using code provided by you except setting config parser object and getting SSL error when setting 'keystone' interface as 'public'. Error is pasted here: <a href="http://paste.openstack.org/show/601428/" target="_blank">http://paste.openstack.<wbr>org/show/601428/</a></div><div><br></div><div>I am using auth_url as '<a href="https://192.168.255.45:5000/v3" target="_blank">https://192.168.255.45:<wbr>5000/v3</a>'. 192.168.255.45 is public interface. But when I am setting 'keystone' interface as 'internal' with internal ip 172.29.236.11, connection is successful. Seems this SSL error be related to config parser object.</div><div><br></div><div>Regards,</div><div>Amit</div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 4, 2017 at 2:12 AM, Michael Gale <span dir="ltr"><<a href="mailto:gale.michael@gmail.com" target="_blank">gale.michael@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hey,<div><br></div><div>    Here is how I am authenticating using openstacksdk:</div><div><br></div><div>--snip--</div><div><div>from openstack import connection</div><div>from openstack import profile</div><div>from openstack import utils</div></div><div><br></div><div><div>def _create_connection(self, cloud_params, configobj):</div><div><br></div><div>        auth_args = {</div><div>            'auth_url' : cloud_params['OS_AUTH_URL'],</div><div>            'username' : cloud_params['OS_USERNAME'],</div><div>            'password' : cloud_params['OS_PASSWORD'],</div><div>            'project_name' : cloud_params['OS_PROJECT_NAME'<wbr>],</div><div>            'user_domain_name' : cloud_params['OS_USER_DOMAIN_N<wbr>AME'],</div><div>            'project_domain_name' : cloud_params['OS_USER_DOMAIN_N<wbr>AME'],</div><div>        }</div><div><br></div><div>        prof = profile.Profile()</div><div>        prof.set_region(profile.Profil<wbr>e.ALL, cloud_params['OS_REGION_NAME']<wbr>)</div><div>        prof.set_interface('identity', 'public')</div><div><br></div><div>        <a href="http://log.info" target="_blank">log.info</a>("Authenticating against: %s" % (cloud_params['OS_AUTH_URL']))</div><div>        log.debug("Authenticating project: %s" % (cloud_params['OS_PROJECT_NAME<wbr>']))</div><div><br></div><div>        conn = connection.Connection(</div><div>            profile=prof,</div><div>            verify=configobj.getboolean('D<wbr>EFAULT', 'verify_certs'),</div><div>            user_agent='openstatstats',</div><div>            **auth_args</div><div>        )</div><div><br></div><div>        <a href="http://log.info" target="_blank">log.info</a>("Authentication successful")</div><div><br></div><div>        return conn</div></div><div>--snip--</div><div><br></div><div>cloud_params is a dictionary with the OS_* vars loaded from the environment vars, configobj is a configparser object.</div><div><br></div><div>Michael</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_-5904297253662509756h5">On Fri, Mar 3, 2017 at 4:12 AM, Amit Kumar <span dir="ltr"><<a href="mailto:ebiibe82@gmail.com" target="_blank">ebiibe82@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_-5904297253662509756h5"><div dir="ltr"><div>Andy, thanks for your response.</div><div><br></div>Address is reachable. I am running Horizon UI on this address successfully. I used "http" whereas it should be "https" but it is not working currently with https as well.<div><br></div><div>Anyways, I tried the script from utility container where openstack command line client is successful in executing the commands but python sdk connection is failing with following error:</div><div><br></div><div><i style="font-size:12.8px">"openstack.exceptions.HttpExce<wbr>ption: HttpException: Expecting to find domain in project - the server could not comply with the request since it is either malformed or otherwise incorrect. The client is assumed to be in error."</i><span style="font-size:12.8px"> </span><br></div><div><span style="font-size:12.8px"><br></span></div><div>On noting the difference in wireshark traces, openstack command line client is adding "domain" related information in request but this domain related information is missing while attempting connection using python SDK.<br><div><br></div><div>@openstack-sdk, could anyone provide information that how to add domain related information while attempting connection using python sdk.</div></div><div><br></div><div>Regards,</div><div>Amit</div><div><div class="m_-5904297253662509756m_-8638713696154578065h5"><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 2, 2017 at 8:54 PM, Andy McCrae <span dir="ltr"><<a href="mailto:andy.mccrae@gmail.com" target="_blank">andy.mccrae@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra" style="font-size:12.8px">Hi Amit,</div><div class="gmail_extra" style="font-size:12.8px"><br></div><div class="gmail_extra" style="font-size:12.8px">Sending it again to include the ML!</div><div class="gmail_extra" style="font-size:12.8px"><br><div class="gmail_quote"><span class="m_-5904297253662509756m_-8638713696154578065m_2656603551323834516m_-487992749003537655gmail-im"><span>On 2 March 2017 at 11:01, Amit Kumar <span dir="ltr"><<a href="mailto:ebiibe82@gmail.com" target="_blank">ebiibe82@gmail.com</a>></span> wro<wbr>te:<br></span><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi All,</div><div><br></div><div>I have deployed Openstack using Openstack-Ansible. I am using Newton release from tag 14.0.8. My test environment is containing only Compute Node and Controller Node (Infra Node).</div><div>When using Openstack Python SDK, I am getting following error while making connection to external_vib_lp_address (192.168.255.45) binded to port 5000.</div><div><br></div><div><i>openstack.exceptions.SDKExcept<wbr>ion: Connection failure that may be retried.</i></div></div></blockquote><div><br></div></span></span><span><div>Based on the error this is a connection issue -  have you tested manually connecting to the external address you listed on that port? <br></div><div>A good place to start would be to start looking at why it can't connect and seeing if you can manually connect outside of using the SDK.</div><div><br></div><div>Are you trying to connect from a separate host to the OpenStack environment? If so can you even access 192.168.255.45?<br></div><div><br></div><div>If you're still having issues feel free to jump into #openstack-ansible on Freenode and hopefully you'll be able to get more help there!</div></span></div></div><span class="m_-5904297253662509756m_-8638713696154578065m_2656603551323834516HOEnZb"><font color="#888888"><div class="gmail_extra"><br></div><div class="gmail_extra">Andy</div></font></span></div>
</blockquote></div><br></div></div></div></div>
<br></div></div>______________________________<wbr>_________________<br>
Mailing list: <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack" rel="noreferrer" target="_blank">http://lists.openstack.org/cgi<wbr>-bin/mailman/listinfo/openstac<wbr>k</a><br>
Post to     : <a href="mailto:openstack@lists.openstack.org" target="_blank">openstack@lists.openstack.org</a><br>
Unsubscribe : <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack" rel="noreferrer" target="_blank">http://lists.openstack.org/cgi<wbr>-bin/mailman/listinfo/openstac<wbr>k</a><br>
<br></blockquote></div><span class="m_-5904297253662509756HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_-5904297253662509756m_-8638713696154578065gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><span style="font-size:16px"><h2 style="font-family:Verdana,Arial,Helvetica,sans-serif;font-weight:bold;font-size:16px"><span style="font-weight:normal"><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">“The Man who says he can, and the man who says he can not.. Are both correct”</span></p></span></h2></span></div></div></div></div>
</font></span></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><span style="font-size:16px"><h2 style="font-family:Verdana,Arial,Helvetica,sans-serif;font-weight:bold;font-size:16px"><span style="font-weight:normal"><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">“The Man who says he can, and the man who says he can not.. Are both correct”</span></p></span></h2></span></div></div></div></div>
</div>