Fix msb url in homing cloudsite 94/71694/1
authorMarcus G K Williams <marcus.williams@intel.com>
Thu, 1 Nov 2018 21:35:21 +0000 (14:35 -0700)
committerMarcus G K Williams <marcus.williams@intel.com>
Thu, 1 Nov 2018 21:35:32 +0000 (14:35 -0700)
This change adds a getMsbHost method
to homingUtils to enable correct configuration
of the msburl used in identity_services for
multicloud.

Issue-ID: SO-1180
Change-Id: Ib7adecda98b1d5f5770e2d17a2e76c970619ab46
Signed-off-by: Marcus G K Williams <marcus.williams@intel.com>
bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/UrnPropertiesReader.java

index 533df72..c8736b8 100644 (file)
@@ -250,7 +250,7 @@ class OofHoming extends AbstractServiceTaskProcessor {
                             resource.getHomingSolution().setCloudOwner(cloudOwner)
                             resource.getHomingSolution().setCloudRegionId(cloudRegionId)
 
-                            CloudSite cloudSite = new CloudSite();
+                            CloudSite cloudSite = new CloudSite()
                             cloudSite.setId(cloudRegionId)
                             cloudSite.setRegionId(cloudRegionId)
                             String orchestrator = execution.getVariable("orchestrator")
@@ -258,10 +258,18 @@ class OofHoming extends AbstractServiceTaskProcessor {
                                 cloudSite.setOrchestrator(orchestrator)
                             }
 
-                            CloudIdentity cloudIdentity = new CloudIdentity();
-                            cloudIdentity.setId(cloudRegionId);
-                            cloudIdentity.setIdentityUrl("/api/multicloud /v1/" + cloudOwner + "/" + cloudRegionId + "/infra_workload")
-                            cloudSite.setIdentityService(cloudIdentity);
+                            CloudIdentity cloudIdentity = new CloudIdentity()
+                            cloudIdentity.setId(cloudRegionId)
+                            // Get MSB Url
+                            String msbHost = oofUtils.getMsbHost(execution)
+                            String multicloudApiEndpoint = UrnPropertiesReader
+                                    .getVariable("mso.multicloud.api.endpoint", execution,
+                                    "/api/multicloud-titaniumcloud/v1")
+                            cloudIdentity.setIdentityUrl(msbHost + multicloudApiEndpoint
+                                    + "/" + cloudOwner + "/" +
+                                    cloudRegionId + "/infra_workload")
+
+                            cloudSite.setIdentityService(cloudIdentity)
 
                             // Set cloudsite in catalog DB here
                             oofUtils.createCloudSiteCatalogDb(cloudSite)
index 197589e..ae1079a 100644 (file)
@@ -526,4 +526,12 @@ class OofUtils {
             exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from CatalogDB.")
         }
     }
+
+     String getMsbHost(DelegateExecution execution) {
+         msbHost = UrnPropertiesReader.getVariable("mso.msb.host", execution, "msb-iag.onap")
+
+         Integer msbPort = UrnPropertiesReader.getVariable("mso.msb.port", execution, "80").toInteger()
+
+         return UriBuilder.fromPath("").host(msbHost).port(msbPort).scheme("http").build().toString()
+    }
 }
index 968c8c1..750cd24 100644 (file)
@@ -69,6 +69,10 @@ public class UrnPropertiesReader {
         return variableValue;
     }
 
+    public static String getVariable(String variableName, DelegateExecution execution, String defaultValue) {
+        return Optional.ofNullable(getVariable(variableName, execution)).orElse(defaultValue);
+    }
+
     /**
      * Return the URN property value from the environment object
      * @param variableName URN property name