diff options
author | Valentin Boucher <valentin.boucher@kontron.com> | 2018-02-21 15:44:52 -0500 |
---|---|---|
committer | Valentin Boucher <valentin.boucher@kontron.com> | 2018-02-22 09:35:02 -0500 |
commit | f15f1764ae1531e086a68d6070964a8b6c60a987 (patch) | |
tree | d2626a872ef796e3fad886a9a6359bb3b2327e72 | |
parent | 78a21107e377f4f4722fd8d570dc0394f6ae5692 (diff) |
Support different user/project domain values
For the moment, VNF works well only if
OS_PROJECT_DOMAIN_NAME=Default
OS_USER_DOMAIN_NAME=Default
It's now possible to use domain != Default
JIRA: FUNCTEST-935
Change-Id: I779a93538662ff32906d91d7cf3b2c5c3e872765
Signed-off-by: Valentin Boucher <valentin.boucher@kontron.com>
-rw-r--r-- | functest/core/vnf.py | 20 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/ims/cloudify_ims.py | 4 | ||||
-rw-r--r-- | functest/tests/unit/core/test_vnf.py | 14 |
3 files changed, 33 insertions, 5 deletions
diff --git a/functest/core/vnf.py b/functest/core/vnf.py index 05baf432a..15065f730 100644 --- a/functest/core/vnf.py +++ b/functest/core/vnf.py @@ -17,6 +17,7 @@ from snaps.config.user import UserConfig from snaps.config.project import ProjectConfig from snaps.openstack.create_user import OpenStackUser from snaps.openstack.create_project import OpenStackProject +from snaps.openstack.utils import keystone_utils from snaps.openstack.tests import openstack_tests from functest.core import testcase @@ -116,16 +117,31 @@ class VnfOnBoarding(testcase.TestCase): snaps_creds, ProjectConfig( name=self.tenant_name, - description=self.tenant_description + description=self.tenant_description, + domain=snaps_creds.project_domain_name )) self.os_project.create() self.created_object.append(self.os_project) + + snaps_creds.project_domain_id = \ + self.os_project.get_project().domain_id + snaps_creds.user_domain_id = \ + self.os_project.get_project().domain_id + + for role in ['admin', 'Admin']: + if keystone_utils.get_role_by_name( + keystone_utils.keystone_client(snaps_creds), role): + admin_role = role + break + user_creator = OpenStackUser( snaps_creds, UserConfig( name=self.user_name, password=str(uuid.uuid4()), - roles={'admin': self.tenant_name})) + project_name=self.tenant_name, + domain_name=snaps_creds.user_domain_name, + roles={admin_role: self.tenant_name})) user_creator.create() self.created_object.append(user_creator) self.snaps_creds = user_creator.get_os_creds(self.tenant_name) diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py index a6b87ea35..38a40ed83 100644 --- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py +++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py @@ -234,7 +234,9 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase): keystone_password=self.snaps_creds.password, keystone_tenant_name=self.snaps_creds.project_name, keystone_url=public_auth_url, - region=self.snaps_creds.region_name) + region=self.snaps_creds.region_name, + user_domain_name=self.snaps_creds.user_domain_name, + project_domain_name=self.snaps_creds.project_domain_name) self.__logger.info("Set creds for cloudify manager %s", cfy_creds) cfy_client = CloudifyClient( diff --git a/functest/tests/unit/core/test_vnf.py b/functest/tests/unit/core/test_vnf.py index 16a609027..086ee6821 100644 --- a/functest/tests/unit/core/test_vnf.py +++ b/functest/tests/unit/core/test_vnf.py @@ -128,6 +128,9 @@ class VnfBaseTesting(unittest.TestCase): args[2].assert_not_called() @mock.patch('functest.core.vnf.OpenStackUser', side_effect=Exception) + @mock.patch('snaps.openstack.utils.keystone_utils.get_role_by_name', + return_value="admin") + @mock.patch('snaps.openstack.utils.keystone_utils.keystone_client') @mock.patch('functest.core.vnf.OpenStackProject') @mock.patch('snaps.openstack.tests.openstack_tests.get_credentials') def test_prepare_exc3(self, *args): @@ -135,16 +138,23 @@ class VnfBaseTesting(unittest.TestCase): self.test.prepare() args[0].assert_called_with(os_env_file=vnf.VnfOnBoarding.env_file) args[1].assert_called_with(mock.ANY, mock.ANY) - args[2].assert_called_with(mock.ANY, mock.ANY) + args[2].assert_called_with(mock.ANY) + args[3].assert_called_with(mock.ANY, mock.ANY) + args[4].assert_called_with(mock.ANY, mock.ANY) @mock.patch('functest.core.vnf.OpenStackUser') + @mock.patch('snaps.openstack.utils.keystone_utils.get_role_by_name', + return_value="admin") + @mock.patch('snaps.openstack.utils.keystone_utils.keystone_client') @mock.patch('functest.core.vnf.OpenStackProject') @mock.patch('snaps.openstack.tests.openstack_tests.get_credentials') def test_prepare_default(self, *args): self.assertEqual(self.test.prepare(), testcase.TestCase.EX_OK) args[0].assert_called_with(os_env_file=vnf.VnfOnBoarding.env_file) args[1].assert_called_with(mock.ANY, mock.ANY) - args[2].assert_called_with(mock.ANY, mock.ANY) + args[2].assert_called_with(mock.ANY) + args[3].assert_called_with(mock.ANY, mock.ANY) + args[4].assert_called_with(mock.ANY, mock.ANY) def test_deploy_vnf_unimplemented(self): with self.assertRaises(vnf.VnfDeploymentException): |