Python neutronclient session failed request

asked 2019-03-06 12:43:25 -0600

frenchtoasters gravatar image

updated 2019-03-06 15:56:43 -0600

I am trying to use the python-neutronclient and creating my connection via a keystone session variable however no matter what call i do for neutron I have a hard fail because self.endpoint_url is not defined, thus i am unable to run the _check_uri_length function when making a call. Looking at the call to SessionClienthere ( endpoint_url is defined here however it is never passed to the SessionClient class. Yet the class still calls the self.endpoint_url which returns None. I have tried passing this variable a couple different places and I see that it is being passed to construct_http_client however it does not get passed to the SessionClient class.

import argparse
import sys
import os

from keystoneauth1 import loading as ks_loading
from keystoneclient.v3 import client as ks_client
from neutronclient.v2_0 import client as neutron_client    

class OpenStack(object):
    def __repr__(self):
        return "<Server: %s>" %

    def __init__(self, args):
        # get a connection based on those args/vars
        self.auth = ks_loading.load_auth_from_argparse_arguments(args)
        self.sess = ks_loading.load_session_from_argparse_arguments(args, auth=self.auth)
        self._os = ks_client.Client(session=self.sess)
        self._neutron = neutron_client.Client(endpoint_url="https://openstack.future.lab:9696/", 
version=os.getenv('OS_NETWORK_API_VERSION', '2.1'), session=self.sess)
        self._data = dict(
            projects = [],

    def __enter__(self):
        return self

    def __exit__(self, type, value, traceback):
        return 0

def main(argv=None):
    # support OS_* environment variables and/or --os-* arguments
    parser = argparse.ArgumentParser()
    ks_loading.register_auth_argparse_arguments(parser, sys.argv[1:], default='v3password')
    args = parser.parse_args()

    with OpenStack(args) as OS:
       projects = OS._os.projects.list()
       for project in projects:
           temp = {}
           temp['name'] =
           temp['_id'] =
           neutron_quota = OS._neutron.show_quota(

if __name__ == '__main__':

The error that im getting is:

Traceback (most recent call last):
  File "", line 70, in <module>
  File "", line 63, in main
    neutron_quota = power_vc._neutron.show_quota(
  File "/home/ubuntu/powervc/venv/lib/python3.7/site-packages/debtcollector/", line 43, in decorator
    return wrapped(*args, **kwargs)
  File "/home/ubuntu/powervc/venv/lib/python3.7/site-packages/neutronclient/v2_0/", line 753, in 
    return self.get(self.quota_path % (project_id), params=_params)
  File "/home/ubuntu/powervc/venv/lib/python3.7/site-packages/neutronclient/v2_0/", line 353, in get
    headers=headers, params=params)
  File "/home/ubuntu/powervc/venv/lib/python3.7/site-packages/neutronclient/v2_0/", line 330, in 
    headers=headers, params=params)
  File "/home/ubuntu/powervc/venv/lib/python3.7/site-packages/neutronclient/v2_0/", line 281, in 
  File "/home/ubuntu/powervc/venv/lib/python3.7/site-packages/neutronclient/", line 348, in do_request
  File "/home/ubuntu/powervc/venv/lib/python3.7/site-packages/neutronclient/", line 335, in _ 
    uri_len = len(self.endpoint_url) + len(url)
TypeError: object of type 'NoneType' has no len()
edit retag flag offensive close merge delete