Dear Predeep,
you need to authenticate against Keystone API.
For example see https://docs.openstack.org/openstacksdk/wallaby/user/guides/connect.html
Best, Jani
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 openstackconn = 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_proxyfound_version = temp_adapter.get_api_major_version()File "/usr/local/lib/python3.6/site-packages/keystoneauth1/adapter.py", line 354, in get_api_major_versionreturn 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_versionreturn 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_versiondata = get_endpoint_data(discover_versions=discover_versions)File "/usr/local/lib/python3.6/site-packages/keystoneauth1/identity/base.py", line 271, in get_endpoint_dataservice_catalog = self.get_access(session).service_catalogFile "/usr/local/lib/python3.6/site-packages/keystoneauth1/identity/base.py", line 134, in get_accessself.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_refreturn 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_refauthenticated=False, log=False, **rkwargs)File "/usr/local/lib/python3.6/site-packages/keystoneauth1/session.py", line 1149, in postreturn self.request(url, 'POST', **kwargs)File "/usr/local/lib/python3.6/site-packages/keystoneauth1/session.py", line 986, in requestraise 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)
RegardsPradeep KumarOn 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 openstackconn = 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_proxyfound_version = temp_adapter.get_api_major_version()File "/usr/local/lib/python3.6/site-packages/keystoneauth1/adapter.py", line 354, in get_api_major_versionreturn 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_versionreturn 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_versiondata = get_endpoint_data(discover_versions=discover_versions)File "/usr/local/lib/python3.6/site-packages/keystoneauth1/identity/base.py", line 271, in get_endpoint_dataservice_catalog = self.get_access(session).service_catalogFile "/usr/local/lib/python3.6/site-packages/keystoneauth1/identity/base.py", line 134, in get_accessself.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_refreturn 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_refauthenticated=False, log=False, **rkwargs)File "/usr/local/lib/python3.6/site-packages/keystoneauth1/session.py", line 1149, in postreturn self.request(url, 'POST', **kwargs)File "/usr/local/lib/python3.6/site-packages/keystoneauth1/session.py", line 986, in requestraise 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)
RegardsPradeep Kumar