Construct multicloud infra_workload endpoint

Use the cloudOwner and cloudRegion to construct the
multicloud endpoint for the multicloud VNF plugin adapter.
Use configuration to obtain the MSB IP and port number.
Stop using the cloud sites catalog DB since there is only
a single endpoint required talking to multicloud.

Change-Id: I0e9b45a51b6e36f4782226f851e7d01de7f1b133
Issue-ID: SO-1447
Signed-off-by: Eric Multanen <eric.w.multanen@intel.com>
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
index 62c373b..0dad10b 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
@@ -707,29 +707,32 @@
 
         //  Perform a version check against cloudSite
         // Obtain the cloud site information where we will create the VF Module
+        Boolean usingMulticloud = false;
         Optional<CloudSite> cloudSiteOp = cloudConfig.getCloudSite (cloudSiteId);
         if (!cloudSiteOp.isPresent()) {
-            throw new VnfException (new MsoCloudSiteNotFound (cloudSiteId));
-        }
-        CloudSite cloudSite = cloudSiteOp.get();
-		MavenLikeVersioning aicV = new MavenLikeVersioning();
-		aicV.setVersion(cloudSite.getCloudVersion());
-		Boolean usingMulticloud = getUsingMulticloud(cloudSite);
+            // If cloudSiteId is not present in the catalog DB, then default to multicloud
+            usingMulticloud = true;
+        } else {
+            CloudSite cloudSite = cloudSiteOp.get();
+    		MavenLikeVersioning aicV = new MavenLikeVersioning();
+    		aicV.setVersion(cloudSite.getCloudVersion());
+    		usingMulticloud = getUsingMulticloud(cloudSite);
 
-		String vnfMin = vnfResource.getAicVersionMin();
-		String vnfMax = vnfResource.getAicVersionMax();
+    		String vnfMin = vnfResource.getAicVersionMin();
+    		String vnfMax = vnfResource.getAicVersionMax();
 
-        if ((vnfMin != null && !(aicV.isMoreRecentThan(vnfMin) || aicV.isTheSameVersion(vnfMin))) || (vnfMax != null
-            && aicV.isMoreRecentThan(vnfMax))) {
-            // ERROR
-            String error =
-                "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID()
-                    + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " + cloudSiteId
-                    + " with AIC_Version:" + cloudSite.getCloudVersion();
-            logger.error("{} {} {} {} {}", MessageEnum.RA_CONFIG_EXC.toString(), error, "OpenStack",
-                ErrorCode.BusinessProcesssError.getValue(), "Exception - setVersion");
-            logger.debug(error);
-            throw new VnfException(error, MsoExceptionCategory.USERDATA);
+            if ((vnfMin != null && !(aicV.isMoreRecentThan(vnfMin) || aicV.isTheSameVersion(vnfMin))) || (vnfMax != null
+                && aicV.isMoreRecentThan(vnfMax))) {
+                // ERROR
+                String error =
+                    "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID()
+                        + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " + cloudSiteId
+                        + " with AIC_Version:" + cloudSite.getCloudVersion();
+                logger.error("{} {} {} {} {}", MessageEnum.RA_CONFIG_EXC.toString(), error, "OpenStack",
+                    ErrorCode.BusinessProcesssError.getValue(), "Exception - setVersion");
+                logger.debug(error);
+                throw new VnfException(error, MsoExceptionCategory.USERDATA);
+            }
         }
         // End Version check
 
@@ -1261,12 +1264,16 @@
     		else if (orchestrator.equalsIgnoreCase("HEAT")) {
     			return heatUtils;
     		}
-            if (orchestrator.equalsIgnoreCase("MULTICLOUD")) {
-                logger.debug ("Got MulticloudUtils for vduPlugin");
-                return multicloudUtils; }
+            else if (orchestrator.equalsIgnoreCase("MULTICLOUD")) {
+                return multicloudUtils;
+            }
+            else {
+                // Default if cloudSite record exists - return HEAT plugin - will fail later
+    			return heatUtils;
+            }
     	}
-        // Default - return HEAT plugin, though will fail later
-    	return heatUtils;
+        // Default if no cloudSite record exists - return multicloud plugin
+    	return multicloudUtils;
     }
 
     private Boolean getUsingMulticloud (CloudSite cloudSite) {
diff --git a/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml b/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml
index 936bde1..2ec5be7 100644
--- a/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml
+++ b/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml
@@ -52,6 +52,8 @@
   msoKey: 07a7159d3bf51a0e53be7a8f89699be7
   auth: 6B466C603A260F3655DBF91E53CE54667041C01406D10E8CAF9CC24D8FA5388D06F90BFE4C852052B436
   logPath: logs
+  msb-ip: localhost
+  msb-port: ${wiremock.server.port}
   workflow:
     endpoint: http://bpmn-infra:8081/sobpmnengine
     topics:
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
index 152c23e..f3ad4e6 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
@@ -53,7 +53,7 @@
     @Before
     public void before() throws Exception {
         super.orchestrator = "multicloud";
-        super.cloudEndpoint = "/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload";
+        super.cloudEndpoint = "/api/multicloud/v1/CloudOwner/MTN13/infra_workload";
         super.setUp();
     }
 
@@ -70,19 +70,19 @@
         msoRequest.setRequestId("12345");
         msoRequest.setServiceInstanceId("12345");
 
-        wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/vfname")).willReturn(aResponse()
+        wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/vfname")).willReturn(aResponse()
                 //.withHeader()
                 .withStatus(HttpStatus.SC_NOT_FOUND)));
 
-        wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
+        wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id")).willReturn(aResponse()
                 //.withHeader()
                 .withBodyFile("MulticloudResponse_Stack.json")
                 .withStatus(HttpStatus.SC_OK)));
 
-        wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/vfname/outputs")).willReturn(aResponse()
+        wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/vfname/outputs")).willReturn(aResponse()
                 .withStatus(HttpStatus.SC_NOT_FOUND)));
 
-        wireMockServer.stubFor(post(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload")).willReturn(aResponse()
+        wireMockServer.stubFor(post(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload")).willReturn(aResponse()
                 .withBodyFile("MulticloudResponse_Stack_Create.json")
                 .withStatus(HttpStatus.SC_CREATED)));
 
@@ -95,11 +95,11 @@
         msoRequest.setRequestId("12345");
         msoRequest.setServiceInstanceId("12345");
 
-        wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
+        wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id")).willReturn(aResponse()
                 .withBodyFile("MulticloudResponse_Stack.json")
                 .withStatus(HttpStatus.SC_OK)));
 
-        wireMockServer.stubFor(delete(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
+        wireMockServer.stubFor(delete(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id")).willReturn(aResponse()
                 .withStatus(HttpStatus.SC_NO_CONTENT)));
 
         instance.deleteVfModule("MTN13", "CloudOwner", "123", "workload-id", msoRequest, new Holder<>());
@@ -111,7 +111,7 @@
         msoRequest.setRequestId("12345");
         msoRequest.setServiceInstanceId("12345");
 
-        wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/cloud_owner/cloud_region_id/infra_workload/workload-id")).willReturn(aResponse()
+        wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id")).willReturn(aResponse()
                 .withBodyFile("MulticloudResponse_Stack.json")
                 .withStatus(HttpStatus.SC_OK)));
 
diff --git a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml
index 398885c..8da26e9 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml
+++ b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml
@@ -64,6 +64,8 @@
   max-threads: 50
 mso:
   logPath: logs
+  msb-ip: localhost
+  msb-port: ${wiremock.server.port}
   catalog:
     db:
       spring: