From: Benjamin, Max (mb388a) Date: Fri, 25 Jan 2019 22:08:41 +0000 (-0500) Subject: Merge 'origin/casablanca' into master X-Git-Tag: 1.4.1~336^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=fe91155454a27401e8c23780fa247c0ede196747;p=so.git Merge 'origin/casablanca' into master Issue-ID: SO-1435 Change-Id: If065ef5c91e769452fd6701fa6c28a23b4bdf2b2 Signed-off-by: Smokowski, Steve (ss835w) --- fe91155454a27401e8c23780fa247c0ede196747 diff --cc adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java index c9b70610d1,8d700751a9..5c0110b680 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java @@@ -28,12 -27,12 +28,9 @@@ import java.util.List import java.util.Map; import java.util.Scanner; -import javax.ws.rs.core.UriBuilder; --import javax.ws.rs.core.UriBuilderException; import javax.ws.rs.core.Response; ++import javax.ws.rs.core.UriBuilderException; - import org.onap.so.client.HttpClientFactory; --import org.slf4j.Logger; --import org.slf4j.LoggerFactory; import org.onap.so.adapters.vdu.CloudInfo; import org.onap.so.adapters.vdu.PluginAction; import org.onap.so.adapters.vdu.VduArtifact; @@@ -44,20 -43,28 +41,25 @@@ import org.onap.so.adapters.vdu.VduMode import org.onap.so.adapters.vdu.VduPlugin; import org.onap.so.adapters.vdu.VduStateType; import org.onap.so.adapters.vdu.VduStatus; ++import org.onap.so.client.HttpClientFactory; ++import org.onap.so.client.RestClient; ++import org.onap.so.db.catalog.beans.CloudSite; ++import org.onap.so.logger.MessageEnum; ++import org.onap.so.logger.MsoLogger; 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; -import org.onap.so.client.HttpClient; --import org.onap.so.client.RestClient; --import org.onap.so.db.catalog.beans.CloudSite; --import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoAlarmLogger; --import org.onap.so.logger.MsoLogger; import org.onap.so.utils.TargetEntity; ++import org.slf4j.Logger; ++import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; import org.springframework.stereotype.Component; -import com.fasterxml.jackson.core.JsonProcessingException; + import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.woorea.openstack.heat.model.CreateStackParam; @@@ -215,9 -215,14 +210,13 @@@ public class MsoMulticloudUtils extend } return getStackStatus(cloudSiteId, tenantId, createInfo.getCanonicalName(), pollForCompletion, timeoutMinutes, backout); } else { - createInfo.setStatus(HeatStatus.FAILED); - createInfo.setStatusMessage(response.getStatusInfo().getReasonPhrase()); - return createInfo; + StringBuilder stackErrorStatusReason = new StringBuilder(response.getStatusInfo().getReasonPhrase()); + if (null != multicloudResponseBody) { + stackErrorStatusReason.append(multicloudResponseBody.toString()); + } + MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString()); + me.addContext(CREATE_STACK); - alarmLogger.sendAlarm(HEAT_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage()); + throw me; } } diff --cc adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql index 9eb3daa5ae,5b2ba3d11a..3e92b5d7ba --- a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql +++ b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql @@@ -210,16 -213,14 +218,26 @@@ INSERT INTO vnf_components_recipe (VNF_ VALUES ('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"}]}'); + + -- for query resource receipe + INSERT INTO allotted_resource + (MODEL_UUID, MODEL_INVARIANT_UUID, MODEL_VERSION, MODEL_NAME, TOSCA_NODE_TYPE, SUBCATEGORY, DESCRIPTION, CREATION_TIMESTAMP) + VALUES('25e2d69b-3b22-47b8-b4c9-7b14fd4a80df', '8f5fe343-9a3a-4d31-a829-49b27bbfc1c4', '2.0', 'sotnvpnattachmentvF', 'org.openecomp.resource.vf.Sdwanvpnattachmentvf', 'Allotted Resource', 'sdwanvpnattachmentVF', '2019-01-24 09:59:16.000'); + INSERT INTO ar_recipe(ID, MODEL_NAME, ACTION, VERSION_STR, SERVICE_TYPE, DESCRIPTION, ORCHESTRATION_URI, AR_PARAM_XSD, RECIPE_TIMEOUT, CREATION_TIMESTAMP) + VALUES(1, 'sotnvpnattachmentvF', 'createInstance', '2.0', 'VF', 'sotnvpnattachmentvF', '/mso/async/services/CreateSDNCNetworkResource', '', 180, '2019-01-24 09:59:16.000'); +INSERT INTO northbound_request_ref_lookup(MACRO_ACTION, ACTION, REQUEST_SCOPE, IS_ALACARTE, MIN_API_VERSION, MAX_API_VERSION, CLOUD_OWNER, SERVICE_TYPE) VALUES +('Service-Create', 'createInstance', 'Service', true, '7','7', 'my-custom-cloud-owner','*'); + + +INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID) VALUES +('Service-Create', '1', 'AssignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Create' and CLOUD_OWNER = 'my-custom-cloud-owner')); + +INSERT INTO northbound_request_ref_lookup(MACRO_ACTION, ACTION, REQUEST_SCOPE, IS_ALACARTE, MIN_API_VERSION, MAX_API_VERSION, CLOUD_OWNER, SERVICE_TYPE) VALUES +('Service-Create', 'createInstance', 'Service', true, '7','7', 'my-custom-cloud-owner','TRANSPORT'); + +INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID) VALUES +('Service-Create', '1', 'AssignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Create' and CLOUD_OWNER = 'my-custom-cloud-owner' and SERVICE_TYPE = 'TRANSPORT')); diff --cc asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java index 486844ae02,0fde1332d6..cd9a121ddb --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java @@@ -20,15 -20,11 +20,17 @@@ package org.onap.so.asdc.installer.bpmn; -import java.io.*; +import java.io.BufferedOutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.URI; import java.nio.file.Path; import java.nio.file.Paths; + import java.util.Enumeration; -import java.util.zip.*; +import java.util.zip.ZipEntry; ++import java.util.zip.ZipFile; +import java.util.zip.ZipInputStream; import org.apache.commons.io.IOUtils; import org.apache.http.HttpEntity; @@@ -109,10 -106,34 +111,34 @@@ public class BpmnInstaller } return; } + + public boolean containsWorkflows(String csarFilePath) { + boolean workflowsInCsar = false; + try { + ZipFile zipFile = new ZipFile(csarFilePath); + Enumeration zipEntries = zipFile.entries(); + while (zipEntries.hasMoreElements()) { + String fileName = ((ZipEntry) zipEntries.nextElement()).getName(); + if (fileName.endsWith(BPMN_SUFFIX)) { + workflowsInCsar = true; + break; + } + } + } + catch (Exception e) { + LOGGER.debug("Exception :",e); + LOGGER.error(MessageEnum.ASDC_ARTIFACT_CHECK_EXC, + csarFilePath, + "", + "", + e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "ASDC Unable to check CSAR entries"); + } + return workflowsInCsar; + } - protected HttpResponse sendDeploymentRequest(String bpmnFileName) throws Exception { + protected HttpResponse sendDeploymentRequest(String bpmnFileName) throws Exception { HttpClient client = HttpClientBuilder.create().build(); - String deploymentUri = this.env.getProperty(CAMUNDA_URL) + CREATE_DEPLOYMENT_PATH; + URI deploymentUri = new URI(this.env.getProperty(CAMUNDA_URL) + CREATE_DEPLOYMENT_PATH); HttpPost post = new HttpPost(deploymentUri); RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(1000000).setConnectTimeout(1000).setConnectionRequestTimeout(1000).build(); diff --cc asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index e455d2da93,aa1e1a8bd9..7951e9be76 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@@ -25,18 -25,26 +25,23 @@@ package org.onap.so.asdc.installer.heat import java.sql.Timestamp; import java.util.ArrayList; import java.util.Date; + import java.util.HashMap; import java.util.HashSet; + import java.util.LinkedHashMap; import java.util.List; + import java.util.Map; import java.util.Optional; import java.util.Set; + import java.util.stream.Collectors; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.Gson; import org.hibernate.exception.ConstraintViolationException; import org.hibernate.exception.LockAcquisitionException; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.sdc.api.notification.IResourceInstance; import org.onap.sdc.api.notification.IStatusData; + import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; -import org.onap.sdc.tosca.parser.impl.SdcPropertyNames; import org.onap.sdc.tosca.parser.enums.SdcTypes; +import org.onap.sdc.tosca.parser.impl.SdcPropertyNames; import org.onap.sdc.toscaparser.api.CapabilityAssignment; import org.onap.sdc.toscaparser.api.CapabilityAssignments; import org.onap.sdc.toscaparser.api.Group; @@@ -118,6 -132,6 +127,9 @@@ import org.springframework.beans.factor import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; ++import com.fasterxml.jackson.core.JsonProcessingException; ++import com.fasterxml.jackson.databind.ObjectMapper; ++ @Component public class ToscaResourceInstaller { @@@ -137,6 -151,6 +149,7 @@@ protected static final String MSO = "SO"; ++ @Autowired protected ServiceRepository serviceRepo; @@@ -145,7 -159,10 +158,7 @@@ @Autowired protected ServiceProxyResourceCustomizationRepository serviceProxyCustomizationRepo; - + - @Autowired - protected ServiceProxyResourceRepository serviceProxyRepo; - @Autowired protected CollectionResourceRepository collectionRepo; @@@ -267,9 -284,9 +280,9 @@@ @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... @@@ -278,9 -295,10 +291,23 @@@ createToscaCsar(toscaResourceStruct); createService(toscaResourceStruct, vfResourceStruct); Service service = toscaResourceStruct.getCatalogService(); -- ++ List 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); ++ } ++ + processResourceSequence(toscaResourceStruct, service); processVFResources(toscaResourceStruct, service, vfResourceStructure); -- processAllottedResources(toscaResourceStruct, service); ++ List allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources(); ++ processAllottedResources(toscaResourceStruct, service, allottedResourceList); processNetworks(toscaResourceStruct, service); // process Network Collections processNetworkCollections(toscaResourceStruct, service); @@@ -331,8 -473,8 +482,8 @@@ Service service) throws ArtifactInstallerException { List nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper ().getServiceVlList (); -- if (nodeTemplatesVLList != null) { -- for (NodeTemplate vlNode : nodeTemplatesVLList) { ++ if (nodeTemplatesVLList != null) { ++ for (NodeTemplate vlNode : nodeTemplatesVLList) { String networkResourceModelName = vlNode.getMetaData ().getValue (SdcPropertyNames.PROPERTY_NAME_NAME); TempNetworkHeatTemplateLookup tempNetworkLookUp = @@@ -353,30 -495,32 +504,29 @@@ } else { throw new ArtifactInstallerException ("No HeatTemplate found for artifactUUID: " + tempNetworkLookUp.getHeatTemplateArtifactUuid ()); -- } -- } else { ++ } ++ } else { NetworkResourceCustomization networkCustomization = createNetwork (vlNode, toscaResourceStruct, null, null, null, service); - networkCustomization.setResourceInput(getResourceInput(toscaResourceStruct, networkCustomization.getModelCustomizationUUID())); - service.getNetworkCustomizations().add (networkCustomization); + service.getNetworkCustomizations().add (networkCustomization); logger.debug ("No NetworkResourceName found in TempNetworkHeatTemplateLookup for " -- + networkResourceModelName); -- } -- -- } -- } ++ + networkResourceModelName); ++ } ++ ++ } ++ } } - protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service) { - protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service) throws ArtifactInstallerException { -- List allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources(); -- ++ protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service, ++ List allottedResourceList) { if (allottedResourceList != null) { - for (NodeTemplate allottedNode : allottedResourceList) { - AllottedResourceCustomization allottedResource = createAllottedResource(allottedNode, toscaResourceStruct, service); - allottedResource.setResourceInput(getResourceInput(toscaResourceStruct, allottedResource.getModelCustomizationUUID())); - service.getAllottedCustomizations().add(allottedResource); + for (NodeTemplate allottedNode : allottedResourceList) { + service.getAllottedCustomizations() + .add(createAllottedResource(allottedNode, toscaResourceStruct, service)); } } } @@@ -478,9 -622,9 +628,9 @@@ logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + " matches vfNotificationResource CustomizationUUID"); -- processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, vfCustomizationUUID); -- } -- else { ++ processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata, ++ vfCustomizationCategory); ++ } else { logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " + "Tosca VF Customization UUID: " + vfCustomizationUUID); @@@ -490,40 -634,41 +640,59 @@@ protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure, -- Service service, NodeTemplate nodeTemplate, String vfCustomizationUUID) -- throws Exception { -- logger.debug("processVfModules for vfCustomizationUUID: " + vfCustomizationUUID); ++ Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory) throws Exception { -- VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service); ++ logger.debug("VF Category is : " + vfCustomizationCategory); -- if (vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty()) { -- Set existingCvnfcSet = new HashSet(); -- Set existingVnfcSet = new HashSet(); - - for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) { - - logger.debug("vfModuleStructure:" + vfModuleStructure.toString()); - List vfGroups = toscaResourceStruct.getSdcCsarHelper() - .getVfModulesByVf(vfCustomizationUUID); - IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata(); - - logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID()); - - Optional 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()); ++ if(vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty()) ++ { + - for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) { - - logger.debug("vfModuleStructure:" + vfModuleStructure.toString()); - List vfGroups = toscaResourceStruct.getSdcCsarHelper() - .getVfModulesByVf(vfCustomizationUUID); - IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata(); - - logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID()); - - Optional 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()); ++ 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"); ++ ++ VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service); ++ ++ Set existingCvnfcSet = new HashSet(); ++ Set existingVnfcSet = new HashSet(); ++ ++ for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) { ++ ++ logger.debug("vfModuleStructure:" + vfModuleStructure.toString()); ++ List vfGroups = toscaResourceStruct ++ .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID); ++ IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata(); ++ ++ logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID()); ++ ++ Optional 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); } } -- - vnfResource.setResourceInput(getResourceInput(toscaResourceStruct, vnfResource.getModelCustomizationUUID())); -- service.getVnfCustomizations().add(vnfResource); } public void processWatchdog(String distributionId, String servideUUID) { @@@ -760,8 -907,12 +929,9 @@@ spCustomizationResource.setModelInstanceName(nodeTemplate.getName()); spCustomizationResource.setToscaNodeType(nodeTemplate.getType()); spCustomizationResource.setSourceService(service); - spCustomizationResource.setServiceProxyResource(spResource); spCustomizationResource.setToscaNodeType(nodeTemplate.getType()); - spCustomizationResource.setServiceProxyResource(spResource); serviceProxyCustomizationSet.add(spCustomizationResource); + - toscaResourceStructure.setCatalogServiceProxyResource(spResource); toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource); diff --cc bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy index 5659c7affa,b03256b098..5e949fd8d2 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy @@@ -30,14 -30,14 +30,14 @@@ import org.onap.so.bpmn.core.domain.Ser 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.AuthenticationType +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.logger.MsoLogger 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 -import org.onap.so.rest.RESTConfig +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.utils.TargetEntity import org.json.JSONArray import org.json.JSONObject diff --cc bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy index c0da8881fb,f72fc47aa5..af33f38a64 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy @@@ -33,23 -33,10 +33,24 @@@ import org.onap.so.bpmn.core.domain.Ser 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.client.HttpClient +import org.onap.so.client.HttpClientFactory import org.onap.so.db.catalog.beans.CloudSite + import org.onap.so.db.catalog.beans.HomingInstance -import javax.ws.rs.core.UriBuilder -import org.onap.so.bpmn.common.util.OofInfraUtils +import org.onap.so.utils.TargetEntity +import org.springframework.http.HttpEntity +import org.springframework.http.HttpHeaders +import org.springframework.http.HttpMethod +import org.springframework.http.ResponseEntity +import org.springframework.http.client.BufferingClientHttpRequestFactory +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory +import org.springframework.web.client.RestTemplate +import org.springframework.web.util.UriComponentsBuilder + +import javax.ws.rs.core.MediaType +import javax.ws.rs.core.Response +import javax.xml.ws.http.HTTPException + import static org.onap.so.bpmn.common.scripts.GenericUtils.* class OofUtils { @@@ -502,31 -491,23 +504,41 @@@ * * @return void */ - Void createCloudSite(CloudSite cloudSite, DelegateExecution execution) { - oofInfraUtils.createCloudSite(cloudSite, execution) - } + Void createCloudSiteCatalogDb(CloudSite cloudSite, DelegateExecution execution) { + + String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution) + String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution) + String uri = "/cloudSite" + + URL url = new URL(endpoint + uri) + HttpClient client = new HttpClientFactory().newJsonClient(url, TargetEntity.EXTERNAL) + client.addAdditionalHeader(HttpHeaders.AUTHORIZATION, auth) + client.addAdditionalHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON) + + Response response = client.post(request.getBody().toString()) + int responseCode = response.getStatus() + logDebug("CatalogDB response code is: " + responseCode, isDebugEnabled) + String syncResponse = response.readEntity(String.class) + logDebug("CatalogDB response is: " + syncResponse, isDebugEnabled) + + if(responseCode != 202){ + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from CatalogDB.") + } + } - ++ + /** + * 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) { - msbHost = UrnPropertiesReader.getVariable("mso.msb.host", execution, "msb-iag.onap") + String msbHost = UrnPropertiesReader.getVariable("mso.msb.host", execution, "msb-iag.onap") Integer msbPort = UrnPropertiesReader.getVariable("mso.msb.port", execution, "80").toInteger() diff --cc bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java index 12a4b2a9c3,44559443a7..025b533dc0 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java @@@ -20,29 -20,32 +20,18 @@@ package org.onap.so.bpmn.common.resource; --import java.io.File; import java.io.IOException; - import java.nio.file.Paths; + import java.lang.reflect.Type; -import java.net.MalformedURLException; import java.util.ArrayList; + import java.util.Arrays; import java.util.HashMap; --import java.util.LinkedHashMap; import java.util.List; import java.util.Map; --import java.util.Optional; -import java.util.logging.Logger; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import org.camunda.bpm.engine.runtime.Execution; --import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; --import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; --import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; --import org.onap.sdc.toscaparser.api.NodeTemplate; --import org.onap.sdc.toscaparser.api.Property; --import org.onap.sdc.toscaparser.api.RequirementAssignment; --import org.onap.sdc.toscaparser.api.RequirementAssignments; --import org.onap.sdc.toscaparser.api.functions.GetInput; --import org.onap.sdc.toscaparser.api.parameters.Input; import org.onap.so.bpmn.core.UrnPropertiesReader; import org.onap.so.bpmn.core.json.JsonUtils; import org.onap.so.client.HttpClient; @@@ -198,91 -148,98 +131,95 @@@ public class ResourceRequestBuilder return result; } - public static Map buildResouceRequest(String serviceUuid, String resourceCustomizationUuid, Map serviceInputs) - throws SdcToscaParserException { - - Map resouceRequest = new HashMap<>(); - - String csarpath = null; + @SuppressWarnings("unchecked") + public static Map buildResouceRequest(String serviceUuid, String resourceCustomizationUuid, Map serviceInputs) { try { - csarpath = getCsarFromUuid(serviceUuid); - } catch(Exception e) { - LOGGER.debug("csar file is not available for service uuid:" + serviceUuid, e); - return resouceRequest; - } + Map serviceInstnace = getServiceInstnace(serviceUuid); - SdcToscaParserFactory toscaParser = SdcToscaParserFactory.getInstance(); - ISdcCsarHelper iSdcCsarHelper = toscaParser.getSdcCsarHelper(csarpath, false); + // find match of customization uuid in vnf + Map> serviceResources = (Map>) serviceInstnace.get("serviceResources"); - List serInput = iSdcCsarHelper.getServiceInputs(); - Optional nodeTemplateOpt = iSdcCsarHelper.getServiceNodeTemplates().stream() - .filter(e -> e.getMetaData().getValue(CUSTOMIZATION_UUID).equals(resourceCustomizationUuid)).findFirst(); + List> serviceVnfCust = (List>) serviceResources.get("serviceVnfs"); + String resourceInputStr = getResourceInputStr(serviceVnfCust, resourceCustomizationUuid); - if(nodeTemplateOpt.isPresent()) { - NodeTemplate nodeTemplate = nodeTemplateOpt.get(); - LinkedHashMap resourceProperties = nodeTemplate.getProperties(); + // find match in network resource + if (resourceInputStr == null) { + List> serviceNetworkCust = (List>) serviceResources.get("serviceNetworks"); + resourceInputStr = getResourceInputStr(serviceNetworkCust, resourceCustomizationUuid); - for(String key : resourceProperties.keySet()) { - Property property = resourceProperties.get(key); - - Object value = getValue(property.getValue(), serviceInputs, serInput); - resouceRequest.put(key, value); + // find match in AR resource + if (resourceInputStr == null) { + List> serviceArCust = (List>) serviceResources.get("serviceAllottedResources"); + resourceInputStr = getResourceInputStr(serviceArCust, resourceCustomizationUuid); + } } + + if (resourceInputStr != null || !resourceInputStr.equals("")) { + return getResourceInput(resourceInputStr, serviceInputs); + } + + } catch (Exception e) { + LOGGER.error("not able to retrieve service instance"); } - return resouceRequest; + return new HashMap(); } - private static Object getValue(Object value, Map serviceInputs, List servInputs) { - if(value instanceof Map) { - Map valueMap = new HashMap<>(); + private static String getResourceInputStr(List> resources, String resCustomizationUuid) { - Map propertyMap = (Map)value; + for (Map resource : resources) { + Map modelInfo = (Map) resource.get("modelInfo"); - for(String key : propertyMap.keySet()) { - valueMap.put(key, getValue(propertyMap.get(key), serviceInputs, servInputs)); + if (modelInfo.get("modelCustomizationUuid").equalsIgnoreCase(resCustomizationUuid)) { + return (String) resource.get("resourceInput"); } - return valueMap; // return if the value is nested hashmap - } else if(value instanceof GetInput) { - String inputName = ((GetInput)value).getInputName(); - - if(serviceInputs.get(inputName) != null) { - value = serviceInputs.get(inputName); - } else { - for(Input input : servInputs) { - if(input.getName().equals(inputName)) { - return input.getDefault(); // return default value - } + } + return null; + } + + // this method combines resource input with service input + private static Map getResourceInput(String resourceInputStr, Map serviceInputs) { + Gson gson = new Gson(); + Type type = new TypeToken>(){}.getType(); + Map resourceInput = gson.fromJson(resourceInputStr, type); + + // replace value if key is available in service input + for (String key: resourceInput.keySet()) { + String value = (String) resourceInput.get(key); + + if (value.contains("|")) { + // node it type of getinput + String[] split = value.split("\\|"); + String tmpKey = split[0]; + if (serviceInputs.containsKey(tmpKey)) { + value = (String) serviceInputs.get(tmpKey); + } else { + value = split[1]; } } + resourceInput.put(key,value); } - return value; // return property value + return resourceInput; } - private static String getCsarFromUuid(String uuid) throws Exception { - String catalogEndPoint = UrnPropertiesReader.getVariable("mso.catalog.db.endpoint"); - HttpClient client = new HttpClientFactory().newJsonClient( - UriBuilder.fromUri(catalogEndPoint).path(SERVICE_URL_TOSCA_CSAR).queryParam("serviceModelUuid", uuid).build().toURL(), - TargetEntity.CATALOG_DB); - - client.addAdditionalHeader("Accept", "application/json"); - // client.addBasicAuthHeader (UrnPropertiesReader.getVariable("mso.adapters.db.auth"), UrnPropertiesReader.getVariable("mso.msoKey")); - client.addAdditionalHeader("Authorization", UrnPropertiesReader.getVariable("mso.db.auth")); - Response response = client.get(); - String value = response.readEntity(String.class); + public static Map getServiceInstnace(String uuid) throws Exception { + String catalogEndPoint = UrnPropertiesReader.getVariable("mso.catalog.db.endpoint"); - HashMap map = new Gson().fromJson(value, new TypeToken>() {}.getType()); - RESTClient restClient = new RESTClient(new RESTConfig( - UriBuilder.fromUri(catalogEndPoint) - .path(SERVICE_URL_SERVICE_INSTANCE) - .queryParam("serviceModelUuid", uuid) - .build().toURL().toString() - )); ++ HttpClient client = new HttpClientFactory().newJsonClient( ++ UriBuilder.fromUri(catalogEndPoint).path(SERVICE_URL_SERVICE_INSTANCE).queryParam("serviceModelUuid", uuid).build().toURL(), ++ TargetEntity.CATALOG_DB); - String filePath = Paths.get(System.getProperty("mso.config.path"), "ASDC", map.get("version"), map.get("name")).normalize().toString(); - restClient.addHeader("Accept", "application/json"); - restClient.addAuthorizationHeader(UrnPropertiesReader.getVariable("mso.db.auth")); ++ client.addAdditionalHeader("Accept", "application/json"); ++ client.addAdditionalHeader("Authorization", UrnPropertiesReader.getVariable("mso.db.auth")); - File csarFile = new File(filePath); - APIResponse apiResponse = restClient.httpGet(); ++ Response apiResponse = client.get(); - if(!csarFile.exists()) { - throw new Exception("csar file does not exist in filePath:" + csarFile.getAbsolutePath()); - } - String value = apiResponse.getResponseBodyAsString(); ++ String value = apiResponse.readEntity(String.class); - return csarFile.getAbsolutePath(); + ObjectMapper objectMapper = new ObjectMapper(); + HashMap map = objectMapper.readValue(value, HashMap.class); + return map; } - + public static T getJsonObject(String jsonstr, Class type) { ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); diff --cc bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java index 5598e3d2e4,115ed91e50..e5e13268b2 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java @@@ -19,24 -19,416 +19,390 @@@ */ package org.onap.so.bpmn.common.resource; -import com.github.tomakehurst.wiremock.client.WireMock; -import com.github.tomakehurst.wiremock.junit.WireMockRule; -import org.junit.Rule; --import org.junit.Test; -import org.mockito.Mock; -import org.onap.so.bpmn.core.UrnPropertiesReader; -import org.springframework.core.env.Environment; ++import static org.junit.Assert.assertEquals; ++import static org.mockito.ArgumentMatchers.eq; ++import static org.mockito.Mockito.mock; ++import static org.mockito.Mockito.when; import java.util.HashMap; + import java.util.List; + import java.util.Map; + -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; ++import org.junit.Rule; ++import org.junit.Test; ++import org.mockito.Mock; ++import org.onap.so.BaseTest; ++import org.onap.so.bpmn.core.UrnPropertiesReader; ++import org.springframework.core.env.Environment; + -public class ResourceRequestBuilderTest { ++import static com.github.tomakehurst.wiremock.client.WireMock.*; + - @Rule - public WireMockRule wireMockRule = new WireMockRule(); - public class ResourceRequestBuilderTest { - @Mock - UrnPropertiesReader urnPropertiesReader; ++public class ResourceRequestBuilderTest extends BaseTest { @Test - public void buildResouceRequestTest() throws Exception { + public void getResourceInputTest() throws Exception { - ResourceRequestBuilder.buildResouceRequest("xxxxxx", - "a1074969-944f-4ddc-b687-9550b0c8cd57", new HashMap<>()); - UrnPropertiesReader reader = new UrnPropertiesReader(); - Environment env = mock(Environment.class); + - when(env.getProperty(eq("mso.catalog.db.endpoint"))).thenReturn("http://localhost:8080/ecomp/mso/catalog"); - reader.setEnvironment(env); + - WireMock.stubFor(WireMock.get(WireMock.urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5")) - .willReturn(WireMock.ok("{ \"serviceResources\" : {\n" + ++ stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5")) ++ .willReturn(ok("{ \"serviceResources\" : {\n" + + "\t\"modelInfo\" : {\n" + + "\t\t\"modelName\" : \"demoVFWCL\",\n" + + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" + + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" + + "\t\t\"modelVersion\" : \"1.0\"\n" + + "\t},\n" + + "\t\"serviceType\" : \"\",\n" + + "\t\"serviceRole\" : \"\",\n" + + "\t\"environmentContext\" : null,\n" + + "\t\"resourceOrder\" : \"res1,res2\",\n" + + "\t\"workloadContext\" : \"Production\",\n" + + "\t\"serviceVnfs\": [\n" + + "\t\n" + + "\t\t{ \"modelInfo\" : {\n" + + "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n" + + "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n" + + "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n" + + "\t\t\t\"modelVersion\" : \"1.0\",\n" + + "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n" + + "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" + + "\t\t\t},\n" + + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n" + + "\t\t\"nfFunction\" \t: null,\n" + + "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\"," + + "\t\t\"nfType\" \t\t: null,\n" + + "\t\t\"nfRole\" \t\t: null,\n" + + "\t\t\"nfNamingCode\" \t: null,\n" + + "\t\t\"multiStageDesign\" : \"false\",\n" + + "\t\t\t\"vfModules\": [\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"modelInfo\" : { \n" + + "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n" + + "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n" + + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n" + + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" + + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n" + + "\t\t\t\t\t},\t\t\"isBase\" : true,\n" + + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n" + + "\t\t\t\t\t\"initialCount\" : 1,\n" + + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + + "\t\t\t\t}\n" + + "\t\t\t]\n" + + "\t\t},\n" + + "\t\n" + + "\t\t{ \"modelInfo\" : {\n" + + "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n" + + "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n" + + "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n" + + "\t\t\t\"modelVersion\" : \"1.0\",\n" + + "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n" + + "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" + + "\t\t\t},\n" + + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n" + + "\t\t\"nfFunction\" \t: null,\n" + + "\t\t\"nfType\" \t\t: null,\n" + + "\t\t\"nfRole\" \t\t: null,\n" + + "\"resourceInput\":\"{\\\"a\\\":\\\"key|default_value\\\"}\"," + + "\t\t\"nfNamingCode\" \t: null,\n" + + "\t\t\"multiStageDesign\" : \"false\",\n" + + "\t\t\t\"vfModules\": [\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"modelInfo\" : { \n" + + "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n" + + "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n" + + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n" + + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" + + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n" + + "\t\t\t\t\t},\t\t\"isBase\" : true,\n" + + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n" + + "\t\t\t\t\t\"initialCount\" : 1,\n" + + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + + "\t\t\t\t}\n" + + "\t\t\t]\n" + + "\t\t}\n" + + "\t],\n" + + "\t\"serviceNetworks\": [],\n" + + "\t\"serviceAllottedResources\": []\n" + + "\t}}"))); + + // when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080"); + HashMap serviceInput = new HashMap(); + serviceInput.put("key", "value"); + Map stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5", + "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput); + assertEquals(stringObjectMap.get("a"), "value"); } @Test - public void buildResouceRequestParametersTest() throws Exception { + public void getResourceInputDefaultValueTest() throws Exception { + - UrnPropertiesReader reader = new UrnPropertiesReader(); - Environment env = mock(Environment.class); - - when(env.getProperty(eq("mso.catalog.db.endpoint"))).thenReturn("http://localhost:8080/ecomp/mso/catalog"); - reader.setEnvironment(env); - - WireMock.stubFor(WireMock.get(WireMock.urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5")) - .willReturn(WireMock.ok("{ \"serviceResources\" : {\n" + ++ stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5")) ++ .willReturn(ok("{ \"serviceResources\" : {\n" + + "\t\"modelInfo\" : {\n" + + "\t\t\"modelName\" : \"demoVFWCL\",\n" + + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" + + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" + + "\t\t\"modelVersion\" : \"1.0\"\n" + + "\t},\n" + + "\t\"serviceType\" : \"\",\n" + + "\t\"serviceRole\" : \"\",\n" + + "\t\"environmentContext\" : null,\n" + + "\t\"workloadContext\" : \"Production\",\n" + + "\t\"serviceVnfs\": [\n" + + "\t\n" + + "\t\t{ \"modelInfo\" : {\n" + + "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n" + + "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n" + + "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n" + + "\t\t\t\"modelVersion\" : \"1.0\",\n" + + "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n" + + "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" + + "\t\t\t},\n" + + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n" + + "\t\t\"nfFunction\" \t: null,\n" + + "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\"," + + "\t\t\"nfType\" \t\t: null,\n" + + "\t\t\"nfRole\" \t\t: null,\n" + + "\t\t\"nfNamingCode\" \t: null,\n" + + "\t\t\"multiStageDesign\" : \"false\",\n" + + "\t\t\t\"vfModules\": [\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"modelInfo\" : { \n" + + "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n" + + "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n" + + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n" + + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" + + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n" + + "\t\t\t\t\t},\t\t\"isBase\" : true,\n" + + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n" + + "\t\t\t\t\t\"initialCount\" : 1,\n" + + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + + "\t\t\t\t}\n" + + "\t\t\t]\n" + + "\t\t},\n" + + "\t\n" + + "\t\t{ \"modelInfo\" : {\n" + + "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n" + + "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n" + + "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n" + + "\t\t\t\"modelVersion\" : \"1.0\",\n" + + "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n" + + "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" + + "\t\t\t},\n" + + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n" + + "\t\t\"nfFunction\" \t: null,\n" + + "\t\t\"nfType\" \t\t: null,\n" + + "\t\t\"nfRole\" \t\t: null,\n" + + "\"resourceInput\":\"{\\\"a\\\":\\\"key|default_value\\\"}\"," + + "\t\t\"nfNamingCode\" \t: null,\n" + + "\t\t\"multiStageDesign\" : \"false\",\n" + + "\t\t\t\"vfModules\": [\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"modelInfo\" : { \n" + + "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n" + + "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n" + + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n" + + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" + + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n" + + "\t\t\t\t\t},\t\t\"isBase\" : true,\n" + + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n" + + "\t\t\t\t\t\"initialCount\" : 1,\n" + + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + + "\t\t\t\t}\n" + + "\t\t\t]\n" + + "\t\t}\n" + + "\t],\n" + + "\t\"serviceNetworks\": [],\n" + + "\t\"serviceAllottedResources\": []\n" + + "\t}}"))); + + // when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080"); + HashMap serviceInput = new HashMap(); + serviceInput.put("key1", "value"); + Map stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5", + "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput); + assertEquals(stringObjectMap.get("a"), "default_value"); + } + + @Test + public void getResourceInputValueNoDefaultTest() throws Exception { + - UrnPropertiesReader reader = new UrnPropertiesReader(); - Environment env = mock(Environment.class); - - when(env.getProperty(eq("mso.catalog.db.endpoint"))).thenReturn("http://localhost:8080/ecomp/mso/catalog"); - reader.setEnvironment(env); - - WireMock.stubFor(WireMock.get(WireMock.urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5")) - .willReturn(WireMock.ok("{ \"serviceResources\" : {\n" + ++ stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5")) ++ .willReturn(ok("{ \"serviceResources\" : {\n" + + "\t\"modelInfo\" : {\n" + + "\t\t\"modelName\" : \"demoVFWCL\",\n" + + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" + + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" + + "\t\t\"modelVersion\" : \"1.0\"\n" + + "\t},\n" + + "\t\"serviceType\" : \"\",\n" + + "\t\"serviceRole\" : \"\",\n" + + "\t\"environmentContext\" : null,\n" + + "\t\"workloadContext\" : \"Production\",\n" + + "\t\"serviceVnfs\": [\n" + + "\t\n" + + "\t\t{ \"modelInfo\" : {\n" + + "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n" + + "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n" + + "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n" + + "\t\t\t\"modelVersion\" : \"1.0\",\n" + + "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n" + + "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" + + "\t\t\t},\n" + + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n" + + "\t\t\"nfFunction\" \t: null,\n" + + "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\"," + + "\t\t\"nfType\" \t\t: null,\n" + + "\t\t\"nfRole\" \t\t: null,\n" + + "\t\t\"nfNamingCode\" \t: null,\n" + + "\t\t\"multiStageDesign\" : \"false\",\n" + + "\t\t\t\"vfModules\": [\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"modelInfo\" : { \n" + + "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n" + + "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n" + + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n" + + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" + + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n" + + "\t\t\t\t\t},\t\t\"isBase\" : true,\n" + + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n" + + "\t\t\t\t\t\"initialCount\" : 1,\n" + + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + + "\t\t\t\t}\n" + + "\t\t\t]\n" + + "\t\t},\n" + + "\t\n" + + "\t\t{ \"modelInfo\" : {\n" + + "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n" + + "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n" + + "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n" + + "\t\t\t\"modelVersion\" : \"1.0\",\n" + + "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n" + + "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" + + "\t\t\t},\n" + + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n" + + "\t\t\"nfFunction\" \t: null,\n" + + "\t\t\"nfType\" \t\t: null,\n" + + "\t\t\"nfRole\" \t\t: null,\n" + + "\"resourceInput\":\"{\\\"a\\\":\\\"value\\\"}\"," + + "\t\t\"nfNamingCode\" \t: null,\n" + + "\t\t\"multiStageDesign\" : \"false\",\n" + + "\t\t\t\"vfModules\": [\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"modelInfo\" : { \n" + + "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n" + + "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n" + + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n" + + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" + + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n" + + "\t\t\t\t\t},\t\t\"isBase\" : true,\n" + + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n" + + "\t\t\t\t\t\"initialCount\" : 1,\n" + + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + + "\t\t\t\t}\n" + + "\t\t\t]\n" + + "\t\t}\n" + + "\t],\n" + + "\t\"serviceNetworks\": [],\n" + + "\t\"serviceAllottedResources\": []\n" + + "\t}}"))); + + // when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080"); + HashMap serviceInput = new HashMap(); + serviceInput.put("key1", "value"); + Map stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5", + "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput); + assertEquals(stringObjectMap.get("a"), "value"); + } + + @Test + public void getResourceSequenceTest() throws Exception { + - UrnPropertiesReader reader = new UrnPropertiesReader(); - Environment env = mock(Environment.class); - - when(env.getProperty(eq("mso.catalog.db.endpoint"))).thenReturn("http://localhost:8080/ecomp/mso/catalog"); - reader.setEnvironment(env); - - WireMock.stubFor(WireMock.get(WireMock.urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5")) - .willReturn(WireMock.ok("{ \"serviceResources\" : {\n" + ++ stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5")) ++ .willReturn(ok("{ \"serviceResources\" : {\n" + + "\t\"modelInfo\" : {\n" + + "\t\t\"modelName\" : \"demoVFWCL\",\n" + + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" + + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" + + "\t\t\"modelVersion\" : \"1.0\"\n" + + "\t},\n" + + "\t\"serviceType\" : \"\",\n" + + "\t\"serviceRole\" : \"\",\n" + + "\t\"environmentContext\" : null,\n" + + "\t\"resourceOrder\" : \"res1,res2\",\n" + + "\t\"workloadContext\" : \"Production\",\n" + + "\t\"serviceVnfs\": [\n" + + "\t\n" + + "\t\t{ \"modelInfo\" : {\n" + + "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n" + + "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n" + + "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n" + + "\t\t\t\"modelVersion\" : \"1.0\",\n" + + "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n" + + "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" + + "\t\t\t},\n" + + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n" + + "\t\t\"nfFunction\" \t: null,\n" + + "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\"," + + "\t\t\"nfType\" \t\t: null,\n" + + "\t\t\"nfRole\" \t\t: null,\n" + + "\t\t\"nfNamingCode\" \t: null,\n" + + "\t\t\"multiStageDesign\" : \"false\",\n" + + "\t\t\t\"vfModules\": [\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"modelInfo\" : { \n" + + "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n" + + "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n" + + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n" + + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" + + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n" + + "\t\t\t\t\t},\t\t\"isBase\" : true,\n" + + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n" + + "\t\t\t\t\t\"initialCount\" : 1,\n" + + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + + "\t\t\t\t}\n" + + "\t\t\t]\n" + + "\t\t},\n" + + "\t\n" + + "\t\t{ \"modelInfo\" : {\n" + + "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n" + + "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n" + + "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n" + + "\t\t\t\"modelVersion\" : \"1.0\",\n" + + "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n" + + "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" + + "\t\t\t},\n" + + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n" + + "\t\t\"nfFunction\" \t: null,\n" + + "\t\t\"nfType\" \t\t: null,\n" + + "\t\t\"nfRole\" \t\t: null,\n" + + "\"resourceInput\":\"{\\\"a\\\":\\\"key|default_value\\\"}\"," + + "\t\t\"nfNamingCode\" \t: null,\n" + + "\t\t\"multiStageDesign\" : \"false\",\n" + + "\t\t\t\"vfModules\": [\n" + + "\t\t\t\t{\n" + + "\t\t\t\t\t\"modelInfo\" : { \n" + + "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n" + + "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n" + + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n" + + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" + + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n" + + "\t\t\t\t\t},\t\t\"isBase\" : true,\n" + + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n" + + "\t\t\t\t\t\"initialCount\" : 1,\n" + + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + + "\t\t\t\t}\n" + + "\t\t\t]\n" + + "\t\t}\n" + + "\t],\n" + + "\t\"serviceNetworks\": [],\n" + + "\t\"serviceAllottedResources\": []\n" + + "\t}}"))); - String parameters = - "{ \"locationConstraints\":[ ], \"resources\":[ { \"resourceName\":\"vEPC_ONAP01\", \"resourceInvariantUuid\":\"36ebe421-283a-4ee8-92f1-d09e7c44b911\", \"resourceUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed111\", \"resourceCustomizationUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed231\", \"parameters\":{ \"locationConstraints\":[ { \"vnfProfileId\":\"b244d433-8c9c-49ad-9c70-8e34b8dc8328\", \"locationConstraints\":{ \"vimId\":\"vmware_vio\" } }, { \"vnfProfileId\":\"8a9f7c48-21ce-41b7-95b8-a8ac61ccb1ff\", \"locationConstraints\":{ \"vimId\":\"core-dc_RegionOne\" } } ], \"resources\":[ ], \"requestInputs\":{ \"sdncontroller\":\"\" } } }, { \"resourceName\":\"VL OVERLAYTUNNEL\", \"resourceInvariantUuid\":\"184494cf-472f-436f-82e2-d83dddde21cb\", \"resourceUuid\":\"95bc3e59-c9c5-458f-ad6e-78874ab4b3cc\", \"resourceCustomizationUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed232\", \"parameters\":{ \"locationConstraints\":[ ], \"resources\":[ ], \"requestInputs\":{ } } } ], \"requestInputs\":{ \"vlunderlayvpn0_name\":\"l3connect\", \"vlunderlayvpn0_site1_id\":\"IP-WAN-Controller-1\", \"vlunderlayvpn0_site2_id\":\"SPTNController\", \"vlunderlayvpn0_site1_networkName\":\"network1,network2\", \"vlunderlayvpn0_site2_networkName\":\"network3,network4\", \"vlunderlayvpn0_site1_routerId\":\"a8098c1a-f86e-11da-bd1a-00112444be1a\", \"vlunderlayvpn0_site2_routerId\":\"a8098c1a-f86e-11da-bd1a-00112444be1e\", \"vlunderlayvpn0_site2_importRT1\":\"200:1,200:2\", \"vlunderlayvpn0_site1_exportRT1\":\"300:1,300:2\", \"vlunderlayvpn0_site2_exportRT1\":\"400:1,400:2\", \"vlunderlayvpn0_site1_vni\":\"2000\", \"vlunderlayvpn0_site2_vni\":\"3000\", \"vlunderlayvpn0_tunnelType\":\"L3-DCI\" } }"; - ResourceRequestBuilder.buildResourceRequestParameters(null, "1bd0eae6-2dcc-4461-9ae6-56d641f369d6", "27a0e235-b67a-4ea4-a0cf-25761afed231", parameters); + List resourceSequence = ResourceRequestBuilder.getResourceSequence("c3954379-4efe-431c-8258-f84905b158e5"); + assertEquals(resourceSequence.size(), 2); + assertEquals(resourceSequence.get(0), "res1"); + assertEquals(resourceSequence.get(1), "res2"); } } diff --cc bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml index 18f94f3b88,dea3f17f8e..945972c9e2 --- a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml +++ b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml @@@ -84,7 -83,7 +84,7 @@@ mso callbackRetryAttempts: '5' catalog: db: -- endpoint: http://localhost:${wiremock.server.port}/ ++ endpoint: http://localhost:${wiremock.server.port}/ecomp/mso/catalog spring: endpoint: http://localhost:${wiremock.server.port} correlation: diff --cc bpmn/mso-infrastructure-bpmn/pom.xml index fb5d0108ba,e617cfed61..5d0d05df92 --- a/bpmn/mso-infrastructure-bpmn/pom.xml +++ b/bpmn/mso-infrastructure-bpmn/pom.xml @@@ -161,8 -137,13 +161,13 @@@ org.camunda.bpm.springboot camunda-bpm-spring-boot-starter-rest - 2.3.0 + ${camunda.springboot.version} + + org.camunda.bpm.springboot + camunda-bpm-spring-boot-starter-webapp + 2.3.0 + org.springframework.boot spring-boot-starter-web diff --cc bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn index a389e8077b,a5433b3841..81d3226037 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn @@@ -542,24 -558,12 +542,24 @@@ - - + + - + + + + + + + + + + + + + -- ++ diff --cc bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy index 1d3d3331ef,74926ce5b7..53e3525036 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy @@@ -44,9 -41,11 +45,10 @@@ import org.onap.so.bpmn.common.util.Oof import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException - import org.onap.so.bpmn.core.domain.VnfResource + import org.onap.so.bpmn.core.json.DecomposeJsonUtil import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.client.graphinventory.entities.uri.Depth +import org.onap.so.client.HttpClient import org.onap.so.client.aai.AAIObjectPlurals import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient @@@ -54,12 -53,13 +56,13 @@@ import org.onap.so.client.aai.entities. import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUri import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.constants.Defaults ++import org.onap.so.db.catalog.beans.HomingInstance 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.springframework.web.util.UriUtils + +import org.onap.so.utils.TargetEntity import org.w3c.dom.Document import org.w3c.dom.Element import org.w3c.dom.NamedNodeMap @@@ -78,8 -78,9 +81,10 @@@ public class DoCreateVfModule extends V ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + OofInfraUtils oofInfraUtils = new OofInfraUtils() - CatalogDbUtils catalog = new CatalogDbUtils() + CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() + DecomposeJsonUtil decomposeJsonUtils = new DecomposeJsonUtil() + private final HttpClientFactory httpClientFactory = new HttpClientFactory() /** * Validates the request message and sets up the workflow. diff --cc bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy index 6109d8631f,5ff93363d2..7c8a1d70e1 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy @@@ -247,24 -256,33 +247,24 @@@ public class DoDeleteVFCNetworkServiceI msoLogger.trace("Started Execute VFC adapter Delete Process ") msoLogger.info("url:"+url +"\nrequestBody:"+ requestBody) - Response 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()) ++ Response r + try{ + - URL Url = new URL(url) ++ URL Url = new URL(url) + // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7' + // user 'bepl' authHeader is the same with mso.db.auth + String basicAuthValuedb = UrnPropertiesReader.getVariable("mso.db.auth", execution) + HttpClient httpClient = httpClientFactory.newJsonClient(url, TargetEntity.VNF_ADAPTER) + httpClient.addAdditionalHeader("Accept", "application/json") + httpClient.addAdditionalHeader("Authorization", basicAuthValuedb) - - r = httpClient.delete(requestBody) - ++ httpClient.addAdditionalHeader("Content-Type", "application/json") ++ r = httpClient.delete(requestBody) + - }catch(Exception e){ - msoLogger.error("Exception occured while executing VF-C Delete Call. Exception is: \n" + e.getMessage()); - throw new BpmnError("MSOWorkflowException") - } - return apiResponse + msoLogger.trace("Completed Execute VF-C adapter Delete Process ") + }catch(Exception e){ + msoLogger.error("Exception occured while executing VF-C Post Call. Exception is: \n" + e.getMessage()); + throw new BpmnError("MSOWorkflowException") + } + return r } } diff --cc bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegateTest.java index 6bfbac0791,ce6b766fa2..c487125ea6 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegateTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegateTest.java @@@ -51,6 -51,6 +51,6 @@@ public class CreatePnfEntryInAaiDelegat Pnf createdEntry = aaiConnection.getCreated().get("testCorrelationId"); assertThat(createdEntry.getPnfId()).isEqualTo(pnfUuid); assertThat(createdEntry.getPnfName()).isEqualTo("testCorrelationId"); - assertThat(createdEntry.isInMaint()).isTrue(); + assertThat(createdEntry.isInMaint()).isNull(); } --} ++} diff --cc bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegateTest.java index 763a4546e8,c351706aff..8a1cdfa4c0 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegateTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegateTest.java @@@ -38,6 -36,6 +36,6 @@@ public class GeneratePnfUuidDelegateTes // when delegate.execute(execution); // then - assertThat((String) execution.getVariable(PNF_UUID)).matches(UUID_REGEX); + assertThat((String) execution.getVariable(PNF_UUID)).matches(PnfCheckInputs.UUID_REGEX); } --} ++} diff --cc bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java index e17859969d,3ef7ef4dc5..7fdf2535bf --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java @@@ -35,17 -32,13 +35,18 @@@ import java.util.UUID import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; ++import org.junit.Ignore; import org.junit.Test; +import org.mockito.ArgumentMatchers; +import org.mockito.InjectMocks; import org.onap.appc.client.lcm.model.Action; import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.db.catalog.beans.ControllerSelectionReference; -import org.springframework.beans.factory.annotation.Autowired; public class GenericVnfHealthCheckTest extends BaseTaskTest { @@@ -135,10 -125,38 +136,40 @@@ execution.setVariable("vnfHostIpAddress", "testOamIpAddress"); execution.setVariable("payload", payload); - doThrow(Exception.class).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType); + doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1002), eq("APPC Client Failed")); + doThrow(new RuntimeException("APPC Client Failed")).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType); + genericVnfHealthCheck.callAppcClient(execution); + verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType); + } + + @Test - public void callAppcClientTimeOutExceptionTest() throws java.util.concurrent.TimeoutException { ++ @Ignore //The runAppCCommand method in not capable of throwing this exception ++ public void callAppcClientTimeOutExceptionTest() { + expectedException.expect(java.util.concurrent.TimeoutException.class); + Action action = Action.HealthCheck; + String vnfId = genericVnf.getVnfId(); + String payload = "{\"testName\":\"testValue\",}"; + String controllerType = "testType"; + HashMap payloadInfo = new HashMap(); + payloadInfo.put("vnfName", "testVnfName"); + payloadInfo.put("vfModuleId", "testVfModuleId"); + payloadInfo.put("oamIpAddress", "testOamIpAddress"); + payloadInfo.put("vnfHostIpAddress", "testOamIpAddress"); + execution.setVariable("action", Action.HealthCheck.toString()); + execution.setVariable("msoRequestId", msoRequestId); + execution.setVariable("controllerType", controllerType); + execution.setVariable("vnfId", "testVnfId1"); + execution.setVariable("vnfName", "testVnfName"); + execution.setVariable("vfModuleId", "testVfModuleId"); + execution.setVariable("oamIpAddress", "testOamIpAddress"); + execution.setVariable("vnfHostIpAddress", "testOamIpAddress"); + execution.setVariable("payload", payload); + + doThrow(java.util.concurrent.TimeoutException.class).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType); + + genericVnfHealthCheck.callAppcClient(execution); verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType); } diff --cc mso-api-handlers/mso-api-handler-infra/pom.xml index 12b4d34380,e193fad425..dd77c242d4 --- a/mso-api-handlers/mso-api-handler-infra/pom.xml +++ b/mso-api-handlers/mso-api-handler-infra/pom.xml @@@ -108,12 -104,15 +108,11 @@@ javax.servlet - servlet-api - 2.5 + javax.servlet-api - org.javassist - javassist - - - org.json - json + javax.interceptor + javax.interceptor-api diff --cc mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java index 3612d83359,98addf90aa..828b2ff920 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java @@@ -126,9 -126,9 +127,10 @@@ 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"; + private static final String ASTERISK = "*"; private String findExternalToInternalServiceByServiceName = "/findByServiceName"; private String findServiceByModelName = "/findOneByModelName"; @@@ -153,10 -153,10 +155,12 @@@ private String findVnfcInstanceGroupCustomizationByModelCustomizationUUID = "/findByModelCustomizationUUID"; private String findCollectionResourceInstanceGroupCustomizationByModelCustomizationUUID = "/findByModelCustomizationUUID"; private String findOneByActionAndRequestScopeAndIsAlacarte = "/findOneByActionAndRequestScopeAndIsAlacarte"; + private String findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwner = "/findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwner"; + private String findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwnerAndServiceType = "/findOneByActionAndRequestScopeAndIsAlacarteAndCloudOwnerAndServiceType"; private String findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep = "/findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep"; private String findByClliAndCloudVersion = "/findByClliAndCloudVersion"; + private String findServiceByServiceInstanceId = "/findServiceByServiceInstanceId"; + private String serviceURI; private String vfModuleURI;