[sdk] Question about openstacksdk
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) RegardsPradeep 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) RegardsPradeep Kumar
Dear Predeep, you need to authenticate against Keystone API. For example see https://docs.openstack.org/openstacksdk/wallaby/user/guides/connect.html Best, Jani On 6/20/22 13:33, 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 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
Hi, your code works for me, at least with proper credentials in place. How do you keep your credentials for Keystone authentication? I’d strongly recommend using a “clouds.yaml” (and possibly a “secure.yaml” in the same directory) for that in favor of using environment variables. To check if your information is read and processed correctly, you may run this code that reads, formats, and displays (parts of) your connection object: import openstacksdk import yaml print(yaml.dump({"clouds": {"mycloud": {"auth": openstack.connect().config.config["auth"]}}}, indent=4)) This creates something like: In [2]: print(yaml.dump({"clouds": {"mycloud": {"auth": openstack.connect().config.config["auth"]}}}, indent=4)) clouds: mycloud: auth: auth_url: https://iam.eu-de.otc.t-systems.com/v3 password: "SecretSecretSeccret" project_name: eu-de_myproj user_domain_name: OTC000000000010000***** username: nilsmagnus (the actual config object is way larger) For completeness, could you also specify the version of your SDK? In [35]: print(openstack.version.pbr.version.VersionInfo("openstacksdk").version_string()) 0.99.0 Von: pspal83@hotmail.com <pspal83@hotmail.com> Gesendet: Montag, 20. Juni 2022 13:34 An: user-committee@lists.openstack.org Betreff: [sdk] Question about openstacksdk 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<mailto:pspal83@hotmail.com> <pspal83@hotmail.com<mailto: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
Hi All, Thanks, Let me check. I will update you on this very soon. Regards Pradeep Sent from Yahoo Mail on Android <!--#yiv9495875459 _filtered {} _filtered {} _filtered {} _filtered {}#yiv9495875459 #yiv9495875459 p.yiv9495875459MsoNormal, #yiv9495875459 li.yiv9495875459MsoNormal, #yiv9495875459 div.yiv9495875459MsoNormal {margin:0cm;font-size:11.0pt;font-family:"Calibri", sans-serif;}#yiv9495875459 a:link, #yiv9495875459 span.yiv9495875459MsoHyperlink {color:#0563C1;text-decoration:underline;}#yiv9495875459 .yiv9495875459MsoChpDefault {font-size:10.0pt;} _filtered {}#yiv9495875459 div.yiv9495875459WordSection1 {}--> Hi, your code works for me, at least with proper credentials in place. How do you keep your credentials for Keystone authentication? I’d strongly recommend using a “clouds.yaml” (and possibly a “secure.yaml” in the same directory) for that in favor of using environment variables. To check if your information is read and processed correctly, you may run this code that reads, formats, and displays (parts of) your connection object: import openstacksdk import yaml print(yaml.dump({"clouds": {"mycloud": {"auth": openstack.connect().config.config["auth"]}}}, indent=4)) This creates something like: In [2]: print(yaml.dump({"clouds": {"mycloud": {"auth": openstack.connect().config.config["auth"]}}}, indent=4)) clouds: mycloud: auth: auth_url:https://iam.eu-de.otc.t-systems.com/v3 password: "SecretSecretSeccret" project_name: eu-de_myproj user_domain_name: OTC000000000010000***** username: nilsmagnus (the actual config object is way larger) For completeness, could you also specify the version of your SDK? In [35]: print(openstack.version.pbr.version.VersionInfo("openstacksdk").version_string()) 0.99.0 Von: pspal83@hotmail.com <pspal83@hotmail.com> Gesendet: Montag, 20. Juni 2022 13:34 An: user-committee@lists.openstack.org Betreff: [sdk] Question about openstacksdk 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 serverin 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 serverin 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
participants (3)
-
Jani Heikkinen
-
Nils.Magnus@t-systems.com
-
pspal83@hotmail.com