diff --git a/keystoneauth1/session.py b/keystoneauth1/session.py index f4c400c0..0fa31845 100644 --- a/keystoneauth1/session.py +++ b/keystoneauth1/session.py @@ -83,6 +83,8 @@ def _mv_legacy_headers_for_service(mv_service_type): headers.append("X-OpenStack-Nova-API-Version") elif mv_service_type == "baremetal": headers.append("X-OpenStack-Ironic-API-Version") + elif mv_service_type in ["sharev2", "shared-file-system"]: + headers.append("X-OpenStack-Manila-API-Version") return headers @@ -614,6 +616,14 @@ class Session(object): if (service_type.startswith('volume') or service_type == 'block-storage'): service_type = 'volume' + elif service_type.startswith('share'): + # NOTE(gouthamr) manila doesn't honor the "OpenStack-API-Version" + # header yet, but sending it does no harm - when the service + # honors this header, it'll use the standardized name in the + # service-types-authority and not the legacy name in the cloud's + # service catalog + service_type = 'shared-file-system' + headers.setdefault('OpenStack-API-Version', '{service_type} {microversion}'.format( service_type=service_type, diff --git a/keystoneauth1/tests/unit/test_session.py b/keystoneauth1/tests/unit/test_session.py index f4ea07af..b191e8d9 100644 --- a/keystoneauth1/tests/unit/test_session.py +++ b/keystoneauth1/tests/unit/test_session.py @@ -164,6 +164,17 @@ class SessionTests(utils.TestCase): self.assertEqual(headers['OpenStack-API-Version'], 'volume 2.30') self.assertEqual(len(headers.keys()), 1) + # shared file system service-type - shared-file-system microversion + # (with service type aliases) + for service_type in ['sharev2', 'shared-file-system']: + headers = {} + client_session.Session._set_microversion_headers( + headers, (2, 30), None, {'service_type': service_type}) + self.assertEqual(headers['X-OpenStack-Manila-API-Version'], '2.30') + self.assertEqual(headers['OpenStack-API-Version'], + 'shared-file-system 2.30') + self.assertEqual(len(headers.keys()), 2) + # Headers already exist - no change headers = { 'OpenStack-API-Version': 'compute 2.30',