Fix INF-332 and INF-333 that the response of the POST
[pti/o2.git] / o2ims / views / ocloud_view.py
index eb6c79f..953adc9 100644 (file)
@@ -128,7 +128,8 @@ def deployment_managers(uow: unit_of_work.AbstractUnitOfWork, **kwargs):
 
 def deployment_manager_one(deploymentManagerId: str,
                            uow: unit_of_work.AbstractUnitOfWork,
-                           profile: str = 'default'):
+                           profile: str =
+                           ocloud.DeploymentManagerProfileDefault):
     profile = profile.lower()
     with uow:
         first = uow.deployment_managers.get(deploymentManagerId)
@@ -140,15 +141,17 @@ def deployment_manager_one(deploymentManagerId: str,
 
     profile_data = result.pop("profile", None)
     result['profileName'] = profile
+    profiles = config.get_dms_support_profiles()
+    if profile not in profiles:
+        return ""
 
-    if ocloud.DeploymentManagerProfileDefault == profile:
-        pass
-    elif ocloud.DeploymentManagerProfileSOL018 == profile:
-        result['deploymentManagementServiceEndpoint'] = \
+    if ocloud.DeploymentManagerProfileDefault == profile \
+            or ocloud.DeploymentManagerProfileSOL018 == profile:
+        result['serviceUri'] = \
             profile_data['cluster_api_endpoint']
         result['profileData'] = profile_data
     elif ocloud.DeploymentManagerProfileSOL018HelmCLI == profile:
-        result['deploymentManagementServiceEndpoint'] = \
+        result['serviceUri'] = \
             profile_data['cluster_api_endpoint']
 
         helmcli_profile = dict()
@@ -159,7 +162,7 @@ def deployment_manager_one(deploymentManagerId: str,
             deploymentManagerId, profile_data)
         result['profileData'] = helmcli_profile
     else:
-        return None
+        return ""
 
     return result
 
@@ -215,7 +218,7 @@ def subscription_one(subscriptionId: str,
         return first.serialize() if first is not None else None
 
 
-def subscription_create(subscriptionDto: SubscriptionDTO.subscription,
+def subscription_create(subscriptionDto: SubscriptionDTO.subscription_create,
                         uow: unit_of_work.AbstractUnitOfWork):
 
     sub_uuid = str(uuid.uuid4())
@@ -226,7 +229,8 @@ def subscription_create(subscriptionDto: SubscriptionDTO.subscription,
     with uow:
         uow.subscriptions.add(subscription)
         uow.commit()
-    return {"subscriptionId": sub_uuid}
+        first = uow.subscriptions.get(sub_uuid)
+        return first.serialize()
 
 
 def subscription_delete(subscriptionId: str,