HelmCLI: profile list use constant 16/8816/1
authorZhang Rong(Jon) <rong.zhang@windriver.com>
Tue, 2 Aug 2022 07:25:52 +0000 (15:25 +0800)
committerZhang Rong(Jon) <rong.zhang@windriver.com>
Tue, 2 Aug 2022 07:25:52 +0000 (15:25 +0800)
Issue-ID: INF-280
Signed-off-by: Zhang Rong(Jon) <rong.zhang@windriver.com>
Change-Id: I0a84363b89be568fb8ea10e1efec286597042a7f

o2ims/domain/ocloud.py
o2ims/views/ocloud_view.py
tests/unit/test_ocloud.py

index 01ea29a..380d919 100644 (file)
@@ -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
 
index 83be178..56f970d 100644 (file)
@@ -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']
 
index 461fa41..3359230 100644 (file)
@@ -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'] = {