Merge "Fix Cloud Version" into casablanca
authorSeshu Kumar M <seshu.kumar.m@huawei.com>
Tue, 4 Dec 2018 06:44:02 +0000 (06:44 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 4 Dec 2018 06:44:02 +0000 (06:44 +0000)
48 files changed:
adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java
adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.16__Add_Default_NeutronNetwork.sql
adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.19__RenameCustomToNoValidate.sql [new file with mode: 0644]
adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.20__SetActivitiesBBsToNoValidate.sql [new file with mode: 0644]
adapters/mso-catalog-db-adapter/src/main/resources/db/migration/v4.21_AddHomingTables.sql [new file with mode: 0644]
adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql
adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java
adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/CXFConfiguration.java
adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/WebSecurityConfigImpl.java [new file with mode: 0644]
adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java
asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
bpmn/MSOCommonBPMN/pom.xml
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/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java [new file with mode: 0644]
bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/RollbackData.java
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java [new file with mode: 0644]
common/src/main/java/org/onap/so/client/HttpClient.java
docs/api/offered_consumed_apis.rst
docs/release-notes.rst [moved from docs/release_notes/release-notes.rst with 62% similarity]
mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java [new file with mode: 0644]
mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatusValidationDirective.java
mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java
mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResource.java
mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HomingInstanceRepository.java [new file with mode: 0644]
so-monitoring/so-monitoring-ui/src/main/frontend/src/app/data.service.ts
so-monitoring/so-monitoring-ui/src/main/frontend/src/app/details/details.component.ts
so-monitoring/so-monitoring-ui/src/main/frontend/src/environments/environment.ts
version.properties

index d036468..73e0da1 100644 (file)
@@ -45,6 +45,7 @@ import org.onap.so.adapters.vdu.VduStateType;
 import org.onap.so.adapters.vdu.VduStatus;
 import org.onap.so.openstack.beans.HeatStatus;
 import org.onap.so.openstack.beans.StackInfo;
+import org.onap.so.openstack.exceptions.MsoAdapterException;
 import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
 import org.onap.so.openstack.exceptions.MsoException;
 import org.onap.so.openstack.exceptions.MsoOpenstackException;
@@ -149,8 +150,8 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
         logger.trace("Started MsoMulticloudUtils.createStack");
 
         // Get the directives, if present.
-        String oofDirectives = "";
-        String sdncDirectives = "";
+        String oofDirectives = "{}";
+        String sdncDirectives = "{}";
         String genericVnfId = "";
         String vfModuleId = "";
         String templateType = "";
@@ -185,26 +186,17 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
 
         MulticloudRequest multicloudRequest= new MulticloudRequest();
 
-        try {
-            multicloudRequest.setGenericVnfId(genericVnfId);
-            multicloudRequest.setVfModuleId(vfModuleId);
-            multicloudRequest.setOofDirectives(JSON_MAPPER.readTree(oofDirectives));
-            multicloudRequest.setSdncDirectives(JSON_MAPPER.readTree(sdncDirectives));
-            multicloudRequest.setTemplateType(templateType);
-            if (logger.isDebugEnabled()) {
-                logger.debug(String.format("Stack Template Data is: %s", stack.toString().substring(16)));
-            }
-            multicloudRequest.setTemplateData(stack);
-            if (logger.isDebugEnabled()) {
-                logger.debug(String.format("Multicloud Request is: %s", multicloudRequest.toString()));
-            }
-        } catch (Exception e) {
-            logger.debug("ERROR making multicloud JSON body ", e);
-        }
-        String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, null);
+        multicloudRequest.setGenericVnfId(genericVnfId);
+        multicloudRequest.setVfModuleId(vfModuleId);
+        multicloudRequest.setTemplateType(templateType);
+        multicloudRequest.setTemplateData(stack);
+        multicloudRequest.setOofDirectives(getDirectiveNode(oofDirectives));
+        multicloudRequest.setSdncDirectives(getDirectiveNode(sdncDirectives));
         if (logger.isDebugEnabled()) {
-            logger.debug(String.format("Multicloud Endpoint is: %s", multicloudEndpoint));
+            logger.debug(String.format("Multicloud Request is: %s", multicloudRequest.toString()));
         }
+
+        String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, null);
         RestClient multicloudClient = getMulticloudClient(multicloudEndpoint);
 
         Response response = multicloudClient.post(multicloudRequest);
@@ -617,6 +609,21 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
         return client;
     }
 
+    private JsonNode getDirectiveNode(String directives) throws MsoException {
+        try {
+            return JSON_MAPPER.readTree(directives);
+        } catch (Exception e) {
+            logger.error(String.format("%d %s %s %s %d %s",
+                    MessageEnum.RA_CREATE_STACK_ERR,
+                    "Create Stack: " + e, "", "",
+                    MsoLogger.ErrorCode.BusinessProcesssError,
+                    "Exception in Create Stack: Invalid JSON format of directives" + directives));
+            MsoException me = new MsoAdapterException("Invalid JSON format of directives parameter: " + directives);
+            me.addContext(CREATE_STACK);
+            throw me;
+        }
+    }
+
     /**
      * VduPlugin interface for instantiate function.
      *
index 8a7b7a2..9bcbe16 100644 (file)
@@ -588,7 +588,7 @@ public class CatalogDbAdapterRest {
 
                 if (null == recipe) {
                     NetworkResource nResource = networkResourceRepo.findResourceByModelUUID(rmUuid);
-                    recipe = networkRecipeRepo.findFirstByModelNameAndActionAndVersionStr(nResource.getModelName(), action, vnf.getModelVersion());
+                    recipe = networkRecipeRepo.findFirstByModelNameAndActionAndVersionStr(nResource.getModelName(), action, nResource.getModelVersion());
 
                     // for network fetch the default recipe
                     if (recipe == null) {
index 3ad4b31..47c540b 100644 (file)
@@ -1,7 +1,28 @@
 USE catalogdb;
 
 INSERT INTO `heat_template` (`ARTIFACT_UUID`,`NAME`,`VERSION`,`BODY`,`TIMEOUT_MINUTES`,`DESCRIPTION`,`CREATION_TIMESTAMP`,`ARTIFACT_CHECKSUM`) VALUES
-('efee1d84-b8ec-11e7-abc4-cec278b6b50a','Generic NeutronNet','1','heat_template_version: 2013-05-23\n\ndescription:\n HOT template that creates a Generic Neutron Network\n\nparameters:\n network_name:\n type: string\n description: Name of direct network (e.g. core, dmz)\n default: ECOMPNetwork\n network_subnet_name:\n type: string\n description: Name of subnet network (e.g. core, dmz)\n default: ECOMPNetwork\n network_subnet_cidr:\n type: string\n description: CIDR of subnet network (e.g. core, dmz)\n default: 10.0.0.0/16\n\noutputs:\n network_id:\n description: Openstack network identifier\n value: { get_resource: network }\n network_fqdn:\n description: Openstack network identifier\n value: {list_join: [\':\', { get_attr: [network, fq_name] } ] }\n\nresources:\n network:\n type: OS::Neutron::Net\n properties:\n name: {get_param: network_name }\n\n subnet:\n type: OS::Neutron::Subnet\n properties:\n name: { get_param: network_subnet_name }\n network_id: { get_resource: network }\n cidr: { get_param: network_subnet_cidr }\n enable_dhcp: false\n',10,'Generic Neutron Template','2017-10-26 14:44:00', 'MANUAL RECORD');
+('efee1d84-b8ec-11e7-abc4-cec278b6b50a','Generic NeutronNet','1','
+heat_template_version: 2013-05-23
+description: A simple Neutron network
+parameters:
+ network_name:
+   type: string
+   description: Name of the Neutron Network
+   default: ONAP-NW1
+ shared:
+   type: boolean
+   description: Shared amongst tenants
+   default: False
+outputs:
+  network_id:
+    description: Openstack network identifier
+    value: { get_resource: network }
+resources:
+   network:
+     type: OS::Neutron::Net
+     properties:
+       name: { get_param: network_name }
+       shared: { get_param: shared }',10,'Generic Neutron Template','2017-10-26 14:44:00', 'MANUAL RECORD');
 
 
 
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.19__RenameCustomToNoValidate.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.19__RenameCustomToNoValidate.sql
new file mode 100644 (file)
index 0000000..bded179
--- /dev/null
@@ -0,0 +1,2 @@
+update building_block_detail set RESOURCE_TYPE = "NO_VALIDATE" where RESOURCE_TYPE = "CUSTOM";
+update orchestration_status_state_transition_directive set RESOURCE_TYPE = "NO_VALIDATE" where RESOURCE_TYPE = "CUSTOM";
\ No newline at end of file
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.20__SetActivitiesBBsToNoValidate.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.20__SetActivitiesBBsToNoValidate.sql
new file mode 100644 (file)
index 0000000..9f51ed1
--- /dev/null
@@ -0,0 +1,13 @@
+USE catalogdb;
+
+INSERT INTO building_block_detail (BUILDING_BLOCK_NAME, RESOURCE_TYPE, TARGET_ACTION)
+VALUES
+('FlowCompleteActivity', 'NO_VALIDATE', 'CUSTOM'),
+('VNFHealthCheckActivity', 'NO_VALIDATE', 'CUSTOM'),
+('VNFQuiesceTrafficActivity', 'NO_VALIDATE', 'CUSTOM'),
+('VNFResumeTrafficActivity', 'NO_VALIDATE', 'CUSTOM'),
+('VNFSetInMaintFlagActivity', 'NO_VALIDATE', 'CUSTOM'),
+('VNFUnsetInMaintFlagActivity', 'NO_VALIDATE', 'CUSTOM'),
+('VNFUpgradePostCheckActivity', 'NO_VALIDATE', 'CUSTOM'),
+('VNFUpgradePreCheckActivity', 'NO_VALIDATE', 'CUSTOM'),
+('VNFUpgradeSoftwareActivity', 'NO_VALIDATE', 'CUSTOM');
\ No newline at end of file
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/v4.21_AddHomingTables.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/v4.21_AddHomingTables.sql
new file mode 100644 (file)
index 0000000..a2ebe04
--- /dev/null
@@ -0,0 +1,7 @@
+CREATE TABLE IF NOT EXISTS `homing_instances` (
+`SERVICE_INSTANCE_ID` varchar(50) NOT NULL,
+`CLOUD_OWNER` VARCHAR(200) NOT NULL,
+`CLOUD_REGION_ID` VARCHAR(200) NOT NULL,
+`OOF_DIRECTIVES` longtext NULL DEFAULT NULL,
+PRIMARY KEY (`SERVICE_INSTANCE_ID`)
+) ;
\ No newline at end of file
index c85a4c2..8c990a1 100644 (file)
@@ -33,6 +33,7 @@ import org.onap.so.db.catalog.beans.CloudIdentity;
 import org.onap.so.db.catalog.beans.CloudSite;
 import org.onap.so.db.catalog.beans.CloudifyManager;
 import org.onap.so.db.catalog.beans.ExternalServiceToInternalService;
+import org.onap.so.db.catalog.beans.HomingInstance;
 import org.onap.so.db.catalog.beans.InstanceGroup;
 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
 import org.onap.so.db.catalog.beans.ServerType;
@@ -414,6 +415,80 @@ public class CatalogDbClientTest {
         Assert.assertEquals("RANDOMID", getCloudSite.getIdentityServiceId());
     }
 
+    @Test
+    public void testGetHomingInstance() {
+        HomingInstance homingInstance = client.getHomingInstance("5df8b6de-2083-11e7-93ae-92361f232671");
+        Assert.assertNotNull(homingInstance);
+        Assert.assertNotNull(homingInstance.getCloudOwner());
+        Assert.assertNotNull(homingInstance.getCloudRegionId());
+        Assert.assertNotNull(homingInstance.getOofDirectives());
+    }
+
+    @Test
+    public void testPostHomingInstance() {
+        CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger("http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
+        HomingInstance homingInstance = new HomingInstance();
+        homingInstance.setServiceInstanceId("5df8d6be-2083-11e7-93ae-92361f232671");
+        homingInstance.setCloudOwner("CloudOwner-1");
+        homingInstance.setCloudRegionId("CloudRegionOne");
+        homingInstance.setOofDirectives("{\n" +
+                "\"directives\": [\n" +
+                "{\n" +
+                "\"directives\": [\n" +
+                "{\n" +
+                "\"attributes\": [\n" +
+                "{\n" +
+                "\"attribute_value\": \"onap.hpa.flavor31\",\n" +
+                "\"attribute_name\": \"firewall_flavor_name\"\n" +
+                "}\n" +
+                "],\n" +
+                "\"type\": \"flavor_directives\"\n" +
+                "}\n" +
+                "],\n" +
+                "\"type\": \"vnfc\",\n" +
+                "\"id\": \"vfw\"\n" +
+                "},\n" +
+                "{\n" +
+                "\"directives\": [\n" +
+                "{\n" +
+                "\"attributes\": [\n" +
+                "{\n" +
+                "\"attribute_value\": \"onap.hpa.flavor32\",\n" +
+                "\"attribute_name\": \"packetgen_flavor_name\"\n" +
+                "}\n" +
+                "],\n" +
+                "\"type\": \"flavor_directives\"\n" +
+                "}\n" +
+                "],\n" +
+                "\"type\": \"vnfc\",\n" +
+                "\"id\": \"vgenerator\"\n" +
+                "},\n" +
+                "{\n" +
+                "\"directives\": [\n" +
+                "{\n" +
+                "\"attributes\": [\n" +
+                "{\n" +
+                "\"attribute_value\": \"onap.hpa.flavor31\",\n" +
+                "\"attribute_name\": \"sink_flavor_name\"\n" +
+                "}\n" +
+                "],\n" +
+                "\"type\": \"flavor_directives\"\n" +
+                "}\n" +
+                "],\n" +
+                "\"type\": \"vnfc\",\n" +
+                "\"id\": \"vsink\"\n" +
+                "}\n" +
+                "]\n" +
+                "}");
+        localClient.postHomingInstance(homingInstance);
+        HomingInstance getHomingInstance = this.client.getHomingInstance("5df8d6be-2083-11e7-93ae-92361f232671");
+        Assert.assertNotNull(getHomingInstance);
+        Assert.assertNotNull(getHomingInstance.getCloudRegionId());
+        Assert.assertNotNull(getHomingInstance.getCloudOwner());
+        Assert.assertEquals("CloudOwner-1", getHomingInstance.getCloudOwner());
+        Assert.assertEquals("CloudRegionOne", getHomingInstance.getCloudRegionId());
+    }
+
    @Test
     public void testGetServiceByModelName() {
         Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service");
index c847556..7ac3c53 100644 (file)
@@ -49,6 +49,14 @@ CREATE TABLE IF NOT EXISTS `cloud_sites` (
   CONSTRAINT `FK_cloud_sites_identity_services` FOREIGN KEY (`IDENTITY_SERVICE_ID`) REFERENCES `identity_services` (`ID`)
 ) ;
 
+CREATE TABLE IF NOT EXISTS `homing_instances` (
+`SERVICE_INSTANCE_ID` varchar(50) NOT NULL,
+`CLOUD_OWNER` VARCHAR(200) NOT NULL,
+`CLOUD_REGION_ID` VARCHAR(200) NOT NULL,
+`OOF_DIRECTIVES` longtext NULL DEFAULT NULL,
+PRIMARY KEY (`SERVICE_INSTANCE_ID`)
+) ;
+
 insert into heat_files(artifact_uuid, name, version, description, body, artifact_checksum, creation_timestamp) values
 ('00535bdd-0878-4478-b95a-c575c742bfb0', 'nimbus-ethernet-gw', '1', 'created from csar', 'DEVICE=$dev\nBOOTPROTO=none\nNM_CONTROLLED=no\nIPADDR=$ip\nNETMASK=$netmask\nGATEWAY=$gateway\n', 'MANUAL RECORD', '2017-01-21 23:56:43');
 
@@ -203,4 +211,8 @@ VALUES
 
 INSERT INTO vnf_components_recipe (VNF_COMPONENT_TYPE, ACTION, VERSION, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT, VF_MODULE_MODEL_UUID)
 VALUES
-('volumeGroup', 'createInstance', '1', 'Gr api recipe to create volume-group', '/mso/async/services/WorkflowActionBB', 180, '20c4431c-246d-11e7-93ae-92361f002671');
\ No newline at end of file
+('volumeGroup', 'createInstance', '1', 'Gr api recipe to create volume-group', '/mso/async/services/WorkflowActionBB', 180, '20c4431c-246d-11e7-93ae-92361f002671');
+
+insert into homing_instances (service_instance_id, cloud_owner, cloud_region_id, oof_directives) values
+('5df8b6de-2083-11e7-93ae-92361f232671', 'CloudOwner', 'CloudRegionId', '{"directives": [{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "firewall_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vfw"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor33","attribute_name": "packetgen_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vgenerator"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "sink_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vsink"}]}'),
+('5df8b6de-2083-11e7-93ae-92361f562672', 'CloudOwner', 'CloudRegionId', '{"directives": [{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "firewall_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vfw"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor33","attribute_name": "packetgen_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vgenerator"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "sink_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vsink"}]}');
\ No newline at end of file
index b6f1ad1..20c2231 100644 (file)
@@ -67,8 +67,8 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils{
     public void createVfModule() throws Exception {
         //expectedException.expect(VnfException.class);
         Map<String, String> stackInputs = new HashMap<>();
-        stackInputs.put("oof_directives", "{oofDIRECTIVES}");
-        stackInputs.put("sdnc_directives", "{sdncDIRECTIVES}");
+        stackInputs.put("oof_directives", "{}");
+        stackInputs.put("sdnc_directives", "{}");
         stackInputs.put("generic_vnf_id", "genVNFID");
         stackInputs.put("vf_module_id", "vfMODULEID");
 
index 762c76f..a849478 100644 (file)
@@ -23,6 +23,8 @@
 package org.onap.so.adapters.requestsdb;
 
 import java.sql.Timestamp;
+import java.util.List;
+
 import javax.jws.WebService;
 import javax.transaction.Transactional;
 import org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException;
@@ -334,5 +336,65 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
                resStatus.setErrorCode(errorCode);
                resStatus.setStatusDescription(statusDescription);
                resourceOperationStatusRepository.save(resStatus);
+               
+               updateOperationStatusBasedOnResourceStatus(resStatus);
        }
+       
+    /**
+     * update service operation status when a operation resource status updated
+     * <br>
+     * 
+     * @param operStatus the resource operation status
+     * @since ONAP Amsterdam Release
+     */
+    private void updateOperationStatusBasedOnResourceStatus(ResourceOperationStatus operStatus) {
+       String serviceId = operStatus.getServiceId();
+        String operationId = operStatus.getOperationId();
+
+        logger.debug("Request database - update Operation Status Based On Resource Operation Status with service Id:"
+                + serviceId + ", operationId:" + operationId);
+        
+        List<ResourceOperationStatus> lstResourceStatus = resourceOperationStatusRepository.findByServiceIdAndOperationId(serviceId, operationId);
+               if (lstResourceStatus == null) {
+                       logger.error("Unable to retrieve resourceOperStatus Object by ServiceId: " + serviceId + " operationId: " + operationId);
+                       return;
+               }
+               
+               // count the total progress
+        int resourceCount = lstResourceStatus.size();
+        int progress = 0;
+        boolean isFinished = true;
+        for (ResourceOperationStatus lstResourceStatu : lstResourceStatus) {
+            progress = progress + Integer.valueOf(lstResourceStatu.getProgress()) / resourceCount;
+            if (RequestsDbConstant.Status.PROCESSING.equals(lstResourceStatu.getStatus())) {
+                isFinished = false;
+            }
+        }
+        
+        OperationStatus serviceOperStatus = operationStatusRepository.findOneByServiceIdAndOperationId(serviceId, operationId);
+               if (serviceOperStatus == null) {
+                       String error = "Entity not found. Unable to retrieve OperationStatus Object ServiceId: " + serviceId + " operationId: "
+                                       + operationId;
+                       logger.error(error);
+                       
+                       serviceOperStatus = new OperationStatus();
+                       serviceOperStatus.setOperationId(operationId);
+                       serviceOperStatus.setServiceId(serviceId);
+               }
+        
+        progress = progress > 100 ? 100 : progress;
+        serviceOperStatus.setProgress(String.valueOf(progress));
+        serviceOperStatus.setOperationContent(operStatus.getStatusDescription());
+        // if current resource failed. service failed.
+        if(RequestsDbConstant.Status.ERROR.equals(operStatus.getStatus())) {
+            serviceOperStatus.setResult(RequestsDbConstant.Status.ERROR);
+            serviceOperStatus.setReason(operStatus.getStatusDescription());
+        } else if(isFinished) {
+            // if finished
+            serviceOperStatus.setResult(RequestsDbConstant.Status.FINISHED);
+            serviceOperStatus.setProgress(RequestsDbConstant.Progress.ONE_HUNDRED);
+        }
+
+        operationStatusRepository.save(serviceOperStatus);
+    }
 }
index f842e78..3276931 100644 (file)
@@ -87,7 +87,7 @@ public class SDNCRestClient{
                // Added delay to allow completion of create request to SDNC
                // before executing activate of create request.
                try {
-                       Thread.sleep(1000);
+                       Thread.sleep(5000);
                } catch (InterruptedException e) {
                        e.printStackTrace();
                }
index 031bc2e..ea1c380 100644 (file)
@@ -79,11 +79,11 @@ public class CXFConfiguration {
        public Swagger2Feature createSwaggerFeature() {
                Swagger2Feature swagger2Feature = new Swagger2Feature();
                swagger2Feature.setPrettyPrint(true);
-               swagger2Feature.setTitle("SO Request Adapter");
+               swagger2Feature.setTitle("SO VFC Adapter");
                swagger2Feature.setContact("The ONAP SO team");
                swagger2Feature.setDescription("This project is the SO Orchestration Engine");
                swagger2Feature.setVersion("1.0.0");
-               swagger2Feature.setResourcePackage("org.onap.so.adapters.requestdb");
+               swagger2Feature.setResourcePackage("org.onap.so.adapters.vfc.rest");
                swagger2Feature.setScan(true);
                return swagger2Feature;
        }
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/WebSecurityConfigImpl.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/WebSecurityConfigImpl.java
new file mode 100644 (file)
index 0000000..37a5633
--- /dev/null
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vfc;
+
+import org.onap.so.security.MSOSpringFirewall;
+import org.onap.so.security.WebSecurityConfig;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.builders.WebSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.web.firewall.StrictHttpFirewall;
+import org.springframework.util.StringUtils;
+
+@EnableWebSecurity
+public class WebSecurityConfigImpl extends WebSecurityConfig {
+
+       @Override
+       protected void configure(HttpSecurity http) throws Exception {
+               http.csrf().disable()
+               .authorizeRequests()
+               .antMatchers("/manage/health","/manage/info","/services").permitAll()
+               .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(),",").toString())
+               .and()
+               .httpBasic();
+       }
+       
+       @Override
+       public void configure(WebSecurity web) throws Exception {
+               super.configure(web);
+               StrictHttpFirewall firewall = new MSOSpringFirewall();
+               web.httpFirewall(firewall);
+       }
+
+}
\ No newline at end of file
index 0536dd3..f6bf8b9 100644 (file)
@@ -82,15 +82,18 @@ public class RestfulUtil {
    private Environment env;
 
     public String getMsbHost() {
-        // MSB_IP will be set as ONAP_IP environment parameter in install flow.
-        String msbIp = System.getenv().get(ONAP_IP);
-       // if ONAP IP is not set. get it from config file.
-        if(null == msbIp || msbIp.isEmpty()) {
-               msbIp = env.getProperty("mso.msb-ip", DEFAULT_MSB_IP);
-       }
+               // MSB_IP will be set as ONAP_IP environment parameter in install flow.
+               String msbIp = System.getenv().get(ONAP_IP);
+               // if ONAP IP is not set. get it from config file.
+               if (null == msbIp || msbIp.isEmpty()) {
+                       msbIp = env.getProperty("mso.msb-ip", DEFAULT_MSB_IP);
+               }
        Integer msbPort = env.getProperty("mso.msb-port", Integer.class, DEFAULT_MSB_PORT);
        
-       return UriBuilder.fromPath("").host(msbIp).port(msbPort).scheme("http").build().toString();
+       String msbEndpoint = UriBuilder.fromPath("").host(msbIp).port(msbPort).scheme("http").build().toString();
+       LOGGER.debug("msbEndpoint in vfc adapter: " + msbEndpoint);
+       
+       return msbEndpoint;
     }
 
     private RestfulUtil() {
@@ -99,7 +102,7 @@ public class RestfulUtil {
 
     public RestfulResponse send(String url, String methodType, String content) {
         String msbUrl = getMsbHost() + url;
-        LOGGER.info(MessageEnum.RA_NS_EXC, "Begin to sent message " + methodType +": " + msbUrl, "org.onap.so.adapters.vfc.util.RestfulUtil",VFC_ADAPTER);
+        LOGGER.debug("Begin to sent message " + methodType +": " + msbUrl);
 
         HttpRequestBase method = null;
         HttpResponse httpResponse = null;
index c8f7f05..529ce30 100644 (file)
@@ -59,12 +59,10 @@ import org.onap.so.db.catalog.beans.AllottedResource;
 import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
 import org.onap.so.db.catalog.beans.CollectionResource;
-import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
 import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
 import org.onap.so.db.catalog.beans.ConfigurationResource;
 import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
 import org.onap.so.db.catalog.beans.CvnfcCustomization;
-import org.onap.so.db.catalog.beans.ExternalServiceToInternalService;
 import org.onap.so.db.catalog.beans.HeatEnvironment;
 import org.onap.so.db.catalog.beans.HeatFiles;
 import org.onap.so.db.catalog.beans.HeatTemplate;
@@ -141,7 +139,6 @@ public class ToscaResourceInstaller {
 
        protected static final String MSO = "SO";
 
-
        @Autowired
        protected ServiceRepository serviceRepo;
        
@@ -275,9 +272,9 @@ public class ToscaResourceInstaller {
 
        @Transactional(rollbackFor = { ArtifactInstallerException.class })
        public void installTheResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct)
-                       throws ArtifactInstallerException {             
+                       throws ArtifactInstallerException {
                VfResourceStructure vfResourceStructure = vfResourceStruct;
-               extractHeatInformation(toscaResourceStruct, vfResourceStructure);       
+               extractHeatInformation(toscaResourceStruct, vfResourceStructure);
 
                // PCLO: in case of deployment failure, use a string that will represent
                // the type of artifact that failed...
@@ -286,21 +283,9 @@ public class ToscaResourceInstaller {
                        createToscaCsar(toscaResourceStruct);                   
                        createService(toscaResourceStruct, vfResourceStruct);                   
                        Service service = toscaResourceStruct.getCatalogService();                              
-                       List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
-                       
-               
-                       for (NodeTemplate nodeTemplate : vfNodeTemplatesList) { 
-                               
-                               Metadata metadata = nodeTemplate.getMetaData();         
-                               String serviceType = toscaResourceStruct.getCatalogService().getServiceType();                  
-                               String vfCustomizationCategory = toscaResourceStruct.getSdcCsarHelper()
-                                               .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CATEGORY);
-                               processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
-                                               vfCustomizationCategory);
-                       }
 
-                       List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
-                       processAllottedResources(toscaResourceStruct, service, allottedResourceList);
+                       processVFResources(toscaResourceStruct, service, vfResourceStructure);
+                       processAllottedResources(toscaResourceStruct, service);
                        processNetworks(toscaResourceStruct, service);  
                        // process Network Collections
                        processNetworkCollections(toscaResourceStruct, service);
@@ -390,8 +375,9 @@ public class ToscaResourceInstaller {
         }
        }
 
-       protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service,
-                       List<NodeTemplate> allottedResourceList) {
+       protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service) {
+               List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
+               
                if (allottedResourceList != null) {
                        for (NodeTemplate allottedNode : allottedResourceList) {                                                                        
                                service.getAllottedCustomizations()
@@ -463,60 +449,86 @@ public class ToscaResourceInstaller {
                service.getCollectionResourceCustomizations().add(toscaResourceStruct.getCatalogCollectionResourceCustomization());
        }
 
-       protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
-                       Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory) throws Exception {
+
+       protected void processVFResources (ToscaResourceStructure toscaResourceStruct, Service service, VfResourceStructure vfResourceStructure)
+                       throws Exception{
+               logger.debug("processVFResources");
                
-               logger.debug("VF Category is : " + vfCustomizationCategory);
+               List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
+//             String servicecategory = toscaResourceStruct.getCatalogService().getCategory();
+//             String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
                
-               if(vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty())
-               {
-
-                       String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper()
-                                       .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
-                       logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);     
-                       
-                       IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();           
-                       
-                       // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before comparing their VF Modules UUID's
-                       logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + 
-                                                  " matches Tosca VF Customization UUID: " +  vfCustomizationUUID);
-                       
-                       if(vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())){
-                               
-                               logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + " matches vfNotificationResource CustomizationUUID");
+               for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
+                       Metadata metadata = nodeTemplate.getMetaData();
+                       String vfCustomizationCategory = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
+                       logger.debug("VF Category is : " + vfCustomizationCategory);
                        
-                               VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
+                       // Do not treat Allotted Resources as VNF resources
+                       if(ALLOTTED_RESOURCE.equalsIgnoreCase(vfCustomizationCategory)){
+                               continue;
+                       }
+
+                       String vfCustomizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+                       logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
+
+                       IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
+
+                       // Make sure the VF ResourceCustomizationUUID from the notification and tosca
+                       // customizations match before comparing their VF Modules UUID's
+                       logger.debug("Checking if Notification VF ResourceCustomizationUUID: "
+                                       + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: "
+                                       + vfCustomizationUUID);
+
+                       if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
+                               logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
+                                               + " matches vfNotificationResource CustomizationUUID");                         
                                
-                               Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>(); 
-                               Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>();
-                                                               
-                               for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
-                                       
-                                       logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
-                                       List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct
-                                                       .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
-                                       IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();     
-                                       
-                                       logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
-                                       
-                                       Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
-                                                       .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
-                                                   .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID()))
-                                                   .findFirst();
-                                       if(matchingObject.isPresent()){
-                                               VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct, 
-                                                                                                                                                                                        vfResourceStructure,vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet);
-                                               vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
-                                       }else
-                                               throw new Exception("Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
-                                       
+                               processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, vfCustomizationUUID);
+                       }
+                       else {
+                               logger.debug("Notification VF ResourceCustomizationUUID: "
+                                               + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
+                                               + "Tosca VF Customization UUID: " + vfCustomizationUUID);
+                       }
+               }
+       }
+       
+       
+       protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
+                       Service service, NodeTemplate nodeTemplate, String vfCustomizationUUID)
+                       throws Exception {
+               logger.debug("processVfModules for vfCustomizationUUID: " + vfCustomizationUUID);
+               
+               VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
+               
+               if (vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty()) {
+                       Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>();
+                       Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>();
+
+                       for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
+
+                               logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
+                               List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct.getSdcCsarHelper()
+                                               .getVfModulesByVf(vfCustomizationUUID);
+                               IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
+
+                               logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
+
+                               Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
+                                               .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID "     + group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
+                                               .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID()))
+                                               .findFirst();
+                               if (matchingObject.isPresent()) {
+                                       VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct, 
+                                                                                    vfResourceStructure, vfMetadata, vnfResource,service, existingCvnfcSet, existingVnfcSet);
+                                       vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
+                               } else {
+                                       throw new Exception("Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
                                }
-                               service.getVnfCustomizations().add(vnfResource);
-                       } else{
-                               logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " +
-                                                    "Tosca VF Customization UUID: " +  vfCustomizationUUID);
                        }
                }
+
+               service.getVnfCustomizations().add(vnfResource);
        }
 
        public void processWatchdog(String distributionId, String servideUUID) {
index 926e09c..42e9cb6 100644 (file)
                <dependency>
                        <groupId>org.onap.sdc.sdc-tosca</groupId>
                        <artifactId>sdc-tosca</artifactId>
-                       <version>1.4.1</version>                        
+                       <version>1.4.4</version>
                </dependency>
                <dependency>
                        <groupId>org.onap.sdc.jtosca</groupId>
                        <artifactId>jtosca</artifactId>
-                       <version>1.4.1</version>
+                       <version>1.4.4</version>
                </dependency>
                <dependency>
                        <groupId>org.springframework.boot</groupId>
index c50ef35..b03256b 100644 (file)
@@ -33,6 +33,7 @@ import org.onap.so.bpmn.core.json.JsonUtils
 import org.onap.so.db.catalog.beans.AuthenticationType
 import org.onap.so.db.catalog.beans.CloudIdentity
 import org.onap.so.db.catalog.beans.CloudSite
+import org.onap.so.db.catalog.beans.HomingInstance
 import org.onap.so.db.catalog.beans.ServerType
 import org.onap.so.rest.APIResponse
 import org.onap.so.rest.RESTClient
@@ -267,7 +268,7 @@ class OofHoming extends AbstractServiceTaskProcessor {
                             cloudIdentity.setAdminTenant("service")
                             cloudIdentity.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD)
                             String msoMulticloudUserName = UrnPropertiesReader
-                                    .getVariable("mso.multicloud.api.password", execution,
+                                    .getVariable("mso.multicloud.api.username", execution,
                                     "apih")
                             String msoMulticloudPassword = UrnPropertiesReader
                                     .getVariable("mso.multicloud.api.password", execution,
@@ -293,8 +294,7 @@ class OofHoming extends AbstractServiceTaskProcessor {
                                     + " *****", "true")
 
                             // Set cloudsite in catalog DB here
-                            // TODO Get cloudsite and compare, set if not present
-                            oofUtils.createCloudSiteCatalogDb(cloudSite, execution)
+                            oofUtils.createCloudSite(cloudSite, execution)
 
                             if (oofDirectives != null && oofDirectives != "") {
                                 resource.getHomingSolution().setOofDirectives(oofDirectives)
@@ -303,6 +303,19 @@ class OofHoming extends AbstractServiceTaskProcessor {
                                         " *****", "true")
                             }
 
+                            // Set Homing Instance
+                            String serviceInstanceId = decomposition.getServiceInstance().getInstanceId()
+                            HomingInstance homingInstance = new HomingInstance()
+                            homingInstance.setServiceInstanceId(serviceInstanceId)
+                            homingInstance.setCloudOwner(cloudOwner)
+                            homingInstance.setCloudRegionId(cloudRegionId)
+                            if (oofDirectives != null && oofDirectives != "") {
+                                homingInstance.setOofDirectives(oofDirectives)}
+                            else {
+                                homingInstance.setOofDirectives("{}")
+                            }
+                            oofUtils.createHomingInstance(homingInstance, execution)
+
                             if (inventoryType.equalsIgnoreCase("service")) {
                                 resource.getHomingSolution().setRehome(assignmentMap.get("isRehome").toBoolean())
                                 VnfResource vnf = new VnfResource()
index 19d19b8..f72fc47 100644 (file)
@@ -33,24 +33,16 @@ import org.onap.so.bpmn.core.domain.ServiceInstance
 import org.onap.so.bpmn.core.domain.Subscriber
 import org.onap.so.bpmn.core.domain.VnfResource
 import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.db.catalog.beans.CloudIdentity
 import org.onap.so.db.catalog.beans.CloudSite
-import org.onap.so.db.catalog.client.CatalogDbClient
-import org.onap.so.rest.APIResponse
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
-import org.springframework.http.HttpEntity
-import org.springframework.http.HttpHeaders
-import org.springframework.web.util.UriComponentsBuilder
-
-import javax.ws.rs.core.MediaType
+import org.onap.so.db.catalog.beans.HomingInstance
 import javax.ws.rs.core.UriBuilder
-
+import org.onap.so.bpmn.common.util.OofInfraUtils
 import static org.onap.so.bpmn.common.scripts.GenericUtils.*
 
 class OofUtils {
     ExceptionUtil exceptionUtil = new ExceptionUtil()
     JsonUtils jsonUtil = new JsonUtils()
+    OofInfraUtils oofInfraUtils = new OofInfraUtils()
 
     private AbstractServiceTaskProcessor utils
 
@@ -491,6 +483,7 @@ class OofUtils {
         if (candidatesJson != "") {candidatesJson = candidatesJson.substring(0, candidatesJson.length() - 1)}
         return candidatesJson
     }
+
     /**
      * This method creates a cloudsite in catalog database.
      *
@@ -498,23 +491,19 @@ class OofUtils {
      *
      * @return void
      */
-    Void createCloudSiteCatalogDb(CloudSite cloudSite, DelegateExecution execution) {
-        def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
-        String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution)
-        String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution)
-        CloudSite getCloudsite = null
+    Void createCloudSite(CloudSite cloudSite, DelegateExecution execution) {
+        oofInfraUtils.createCloudSite(cloudSite, execution)
+    }
 
-        CatalogDbClient catalogDbClient = new CatalogDbClient(endpoint, auth)
-        try {
-            getCloudsite = catalogDbClient.getCloudSite(cloudSite.getId().toString())
-        } catch (Exception e) {
-            e = null
-            utils.log("DEBUG", "Could not find cloudsite : " + cloudSite.getId(), isDebugEnabled)
-            utils.log("DEBUG", "Creating cloudSite: " + cloudSite.toString(), isDebugEnabled)
-        }
-        if (getCloudsite?.getId() != cloudSite.getId()) {
-            catalogDbClient.postCloudSite(cloudSite)
-        }
+    /**
+     * This method creates a HomingInstance in catalog database.
+     *
+     * @param HomingInstance homingInstance
+     *
+     * @return void
+     */
+    Void createHomingInstance(HomingInstance homingInstance, DelegateExecution execution) {
+        oofInfraUtils.createHomingInstance(homingInstance, execution)
     }
 
      String getMsbHost(DelegateExecution execution) {
index b4851ee..5e05637 100644 (file)
@@ -47,6 +47,9 @@ import org.onap.so.bpmn.core.json.JsonUtils;
 import org.onap.so.client.HttpClient;
 import org.onap.so.logger.MessageEnum;
 import org.onap.so.logger.MsoLogger;
+import org.onap.so.rest.APIResponse;
+import org.onap.so.rest.RESTClient;
+import org.onap.so.rest.RESTConfig;
 import org.onap.so.utils.TargetEntity;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
@@ -261,10 +264,20 @@ public class ResourceRequestBuilder {
 
     private static String getCsarFromUuid(String uuid) throws Exception {
                String catalogEndPoint = UrnPropertiesReader.getVariable("mso.catalog.db.endpoint");
-       HttpClient client = new HttpClient(UriBuilder.fromUri(catalogEndPoint).path(SERVICE_URL_TOSCA_CSAR).queryParam("serviceModelUuid", uuid).build().toURL(), "application/json", TargetEntity.CATALOG_DB);
-       
-        Response response = client.get();
-        String value = response.readEntity(String.class);
+
+        RESTClient restClient = new RESTClient(new RESTConfig(
+                UriBuilder.fromUri(catalogEndPoint)
+                        .path(SERVICE_URL_TOSCA_CSAR)
+                        .queryParam("serviceModelUuid", uuid)
+                        .build().toURL().toString()
+        ));
+
+        restClient.addHeader("Accept", "application/json");
+        restClient.addAuthorizationHeader(UrnPropertiesReader.getVariable("mso.db.auth"));
+
+        APIResponse apiResponse = restClient.httpGet();
+
+        String value = apiResponse.getResponseBodyAsString();
 
         HashMap<String, String> map = new Gson().fromJson(value, new TypeToken<HashMap<String, String>>() {}.getType());
 
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java
new file mode 100644 (file)
index 0000000..df7b57f
--- /dev/null
@@ -0,0 +1,112 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018. Intel Corp. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.common.util;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.core.UrnPropertiesReader;
+import org.onap.so.db.catalog.beans.CloudSite;
+import org.onap.so.db.catalog.beans.HomingInstance;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.logger.MsoLogger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Arrays;
+import java.util.Optional;
+
+public class OofInfraUtils {
+
+    private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, OofInfraUtils.class);
+
+    /**
+     * This method creates a cloudsite in catalog database.
+     *
+     * @param cloudSite
+     *
+     * @return void
+     */
+    public void createCloudSite(CloudSite cloudSite, DelegateExecution execution) {
+        String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution);
+        String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution);
+        try {
+            CloudSite getCloudsite;
+
+            CatalogDbClient client = new CatalogDbClient(endpoint, auth);
+
+            getCloudsite = Optional.ofNullable(client.getCloudSite(cloudSite.getId(), endpoint + "/cloudSite/")).orElse(new CloudSite());
+            if (!cloudSite.getId().equals(getCloudsite.getId())) {
+                client.postCloudSite(cloudSite);
+                LOGGER.debug("Did not findd cloudsite : " + cloudSite.getId());
+                LOGGER.debug("Will create cloudSite: " + cloudSite.toString());
+            }
+            else {
+                LOGGER.debug("Found cloudsite : " + cloudSite.getId());
+                LOGGER.debug("Will not create cloudSite: " + cloudSite.toString());
+            }
+        } catch (Exception e) {
+            LOGGER.debug("Error looking up or creating cloudsite : " + cloudSite.getId());
+            LOGGER.debug("CloudSite Lookup/Creation Error: " + e);
+        }
+
+
+    }
+
+    /**
+     * This method creates a HomingInstance in catalog database.
+     *
+     * @param homingInstance
+     *
+     * @return void
+     */
+    public void createHomingInstance(HomingInstance homingInstance, DelegateExecution execution) {
+        String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution);
+        String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution);
+
+        CatalogDbClient client = new CatalogDbClient(endpoint, auth);
+        try {
+            client.postHomingInstance(homingInstance);
+        } catch (Exception exception) {
+            LOGGER.debug("Could not create HomingInstance : " + homingInstance.getServiceInstanceId());
+            LOGGER.debug("HomingInstance Creation Error: " + exception);
+        }
+
+    }
+
+    /**
+     * This method gets a HomingInstance in catalog database.
+     *
+     * @param serviceInstanceId
+     *
+     * @return HomingInstance
+     */
+    public HomingInstance getHomingInstance(String serviceInstanceId, DelegateExecution execution) {
+        String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution);
+        String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution);
+
+        CatalogDbClient client = new CatalogDbClient(endpoint, auth);
+        try {
+            return client.getHomingInstance(serviceInstanceId, endpoint + "/homingInstance/");
+        } catch (Exception exception) {
+            LOGGER.debug("Could not get HomingInstance for serviceInstanceId : " + serviceInstanceId);
+            LOGGER.debug("Get HomingInstance Error: " + exception);
+        }
+        return null;
+    }
+}
index 9c80548..52207f2 100644 (file)
@@ -25,24 +25,26 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.stream.Collectors;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+
 /**
- * An object that stores data for rollbacks.  Data is organized by type.  A
- * type is simply a string identifier.  Multiple types of data may be stored
- * in the same object for separate rollback operations.
+ * An object that stores data for rollbacks. Data is organized by type. A type is simply a string
+ * identifier. Multiple types of data may be stored in the same object for separate rollback
+ * operations.
  */
 public class RollbackData implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    private Map<String, Map<String, Serializable>> dictionary =
-        new HashMap<>();
+    @JsonProperty
+    private final Map<String, Map<String, Serializable>> dictionary = new HashMap<>();
 
     /**
      * Returns true if the specified type is stored in this object.
      *
      * @param type the data type
      */
-    public boolean hasType(String type) {
+    public boolean hasType(final String type) {
         return dictionary.containsKey(type);
     }
 
@@ -53,9 +55,8 @@ public class RollbackData implements Serializable {
      * @param key the key
      * @param value the value
      */
-    public void put(String type, String key, String value) {
-        Map<String, Serializable> mapForType = dictionary
-            .computeIfAbsent(type, k -> new HashMap<>());
+    public void put(final String type, final String key, final String value) {
+        final Map<String, Serializable> mapForType = dictionary.computeIfAbsent(type, k -> new HashMap<>());
 
         mapForType.put(key, value);
     }
@@ -67,8 +68,8 @@ public class RollbackData implements Serializable {
      * @param key the key
      * @return the item or null if there is no item for the specified type and key
      */
-    public Serializable get(String type, String key) {
-        Map<String, Serializable> mapForType = dictionary.get(type);
+    public Serializable get(final String type, final String key) {
+        final Map<String, Serializable> mapForType = dictionary.get(type);
 
         if (mapForType == null) {
             return null;
@@ -83,7 +84,7 @@ public class RollbackData implements Serializable {
      * @param type the data type
      * @return a map, or null if there are no items associated with the specified data type
      */
-    public Map<String, Serializable> get(String type) {
+    public Map<String, Serializable> get(final String type) {
         return dictionary.get(type);
     }
 
index b912b64..580416e 100644 (file)
@@ -53,7 +53,6 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
     MsoUtils msoUtils = new MsoUtils()
 
     public void preProcessRequest(DelegateExecution execution) {
-        def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
         msoLogger.info(" ***** Started preProcessRequest *****")
 
         try {
@@ -64,7 +63,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
             String resourceInput = execution.getVariable("resourceInput")
             //Get ResourceInput Object
             ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
-            execution.setVariable(Prefix + "resourceInput", resourceInputObj)
+            execution.setVariable(Prefix + "resourceInput", resourceInputObj.toString())
 
             //Deal with recipeParams
             String recipeParamsFromWf = execution.getVariable("recipeParamXsd")
@@ -125,8 +124,8 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
         } catch (BpmnError e) {
             throw e;
         } catch (Exception ex){
-            msg = "Exception in preProcessRequest " + ex.getMessage()
-            msoLogger.debug( msg)
+            String msg = "Exception in preProcessRequest " + ex.getMessage()
+            msoLogger.debug(msg)
             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
         }
     }
@@ -398,7 +397,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
 
         } catch (Exception ex) {
             String exceptionMessage = " Bpmn error encountered in CreateSDNCCNetworkResource flow. prepareSDNCRequest() - " + ex.getMessage()
-            msoLogger.debug( exceptionMessage)
+            msoLogger.debug(exceptionMessage)
             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
 
         }
@@ -415,7 +414,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
     }
 
     public void sendSyncResponse(DelegateExecution execution) {
-        msoLogger.dubug(" *** sendSyncResponse *** ")
+        msoLogger.info("started sendsyncResp")
 
         try {
             String operationStatus = "finished"
@@ -427,9 +426,9 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
 
         } catch (Exception ex) {
             String msg = "Exception in sendSyncResponse:" + ex.getMessage()
-            msoLogger.debug( msg)
+            msoLogger.debug(msg)
             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
         }
-        msoLogger.dubug(" ***** Exit sendSyncResponse *****")
+        msoLogger.info("exited sendsyncResp")
     }
 }
\ No newline at end of file
index a505f3f..8e168a3 100644 (file)
@@ -203,7 +203,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
                     uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.access-ltp-id", inputParameters.get("local-access-ltp-id"))
                     uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.access-node-id", inputParameters.get("local-access-node-id"))
                     resourceInputObj.setResourceParameters(uResourceInput)
-                    execution.setVariable(Prefix + "resourceInput", resourceInputObj)
+                    execution.setVariable(Prefix + "resourceInput", resourceInputObj.toString())
                 }
 
                 break
@@ -539,10 +539,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
 
     private def getInstnaceId(DelegateExecution execution) {
         def responce  = new XmlSlurper().parseText(execution.getVariable("CRENWKI_createSDNCResponse"))
-        def data = responce.toString()
-        data = data.substring(data.indexOf("<"))
 
-        def resp = new XmlSlurper().parseText(data)
         ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(execution.getVariable(Prefix + "resourceInput"), ResourceInput.class)
         String modelName = resourceInputObj.getResourceModelInfo().getModelName()
         def val = ""
@@ -550,18 +547,18 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
         switch (modelName) {
             case  ~/[\w\s\W]*SOTNConnectivity[\w\s\W]*/ :
             case ~/[\w\s\W]*SDWANConnectivity[\w\s\W]*/ :
-                val = resp."network-response-information"."instance-id"
+                val = responce."response-data"."RequestData"."output"."network-response-information"."instance-id"
                 break
 
             case ~/[\w\s\W]*deviceVF[\w\s\W]*/ :
             case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ :
             case ~/[\w\s\W]*Site[\w\s\W]*/:
-                val = resp."vnf-response-information"."instance-id"
+                val = responce."response-data"."RequestData"."output"."vnf-response-information"."instance-id"
                 break
 
             case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ :
             case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/:
-                val = resp."connection-attachment-response-information"."instance-id"
+                val = responce."response-data"."RequestData"."output"."connection-attachment-response-information"."instance-id"
                 break
         }
 
index dabd351..94df0a9 100644 (file)
@@ -28,13 +28,18 @@ import org.camunda.bpm.engine.delegate.DelegateExecution
 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
 import org.onap.so.bpmn.common.scripts.ExceptionUtil
 import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.client.HttpClient
+//import org.onap.so.client.HttpClient
+//import org.onap.so.client.RestRequest
 import org.onap.so.logger.MessageEnum
 import org.onap.so.logger.MsoLogger
+import org.onap.so.rest.APIResponse
+import org.onap.so.rest.RESTClient
+import org.onap.so.rest.RESTConfig
+import org.onap.so.bpmn.core.UrnPropertiesReader
 
 import groovy.json.*
-import javax.ws.rs.core.Response
-import org.onap.so.utils.TargetEntity
+//import javax.ws.rs.core.Response
+//import org.onap.so.utils.TargetEntity
 
 /**
  * This groovy class supports the <class>DoCreateVFCNetworkServiceInstance.bpmn</class> process.
@@ -43,11 +48,10 @@ import org.onap.so.utils.TargetEntity
 public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
        private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateVFCNSResource.class);
 
+//    String vfcUrl = "/vfc/rest/v1/vfcadapter"
 
-    String vfcUrl = "/vfc/rest/v1/vfcadapter"
-
-    String host = "http://mso.mso.testlab.openecomp.org:8080"
-
+//    String host = "http://mso.mso.testlab.openecomp.org:8080"
+       
     ExceptionUtil exceptionUtil = new ExceptionUtil()
 
     JsonUtils jsonUtil = new JsonUtils()
@@ -116,6 +120,18 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
            execution.setVariable("nsParameters", nsParameters)
            execution.setVariable("nsServiceModelUUID", nsServiceModelUUID);
 
+           String vfcAdapterUrl = UrnPropertiesReader.getVariable("mso.adapters.vfc.rest.endpoint", execution)
+                  
+           if (vfcAdapterUrl == null || vfcAdapterUrl.isEmpty()) {
+                  msg = getProcessKey(execution) + ': mso:adapters:vfcc:rest:endpoint URN mapping is not defined'
+                  msoLogger.debug(msg)
+           }
+
+           while (vfcAdapterUrl.endsWith('/')) {
+                  vfcAdapterUrl = vfcAdapterUrl.substring(0, vfcAdapterUrl.length()-1)
+           }              
+                  
+           execution.setVariable("vfcAdapterUrl", vfcAdapterUrl)
 
        } catch (BpmnError e) {
            throw e;
@@ -132,6 +148,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
      */
     public void createNetworkService(DelegateExecution execution) {
         msoLogger.trace("createNetworkService ")
+        String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
         String nsOperationKey = execution.getVariable("nsOperationKey");
         String nsServiceModelUUID = execution.getVariable("nsServiceModelUUID");
         String nsParameters = execution.getVariable("nsParameters");
@@ -149,9 +166,9 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
                      "additionalParamForNs":${requestInputs}
                 }
                }"""
-        Response apiResponse = postRequest(execution, host + vfcUrl + "/ns", reqBody)
-        String returnCode = apiResponse.getStatus()
-        String aaiResponseAsString = apiResponse.readEntity(String.class)
+        APIResponse apiResponse = postRequest(execution, vfcAdapterUrl + "/ns", reqBody)
+        String returnCode = apiResponse.getStatusCode()
+        String aaiResponseAsString = apiResponse.getResponseBodyAsString()
         String nsInstanceId = "";
         if(returnCode== "200" || returnCode == "201"){
             nsInstanceId =  jsonUtil.getJsonValue(aaiResponseAsString, "nsInstanceId")
@@ -165,6 +182,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
      */
     public void instantiateNetworkService(DelegateExecution execution) {
         msoLogger.trace("instantiateNetworkService ")
+        String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
         String nsOperationKey = execution.getVariable("nsOperationKey");
         String nsParameters = execution.getVariable("nsParameters");
         String nsServiceName = execution.getVariable("nsServiceName")
@@ -176,10 +194,10 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
         "nsParameters":${nsParameters}
        }"""
         String nsInstanceId = execution.getVariable("nsInstanceId")
-        String url = host + vfcUrl + "/ns/" +nsInstanceId + "/instantiate"
-        Response apiResponse = postRequest(execution, url, reqBody)
-        String returnCode = apiResponse.getStatus()
-        String aaiResponseAsString = apiResponse.readEntity(String.class)
+        String url = vfcAdapterUrl + "/ns/" +nsInstanceId + "/instantiate"
+        APIResponse apiResponse = postRequest(execution, url, reqBody)
+        String returnCode = apiResponse.getStatusCode()
+        String aaiResponseAsString = apiResponse.getResponseBodyAsString()
         String jobId = "";
         if(returnCode== "200"|| returnCode == "201"){
             jobId =  jsonUtil.getJsonValue(aaiResponseAsString, "jobId")
@@ -193,12 +211,13 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
      */
     public void queryNSProgress(DelegateExecution execution) {
         msoLogger.trace("queryNSProgress ")
+        String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
         String jobId = execution.getVariable("jobId")
         String nsOperationKey = execution.getVariable("nsOperationKey");
-        String url = host + vfcUrl + "/jobs/" + jobId
-        Response apiResponse = postRequest(execution, url, nsOperationKey)
-        String returnCode = apiResponse.getStatus()
-        String aaiResponseAsString = apiResponse.readEntity(String.class)
+        String url = vfcAdapterUrl + "/jobs/" + jobId
+        APIResponse apiResponse = postRequest(execution, url, nsOperationKey)
+        String returnCode = apiResponse.getStatusCode()
+        String aaiResponseAsString = apiResponse.getResponseBodyAsString()
         String operationStatus = "error"
         if(returnCode== "200"|| returnCode == "201"){
             operationStatus = jsonUtil.getJsonValue(aaiResponseAsString, "responseDescriptor.status")
@@ -214,7 +233,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
         try {
             Thread.sleep(5000);
         } catch(InterruptedException e) {
-            msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Time Delay exception" + e , "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
+            msoLogger.error( "Time Delay exception" + e.getMessage());
         }
     }
 
@@ -239,7 +258,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
             getAAIClient().connect(nsUri,relatedServiceUri)
             msoLogger.info("NS relationship to Service added successfully")
         }catch(Exception e){
-            msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while Creating NS relationship.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e.getMessage(),e);
+            msoLogger.error("Exception occured while Creating NS relationship."+ e.getMessage());
             throw new BpmnError("MSOWorkflowException")
         }
     }
@@ -249,26 +268,37 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
      * url: the url of the request
      * requestBody: the body of the request
      */
-    private Response postRequest(DelegateExecution execution, String urlString, String requestBody){
+    private APIResponse postRequest(DelegateExecution execution, String urlString, String requestBody){
         msoLogger.trace("Started Execute VFC adapter Post Process ")
-        msoLogger.info("url:"+url +"\nrequestBody:"+ requestBody)
-        Response apiResponse = null
-        try{
-
-                       URL url = new URL(urlString);
-
-                       HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER)
-                       httpClient.addAdditionalHeader("Accept", "application/json")
-                       httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk")
-
-                       apiResponse = httpClient.post(requestBody)
-
-            msoLogger.info("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class))
-            msoLogger.trace("Completed Execute VF-C adapter Post Process ")
-        }catch(Exception e){
-            msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Post Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e);
-            throw new BpmnError("MSOWorkflowException")
-        }
+        msoLogger.info("url:" + urlString +"\nrequestBody:"+ requestBody)
+        APIResponse apiResponse = null
+               try{
+                       // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7'
+                       def basicAuthHeaderValue = ""
+                       RESTConfig config = new RESTConfig(urlString)
+                       RESTClient client = null;
+                       int statusCode = 0;
+                       
+                       // user 'bepl' authHeader is the same with mso.db.auth
+                       String basicAuthValuedb =  UrnPropertiesReader.getVariable("mso.db.auth", execution)
+       
+                       client = new RESTClient(config)
+                       client.addHeader("Accept", "application/json")
+                       client.addAuthorizationHeader(basicAuthValuedb)
+                       client.addHeader("Content-Type", "application/json")
+                       
+                       apiResponse = client.httpPost(requestBody)
+                       statusCode = apiResponse.getStatusCode()
+                       
+                       msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString())               
+               
+               }catch(Exception e){
+                       msoLogger.error("Exception occured while executing VF-C Post Call. Exception is: \n" + e.getMessage());
+                       throw new BpmnError("MSOWorkflowException")
+               }
+               
+               msoLogger.trace("Completed Execute VF-C adapter Post Process ")
+        
         return apiResponse
     }
 
index 61c88db..f6e4fcc 100644 (file)
@@ -263,15 +263,14 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{
             JSONObject resourceRecipe = cutils.getResourceRecipe(execution, resourceModelUUID, requestAction)
 
             if (resourceRecipe != null) {
-                String recipeURL = BPMNProperties.getProperty("bpelURL", "http://bpmn-infra:8081") + resourceRecipe.getString("orchestrationUri")
+                String recipeURL = BPMNProperties.getProperty("bpelURL", "http://so-bpmn-infra.onap:8081") + resourceRecipe.getString("orchestrationUri")
                 int recipeTimeOut = resourceRecipe.getInt("recipeTimeout")
                 String recipeParamXsd = resourceRecipe.get("paramXSD")
 
                 BpmnRestClient bpmnRestClient = new BpmnRestClient()
                 HttpResponse resp = bpmnRestClient.post(recipeURL, requestId, recipeTimeOut, requestAction, serviceInstanceId, serviceType, resourceInput, recipeParamXsd)
             } else {
-                String exceptionMessage = "Resource receipe is not found for resource modeluuid: " +
-                        resourceInput.getResourceModelInfo().getModelUuid()
+                String exceptionMessage = "Resource receipe is not found for resource modeluuid: " + resourceModelUUID
                 msoLogger.trace(exceptionMessage)
                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, exceptionMessage)
             }
index 09f159e..0502f79 100644 (file)
@@ -28,14 +28,18 @@ import org.camunda.bpm.engine.delegate.DelegateExecution
 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
 import org.onap.so.bpmn.common.scripts.ExceptionUtil
 import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.client.HttpClient
+//import org.onap.so.client.HttpClient
 import org.onap.so.logger.MessageEnum
 import org.onap.so.logger.MsoLogger
+import org.onap.so.rest.APIResponse
+import org.onap.so.rest.RESTClient
+import org.onap.so.rest.RESTConfig
+import org.onap.so.bpmn.core.UrnPropertiesReader
 
-import org.onap.so.utils.TargetEntity
+//import org.onap.so.utils.TargetEntity
 
 import groovy.json.*
-import javax.ws.rs.core.Response
+//import javax.ws.rs.core.Response
 
 /**
  * This groovy class supports the <class>DoCreateVFCNetworkServiceInstance.bpmn</class> process.
@@ -44,9 +48,6 @@ import javax.ws.rs.core.Response
 public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProcessor {
        private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVFCNetworkServiceInstance.class);
 
-    String vfcUrl = "/vfc/rest/v1/vfcadapter"
-
-    String host = "http://mso.mso.testlab.openecomp.org:8080"
 
     ExceptionUtil exceptionUtil = new ExceptionUtil()
 
@@ -100,6 +101,19 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
            execution.setVariable("nsOperationKey", nsOperationKey);
            execution.setVariable("nsParameters", nsParameters)
 
+           String vfcAdapterUrl = UrnPropertiesReader.getVariable("mso.adapters.vfc.rest.endpoint", execution)
+                  
+           if (vfcAdapterUrl == null || vfcAdapterUrl.isEmpty()) {
+               msg = getProcessKey(execution) + ': mso:adapters:vfcc:rest:endpoint URN mapping is not defined'
+               msoLogger.debug(msg)
+           }
+
+           while (vfcAdapterUrl.endsWith('/')) {
+               vfcAdapterUrl = vfcAdapterUrl.substring(0, vfcAdapterUrl.length()-1)
+           }
+                  
+           execution.setVariable("vfcAdapterUrl", vfcAdapterUrl)
+
 
        } catch (BpmnError e) {
            throw e;
@@ -116,6 +130,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
      */
     public void createNetworkService(DelegateExecution execution) {
         msoLogger.trace("createNetworkService")
+        String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
         String nsOperationKey = execution.getVariable("nsOperationKey");
         String nsParameters = execution.getVariable("nsParameters");
         String nsServiceName = execution.getVariable("nsServiceName")
@@ -126,7 +141,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
                 "nsOperationKey":${nsOperationKey},
                 "nsParameters":${nsParameters}
                }"""
-        Response apiResponse = postRequest(execution, host + vfcUrl + "/ns", reqBody)
+        APIResponse apiResponse = postRequest(execution, vfcAdapterUrl + "/ns", reqBody)
         String returnCode = apiResponse.getStatus()
         String aaiResponseAsString = apiResponse.readEntity(String.class)
         String nsInstanceId = "";
@@ -142,6 +157,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
      */
     public void instantiateNetworkService(DelegateExecution execution) {
         msoLogger.trace("instantiateNetworkService")
+        String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
         String nsOperationKey = execution.getVariable("nsOperationKey");
         String nsParameters = execution.getVariable("nsParameters");
         String nsServiceName = execution.getVariable("nsServiceName")
@@ -153,8 +169,8 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
         "nsParameters":${nsParameters}
        }"""
         String nsInstanceId = execution.getVariable("nsInstanceId")
-        String url = host + vfcUrl + "/ns/" +nsInstanceId + "/instantiate"
-        Response apiResponse = postRequest(execution, url, reqBody)
+        String url = vfcAdapterUrl + "/ns/" +nsInstanceId + "/instantiate"
+        APIResponse apiResponse = postRequest(execution, url, reqBody)
         String returnCode = apiResponse.getStatus()
         String aaiResponseAsString = apiResponse.readEntity(String.class)
         String jobId = "";
@@ -170,10 +186,11 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
      */
     public void queryNSProgress(DelegateExecution execution) {
         msoLogger.trace("queryNSProgress")
+        String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
         String jobId = execution.getVariable("jobId")
         String nsOperationKey = execution.getVariable("nsOperationKey");
-        String url = host + vfcUrl + "/jobs/" + jobId
-        Response apiResponse = postRequest(execution, url, nsOperationKey)
+        String url = vfcAdapterUrl + "/jobs/" + jobId
+        APIResponse apiResponse = postRequest(execution, url, nsOperationKey)
         String returnCode = apiResponse.getStatus()
         String aaiResponseAsString = apiResponse.readEntity(String.class)
         String operationStatus = "error"
@@ -226,26 +243,38 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
      * url: the url of the request
      * requestBody: the body of the request
      */
-    private Response postRequest(DelegateExecution execution, String urlString, String requestBody){
+    private APIResponse postRequest(DelegateExecution execution, String urlString, String requestBody){
         msoLogger.trace("Started Execute VFC adapter Post Process")
         msoLogger.debug("url:"+urlString +"\nrequestBody:"+ requestBody)
-        Response apiResponse = null
-        try{
-
-                       URL url = new URL(urlString);
-
-                       HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER)
-                       httpClient.addAdditionalHeader("Accept", "application/json")
-                       httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk")
-
-                       apiResponse = httpClient.post(requestBody)
-
-            msoLogger.debug("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class))
-            msoLogger.trace("Completed Execute VF-C adapter Post Process")
-        }catch(Exception e){
-                       msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Post Call", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
-            throw new BpmnError("MSOWorkflowException")
-        }
+        APIResponse apiResponse = null
+               try{
+                       // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7'
+                       def basicAuthHeaderValue = ""
+                       RESTConfig config = new RESTConfig(urlString)
+                       RESTClient client = null;
+                       int statusCode = 0;
+                       
+                       // user 'bepl' authHeader is the same with mso.db.auth
+                       String basicAuthValuedb =  UrnPropertiesReader.getVariable("mso.db.auth", execution)
+                       msoLogger.debug("basicAuthValuedb: " + basicAuthValuedb)
+       
+                       client = new RESTClient(config)
+                       client.addHeader("Accept", "application/json")
+                       client.addAuthorizationHeader(basicAuthValuedb)
+                       client.addHeader("Content-Type", "application/json")
+                       
+                       apiResponse = client.httpPost(requestBody)
+                       statusCode = apiResponse.getStatusCode()
+                               
+                       msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString())
+               
+               }catch(Exception e){
+                       msoLogger.error("Exception occured while executing VF-C Post Call. Exception is: \n" + e.getMessage());
+                       throw new BpmnError("MSOWorkflowException")
+               }
+               
+               msoLogger.trace("Completed Execute VF-C adapter Post Process ")
+               
         return apiResponse
     }
 }
index 58b90a1..74926ce 100644 (file)
@@ -20,6 +20,8 @@
 
 package org.onap.so.bpmn.infrastructure.scripts
 
+import org.onap.so.db.catalog.beans.HomingInstance
+
 import javax.xml.parsers.DocumentBuilder
 import javax.xml.parsers.DocumentBuilderFactory
 
@@ -35,6 +37,7 @@ import org.onap.so.bpmn.common.scripts.MsoUtils
 import org.onap.so.bpmn.common.scripts.NetworkUtils
 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
 import org.onap.so.bpmn.common.scripts.VfModuleBase
+import org.onap.so.bpmn.common.util.OofInfraUtils
 import org.onap.so.bpmn.core.RollbackData
 import org.onap.so.bpmn.core.UrnPropertiesReader
 import org.onap.so.bpmn.core.WorkflowException
@@ -75,6 +78,7 @@ public class DoCreateVfModule extends VfModuleBase {
        ExceptionUtil exceptionUtil = new ExceptionUtil()
        JsonUtils jsonUtil = new JsonUtils()
        SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+       OofInfraUtils oofInfraUtils = new OofInfraUtils()
        CatalogDbUtils catalog = new CatalogDbUtils()
        DecomposeJsonUtil decomposeJsonUtils = new DecomposeJsonUtil()
 
@@ -232,12 +236,37 @@ public class DoCreateVfModule extends VfModuleBase {
                                String globalSubscriberId = execution.getVariable("globalSubscriberId")
                                execution.setVariable("DCVFM_globalSubscriberId", globalSubscriberId)
                                msoLogger.debug("globalSubsrciberId: " + globalSubscriberId)
-                               //OofDirectives
-                               String oofDirectives = execution.getVariable("oofDirectives")
+
+                               // Set Homing Info
+                               String oofDirectives = null
+                               try {
+                                       HomingInstance homingInstance = oofInfraUtils.getHomingInstance(serviceInstanceId, execution)
+                                       if (homingInstance != null) {
+                                               execution.setVariable("DCVFM_cloudSiteId", homingInstance.getCloudRegionId())
+                                               rollbackData.put("VFMODULE", "aiccloudregion", homingInstance.getCloudRegionId())
+                                               msoLogger.debug("Overwriting cloudSiteId with homing cloudSiteId: " +
+                                                               homingInstance.getCloudRegionId())
+                                               execution.setVariable("DCVFM_cloudOwner", homingInstance.getCloudOwner())
+                                               rollbackData.put("VFMODULE", "cloudOwner", homingInstance.getCloudOwner())
+                                               msoLogger.debug("Overwriting cloudOwner with homing cloudOwner: " +
+                                                               homingInstance.getCloudOwner())
+                                               oofDirectives = homingInstance.getOofDirectives()
+                                               execution.setVariable("DCVFM_oofDirectives", oofDirectives)
+                                       }
+                               } catch (Exception exception) {
+                                       msoLogger.debug("Could not find homing information for service instance: " + serviceInstanceId +
+                                                       "... continuing")
+                                       msoLogger.debug("Could not find homing information for service instance error: " + exception)
+                               }
+                               //OofDirectives to Input Params
                                Map<String,String> vfModuleInputParams = execution.getVariable("vfModuleInputParams")
-                               if (oofDirectives != null) {
-                                       vfModuleInputParams.put("oofDirectives", oofDirectives)
-                                       logDebug("OofDirectives are: " + oofDirectives, isDebugLogEnabled)
+                               if (oofDirectives != null && vfModuleInputParams != null) {
+                                       vfModuleInputParams.put("oof_directives", oofDirectives)
+                                       vfModuleInputParams.put("sdnc_directives", "{}")
+                                       msoLogger.debug("OofDirectives are: " + oofDirectives)
+                               } else if (vfModuleInputParams != null) {
+                                       vfModuleInputParams.put("oof_directives", "{}")
+                                       vfModuleInputParams.put("sdnc_directives", "{}")
                                }
                                if (vfModuleInputParams != null) {
                                        execution.setVariable("DCVFM_vnfParamsMap", vfModuleInputParams)
@@ -464,11 +493,30 @@ public class DoCreateVfModule extends VfModuleBase {
                                                        }
 
                                //OofDirectives
-                               String oofDirectives = execution.getVariable("oofDirectives")
+                               String oofDirectives = null
+                               try {
+                                       HomingInstance homingInstance = oofInfraUtils.getHomingInstance(serviceInstanceId, execution)
+                                       if (homingInstance != null) {
+                                               execution.setVariable("DCVFM_cloudSiteId", homingInstance.getCloudRegionId())
+                                               rollbackData.put("VFMODULE", "aiccloudregion", homingInstance.getCloudRegionId())
+                                               msoLogger.debug("Overwriting cloudSiteId with homing cloudSiteId: " +
+                                                               homingInstance.getCloudRegionId())
+                                               execution.setVariable("DCVFM_cloudOwner", homingInstance.getCloudOwner())
+                                               rollbackData.put("VFMODULE", "cloudOwner", homingInstance.getCloudOwner())
+                                               msoLogger.debug("Overwriting cloudOwner with homing cloudOwner: " +
+                                                               homingInstance.getCloudOwner())
+                                               oofDirectives = homingInstance.getOofDirectives()
+                                               execution.setVariable("DCVFM_oofDirectives", oofDirectives)
+                                       }
+                               } catch (Exception exception) {
+                                       msoLogger.debug("Could not find homing information for service instance: " + serviceInstanceId +
+                                                       "... continuing")
+                                       msoLogger.debug("Could not find homing information for service instance error: " + exception)
+                               }
                                if (oofDirectives != null) {
                                        Map<String, String> paramsMap = execution.getVariable("DCVFM_vnfParamsMap")
                                        paramsMap.put("oofDirectives", oofDirectives)
-                                       logDebug("OofDirectives are: " + oofDirectives, isDebugLogEnabled)
+                                       msoLogger.debug("OofDirectives are: " + oofDirectives)
                                        execution.setVariable("DCVFM_vnfParamsMap", paramsMap)
                                }
                        }
index b35aab1..deb0bff 100644 (file)
@@ -20,6 +20,8 @@
 
 package org.onap.so.bpmn.infrastructure.scripts
 
+import org.onap.so.db.catalog.beans.HomingInstance
+
 import static org.apache.commons.lang3.StringUtils.*
 
 import org.camunda.bpm.engine.delegate.BpmnError
@@ -31,6 +33,7 @@ import org.onap.so.bpmn.common.scripts.ExceptionUtil
 import org.onap.so.bpmn.common.scripts.MsoUtils
 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
 import org.onap.so.bpmn.common.scripts.VidUtils
+import org.onap.so.bpmn.common.util.OofInfraUtils
 import org.onap.so.bpmn.core.RollbackData
 import org.onap.so.bpmn.core.UrnPropertiesReader
 import org.onap.so.bpmn.core.WorkflowException
@@ -61,6 +64,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor {
        JsonUtils jsonUtil = new JsonUtils()
        VidUtils vidUtils = new VidUtils(this)
        SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+       OofInfraUtils oofInfraUtils = new OofInfraUtils()
 
        /**
         * This method gets and validates the incoming
@@ -238,6 +242,21 @@ class DoCreateVnf extends AbstractServiceTaskProcessor {
                        execution.setVariable("DoCVNF_nfFunction", nfFunction)
                        msoLogger.debug("NF Function is: " + nfFunction)
 
+                       // Set Homing Info
+                       try {
+                               HomingInstance homingInstance = oofInfraUtils.getHomingInstance(serviceInstanceId, execution)
+                               if (homingInstance != null) {
+                                       execution.setVariable("DoCVNF_cloudSiteId", homingInstance.getCloudRegionId())
+                                       rollbackData.put("VNF", "cloudSiteId", homingInstance.getCloudRegionId())
+                                       msoLogger.debug("Overwriting cloudSiteId with homing cloudSiteId: " +
+                                                       homingInstance.getCloudRegionId())
+                               }
+                       } catch (Exception exception) {
+                               msoLogger.debug("Could not find homing information for service instance: " + serviceInstanceId +
+                                               "... continuing")
+                               msoLogger.debug("Could not find homing information for service instance error: " + exception)
+                       }
+
                        rollbackData.put("VNF", "rollbackSDNCAssign", "false")
                        rollbackData.put("VNF", "rollbackSDNCActivate", "false")
                        rollbackData.put("VNF", "rollbackVnfCreate", "false")
index bae1349..5ff9336 100644 (file)
@@ -25,15 +25,19 @@ import org.camunda.bpm.engine.delegate.DelegateExecution
 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
 import org.onap.so.bpmn.common.scripts.ExceptionUtil
 import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.client.HttpClient
+//import org.onap.so.client.HttpClient
 import org.onap.so.client.aai.AAIObjectType
 import org.onap.so.client.aai.entities.uri.AAIResourceUri
 import org.onap.so.client.aai.entities.uri.AAIUriFactory
 import org.onap.so.logger.MessageEnum
 import org.onap.so.logger.MsoLogger
-import org.onap.so.utils.TargetEntity
+import org.onap.so.rest.APIResponse
+import org.onap.so.rest.RESTClient
+import org.onap.so.rest.RESTConfig
+//import org.onap.so.utils.TargetEntity
+import org.onap.so.bpmn.core.UrnPropertiesReader
 
-import javax.ws.rs.core.Response
+//import javax.ws.rs.core.Response
 /**
  * This groovy class supports the <class>DoDeleteVFCNetworkServiceInstance.bpmn</class> process.
  * flow for E2E ServiceInstance Delete
@@ -41,11 +45,6 @@ import javax.ws.rs.core.Response
 public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProcessor {
        private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteVFCNetworkServiceInstance.class);
 
-
-    String vfcUrl = "/vfc/rest/v1/vfcadapter"
-
-    String host = "http://mso.mso.testlab.openecomp.org:8080"
-
     ExceptionUtil exceptionUtil = new ExceptionUtil()
 
     JsonUtils jsonUtil = new JsonUtils()
@@ -83,6 +82,20 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
              }"""
             execution.setVariable("nsOperationKey", nsOperationKey);
             msoLogger.info("nsOperationKey:" + nsOperationKey)
+
+            String vfcAdapterUrl = UrnPropertiesReader.getVariable("mso.adapters.vfc.rest.endpoint", execution)
+                       
+            if (vfcAdapterUrl == null || vfcAdapterUrl.isEmpty()) {
+                msg = getProcessKey(execution) + ': mso:adapters:vfcc:rest:endpoint URN mapping is not defined'
+                msoLogger.debug(msg)
+            }
+            while (vfcAdapterUrl.endsWith('/')) {
+                vfcAdapterUrl = vfcAdapterUrl.substring(0, vfcAdapterUrl.length()-1)
+            }
+                       
+            execution.setVariable("vfcAdapterUrl", vfcAdapterUrl)
+
         } catch (BpmnError e) {
             throw e;
         } catch (Exception ex){
@@ -123,10 +136,12 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
     public void deleteNetworkService(DelegateExecution execution) {
 
         msoLogger.trace("deleteNetworkService  start ")
+        String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
         String nsOperationKey = execution.getVariable("nsOperationKey");
-        String url = host + vfcUrl + "/ns/" + execution.getVariable("nsInstanceId")
-        Response apiResponse = deleteRequest(execution, url, nsOperationKey)
-        String returnCode = apiResponse.getStatus()
+        String url = vfcAdapterUrl + "/ns/" + execution.getVariable("nsInstanceId")
+        APIResponse apiResponse = deleteRequest(execution, url, nsOperationKey)
+        String returnCode = apiResponse.getStatusCode()
+               String aaiResponseAsString = apiResponse.getResponseBodyAsString()
         String operationStatus = "error";
         if(returnCode== "200" || returnCode== "202"){
             operationStatus = "finished"
@@ -137,16 +152,17 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
     }
 
     /**
-     * instantiate NS task
+     *  terminate NS task
      */
     public void terminateNetworkService(DelegateExecution execution) {
 
         msoLogger.trace("terminateNetworkService  start ")
+        String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
         String nsOperationKey = execution.getVariable("nsOperationKey")
-        String url =  host + vfcUrl + "/ns/" + execution.getVariable("nsInstanceId") + "/terminate"
-        Response apiResponse = postRequest(execution, url, nsOperationKey)
-        String returnCode = apiResponse.getStatus()
-        String aaiResponseAsString = apiResponse.readEntity(String.class)
+        String url =  vfcAdapterUrl + "/ns/" + execution.getVariable("nsInstanceId") + "/terminate"
+        APIResponse apiResponse = postRequest(execution, url, nsOperationKey)
+        String returnCode = apiResponse.getStatusCode()                
+        String aaiResponseAsString = apiResponse.getResponseBodyAsString()
         String jobId = "";
         if(returnCode== "200" || returnCode== "202"){
             jobId =  jsonUtil.getJsonValue(aaiResponseAsString, "jobId")
@@ -161,12 +177,13 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
     public void queryNSProgress(DelegateExecution execution) {
 
         msoLogger.trace("queryNSProgress  start ")
+        String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl")
         String jobId = execution.getVariable("jobId")
         String nsOperationKey = execution.getVariable("nsOperationKey");
-        String url =  host + vfcUrl + "/jobs/" +  execution.getVariable("jobId")
-        Response apiResponse = postRequest(execution, url, nsOperationKey)
-        String returnCode = apiResponse.getStatus()
-        String apiResponseAsString = apiResponse.readEntity(String.class)
+        String url =  vfcAdapterUrl + "/jobs/" +  execution.getVariable("jobId")
+        APIResponse apiResponse = postRequest(execution, url, nsOperationKey)
+        String returnCode = apiResponse.getStatusCode()
+        String apiResponseAsString = apiResponse.getResponseBodyAsString()
         String operationProgress = "100"
         if(returnCode== "200"){
             operationProgress = jsonUtil.getJsonValue(apiResponseAsString, "responseDescriptor.progress")
@@ -198,25 +215,34 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
      * url: the url of the request
      * requestBody: the body of the request
      */
-    private Response postRequest(DelegateExecution execution, String urlString, String requestBody){
+    private APIResponse postRequest(DelegateExecution execution, String urlString, String requestBody){
 
                msoLogger.trace("Started Execute VFC adapter Post Process ")
                msoLogger.info("url:"+urlString +"\nrequestBody:"+ requestBody)
-               Response apiResponse = null
+               APIResponse apiResponse = null
                try{
-                       URL url = new URL(urlString);
-
-                       HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER)
-                       httpClient.addAdditionalHeader("Accept", "application/json")
-                       httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk")
-
-                       apiResponse = httpClient.post(requestBody)
-
-                       msoLogger.debug("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class))
-
-                       msoLogger.trace("Completed Execute VF-C adapter Post Process ")
+                       // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7'
+                       def basicAuthHeaderValue = ""
+                       RESTConfig config = new RESTConfig(urlString)
+                       RESTClient client = null;
+                       int statusCode = 0;
+                       
+                       // user 'bepl' authHeader is the same with mso.db.auth
+                       String basicAuthValuedb =  UrnPropertiesReader.getVariable("mso.db.auth", execution)
+                       msoLogger.debug("basicAuthValuedb: " + basicAuthValuedb)
+                       
+                       client = new RESTClient(config)
+                       client.addHeader("Accept", "application/json")
+                       client.addAuthorizationHeader(basicAuthValuedb)
+                       client.addHeader("Content-Type", "application/json")
+                       
+                       apiResponse = client.httpPost(requestBody)
+                       statusCode = apiResponse.getStatusCode()
+                               
+                       msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString())
+               
                }catch(Exception e){
-            msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing VF-C Post Call. Exception is: \n" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+            msoLogger.error("Exception occured while executing VF-C Post Call. Exception is: \n" + e.getMessage());
             throw new BpmnError("MSOWorkflowException")
         }
         return apiResponse
@@ -226,24 +252,37 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
      * url: the url of the request
      * requestBody: the body of the request
      */
-    private Response deleteRequest(DelegateExecution execution, String url, String requestBody){
+    private APIResponse deleteRequest(DelegateExecution execution, String url, String requestBody){
 
         msoLogger.trace("Started Execute VFC adapter Delete Process ")
         msoLogger.info("url:"+url +"\nrequestBody:"+ requestBody)
-               Response r
-        try{
-
-                       URL Url = new URL(url)
-                       HttpClient httpClient = new HttpClient(Url, "application/json", TargetEntity.VNF_ADAPTER)
-                       httpClient.addAdditionalHeader("Accept", "application/json")
-                       httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk")
-                       r = httpClient.delete(requestBody)
-
-            msoLogger.trace("Completed Execute VF-C adapter Delete Process ")
-        }catch(Exception e){
-            msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing VF-C Post Call. Exception is: \n" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
-            throw new BpmnError("MSOWorkflowException")
-        }
-        return r
+       
+               APIResponse apiResponse = null
+               try{
+                       // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7'
+                       def basicAuthHeaderValue = ""
+                       RESTConfig config = new RESTConfig(url)
+                       RESTClient client = null;
+                       int statusCode = 0;
+                       
+                       // user 'bepl' authHeader is the same with mso.db.auth
+                       String basicAuthValuedb =  UrnPropertiesReader.getVariable("mso.db.auth", execution)
+                       msoLogger.debug("basicAuthValuedb: " + basicAuthValuedb)
+       
+                       client = new RESTClient(config)
+                       client.addHeader("Accept", "application/json")
+                       client.addAuthorizationHeader(basicAuthValuedb)
+                       client.addHeader("Content-Type", "application/json")
+                       
+                       apiResponse = client.httpDelete(requestBody)
+                       statusCode = apiResponse.getStatusCode()
+                               
+                       msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString())
+               
+               }catch(Exception e){
+                       msoLogger.error("Exception occured while executing VF-C Delete Call. Exception is: \n" + e.getMessage());
+                       throw new BpmnError("MSOWorkflowException")
+               }
+        return apiResponse
     }
 }
index e753f79..95b826f 100644 (file)
@@ -436,14 +436,19 @@ public class ServicePluginFactory {
                
                Map<String, String> keys = uri.getURIKeys();
                String uriString = uri.build().toString();
-               AAIResourceUri parent = AAIUriFactory.createResourceUri(AAIObjectType.PNF, keys.get("pnf-name"));
-               
-               AAIResultWrapper wrapper = client.get(parent);
-               Optional<Relationships> optRelationships = wrapper.getRelationships();
-               if (optRelationships.isPresent()) {
-                       Relationships relationships = optRelationships.get();
-                       
-                       return !relationships.getRelatedAAIUris(AAIObjectType.EXT_AAI_NETWORK).isEmpty();
+
+               if (uriString != null) {
+                       // get the pnfname
+                       String[] token = uriString.split("/");
+                       AAIResourceUri parent = AAIUriFactory.createResourceUri(AAIObjectType.PNF, token[4]);
+
+                       AAIResultWrapper wrapper = client.get(parent);
+                       Optional<Relationships> optRelationships = wrapper.getRelationships();
+                       if (optRelationships.isPresent()) {
+                               Relationships relationships = optRelationships.get();
+
+                               return !relationships.getRelatedAAIUris(AAIObjectType.EXT_AAI_NETWORK).isEmpty();
+                       }
                }
                
                return false;
index 0a00a61..3108ada 100644 (file)
@@ -289,9 +289,8 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
 
     protected boolean isSend2SdncDirectly() {
         logger.info("AbstractSdncOperationTask.isSend2SdncDirectly begin!");
-            String sdncIp = UrnPropertiesReader.getVariable("sdnc-ip");
-            String sdncPort = UrnPropertiesReader.getVariable("sdnc-port");
-            if (!StringUtils.isBlank(sdncIp) && isIp(sdncIp) && !StringUtils.isBlank(sdncPort)) {
+        String sdncHost = UrnPropertiesReader.getVariable("sdnc.host");
+            if (!StringUtils.isBlank(sdncHost)) {
                 logger.info("AbstractSdncOperationTask.isSend2SdncDirectly = true.");
                 return true;
             }
@@ -317,6 +316,12 @@ public abstract class AbstractSdncOperationTask extends BaseTask {
         return returnPort;
     }
 
+    protected String getSdncHost() {
+        String sdncHost = UrnPropertiesReader.getVariable("sdnc.host");
+        logger.info("AbstractSdncOperationTask.getSdncPort: returnPort = {}", sdncHost);
+        return sdncHost;
+    }
+
     private GenericResourceApi getGenericResourceApiClient() {
         logger.info("AbstractSdncOperationTask.getGenericResourceApiClient begin!");
         String msbIp = System.getenv().get(ONAP_IP);
index 8e41d0d..dc625d3 100644 (file)
@@ -72,7 +72,7 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask
     private void send2SdncDirectly(String defaulAuth,
                                    RpcServiceTopologyOperationInputEntity inputEntity) throws RouteException {
         sdncLogger.info("SdncServiceTopologyOperationTask.send2SdncDirectly begin!");
-        String url = "http://" + getSdncIp() + ":" + getSdncPort() + URL;
+        String url = getSdncHost() + URL;
         HttpPost httpPost = new HttpPost(url);
         httpPost.addHeader("Authorization", defaulAuth);
         httpPost.addHeader("Content-type", "application/json");
index 94eead2..acef0cb 100644 (file)
@@ -84,6 +84,7 @@ public class ExecuteActivity implements JavaDelegate {
                        variables.put("buildingBlock", executeBuildingBlock);
                        variables.put("mso-request-id", requestId);
                        variables.put("retryCount", 1); 
+                       variables.put("aLaCarte", true);        
                
                    ProcessInstanceWithVariables buildingBlockResult = runtimeService.createProcessInstanceByKey("ExecuteBuildingBlock").setVariables(variables).executeWithVariablesInReturn();
                        VariableMap variableMap = buildingBlockResult.getVariables();
index b0063c1..2065dfb 100644 (file)
@@ -105,6 +105,10 @@ public class OrchestrationStatusValidator {
                                org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID, execution.getLookupMap().get(ResourceKey.CONFIGURATION_ID));
                                orchestrationStatus = configuration.getOrchestrationStatus();
                                break;
+                       case NO_VALIDATE:
+                               //short circuit and exit method
+                               execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, OrchestrationStatusValidationDirective.VALIDATION_SKIPPED);
+                               return;
                        default:
                                // can't currently get here, so not tested. Added in case enum is expanded without a change to this code
                                throw new OrchestrationStatusValidationException(String.format(UNKNOWN_RESOURCE_TYPE, buildingBlockFlowName, buildingBlockDetail.getResourceType(), buildingBlockDetail.getTargetAction()));
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java
new file mode 100644 (file)
index 0000000..4ace272
--- /dev/null
@@ -0,0 +1,45 @@
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.when;
+
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.db.catalog.beans.BuildingBlockDetail;
+import org.onap.so.db.catalog.beans.OrchestrationAction;
+import org.onap.so.db.catalog.beans.OrchestrationStatusValidationDirective;
+import org.onap.so.db.catalog.beans.ResourceType;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+
+@RunWith(MockitoJUnitRunner.class)
+public class OrchestrationStatusValidatorUnitTest {
+
+       @Mock
+       private CatalogDbClient catalogDbClient;
+       
+       @InjectMocks
+       private OrchestrationStatusValidator validator;
+       @Test
+       public void skipValidationTest() {
+               BuildingBlockDetail bbDetail = new BuildingBlockDetail();
+               bbDetail.setBuildingBlockName("customBB");
+               bbDetail.setResourceType(ResourceType.NO_VALIDATE);
+               bbDetail.setTargetAction(OrchestrationAction.CUSTOM);
+               when(catalogDbClient.getBuildingBlockDetail("customBB")).thenReturn(bbDetail);
+               BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
+               execution.setVariable("flowToBeCalled", "customBB");
+               execution.setVariable("aLaCarte", false);
+               validator.validateOrchestrationStatus(execution);
+               
+               
+               assertThat(execution.getVariable("orchestrationStatusValidationResult"), equalTo(OrchestrationStatusValidationDirective.VALIDATION_SKIPPED));
+       }
+       
+}
index 9c4b573..b991e79 100644 (file)
@@ -42,8 +42,6 @@ public class HttpClient extends RestClient {
 
        @Override
        protected void initializeHeaderMap(Map<String, String> headerMap) {
-               headerMap.put("Authorization", "Basic YnBlbDpwYXNzd29yZDEk");
-               headerMap.put("content-type", "application/json");
        }
 
        @Override
index d6791d3..4521604 100644 (file)
@@ -5,7 +5,7 @@
 SO Offered and Consumed APIs
 =====================================
 
-The list of APIs that SO offerers could be found in the following table:
+The list of APIs that SO offers can be found in following table:
 
 .. |yml-icon| image:: swagger/images/yaml.png
               :width: 40px
similarity index 62%
rename from docs/release_notes/release-notes.rst
rename to docs/release-notes.rst
index 4ca1a01..1cb4ba1 100644 (file)
@@ -8,6 +8,64 @@ Service Orchestrator Release Notes
 
 The SO provides the highest level of service orchestration in the ONAP architecture. 
 
+Version: 1.3.3
+--------------
+
+:Release Date: 2018-11-30
+
+This is the official release package that was tested against the 72 hour stability test in integration environment.
+
+Casablanca Release branch
+
+**New Features**
+
+Features delivered in this release:
+
+ - Automatic scale out of VNFs.
+ - Extend the support of homing to vFW, vCPE usecases through HPA.
+ - Monitoring BPMN workflow capabilities through UI.
+ - SO internal architecture improvements.
+ - Support PNF resource type.
+ - Support to the CCVPN Usecase.
+ - Workflow Designer Integration.
+
+**Docker Images**
+
+Dockers released for SO:
+
+ - onap/so/api-handler-infra,1.3.3
+ - onap/so/bpmn-infra,1.3.3
+ - onap/so/catalog-db-adapter,1.3.3
+ - onap/so/openstack-adapter,1.3.3
+ - onap/so/request-db-adapter,1.3.3
+ - onap/so/sdc-controller,1.3.3
+ - onap/so/sdnc-adapter,1.3.3
+ - onap/so/so-monitoring,1.3.3
+ - onap/so/vfc-adapter,1.3.3
+
+**Known Issues**
+
+There are some issues around the HPA and CCVPN that have been resolved in the patch release of 1.3.5
+- `SO-1249 <https://jira.onap.org/browse/SO-1249>`_
+- `SO-1257 <https://jira.onap.org/browse/SO-1257>`_
+- `SO-1258 <https://jira.onap.org/browse/SO-1258>`_
+- `SO-1256 <https://jira.onap.org/browse/SO-1256>`_
+- `SO-1194 <https://jira.onap.org/browse/SO-1256>`_
+       
+Below issues will be resolved in the next release:
+- `SO-1248 <https://jira.onap.org/browse/SO-1248>`_
+- `SO-1184 <https://jira.onap.org/browse/SO-1184>`_
+
+**Security Notes**
+
+       SO code has been formally scanned during build time using NexusIQ and all Critical vulnerabilities have been addressed, items that remain open have been assessed for risk and determined to be false positive. The SO open Critical security vulnerabilities and their risk assessment have been documented as part of the `project <https://wiki.onap.org/pages/viewpage.action?pageId=43385708>`_.
+
+       Quick Links:
+
+ - `SO project page <https://wiki.onap.org/display/DW/Service+Orchestrator+Project>`_
+ - `Passing Badge information for SO <https://bestpractices.coreinfrastructure.org/en/projects/1702>`_
+ - `Project Vulnerability Review Table for SO <https://wiki.onap.org/pages/viewpage.action?pageId=43385708>`_
+
 Version: 1.3.1
 --------------
 
@@ -17,12 +75,14 @@ Branch cut for Casablanca post M4 for integration test.
 **New Features**
 
 Below  features are under test:
-* Support PNF resource type.
-* Extend the support of homing to vFW, VDNS usecases.
-* Workflow Designer Integration.
-* Monitoring BPMN worflow capabilities through UI.
-* Support to the CCVPN Usecase.
-* SO internal architecture improvements 
+ - Automatic scale out of VNFs.
+ - Extend the support of homing to vFW, vCPE usecases through HPA.
+ - Monitoring BPMN workflow capabilities through UI.
+ - SO internal architecture improvements.
+ - Support PNF resource type.
+ - Support to the CCVPN Usecase.
+ - Workflow Designer Integration.
+
 
 Version: 1.3.0
 --------------
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java
new file mode 100644 (file)
index 0000000..ef474be
--- /dev/null
@@ -0,0 +1,152 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018. Intel Corp. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.db.catalog.beans;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.openpojo.business.annotation.BusinessKey;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import uk.co.blackpepper.bowman.annotation.RemoteResource;
+import uk.co.blackpepper.bowman.annotation.ResourceId;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import java.net.URI;
+
+/**
+ * EntityBean class for a HomingInstance.  This bean represents a homing instance
+ * of a service, populated on successful homing
+ *
+ */
+@RemoteResource("/homingInstance")
+@Entity
+@Table(name = "homing_instances")
+public class HomingInstance {
+    @JsonProperty
+    @BusinessKey
+    @Id
+    @Column(name = "SERVICE_INSTANCE_ID")
+    private String serviceInstanceId;
+
+    @JsonProperty("cloud_region_id")
+    @BusinessKey
+    @Column(name = "CLOUD_REGION_ID")
+    private String cloudRegionId;
+
+    @JsonProperty("cloud_owner")
+    @BusinessKey
+    @Column(name = "CLOUD_OWNER")
+    private String cloudOwner;
+
+
+
+    @JsonProperty("oof_directives")
+    @BusinessKey
+    @Column(name = "OOF_DIRECTIVES", columnDefinition = "LONGTEXT")
+    private String oofDirectives;
+
+    @Transient
+    private URI uri;
+
+    public HomingInstance () {
+
+    }
+
+    public HomingInstance (HomingInstance homingInstance) {
+        this.serviceInstanceId = homingInstance.getServiceInstanceId();
+        this.cloudRegionId = homingInstance.getCloudRegionId();
+        this.cloudOwner = homingInstance.getCloudOwner();
+        this.oofDirectives = homingInstance.getOofDirectives();
+    }
+
+
+    public String getServiceInstanceId() {
+        return this.serviceInstanceId;
+    }
+
+    public void setServiceInstanceId(String serviceInstanceId) {
+
+        this.serviceInstanceId = serviceInstanceId;
+    }
+
+    public String getCloudRegionId() {
+
+        return this.cloudRegionId;
+    }
+
+    public void setCloudRegionId(String cloudRegionId) {
+
+        this.cloudRegionId = cloudRegionId;
+    }
+
+    public String getCloudOwner() {
+
+        return this.cloudOwner;
+    }
+
+    public void setCloudOwner (String cloudOwner) {
+
+        this.cloudOwner = cloudOwner;
+    }
+
+    public String getOofDirectives() {
+        return oofDirectives;
+    }
+
+    public void setOofDirectives(String oofDirectives) {
+        this.oofDirectives = oofDirectives;
+    }
+
+    @ResourceId
+    public URI getUri() {
+        return this.uri;
+    }
+
+    public void setUri(URI uri) {
+
+        this.uri = uri;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this).append("serviceInstanceId", serviceInstanceId)
+                .append("cloudRegionId", cloudRegionId)
+                .append("cloudOwner", cloudOwner)
+                .append("oofDirectives", oofDirectives).toString();
+    }
+
+    @Override
+    public boolean equals(final Object other) {
+        if (!(other instanceof HomingInstance)) {
+            return false;
+        }
+        HomingInstance castOther = (HomingInstance) other;
+        return new EqualsBuilder().append(serviceInstanceId, castOther.serviceInstanceId).isEquals();
+    }
+
+    @Override
+    public int hashCode() {
+        return new HashCodeBuilder().append(serviceInstanceId).toHashCode();
+    }
+}
index 544e1cb..f92aadf 100644 (file)
@@ -22,7 +22,7 @@ package org.onap.so.db.catalog.beans;
 
 //TODO find this file a new location?
 public enum OrchestrationStatusValidationDirective {
-       SILENT_SUCCESS("SilentSuccess"), CONTINUE("Continue"), FAIL("Fail");
+       SILENT_SUCCESS("SilentSuccess"), CONTINUE("Continue"), FAIL("Fail"), VALIDATION_SKIPPED("ValidationSkiPped");
 
        private final String name;
 
index 8e1d498..64eff56 100644 (file)
@@ -28,7 +28,7 @@ public enum ResourceType {
        NETWORK("Network"),
        NETWORK_COLLECTION("NetworkCollection"),
        CONFIGURATION("Configuration"),
-       CUSTOM("Custom");
+       NO_VALIDATE("NoValidate");
        
        private final String name;
        
index 764d2b7..83fe051 100644 (file)
@@ -43,6 +43,8 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import com.openpojo.business.annotation.BusinessKey;
 
+import org.hibernate.annotations.NotFound;
+import org.hibernate.annotations.NotFoundAction;
 import uk.co.blackpepper.bowman.annotation.LinkedResource;
 
 @Entity
@@ -91,6 +93,7 @@ public class VnfResource implements Serializable {
        private Date created;
 
        @ManyToOne(fetch = FetchType.LAZY)
+       @NotFound(action = NotFoundAction.IGNORE)
        @JoinColumn(name = "HEAT_TEMPLATE_ARTIFACT_UUID")
        private HeatTemplate heatTemplates;
 
index 8a61102..98addf9 100644 (file)
@@ -36,6 +36,7 @@ import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization
 import org.onap.so.db.catalog.beans.ControllerSelectionReference;
 import org.onap.so.db.catalog.beans.CvnfcCustomization;
 import org.onap.so.db.catalog.beans.ExternalServiceToInternalService;
+import org.onap.so.db.catalog.beans.HomingInstance;
 import org.onap.so.db.catalog.beans.InstanceGroup;
 import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
 import org.onap.so.db.catalog.beans.NetworkRecipe;
@@ -125,6 +126,7 @@ public class CatalogDbClient {
        private static final String WORK_STEP = "workStep";
        private static final String CLLI = "clli";
        private static final String CLOUD_VERSION = "cloudVersion";
+       private static final String HOMING_INSTANCE = "/homingInstance";
        
        private static final String TARGET_ENTITY = "SO:CatalogDB";
 
@@ -153,6 +155,8 @@ public class CatalogDbClient {
        private String findOneByActionAndRequestScopeAndIsAlacarte = "/findOneByActionAndRequestScopeAndIsAlacarte";
        private String findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep = "/findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep";
        private String findByClliAndCloudVersion = "/findByClliAndCloudVersion";
+       private String findServiceByServiceInstanceId = "/findServiceByServiceInstanceId";
+
 
        private String serviceURI;
        private String vfModuleURI;
@@ -165,6 +169,7 @@ public class CatalogDbClient {
        private String instanceGroupURI;
        private String cloudifyManagerURI;
        private String cloudSiteURI;
+       private String homingInstanceURI;
 
        private final Client<Service> serviceClient;
 
@@ -210,6 +215,8 @@ public class CatalogDbClient {
 
        private final Client<CloudSite> cloudSiteClient;
 
+       private final Client<HomingInstance> homingInstanceClient;
+
        private final Client<CloudifyManager> cloudifyManagerClient;
        
        private Client<CvnfcCustomization> cvnfcCustomizationClient;
@@ -262,6 +269,7 @@ public class CatalogDbClient {
                instanceGroupURI = endpoint + INSTANCE_GROUP + URI_SEPARATOR;
                cloudifyManagerURI = endpoint + CLOUDIFY_MANAGER + URI_SEPARATOR;
                cloudSiteURI = endpoint + CLOUD_SITE + URI_SEPARATOR;
+               homingInstanceURI = endpoint + HOMING_INSTANCE + URI_SEPARATOR;
 
        }
 
@@ -300,6 +308,7 @@ public class CatalogDbClient {
                networkCollectionResourceCustomizationClient = clientFactory.create(NetworkCollectionResourceCustomization.class);
                collectionNetworkResourceCustomizationClient = clientFactory.create(CollectionNetworkResourceCustomization.class);
                cloudSiteClient = clientFactory.create(CloudSite.class);
+               homingInstanceClient = clientFactory.create(HomingInstance.class);
                cloudifyManagerClient = clientFactory.create(CloudifyManager.class);
                serviceRecipeClient = clientFactory.create(ServiceRecipe.class);
                cvnfcCustomizationClient = clientFactory.create(CvnfcCustomization.class);
@@ -342,6 +351,7 @@ public class CatalogDbClient {
                networkCollectionResourceCustomizationClient = clientFactory.create(NetworkCollectionResourceCustomization.class);
                collectionNetworkResourceCustomizationClient = clientFactory.create(CollectionNetworkResourceCustomization.class);
                cloudSiteClient = clientFactory.create(CloudSite.class);
+               homingInstanceClient = clientFactory.create(HomingInstance.class);
                cloudifyManagerClient = clientFactory.create(CloudifyManager.class);
                serviceRecipeClient = clientFactory.create(ServiceRecipe.class);
                cvnfcCustomizationClient = clientFactory.create(CvnfcCustomization.class);
@@ -583,7 +593,13 @@ public class CatalogDbClient {
        }
 
        public CloudSite getCloudSite(String id){
-               return this.getSingleResource(cloudSiteClient, getUri(cloudSiteURI + id));
+               return this.getSingleResource(cloudSiteClient,
+                               getUri(cloudSiteURI + id));
+       }
+
+       public CloudSite getCloudSite(String id, String uri){
+               return this.getSingleResource(cloudSiteClient,
+                               getUri(uri + id));
        }
 
        public void postCloudSite(CloudSite cloudSite){
@@ -596,6 +612,20 @@ public class CatalogDbClient {
                                .queryParam(CLLI,clli).queryParam(CLOUD_VERSION,cloudVersion).build().toString()));
        }
 
+       public HomingInstance getHomingInstance (String serviceInstanceId){
+               return this.getSingleResource(homingInstanceClient,
+                               getUri(homingInstanceURI + serviceInstanceId));
+       }
+
+       public HomingInstance getHomingInstance (String serviceInstanceId, String uri){
+               return this.getSingleResource(homingInstanceClient,
+                               getUri(uri + serviceInstanceId));
+       }
+
+       public void postHomingInstance(HomingInstance homingInstance){
+               this.postSingleResource(homingInstanceClient, homingInstance);
+       }
+
        public Service getServiceByModelVersionAndModelInvariantUUID(String modelVersion, String modelInvariantUUID) {
                return this.getSingleResource(serviceClient, getUri(UriBuilder
                                .fromUri(findFirstByModelVersionAndModelInvariantUUIDURI)
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HomingInstanceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HomingInstanceRepository.java
new file mode 100644 (file)
index 0000000..aea8d3e
--- /dev/null
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018. Intel Corp. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.db.catalog.data.repository;
+
+import org.onap.so.db.catalog.beans.HomingInstance;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
+
+@RepositoryRestResource(collectionResourceRel = "homingInstance", path = "homingInstance")
+public interface HomingInstanceRepository extends JpaRepository<HomingInstance, String> {
+       HomingInstance findServiceByServiceInstanceId(String serviceInstanceId);
+}
index 7967390..2e8f423 100644 (file)
@@ -30,6 +30,7 @@ import { environment } from '../environments/environment';
 import { HttpResponse } from '@angular/common/http';\r
 import { PII } from './model/processInstance.model';\r
 import { HttpErrorHandlerService } from './http-error-handler.service';\r
+import { ACTINST } from './model/activityInstance.model';\r
 \r
 \r
 @Injectable({\r
@@ -59,12 +60,12 @@ export class DataService {
   }\r
 \r
   // HTTP GET to return Activity instancs using ProcessInstanceID\r
-  getActivityInstance(processInstanceId) {\r
+  getActivityInstance(processInstanceId): Promise<ACTINST[]> {\r
     var url = environment.soMonitoringBackendURL + 'activity-instance/' + processInstanceId;\r
-    return this.http.get(url)\r
+    return this.http.get<ACTINST[]>(url)\r
       .pipe(\r
         catchError(this.httpErrorHandlerService.handleError("GET", url))\r
-      );\r
+      ).toPromise();\r
   }\r
 \r
   // HTTP GET to return Activity Instance using ProcessInstanceID\r
index 4c19ba1..bb464a9 100644 (file)
@@ -43,7 +43,6 @@ import { NgxSpinnerService } from 'ngx-spinner';
 })\r
 \r
 export class DetailsComponent implements OnInit {\r
-\r
   bpmnViewer: any;\r
 \r
   processInstanceID: string;\r
@@ -67,8 +66,8 @@ export class DetailsComponent implements OnInit {
   constructor(private route: ActivatedRoute, private data: DataService, private popup: ToastrNotificationService,\r
     private router: Router, private spinner: NgxSpinnerService) { }\r
 \r
-  getActInst(procInstId: string) {\r
-    this.data.getActivityInstance(procInstId).subscribe(\r
+  async getActInst(procInstId: string) {\r
+    await this.data.getActivityInstance(procInstId).then(\r
       (data: ACTINST[]) => {\r
         this.activityInstance = data;\r
         console.log(data);\r
@@ -90,7 +89,7 @@ export class DetailsComponent implements OnInit {
       });\r
   }\r
 \r
-  async  getProcInstance(procInstId) {\r
+  async getProcInstance(procInstId) {\r
     await this.data.getProcessInstance(procInstId).then(\r
       async (data: PII) => {\r
         this.processInstance = data;\r
@@ -160,4 +159,5 @@ export class DetailsComponent implements OnInit {
         this.getVarInst(this.processInstanceID);\r
       });\r
   }\r
+\r
 }\r
index 003abf9..f0c63fe 100644 (file)
@@ -24,5 +24,5 @@ SPDX-License-Identifier: Apache-2.0
 export const environment = {
   production: false,
 
-  soMonitoringBackendURL: 'http://so-monitoring:9091/so/monitoring/'
+  soMonitoringBackendURL: 'http://so-monitoring:30224/so/monitoring/'
 };
index 0969948..d1d81a0 100644 (file)
@@ -4,7 +4,7 @@
 
 major=1
 minor=3
-patch=2
+patch=5
 
 base_version=${major}.${minor}.${patch}