diff --git a/hooks/keystone_utils.py b/hooks/keystone_utils.py index 0374807f..b6f16f17 100644 --- a/hooks/keystone_utils.py +++ b/hooks/keystone_utils.py @@ -1757,6 +1757,13 @@ def add_credentials_to_keystone(relation_id=None, remote_unit=None): } if domain: relation_data['domain'] = domain + # The same domain is used for project and user creation. However, in + # the future they may not be. + domain_id = manager.resolve_domain_id(domain) + relation_data['credentials_user_domain_name'] = domain + relation_data['credentials_user_domain_id'] = domain_id + relation_data['credentials_project_domain_name'] = domain + relation_data['credentials_project_domain_id'] = domain_id peer_store_and_set(relation_id=relation_id, **relation_data) diff --git a/unit_tests/test_keystone_utils.py b/unit_tests/test_keystone_utils.py index d973f271..2c08a1ba 100644 --- a/unit_tests/test_keystone_utils.py +++ b/unit_tests/test_keystone_utils.py @@ -1067,6 +1067,7 @@ class TestKeystoneUtils(CharmTestCase): """ Verify add_credentials with Keystone V3 """ manager = MagicMock() manager.resolve_tenant_id.return_value = 'abcdef0123456789' + manager.resolve_domain_id.return_value = 'a-domain-id' get_manager.return_value = manager remote_unit = 'unit/0' relation_id = 'identity-credentials:0' @@ -1090,6 +1091,10 @@ class TestKeystoneUtils(CharmTestCase): 'credentials_password': 'password', 'credentials_project': 'services', 'credentials_project_id': 'abcdef0123456789', + 'credentials_user_domain_id': 'a-domain-id', + 'credentials_project_domain_id': 'a-domain-id', + 'credentials_project_domain_name': 'Non-Default', + 'credentials_user_domain_name': 'Non-Default', 'region': 'RegionOne', 'domain': 'Non-Default', 'api_version': 3}