From e07ca03ee134886983e420fb974ff6c38855a0d6 Mon Sep 17 00:00:00 2001 From: "Zhang Rong(Jon)" Date: Tue, 2 Aug 2022 15:25:52 +0800 Subject: [PATCH] HelmCLI: profile list use constant Issue-ID: INF-280 Signed-off-by: Zhang Rong(Jon) Change-Id: I0a84363b89be568fb8ea10e1efec286597042a7f --- o2ims/domain/ocloud.py | 12 +++++++++++- o2ims/views/ocloud_view.py | 7 ++++--- tests/unit/test_ocloud.py | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/o2ims/domain/ocloud.py b/o2ims/domain/ocloud.py index 01ea29a..380d919 100644 --- a/o2ims/domain/ocloud.py +++ b/o2ims/domain/ocloud.py @@ -23,6 +23,11 @@ from .resource_type import ResourceTypeEnum # from uuid import UUID +DeploymentManagerProfileDefault = 'default' +DeploymentManagerProfileSOL018 = 'sol018' +DeploymentManagerProfileSOL018HelmCLI = 'sol018_helmcli' + + class DeploymentManager(AgRoot, Serializer): def __init__(self, id: str, name: str, ocloudid: str, dmsendpoint: str, description: str = '', @@ -42,11 +47,16 @@ class DeploymentManager(AgRoot, Serializer): self.extensions = [] def serialize(self): + print(self.__dict__) d = Serializer.serialize(self) if 'profile' in d and d['profile'] != '': d['profile'] = json.loads(d['profile']) - d['profileSupportList'] = ['default', 'sol018'] + d['profileSupportList'] = [ + DeploymentManagerProfileDefault, + DeploymentManagerProfileSOL018, + DeploymentManagerProfileSOL018HelmCLI, + ] return d diff --git a/o2ims/views/ocloud_view.py b/o2ims/views/ocloud_view.py index 83be178..56f970d 100644 --- a/o2ims/views/ocloud_view.py +++ b/o2ims/views/ocloud_view.py @@ -20,6 +20,7 @@ from datetime import datetime import shutil from o2common.service import unit_of_work +from o2ims.domain import ocloud from o2ims.views.ocloud_dto import SubscriptionDTO from o2ims.domain.subscription_obj import Subscription @@ -119,13 +120,13 @@ def deployment_manager_one(deploymentManagerId: str, profile_data = result.pop("profile", None) result['profileName'] = profile - if "default" == profile: + if ocloud.DeploymentManagerProfileDefault == profile: pass - elif "sol018" == profile: + elif ocloud.DeploymentManagerProfileSOL018 == profile: result['deploymentManagementServiceEndpoint'] = \ profile_data['cluster_api_endpoint'] result['profileData'] = profile_data - elif "sol018_helmcli" == profile: + elif ocloud.DeploymentManagerProfileSOL018HelmCLI == profile: result['deploymentManagementServiceEndpoint'] = \ profile_data['cluster_api_endpoint'] diff --git a/tests/unit/test_ocloud.py b/tests/unit/test_ocloud.py index 461fa41..3359230 100644 --- a/tests/unit/test_ocloud.py +++ b/tests/unit/test_ocloud.py @@ -290,7 +290,7 @@ def test_view_deployment_manager_one(mock_uow): assert deployment_manager_res.get('profile') is None # profile sol018 - profileName = 'sol018' + profileName = ocloud.DeploymentManagerProfileSOL018 cluster_endpoint = "https://test_k8s:6443" session.return_value.query.return_value.filter_by.return_value.first.\ return_value.serialize.return_value['profile'] = { -- 2.16.6