From 0603e8f7b7a39f760ab06a278583caf5c570f87b Mon Sep 17 00:00:00 2001 From: Pulkit Tandon Date: Fri, 22 Jun 2018 11:42:14 +0530 Subject: [PATCH] For k8s multi cluster support, the project names will be prepended by cluster name of kubernetes. Thus, making corresponding changes in the test infra to handle it. Change-Id: I681724e6de0c6c1f5fb47c8735dbe1e0a4088e90 Closes-bug: #1778179 --- common/contrail_test_init.py | 8 ++++++-- common/k8s/base.py | 7 ++++--- fixtures/k8s/namespace.py | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/common/contrail_test_init.py b/common/contrail_test_init.py index 2b8ce86d2..795d34d69 100755 --- a/common/contrail_test_init.py +++ b/common/contrail_test_init.py @@ -839,10 +839,14 @@ def parse_yml_file(self): self.authn_url = '/v3/auth/tokens' else: self.authn_url = '/v2.0/tokens' - if self.orchestrator == 'kubernetes': - self.admin_tenant = 'default' self.internal_vip = orchestrator_configs.get('internal_vip') self.external_vip = orchestrator_configs.get('external_vip') or self.internal_vip + + #kubernetes specific configs + self.k8s_cluster_name = contrail_configs.get('KUBERNETES_CLUSTER_NAME') or "k8s" + if self.orchestrator == 'kubernetes': + self.admin_tenant = self.k8s_cluster_name + '_default' + # test specific configs self.auth_url = test_configs.get('auth_url') or os.getenv('OS_AUTH_URL', self._gen_auth_url()) diff --git a/common/k8s/base.py b/common/k8s/base.py index e581ec7d2..c2e46b955 100644 --- a/common/k8s/base.py +++ b/common/k8s/base.py @@ -1058,16 +1058,17 @@ def modify_cluster_project(self, project_name = None): if not cp_line or no_match: self.logger.debug("Cluster_project not set in this sanity run. " "Setting it to default project for few tests") - cmd = r'crudini --set /entrypoint.sh KUBERNETES cluster_project \\${KUBERNETES_CLUSTER_PROJECT:-\\"{\'domain\':\'default-domain\'\,\'project\':\'default\'}\\"}' + default_project = self.inputs.admin_tenant + cmd = r'crudini --set /entrypoint.sh KUBERNETES cluster_project \\${KUBERNETES_CLUSTER_PROJECT:-\\"{\'domain\':\'default-domain\'\,\'project\':\'%s\'}\\"}'\ + % default_project operation = "set" - project = "default" for kube_manager in self.inputs.kube_manager_ips: self.inputs.run_cmd_on_server(kube_manager, cmd, container='contrail-kube-manager', shell_prefix = None) self.restart_kube_manager() self.addCleanup(self.revert_cluster_project, - project_name = project, + project_name = default_project, operation = operation) return operation #end modify_cluster_project diff --git a/fixtures/k8s/namespace.py b/fixtures/k8s/namespace.py index 80e89b99d..c375b99eb 100644 --- a/fixtures/k8s/namespace.py +++ b/fixtures/k8s/namespace.py @@ -98,7 +98,7 @@ def get_project_name_for_namespace(self): if project: return project else: - return self.name + return self.inputs.k8s_cluster_name + "_" + self.name @retry(delay=2, tries=10) def verify_namespace_in_contrail_api(self):