Ask Your Question
0

Python neutron.list_agents() error

asked 2020-01-30 20:28:51 -0500

asghar_h gravatar image

Hello,

I am using the latest Python neutron client (as of Jan 2020) and am encountering an error.

Code:

--> BEGIN PYTHON CODE

auth = identity.Password(auth_url=auth_url,
                         username=username,
                         password=password,
                         project_name=project_name,
                         project_domain_name=project_domain_name,
                         user_domain_name=user_domain_name)

neutron_session = session.Session(auth=auth)
neutron = neutron_v2_client.Client(session=neutron_session)

neutron_agent_list = neutron.list_agents()

<--END PYTHON CODE

Perhaps I am not using this API correctly. Can someone guide me.

Thanks.

Error: Traceback (most recent call last): File "/Users/a/ComputerProgramming/Python/openstack/test.py", line 52, in <module> neutron_agent_list = neutron.list_agents() File "/Users/a/ComputerProgramming/Python/openstack/venv/lib/python3.6/site-packages/neutronclient/v2_0/client.py", line 1444, in list_agents return self.get(self.agents_path, params=_params) File "/Users/a/ComputerProgramming/Python/openstack/venv/lib/python3.6/site-packages/neutronclient/v2_0/client.py", line 354, in get headers=headers, params=params) File "/Users/a/ComputerProgramming/Python/openstack/venv/lib/python3.6/site-packages/neutronclient/v2_0/client.py", line 331, in retry_request headers=headers, params=params) File "/Users/a/ComputerProgramming/Python/openstack/venv/lib/python3.6/site-packages/neutronclient/v2_0/client.py", line 282, in do_request headers=headers) File "/Users/a/ComputerProgramming/Python/openstack/venv/lib/python3.6/site-packages/neutronclient/client.py", line 339, in do_request self._check_uri_length(url) File "/Users/a/ComputerProgramming/Python/openstack/venv/lib/python3.6/site-packages/neutronclient/client.py", line 332, in _check_uri_length uri_len = len(self.endpoint_url) + len(url) File "/Users/a/ComputerProgramming/Python/openstack/venv/lib/python3.6/site-packages/neutronclient/client.py", line 346, in endpoint_url return self.get_endpoint() File "/Users/a/ComputerProgramming/Python/openstack/venv/lib/python3.6/site-packages/keystoneauth1/adapter.py", line 282, in get_endpoint return self.session.get_endpoint(auth or self.auth, *kwargs) File "/Users/a/ComputerProgramming/Python/openstack/venv/lib/python3.6/site-packages/keystoneauth1/session.py", line 1225, in get_endpoint return auth.get_endpoint(self, *kwargs) File "/Users/a/ComputerProgramming/Python/openstack/venv/lib/python3.6/site-packages/keystoneauth1/identity/base.py", line 380, in get_endpoint allow_version_hack=allow_version_hack, **kwargs) File "/Users/a/ComputerProgramming/Python/openstack/venv/lib/python3.6/site-packages/keystoneauth1/identity/base.py", line 271, in get_endpoint_data service_catalog = self.get_access(session).service_catalog File "/Users/a/ComputerProgramming/Python/openstack/venv/lib/python3.6/site-packages/keystoneauth1/identity/base.py", line 134, in get_access self.auth_ref = self.get_auth_ref(session) File "/Users/a/ComputerProgramming/Python/openstack/venv/lib/python3.6/site-packages/keystoneauth1/identity/generic/base.py", line 206, in get_auth_ref self._plugin = self._do_create_plugin(session) File "/Users/a/ComputerProgramming/Python/openstack/venv/lib/python3.6/site-packages/keystoneauth1/identity/generic/base.py", line 138, in _do_create_plugin authenticated=False) File "/Users/a/ComputerProgramming/Python/openstack/venv/lib/python3.6/site-packages/keystoneauth1/identity/base.py", line 610, in get_discovery authenticated=authenticated) File "/Users/a/ComputerProgramming/Python/openstack/venv/lib/python3.6/site-packages/keystoneauth1/discover.py", line 1436, in get_discovery parsed_url = urllib.parse.urlparse(url) File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/parse.py", line 367, in urlparse url, scheme, _coerce_result = _coerce_args(url, scheme) File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/parse.py", line ... (more)

edit retag flag offensive close merge delete

Comments

You are so good at formatting Python code as code, then you generate a barely readable wall of text from the stack trace. A shame!

Your neutron client seems to be incompatible with some Python library/libraries. How did you install it?

Bernd Bausch gravatar imageBernd Bausch ( 2020-01-30 20:54:23 -0500 )edit

Bernd,

Thanks for taking the time to tackle this question.

The neutron version is:

neutron --version
6.0.1

I installed the Python library using pip3.6. The version of the "python-neutronclient" is as follows:

python-neutronclient==6.14.0

Thanks.

-Asghar

asghar_h gravatar imageasghar_h ( 2020-01-31 12:59:26 -0500 )edit

neutron --version shows you the version of the neutron command, which is the neutron client. Could you have installed two versions? Would that explain the problem?

Well, I just notice your program uses a venv, though the urllib resides outside of the venv. Might be a red herring.

Bernd Bausch gravatar imageBernd Bausch ( 2020-01-31 15:57:12 -0500 )edit

2 answers

Sort by » oldest newest most voted
0

answered 2020-02-01 15:57:30 -0500

asghar_h gravatar image

There should be only a single neutron environment, so I am not worried about that. I do know that the version of openstack is "Newton" and am not sure if thats an issue.

The Python urllib versions are as follows:

SYSTEM WIDE (Py3.6)
==================
pip3.6 list installed  | grep -i urllib     
urllib3                       1.25.3   

VIRTUAL ENV (Py3.6)
./venv/bin/pip3.6 list installed | grep -i urllib                                                        ░▒▓ 100% █ ─╯
urllib3               1.25.8

Is there an example of this library/function being used anywhere? I want to make sure I am using this correctly.

Regards.

edit flag offensive delete link more

Comments

am not sure if thats an issue

Might well be. Have you tried the version of the neutronclient that came with Newton?

Bernd Bausch gravatar imageBernd Bausch ( 2020-02-02 00:46:56 -0500 )edit

Bernd,

No I have not. How do I get the client installed on control node.

Thanks.

-Asghar

asghar_h gravatar imageasghar_h ( 2020-02-03 09:26:58 -0500 )edit

That depends on how you installed all the rest on the control node.

Bernd Bausch gravatar imageBernd Bausch ( 2020-02-03 11:47:09 -0500 )edit
0

answered 2020-02-03 04:31:44 -0500

Python 3.6 wasn't supported by neutronclient 6.0.1, see https://opendev.org/openstack/python-... Support for python 3.6 was added in version 6.12: https://opendev.org/openstack/python-...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2020-01-30 20:28:51 -0500

Seen: 80 times

Last updated: Feb 03