From 2eba95cd8c1fcc5b6d262fe6d58bee5732a53ed2 Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Fri, 12 Jul 2024 15:36:48 -0400 Subject: [PATCH 1/2] Allow callers of get_overcloud_keystone_session() to specify a scope By default get_overcloud_keystone_session() hands off project scoped tokens, this is not suitable for all API calls, this change allows callers to optionally request a different scope (e.g. system) --- zaza/openstack/utilities/openstack.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zaza/openstack/utilities/openstack.py b/zaza/openstack/utilities/openstack.py index e87f8547d..143472e0e 100644 --- a/zaza/openstack/utilities/openstack.py +++ b/zaza/openstack/utilities/openstack.py @@ -574,19 +574,21 @@ def get_keystone_session(openrc_creds, scope='PROJECT', verify=None): return session.Session(auth=auth, verify=verify) -def get_overcloud_keystone_session(verify=None, model_name=None): +def get_overcloud_keystone_session(verify=None, model_name=None, scope=None): """Return Over cloud keystone session. :param verify: Control TLS certificate verification behaviour :type verify: any :param model_name: Name of model to query. :type model_name: str + :param scope: Keystone scope + :type scope: str :returns keystone_session: keystoneauth1.session.Session object :rtype: keystoneauth1.session.Session """ return get_keystone_session( get_overcloud_auth(model_name=model_name), - scope=get_keystone_scope(model_name=model_name), + scope=scope or get_keystone_scope(model_name=model_name), verify=verify) From fe2e0a48a98a1d2b5419e162c81dbf4a8d0d2b5f Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Fri, 12 Jul 2024 15:38:12 -0400 Subject: [PATCH 2/2] Use a system scope token for ironic client --- zaza/openstack/charm_tests/ironic/tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zaza/openstack/charm_tests/ironic/tests.py b/zaza/openstack/charm_tests/ironic/tests.py index deba8ab01..b6c53809e 100644 --- a/zaza/openstack/charm_tests/ironic/tests.py +++ b/zaza/openstack/charm_tests/ironic/tests.py @@ -22,7 +22,8 @@ def _get_ironic_client(ironic_api_version="1.58"): - keystone_session = openstack_utils.get_overcloud_keystone_session() + keystone_session = openstack_utils.get_overcloud_keystone_session( + scope='system') ironic = ironic_client.Client(1, session=keystone_session, os_ironic_api_version=ironic_api_version) return ironic