Hi All,

I am new to OpenStack SDA API and I need help.

While I am running my basic py file I am always getting the below error, Please suggest.


Code:

import openstack

conn = openstack.connect(cloud='openstack')

for server in conn.compute.servers():
    print(server.to_dict())


Error:

[pke@vm01 ~]$ python openstack-connect.py 

Traceback (most recent call last):
  File "openstack-connect.py", line 7, in <module>
    for server in conn.compute.servers():
  File "/usr/local/lib/python3.6/site-packages/openstack/service_description.py", line 87, in __get__
    proxy = self._make_proxy(instance)
  File "/usr/local/lib/python3.6/site-packages/openstack/service_description.py", line 262, in _make_proxy
    found_version = temp_adapter.get_api_major_version()
  File "/usr/local/lib/python3.6/site-packages/keystoneauth1/adapter.py", line 354, in get_api_major_version
    return self.session.get_api_major_version(auth or self.auth, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/keystoneauth1/session.py", line 1276, in get_api_major_version
    return auth.get_api_major_version(self, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/keystoneauth1/identity/base.py", line 500, in get_api_major_version
    data = get_endpoint_data(discover_versions=discover_versions)
  File "/usr/local/lib/python3.6/site-packages/keystoneauth1/identity/base.py", line 271, in get_endpoint_data
    service_catalog = self.get_access(session).service_catalog
  File "/usr/local/lib/python3.6/site-packages/keystoneauth1/identity/base.py", line 134, in get_access
    self.auth_ref = self.get_auth_ref(session)
  File "/usr/local/lib/python3.6/site-packages/keystoneauth1/identity/generic/base.py", line 208, in get_auth_ref
    return self._plugin.get_auth_ref(session, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/keystoneauth1/identity/v3/base.py", line 188, in get_auth_ref
    authenticated=False, log=False, **rkwargs)
  File "/usr/local/lib/python3.6/site-packages/keystoneauth1/session.py", line 1149, in post
    return self.request(url, 'POST', **kwargs)
  File "/usr/local/lib/python3.6/site-packages/keystoneauth1/session.py", line 986, in request
    raise exceptions.from_response(resp, method, url)
keystoneauth1.exceptions.http.Unauthorized: The request you have made requires authentication. (HTTP 401) (Request-ID: req-0e898e09-0dbc-4beb-8414-8dcdc4f6631e)


Regards
Pradeep Kumar
On Monday, 20 June, 2022, 04:54:19 pm IST, pspal83@hotmail.com <pspal83@hotmail.com> wrote:


Hi All,

I am new to OpenStack SDA API and I need help.

While I am running my basic py file I am always getting the below error, Please suggest.


Code:

import openstack

conn = openstack.connect(cloud='openstack')

for server in conn.compute.servers():
    print(server.to_dict())


Error:

[pke@vm01 ~]$ python openstack-connect.py 

Traceback (most recent call last):
  File "openstack-connect.py", line 7, in <module>
    for server in conn.compute.servers():
  File "/usr/local/lib/python3.6/site-packages/openstack/service_description.py", line 87, in __get__
    proxy = self._make_proxy(instance)
  File "/usr/local/lib/python3.6/site-packages/openstack/service_description.py", line 262, in _make_proxy
    found_version = temp_adapter.get_api_major_version()
  File "/usr/local/lib/python3.6/site-packages/keystoneauth1/adapter.py", line 354, in get_api_major_version
    return self.session.get_api_major_version(auth or self.auth, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/keystoneauth1/session.py", line 1276, in get_api_major_version
    return auth.get_api_major_version(self, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/keystoneauth1/identity/base.py", line 500, in get_api_major_version
    data = get_endpoint_data(discover_versions=discover_versions)
  File "/usr/local/lib/python3.6/site-packages/keystoneauth1/identity/base.py", line 271, in get_endpoint_data
    service_catalog = self.get_access(session).service_catalog
  File "/usr/local/lib/python3.6/site-packages/keystoneauth1/identity/base.py", line 134, in get_access
    self.auth_ref = self.get_auth_ref(session)
  File "/usr/local/lib/python3.6/site-packages/keystoneauth1/identity/generic/base.py", line 208, in get_auth_ref
    return self._plugin.get_auth_ref(session, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/keystoneauth1/identity/v3/base.py", line 188, in get_auth_ref
    authenticated=False, log=False, **rkwargs)
  File "/usr/local/lib/python3.6/site-packages/keystoneauth1/session.py", line 1149, in post
    return self.request(url, 'POST', **kwargs)
  File "/usr/local/lib/python3.6/site-packages/keystoneauth1/session.py", line 986, in request
    raise exceptions.from_response(resp, method, url)
keystoneauth1.exceptions.http.Unauthorized: The request you have made requires authentication. (HTTP 401) (Request-ID: req-0e898e09-0dbc-4beb-8414-8dcdc4f6631e)


Regards
Pradeep Kumar