diff options
215 files changed, 4119 insertions, 5864 deletions
diff --git 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 index 051d8134f1..076e03b6b3 100644 --- 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 @@ -31,8 +31,6 @@ import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriBuilderException; import javax.ws.rs.core.Response; -import org.onap.so.db.catalog.beans.CloudIdentity; -import org.onap.so.utils.CryptoUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.onap.so.adapters.vdu.CloudInfo; @@ -64,6 +62,8 @@ 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; @@ -173,35 +173,20 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ CreateStackParam stack = createStackParam(stackName, heatTemplate, stackInputs, timeoutMinutes, environment, files, heatFiles); MulticloudRequest multicloudRequest= new MulticloudRequest(); - HttpEntity<MulticloudRequest> request = null; try { multicloudRequest.setGenericVnfId(genericVnfId); multicloudRequest.setVfModuleId(vfModuleId); - multicloudRequest.setOofDirectives(oofDirectives); - multicloudRequest.setSdncDirectives(sdncDirectives); + 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(JSON_MAPPER.writeValueAsString(stack)); + multicloudRequest.setTemplateData(stack); if (logger.isDebugEnabled()) { logger.debug(String.format("Multicloud Request is: %s", multicloudRequest.toString())); } - - CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> - new MsoCloudSiteNotFound(cloudSiteId)); - CloudIdentity cloudIdentity = cloudSite.getIdentityService(); - HttpHeaders headers = new HttpHeaders(); - headers.set ("X-Auth-User", cloudIdentity.getMsoId ()); - headers.set ("X-Auth-Key", CryptoUtils.decryptCloudConfigPassword(cloudIdentity.getMsoPass ())); - headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON.toString()); - headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString()); - - if (logger.isDebugEnabled()) { - logger.debug(String.format("Multicloud Request Headers: %s", headers.toString())); - } - request = new HttpEntity<>(multicloudRequest, headers); } catch (Exception e) { logger.debug("ERROR making multicloud JSON body ", e); } @@ -211,7 +196,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ } RestClient multicloudClient = getMulticloudClient(multicloudEndpoint); - Response response = multicloudClient.post(request); + Response response = multicloudClient.post(multicloudRequest); StackInfo createInfo = new StackInfo(); createInfo.setName(stackName); @@ -223,7 +208,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ if (logger.isDebugEnabled()) { logger.debug("Multicloud Create Response Body: " + multicloudResponseBody); } - return getStackStatus(cloudSiteId, tenantId, multicloudResponseBody.getWorkloadId(), pollForCompletion, timeoutMinutes, backout); + return getStackStatus(cloudSiteId, tenantId, createInfo.getCanonicalName(), pollForCompletion, timeoutMinutes, backout); } else { createInfo.setStatus(HeatStatus.FAILED); createInfo.setStatusMessage(response.getStatusInfo().getReasonPhrase()); @@ -609,7 +594,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ private RestClient getMulticloudClient(String endpoint) { RestClient client = null; try { - client= new HttpClient(UriBuilder.fromUri(endpoint).build().toURL(), + client = new HttpClient(UriBuilder.fromUri(endpoint).build().toURL(), MediaType.APPLICATION_JSON.toString(), TargetEntity.MULTICLOUD); } catch (MalformedURLException e) { logger.debug(String.format("Encountered malformed URL error getting multicloud rest client %s", e.getMessage())); @@ -715,7 +700,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ try { // Delete the Multicloud stack - StackInfo stackInfo = deleteStack (tenantId, cloudSiteId, instanceId); + StackInfo stackInfo = deleteStack (cloudSiteId, tenantId, instanceId); // Populate a VduInstance based on the deleted Cloudify Deployment object VduInstance vduInstance = stackInfoToVduInstance(stackInfo); diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java index fefc0951f6..4204813cec 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java @@ -24,6 +24,9 @@ import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.JsonNode; +import com.woorea.openstack.heat.model.CreateStackParam; + import org.apache.commons.lang.builder.ToStringBuilder; @JsonInclude(JsonInclude.Include.NON_NULL) @@ -43,13 +46,13 @@ public class MulticloudRequest implements Serializable { @JsonProperty("vf-module-id") private String vfModuleId; @JsonProperty("oof_directives") - private String oofDirectives; + private JsonNode oofDirectives; @JsonProperty("sdnc_directives") - private String sdncDirectives; + private JsonNode sdncDirectives; @JsonProperty("template_type") private String templateType; @JsonProperty("template_data") - private String templateData; + private CreateStackParam templateData; @JsonProperty("generic-vnf-id") @@ -73,22 +76,22 @@ public class MulticloudRequest implements Serializable { } @JsonProperty("oof_directives") - public String getOofDirectives() { + public JsonNode getOofDirectives() { return oofDirectives; } @JsonProperty("oof_directives") - public void setOofDirectives(String oofDirectives) { + public void setOofDirectives(JsonNode oofDirectives) { this.oofDirectives = oofDirectives; } @JsonProperty("sdnc_directives") - public String getSdncDirectives() { + public JsonNode getSdncDirectives() { return sdncDirectives; } @JsonProperty("sdnc_directives") - public void setSdncDirectives(String sdncDirectives) { + public void setSdncDirectives(JsonNode sdncDirectives) { this.sdncDirectives = sdncDirectives; } @@ -103,12 +106,12 @@ public class MulticloudRequest implements Serializable { } @JsonProperty("template_data") - public String getTemplateData() { + public CreateStackParam getTemplateData() { return templateData; } @JsonProperty("template_data") - public void setTemplateData(String templateData) { + public void setTemplateData(CreateStackParam templateData) { this.templateData = templateData; } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java index 5cd2559ef2..eaf3e125a1 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java @@ -340,14 +340,21 @@ public class CatalogDbAdapterRest { uuid = modelUUID; logger.debug ("Query serviceMacroHolder getAllResourcesByServiceModelUuid serviceModelUuid: {}" , uuid); Service serv =serviceRepo.findOneByModelUUID(uuid); - ret.setService(serv); + + if (serv != null) { + ret.setNetworkResourceCustomizations(new ArrayList(serv.getNetworkCustomizations())); + ret.setVnfResourceCustomizations(new ArrayList(serv.getVnfCustomizations())); + ret.setAllottedResourceCustomizations(new ArrayList(serv.getAllottedCustomizations())); + } + ret.setService(serv); } else if (modelInvariantUUID != null && !"".equals(modelInvariantUUID)) { uuid = modelInvariantUUID; if (modelVersion != null && !"".equals(modelVersion)) { logger.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: {} serviceModelVersion: {}",uuid, modelVersion); Service serv = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(modelVersion, uuid); - ret.setService(serv); + + ret.setService(serv); } else { logger.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelUuid: {}" , uuid); diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index 5c7b64d054..5e2bd82776 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -20,9 +20,11 @@ package org.onap.so.db.catalog.client; +import java.util.List; +import java.util.UUID; + import org.junit.Assert; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.catalogdb.CatalogDBApplication; @@ -30,6 +32,7 @@ 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.CloudifyManager; +import org.onap.so.db.catalog.beans.ExternalServiceToInternalService; import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.ServerType; @@ -49,10 +52,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; -import java.net.URI; -import java.util.List; -import java.util.UUID; - @RunWith(SpringRunner.class) @SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") @@ -414,4 +413,57 @@ public class CatalogDbClientTest { Assert.assertEquals("regionId", getCloudSite.getRegionId()); Assert.assertEquals("RANDOMID", getCloudSite.getIdentityServiceId()); } + @Test + public void testGetServiceByModelName() { + Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service"); + Assert.assertNotNull(service); + Assert.assertNotNull(service.getModelVersion()); + Assert.assertNotNull(service.getModelInvariantUUID()); + Assert.assertEquals("MSOTADevInfra_Test_Service", service.getModelName()); + Assert.assertEquals("NA", service.getServiceRole()); + } + + @Test + public void testGetServiceByModelNameNotFound() { + Service service = client.getServiceByModelName("Not_Found"); + Assert.assertNull(service); + } + + @Test + public void testGetServiceByModelUUID() { + Service service = client.getServiceByModelUUID("5df8b6de-2083-11e7-93ae-92361f002679"); + Assert.assertNotNull(service); + Assert.assertNotNull(service.getModelVersion()); + Assert.assertNotNull(service.getModelInvariantUUID()); + Assert.assertEquals("5df8b6de-2083-11e7-93ae-92361f002679", service.getModelUUID()); + Assert.assertEquals("NA", service.getServiceRole()); + } + + @Test + public void testGetServiceByModelUUIDNotFound() { + Service service = client.getServiceByModelUUID("Not_Found"); + Assert.assertNull(service); + } + + @Test + public void testFindServiceRecipeByActionAndServiceModelUUID() { + ServiceRecipe serviceRecipe = client.findServiceRecipeByActionAndServiceModelUUID("createInstance","4694a55f-58b3-4f17-92a5-796d6f5ffd0d" ); + Assert.assertNotNull(serviceRecipe); + Assert.assertNotNull(serviceRecipe.getServiceModelUUID()); + Assert.assertNotNull(serviceRecipe.getAction()); + Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance", serviceRecipe.getOrchestrationUri()); + Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription()); + } + + @Test + public void testFindServiceRecipeByActionAndServiceModelUUIDNotFound() { + ServiceRecipe serviceRecipe = client.findServiceRecipeByActionAndServiceModelUUID("not_found","5df8b6de-2083-11e7-93ae-test" ); + Assert.assertNull(serviceRecipe); + } + + @Test + public void testFindExternalToInternalServiceByServiceNameNotFound() { + ExternalServiceToInternalService externalServiceToInternalService = client.findExternalToInternalServiceByServiceName("Not_Found"); + Assert.assertNull(externalServiceToInternalService); + } } diff --git 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 index d5cdb18a0c..c8475564a4 100644 --- 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 @@ -60,6 +60,9 @@ insert into tosca_csar(artifact_uuid, name, version, description, artifact_check insert into service(model_uuid, model_name, model_invariant_uuid, model_version, description, creation_timestamp, tosca_csar_artifact_uuid, service_type, service_role, environment_context, workload_context) values ('5df8b6de-2083-11e7-93ae-92361f002671', 'MSOTADevInfra_vSAMP10a_Service', '9647dfc4-2083-11e7-93ae-92361f002671', '1.0', 'MSO aLaCarte Vfmodule with addon', '2017-04-14 13:42:39', '0513f839-459d-46b6-aa3d-2edfef89a079', 'NA', 'NA', 'Luna', 'Oxygen'); +insert into service(model_uuid, model_name, model_invariant_uuid, model_version, description, creation_timestamp, tosca_csar_artifact_uuid, service_type, service_role, environment_context, workload_context) values +('5df8b6de-2083-11e7-93ae-92361f002679', 'MSOTADevInfra_Test_Service', '9647dfc4-2083-11e7-93ae-92361f002673', '3.0', 'MSO aLaCarte Vfmodule with addon', '2017-04-14 13:42:39', '0513f839-459d-46b6-aa3d-2edfef89a079', 'NA', 'NA', 'Luna', 'Oxygen'); + insert into tosca_csar(ARTIFACT_UUID,NAME,VERSION,DESCRIPTION,ARTIFACT_CHECKSUM,URL,CREATION_TIMESTAMP) values ('266eaf78-af74-45cd-83ec-9c477f189dc1','service-NetworkCollectionSvc0106-csar.csar','1','TOSCA definition package of the asset','OGQ1M2QyYjU0OWMzZTY4MWVlYTNhOWIxNmQ2NjEyZDQ=','/sdc/v1/catalog/services/NetworkCollectionSvc0106/1.0/artifacts/service-NetworkCollectionSvc0106-csar.csar','2018-06-01 16:06:52'); insert into service(model_uuid, model_name, model_invariant_uuid, model_version, description, creation_timestamp, tosca_csar_artifact_uuid, service_type, service_role, environment_context, workload_context) values diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java index 91505918a8..503de0429e 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java @@ -680,36 +680,13 @@ public class ASDCController { VfResourceStructure resourceStructure = null; ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure(); boolean deploySuccessful = true; + boolean hasVFResource = false; String errorMessage = null; try { this.processCsarServiceArtifacts(iNotif, toscaResourceStructure); - - if (toscaResourceStructure.getServiceVersion() == null) { - LOGGER.debug("Deploy the workflow"); - IArtifactInfo iArtifact = toscaResourceStructure.getToscaArtifact(); - String csarFilePath = System.getProperty("mso.config.path") + "/ASDC" + "/" + iArtifact.getArtifactName(); - bpmnInstaller.installBpmn(csarFilePath); - } - - // Install a service with no resources, only the service itself - if (iNotif.getResources() == null || iNotif.getResources().size() < 1) { - - LOGGER.debug("No resources found for Service: " + iNotif.getServiceUUID()); - - try{ - resourceStructure = new VfResourceStructure(iNotif,new ResourceInstance()); - - this.deployResourceStructure(resourceStructure, toscaResourceStructure); - - } catch(ArtifactInstallerException e){ - deploySuccessful = false; - errorMessage = e.getMessage(); - LOGGER.debug ("Exception in processResourceNotification(): " + e); - } - } else { // Services with resources - + for (IResourceInstance resource : iNotif.getResources()){ resourceStructure = new VfResourceStructure(iNotif,resource); @@ -720,11 +697,14 @@ public class ASDCController { LOGGER.debug("Processing Resource Type: " + resourceType + " and Model UUID: " + resourceStructure.getResourceInstance().getResourceUUID()); if("VF".equals(resourceType) && !"Allotted Resource".equalsIgnoreCase(category)){ + + hasVFResource = true; for (IArtifactInfo artifact : resource.getArtifacts()) { IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact, iNotif.getDistributionID()); if (resultArtifact != null) { + if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifact.getArtifactType())) { LOGGER.debug("VF_MODULE_ARTIFACT: "+new String(resultArtifact.getArtifactPayload(),"UTF-8")); LOGGER.debug(ASDCNotificationLogging.dumpVfModuleMetaDataList(resourceStructure.decodeVfModuleArtifact(resultArtifact.getArtifactPayload()))); @@ -732,21 +712,37 @@ public class ASDCController { resourceStructure.addArtifactToStructure(distributionClient,artifact, resultArtifact); } } + + //Deploy VF resource and artifacts + LOGGER.debug("Preparing to deploy Service: " + iNotif.getServiceUUID()); + try{ + + this.deployResourceStructure(resourceStructure, toscaResourceStructure); + + } catch(ArtifactInstallerException e){ + deploySuccessful = false; + errorMessage = e.getMessage(); + LOGGER.error(e); + } } + + } + + // There are cases where the Service has no VF resources, those are handled here + if (!hasVFResource) { + + LOGGER.debug("No resources found for Service: " + iNotif.getServiceUUID()); - //Deploy All resources and artifacts - LOGGER.debug("Preparing to deploy Service: " + iNotif.getServiceUUID()); - try{ - + try{ + resourceStructure = new VfResourceStructure(iNotif,new ResourceInstance()); + this.deployResourceStructure(resourceStructure, toscaResourceStructure); } catch(ArtifactInstallerException e){ deploySuccessful = false; errorMessage = e.getMessage(); - LOGGER.debug ("Exception in processResourceNotification(): " + e); - } - - } + LOGGER.error(e); + } } this.sendCsarDeployNotification(iNotif, resourceStructure, toscaResourceStructure, deploySuccessful, errorMessage); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java index cbacd88870..248d94d530 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java @@ -45,6 +45,7 @@ public final class ASDCStatusCallBack implements IStatusCallback { @Override public void activateCallback (IStatusData iStatus) { + long startTime = System.currentTimeMillis (); UUIDChecker.generateUUID (LOGGER); MsoLogger.setServiceName ("ASDCStatusCallBack"); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java index 9df9ffc7af..f7c761f017 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java @@ -97,6 +97,7 @@ public class ASDCNotificationLogging { buffer.append(System.lineSeparator()); buffer.append("Environment Context:"); buffer.append(csarHelper.getServiceMetadata().getValue("environmentContext")); + buffer.append(System.lineSeparator()); List<NodeTemplate> serviceProxyResourceList = toscaResourceStructure.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY); @@ -223,6 +224,9 @@ public class ASDCNotificationLogging { buffer.append("Type:"); buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE))); buffer.append(System.lineSeparator()); + buffer.append("Category:"); + buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY))); + buffer.append(System.lineSeparator()); buffer.append("InvariantUuid:"); buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); buffer.append(System.lineSeparator()); @@ -368,7 +372,9 @@ public class ASDCNotificationLogging { } } - } + + } + List<NodeTemplate> nodeTemplatesVLList = toscaResourceStructure.getSdcCsarHelper().getServiceVlList(); @@ -410,14 +416,13 @@ public class ASDCNotificationLogging { } - buffer.append(System.lineSeparator()); - buffer.append("Network Collection Resource Properties:"); - buffer.append(System.lineSeparator()); - + List<NodeTemplate> networkCollectionList = toscaResourceStructure.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CR); if (networkCollectionList != null) { for (NodeTemplate crNode : networkCollectionList) { + buffer.append(System.lineSeparator()); + buffer.append("Network Collection Properties:"); buffer.append(System.lineSeparator()); buffer.append("Model Name:"); buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy index 3e451a5a4a..2f4e70c893 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy @@ -19,15 +19,24 @@ */ package org.onap.so.bpmn.common.scripts +import java.util.regex.Matcher +import java.util.regex.Pattern + +import javax.ws.rs.core.UriBuilder + import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.client.aai.AAIVersion +import org.onap.so.client.aai.entities.uri.AAIUri +import org.onap.so.logger.MessageEnum +import org.onap.so.logger.MsoLogger +import org.onap.so.openpojo.rules.HasToStringRule 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.logger.MsoLogger +@Deprecated class AaiUtil { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, AaiUtil.class); @@ -43,124 +52,13 @@ class AaiUtil { public AaiUtil(AbstractServiceTaskProcessor taskProcessor) { this.taskProcessor = taskProcessor } - public AaiUtil() { - } - - public String getNetworkGenericVnfEndpoint(DelegateExecution execution) { - String endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - def uri = getNetworkGenericVnfUri(execution) - msoLogger.debug('AaiUtil.getNetworkGenericVnfEndpoint() - AAI endpoint: ' + endpoint + uri) - return endpoint + uri - } - public String getNetworkGenericVnfUri(DelegateExecution execution) { - def uri = getUri(execution, 'generic-vnf') - msoLogger.debug('AaiUtil.getNetworkGenericVnfUri() - AAI URI: ' + uri) - return uri - } - - public String getNetworkVpnBindingUri(DelegateExecution execution) { - def uri = getUri(execution, 'vpn-binding') - msoLogger.debug('AaiUtil.getNetworkVpnBindingUri() - AAI URI: ' + uri) - return uri - } - - public String getNetworkPolicyUri(DelegateExecution execution) { - def uri = getUri(execution, 'network-policy') - msoLogger.debug('AaiUtil.getNetworkPolicyUri() - AAI URI: ' + uri) - return uri - } - - public String getNetworkTableReferencesUri(DelegateExecution execution) { - def uri = getUri(execution, 'route-table-reference') - msoLogger.debug('AaiUtil.getNetworkTableReferencesUri() - AAI URI: ' + uri) - return uri - } - - public String getNetworkVceUri(DelegateExecution execution) { - def uri = getUri(execution, 'vce') - msoLogger.debug('AaiUtil.getNetworkVceUri() - AAI URI: ' + uri) - return uri - } - - public String getNetworkL3NetworkUri(DelegateExecution execution) { - def uri = getUri(execution, 'l3-network') - msoLogger.debug('AaiUtil.getNetworkL3NetworkUri() - AAI URI: ' + uri) - return uri - } - - public String getNetworkDeviceUri(DelegateExecution execution) { - def uri = getUri(execution, 'device') - msoLogger.debug('AaiUtil.getNetworkDeviceUri() - AAI URI: ' + uri) - return uri - } - - public String getBusinessCustomerUri(DelegateExecution execution) { - def uri = getUri(execution, 'customer') - msoLogger.debug('AaiUtil.getBusinessCustomerUri() - AAI URI: ' + uri) - return uri - } - public String getBusinessSPPartnerUri(DelegateExecution execution) { def uri = getUri(execution, 'sp-partner') msoLogger.debug('AaiUtil.getBusinessSPPartnerUri() - AAI URI: ' + uri) return uri } - public String getAAIServiceInstanceUri(DelegateExecution execution) { - String uri = getBusinessCustomerUri(execution) - - uri = uri +"/" + execution.getVariable("globalSubscriberId") + "/service-subscriptions/service-subscription/" + UriUtils.encode(execution.getVariable("serviceType"),"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(execution.getVariable("serviceInstanceId"),"UTF-8") - - msoLogger.debug('AaiUtil.getAAIRequestInputUri() - AAI URI: ' + uri) - return uri - } - - //public String getBusinessCustomerUriv7(DelegateExecution execution) { - // //def uri = getUri(execution, BUSINESS_CUSTOMERV7) - // def uri = getUri(execution, 'Customer') - // msoLogger.debug('AaiUtil.getBusinessCustomerUriv7() - AAI URI: ' + uri) - // return uri - //} - - public String getCloudInfrastructureCloudRegionEndpoint(DelegateExecution execution) { - String endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - def uri = getCloudInfrastructureCloudRegionUri(execution) - msoLogger.debug('AaiUtil.getCloudInfrastructureCloudRegionEndpoint() - AAI endpoint: ' + endpoint + uri) - return endpoint + uri - } - - public String getCloudInfrastructureCloudRegionUri(DelegateExecution execution) { - def uri = getUri(execution, 'cloud-region') - msoLogger.debug('AaiUtil.getCloudInfrastructureCloudRegionUri() - AAI URI: ' + uri) - return uri - } - - public String getCloudInfrastructureTenantUri(DelegateExecution execution) { - def uri = getUri(execution, 'tenant') - msoLogger.debug('AaiUtil.getCloudInfrastructureTenantUri() - AAI URI: ' + uri) - return uri - } - - public String getSearchNodesQueryUri(DelegateExecution execution) { - def uri = getUri(execution, 'nodes-query') - msoLogger.debug('AaiUtil.getSearchNodesQueryUri() - AAI URI: ' + uri) - return uri - } - - public String getSearchNodesQueryEndpoint(DelegateExecution execution) { - String endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - def uri = getSearchNodesQueryUri(execution) - msoLogger.debug('AaiUtil.getSearchNodesQueryEndpoint() - AAI endpoint: ' + endpoint + uri) - return endpoint + uri - } - - public String getSearchGenericQueryUri(DelegateExecution execution) { - def uri = getUri(execution, 'generic-query') - msoLogger.debug('AaiUtil.getSearchGenericQueryUri() - AAI URI: ' + uri) - return uri - } - public String getVersion(DelegateExecution execution, resourceName, processKey) { def versionWithResourceKey = "mso.workflow.default.aai.${resourceName}.version" def versionWithProcessKey = "mso.workflow.custom.${processKey}.aai.version" @@ -186,53 +84,13 @@ class AaiUtil { (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, "Internal Error: One of the following should be defined in MSO URN properties file: ${versionWithResourceKey}, ${versionWithProcessKey}, ${DEFAULT_VERSION_KEY}") } - public String getMainProcessKey(DelegateExecution execution) { - DelegateExecution exec = execution - - while (true) { - DelegateExecution parent = exec.getSuperExecution() - - if (parent == null) { - parent = exec.getParent() - - if (parent == null) { - break - } - } - - exec = parent - } - - return execution.getProcessEngineServices().getRepositoryService() - .getProcessDefinition(exec.getProcessDefinitionId()).getKey() + public String createAaiUri(AAIUri uri) { + return createAaiUri(AAIVersion.valueOf('V' + UrnPropertiesReader.getVariable(DEFAULT_VERSION_KEY)), uri) } - - public String getUri(DelegateExecution execution, resourceName) { - - def processKey = getMainProcessKey(execution) - - //set namespace - setNamespace(execution) - - // Check for flow+resource specific first - def key = "mso.workflow.${processKey}.aai.${resourceName}.uri" - def uri = UrnPropertiesReader.getVariable(key, execution) - if(uri) { - msoLogger.debug("AaiUtil.getUri() - using flow+resource specific key: ${key}=${uri}") - return uri - } - - // Check for versioned key - def version = getVersion(execution, resourceName, processKey) - key = "mso.workflow.default.aai.v${version}.${resourceName}.uri" - uri = UrnPropertiesReader.getVariable(key, execution) - - if(uri) { - msoLogger.debug("AaiUtil.getUri() - using versioned URI key: ${key}=${uri}") - return uri - } - - (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + key + ' not defined in the MSO URN properties file') + public String createAaiUri(AAIVersion version, AAIUri uri) { + String endpoint = UrnPropertiesReader.getVariable("aai.endpoint") + String result = UriBuilder.fromUri(endpoint).path('aai').path(version.toString()).build().toString() + return UriBuilder.fromUri(result + uri.build().toString()).build().toString() } public String setNamespace(DelegateExecution execution) { @@ -243,6 +101,18 @@ class AaiUtil { } } + public String getNamespace() { + return getNamespace(AAIVersion.valueOf('V' + UrnPropertiesReader.getVariable(DEFAULT_VERSION_KEY))) + } + + public String getNamespace(AAIVersion version) { + String namespace = UrnPropertiesReader.getVariable(AAI_NAMESPACE_STRING_KEY) + if (namespace == null) { + throw new Exception('Internal Error: AAI Namespace has not been set yet. A getUri() method needs to be invoked first.') + } + + return namespace + version + } /** * This method can be used for getting the building namespace out of uri. * NOTE: A getUri() method needs to be invoked first. @@ -253,12 +123,11 @@ class AaiUtil { * * @return namespace */ - public String getNamespaceFromUri(String uri) { - if (aaiNamespace == null) { + String namespace = UrnPropertiesReader.getVariable(AAI_NAMESPACE_STRING_KEY) + if (namespace == null) { throw new Exception('Internal Error: AAI Namespace has not been set yet. A getUri() method needs to be invoked first.') } - String namespace = aaiNamespace if(uri!=null){ String version = getVersionFromUri(uri) return namespace + "v"+version @@ -296,16 +165,13 @@ class AaiUtil { * @return version */ private String getVersionFromUri(String uri) { - def version = "" - def savedVersion = "" - for (int x=2; x<6; x++) { - version = uri.substring(uri.indexOf("v")+1, uri.indexOf("v")+x) - if (!Character.isDigit(version.charAt(version.size()-1))) { - break - } - savedVersion = version + + Matcher versionRegEx = Pattern.compile("/v(\\d+)").matcher(uri) + if (versionRegEx.find()) { + return versionRegEx.group(1); } - return savedVersion + + return ""; } @@ -336,7 +202,7 @@ class AaiUtil { if (basicAuthCred != null && !"".equals(basicAuthCred)) { client.addAuthorizationHeader(basicAuthCred) } - apiResponse = client.get() + apiResponse = client.httpGet() msoLogger.trace("COMPLETED Execute AAI Get Process ") }catch(Exception e){ @@ -682,129 +548,5 @@ class AaiUtil { return 0 } } +} - private def getPInterface(DelegateExecution execution, String aai_uri) { - - String namespace = getNamespaceFromUri(execution, aai_uri) - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - String serviceAaiPath = aai_endpoint + aai_uri - - APIResponse response = executeAAIGetCall(execution, serviceAaiPath) - return new XmlParser().parseText(response.getResponseBodyAsString()) - } - - // This method checks if interface is remote - private def isPInterfaceRemote(DelegateExecution execution, String uri) { - if(uri.contains("ext-aai-network")) { - return true - } else { - return false - } - } - - // This method returns Local and remote TPs information from AAI - public Map getTPsfromAAI(DelegateExecution execution) { - Map tpInfo = [:] - - String aai_uri = '/aai/v14/network/logical-links' - - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - String serviceAaiPath = aai_endpoint + aai_uri - - APIResponse response = executeAAIGetCall(execution, serviceAaiPath) - - def logicalLinks = new XmlParser().parseText(response.getResponseBodyAsString()) - - logicalLinks."logical-link".each { link -> - def isRemoteLink = false - def pInterfaces = [] - def relationship = link."relationship-list"."relationship" - relationship.each { rel -> - if ("ext-aai-network".compareToIgnoreCase("${rel."related-to"[0]?.text()}") == 0) { - isRemoteLink = true - } - if ("p-interface".compareToIgnoreCase("${rel."related-to"[0]?.text()}") == 0) { - pInterfaces.add(rel) - } - } - - // if remote link then process - if (isRemoteLink) { - - // find remote p interface - def localTP = null - def remoteTP = null - - def pInterface0 = pInterfaces[0] - def pIntfUrl = "${pInterface0."related-link"[0].text()}" - - if (isRemotePInterface(execution, pIntfUrl)) { - remoteTP = pInterfaces[0] - localTP = pInterfaces[1] - } else { - localTP = pInterfaces[0] - remoteTP = pInterfaces[1] - } - - if (localTP != null && remoteTP != null) { - - // give local tp - def tpUrl = "${localTP."related-link"[0]?.text()}" - def intfLocal = getPInterface(execution, "${localTP?."related-link"[0]?.text()}") - tpInfo.put("local-access-node-id", tpUrl.split("/")[6]) - - def networkRef = "${intfLocal."network-ref"[0]?.text()}".split("/") - if (networkRef.size() == 6) { - tpInfo.put("local-access-provider-id", networkRef[1]) - tpInfo.put("local-access-client-id", networkRef[3]) - tpInfo.put("local-access-topology-id", networkRef[5]) - } - def ltpIdStr = tpUrl?.substring(tpUrl?.lastIndexOf("/") + 1) - if (ltpIdStr?.contains("-")) { - tpInfo.put("local-access-ltp-id", ltpIdStr?.substring(ltpIdStr?.lastIndexOf("-") + 1)) - } - - // give remote tp - tpUrl = "${remoteTP."related-link"[0]?.text()}" - def intfRemote = getPInterface(execution, "${remoteTP."related-link"[0].text()}") - tpInfo.put("remote-access-node-id", tpUrl.split("/")[6]) - - def networkRefRemote = "${intfRemote."network-ref"[0]?.text()}".split("/") - - if (networkRefRemote.size() == 6) { - tpInfo.put("remote-access-provider-id", networkRefRemote[1]) - tpInfo.put("remote-access-client-id", networkRefRemote[3]) - tpInfo.put("remote-access-topology-id", networkRefRemote[5]) - } - def ltpIdStrR = tpUrl?.substring(tpUrl?.lastIndexOf("/") + 1) - if (ltpIdStrR?.contains("-")) { - tpInfo.put("remote-access-ltp-id", ltpIdStrR?.substring(ltpIdStr?.lastIndexOf("-") + 1)) - } - return tpInfo - } - } - - } - return tpInfo - } - - // this method check if pInterface is remote - private def isRemotePInterface(DelegateExecution execution, String uri) { - def aai_uri = uri.substring(0, uri.indexOf("/p-interfaces")) - - String namespace = getNamespaceFromUri(execution, aai_uri) - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - String serviceAaiPath = aai_endpoint + aai_uri - - APIResponse response = executeAAIGetCall(execution, serviceAaiPath) - def pnf = new XmlParser().parseText(response.getResponseBodyAsString()) - - def relationship = pnf."relationship-list"."relationship" - relationship.each { - if ("ext-aai-network".compareToIgnoreCase("${it."related-to"[0]?.text()}") == 0) { - return true - } - } - return false - } -}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy index 0692e5022a..00bd8e9ef8 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy @@ -32,6 +32,7 @@ import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.client.aai.AAIResourcesClient import org.springframework.web.util.UriUtils public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcessor { @@ -693,6 +694,32 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess } /** + * Constructs a workflow message callback URL for the specified message type and correlator. + * This type of callback URL is used when a workflow wants an MSO adapter (like the SDNC + * adapter) to call it back. In other words, this is for callbacks internal to the MSO + * complex. Use <code>createWorkflowMessageAdapterCallbackURL</code> if the callback + * will come from outside the MSO complex. + * @param endpoint endpoint address to contruct URL from + * @param messageType the message type (e.g. SDNCAResponse or VNFAResponse) + * @param correlator the correlator value (e.g. a request ID) + */ + public String createCallbackURL(String endpoint, String messageType, String correlator) { + if (endpoint == null || endpoint.isEmpty()) { + ExceptionUtil exceptionUtil = new ExceptionUtil() + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, + 'mso:workflow:message:endpoint was not passed in') + } + + while (endpoint.endsWith('/')) { + endpoint = endpoint.substring(0, endpoint.length()-1) + } + + return endpoint + + '/' + UriUtils.encodePathSegment(messageType, 'UTF-8') + + '/' + UriUtils.encodePathSegment(correlator, 'UTF-8') + } + + /** * * Constructs a workflow message callback URL for the specified message type and correlator. * This type of callback URL is used when a workflow wants a system outside the MSO complex @@ -763,4 +790,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) } } + public AAIResourcesClient getAAIClient(){ + return new AAIResourcesClient(); + } }
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy index b054c0f934..e4bc5f8fa2 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy @@ -7,9 +7,9 @@ * 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. @@ -22,11 +22,17 @@ package org.onap.so.bpmn.common.scripts import static org.apache.commons.lang3.StringUtils.*; +import javax.ws.rs.NotFoundException + import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient +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.rest.APIResponse; @@ -102,7 +108,7 @@ class AllottedResourceUtils { // setsVariable aaiARGetResponse public String getARbyId (DelegateExecution execution, String allottedResourceId) { msoLogger.trace("getARbyId ") - String arLink = getARLinkbyId(execution, allottedResourceId) + AAIResourceUri arLink = getARLinkbyId(execution, allottedResourceId) String ar = null if (!isBlank(arLink)) { @@ -111,7 +117,7 @@ class AllottedResourceUtils { msoLogger.trace(" Exit GetARbyId - AR:" + ar) return ar; } - + public String getPSIFmARLink(DelegateExecution execution, String arLink) { // Path: /aai/{version}/business/customers/customer/{cust}/service-subscriptions/service-subscription/{subs}/service-instances/service-instance/{psiid}/allotted-resources/allotted-resource/{arid} @@ -129,39 +135,17 @@ class AllottedResourceUtils { msoLogger.trace("getARLinkbyId ") String arLink = null try { - AaiUtil aaiUriUtil = new AaiUtil(taskProcessor) - String aaiNQUri = aaiUriUtil.getSearchNodesQueryEndpoint(execution) - String aaiEndpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - String aaiUrl = "${aaiNQUri}?search-node-type=allotted-resource&filter=id:EQUALS:${allottedResourceId}" - - msoLogger.debug("getARLinkbyId url: \n" + aaiUrl) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, aaiUrl) - int responseCode = response.getStatusCode() - msoLogger.debug(" GET AR response code is: " + responseCode) - - String aaiResponse = response.getResponseBodyAsString() - msoLogger.debug("GET AR:" + aaiResponse) - if(responseCode == 200 || responseCode == 202){ - msoLogger.debug("GET AR Received a Good Response Code") - if(utils.nodeExists(aaiResponse, "result-data")){ - msoLogger.debug("Query for AllottedResource Url Response Does Contain Data" ) - arLink = utils.getNodeText(aaiResponse, "resource-link") - }else{ - msoLogger.debug("GET AR Response Does NOT Contain Data" ) - } - }else if(responseCode == 404){ - msoLogger.debug("GET AR received a Not Found (404) Response") - } - else{ - msoLogger.debug(" GET AR received a Bad Response: \n" + aaiResponse) - buildAAIErrorResponse(execution, aaiResponse, "Error retrieving AR from AAI") - } - }catch(Exception e){ + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId) + AaiUtil aaiUtil = new AaiUtil() + arLink = aaiUtil.createAaiUri(uri) + } catch (NotFoundException e) { + msoLogger.debug("GET AR received a Not Found (404) Response") + } catch(Exception e){ msoLogger.debug(" Error encountered within GetAaiAR" + e.getMessage()) exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error in GetARbyId" + e.getMessage()) } - msoLogger.trace(" Exit GetARLinkbyId - Link:" + arLink) + msoLogger.debug(" ***** Exit GetARLinkbyId ***** Link:" + arLink) return arLink } @@ -185,7 +169,7 @@ class AllottedResourceUtils { } arUrl = "${aai_endpoint}" + arEndpoint - + msoLogger.debug("GET AR Aai Path is: \n" + arUrl) APIResponse response = aaiUriUtil.executeAAIGetCall(execution, arUrl) @@ -229,13 +213,13 @@ class AllottedResourceUtils { { execution.setVariable("aaiARGetResponse", ar) execution.setVariable("aaiARPath", arUrl) - + String resourceVersion = null if (utils.nodeExists(ar, "resource-version")) { resourceVersion = utils.getNodeText(ar, "resource-version") execution.setVariable("aaiARResourceVersion", resourceVersion) } - + String orchStatus = null if (utils.nodeExists(ar, "orchestration-status")) { orchStatus= utils.getNodeText(ar, "orchestration-status") @@ -285,7 +269,7 @@ class AllottedResourceUtils { } msoLogger.trace("Exit updateAROrchStatus ") } - + //Sets Variable "wasDeleted" public void deleteAR(DelegateExecution execution, String aaiARPath){ msoLogger.trace(" deleteAR - aaiARPath:" + aaiARPath) @@ -294,14 +278,14 @@ class AllottedResourceUtils { APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, aaiARPath) int responseCode = response.getStatusCode() execution.setVariable("deleteARResponseCode", responseCode) - + msoLogger.debug(" Delete AR response code:" + responseCode) String aaiResponse = response.getResponseBodyAsString() execution.setVariable("aaiARDeleteResponse", aaiResponse) msoLogger.debug("Delete AR Response:" + aaiResponse) - + //Process Response if(responseCode == 204){ msoLogger.debug(" Delete AR Received a Good Response") diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy index ff5dabf99a..c19851d223 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy @@ -206,6 +206,7 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor { idXml = "" } idXml = utils.removeXmlPreamble(idXml) + idXml = utils.removeXmlNamespaces(idXml) msoLogger.debug("Incoming Instance Id Xml: " + idXml) String payload = """ diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy index bcd740eae9..c309c3bb68 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy @@ -7,9 +7,9 @@ * 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. @@ -19,15 +19,20 @@ */ package org.onap.so.bpmn.common.scripts +import javax.ws.rs.core.UriBuilder + import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.rest.APIResponse +import org.onap.aai.domain.yang.VolumeGroup +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.constants.Defaults import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ConfirmVolumeGroupName.class); - + def Prefix="CVGN_" ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -37,7 +42,7 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ execution.setVariable("CVGN_volumeGroupName",null) execution.setVariable("CVGN_aicCloudRegion", null) execution.setVariable("CVGN_volumeGroupGetEndpoint",null) - + // ConfirmVolumeGroupName workflow response variable placeholders execution.setVariable("CVGN_volumeGroupNameMatches", false) execution.setVariable("CVGN_queryVolumeGroupResponseCode",null) @@ -51,43 +56,31 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ def volumeGroupId = execution.getVariable("ConfirmVolumeGroupName_volumeGroupId") def volumeGroupName= execution.getVariable("ConfirmVolumeGroupName_volumeGroupName") def aicCloudRegion = execution.getVariable("ConfirmVolumeGroupName_aicCloudRegion") - + initProcessVariables(execution) execution.setVariable("CVGN_volumeGroupId", volumeGroupId) execution.setVariable("CVGN_volumeGroupName", volumeGroupName) execution.setVariable("CVGN_aicCloudRegion", aicCloudRegion) - - AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getCloudInfrastructureCloudRegionUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - msoLogger.debug("AAI URI: " + aai_uri) - execution.setVariable("CVGN_volumeGroupGetEndpoint","${aai_uri}/${aicCloudRegion}/volume-groups/volume-group/" + - volumeGroupId) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId) + execution.setVariable("CVGN_volumeGroupGetEndpoint", uri) } - + // send a GET request to AA&I to retrieve the Volume information based on volume-group-id // expect a 200 response with the information in the response body or a 404 if the volume group id does not exist public void queryAAIForVolumeGroupId(DelegateExecution execution) { - def endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + execution.getVariable("CVGN_volumeGroupGetEndpoint") - + AAIResourceUri resourceUri = execution.getVariable("CVGN_volumeGroupGetEndpoint") + try { - msoLogger.debug("invoking GET call to AAI endpoint :"+System.lineSeparator()+endPoint) - msoLogger.debug("queryAAIForVolumeGroupId() endpoint-" + endPoint) - msoLogger.debug("ConfirmVolumeGroup sending GET call to AAI Endpoint: " + endPoint) - - AaiUtil aaiUtil = new AaiUtil(this) - APIResponse response = aaiUtil.executeAAIGetCall(execution, endPoint) - def responseData = response.getResponseBodyAsString() - def responseStatusCode = response.getStatusCode() - execution.setVariable("CVGN_queryVolumeGroupResponseCode", responseStatusCode) - execution.setVariable("CVGN_queryVolumeGroupResponse", responseData) - - msoLogger.debug("Response code:" + responseStatusCode) - msoLogger.debug("Response:" + responseData) - msoLogger.debug("Response code:" + responseStatusCode) - msoLogger.debug("Response:" + System.lineSeparator()+responseData) + Optional<VolumeGroup> volumeGroupOp = getAAIClient().get(VolumeGroup.class, resourceUri) + if(volumeGroupOp.isPresent()){ + execution.setVariable("CVGN_queryVolumeGroupResponseCode", 200) + execution.setVariable("CVGN_queryVolumeGroupResponse", volumeGroupOp.get()) + }else{ + execution.setVariable("CVGN_queryVolumeGroupResponseCode", 404) + execution.setVariable("CVGN_queryVolumeGroupResponse", "Volume Group not Found!") + } } catch (Exception ex) { - // ex.printStackTrace() msoLogger.debug("Exception occurred while executing AAI GET:" + ex.getMessage()) execution.setVariable("CVGN_queryVolumeGroupResponseCode", 500) execution.setVariable("CVGN_queryVolumeGroupResponse", "AAI GET Failed:" + ex.getMessage()) @@ -100,17 +93,17 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ public void checkAAIQueryResult(DelegateExecution execution) { def result = execution.getVariable("CVGN_queryVolumeGroupResponse") - if (execution.getVariable("CVGN_queryVolumeGroupResponseCode") == 404) { + def actualVolumeGroupName = "" + if (execution.getVariable("CVGN_queryVolumeGroupResponseCode") == 404) { msoLogger.debug('volumeGroupId does not exist in AAI') } else if (execution.getVariable("CVGN_queryVolumeGroupResponseCode") == 200) { + VolumeGroup volumeGroup = execution.getVariable("CVGN_queryVolumeGroupResponse") + if(volumeGroup.getVolumeGroupName()!=null){ + actualVolumeGroupName = volumeGroup.getVolumeGroupName() + } msoLogger.debug("volumeGroupId exists in AAI") } - def xml = execution.getVariable("CVGN_queryVolumeGroupResponse") - def actualVolumeGroupName = "" - if (utils.nodeExists(xml, "volume-group-name")) { - actualVolumeGroupName = utils.getNodeText(xml, "volume-group-name") - } execution.setVariable("CVGN_volumeGroupNameMatches", false) def volumeGroupName = execution.getVariable("CVGN_volumeGroupName") @@ -134,4 +127,10 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ exceptionUtil.buildAndThrowWorkflowException(execution, 1002, errorNotAssociated) } -}
\ No newline at end of file + // sends a successful WorkflowResponse + public void reportSuccess(DelegateExecution execution) { + msoLogger.debug("Sending 200 back to the caller") + def responseXML = "" + execution.setVariable("WorkflowResponse", responseXML) + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy index c0ed81c553..13904c372d 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy @@ -7,9 +7,9 @@ * 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. @@ -37,6 +37,10 @@ import org.w3c.dom.NodeList import org.xml.sax.InputSource import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger +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.constants.Defaults /** * Vnf Module Subflow for confirming the volume group belongs @@ -63,13 +67,10 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ String incomingGroupName = execution.getVariable("volumeGroupName") String incomingTenantId = execution.getVariable("tenantId") def aicCloudRegion = execution.getVariable("aicCloudRegion") - String aai = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getCloudInfrastructureCloudRegionUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - - String path = aai + "${aai_uri}/${aicCloudRegion}/volume-groups/volume-group/" + volumeGroupId + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId) + String path = aaiUriUtil.createAaiUri(uri) APIResponse queryAAIForVolumeGroupResponse = aaiUriUtil.executeAAIGetCall(execution, path) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy index 84dd70682d..3bbc4bd110 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy @@ -22,6 +22,10 @@ package org.onap.so.bpmn.common.scripts import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.UrnPropertiesReader +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.client.graphinventory.entities.uri.Depth import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse @@ -67,8 +71,6 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("CAAIVfMod_deleteGenericVnfResponse","") execution.setVariable("CAAIVfMod_deleteVfModuleResponseCode",null) execution.setVariable("CAAIVfMod_deleteVfModuleResponse","") -// execution.setVariable("CAAIVfMod_ResponseCode",null) -// execution.setVariable("CAAIVfMod_ErrorResponse","") execution.setVariable("CreateAAIVfModuleResponse","") execution.setVariable("RollbackData", null) @@ -158,38 +160,38 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("CAAIVfMod_moduleModelName",execution.getVariable("vfModuleModelName")) AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - String aaiNamespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String aaiNamespace = aaiUriUtil.getNamespace() msoLogger.debug('AAI namespace is: ' + aaiNamespace) - - execution.setVariable("CAAIVfMod_aaiNamespace","${aaiNamespace}") - if (vnfId == null || vnfId.isEmpty()) { - // TBD - assert that the vnfName is not empty - execution.setVariable("CAAIVfMod_genericVnfGetEndpoint", - "${aai_uri}/?vnf-name=" + - UriUtils.encode(vnfName,"UTF-8") + "&depth=1") - } else { - execution.setVariable("CAAIVfMod_genericVnfGetEndpoint", - "${aai_uri}/" + UriUtils.encode(vnfId,"UTF-8") + "?depth=1") - } + execution.setVariable("CAAIVfMod_aaiNamespace","${aaiNamespace}") - msoLogger.debug("CreateAAIVfModule VNF PUT Endpoint: ${aai_uri}/") - execution.setVariable("CAAIVfMod_genericVnfPutEndpoint","${aai_uri}/") } // send a GET request to AA&I to retrieve the Generic VNF/VF Module information based on a Vnf Name // expect a 200 response with the information in the response body or a 404 if the Generic VNF does not exist public void queryAAIForGenericVnf(DelegateExecution execution) { - def endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + execution.getVariable("CAAIVfMod_genericVnfGetEndpoint") + + AaiUtil aaiUtil = new AaiUtil(this) + AAIResourceUri uri + + def vnfId = execution.getVariable("CAAIVfMod_vnfId") + def vnfName = execution.getVariable("CAAIVfMod_vnfName") + + if (vnfId == null || vnfId.isEmpty()) { + uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "") + uri.queryParam("vnf-name", vnfName) + } else { + uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + } + + uri.depth(Depth.ONE) + String endPoint = aaiUtil.createAaiUri(uri) try { msoLogger.debug("queryAAIForGenericVnf() endpoint-" + endPoint) msoLogger.debug("invoking GET call to AAI endpoint :"+System.lineSeparator()+endPoint) msoLogger.debug("CreateAAIVfModule sending GET call to AAI Endpoint: " + endPoint) - AaiUtil aaiUtil = new AaiUtil(this) APIResponse response = aaiUtil.executeAAIGetCall(execution, endPoint) def responseData = response.getResponseBodyAsString() def statusCode = response.getStatusCode() @@ -238,18 +240,8 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ public void createGenericVnf(DelegateExecution execution) { // TBD - is this how we want to generate the Id for the new Generic VNF? def newVnfId = UUID.randomUUID().toString() - def endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + - execution.getVariable("CAAIVfMod_genericVnfPutEndpoint") + newVnfId - // update the flow execution with the new Vnf Id execution.setVariable("CAAIVfMod_vnfId",newVnfId) - - // AaiUriUtil aaiUriUtil = new AaiUriUtil(this) - // def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - // msoLogger.debug('AAI URI is: ' + aai_uri) - // String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) - // msoLogger.debug('AAI namespace is: ' + namespace) - - + String payload = """<generic-vnf xmlns="${execution.getVariable("CAAIVfMod_aaiNamespace")}"> <vnf-id>${MsoUtils.xmlEscape(newVnfId)}</vnf-id> <vnf-name>${MsoUtils.xmlEscape(execution.getVariable("CAAIVfMod_vnfName"))}</vnf-name> @@ -262,11 +254,14 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("CAAIVfMod_createGenericVnfPayload", payload) try { + AaiUtil aaiUtil = new AaiUtil(this) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, newVnfId) + String endPoint = aaiUtil.createAaiUri(uri) + msoLogger.debug("createGenericVnf() endpoint-" + endPoint) msoLogger.debug("invoking PUT call to AAI with payload:"+System.lineSeparator()+payload) msoLogger.debug("Sending PUT call to AAI with Endpoint /n" + endPoint + " with payload /n" + payload) - AaiUtil aaiUtil = new AaiUtil(this); APIResponse response = aaiUtil.executeAAIPutCall(execution, endPoint, payload); def responseData = response.getResponseBodyAsString() def responseStatusCode = response.getStatusCode() @@ -293,10 +288,9 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ if (newModuleId == null || newModuleId.isEmpty()) { newModuleId = UUID.randomUUID().toString() } - def endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + execution.getVariable("CAAIVfMod_genericVnfPutEndpoint") - // need to append the existing Vnf Id or the one generated in createGenericVnf() to the url - endPoint = endPoint + UriUtils.encode(execution.getVariable("CAAIVfMod_vnfId"), "UTF-8") + - "/vf-modules/vf-module/" + newModuleId; + + String vnfId = execution.getVariable("CAAIVfMod_vnfId") + int moduleIndex = 0 if (!isBaseModule) { def aaiVnfResponse = execution.getVariable("CAAIVfMod_queryGenericVnfResponse") @@ -342,11 +336,15 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("CAAIVfMod_createVfModulePayload", payload) try { + + AaiUtil aaiUtil = new AaiUtil(this) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, newModuleId) + String endPoint = aaiUtil.createAaiUri(uri) + msoLogger.debug("createVfModule() endpoint-" + endPoint) msoLogger.debug("invoking PUT call to AAI with payload:"+System.lineSeparator()+payload) msoLogger.debug("CreateAAIVfModule sending PUT call to AAI with endpoint /n" + endPoint + " with payload /n " + payload) - AaiUtil aaiUtil = new AaiUtil(this) APIResponse response = aaiUtil.executeAAIPutCall(execution, endPoint, payload) def responseData = response.getResponseBodyAsString() def statusCode = response.getStatusCode() @@ -554,9 +552,6 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ msoLogger.debug("RollbackData:" + rollbackData) AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - msoLogger.debug("CreateAAIVfModule rollback AAI URI: " + aai_uri) if (rollbackData != null) { if (rollbackData.hasType("VFMODULE")) { @@ -566,9 +561,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ def isBaseModule = rollbackData.get("VFMODULE", "isBaseModule") execution.setVariable("DAAIVfMod_vnfId", vnfId) execution.setVariable("DAAIVfMod_vfModuleId", vfModuleId) - execution.setVariable("DAAIVfMod_genericVnfEndpoint", "${aai_uri}/" + vnfId) - execution.setVariable("DAAIVfMod_vfModuleEndpoint", "${aai_uri}/" + vnfId + - "/vf-modules/vf-module/" + vfModuleId) + DeleteAAIVfModule dvm = new DeleteAAIVfModule() // query A&AI to get the needed information for the delete(s) dvm.queryAAIForGenericVnf(execution) @@ -581,13 +574,14 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ if (isOneOf(responseCode, 200, 204)) { msoLogger.debug("Received " + responseCode + " to VF Module rollback request") -// execution.setVariable("RollbackResult", "SUCCESS") } else { msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Received " + responseCode + " to VF Module rollback request", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, rollbackData + System.lineSeparator() + "Response: " + response); } // a new Generic VNF was created that needs to be rolled back if (isBaseModule.equals("true")) { + dvm.queryAAIForGenericVnf(execution) + dvm.parseForResourceVersion(execution) dvm.deleteGenericVnf(execution) responseCode = execution.getVariable("DAAIVfMod_deleteGenericVnfResponseCode") response = execution.getVariable("DAAIVfMod_deleteGenericVnfResponse") diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy index ec691f299e..cc1be47029 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy @@ -23,6 +23,9 @@ package org.onap.so.bpmn.common.scripts import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.UrnPropertiesReader +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.rest.APIResponse import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger @@ -76,6 +79,9 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { def aicCloudRegion = getRequiredNodeText(execution, xml,'aic-cloud-region') execution.setVariable('CAAIVfModVG_aicCloudRegion', aicCloudRegion) + def cloudOwner = getRequiredNodeText(execution, xml,'cloud-owner') + execution.setVariable('CAAIVfModVG_cloudOwner', cloudOwner) + def volumeGroupId = getRequiredNodeText(execution, xml,'volume-group-id') execution.setVariable('CAAIVfModVG_volumeGroupId', volumeGroupId) @@ -105,12 +111,10 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { def vnfId = execution.getVariable('CAAIVfModVG_vnfId') def vfModuleId = execution.getVariable('CAAIVfModVG_vfModuleId') - // Construct endpoint AaiUtil aaiUtil = new AaiUtil(this) - def aai_uri = aaiUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + aai_uri + '/' + URLEncoder.encode(vnfId, "UTF-8") + '/vf-modules/vf-module/' + URLEncoder.encode(vfModuleId, "UTF-8") - + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + String endPoint = aaiUtil.createAaiUri(uri) + try { msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'') msoLogger.debug("aaiResponse GET TO AAI Endpoint: " + endPoint) @@ -166,17 +170,16 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { // Construct payload by creating a Volume Group relationhip and inserting it into the VF Module def aicCloudRegion = execution.getVariable('CAAIVfModVG_aicCloudRegion') + def cloudOwner = execution.getVariable('CAAIVfModVG_cloudOwner') def volumeGroupId = execution.getVariable('CAAIVfModVG_volumeGroupId') - def Node vgRelationshipNode = createVolumeGroupRelationshipNode(aicCloudRegion, volumeGroupId) + def Node vgRelationshipNode = createVolumeGroupRelationshipNode(cloudOwner, aicCloudRegion, volumeGroupId) insertVolumeGroupRelationshipNode(vfModuleNode, vgRelationshipNode) def payload = utils.nodeToString(vfModuleNode) - // Construct endpoint AaiUtil aaiUtil = new AaiUtil(this) - def aai_uri = aaiUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + aai_uri + '/' + URLEncoder.encode(vnfId, "UTF-8") + '/vf-modules/vf-module/' + URLEncoder.encode(vfModuleId, "UTF-8") - + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + String endPoint = aaiUtil.createAaiUri(uri) + try { msoLogger.debug("CreateAAIVfModuleVolume Sendind PUT to AAI Endpoint \n " + endPoint + " with payload \n " + payload) msoLogger.debug('sending PUT to AAI endpoint \'' + endPoint + '\'' + 'with payload \n' + payload) @@ -212,12 +215,12 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { * @param volumeGroupId Volume Group ID to use in the Volume Group relationship * @return a Node representing the new Volume Group relationship */ - private Node createVolumeGroupRelationshipNode(String aicCloudRegion, String volumeGroupId) { + private Node createVolumeGroupRelationshipNode(String cloudOwner, String aicCloudRegion, String volumeGroupId) { def Node relatedTo = new Node(null, 'related-to', 'volume-group') def Node relationshipKeyCO = new Node(null, 'relationship-key', 'cloud-region.cloud-owner') - def Node relationshipValueCO = new Node(null, 'relationship-value', 'att-aic') + def Node relationshipValueCO = new Node(null, 'relationship-value', cloudOwner) def Node relationshipDataCO = new Node(null, 'relationship-data') relationshipDataCO.append(relationshipKeyCO) relationshipDataCO.append(relationshipValueCO) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CustomE2EPutService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CustomE2EPutService.groovy deleted file mode 100644 index 43d540cc74..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CustomE2EPutService.groovy +++ /dev/null @@ -1,283 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.scripts - -import static org.apache.commons.lang3.StringUtils.*; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.apache.commons.codec.binary.Base64 -import org.apache.commons.lang3.* - -import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.rest.APIResponse; -import org.onap.so.rest.RESTClient -import org.onap.so.rest.RESTConfig - -import java.net.URLEncoder; -import org.springframework.web.util.UriUtils -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger - -/** - * This class supports the GenericPutService Sub Flow. - * This Generic sub flow can be used by any flow for the - * goal of creating a Service Instance or Service-Subscription in AAI. Upon successful completion of - * this sub flow the GENPS_SuccessIndicator will be true. - * The calling flow must set the GENPS_type variable as "service-instance" - * or "service-subscription". - * A MSOWorkflowException will be thrown Upon unsuccessful - * completion or if an error occurs within this flow. - * Please map variables to the corresponding variable names - * below. - * - * - * Incoming Required Variables: - * @param - GENPS_requestId - * @param - GENPS_type - Required field. This will be required field populated as service-instance or service-subscription - * @param - GENPS_globalSubscriberId - Required field - * @param - GENPS_serviceType - Required Field - * @param - GENPS_payload - Required Field This will be the payload that needs to be sent. - * - * @param - GENPS_serviceInstanceId - Conditional Field. Required for service-instance. - * @param - GENPS_allottedResourceId - Conditional Field. Required for allotted-resource. - * @param - GENPS_tunnelXconnectId - Conditional Field. Required for tunnel-xconnect. - * - * @param - GENPS_serviceResourceVersion - Conditional Field. Needs to be provided only in case of update for both service-instance and service subscription. The calling flows - * should check if a service-instance or servic-subscription exists by calling the subflow GenericGetService. if it exists then resourceversion should be - * obtained from aai and sent as an input parameter. - * - * Outgoing Variables: - * @param - GENPS_SuccessIndicator - * @param - WorkflowException - * - * - */ - - -class CustomE2EPutService extends AbstractServiceTaskProcessor{ - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CustomE2EPutService.class); - - String Prefix = "GENPS_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - - - public void preProcessRequest(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) - msoLogger.trace("STARTED GenericPutService PreProcessRequest Process") - - execution.setVariable("GENPS_SuccessIndicator", false) - - try{ - // Get Variables - String requestId = execution.getVariable("GENPS_requestId") - msoLogger.debug("Incoming GENPS_requestId is: " + requestId) - - String globalSubscriberId = execution.getVariable("GENPS_globalSubscriberId") - String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") - String serviceType = execution.getVariable("GENPS_serviceType") - String allottedResourceId = execution.getVariable("GENPS_allottedResourceId") - String tunnelXconnectId = execution.getVariable("GENPS_tunnelXconnectId") - String type = execution.getVariable("GENPS_type") - - if(type != null){ - msoLogger.debug("Incoming GENPS_type is: " + type) - if(type.equalsIgnoreCase("service-instance")){ - if(isBlank(globalSubscriberId) || isBlank(serviceType) || isBlank(serviceInstanceId)){ - msoLogger.debug("Incoming Required Variable is missing or null!") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Required Variable is Missing or Null!") - }else{ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - } - }else if(type.equalsIgnoreCase("service-subscription")){ - if(isBlank(serviceType) || isBlank(globalSubscriberId)){ - msoLogger.debug("Incoming ServiceType or GlobalSubscriberId is null. These variables are required to create a service-subscription.") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming ServiceType or GlobalCustomerId is null. These variables are required to Get a service-subscription.") - }else{ - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - } - }else if(type.equalsIgnoreCase("allotted-resource")){ - if(isBlank(globalSubscriberId) || isBlank(serviceType) || isBlank(serviceInstanceId) || isBlank(allottedResourceId)){ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Allotted Resource Id is: " + allottedResourceId) - msoLogger.debug("Incoming Required Variable is missing or null!") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Required Variable is Missing or Null!") - }else{ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Allotted Resource Id is: " + allottedResourceId) - } - }else if(type.equalsIgnoreCase("tunnel-xconnect")){ - if(isBlank(globalSubscriberId) || isBlank(serviceType) || isBlank(serviceInstanceId) || isBlank(allottedResourceId) || isBlank(tunnelXconnectId)){ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Allotted Resource Id is: " + allottedResourceId) - msoLogger.debug("Incoming Tunnel Xconnect Id is: " + tunnelXconnectId) - msoLogger.debug("Incoming Required Variable is missing or null!") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Required Variable is Missing or Null!") - }else{ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Allotted Resource Id is: " + allottedResourceId) - msoLogger.debug("Incoming Tunnel Xconnect Id is: " + tunnelXconnectId) - } - }else{ - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Type is Invalid. Please Specify Type as service-instance or service-subscription") - } - }else{ - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Incoming GENPS_type is null. Variable is Required.") - } - - }catch(BpmnError b){ - msoLogger.debug("Rethrowing MSOWorkflowException") - throw b - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Error encountered within GenericPutService PreProcessRequest method!" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in GenericPutService PreProcessRequest") - - } - msoLogger.trace("COMPLETED GenericPutService PreProcessRequest Process ") - - } - - - - /** - * This method executes a Put call to AAI for the provided - * service instance. - * - * @param - execution - * - */ - public void putServiceInstance(DelegateExecution execution){ - execution.setVariable("prefix",Prefix) - msoLogger.trace("STARTED GenericPutService PutServiceInstance method") - try { - String type = execution.getVariable("GENPS_type") - - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - String namespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) - msoLogger.debug('AAI namespace is: ' + namespace) - - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - String serviceAaiPath = "" - String payload = execution.getVariable("GENPS_payload") - execution.setVariable("GENPS_payload", payload) - msoLogger.debug("Incoming GENPS_payload is: " + payload) - msoLogger.debug(payload) - - String serviceType = execution.getVariable("GENPS_serviceType") - msoLogger.debug(" Incoming GENPS_serviceType is: " + serviceType) - String globalSubscriberId = execution.getVariable("GENPS_globalSubscriberId") - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - - // This IF clause is if we need to create a new Service Instance - if(type.equalsIgnoreCase("service-instance")){ - - String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") - msoLogger.debug(" Incoming GENPS_serviceInstanceId is: " + serviceInstanceId) - - // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + URLEncoder.encode(serviceInstanceId,"UTF-8") - serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") - - }else if(type.equalsIgnoreCase("service-subscription")){ - - // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") - serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") - }else if(type.equalsIgnoreCase("allotted-resource")){ - - String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") - msoLogger.debug(" Incoming GENPS_serviceInstanceId is: " + serviceInstanceId) - String allottedResourceId = execution.getVariable("GENPS_allottedResourceId") - msoLogger.debug(" Incoming GENPS_allottedResourceId is: " + allottedResourceId) - - // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") - serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") - }else if(type.equalsIgnoreCase("tunnel-xconnect")){ - - String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") - msoLogger.debug(" Incoming GENPS_serviceInstanceId is: " + serviceInstanceId) - String allottedResourceId = execution.getVariable("GENPS_allottedResourceId") - msoLogger.debug(" Incoming GENPS_allottedResourceId is: " + allottedResourceId) - String tunnelXconnectId = execution.getVariable("GENPS_tunnelXconnectId") - msoLogger.debug(" Incoming GENPS_tunnelXconnectId is: " + tunnelXconnectId) - - // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") - serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") + "/tunnel-xconnects/tunnel-xconnect/" + UriUtils.encode(tunnelXconnectId,"UTF-8") - } - - String resourceVersion = execution.getVariable("GENPS_serviceResourceVersion") - msoLogger.debug("Incoming Resource Version is: " + resourceVersion) - if(resourceVersion !=null){ - serviceAaiPath = serviceAaiPath +'?resource-version=' + UriUtils.encode(resourceVersion,"UTF-8") - } - - execution.setVariable("GENPS_putServiceInstanceAaiPath", serviceAaiPath) - msoLogger.debug("PUT Service Instance AAI Path is: " + "\n" + serviceAaiPath) - - APIResponse response = aaiUriUtil.executeAAIPutCall(execution, serviceAaiPath, payload) - int responseCode = response.getStatusCode() - execution.setVariable("GENPS_putServiceInstanceResponseCode", responseCode) - msoLogger.debug(" Put Service Instance response code is: " + responseCode) - - String aaiResponse = response.getResponseBodyAsString() - execution.setVariable("GENPS_putServiceInstanceResponse", aaiResponse) - - - //Process Response - if(responseCode == 200 || responseCode == 201 || responseCode == 202 ) - //200 OK 201 CREATED 202 ACCEPTED - { - msoLogger.debug("PUT Service Instance Received a Good Response") - execution.setVariable("GENPS_SuccessIndicator", true) - } - - else{ - msoLogger.debug("Put Generic Service Instance Received a Bad Response Code. Response Code is: " + responseCode) - exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) - throw new BpmnError("MSOWorkflowException") - } - }catch(BpmnError b){ - msoLogger.debug("Rethrowing MSOWorkflowException") - throw b - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Error encountered within GenericPutService PutServiceInstance method!" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During Put Service Instance") - } - msoLogger.trace("COMPLETED GenericPutService PutServiceInstance Process") - } - - - -} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy index bb9846c112..178b4d1695 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy @@ -22,6 +22,10 @@ package org.onap.so.bpmn.common.scripts import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.UrnPropertiesReader +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.client.graphinventory.entities.uri.Depth import org.onap.so.rest.APIResponse import org.onap.so.rest.RESTClient; import org.onap.so.rest.RESTConfig; @@ -41,8 +45,6 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("DAAIVfMod_genVnfRsrcVer",null) execution.setVariable("DAAIVfMod_vfModuleId",null) execution.setVariable("DAAIVfMod_vfModRsrcVer",null) - execution.setVariable("DAAIVfMod_genericVnfEndpoint",null) - execution.setVariable("DAAIVfMod_vfModuleEndpoint",null) execution.setVariable("DAAIVfMod_moduleExists",false) execution.setVariable("DAAIVfMod_isBaseModule", false) execution.setVariable("DAAIVfMod_isLastModule", false) @@ -69,79 +71,55 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ def vfModuleId = utils.getNodeText(xml,"vf-module-id") execution.setVariable("DAAIVfMod_vnfId", vnfId) execution.setVariable("DAAIVfMod_vfModuleId", vfModuleId) - - AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - - execution.setVariable("DAAIVfMod_genericVnfEndpoint", "${aai_uri}/" + vnfId) - execution.setVariable("DAAIVfMod_vfModuleEndpoint", "${aai_uri}/" + vnfId + - "/vf-modules/vf-module/" + vfModuleId) } // send a GET request to AA&I to retrieve the Generic Vnf/Vf Module information based on a Vnf Id // expect a 200 response with the information in the response body or a 404 if the Generic Vnf does not exist public void queryAAIForGenericVnf(DelegateExecution execution) { - def delModuleId = execution.getVariable("DAAIVfMod_vfModuleId") - def endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + execution.getVariable("DAAIVfMod_genericVnfEndpoint") + "?depth=1" - msoLogger.debug("DeleteAAIVfModule endPoint: " + endPoint) - def aaiRequestId = utils.getRequestID() + + def vnfId = execution.getVariable("DAAIVfMod_vnfId") - RESTConfig config = new RESTConfig(endPoint); - msoLogger.debug("queryAAIForGenericVnf() endpoint-" + endPoint) - def responseData = "" try { - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", aaiRequestId).addHeader("X-FromAppId", "MSO"). - addHeader("Accept","application/xml"); - String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution)) - - if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) - } - msoLogger.debug("invoking GET call to AAI endpoint :"+System.lineSeparator()+endPoint) - APIResponse response = client.httpGet() - msoLogger.debug("DeleteAAIVfModule - invoking httpGet to AAI") + AaiUtil aaiUriUtil = new AaiUtil(this) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + uri.depth(Depth.ONE) + String endPoint = aaiUriUtil.createAaiUri(uri) + + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint) + + msoLogger.debug('Response code:' + response.getStatusCode()) + msoLogger.debug('Response:' + response.getResponseBodyAsString()) - responseData = response.getResponseBodyAsString() execution.setVariable("DAAIVfMod_queryGenericVnfResponseCode", response.getStatusCode()) - execution.setVariable("DAAIVfMod_queryGenericVnfResponse", responseData) - msoLogger.debug("AAI Response: " + responseData) - msoLogger.debug("Response code:" + response.getStatusCode()) - msoLogger.debug("Response:" + System.lineSeparator()+responseData) + execution.setVariable("DAAIVfMod_queryGenericVnfResponse", response.getResponseBodyAsString()) + } catch (Exception ex) { msoLogger.debug("Exception occurred while executing AAI GET:" + ex.getMessage()) execution.setVariable("DAAIVfMod_queryGenericVnfResponse", "AAI GET Failed:" + ex.getMessage()) exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured during queryAAIForGenericVnf") - } } // construct and send a DELETE request to A&AI to delete a Generic Vnf // note: to get here, all the modules associated with the Generic Vnf must already be deleted public void deleteGenericVnf(DelegateExecution execution) { - def aaiRequestId = utils.getRequestID() - def endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + execution.getVariable("DAAIVfMod_genericVnfEndpoint") + - "/?resource-version=" + execution.getVariable("DAAIVfMod_genVnfRsrcVer") - msoLogger.debug("AAI endPoint: " + endPoint) - RESTConfig config = new RESTConfig(endPoint); - msoLogger.debug("deleteGenericVnf() endpoint-" + endPoint) - def responseData = "" + try { - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", aaiRequestId).addHeader("X-FromAppId", "MSO"). - addHeader("Accept","application/xml"); + String vnfId = execution.getVariable("DAAIVfMod_vnfId") + String resourceVersion = execution.getVariable("DAAIVfMod_genVnfRsrcVer") - String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution)) - - if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) - } - APIResponse response = client.httpDelete() + AaiUtil aaiUriUtil = new AaiUtil(this) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + uri.resourceVersion(resourceVersion) + String endPoint = aaiUriUtil.createAaiUri(uri) + + APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, endPoint) - responseData = response.getResponseBodyAsString() + def responseData = response.getResponseBodyAsString() execution.setVariable("DAAIVfMod_deleteGenericVnfResponseCode", response.getStatusCode()) execution.setVariable("DAAIVfMod_deleteGenericVnfResponse", responseData) msoLogger.debug("Response code:" + response.getStatusCode()) - msoLogger.debug("Response:" + System.lineSeparator()+responseData) + msoLogger.debug("Response:" + System.lineSeparator() + responseData) } catch (Exception ex) { ex.printStackTrace() msoLogger.debug("Exception occurred while executing AAI DELETE:" + ex.getMessage()) @@ -151,32 +129,25 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ // construct and send a DELETE request to A&AI to delete the Base or Add-on Vf Module public void deleteVfModule(DelegateExecution execution) { - def endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + execution.getVariable("DAAIVfMod_vfModuleEndpoint") + - "/?resource-version=" + execution.getVariable("DAAIVfMod_vfModRsrcVer") - def aaiRequestId = utils.getRequestID() - - RESTConfig config = new RESTConfig(endPoint); - msoLogger.debug("deleteVfModule() endpoint-" + endPoint) def responseData = "" try { - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", aaiRequestId).addHeader("X-FromAppId", "MSO"). - addHeader("Accept","application/xml"); + String vnfId = execution.getVariable("DAAIVfMod_vnfId") + String vfModuleId = execution.setVariable("DAAIVfMod_vfModuleId") + String resourceVersion = execution.getVariable("DAAIVfMod_vfModRsrcVer") - String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution)) - - if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) - } - APIResponse response = client.httpDelete() + AaiUtil aaiUriUtil = new AaiUtil(this) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + uri.resourceVersion(resourceVersion) + String endPoint = aaiUriUtil.createAaiUri(uri) - msoLogger.debug("DeleteAAIVfModule - invoking httpDelete to AAI") + APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, endPoint) responseData = response.getResponseBodyAsString() execution.setVariable("DAAIVfMod_deleteVfModuleResponseCode", response.getStatusCode()) execution.setVariable("DAAIVfMod_deleteVfModuleResponse", responseData) msoLogger.debug("DeleteAAIVfModule - AAI Response" + responseData) msoLogger.debug("Response code:" + response.getStatusCode()) - msoLogger.debug("Response:" + System.lineSeparator()+responseData) + msoLogger.debug("Response:" + System.lineSeparator() + responseData) } catch (Exception ex) { ex.printStackTrace() diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy index 7d4adaea58..3096bedda6 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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. @@ -31,11 +31,11 @@ import java.util.regex.Matcher import java.util.regex.Pattern class ExternalAPIUtil { - + String Prefix="EXTAPI_" public MsoUtils utils = new MsoUtils() - + ExceptionUtil exceptionUtil = new ExceptionUtil() private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ExternalAPIUtil.class) @@ -71,16 +71,16 @@ class ExternalAPIUtil { "\t\t\t\"serviceCharacteristic\": [ \n" + "<_requestInputs_> \n" + "\t\t\t] \n" + - "\t\t}\n" + + "\t\t}\n" + "\t}]\n" + "}" - + public static final String RequestInputsTemplate = "{ \n" + "\t\"name\": <inputName>, \n" + "\t\"value\": { \n" + "\t\t\"serviceCharacteristicValue\": <inputValue> \n" + - "\t} \n" + + "\t} \n" + "}" public ExternalAPIUtil() { @@ -93,11 +93,11 @@ class ExternalAPIUtil { // msoLogger.debug("ExternalAPIUtil.getUri: " + uri) // return uri // } -// +// // exceptionUtil.buildAndThrowWorkflowException(execution, 9999, 'ExternalAPI URI not find') // } - - public String setTemplate(String template, Map<String, String> valueMap) { + + public String setTemplate(String template, Map<String, String> valueMap) { msoLogger.debug("ExternalAPIUtil setTemplate", true); StringBuffer result = new StringBuffer(); @@ -143,7 +143,7 @@ class ExternalAPIUtil { if (basicAuthCred != null && !"".equals(basicAuthCred)) { client.addAuthorizationHeader(basicAuthCred) } - apiResponse = client.get() + apiResponse = client.httpGet() msoLogger.debug( "======== COMPLETED Execute ExternalAPI Get Process ======== ") }catch(Exception e){ diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy index 5cdcd0d5bf..78d147e819 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy @@ -30,6 +30,10 @@ import org.springframework.web.util.UriUtils import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.core.WorkflowException +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.client.graphinventory.entities.uri.Depth import org.onap.so.rest.APIResponse; import org.onap.so.rest.RESTClient import org.onap.so.rest.RESTConfig @@ -73,11 +77,11 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{ def vnfId = execution.getVariable('vnfId') def personaModelId = execution.getVariable('personaModelId') - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) + AaiUtil aaiUtil = new AaiUtil(this) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + uri.depth(Depth.ONE) + String endPoint = aaiUtil.createAaiUri(uri) - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" msoLogger.debug("AAI endPoint: " + endPoint) try { diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericGetVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericGetVnf.groovy deleted file mode 100644 index 01d8e9b8d5..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericGetVnf.groovy +++ /dev/null @@ -1,275 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.bpmn.common.scripts - -import org.onap.so.bpmn.core.UrnPropertiesReader -import static org.onap.so.bpmn.common.scripts.GenericUtils.*; - -import org.apache.commons.lang3.* -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.rest.APIResponse -import org.springframework.web.util.UriUtils -import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger - - - - -/** - * TODO: Support getting vnf type = vpe - * - * This class supports the GenericGetVnf Sub Flow. - * This Generic sub flow can be used by any flow for accomplishing - * the goal of getting a Vnf Object (from AAI). The flow currently - * supports the querying of 2 types of Vnfs, generic-vnf and vce. The - * type must be provided by the calling flow and the type should - * be mapped to the variable GENGV_type. The type should either be - * "generic-vnf" or "vce". If the Vnf Id is not provided by the calling - * flow then this sub flow will execute the query to get the - * Vnf using the Vnf Name. Therefore, the calling flow must provide - * either the Vnf Id or Vnf Name. - * - * Upon successful completion of this sub flow the - * GENGV_SuccessIndicator will be true and the query response payload - * will be set to GENGV_vnf. An MSOWorkflowException will - * be thrown upon unsuccessful completion or if an error occurs - * at any time during this sub flow. Please map variables - * to the corresponding variable names below. - * - * Note - if this sub flow receives a Not Found (404) response - * from AAI at any time this will be considered an acceptable - * successful response however the GENGV_FoundIndicator - * set to false. This will allow the calling flow to distinguish - * between the two success scenarios, "Success where Vnf is found" - * and "Success where Vnf is NOT found". - * - * - * Variable Mapping Below - * - * In Mapping Variables: - * @param - GENGV_vnfId or @param - GENGV_vnfName - * @param - GENGV_type - * - * Out Mapping Variables: - * @param - GENGV_vnf - * @param - GENGV_SuccessIndicator - * @param - GENGV_FoundIndicator - * @param - WorkflowException - * - * - */ -class GenericGetVnf extends AbstractServiceTaskProcessor{ - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, GenericGetVnf.class); - - - String Prefix = "GENGV_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - - /** - * This method validates the incoming variables and - * determines the subsequent event based on which - * variables the calling flow provided. - * - * @param - execution - */ - public void preProcessRequest(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) - msoLogger.trace("STARTED GenericGetVnf PreProcessRequest Process") - - execution.setVariable("GENGV_getVnfByName", false) - execution.setVariable("GENGV_SuccessIndicator", false) - execution.setVariable("GENGV_FoundIndicator", false) - - try{ - // Get Variables - String vnfId = execution.getVariable("GENGV_vnfId") - msoLogger.debug("Incoming Vnf Id is: " + vnfId) - String vnfName = execution.getVariable("GENGV_vnfName") - msoLogger.debug("Incoming Vnf Name is: " + vnfName) - - if(isBlank(vnfId) && isBlank(vnfName)){ - msoLogger.debug("Incoming Vnf Name and Vnf Id are null. At least one is required!") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Vnf Name and Vnf Id are null. At least one is required.") - }else{ - if(isBlank(vnfId)){ - execution.setVariable("GENGV_getVnfByName", true) - } - } - - }catch(BpmnError b){ - msoLogger.debug("Rethrowing MSOWorkflowException") - throw b - }catch(Exception e){ - msoLogger.debug(" Error encountered within GenericGetVnf PreProcessRequest method!" + e) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in GenericGetVnf PreProcessRequest") - - } - msoLogger.trace("COMPLETED GenericGetVnf PreProcessRequest Process ") - } - - /** - * This method executes a GET call to AAI to obtain the - * Vnf using the Vnf Name - * - * @param - execution - */ - public void getVnfByName(DelegateExecution execution){ - execution.setVariable("prefix",Prefix) - msoLogger.trace("STARTED GenericGetVnf GetVnfByName Process") - try { - String vnfName = execution.getVariable("GENGV_vnfName") - msoLogger.debug("Getting Vnf by Vnf Name: " + vnfName) - String type = execution.getVariable("GENGV_type") - msoLogger.debug("Type of Vnf Getting is: " + type) - - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - AaiUtil aaiUriUtil = new AaiUtil(this) - - //Determine Type of Vnf Querying For. - def aai_uri = "" - if(type.equals("generic-vnf")){ - aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - }else if(type.equals("vce")){ - aai_uri = aaiUriUtil.getNetworkVceUri(execution) - }else{ - msoLogger.debug("Invalid Incoming GENGV_type") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Invalid Incoming GENGV_type") - } - - String getVnfPath = "${aai_endpoint}${aai_uri}?vnf-name=" + UriUtils.encode(vnfName, "UTF-8") + "&depth=1" - - execution.setVariable("GENGV_getVnfPath", getVnfPath) - msoLogger.debug("Get Vnf Url is: " + getVnfPath) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, getVnfPath) - int responseCode = response.getStatusCode() - execution.setVariable("GENGV_getVnfResponseCode", responseCode) - msoLogger.debug(" GET Vnf response code is: " + responseCode) - - String aaiResponse = response.getResponseBodyAsString() - execution.setVariable("GENGV_getVnfResponse", aaiResponse) - - //Process Response - if(responseCode == 200){ - msoLogger.debug("GET Vnf Received a Good Response") - if(utils.nodeExists(aaiResponse, type)){ - msoLogger.debug("GET Vnf Response Contains a Vnf") - execution.setVariable("GENGV_FoundIndicator", true) - execution.setVariable("GENGV_vnf", aaiResponse) - execution.setVariable("WorkflowResponse", aaiResponse) - }else{ - msoLogger.debug("GET Vnf Response Does NOT Contain a Vnf") - } - - }else if(responseCode == 404){ - msoLogger.debug("GET Vnf Received a Not Found (404) Response") - }else{ - msoLogger.debug("GET Vnf Received a Bad Response: \n" + aaiResponse) - exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) - throw new BpmnError("MSOWorkflowException") - } - }catch(BpmnError b){ - msoLogger.debug("Rethrowing MSOWorkflowException") - throw b - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Error encountered within GenericGetVnf GetVnfByName method!" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During GetVnfByName") - } - msoLogger.trace("COMPLETED GenericGetVnf GetVnfByName Process") - } - - /** - * This method executes a GET call to AAI to obtain the - * Vnf using the Vnf Id - * - * @param - execution - */ - public void getVnfById(DelegateExecution execution){ - execution.setVariable("prefix",Prefix) - msoLogger.trace("STARTED GenericGetVnf GetVnfById Process") - try { - String vnfId = execution.getVariable("GENGV_vnfId") - msoLogger.debug("Getting Vnf by Vnf Id: " + vnfId) - String type = execution.getVariable("GENGV_type") - msoLogger.debug("Type of Vnf Getting is: " + type) - - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - AaiUtil aaiUriUtil = new AaiUtil(this) - - //Determine Type of Vnf Querying For. - def aai_uri = "" - if(type.equals("generic-vnf")){ - aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - }else if(type.equals("vce")){ - aai_uri = aaiUriUtil.getNetworkVceUri(execution) - }else if(type.equals("vpe")){ - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "GenericGetVnf does not yet support getting type of vnf = vpe") - }else{ - msoLogger.debug("Invalid Incoming GENGV_type") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Invalid Incoming GENGV_type") - } - msoLogger.debug("Using AAI Uri: " + aai_uri) - - String getVnfPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" - msoLogger.debug("GET Vnf Endpoint is: " + getVnfPath) - - execution.setVariable("GENGV_getVnfPath", getVnfPath) - msoLogger.debug("Get Vnf Url is: " + getVnfPath) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, getVnfPath) - int responseCode = response.getStatusCode() - execution.setVariable("GENGV_getVnfResponseCode", responseCode) - msoLogger.debug(" GET Vnf response code is: " + responseCode) - - String aaiResponse = response.getResponseBodyAsString() - execution.setVariable("GENGV_getVnfResponse", aaiResponse) - - //Process Response - if(responseCode == 200){ - msoLogger.debug("GET Vnf Received a Good Response") - if(utils.nodeExists(aaiResponse, type)){ - msoLogger.debug("GET Vnf Response Contains a Vnf") - execution.setVariable("GENGV_FoundIndicator", true) - execution.setVariable("GENGV_vnf", aaiResponse) - execution.setVariable("WorkflowResponse", aaiResponse) - }else{ - msoLogger.debug("GET Vnf Response Does NOT Contain a Vnf") - } - - }else if(responseCode == 404){ - msoLogger.debug("GET Vnf Received a Not Found (404) Response") - }else{ - msoLogger.debug("GET Vnf Received a BAD REST Response: \n" + aaiResponse) - exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) - throw new BpmnError("MSOWorkflowException") - } - }catch(BpmnError b){ - msoLogger.debug("Rethrowing MSOWorkflowException") - throw b - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Error encountered within GenericGetVnf GetVnfById method!" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During GetVnfById") - } - msoLogger.trace("COMPLETED GenericGetVnf GetVnfById Process") - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericPutService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericPutService.groovy deleted file mode 100644 index 8cc756d412..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericPutService.groovy +++ /dev/null @@ -1,282 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.bpmn.common.scripts - -import org.onap.so.bpmn.core.UrnPropertiesReader - -import static org.apache.commons.lang3.StringUtils.*; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.apache.commons.codec.binary.Base64 -import org.apache.commons.lang3.* - -import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.rest.APIResponse; -import org.onap.so.rest.RESTClient -import org.onap.so.rest.RESTConfig - -import java.net.URLEncoder; -import org.springframework.web.util.UriUtils -import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger - - - -/** - * This class supports the GenericPutService Sub Flow. - * This Generic sub flow can be used by any flow for the - * goal of creating a Service Instance or Service-Subscription in AAI. Upon successful completion of - * this sub flow the GENPS_SuccessIndicator will be true. - * The calling flow must set the GENPS_type variable as "service-instance" - * or "service-subscription". - * A MSOWorkflowException will be thrown Upon unsuccessful - * completion or if an error occurs within this flow. - * Please map variables to the corresponding variable names - * below. - * - * - * Incoming Required Variables: - * @param - GENPS_requestId - * @param - GENPS_type - Required field. This will be required field populated as service-instance or service-subscription - * @param - GENPS_globalSubscriberId - Required field - * @param - GENPS_serviceType - Required Field - * @param - GENPS_payload - Required Field This will be the payload that needs to be sent. - * - * @param - GENPS_serviceInstanceId - Conditional Field. Required for service-instance. - * @param - GENPS_allottedResourceId - Conditional Field. Required for allotted-resource. - * @param - GENPS_tunnelXconnectId - Conditional Field. Required for tunnel-xconnect. - * - * @param - GENPS_serviceResourceVersion - Conditional Field. Needs to be provided only in case of update for both service-instance and service subscription. The calling flows - * should check if a service-instance or servic-subscription exists by calling the subflow. if it exists then resourceversion should be - * obtained from aai and sent as an input parameter. - * - * Outgoing Variables: - * @param - GENPS_SuccessIndicator - * @param - WorkflowException - * - * - */ - - -class GenericPutService extends AbstractServiceTaskProcessor{ - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, GenericPutService.class); - - - String Prefix = "GENPS_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - - - public void preProcessRequest(DelegateExecution execution) { - execution.setVariable("isDebugLogEnabled","true") - execution.setVariable("prefix",Prefix) - msoLogger.trace("STARTED GenericPutService PreProcessRequest Process") - - execution.setVariable("GENPS_SuccessIndicator", false) - - try{ - // Get Variables - String requestId = execution.getVariable("GENPS_requestId") - msoLogger.debug("Incoming GENPS_requestId is: " + requestId) - - String globalSubscriberId = execution.getVariable("GENPS_globalSubscriberId") - String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") - String serviceType = execution.getVariable("GENPS_serviceType") - String allottedResourceId = execution.getVariable("GENPS_allottedResourceId") - String tunnelXconnectId = execution.getVariable("GENPS_tunnelXconnectId") - String type = execution.getVariable("GENPS_type") - - if(type != null){ - msoLogger.debug("Incoming GENPS_type is: " + type) - if(type.equalsIgnoreCase("service-instance")){ - if(isBlank(globalSubscriberId) || isBlank(serviceType) || isBlank(serviceInstanceId)){ - msoLogger.debug("Incoming Required Variable is missing or null!") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Required Variable is Missing or Null!") - }else{ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - } - }else if(type.equalsIgnoreCase("service-subscription")){ - if(isBlank(serviceType) || isBlank(globalSubscriberId)){ - msoLogger.debug("Incoming ServiceType or GlobalSubscriberId is null. These variables are required to create a service-subscription.") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming ServiceType or GlobalCustomerId is null. These variables are required to Get a service-subscription.") - }else{ - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - } - }else if(type.equalsIgnoreCase("allotted-resource")){ - if(isBlank(globalSubscriberId) || isBlank(serviceType) || isBlank(serviceInstanceId) || isBlank(allottedResourceId)){ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Allotted Resource Id is: " + allottedResourceId) - msoLogger.debug("Incoming Required Variable is missing or null!") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Required Variable is Missing or Null!") - }else{ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Allotted Resource Id is: " + allottedResourceId) - } - }else if(type.equalsIgnoreCase("tunnel-xconnect")){ - if(isBlank(globalSubscriberId) || isBlank(serviceType) || isBlank(serviceInstanceId) || isBlank(allottedResourceId) || isBlank(tunnelXconnectId)){ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Allotted Resource Id is: " + allottedResourceId) - msoLogger.debug("Incoming Tunnel Xconnect Id is: " + tunnelXconnectId) - msoLogger.debug("Incoming Required Variable is missing or null!") - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Required Variable is Missing or Null!") - }else{ - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId) - msoLogger.debug("Incoming Service Type is: " + serviceType) - msoLogger.debug("Incoming Allotted Resource Id is: " + allottedResourceId) - msoLogger.debug("Incoming Tunnel Xconnect Id is: " + tunnelXconnectId) - } - }else{ - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Type is Invalid. Please Specify Type as service-instance or service-subscription") - } - }else{ - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Incoming GENPS_type is null. Variable is Required.") - } - - }catch(BpmnError b){ - msoLogger.debug("Rethrowing MSOWorkflowException") - throw b - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Error encountered within GenericPutService PreProcessRequest method!" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in GenericPutService PreProcessRequest") - - } - msoLogger.trace("COMPLETED GenericPutService PreProcessRequest Process ") - - } - - /** - * This method executes a Put call to AAI for the provided - * service instance. - * - * @param - execution - * - */ - public void putServiceInstance(DelegateExecution execution){ - execution.setVariable("prefix",Prefix) - msoLogger.trace("STARTED GenericPutService PutServiceInstance method") - try { - String type = execution.getVariable("GENPS_type") - - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - String namespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) - msoLogger.debug('AAI namespace is: ' + namespace) - - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - String serviceAaiPath = "" - String payload = execution.getVariable("GENPS_payload") - execution.setVariable("GENPS_payload", payload) - msoLogger.debug("Incoming GENPS_payload is: " + payload) - msoLogger.debug(payload) - - String serviceType = execution.getVariable("GENPS_serviceType") - msoLogger.debug(" Incoming GENPS_serviceType is: " + serviceType) - - String globalSubscriberId = execution.getVariable("GENPS_globalSubscriberId") - msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId) - - // This IF clause is if we need to create a new Service Instance - if(type.equalsIgnoreCase("service-instance")){ - - String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") - msoLogger.debug(" Incoming GENPS_serviceInstanceId is: " + serviceInstanceId) - - // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + URLEncoder.encode(serviceInstanceId,"UTF-8") - serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") - - }else if(type.equalsIgnoreCase("service-subscription")){ - - // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") - serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") - }else if(type.equalsIgnoreCase("allotted-resource")){ - - String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") - msoLogger.debug(" Incoming GENPS_serviceInstanceId is: " + serviceInstanceId) - String allottedResourceId = execution.getVariable("GENPS_allottedResourceId") - msoLogger.debug(" Incoming GENPS_allottedResourceId is: " + allottedResourceId) - - // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") - serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") - }else if(type.equalsIgnoreCase("tunnel-xconnect")){ - - String serviceInstanceId = execution.getVariable("GENPS_serviceInstanceId") - msoLogger.debug(" Incoming GENPS_serviceInstanceId is: " + serviceInstanceId) - String allottedResourceId = execution.getVariable("GENPS_allottedResourceId") - msoLogger.debug(" Incoming GENPS_allottedResourceId is: " + allottedResourceId) - String tunnelXconnectId = execution.getVariable("GENPS_tunnelXconnectId") - msoLogger.debug(" Incoming GENPS_tunnelXconnectId is: " + tunnelXconnectId) - - // serviceAaiPath = "${aai_endpoint}${aai_uri}/" + URLEncoder.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + URLEncoder.encode(serviceType,"UTF-8") - serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalSubscriberId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") + "/tunnel-xconnects/tunnel-xconnect/" + UriUtils.encode(tunnelXconnectId,"UTF-8") - } - - String resourceVersion = execution.getVariable("GENPS_serviceResourceVersion") - msoLogger.debug("Incoming Resource Version is: " + resourceVersion) - if(resourceVersion !=null){ - serviceAaiPath = serviceAaiPath +'?resource-version=' + UriUtils.encode(resourceVersion,"UTF-8") - } - - execution.setVariable("GENPS_putServiceInstanceAaiPath", serviceAaiPath) - msoLogger.debug("PUT Service Instance AAI Path is: " + "\n" + serviceAaiPath) - APIResponse response = aaiUriUtil.executeAAIPutCall(execution, serviceAaiPath, payload) - int responseCode = response.getStatusCode() - execution.setVariable("GENPS_putServiceInstanceResponseCode", responseCode) - msoLogger.debug(" Put Service Instance response code is: " + responseCode) - - String aaiResponse = response.getResponseBodyAsString() - execution.setVariable("GENPS_putServiceInstanceResponse", aaiResponse) - - //Process Response - if(responseCode == 200 || responseCode == 201 || responseCode == 202 ) - //200 OK 201 CREATED 202 ACCEPTED - { - msoLogger.debug("PUT Service Instance Received a Good Response") - execution.setVariable("GENPS_SuccessIndicator", true) - } - - else{ - msoLogger.debug("Put Generic Service Instance Received a Bad Response Code. Response Code is: " + responseCode) - exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) - throw new BpmnError("MSOWorkflowException") - } - }catch(BpmnError b){ - msoLogger.debug("Rethrowing MSOWorkflowException") - throw b - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Error encountered within GenericPutService PutServiceInstance method!" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, ""); - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During Put Service Instance") - } - msoLogger.trace("COMPLETED GenericPutService PutServiceInstance Process") - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy index 2e5499c158..1e8569c3e7 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy @@ -20,43 +20,29 @@ package org.onap.so.bpmn.common.scripts; -import org.apache.commons.lang3.* - -import groovy.xml.XmlUtil -import org.onap.so.bpmn.core.UrnPropertiesReader - +import javax.ws.rs.core.UriBuilder import javax.xml.parsers.DocumentBuilder import javax.xml.parsers.DocumentBuilderFactory import javax.xml.transform.Transformer import javax.xml.transform.TransformerFactory -import javax.xml.transform.TransformerException import javax.xml.transform.dom.DOMSource import javax.xml.transform.stream.StreamResult -import org.camunda.bpm.engine.delegate.BpmnError +import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.DelegateExecution -import org.w3c.dom.Document -import org.w3c.dom.Element - -import org.w3c.dom.NamedNodeMap -import org.w3c.dom.Node -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource +import org.onap.so.bpmn.core.UrnPropertiesReader +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.MsoLogger - -import org.onap.so.logger.MessageEnum - - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; import org.w3c.dom.Document import org.w3c.dom.Element -import org.w3c.dom.NamedNodeMap import org.w3c.dom.Node import org.w3c.dom.NodeList; import org.xml.sax.InputSource +import groovy.xml.XmlUtil + /** * This groovy class supports the any Network processes that need the methods defined here. @@ -332,41 +318,9 @@ class NetworkUtils { return requestPayload } - - def String createCloudRegionVolumeRequest(groupId, volumeName, vnfType, tenantId, cloudRegion, namespace, modelCustomizationId) { - - String requestPayload = - """<volume-group xmlns="${namespace}"> - <volume-group-id>${MsoUtils.xmlEscape(groupId)}</volume-group-id> - <volume-group-name>${MsoUtils.xmlEscape(volumeName)}</volume-group-name> - <heat-stack-id></heat-stack-id> - <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type> - <orchestration-status>Pending</orchestration-status> - <vf-module-model-customization-id>${MsoUtils.xmlEscape(modelCustomizationId)}</vf-module-model-customization-id> - <relationship-list> - <relationship> - <related-to>tenant</related-to> - <relationship-data> - <relationship-key>tenant.tenant-id</relationship-key> - <relationship-value>${MsoUtils.xmlEscape(tenantId)}</relationship-value> - </relationship-data> - <relationship-data> - <relationship-key>cloud-region.cloud-owner</relationship-key> - <relationship-value>att-aic</relationship-value> - </relationship-data> - <relationship-data> - <relationship-key>cloud-region.cloud-region-id</relationship-key> - <relationship-value>${MsoUtils.xmlEscape(cloudRegion)}</relationship-value> - </relationship-data> - </relationship> - </relationship-list> - </volume-group>""" - - return requestPayload - } - - def String createCloudRegionVolumeRequest(groupId, volumeName, vnfType, vnfId, tenantId, cloudRegion, namespace, modelCustomizationId) { - + + def String createCloudRegionVolumeRequest(groupId, volumeName, vnfType, vnfId, tenantId, cloudOwner, cloudRegion, namespace, modelCustomizationId) { + String requestPayload = """<volume-group xmlns="${namespace}"> <volume-group-id>${MsoUtils.xmlEscape(groupId)}</volume-group-id> @@ -391,7 +345,7 @@ class NetworkUtils { </relationship-data> <relationship-data> <relationship-key>cloud-region.cloud-owner</relationship-key> - <relationship-value>att-aic</relationship-value> + <relationship-value>${cloudOwner}</relationship-value> </relationship-data> <relationship-data> <relationship-key>cloud-region.cloud-region-id</relationship-key> @@ -858,10 +812,8 @@ class NetworkUtils { if (utils.getNodeText(relationshipXml, 'related-to') == "cloud-region") { def relatedLink = utils.getNodeText(relationshipXml, 'related-link') if (relatedLink != null || relatedLink != "") { - lcpCloudRegion = relatedLink.substring(relatedLink.indexOf("/att-aic/")+9, relatedLink.length()) - if (lcpCloudRegion.contains('/')) { - lcpCloudRegion = relatedLink.substring(relatedLink.indexOf("/att-aic/")+9, relatedLink.length()-1) - } + AAIResourceUri aaiUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.CLOUD_REGION, UriBuilder.fromUri(relatedLink).build()) + lcpCloudRegion = aaiUri.getURIKeys().getOrDefault("cloud-region", "") } } } diff --git 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 index 7028f6eeed..aa0d8ace6a 100644 --- 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 @@ -152,9 +152,7 @@ class OofHoming extends AbstractServiceTaskProcessor { execution.setVariable("oofRequest", oofRequest) utils.log("DEBUG", "OOF Request is: " + oofRequest, isDebugEnabled) - String endpoint = UrnPropertiesReader.getVariable("mso.oof.service.agnostic.endpoint", execution) - String host = UrnPropertiesReader.getVariable("mso.oof.service.agnostic.host", execution) - String url = host + endpoint + String url = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) utils.log("DEBUG", "Posting to OOF Url: " + url, isDebugEnabled) logDebug("URL to be used is: " + url, isDebugEnabled) diff --git 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 index d95795906f..b1da7cf49b 100644 --- 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 @@ -87,7 +87,9 @@ class OofUtils { ArrayList requiredCandidates = null) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") utils.log("DEBUG", "Started Building OOF Request", isDebugEnabled) - def callbackUrl = utils.createWorkflowMessageAdapterCallbackURL(execution, "oofResponse", requestId) + String callbackEndpoint = UrnPropertiesReader.getVariable("mso.oof.callbackEndpoint", execution) + utils.log("DEBUG", "mso.oof.callbackEndpoint is: " + callbackEndpoint, isDebugEnabled) + def callbackUrl = utils.createWorkflowMessageAdapterCallbackURL(callbackEndpoint, "oofResponse", requestId) def transactionId = requestId //ServiceInstance Info ServiceInstance serviceInstance = decomposition.getServiceInstance() diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy index a6f8ff469d..1a55bf2a0e 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy @@ -7,9 +7,9 @@ * 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. @@ -20,10 +20,20 @@ package org.onap.so.bpmn.common.scripts +import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.camunda.bpm.model.dmn.instance.OrganizationUnit +import org.hibernate.engine.jdbc.Size.LobMultiplier import org.onap.so.bpmn.core.WorkflowException +import org.onap.aai.domain.yang.GenericVnf import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.rest.APIResponse import org.onap.so.rest.RESTClient import org.onap.so.rest.RESTConfig @@ -36,12 +46,12 @@ import org.onap.so.logger.MsoLogger public class PrepareUpdateAAIVfModule extends VfModuleBase { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, PrepareUpdateAAIVfModule.class); - + ExceptionUtil exceptionUtil = new ExceptionUtil() private MsoUtils utils = new MsoUtils() /** * Initialize the flow's variables. - * + * * @param execution The flow's execution instance. */ public void initProcessVariables(DelegateExecution execution) { @@ -58,11 +68,11 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { execution.setVariable('PUAAIVfMod_updateVfModuleResponseCode', null) execution.setVariable('PUAAIVfMod_updateVfModuleResponse', '') execution.setVariable('PUAAIVfMod_outVfModule', null) - } - + } + /** * Check for missing elements in the received request. - * + * * @param execution The flow's execution instance. */ public void preProcessRequest(DelegateExecution execution) { @@ -75,15 +85,15 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { def xml = execution.getVariable('PrepareUpdateAAIVfModuleRequest') msoLogger.debug('Received request xml:\n' + xml) msoLogger.debug("PrepareUpdateAAIVfModule Request : " + xml) - + initProcessVariables(execution) - + def vnfId = getRequiredNodeText(execution, xml,'vnf-id') execution.setVariable('PUAAIVfMod_vnfId', vnfId) def vfModuleId = getRequiredNodeText(execution, xml,'vf-module-id') execution.setVariable('PUAAIVfMod_vfModuleId', vfModuleId) - + def orchestrationStatus = getRequiredNodeText(execution, xml,'orchestration-status') execution.setVariable('PUAAIVfMod_orchestrationStatus', orchestrationStatus) @@ -95,11 +105,11 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) } } - + /** * Using the received vnfId, query AAI to get the corresponding Generic VNF. * A 200 response is expected with the Generic VNF in the response body. - * + * * @param execution The flow's execution instance. */ public void getGenericVnf(DelegateExecution execution) { @@ -110,40 +120,17 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { try { def vnfId = execution.getVariable('PUAAIVfMod_vnfId') - - AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" - - msoLogger.debug("PrepareUpdateAAIVfModule: AAI endPoint : " + endPoint) - String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution)) + + try { - RESTConfig config = new RESTConfig(endPoint); - def responseData = '' - String aaiRequestId = utils.getRequestID() - RESTClient client = new RESTClient(config). - addHeader('X-TransactionId', aaiRequestId). - addHeader('X-FromAppId', 'MSO'). - addHeader('Content-Type', 'application/xml'). - addHeader('Accept','application/xml'); - if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) - } - msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'') - APIResponse response = client.httpGet() - msoLogger.debug("PrepareUpdateAAIVfModule: - invoking httpGet to AAI") - - responseData = response.getResponseBodyAsString() - execution.setVariable('PUAAIVfMod_getVnfResponseCode', response.getStatusCode()) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResultWrapper wrapper = resourceClient.get(uri.depth(Depth.ONE), NotFoundException.class) + GenericVnf responseData = wrapper.asBean(GenericVnf.class).get() + execution.setVariable('PUAAIVfMod_getVnfResponse', responseData) - - msoLogger.debug("PrepareUpdateAAIVfModule: AAI Response : " + responseData) - msoLogger.debug("PrepareUpdateAAIVfModule: AAI ResponseCode : " + response.getStatusCode()) - - msoLogger.debug('Response code:' + response.getStatusCode()) - msoLogger.debug('Response:' + System.lineSeparator() + responseData) + execution.setVariable('PUAAIVfMod_getVnfResponseCode', 200) + } catch (Exception ex) { msoLogger.error(ex); msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) @@ -158,13 +145,13 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in getGenericVnf(): ' + e.getMessage()) } } - + /** * Validate the VF Module. That is, confirm that a VF Module with the input VF Module ID * exists in the retrieved Generic VNF. Then, check to make sure that if that VF Module * is the base VF Module and it's not the only VF Module for this Generic VNF, that we're not * attempting to delete it. - * + * * @param execution The flow's execution instance. */ public void validateVfModule(DelegateExecution execution) { @@ -172,22 +159,30 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { 'execution=' + execution.getId() + ')' msoLogger.trace('Entered ' + method) - + try { - def genericVnf = execution.getVariable('PUAAIVfMod_getVnfResponse') + GenericVnf genericVnf = execution.getVariable('PUAAIVfMod_getVnfResponse') def vnfId = execution.getVariable('PUAAIVfMod_vnfId') def vfModuleId = execution.getVariable('PUAAIVfMod_vfModuleId') - def vnfName = getNodeTextForce(genericVnf, 'vnf-name') + def vnfName = genericVnf.getVnfName() execution.setVariable('PUAAIVfMod_vnfName', vnfName) - def VfModule vfModule = findVfModule(genericVnf, vfModuleId) - if (vfModule == null) { + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + AAIResourcesClient resourceClient = new AAIResourcesClient() + + + + // def VfModule vfModule = findVfModule(genericVnf, vfModuleId) + if (!resourceClient.exists(uri)) { def String msg = 'VF Module \'' + vfModuleId + '\' does not exist in Generic VNF \'' + vnfId + '\'' execution.setVariable('PUAAIVfMod_vfModuleValidationError', msg) execution.setVariable('PUAAIVfMod_vfModuleOK', false) } else { + AAIResultWrapper wrapper = resourceClient.get(uri, NotFoundException.class) + org.onap.aai.domain.yang.VfModule vfModule = wrapper.asBean(org.onap.aai.domain.yang.VfModule.class).get() + def orchestrationStatus = execution.getVariable('PUAAIVfMod_orchestrationStatus') - msoLogger.debug('VF Module \'' + vfModuleId + '\': isBaseVfModule=' + vfModule.isBaseVfModule() +', isOnlyVfModule=' + vfModule.isOnlyVfModule() + ', new orchestration-status=' + orchestrationStatus) - if (vfModule.isBaseVfModule() && !vfModule.isOnlyVfModule() && orchestrationStatus.equals('pending-delete')) { + if (vfModule.isBaseVfModule && genericVnf.getVfModules().getVfModule().size() > 1 && vfModule.getOrchestrationStatus().equals('pending-delete')) { def String msg = 'Orchestration status for VF Module \'' + vfModuleId + '\' cannot be set to \'pending-delete\' since it is the base VF Module and it\'s not the only VF Module in Generic VNF \'' + vnfId + '\'' execution.setVariable('PUAAIVfMod_vfModuleValidationError', msg) @@ -197,7 +192,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { execution.setVariable('PUAAIVfMod_vfModuleOK', true) } } - + msoLogger.trace('Exited ' + method) } catch (BpmnError e) { throw e; @@ -206,10 +201,10 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in validateVfModule(): ' + e.getMessage()) } } - + /** * Construct and send a PATCH request to AAI to update the VF Module. - * + * * @param execution The flow's execution instance. */ public void updateVfModule(DelegateExecution execution) { @@ -217,39 +212,33 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { 'execution=' + execution.getId() + ')' msoLogger.trace('Entered ' + method) - + try { // Construct payload - def VfModule vfModule = (VfModule) execution.getVariable('PUAAIVfMod_vfModule') - def Node newVfModuleNode = vfModule.getNode().clone() + org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('PUAAIVfMod_vfModule') + def orchestrationStatus = execution.getVariable('PUAAIVfMod_orchestrationStatus') - def Node orchestrationStatusNode = utils.getChildNode(newVfModuleNode, 'orchestration-status') - if (orchestrationStatusNode == null) { - // Node doesn't exist, this should never happen, right? - new Node(newVfModuleNode, 'orchestration-status', orchestrationStatus) - } else { - // Node already exists, just give it a new value - orchestrationStatusNode.setValue(orchestrationStatus) - } - def VfModule newVfModule = new VfModule(newVfModuleNode, vfModule.isOnlyVfModule()) + + vfModule.setOrchestrationStatus(orchestrationStatus) + //def payload = utils.nodeToString(newVfModuleNode) - + // Construct endpoint def vnfId = execution.getVariable('PUAAIVfMod_vnfId') def vfModuleId = execution.getVariable('PUAAIVfMod_vfModuleId') - + def payload = """{ "vf-module-id": "${vfModuleId}", "orchestration-status": "${orchestrationStatus}" }""" - + msoLogger.debug("VfModule payload : " + payload) - AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "/vf-modules/vf-module/" + UriUtils.encode(vfModuleId, "UTF-8") + AaiUtil aaiUtil = new AaiUtil(this) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + uri.depth(Depth.ONE) + String endPoint = aaiUtil.createAaiUri(uri) + msoLogger.debug("PrepareUpdateAAIVfModule: AAI endPoint : " + endPoint) String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution)) try { @@ -275,16 +264,16 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { msoLogger.debug('Response:' + System.lineSeparator() + responseData) msoLogger.debug("PrepareUpdateAAIVfModule: AAI Response : " + responseData) msoLogger.debug("PrepareUpdateAAIVfModule: AAI ResponseCode : " + response.getStatusCode()) - + // Set the output for this flow. The updated VfModule is an output, the generic VNF name, and for // backward compatibilty, the heat-stack-id is an output - execution.setVariable('PUAAIVfMod_outVfModule', newVfModule) + execution.setVariable('PUAAIVfMod_outVfModule', vfModule) def vnfName = execution.getVariable('PUAAIVfMod_vnfName') msoLogger.debug('Output PUAAIVfMod_vnfName set to ' + vnfName) // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead - execution.setVariable('WorkflowResponse', newVfModule) - msoLogger.debug('Output PUAAIVfMod_outVfModule set for VF Module Id \'' + newVfModule.getElementText('vf-module-id') + '\'') - def heatStackId = newVfModule.getElementText('heat-stack-id') + execution.setVariable('WorkflowResponse', vfModule) + + def heatStackId = vfModule.getHeatStackId() execution.setVariable('PUAAIVfMod_heatStackId', heatStackId) msoLogger.debug('Output PUAAIVfMod_heatStackId set to \'' + heatStackId + '\'') } catch (Exception ex) { @@ -299,12 +288,12 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { } catch (Exception e) { msoLogger.error(e) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in updateVfModule(): ' + e.getMessage()) - } + } } - + /** * Generates a WorkflowException if the AAI query returns a response code other than 200. - * + * * @param execution The flow's execution instance. */ public void handleVnfNotFound(DelegateExecution execution) { @@ -318,13 +307,13 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { WorkflowException exception = new WorkflowException(processKey, 5000, execution.getVariable('PUAAIVfMod_getVnfResponse')) execution.setVariable('WorkflowException', exception) - + msoLogger.trace('Exited ' + method) } - + /** * Generates a WorkflowException if the VF Module does not pass validation. - * + * * @param execution The flow's execution instance. */ public void handleVfModuleValidationError(DelegateExecution execution) { @@ -332,21 +321,21 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { 'execution=' + execution.getId() + ')' msoLogger.trace('Entered ' + method) - + def String errorMsg = 'VF Module validation error: ' + execution.getVariable('PUAAIVfMod_vfModuleValidationError') msoLogger.error(errorMsg); msoLogger.debug("PrepareUpdateAAIVfModule: Error Message : " + errorMsg) - + String processKey = getProcessKey(execution); WorkflowException exception = new WorkflowException(processKey, 5000, errorMsg) execution.setVariable('WorkflowException', exception) msoLogger.trace('Exited ' + method) } - + /** * Generates a WorkflowException if updating a VF Module in AAI returns a response code other than 200. - * + * * @param execution The flow's execution instance. */ public void handleUpdateVfModuleFailure(DelegateExecution execution) { @@ -360,7 +349,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { WorkflowException exception = new WorkflowException(processKey, 5000, execution.getVariable('PUAAIVfMod_updateVfModuleResponse')) execution.setVariable('WorkflowException', exception) - + msoLogger.trace('Exited ' + method) } } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy index 7d7b9e103f..3e7c4f2d49 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy @@ -24,6 +24,10 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.UrnPropertiesReader +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.client.graphinventory.entities.uri.Depth import org.onap.so.rest.APIResponse import org.springframework.web.util.UriUtils import org.onap.so.logger.MessageEnum @@ -129,10 +133,10 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { // Construct endpoint AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + aai_uri + '/' + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" - + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + uri.depth(Depth.ONE) + String endPoint = aaiUriUtil.createAaiUri(uri) + try { msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'') msoLogger.debug("Sending GET to AAI endpoint: " + endPoint) @@ -246,9 +250,8 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { // Construct endpoint AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + aai_uri + '/' + UriUtils.encode(vnfId, "UTF-8") + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + String endPoint = aaiUriUtil.createAaiUri(uri) try { msoLogger.debug('sending PATCH to AAI endpoint \'' + endPoint + '\'' + 'with payload \n' + payload) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy index 68b2df213a..c455ae90ce 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy @@ -24,6 +24,9 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.UrnPropertiesReader +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.rest.APIResponse import org.springframework.web.util.UriUtils import org.onap.so.logger.MessageEnum @@ -104,12 +107,10 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { def vnfId = execution.getVariable('UAAIVfMod_vnfId') def vfModuleId = execution.getVariable('UAAIVfMod_vfModuleId') - // Construct endpoint AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + aai_uri + '/' + UriUtils.encode(vnfId, "UTF-8") + '/vf-modules/vf-module/' + UriUtils.encode(vfModuleId, "UTF-8") - + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + String endPoint = aaiUriUtil.createAaiUri(uri) + try { msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'') msoLogger.debug("UpdateAAIVfModule sending GET to AAI endpoint: " + endPoint) @@ -202,12 +203,9 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { } """ - - // Construct endpoint AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + aai_uri + '/' + UriUtils.encode(vnfId, "UTF-8") + '/vf-modules/vf-module/' + UriUtils.encode(vfModuleId, "UTF-8") + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + String endPoint = aaiUriUtil.createAaiUri(uri) try { msoLogger.debug('sending PATCH to AAI endpoint \'' + endPoint + '\'' + 'with payload \n' + payload) diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java index 47e36424dd..45bc27d840 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java @@ -85,9 +85,9 @@ public class PayloadClient { public static Optional<String> healthCheckFormat(String vnfName, String vnfHostIpAddress) throws JsonProcessingException{ HealthCheckAction payloadResult = new HealthCheckAction(); RequestParametersHealthCheck requestParams = new RequestParametersHealthCheck(); - requestParams.setVnfHostIpAddress(vnfHostIpAddress); + requestParams.setHostIpAddress(vnfHostIpAddress); payloadResult.setRequestParameters(requestParams); - return Optional.of((mapper.writeValueAsString(payloadResult)).replaceAll("\"", "\\\\\"")); + return Optional.of((mapper.writeValueAsString(payloadResult))); } public static Optional<String> snapshotFormat(String vmId, String identityUrl)throws JsonProcessingException{ diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/RequestParametersHealthCheck.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/RequestParametersHealthCheck.java index 053ac5e741..60030ee3dd 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/RequestParametersHealthCheck.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/RequestParametersHealthCheck.java @@ -32,8 +32,8 @@ public class RequestParametersHealthCheck { @JsonProperty("vnf-name") private String vnfName; -@JsonProperty("vnf-host-ip-address") -private String vnfHostIpAddress; +@JsonProperty("host-ip-address") +private String hostIpAddress; @JsonProperty("vnf-name") public String getVnfName() { @@ -45,14 +45,14 @@ public void setVnfName(String vnfName) { this.vnfName = vnfName; } -@JsonProperty("vnf-host-ip-address") -public void setVnfHostIpAddress(String vnfHostIpAddress) { - this.vnfHostIpAddress = vnfHostIpAddress; +@JsonProperty("host-ip-address") +public void setHostIpAddress(String hostIpAddress) { + this.hostIpAddress = hostIpAddress; } -@JsonProperty("vnf-host-ip-address") -public String getVnfHostIpAddress() { - return vnfHostIpAddress; +@JsonProperty("host-ip-address") +public String getHostIpAddress() { + return hostIpAddress; } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java index 01846681db..91cd2ad791 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java @@ -7,9 +7,9 @@ * 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. @@ -35,6 +35,8 @@ public class Candidate implements Serializable { private CandidateType candidateType; @JsonProperty("candidates") private List<String> candidates; + @JsonProperty("cloudOwner") + private String cloudOwner; /** * list of candidates @@ -68,4 +70,20 @@ public class Candidate implements Serializable { this.candidateType = candidateType; } + /** + * The name of the cloud owner. Required if candidateType is cloudRegionId + */ + public String getCloudOwner(){ + return cloudOwner; + } + + /** + * The name of the cloud owner. Required if candidateType is cloudRegionId + */ + public void setCloudOwner(String cloudOwner){ + this.cloudOwner = cloudOwner; + } + + + } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/CandidateType.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/CandidateType.java index 9540b9148e..40c76a3c92 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/CandidateType.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/CandidateType.java @@ -7,9 +7,9 @@ * 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. @@ -37,7 +37,6 @@ public enum CandidateType { return name; } - //TODO added to get PojoTest to work public String getName(){ return name; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index eb4f4ca0d5..769d3e4e89 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -101,7 +101,6 @@ public class BBInputSetup implements JavaDelegate { private static final String LOOKUP_KEY_MAP_VAR_NAME = "lookupKeyMap"; private static final String GBB_INPUT_VAR_NAME = "gBBInput"; private static final String EXECUTE_BB_VAR_NAME = "buildingBlock"; - private static final String CLOUD_OWNER = "att-aic"; private static final String VOLUME_GROUP = "VolumeGroup"; private static final String VF_MODULE = "VfModule"; private static final String NETWORK = "Network"; @@ -384,7 +383,7 @@ public class BBInputSetup implements JavaDelegate { if (lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID) == null) { for(VolumeGroup volumeGroup : tempVnf.getVolumeGroups()) { String volumeGroupCustId = - this.bbInputSetupUtils.getAAIVolumeGroup(CLOUD_OWNER, + this.bbInputSetupUtils.getAAIVolumeGroup(cloudConfiguration.getCloudOwner(), cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()).getModelCustomizationId(); if(modelInfo.getModelCustomizationId().equalsIgnoreCase(volumeGroupCustId)) { lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId()); @@ -801,9 +800,8 @@ public class BBInputSetup implements JavaDelegate { requestContext.setAction(requestAction); requestContext.setMsoRequestId(executeBB.getRequestId()); org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils - .getCloudRegion(requestDetails.getCloudConfiguration(), CLOUD_OWNER); - CloudRegion cloudRegion = mapperLayer.mapCloudRegion(requestDetails.getCloudConfiguration(), aaiCloudRegion, - CLOUD_OWNER); + .getCloudRegion(requestDetails.getCloudConfiguration()); + CloudRegion cloudRegion = mapperLayer.mapCloudRegion(requestDetails.getCloudConfiguration(), aaiCloudRegion); outputBB.setOrchContext(orchContext); outputBB.setRequestContext(requestContext); outputBB.setCloudRegion(cloudRegion); @@ -981,9 +979,8 @@ public class BBInputSetup implements JavaDelegate { String requestAction, CloudConfiguration cloudConfiguration) throws Exception { ServiceInstance serviceInstance = gBB.getServiceInstance(); if (cloudConfiguration != null && requestAction.equalsIgnoreCase("deleteInstance")) { - org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration, - CLOUD_OWNER); - CloudRegion cloudRegion = mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion, CLOUD_OWNER); + org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration); + CloudRegion cloudRegion = mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion); gBB.setCloudRegion(cloudRegion); } if (bbName.contains(VNF)) { @@ -1030,7 +1027,7 @@ public class BBInputSetup implements JavaDelegate { this.mapCatalogVnf(vnf, vnfModelInfo, service); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnf.getVnfId()); if (cloudConfiguration != null) { - String volumeGroupCustomizationUUID = this.bbInputSetupUtils.getAAIVolumeGroup(CLOUD_OWNER, + String volumeGroupCustomizationUUID = this.bbInputSetupUtils.getAAIVolumeGroup(cloudConfiguration.getCloudOwner(), cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()) .getModelCustomizationId(); ModelInfo volumeGroupModelInfo = new ModelInfo(); @@ -1116,6 +1113,7 @@ public class BBInputSetup implements JavaDelegate { String vfModuleId = lookupKeyMap.get(ResourceKey.VF_MODULE_ID); CloudConfiguration cloudConfig = new CloudConfiguration(); cloudConfig.setLcpCloudRegionId(cloudRegion.getLcpCloudRegionId()); + cloudConfig.setCloudOwner(cloudRegion.getCloudOwner()); this.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, vfModuleId, null, vfModules.getInstanceName(), vfModules.getInstanceParams(), cloudConfig); } @@ -1193,9 +1191,8 @@ public class BBInputSetup implements JavaDelegate { } } if(cloudConfiguration != null) { - org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration, - CLOUD_OWNER); - return mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion, CLOUD_OWNER); + org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration); + return mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion); } else { msoLogger.debug("Could not find any cloud configuration for this request."); return null; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index 0c7eb0973f..d463fde09c 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -347,18 +347,16 @@ public class BBInputSetupMapperLayer { protected OrchestrationContext mapOrchestrationContext(RequestDetails requestDetails) { OrchestrationContext context = new OrchestrationContext(); - context.setIsRollbackEnabled((requestDetails.getRequestInfo().getSuppressRollback())); + context.setIsRollbackEnabled(!(requestDetails.getRequestInfo().getSuppressRollback())); return context; } - protected CloudRegion mapCloudRegion(CloudConfiguration cloudConfiguration, org.onap.aai.domain.yang.CloudRegion aaiCloudRegion, String cloudOwner) { + protected CloudRegion mapCloudRegion(CloudConfiguration cloudConfiguration, org.onap.aai.domain.yang.CloudRegion aaiCloudRegion) { CloudRegion cloudRegion = new CloudRegion(); if(cloudConfiguration != null) cloudRegion = modelMapper.map(cloudConfiguration, CloudRegion.class); if(aaiCloudRegion != null) modelMapper.map(aaiCloudRegion, cloudRegion); - if(cloudOwner != null) - cloudRegion.setCloudOwner(cloudOwner); return cloudRegion; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java index 84ecfc7576..4617fc4710 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java @@ -163,13 +163,14 @@ public class BBInputSetupUtils { } } - protected CloudRegion getCloudRegion(CloudConfiguration cloudConfiguration, String cloudOwner) { + protected CloudRegion getCloudRegion(CloudConfiguration cloudConfiguration) { if (cloudConfiguration != null) { String cloudRegionId = cloudConfiguration.getLcpCloudRegionId(); - if (cloudRegionId != null && !cloudRegionId.isEmpty()) { + String cloudOwner = cloudConfiguration.getCloudOwner(); + if (cloudRegionId != null && cloudOwner != null && !cloudRegionId.isEmpty() && !cloudOwner.isEmpty()) { return injectionHelper.getAaiClient().get(CloudRegion.class, AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudOwner, - cloudConfiguration.getLcpCloudRegionId())).orElse(null); + cloudRegionId)).orElse(null); } else { return null; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClient.java index f87ec91440..89eff5f65a 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClient.java @@ -182,7 +182,7 @@ public class ApplicationControllerClient { commonHeader.setApiVer(API_VER); commonHeader.setOriginatorId(ORIGINATOR_ID); commonHeader.setRequestId(requestId == null ? UUID.randomUUID().toString() : requestId); - commonHeader.setSubRequestId(requestId); + commonHeader.setSubRequestId(UUID.randomUUID().toString()); Flags flags = new Flags(); String flagsMode = "NORMAL"; Mode mode = Mode.valueOf(flagsMode); diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CustomE2EPutService.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CustomE2EPutService.bpmn deleted file mode 100644 index f519bc9dbe..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CustomE2EPutService.bpmn +++ /dev/null @@ -1,201 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_FatVcHn0EeaH6vX1RRdc_w" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> - <bpmn2:process id="CustomE2EPutService" name="CustomE2EPutService" isExecutable="true"> - <bpmn2:startEvent id="StartEvent_1"> - <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> - </bpmn2:startEvent> - <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="Initialization" /> - <bpmn2:endEvent id="EndEvent_1"> - <bpmn2:incoming>SequenceFlow_5</bpmn2:incoming> - <bpmn2:terminateEventDefinition id="TerminateEventDefinition_1" /> - </bpmn2:endEvent> - <bpmn2:scriptTask id="toggleSuccess" name="Toggle Success Indicator" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* - -def serviceInstance= new CustomE2EPutService() -serviceInstance.setSuccessIndicator(execution, true) - -execution.setVariable("WorkflowResponse", " ") //for junits]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_5" name="" sourceRef="toggleSuccess" targetRef="EndEvent_1" /> - <bpmn2:scriptTask id="putServiceInstance" name="Put Service Instance" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_3</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* - -def serviceInstance= new CustomE2EPutService() -serviceInstance.putServiceInstance(execution)]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_4" name="" sourceRef="putServiceInstance" targetRef="toggleSuccess" /> - <bpmn2:scriptTask id="Initialization" name="Initialization" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* - -def serviceInstance= new CustomE2EPutService() -serviceInstance.preProcessRequest(execution) -]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_3" name="" sourceRef="Initialization" targetRef="putServiceInstance" /> - <bpmn2:subProcess id="bpmnExceptionHandlingSubProcess" name="Error Handling Sub Process" triggeredByEvent="true"> - <bpmn2:startEvent id="StartEvent_2"> - <bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing> - <bpmn2:errorEventDefinition id="ErrorEventDefinition_1" /> - </bpmn2:startEvent> - <bpmn2:sequenceFlow id="SequenceFlow_6" name="" sourceRef="StartEvent_2" targetRef="processError" /> - <bpmn2:endEvent id="EndEvent_2"> - <bpmn2:incoming>SequenceFlow_7</bpmn2:incoming> - </bpmn2:endEvent> - <bpmn2:scriptTask id="processError" name="Process Error" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_6</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* - -ExceptionUtil ex = new ExceptionUtil() -ex.processSubflowsBPMNException(execution)]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_7" name="" sourceRef="processError" targetRef="EndEvent_2" /> - </bpmn2:subProcess> - <bpmn2:subProcess id="javaExceptionSubProcess" name="Java Exception Handling Sub Process" triggeredByEvent="true"> - <bpmn2:startEvent id="catchJavaExcep"> - <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing> - <bpmn2:errorEventDefinition id="ErrorEventDefinition_2" errorRef="Error_2" /> - </bpmn2:startEvent> - <bpmn2:sequenceFlow id="SequenceFlow_9" name="" sourceRef="catchJavaExcep" targetRef="processJavaError" /> - <bpmn2:scriptTask id="processJavaError" name="Process Java Error" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_9</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_10</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* - -ExceptionUtil ex = new ExceptionUtil() -ex.processJavaException(execution)]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:endEvent id="EndEvent_3"> - <bpmn2:incoming>SequenceFlow_10</bpmn2:incoming> - <bpmn2:terminateEventDefinition id="TerminateEventDefinition_2" /> - </bpmn2:endEvent> - <bpmn2:sequenceFlow id="SequenceFlow_10" name="" sourceRef="processJavaError" targetRef="EndEvent_3" /> - </bpmn2:subProcess> - </bpmn2:process> - <bpmn2:error id="Error_1" name="MSO Workflow Exception" errorCode="MSOWorkflowException" /> - <bpmn2:error id="Error_2" name="Java Lang Exception" errorCode="java.lang.Exception" /> - <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CustomE2EPutService"> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_71" bpmnElement="StartEvent_1"> - <dc:Bounds x="182" y="180" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="200" y="221" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_302" bpmnElement="Initialization"> - <dc:Bounds x="324" y="158" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_71" targetElement="_BPMNShape_ScriptTask_302"> - <di:waypoint xsi:type="dc:Point" x="218" y="198" /> - <di:waypoint xsi:type="dc:Point" x="324" y="198" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="250" y="198" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_304" bpmnElement="putServiceInstance"> - <dc:Bounds x="528" y="158" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_3" sourceElement="_BPMNShape_ScriptTask_302" targetElement="_BPMNShape_ScriptTask_304"> - <di:waypoint xsi:type="dc:Point" x="424" y="198" /> - <di:waypoint xsi:type="dc:Point" x="528" y="198" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="446" y="198" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_305" bpmnElement="toggleSuccess"> - <dc:Bounds x="732" y="158" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_ScriptTask_304" targetElement="_BPMNShape_ScriptTask_305"> - <di:waypoint xsi:type="dc:Point" x="628" y="198" /> - <di:waypoint xsi:type="dc:Point" x="732" y="198" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="650" y="198" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_EndEvent_230" bpmnElement="EndEvent_1"> - <dc:Bounds x="908" y="180" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="926" y="221" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="SequenceFlow_5" sourceElement="_BPMNShape_ScriptTask_305" targetElement="_BPMNShape_EndEvent_230"> - <di:waypoint xsi:type="dc:Point" x="832" y="198" /> - <di:waypoint xsi:type="dc:Point" x="908" y="198" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="854" y="198" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_SubProcess_27" bpmnElement="bpmnExceptionHandlingSubProcess" isExpanded="true"> - <dc:Bounds x="324" y="312" width="418" height="150" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_72" bpmnElement="StartEvent_2"> - <dc:Bounds x="357" y="370" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="375" y="411" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_306" bpmnElement="processError"> - <dc:Bounds x="466" y="348" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_6" sourceElement="_BPMNShape_StartEvent_72" targetElement="_BPMNShape_ScriptTask_306"> - <di:waypoint xsi:type="dc:Point" x="393" y="388" /> - <di:waypoint xsi:type="dc:Point" x="466" y="388" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="415" y="388" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_EndEvent_231" bpmnElement="EndEvent_2"> - <dc:Bounds x="615" y="370" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="633" y="411" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_7" bpmnElement="SequenceFlow_7" sourceElement="_BPMNShape_ScriptTask_306" targetElement="_BPMNShape_EndEvent_231"> - <di:waypoint xsi:type="dc:Point" x="566" y="388" /> - <di:waypoint xsi:type="dc:Point" x="615" y="388" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="588" y="388" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_SubProcess_28" bpmnElement="javaExceptionSubProcess" isExpanded="true"> - <dc:Bounds x="323" y="486" width="419" height="150" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_73" bpmnElement="catchJavaExcep"> - <dc:Bounds x="357" y="538" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="375" y="579" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_308" bpmnElement="processJavaError"> - <dc:Bounds x="465" y="516" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_9" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_StartEvent_73" targetElement="_BPMNShape_ScriptTask_308"> - <di:waypoint xsi:type="dc:Point" x="393" y="556" /> - <di:waypoint xsi:type="dc:Point" x="465" y="556" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="415" y="556" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_EndEvent_232" bpmnElement="EndEvent_3"> - <dc:Bounds x="615" y="538" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="633" y="579" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_10" bpmnElement="SequenceFlow_10" sourceElement="_BPMNShape_ScriptTask_308" targetElement="_BPMNShape_EndEvent_232"> - <di:waypoint xsi:type="dc:Point" x="565" y="556" /> - <di:waypoint xsi:type="dc:Point" x="615" y="556" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="587" y="556" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - </bpmndi:BPMNPlane> - </bpmndi:BPMNDiagram> -</bpmn2:definitions> diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetVnf.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetVnf.bpmn deleted file mode 100644 index 5784c10d3e..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericGetVnf.bpmn +++ /dev/null @@ -1,212 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_eb5eEHR6EeaJwpcpVN5gXw" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn"> - <bpmn2:process id="GenericGetVnf" name="GenericGetVnf" isExecutable="true"> - <bpmn2:startEvent id="StartEvent_1"> - <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> - </bpmn2:startEvent> - <bpmn2:scriptTask id="intialization" name="Intialization" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* -GenericGetVnf genericGetVnf = new GenericGetVnf () -genericGetVnf.preProcessRequest(execution) -]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="intialization"/> - <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="intialization" targetRef="vnfIdProvided"/> - <bpmn2:exclusiveGateway id="vnfIdProvided" name="Vnf Id Provided?" default="noVnfId"> - <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> - <bpmn2:outgoing>noVnfId</bpmn2:outgoing> - <bpmn2:outgoing>haveVnfId</bpmn2:outgoing> - </bpmn2:exclusiveGateway> - <bpmn2:sequenceFlow id="noVnfId" name="No" sourceRef="vnfIdProvided" targetRef="getVnfByName"/> - <bpmn2:sequenceFlow id="haveVnfId" name="Yes" sourceRef="vnfIdProvided" targetRef="getGenericVnf"> - <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("GENGV_getVnfByName") == false}]]></bpmn2:conditionExpression> - </bpmn2:sequenceFlow> - <bpmn2:scriptTask id="getVnfByName" name="GET Vnf By Name" scriptFormat="groovy"> - <bpmn2:incoming>noVnfId</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* -GenericGetVnf genericGetVnf = new GenericGetVnf() -genericGetVnf.getVnfByName(execution)]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_9" name="" sourceRef="getVnfByName" targetRef="ExclusiveGateway_2"/> - <bpmn2:exclusiveGateway id="ExclusiveGateway_2"> - <bpmn2:incoming>SequenceFlow_9</bpmn2:incoming> - <bpmn2:incoming>SequenceFlow_10</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing> - </bpmn2:exclusiveGateway> - <bpmn2:sequenceFlow id="SequenceFlow_7" name="" sourceRef="ExclusiveGateway_2" targetRef="toggleSuccess"/> - <bpmn2:scriptTask id="getGenericVnf" name="GET Vnf By
Id" scriptFormat="groovy"> - <bpmn2:incoming>haveVnfId</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_10</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* -GenericGetVnf genericGetVnf = new GenericGetVnf() -genericGetVnf.getVnfById(execution)]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_10" name="" sourceRef="getGenericVnf" targetRef="ExclusiveGateway_2"/> - <bpmn2:subProcess id="bpmnExceptionHandlingSubProcess" name="Error Handling Sub Process" triggeredByEvent="true"> - <bpmn2:endEvent id="EndEvent_3"> - <bpmn2:incoming>SequenceFlow_12</bpmn2:incoming> - <bpmn2:terminateEventDefinition id="_TerminateEventDefinition_31"/> - </bpmn2:endEvent> - <bpmn2:scriptTask id="proccessBPMNError" name="Process Error" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_11</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_12</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* - -ExceptionUtil ex = new ExceptionUtil() -ex.processSubflowsBPMNException(execution)]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_12" name="" sourceRef="proccessBPMNError" targetRef="EndEvent_3"/> - <bpmn2:startEvent id="catchMSOWorkflowException"> - <bpmn2:outgoing>SequenceFlow_11</bpmn2:outgoing> - <bpmn2:errorEventDefinition id="ErrorEventDefinition_1"/> - </bpmn2:startEvent> - <bpmn2:sequenceFlow id="SequenceFlow_11" name="" sourceRef="catchMSOWorkflowException" targetRef="proccessBPMNError"/> - </bpmn2:subProcess> - <bpmn2:scriptTask id="toggleSuccess" name="Toggle Success Indicator" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_7</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_8</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* -GenericGetVnf genericGetVnf = new GenericGetVnf() -genericGetVnf.setSuccessIndicator(execution, true) -]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_8" name="" sourceRef="toggleSuccess" targetRef="EndEvent_1"/> - <bpmn2:endEvent id="EndEvent_1"> - <bpmn2:incoming>SequenceFlow_8</bpmn2:incoming> - <bpmn2:terminateEventDefinition id="_TerminateEventDefinition_28"/> - </bpmn2:endEvent> - </bpmn2:process> - <bpmn2:error id="Error_1" errorCode="MSOWorkflowException" name="MSO Workflow Exception"/> - <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="GenericGetVnf"> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_71" bpmnElement="StartEvent_1"> - <dc:Bounds height="36.0" width="36.0" x="110.0" y="271.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="128.0" y="312.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_295" bpmnElement="intialization"> - <dc:Bounds height="80.0" width="100.0" x="228.0" y="249.0"/> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_230" bpmnElement="vnfIdProvided" isMarkerVisible="true"> - <dc:Bounds height="50.0" width="50.0" x="372.0" y="263.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="22.0" width="99.0" x="419.0" y="292.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_71" targetElement="_BPMNShape_ScriptTask_295"> - <di:waypoint xsi:type="dc:Point" x="146.0" y="289.0"/> - <di:waypoint xsi:type="dc:Point" x="228.0" y="289.0"/> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ScriptTask_295" targetElement="_BPMNShape_ExclusiveGateway_230"> - <di:waypoint xsi:type="dc:Point" x="328.0" y="289.0"/> - <di:waypoint xsi:type="dc:Point" x="372.0" y="288.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="347.0" y="288.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_296" bpmnElement="getVnfByName"> - <dc:Bounds height="80.0" width="100.0" x="456.0" y="156.0"/> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_231" bpmnElement="ExclusiveGateway_2" isMarkerVisible="true"> - <dc:Bounds height="50.0" width="50.0" x="600.0" y="263.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="625.0" y="318.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="noVnfId" sourceElement="_BPMNShape_ExclusiveGateway_230" targetElement="_BPMNShape_ScriptTask_296"> - <di:waypoint xsi:type="dc:Point" x="397.0" y="263.0"/> - <di:waypoint xsi:type="dc:Point" x="397.0" y="196.0"/> - <di:waypoint xsi:type="dc:Point" x="456.0" y="196.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="22.0" width="22.0" x="399.0" y="219.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="haveVnfId" sourceElement="_BPMNShape_ExclusiveGateway_230" targetElement="_BPMNShape_ScriptTask_297"> - <di:waypoint xsi:type="dc:Point" x="397.0" y="313.0"/> - <di:waypoint xsi:type="dc:Point" x="397.0" y="368.0"/> - <di:waypoint xsi:type="dc:Point" x="456.0" y="368.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="22.0" width="29.0" x="396.0" y="328.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_297" bpmnElement="getGenericVnf"> - <dc:Bounds height="80.0" width="100.0" x="456.0" y="328.0"/> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_298" bpmnElement="toggleSuccess"> - <dc:Bounds height="80.0" width="100.0" x="696.0" y="249.0"/> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_EndEvent_226" bpmnElement="EndEvent_1"> - <dc:Bounds height="36.0" width="36.0" x="888.0" y="271.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="906.0" y="312.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_7" bpmnElement="SequenceFlow_7" sourceElement="_BPMNShape_ExclusiveGateway_231" targetElement="_BPMNShape_ScriptTask_298"> - <di:waypoint xsi:type="dc:Point" x="650.0" y="288.0"/> - <di:waypoint xsi:type="dc:Point" x="696.0" y="289.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="673.0" y="289.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_8" bpmnElement="SequenceFlow_8" sourceElement="_BPMNShape_ScriptTask_298" targetElement="_BPMNShape_EndEvent_226"> - <di:waypoint xsi:type="dc:Point" x="796.0" y="289.0"/> - <di:waypoint xsi:type="dc:Point" x="888.0" y="289.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="829.0" y="289.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_11" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_ScriptTask_296" targetElement="_BPMNShape_ExclusiveGateway_231"> - <di:waypoint xsi:type="dc:Point" x="556.0" y="196.0"/> - <di:waypoint xsi:type="dc:Point" x="625.0" y="196.0"/> - <di:waypoint xsi:type="dc:Point" x="625.0" y="263.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="622.0" y="205.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_12" bpmnElement="SequenceFlow_10" sourceElement="_BPMNShape_ScriptTask_297" targetElement="_BPMNShape_ExclusiveGateway_231"> - <di:waypoint xsi:type="dc:Point" x="556.0" y="368.0"/> - <di:waypoint xsi:type="dc:Point" x="625.0" y="368.0"/> - <di:waypoint xsi:type="dc:Point" x="625.0" y="313.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="621.0" y="368.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_SubProcess_30" bpmnElement="bpmnExceptionHandlingSubProcess" isExpanded="true"> - <dc:Bounds height="169.0" width="313.0" x="168.0" y="468.0"/> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_74" bpmnElement="catchMSOWorkflowException"> - <dc:Bounds height="36.0" width="36.0" x="180.0" y="535.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="198.0" y="576.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_302" bpmnElement="proccessBPMNError"> - <dc:Bounds height="80.0" width="100.0" x="275.0" y="513.0"/> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_EndEvent_231" bpmnElement="EndEvent_3"> - <dc:Bounds height="36.0" width="36.0" x="432.0" y="535.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="450.0" y="576.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_13" bpmnElement="SequenceFlow_11" sourceElement="_BPMNShape_StartEvent_74" targetElement="_BPMNShape_ScriptTask_302"> - <di:waypoint xsi:type="dc:Point" x="216.0" y="553.0"/> - <di:waypoint xsi:type="dc:Point" x="275.0" y="553.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="238.0" y="553.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_14" bpmnElement="SequenceFlow_12" sourceElement="_BPMNShape_ScriptTask_302" targetElement="_BPMNShape_EndEvent_231"> - <di:waypoint xsi:type="dc:Point" x="375.0" y="553.0"/> - <di:waypoint xsi:type="dc:Point" x="432.0" y="553.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="402.0" y="553.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - </bpmndi:BPMNPlane> - </bpmndi:BPMNDiagram> -</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericPutService.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericPutService.bpmn deleted file mode 100644 index 2d18f38c16..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/GenericPutService.bpmn +++ /dev/null @@ -1,201 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_FatVcHn0EeaH6vX1RRdc_w" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> - <bpmn2:process id="GenericPutService" name="GenericPutService" isExecutable="true"> - <bpmn2:startEvent id="StartEvent_1"> - <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> - </bpmn2:startEvent> - <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="Initialization" /> - <bpmn2:endEvent id="EndEvent_1"> - <bpmn2:incoming>SequenceFlow_5</bpmn2:incoming> - <bpmn2:terminateEventDefinition id="TerminateEventDefinition_1" /> - </bpmn2:endEvent> - <bpmn2:scriptTask id="toggleSuccess" name="Toggle Success Indicator" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* - -def serviceInstance= new GenericPutService() -serviceInstance.setSuccessIndicator(execution, true) - -execution.setVariable("WorkflowResponse", " ") //for junits]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_5" name="" sourceRef="toggleSuccess" targetRef="EndEvent_1" /> - <bpmn2:scriptTask id="putServiceInstance" name="Put Service Instance" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_3</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* - -def serviceInstance= new GenericPutService() -serviceInstance.putServiceInstance(execution)]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_4" name="" sourceRef="putServiceInstance" targetRef="toggleSuccess" /> - <bpmn2:scriptTask id="Initialization" name="Initialization" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* - -def serviceInstance= new GenericPutService() -serviceInstance.preProcessRequest(execution) -]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_3" name="" sourceRef="Initialization" targetRef="putServiceInstance" /> - <bpmn2:subProcess id="bpmnExceptionHandlingSubProcess" name="Error Handling Sub Process" triggeredByEvent="true"> - <bpmn2:startEvent id="StartEvent_2"> - <bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing> - <bpmn2:errorEventDefinition id="ErrorEventDefinition_1" /> - </bpmn2:startEvent> - <bpmn2:sequenceFlow id="SequenceFlow_6" name="" sourceRef="StartEvent_2" targetRef="processError" /> - <bpmn2:endEvent id="EndEvent_2"> - <bpmn2:incoming>SequenceFlow_7</bpmn2:incoming> - </bpmn2:endEvent> - <bpmn2:scriptTask id="processError" name="Process Error" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_6</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* - -ExceptionUtil ex = new ExceptionUtil() -ex.processSubflowsBPMNException(execution)]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_7" name="" sourceRef="processError" targetRef="EndEvent_2" /> - </bpmn2:subProcess> - <bpmn2:subProcess id="javaExceptionSubProcess" name="Java Exception Handling Sub Process" triggeredByEvent="true"> - <bpmn2:startEvent id="catchJavaExcep"> - <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing> - <bpmn2:errorEventDefinition id="ErrorEventDefinition_2" errorRef="Error_2" /> - </bpmn2:startEvent> - <bpmn2:sequenceFlow id="SequenceFlow_9" name="" sourceRef="catchJavaExcep" targetRef="processJavaError" /> - <bpmn2:scriptTask id="processJavaError" name="Process Java Error" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_9</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_10</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* - -ExceptionUtil ex = new ExceptionUtil() -ex.processJavaException(execution)]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:endEvent id="EndEvent_3"> - <bpmn2:incoming>SequenceFlow_10</bpmn2:incoming> - <bpmn2:terminateEventDefinition id="TerminateEventDefinition_2" /> - </bpmn2:endEvent> - <bpmn2:sequenceFlow id="SequenceFlow_10" name="" sourceRef="processJavaError" targetRef="EndEvent_3" /> - </bpmn2:subProcess> - </bpmn2:process> - <bpmn2:error id="Error_1" name="MSO Workflow Exception" errorCode="MSOWorkflowException" /> - <bpmn2:error id="Error_2" name="Java Lang Exception" errorCode="java.lang.Exception" /> - <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="GenericPutService"> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_71" bpmnElement="StartEvent_1"> - <dc:Bounds x="182" y="180" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="200" y="221" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_302" bpmnElement="Initialization"> - <dc:Bounds x="324" y="158" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_71" targetElement="_BPMNShape_ScriptTask_302"> - <di:waypoint xsi:type="dc:Point" x="218" y="198" /> - <di:waypoint xsi:type="dc:Point" x="324" y="198" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="250" y="198" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_304" bpmnElement="putServiceInstance"> - <dc:Bounds x="528" y="158" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_3" sourceElement="_BPMNShape_ScriptTask_302" targetElement="_BPMNShape_ScriptTask_304"> - <di:waypoint xsi:type="dc:Point" x="424" y="198" /> - <di:waypoint xsi:type="dc:Point" x="528" y="198" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="446" y="198" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_305" bpmnElement="toggleSuccess"> - <dc:Bounds x="732" y="158" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_ScriptTask_304" targetElement="_BPMNShape_ScriptTask_305"> - <di:waypoint xsi:type="dc:Point" x="628" y="198" /> - <di:waypoint xsi:type="dc:Point" x="732" y="198" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="650" y="198" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_EndEvent_230" bpmnElement="EndEvent_1"> - <dc:Bounds x="908" y="180" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="926" y="221" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="SequenceFlow_5" sourceElement="_BPMNShape_ScriptTask_305" targetElement="_BPMNShape_EndEvent_230"> - <di:waypoint xsi:type="dc:Point" x="832" y="198" /> - <di:waypoint xsi:type="dc:Point" x="908" y="198" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="854" y="198" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_SubProcess_27" bpmnElement="bpmnExceptionHandlingSubProcess" isExpanded="true"> - <dc:Bounds x="324" y="312" width="418" height="150" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_72" bpmnElement="StartEvent_2"> - <dc:Bounds x="357" y="370" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="375" y="411" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_306" bpmnElement="processError"> - <dc:Bounds x="466" y="348" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_6" sourceElement="_BPMNShape_StartEvent_72" targetElement="_BPMNShape_ScriptTask_306"> - <di:waypoint xsi:type="dc:Point" x="393" y="388" /> - <di:waypoint xsi:type="dc:Point" x="466" y="388" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="415" y="388" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_EndEvent_231" bpmnElement="EndEvent_2"> - <dc:Bounds x="615" y="370" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="633" y="411" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_7" bpmnElement="SequenceFlow_7" sourceElement="_BPMNShape_ScriptTask_306" targetElement="_BPMNShape_EndEvent_231"> - <di:waypoint xsi:type="dc:Point" x="566" y="388" /> - <di:waypoint xsi:type="dc:Point" x="615" y="388" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="588" y="388" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_SubProcess_28" bpmnElement="javaExceptionSubProcess" isExpanded="true"> - <dc:Bounds x="323" y="486" width="419" height="150" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_73" bpmnElement="catchJavaExcep"> - <dc:Bounds x="357" y="538" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="375" y="579" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_308" bpmnElement="processJavaError"> - <dc:Bounds x="465" y="516" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_9" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_StartEvent_73" targetElement="_BPMNShape_ScriptTask_308"> - <di:waypoint xsi:type="dc:Point" x="393" y="556" /> - <di:waypoint xsi:type="dc:Point" x="465" y="556" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="415" y="556" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_EndEvent_232" bpmnElement="EndEvent_3"> - <dc:Bounds x="615" y="538" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="633" y="579" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_10" bpmnElement="SequenceFlow_10" sourceElement="_BPMNShape_ScriptTask_308" targetElement="_BPMNShape_EndEvent_232"> - <di:waypoint xsi:type="dc:Point" x="565" y="556" /> - <di:waypoint xsi:type="dc:Point" x="615" y="556" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="587" y="556" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - </bpmndi:BPMNPlane> - </bpmndi:BPMNDiagram> -</bpmn2:definitions> diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy index 79caf5b9ac..05b1c5e6ed 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -47,11 +47,11 @@ import org.camunda.bpm.engine.repository.ProcessDefinition @RunWith(MockitoJUnitRunner.class) @Ignore class AaiUtilTest extends MsoGroovyTest { - + @Rule public WireMockRule wireMockRule = new WireMockRule(8090); - + @Rule public ExpectedException thrown = ExpectedException.none @@ -128,275 +128,6 @@ class AaiUtilTest extends MsoGroovyTest { } @Test - public void testGetUriDefaultVersion() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.l3-network.uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getUri(mockExecution, 'l3-network') - assertEquals('/aai/v8/network/l3-networks/l3-network', uri) - } - - @Test - public void testGetUriFlowAndResourceSpecific() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.CreateAAIVfModule.aai.l3-network.uri")).thenReturn('/aai/v6/network/l3-networks/l3-network') - - when(mockExecution.getVariable("mso.workflow.default.aai.v8.l3-network.uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getUri(mockExecution, 'l3-network') - assertEquals('/aai/v6/network/l3-networks/l3-network', uri) - } - - @Test - public void testGetNetworkGenericVnfEndpoint() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf') - - when(mockExecution.getVariable('aai.endpoint')).thenReturn('http://localhost:28090') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn('8') - - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def endpoint = aaiUtil.getNetworkGenericVnfEndpoint(mockExecution) - assertEquals('http://localhost:28090/aai/v8/network/generic-vnfs/generic-vnf', endpoint) - } - - @Test - public void testGetNetworkGenericVnfUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf') - - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn('8') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkGenericVnfUri(mockExecution) - assertEquals('/aai/v8/network/generic-vnfs/generic-vnf', uri) - } - - @Test - public void testGetNetworkVpnBindingUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.vpn-binding.uri")).thenReturn('/aai/v8/network/vpn-bindings/vpn-binding') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkVpnBindingUri(mockExecution) - assertEquals('/aai/v8/network/vpn-bindings/vpn-binding', uri) - } - - @Test - public void testGetNetworkPolicyUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.network-policy.uri")).thenReturn('/aai/v8/network/network-policies/network-policy') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkPolicyUri(mockExecution) - assertEquals('/aai/v8/network/network-policies/network-policy', uri) - } - - @Test - public void testGetNetworkTableReferencesUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.route-table-reference.uri")).thenReturn('/aai/v8/network/route-table-references/route-table-reference') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkTableReferencesUri(mockExecution) - assertEquals('/aai/v8/network/route-table-references/route-table-reference', uri) - } - - @Test - public void testGetNetworkVceUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.vce.uri")).thenReturn('/aai/v8/network/vces/vce') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkVceUri(mockExecution) - assertEquals('/aai/v8/network/vces/vce', uri) - } - - @Test - public void testGetNetworkL3NetworkUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.l3-network.uri")).thenReturn('/aai/v8/network/l3-networks/l3-network') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) - assertEquals('/aai/v8/network/l3-networks/l3-network', uri) - } - - @Test - public void testGetBusinessCustomerUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getBusinessCustomerUri(mockExecution) - assertEquals('/aai/v8/business/customers/customer', uri) - } - - @Test - public void testGetCloudInfrastructureCloudRegionEndpoint() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - - when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic') - - when(mockExecution.getVariable('aai.endpoint')).thenReturn('http://localhost:28090') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(mockExecution) - assertEquals('http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri) - } - - @Test - public void testGetCloudInfrastructureCloudRegionUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - - when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic') - - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getCloudInfrastructureCloudRegionUri(mockExecution) - assertEquals('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri) - } - - @Test - public void testGetCloudInfrastructureTenantUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.tenant.uri")).thenReturn('/aai/v8/cloud-infrastructure/tenants/tenant') - - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getCloudInfrastructureTenantUri(mockExecution) - assertEquals('/aai/v8/cloud-infrastructure/tenants/tenant', uri) - } - - @Test - public void testGetSearchNodesQueryUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - - when(mockExecution.getVariable("mso.workflow.default.aai.v8.nodes-query.uri")).thenReturn('/aai/v8/search/nodes-query') - - when(mockExecution.getVariable('aai.endpoint')).thenReturn('http://localhost:28090') - - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getSearchNodesQueryUri(mockExecution) - assertEquals('/aai/v8/search/nodes-query', uri) - } - - @Test - public void testGetSearchNodesQueryEndpoint() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - - when(mockExecution.getVariable("mso.workflow.default.aai.v8.nodes-query.uri")).thenReturn('/aai/v8/search/nodes-query') - - when(mockExecution.getVariable('aai.endpoint')).thenReturn('http://localhost:28090') - - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getSearchNodesQueryEndpoint(mockExecution) - assertEquals('http://localhost:28090/aai/v8/search/nodes-query', uri) - } - - @Test - public void testGetSearchGenericQueryUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-query.uri")).thenReturn('/aai/v8/search/generic-query') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getSearchGenericQueryUri(mockExecution) - assertEquals('/aai/v8/search/generic-query', uri) - } - - @Test - public void testGetNamespaceFromUri() { - ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('6') - when(mockExecution.getVariable("mso.workflow.default.aai.v6.l3-network.uri")).thenReturn('/aai/v6/network/l3-networks/l3-network') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) // Required to populate the namespace in the class - def ns = aaiUtil.getNamespaceFromUri('/aai/v6/search/generic-query') - assertEquals('http://org.openecomp.aai.inventory/v6', ns) - } - - @Test public void testExecuteAAIGetCall() { ExecutionEntity mockExecution = setupMock('CreateAAIVfModule') when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') @@ -420,40 +151,6 @@ class AaiUtilTest extends MsoGroovyTest { } @Test - public void testGetNamespaceFromUri2() { - ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') - // - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('10') - when(mockExecution.getVariable("mso.workflow.default.aai.v10.l3-network.uri")).thenReturn('/aai/v10/network/l3-networks/l3-network') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - // - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) // Required to populate the namespace in the class - def ns = aaiUtil.getNamespaceFromUri('/aai/v10/search/generic-query') - assertEquals('http://org.openecomp.aai.inventory/v10', ns) - } - - @Test - public void testGetNamespaceFromUri3() { - ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') - // - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('100') - when(mockExecution.getVariable("mso.workflow.default.aai.v100.l3-network.uri")).thenReturn('/aai/v100/network/l3-networks/l3-network') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - // - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - CreateAAIVfModule myproc = new CreateAAIVfModule() - AaiUtil aaiUtil = new AaiUtil(myproc) - def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) // Required to populate the namespace in the class - def ns = aaiUtil.getNamespaceFromUri('/aai/v100/search/generic-query') - assertEquals('http://org.openecomp.aai.inventory/v100', ns) - } - - @Test public void testGetNamespaceFromUri_twoArguments() { // (execution, uri) ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') // diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy index 8ac8f25eb1..4b0c33ab99 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy @@ -57,6 +57,19 @@ class CompleteMsoProcessTest { <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name> </sdncadapterworkflow:MsoCompletionRequest> """ + + private String completeMsoNetworkProcessRequest = """ + <aetgt:MsoCompletionRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" + xmlns:ns="http://org.onap/so/request/types/v1"> + <request-info xmlns="http://org.onap/so/infra/vnf-request/v1"> + <request-id>bd631913-cfc6-488b-ba22-6b98504f703d</request-id> + <action>CREATE</action> + <source>VID</source> + </request-info> + <aetgt:status-message>Resource Completed Successfully</aetgt:status-message> + <aetgt:networkId>bd631913-cfc6-488b-ba22-6b98504f703d</aetgt:networkId> + <aetgt:mso-bpel-name>BPMN Network action: CREATE</aetgt:mso-bpel-name> + </aetgt:MsoCompletionRequest>""" @Test public void testPreProcessRequest() { @@ -117,7 +130,7 @@ class CompleteMsoProcessTest { <statusMessage>Resource Completed Successfully</statusMessage> <requestStatus>COMPLETE</requestStatus> <progress>100</progress> - + <networkId>bd631913-cfc6-488b-ba22-6b98504f703d</networkId> </req:updateInfraRequest> </soapenv:Body> </soapenv:Envelope>""" @@ -130,6 +143,7 @@ class CompleteMsoProcessTest { when(mockExecution.getVariable("CMSO_mso-bpel-name")).thenReturn("BPEL") when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC"); when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7"); + when(mockExecution.getVariable("CompleteMsoProcessRequest")).thenReturn(completeMsoNetworkProcessRequest); CompleteMsoProcess completeMsoProcess = new CompleteMsoProcess() completeMsoProcess.setUpdateDBstatustoSuccessPayload(mockExecution) diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy index e065ccd14f..a96127aa2d 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy @@ -20,151 +20,64 @@ package org.onap.so.bpmn.common.scripts -import com.github.tomakehurst.wiremock.junit.WireMockRule - import static org.mockito.Mockito.* -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService + +import javax.ws.rs.core.UriBuilder + +import org.camunda.bpm.engine.delegate.DelegateExecution import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake import org.junit.Assert -import org.junit.Rule +import org.junit.Before import org.junit.Test -import org.junit.runner.RunWith import org.mockito.ArgumentCaptor import org.mockito.Captor import org.mockito.Mockito -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.core.WorkflowException - -import static com.github.tomakehurst.wiremock.client.WireMock.* +import org.mockito.MockitoAnnotations +import org.mockito.Spy +import org.onap.aai.domain.yang.VolumeGroup +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 -@RunWith(MockitoJUnitRunner.class) class ConfirmVolumeGroupNameTest extends MsoGroovyTest { + + @Spy + private ConfirmVolumeGroupName confirmVolumeGroupName; - private static final def AAA_URI = "uri_test" - private static final def AIC_CLOUD_REGION = "AicClReg_test" - private static final def VOLUME_GROUP_NAME = "volumeTestGName" - private static final def VOLUME_GROUP_ID = "vol_gr_id_test" - - @Captor - ArgumentCaptor<ExecutionEntity> captor= ArgumentCaptor.forClass(ExecutionEntity.class); - - @Rule - public WireMockRule wireMockRule = new WireMockRule(8090); - - @Test - void preProcessRequestSuccessful() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("ConfirmVolumeGroupName_volumeGroupId")).thenReturn(VOLUME_GROUP_ID) - when(mockExecution.getVariable("ConfirmVolumeGroupName_volumeGroupName")).thenReturn(VOLUME_GROUP_NAME) - when(mockExecution.getVariable("ConfirmVolumeGroupName_aicCloudRegion")).thenReturn(AIC_CLOUD_REGION) + @Before + public void init() throws IOException { + super.init("ConfirmVolumeGroupName") + MockitoAnnotations.initMocks(this); + when(confirmVolumeGroupName.getAAIClient()).thenReturn(client) - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('namespace_test') - when(mockExecution.getVariable("mso.workflow.ConfirmVolumeGroupName.aai.cloud-region.uri")).thenReturn(AAA_URI) - new ConfirmVolumeGroupName().preProcessRequest(mockExecution) - - verifyInitProcessVariables(mockExecution) - verify(mockExecution).setVariable("CVGN_volumeGroupId", VOLUME_GROUP_ID) - verify(mockExecution).setVariable("CVGN_volumeGroupName", "volumeTestGName") - verify(mockExecution).setVariable("CVGN_aicCloudRegion", AIC_CLOUD_REGION) - verify(mockExecution).setVariable("CVGN_volumeGroupGetEndpoint", - "${AAA_URI}/${AIC_CLOUD_REGION}/volume-groups/volume-group/" + VOLUME_GROUP_ID) - } - - private void verifyInitProcessVariables(ExecutionEntity mockExecution) { - verify(mockExecution).setVariable("prefix", "CVGN_") - verify(mockExecution).setVariable("CVGN_volumeGroupId", null) - verify(mockExecution).setVariable("CVGN_volumeGroupName", null) - verify(mockExecution).setVariable("CVGN_aicCloudRegion", null) - verify(mockExecution).setVariable("CVGN_volumeGroupGetEndpoint", null) - verify(mockExecution).setVariable("CVGN_volumeGroupNameMatches", false) - verify(mockExecution).setVariable("CVGN_queryVolumeGroupResponseCode", null) - verify(mockExecution).setVariable("CVGN_queryVolumeGroupResponse", "") - verify(mockExecution).setVariable("CVGN_ResponseCode", null) - verify(mockExecution).setVariable("RollbackData", null) - } - - @Test - void checkAAIQueryResult_volumeGroupNamesMatch() { - ExecutionEntity mockExecution = setupMock() - commonPartOfCheckAAIQueryTest(mockExecution, VOLUME_GROUP_NAME) - verify(mockExecution).setVariable("CVGN_volumeGroupNameMatches", true) - } - - @Test - void checkAAIQueryResult_volumeGroupNamesDoNotMatch() { - ExecutionEntity mockExecution = setupMock() - commonPartOfCheckAAIQueryTest(mockExecution, "grName2") - verify(mockExecution, Mockito.times(0)).setVariable("CVGN_volumeGroupNameMatches", true) - } - - private void commonPartOfCheckAAIQueryTest(ExecutionEntity mockExecution, def volumeGroupName) { - when(mockExecution.getVariable("CVGN_volumeGroupName")).thenReturn(VOLUME_GROUP_NAME) - def xml = "<volume-group-name>" + volumeGroupName + "</volume-group-name>" - when(mockExecution.getVariable("CVGN_queryVolumeGroupResponse")).thenReturn(xml) - new ConfirmVolumeGroupName().checkAAIQueryResult(mockExecution) - verify(mockExecution).setVariable("CVGN_volumeGroupNameMatches", false) } @Test public void testQueryAAIForVolumeGroupId() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("aai.endpoint")).thenReturn('http://localhost:8090') - when(mockExecution.getVariable("CVGN_volumeGroupGetEndpoint")).thenReturn('/aai/test/volume-groups/volume-group/testVolumeGroup') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - mockData() - - ConfirmVolumeGroupName confirmVolumeGroupName = new ConfirmVolumeGroupName() + AAIResourceUri resourceUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.VOLUME_GROUP, UriBuilder.fromPath('/aai/test/volume-groups/volume-group/testVolumeGroup').build()); + when(mockExecution.getVariable("CVGN_volumeGroupGetEndpoint")).thenReturn(resourceUri) + VolumeGroup volumeGroup = new VolumeGroup() + volumeGroup.setVolumeGroupId("Test") + when(client.get(VolumeGroup.class,resourceUri)).thenReturn(Optional.of(volumeGroup)) confirmVolumeGroupName.queryAAIForVolumeGroupId(mockExecution) - verify(mockExecution).setVariable("CVGN_queryVolumeGroupResponseCode",200) - verify(mockExecution).setVariable("CVGN_queryVolumeGroupResponse","") + Mockito.verify(mockExecution).setVariable("CVGN_queryVolumeGroupResponseCode",200) + Mockito.verify(mockExecution).setVariable("CVGN_queryVolumeGroupResponse",volumeGroup) } @Test public void testQueryAAIForVolumeGroupId_404() { - - ExecutionEntity mockExecution = setupMock() + AAIResourceUri resourceUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.VOLUME_GROUP, UriBuilder.fromPath('/aai/test/volume-groups/volume-group/testVolumeGroup').build()); + when(client.get(VolumeGroup.class, resourceUri)).thenReturn(Optional.empty()) + DelegateExecution execution = new DelegateExecutionFake() try { - when(mockExecution.getVariable("CVGN_volumeGroupGetEndpoint")).thenReturn('/aai/test/volume-groups/volume-group/testVolumeGroup') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - - mockData() - - ConfirmVolumeGroupName confirmVolumeGroupName = new ConfirmVolumeGroupName() - confirmVolumeGroupName.queryAAIForVolumeGroupId(mockExecution) - } - catch(Exception ex){ - + execution.setVariable("CVGN_volumeGroupGetEndpoint", resourceUri) + confirmVolumeGroupName.queryAAIForVolumeGroupId(execution) } - Mockito.verify(mockExecution,times(4)).setVariable(captor.capture(),captor.capture()) - WorkflowException workflowException = captor.getValue() - Assert.assertEquals("AAI GET Failed",workflowException.getErrorMessage()) - Assert.assertEquals(500,workflowException.getErrorCode()) - } - private void mockData() { - stubFor(get(urlMatching("/aai/test/volume-groups/volume-group/testVolumeGroup")) - .willReturn(aResponse() - .withStatus(200))) - } - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("ConfirmVolumeGroupName") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("ConfirmVolumeGroupName") - when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") - ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) - when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - when(mockExecution.getId()).thenReturn("100") - when(mockExecution.getProcessDefinitionId()).thenReturn("ConfirmVolumeGroupName") - when(mockExecution.getProcessInstanceId()).thenReturn("ConfirmVolumeGroupName") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - return mockExecution + catch(Exception ex){} + Assert.assertEquals(404, execution.getVariable("CVGN_queryVolumeGroupResponseCode")) + Assert.assertEquals("Volume Group not Found!", execution.getVariable("CVGN_queryVolumeGroupResponse")) + } } diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CustomE2EPutServiceTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CustomE2EPutServiceTest.groovy deleted file mode 100644 index 879ef7ab4f..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CustomE2EPutServiceTest.groovy +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.bpmn.common.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.junit.Assert -import org.junit.Before -import org.junit.Ignore -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.Captor -import org.mockito.Mockito -import org.mockito.runners.MockitoJUnitRunner - -import static org.mockito.Mockito.times -import static org.mockito.Mockito.when -import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutServiceInstance - -/** - * @author sushilma - * @since January 10, 2018 - */ -@RunWith(MockitoJUnitRunner.class) -@Ignore -class CustomE2EPutServiceTest extends MsoGroovyTest { - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090) - - @Captor - static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - @Test - public void testPutServiceInstance(){ - ExecutionEntity mockExecution = setupMockWithPrefix('CustomE2EPutService','GENPS_') - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer') - when(mockExecution.getVariable("GENPS_type")).thenReturn('service-instance') - when(mockExecution.getVariable("GENPS_payload")).thenReturn('') - when(mockExecution.getVariable("GENPS_globalSubscriberId")).thenReturn("1604-MVM-26") - when(mockExecution.getVariable("GENPS_serviceType")).thenReturn("SDN-ETHERNET-INTERNET") - when(mockExecution.getVariable("GENPS_serviceInstanceId")).thenReturn( "1234") - MockPutServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234", "GenericFlows/getServiceInstance.xml"); - - CustomE2EPutService customE2EPutService = new CustomE2EPutService() - customE2EPutService.putServiceInstance(mockExecution); - Mockito.verify(mockExecution, times(6)).setVariable(captor.capture(), captor.capture()) - Assert.assertEquals(200, captor.getAllValues().get(7)) - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleNameTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleNameTest.groovy index c5baf8cc6c..3a408b3310 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleNameTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleNameTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -59,7 +59,7 @@ class GenerateVfModuleNameTest { when(mockExecution.getVariable("personaModelId")).thenReturn('personaModelId_test') when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf') + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn('8') @@ -78,7 +78,7 @@ class GenerateVfModuleNameTest { when(mockExecution.getVariable("personaModelId")).thenReturn('personaModelId_test') when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf') + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn('8') diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy index 01e37f0cd7..3a2673c9ee 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy @@ -26,9 +26,40 @@ import org.camunda.bpm.engine.ProcessEngineServices import org.camunda.bpm.engine.RepositoryService import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.Rule +import org.junit.rules.ExpectedException +import org.junit.runner.RunWith +import org.mockito.runners.MockitoJUnitRunner +import org.onap.aai.domain.yang.GenericVnf +import org.onap.so.bpmn.mock.FileUtil +import org.onap.so.client.aai.AAIObjectPlurals +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.graphinventory.entities.uri.Depth +import org.onap.so.constants.Defaults +@RunWith(MockitoJUnitRunner.class) abstract class MsoGroovyTest { + @Rule + public ExpectedException thrown = ExpectedException.none() + + protected ExecutionEntity mockExecution + protected AAIResourcesClient client + protected AllottedResourceUtils allottedResourceUtils_MOCK + protected final String SEARCH_RESULT_AAI_WITH_RESULTDATA = + FileUtil.readResourceFile("__files/aai/searchResults.json") + protected static final String CLOUD_OWNER = Defaults.CLOUD_OWNER.toString(); + + protected void init(String procName){ + mockExecution = setupMock(procName) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + client = mock(AAIResourcesClient.class) + } + protected ExecutionEntity setupMock(String procName) { ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) when(mockProcessDefinition.getKey()).thenReturn(procName) @@ -64,5 +95,59 @@ abstract class MsoGroovyTest { return mockExecution } + protected <T> Optional<T> getAAIObjectFromJson(Class<T> clazz , String file){ + String json = FileUtil.readResourceFile(file) + AAIResultWrapper resultWrapper = new AAIResultWrapper(json) + return resultWrapper.asBean(clazz) + } + + protected Optional<GenericVnf> mockAAIGenericVnf(String vnfId){ + return mockAAIGenericVnf(vnfId,"__files/aai/GenericVnf.json") + } + protected Optional<GenericVnf> mockAAIGenericVnf(String vnfId,String file){ + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + AAIResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + Optional<GenericVnf> genericVnf = getAAIObjectFromJson(GenericVnf.class,file); + when(client.get(GenericVnf.class, resourceUri)).thenReturn(genericVnf) + when(client.get(GenericVnf.class, resourceUriDepthOne)).thenReturn(genericVnf) + return genericVnf + } + + protected Optional<GenericVnf> mockAAIGenericVnfByName(String vnfName){ + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName) + AAIResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName).depth(Depth.ONE) + Optional<GenericVnf> genericVnf = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnf.json"); + when(client.get(GenericVnf.class, resourceUri)).thenReturn(genericVnf) + when(client.get(GenericVnf.class, resourceUriDepthOne)).thenReturn(genericVnf) + return genericVnf + } + + protected void mockAAIGenericVnfNotFound(String vnfId){ + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + AAIResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + when(client.get(GenericVnf.class, resourceUri)).thenReturn(Optional.empty()) + when(client.get(GenericVnf.class, resourceUriDepthOne)).thenReturn(Optional.empty()) + } + + protected void mockAAIGenericVnfByNameNotFound(String vnfName){ + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName) + AAIResourceUri resourceUriDepthOne = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName).depth(Depth.ONE) + when(client.get(GenericVnf.class, resourceUri)).thenReturn(Optional.empty()) + when(client.get(GenericVnf.class, resourceUriDepthOne)).thenReturn(Optional.empty()) + } + + protected AAIResultWrapper mockVolumeGroupWrapper(String region, String volumeGroupId, String file){ + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, region,volumeGroupId) + String json = FileUtil.readResourceFile(file) + AAIResultWrapper resultWrapper = new AAIResultWrapper(json) + when(client.get(resourceUri)).thenReturn(resultWrapper) + return resultWrapper + } + + void initAR(String procName){ + init(procName) + allottedResourceUtils_MOCK = spy(new AllottedResourceUtils(mock(AbstractServiceTaskProcessor.class))) + when(allottedResourceUtils_MOCK.getAAIClient()).thenReturn(client) + } } diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModuleTest.groovy index c5b8fab9eb..21441b9b73 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModuleTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModuleTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -57,7 +57,6 @@ class PrepareUpdateAAIVfModuleTest { ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("PUAAIVfMod_vnfId")).thenReturn("skask") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.PrepareUpdateAAIVfModule.aai.version")).thenReturn('8') @@ -75,7 +74,7 @@ class PrepareUpdateAAIVfModuleTest { ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("PUAAIVfMod_vnfId")).thenReturn("skask") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.PrepareUpdateAAIVfModule.aai.version")).thenReturn('8') @@ -105,7 +104,7 @@ class PrepareUpdateAAIVfModuleTest { when(mockExecution.getVariable("PUAAIVfMod_vfModule")).thenReturn(vfModule) when(mockExecution.getVariable("PUAAIVfMod_orchestrationStatus")).thenReturn("created") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.PrepareUpdateAAIVfModule.aai.version")).thenReturn('8') @@ -131,7 +130,7 @@ class PrepareUpdateAAIVfModuleTest { when(mockExecution.getVariable("PUAAIVfMod_vfModule")).thenReturn(vfModule) when(mockExecution.getVariable("PUAAIVfMod_orchestrationStatus")).thenReturn("created") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.PrepareUpdateAAIVfModule.aai.version")).thenReturn('8') diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy index e0166f3602..5641c5e12f 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -65,7 +65,7 @@ class UpdateAAIGenericVnfTest { ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("UAAIGenVnf_vnfId")).thenReturn("skask") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIGenericVnf.aai.version")).thenReturn('8') @@ -82,7 +82,7 @@ class UpdateAAIGenericVnfTest { ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("UAAIGenVnf_vnfId")).thenReturn("skask") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIGenericVnf.aai.version")).thenReturn('8') @@ -107,7 +107,7 @@ class UpdateAAIGenericVnfTest { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("UAAIGenVnf_vnfId")).thenReturn("skask") when(mockExecution.getVariable("UAAIGenVnf_getGenericVnfResponse")).thenReturn(getVfModuleResponse) - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIGenericVnf.aai.version")).thenReturn('8') @@ -128,7 +128,7 @@ class UpdateAAIGenericVnfTest { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("UAAIGenVnf_vnfId")).thenReturn("skask") when(mockExecution.getVariable("UAAIGenVnf_getGenericVnfResponse")).thenReturn(getVfModuleResponse) - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIGenericVnf.aai.version")).thenReturn('8') diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy index d2f9095e2d..407ffa2915 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -65,7 +65,7 @@ class UpdateAAIVfModuleTest { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIVfModule.aai.version")).thenReturn('8') @@ -84,7 +84,7 @@ class UpdateAAIVfModuleTest { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIVfModule.aai.version")).thenReturn('8') @@ -110,7 +110,7 @@ class UpdateAAIVfModuleTest { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIVfModule.aai.version")).thenReturn('8') @@ -131,7 +131,7 @@ class UpdateAAIVfModuleTest { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIVfModule.aai.version")).thenReturn('8') diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/appc/payload/PayloadClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/appc/payload/PayloadClientTest.java index a08d8ca25d..20c69fafe3 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/appc/payload/PayloadClientTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/appc/payload/PayloadClientTest.java @@ -66,8 +66,8 @@ public class PayloadClientTest { @Test public void healthCheckFormatTest() throws Exception { - String payloadResult = "{\\\"request-parameters\\\":{\\\"vnf-host-ip-address\\\":\\\"vnfHostIpAddress1\\\"}}"; - Optional<String> payloadClient = PayloadClient.healthCheckFormat("vnfName1", "vnfHostIpAddress1"); + String payloadResult = "{\"request-parameters\":{\"host-ip-address\":\"hostIpAddress1\"}}"; + Optional<String> payloadClient = PayloadClient.healthCheckFormat("vnfName1", "hostIpAddress1"); assertEquals(payloadResult, payloadClient.get()); } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAAI.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAAI.java index 3b41ff8337..38be9f3790 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAAI.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAAI.java @@ -984,31 +984,6 @@ public class StubResponseAAI { .willReturn(aResponse() .withStatus(404))); } - @Deprecated - public static void MockGENPSIPutServiceInstance(){ - stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("GenericPutServiceInstance/GenericPutServiceInstance_PutServiceInstance_AAIResponse_Success.xml"))); - } - - @Deprecated - public static void MockGENPSIPutServiceSubscription(){ - stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("GenericPutServiceInstance/GenericPutServiceInstance_PutServiceInstance_AAIResponse_Success.xml"))); - } - @Deprecated - public static void MockGENPSIPutServiceInstance_get500(){ - stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET")) - .willReturn(aResponse() - .withStatus(500) - .withHeader("Content-Type", "text/xml") - .withBodyFile("GenericPutServiceInstance/aaiFault.xml"))); - } @Deprecated public static void MockGetGenericVnfById(){ diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java index 33e1390b9c..94dbbf427c 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java @@ -549,7 +549,7 @@ public class BBInputSetupMapperLayerTest { @Test public void testMapOrchestrationContext() throws IOException { OrchestrationContext expected = new OrchestrationContext(); - expected.setIsRollbackEnabled(false); + expected.setIsRollbackEnabled(true); RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class); @@ -561,7 +561,7 @@ public class BBInputSetupMapperLayerTest { @Test public void testMapLocationContext() { CloudRegion expected = new CloudRegion(); - expected.setCloudOwner("att-aic"); + expected.setCloudOwner("test-owner-name"); expected.setLcpCloudRegionId("cloudRegionId"); expected.setComplex("complexName"); expected.setTenantId("tenantId"); @@ -570,11 +570,11 @@ public class BBInputSetupMapperLayerTest { cloudConfig.setLcpCloudRegionId("cloudRegionId"); cloudConfig.setAicNodeClli("aicNodeClli"); org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion(); - cloudRegion.setCloudOwner("att-aic"); + cloudRegion.setCloudOwner("test-owner-name"); cloudRegion.setCloudRegionId("cloudRegionId"); cloudRegion.setComplexName("complexName"); - CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion, "att-aic"); + CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion); assertThat(actual, sameBeanAs(expected)); } @@ -582,7 +582,7 @@ public class BBInputSetupMapperLayerTest { @Test public void testMapCloudRegion() { CloudRegion expected = new CloudRegion(); - expected.setCloudOwner("att-aic"); + expected.setCloudOwner("test-owner-name"); expected.setLcpCloudRegionId("cloudRegionId"); expected.setTenantId("tenantId"); expected.setCloudRegionVersion("cloudRegionVersion"); @@ -593,11 +593,11 @@ public class BBInputSetupMapperLayerTest { cloudConfig.setAicNodeClli("aicNodeClli"); org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion(); - cloudRegion.setCloudOwner("att-aic"); + cloudRegion.setCloudOwner("test-owner-name"); cloudRegion.setCloudRegionId("cloudRegionId"); cloudRegion.setCloudRegionVersion("cloudRegionVersion"); - CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion, "att-aic"); + CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion); assertThat(actual, sameBeanAs(expected)); } @@ -606,7 +606,7 @@ public class BBInputSetupMapperLayerTest { public void testMapCloudRegionWithNullCheck() { CloudRegion expected = new CloudRegion(); - CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null, null); + CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null); assertThat(actual, sameBeanAs(expected)); } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index d0ecedf878..eed4b1411f 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -84,6 +84,7 @@ import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.constants.Defaults; import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResource; import org.onap.so.db.catalog.beans.CollectionResourceCustomization; @@ -317,6 +318,9 @@ public class BBInputSetupTest { RequestInfo requestInfo = new RequestInfo(); requestInfo.setSuppressRollback(true); requestDetails.setRequestInfo(requestInfo); + CloudConfiguration cloudConfiguration = new CloudConfiguration(); + cloudConfiguration.setLcpCloudRegionId("myRegionId"); + requestDetails.setCloudConfiguration(cloudConfiguration); doReturn(requestDetails).when(SPY_bbInputSetupUtils).getRequestDetails(executeBB.getRequestId()); Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); String resourceId = "123"; @@ -351,7 +355,7 @@ public class BBInputSetupTest { lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "instanceId"); doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId"); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration(), "att-aic"); + doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration()); doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(requestDetails, service, "bbName", serviceInstance, lookupKeyMap, resourceId, vnfType); @@ -404,7 +408,7 @@ public class BBInputSetupTest { lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "instanceId"); doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId"); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration(), "att-aic"); + doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration()); doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(requestDetails, service, "bbName", serviceInstance, lookupKeyMap, resourceId, vnfType); @@ -448,7 +452,7 @@ public class BBInputSetupTest { doReturn(service).when(SPY_bbInputSetupUtils) .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId()); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration(), "att-aic"); + doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration()); doReturn(project).when(bbInputSetupMapperLayer).mapRequestProject(requestDetails.getProject()); doReturn(owningEntity).when(bbInputSetupMapperLayer) .mapRequestOwningEntity(requestDetails.getOwningEntity()); @@ -497,7 +501,7 @@ public class BBInputSetupTest { .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId()); doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelVersionAndModelInvariantUUID( requestDetails.getModelInfo().getModelVersion(), requestDetails.getModelInfo().getModelInvariantId()); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration(), "att-aic"); + doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration()); doReturn(project).when(bbInputSetupMapperLayer).mapRequestProject(requestDetails.getProject()); doReturn(owningEntity).when(bbInputSetupMapperLayer) .mapRequestOwningEntity(requestDetails.getOwningEntity()); @@ -543,7 +547,7 @@ public class BBInputSetupTest { .getURIKeysFromServiceInstance(resourceId); doReturn(service).when(SPY_bbInputSetupUtils) .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId()); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration(), "att-aic"); + doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration()); doReturn(customer).when(SPY_bbInputSetup).getCustomerAndServiceSubscription(requestDetails, resourceId); doReturn(serviceSubscription).when(SPY_bbInputSetup).getServiceSubscription(requestDetails, customer); @@ -769,7 +773,7 @@ public class BBInputSetupTest { orchestrationContext.setIsRollbackEnabled(false); CloudRegion cloudRegion = new CloudRegion(); - cloudRegion.setCloudOwner("att-aic"); + cloudRegion.setCloudOwner("test-owner-name"); cloudRegion.setLcpCloudRegionId("lcpCloudRegionId"); cloudRegion.setComplex("complexName"); cloudRegion.setTenantId("tenantId"); @@ -792,11 +796,10 @@ public class BBInputSetupTest { doReturn(uriKeys).when(SPY_bbInputSetupUtils).getURIKeysFromServiceInstance(serviceInstance.getServiceInstanceId()); doReturn(customer).when(SPY_bbInputSetup).mapCustomer(uriKeys.get("global-customer-id"),uriKeys.get("service-type")); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration(), "att-aic"); + doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration()); doReturn(orchestrationContext).when(bbInputSetupMapperLayer).mapOrchestrationContext(requestDetails); doReturn(requestContext).when(bbInputSetupMapperLayer).mapRequestContext(requestDetails); - doReturn(cloudRegion).when(bbInputSetupMapperLayer).mapCloudRegion(requestDetails.getCloudConfiguration(), aaiCloudRegion, - "att-aic"); + doReturn(cloudRegion).when(bbInputSetupMapperLayer).mapCloudRegion(requestDetails.getCloudConfiguration(), aaiCloudRegion); GeneralBuildingBlock actual = SPY_bbInputSetup.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null); @@ -1769,11 +1772,12 @@ public class BBInputSetupTest { new File(RESOURCE_PATH + "ServiceMacroVfModules.json"), org.onap.so.serviceinstancebeans.Service.class); CloudConfiguration cloudConfig = null; org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = new org.onap.aai.domain.yang.CloudRegion(); + aaiCloudRegion.setCloudOwner("test-owner-name"); Resources resources = serviceMacro.getResources(); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(any(CloudConfiguration.class), eq("att-aic")); + doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(any(CloudConfiguration.class)); CloudRegion expected = new CloudRegion(); expected.setLcpCloudRegionId("mdt1"); - expected.setCloudOwner("att-aic"); + expected.setCloudOwner("test-owner-name"); expected.setTenantId("88a6ca3ee0394ade9403f075db23167e"); CloudRegion actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources); @@ -2124,8 +2128,7 @@ public class BBInputSetupTest { cloudConfig.setLcpCloudRegionId("lcpCloudRegionId"); requestDetails.setCloudConfiguration(cloudConfig); org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration(), - "att-aic"); + doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration()); executeBB.getBuildingBlock().setBpmnFlowName("DeleteNetworkBB"); executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); @@ -2273,14 +2276,13 @@ public class BBInputSetupTest { any(Service.class), any(String.class)); org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class); - doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration(), - "att-aic"); + doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration()); VolumeGroup volumeGroup = new VolumeGroup(); volumeGroup.setVolumeGroupId("volumeGroupId"); gBB.getServiceInstance().getVnfs().get(0).getVolumeGroups().add(volumeGroup); org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = new org.onap.aai.domain.yang.VolumeGroup(); aaiVolumeGroup.setModelCustomizationId("modelCustId"); - doReturn(aaiVolumeGroup).when(SPY_bbInputSetupUtils).getAAIVolumeGroup("att-aic", + doReturn(aaiVolumeGroup).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(Defaults.CLOUD_OWNER.toString(), cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()); executeBB.getBuildingBlock().setBpmnFlowName("UnassignVolumeGroupBB"); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java index eb74ab804e..e1efe1c9c5 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java @@ -174,27 +174,25 @@ public class BBInputSetupUtilsTest { @Test public void testGetCloudRegion() { - String cloudOwner = "cloudOwnerId"; CloudConfiguration cloudConfig = new CloudConfiguration(); cloudConfig.setLcpCloudRegionId("lcpCloudRegionId"); Optional<org.onap.aai.domain.yang.CloudRegion> expected = Optional.of(new org.onap.aai.domain.yang.CloudRegion()); - expected.get().setCloudOwner(cloudOwner); + expected.get().setCloudOwner("cloudOwner"); expected.get().setCloudRegionId("lcpCloudRegionId"); doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.CloudRegion.class, - AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudOwner, + AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudConfig.getCloudOwner(), cloudConfig.getLcpCloudRegionId())); - AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudOwner, + AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudConfig.getCloudOwner(), cloudConfig.getLcpCloudRegionId()); - bbInputSetupUtils.getCloudRegion(cloudConfig, cloudOwner); + bbInputSetupUtils.getCloudRegion(cloudConfig); verify(MOCK_aaiResourcesClient, times(1)).get(CloudRegion.class, expectedUri); } @Test public void testGetCloudRegionExceptionTest() { - String cloudOwner = "cloudOwnerId"; - + CloudConfiguration cloudConfig = new CloudConfiguration(); cloudConfig.setLcpCloudRegionId("lcpCloudRegionId"); @@ -203,33 +201,29 @@ public class BBInputSetupUtilsTest { doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class)); - CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfig, cloudOwner); + CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfig); assertNull(cloudRegion); } @Test public void testGetCloudRegionEmptyId() { - String cloudOwner = "cloudOwnerId"; - CloudConfiguration cloudConfig = new CloudConfiguration(); cloudConfig.setLcpCloudRegionId(""); RequestDetails requestDetails = new RequestDetails(); requestDetails.setCloudConfiguration(cloudConfig); - CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfig, cloudOwner); + CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfig); assertNull(cloudRegion); } @Test public void testGetCloudRegionEmptyConfiguration() { - String cloudOwner = "cloudOwnerId"; - RequestDetails requestDetails = new RequestDetails(); - CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(requestDetails.getCloudConfiguration(), cloudOwner); + CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(requestDetails.getCloudConfiguration()); assertNull(cloudRegion); } diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json new file mode 100644 index 0000000000..f05449a96f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json @@ -0,0 +1,6 @@ +{ + "requestInfo" : {"sourceId":"mso","requestType":"create","requestId":"testRequestId","callbackUrl":"http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId","transactionId":"testRequestId","timeout":1800}, + "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"}, + "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyModelInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyModelInstanceName2","serviceResourceId":"testProxyId2"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}}, + "licenseInfo" : {"licenseDemands":[]} +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json index 4c4c9b3f00..6977224ffa 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json @@ -1,6 +1,6 @@ { "requestInfo" : {"sourceId":"mso","requestType":"create","requestId":"testRequestId","callbackUrl":"http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId","transactionId":"testRequestId","timeout":1800}, "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"}, - "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testAllottedModelName1","modelVersionId":"testAllottedModelUuid1","modelVersion":"testAllottedModelVersion1","modelInvariantId":"testAllottedModelInvariantUuid1"},"resourceModuleName":"testAllottedInstanceName1","serviceResourceId":"testAllottedResourceId1"},{"resourceModelInfo":{"modelName":"testAllottedModelName2","modelVersionId":"testAllottedModelUuid2","modelVersion":"testAllottedModelVersion2","modelInvariantId":"testAllottedModelInvariantUuid2"},"resourceModuleName":"testAllottedInstanceName2","serviceResourceId":"testAllottedResourceId2"},{"resourceModelInfo":{"modelName":"testAllottedModelName3","modelVersionId":"testAllottedModelUuid3","modelVersion":"testAllottedModelVersion3","modelInvariantId":"testAllottedModelInvariantUuid3"},"resourceModuleName":"testAllottedInstanceName3","serviceResourceId":"testAllottedResourceId3"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}}, - "licenseInfo" : [] + "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testAllottedModelName1","modelVersionId":"testAllottedModelUuid1","modelVersion":"testAllottedModelVersion1","modelInvariantId":"testAllottedModelInvariantUuid1"},"resourceModuleName":"testAllottedModelInstanceName1","serviceResourceId":"testAllottedResourceId1"},{"resourceModelInfo":{"modelName":"testAllottedModelName2","modelVersionId":"testAllottedModelUuid2","modelVersion":"testAllottedModelVersion2","modelInvariantId":"testAllottedModelInvariantUuid2"},"resourceModuleName":"testAllottedModelInstanceName2","serviceResourceId":"testAllottedResourceId2"},{"resourceModelInfo":{"modelName":"testAllottedModelName3","modelVersionId":"testAllottedModelUuid3","modelVersion":"testAllottedModelVersion3","modelInvariantId":"testAllottedModelInvariantUuid3"},"resourceModuleName":"testAllottedModelInstanceName3","serviceResourceId":"testAllottedResourceId3"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}}, + "licenseInfo" : {"licenseDemands":[]} }
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json new file mode 100644 index 0000000000..877c6e7e74 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json @@ -0,0 +1,6 @@ +{ + "requestInfo" : {"sourceId":"mso","requestType":"create","requestId":"testRequestId","callbackUrl":"http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId","transactionId":"testRequestId","timeout":1800}, + "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"}, + "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyModelInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyModelInstanceName2","serviceResourceId":"testProxyId2"},{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyModelInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyModelInstanceName2","serviceResourceId":"testProxyId2"},{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyModelInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyModelInstanceName2","serviceResourceId":"testProxyId2"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}}, + "licenseInfo" : {"licenseDemands":[]} +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json index 8cd04fdd8e..60dd880040 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockCMExpected.json @@ -10,9 +10,10 @@ "configurationParameters": [] }, "orchContext": { - "is-rollback-enabled": true + "is-rollback-enabled": false }, "cloudRegion": { + "lcp-cloud-region-id" : "myRegionId", "cloud-owner": "att-aic" }, "userInput": null, diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json index 9b021ae1e7..cf65143c9a 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/GeneralBuildingBlockExpected.json @@ -17,7 +17,7 @@ }, "cloudRegion": { "lcp-cloud-region-id": "lcpCloudRegionId", - "cloud-owner": "att-aic", + "cloud-owner": "test-owner-name", "tenant-id": "tenantId", "complex": "complexName" }, diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVfModules.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVfModules.json index 3f07e8d526..de20a5a963 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVfModules.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVfModules.json @@ -49,6 +49,7 @@ }, "cloudConfiguration": { "lcpCloudRegionId": "mdt1", + "cloudOwner" : "test-owner-name", "tenantId": "88a6ca3ee0394ade9403f075db23167e" }, "instanceName": "vmxnjr001_AVPN_base_vRE_BV_expansion_001", diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVnfs.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVnfs.json index 4c29f96361..c4ad0ac047 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVnfs.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVnfs.json @@ -24,6 +24,7 @@ }, "cloudConfiguration": { "lcpCloudRegionId": "mdt1", + "cloudOwner" : "test-owner-name", "tenantId": "88a6ca3ee0394ade9403f075db23167e" }, "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", diff --git a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml index 236d435cb7..dea3f17f8e 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml +++ b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml @@ -115,30 +115,6 @@ mso: version: '9' generic-vnf: version: '9' - v8: - customer: - uri: /aai/v8/business/customers/customer - generic-query: - uri: /aai/v8/search/generic-query - l3-network: - uri: /aai/v8/network/l3-networks/l3-network - network-policy: - uri: /aai/v8/network/network-policies/network-policy - nodes-query: - uri: /aai/v8/search/nodes-query - route-table-reference: - uri: /aai/v8/network/route-table-references/route-table-reference - tenant: - uri: /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant - vce: - uri: /aai/v8/network/vces/vce - vpn-binding: - uri: /aai/v8/network/vpn-bindings/vpn-binding - v9: - cloud-region: - uri: /aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic - generic-vnf: - uri: /aai/v9/network/generic-vnfs/generic-vnf global: default: aai: diff --git a/bpmn/MSORESTClient/src/main/java/org/onap/so/rest/RESTClient.java b/bpmn/MSORESTClient/src/main/java/org/onap/so/rest/RESTClient.java index fc6266d917..c9dd6303bc 100644 --- a/bpmn/MSORESTClient/src/main/java/org/onap/so/rest/RESTClient.java +++ b/bpmn/MSORESTClient/src/main/java/org/onap/so/rest/RESTClient.java @@ -351,15 +351,6 @@ public class RESTClient { } /** - * Alias for httpGet(). - * - * @see RESTClient#httpGet() - */ - public APIResponse get() throws RESTException { - return httpGet(); - } - - /** * Sends an http GET request using the parameters and headers previously * set. * diff --git a/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java b/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java index 17ede2f2ff..a79f0aa536 100644 --- a/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java +++ b/bpmn/MSORESTClient/src/test/java/org/onap/so/rest/RESTClientTest.java @@ -7,9 +7,9 @@ * 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. @@ -49,11 +49,11 @@ public class RESTClientTest { private JSONObject jsonResponse; private String jsonObjectAsString; private String jsonResponseAsString; - + @Rule - public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - + public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); + + @Before public void before() throws Exception { jsonPayload = new JSONObject(); @@ -62,135 +62,123 @@ public class RESTClientTest { jsonObjectAsString = jsonPayload.toString(); jsonResponse = new JSONObject(); jsonResponse.put("response", "responseValue"); - jsonResponseAsString = jsonResponse.toString(); + jsonResponseAsString = jsonResponse.toString(); restClient = new RESTClient("http://localhost:" + wireMockRule.port() + "/example", "localhost", wireMockRule.port()); - } - + } + @Test public void testHeadersParameters() throws Exception { restClient.setHeader("name", "value"); restClient.setParameter("name", "value"); - assertEquals("[value]", restClient.getParameters().get("name").toString()); + assertEquals("[value]", restClient.getParameters().get("name").toString()); assertEquals("[value]", restClient.getHeaders().get("name").toString()); restClient.setHeader("name", "value2"); assertEquals("[value2]", restClient.getHeaders().get("name").toString()); restClient.setParameter("name", "value2"); assertEquals("[value2]", restClient.getParameters().get("name").toString()); - restClient.addParameter("name", "value"); + restClient.addParameter("name", "value"); assertEquals(1, restClient.getParameters().size()); - restClient.addAuthorizationHeader("token"); - assertEquals("[token]", restClient.getHeaders().get("Authorization").toString()); + restClient.addAuthorizationHeader("token"); + assertEquals("[token]", restClient.getHeaders().get("Authorization").toString()); assertEquals("http://localhost:" + wireMockRule.port() + "/example", restClient.getURL()); restClient = new RESTClient("http://localhost:" + wireMockRule.port() + "/example1"); assertEquals("http://localhost:" + wireMockRule.port() + "/example1", restClient.getURL()); } - + @Test public void testHttpPost() throws Exception { RESTClient restClientMock = mock(RESTClient.class); restClientMock = spy(restClient); wireMockRule.stubFor(post(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); APIResponse apiResponse = restClientMock.httpPost(jsonObjectAsString); assertEquals(200, apiResponse.getStatusCode()); assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); verify(restClientMock, times(2)).getURL(); - } - + } + @Test public void testPost() throws Exception { wireMockRule.stubFor(post(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); APIResponse apiResponse = restClient.post(); assertEquals(200, apiResponse.getStatusCode()); assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); - } - + } + @Test public void testHttpPut() throws Exception { wireMockRule.stubFor(put(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); restClient.setParameter("name", "value"); APIResponse apiResponse = restClient.httpPut(jsonObjectAsString); assertEquals(200, apiResponse.getStatusCode()); assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); - - } - + + } + @Test public void testHttpPatch() throws Exception { wireMockRule.stubFor(patch(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); APIResponse apiResponse = restClient.httpPatch(jsonObjectAsString); assertEquals(200, apiResponse.getStatusCode()); assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); - } + } @Test public void testPatch_withParameter() throws Exception { wireMockRule.stubFor(patch(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); restClient.setParameter("name", "value"); APIResponse apiResponse = restClient.patch(jsonObjectAsString); assertEquals(200, apiResponse.getStatusCode()); assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); - } - + } + @Test public void testHttpDelete_withPayload() throws Exception { wireMockRule.stubFor(delete(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); APIResponse apiResponse = restClient.httpDelete(jsonObjectAsString); assertEquals(200, apiResponse.getStatusCode()); assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); - } - + } + @Test public void testHttpDelete() throws Exception { wireMockRule.stubFor(delete(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); APIResponse apiResponse = restClient.httpDelete(); assertEquals(200, apiResponse.getStatusCode()); assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); - } - + } + @Test public void testDelete() throws Exception { wireMockRule.stubFor(delete(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); APIResponse apiResponse = restClient.delete(); assertEquals(200, apiResponse.getStatusCode()); assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); - } - + } + @Test public void testHttpGet() throws Exception { wireMockRule.stubFor(get(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); APIResponse apiResponse = restClient.httpGet(); assertEquals(200, apiResponse.getStatusCode()); assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); - } - - @Test - public void testGet_withParameter() throws Exception { - wireMockRule.stubFor(get(urlPathMatching("/example/*")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()).withBody(jsonResponseAsString))); - restClient.setParameter("name", "value"); - restClient.setParameter("type", "valueType"); - APIResponse apiResponse = restClient.get(); - assertEquals(200, apiResponse.getStatusCode()); - assertEquals(jsonResponseAsString, apiResponse.getResponseBodyAsString()); - assertEquals("application/json", apiResponse.getFirstHeader("Content-Type")); - } - + } + } diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenericGetVnfIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenericGetVnfIT.java deleted file mode 100644 index 10c0640b17..0000000000 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/GenericGetVnfIT.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.bpmn.common; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVceByNameWithDepth; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_500; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfByNameWithDepth; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetVceById; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.junit.Test; -import org.onap.so.BaseIntegrationTest; - -/** - * Please describe the GenericGetVnfTest.java class - * - */ - -public class GenericGetVnfIT extends BaseIntegrationTest { - - @Test - - public void testGenericGetVnf_success_genericVnf() throws Exception{ - MockGetGenericVnfByIdWithDepth("testVnfId123", 1, "GenericFlows/getGenericVnfByNameResponse.xml"); - - Map<String, Object> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", "testVnfName123", "generic-vnf"); - - String processId = invokeSubProcess( "GenericGetVnf", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_FoundIndicator",processId); - String vnf = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_vnf",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_getVnfByName",processId); - String response = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowResponse",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowException",processId); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("false", byName); - assertNotNull(response); - assertNotNull(vnf); - assertEquals(null, workflowException); - - } - - @Test - - public void testGenericGetVnf_success_vce() throws Exception{ - MockGetVceById("testVnfId123[?]depth=1", "GenericFlows/getVceResponse.xml"); - - Map<String, Object> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", "testVnfName123", "vce"); - - String processId = invokeSubProcess( "GenericGetVnf", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_FoundIndicator",processId); - String vnf = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_vnf",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_getVnfByName",processId); - String response = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowResponse",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowException",processId); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("false", byName); - assertNotNull(response); - assertNotNull(vnf); - assertEquals(null, workflowException); - - } - - @Test - - public void testGenericGetVnf_success_genericVnfByName() throws Exception{ - MockGetGenericVnfByNameWithDepth("testVnfName123", 1, "GenericFlows/getGenericVnfResponse.xml"); - - Map<String, Object> variables = new HashMap<>(); - setVariables(variables, "", "testVnfName123", "generic-vnf"); - - String processId = invokeSubProcess( "GenericGetVnf", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_FoundIndicator",processId); - String vnf = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_vnf",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_getVnfByName",processId); - String response = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowResponse",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowException",processId); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("true", byName); - assertNotNull(response); - assertNotNull(vnf); - assertEquals(null, workflowException); - - } - - @Test - - public void testGenericGetVnf_success_vceByName() throws Exception{ - MockGetGenericVceByNameWithDepth("testVnfName123", 1, "GenericFlows/getVceByNameResponse.xml"); - - Map<String, Object> variables = new HashMap<>(); - setVariables(variables, null, "testVnfName123", "vce"); - - String processId = invokeSubProcess( "GenericGetVnf", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_FoundIndicator",processId); - String vnf = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_vnf",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_getVnfByName",processId); - String response = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowResponse",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowException",processId); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("true", byName); - assertNotNull(response); - assertNotNull(vnf); - assertEquals(null, workflowException); - - } - - - - @Test - public void testGenericGetVnf_error_genericVnf500() throws Exception{ - - MockGetGenericVnfById_500("testVnfId123_500"); - - Map<String, Object> variables = new HashMap<>(); - setVariables(variables, "testVnfId123_500", "testVnfId123_500", "generic-vnf"); - - String processId = invokeSubProcess( "GenericGetVnf", variables); - - - String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_SuccessIndicator",processId); - String found = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_FoundIndicator",processId); - String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowException",processId); - String byName = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_getVnfByName",processId); - - String expectedWorkflowException = "WorkflowException[processKey=GenericGetVnf,errorCode=500,errorMessage=Received a bad response from AAI,workStep=*]"; - - assertEquals("false", successIndicator); - assertEquals("false", found); - assertEquals("false", byName); - - assertEquals(expectedWorkflowException, workflowException); - } - - private void setVariables(Map<String, Object> variables, String vnfId, String vnfName, String type) { - variables.put("isDebugLogEnabled", "true"); - variables.put("GENGV_vnfId", vnfId); - variables.put("GENGV_vnfName",vnfName); - variables.put("GENGV_type", type); - variables.put("mso-request-id", UUID.randomUUID().toString()); - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml index e2db499929..e2db499929 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/AddNetworkPolicy_AAIResponse_Success.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml index 2126ae7464..747d424f9c 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml @@ -2,5 +2,6 @@ <vnf-id>skask</vnf-id> <vf-module-id>lukewarm</vf-module-id> <aic-cloud-region>pdk1</aic-cloud-region> + <cloud-owner>test-owner</cloud-owner> <volume-group-id>78987</volume-group-id> </CreateAAIVfModuleVolumeGroupRequest>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml index 5232e530e9..5232e530e9 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/DoUpdateVfModuleRequest.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/GenericVnf.xml index c86a4aaa73..c86a4aaa73 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/GenericVnf.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml index 65f235cf4b..65f235cf4b 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml index f40b6bc991..f40b6bc991 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml index 4cab6c6615..4cab6c6615 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml index 7d3d0e54d1..7d3d0e54d1 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml index 7d3d0e54d1..7d3d0e54d1 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml index dbd55b0cf4..dbd55b0cf4 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml index e8a69da0f8..e8a69da0f8 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml index 77528ccf61..77528ccf61 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/StandardSDNCSynchResponse.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIGenericVnfRequest.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/UpdateAAIGenericVnfRequest.xml index 3e7c6503f4..3e7c6503f4 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIGenericVnfRequest.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/UpdateAAIGenericVnfRequest.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml index 8a690403c4..8a690403c4 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/UpdateAAIVfModuleRequest.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateVfModuleRequest.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/UpdateVfModuleRequest.xml index 0dc1b1d410..0dc1b1d410 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/UpdateVfModuleRequest.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/UpdateVfModuleRequest.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml index 49ecd0bf3f..49ecd0bf3f 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml index c602dd9667..c602dd9667 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml index 830d2e2237..830d2e2237 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml index b882c4c6f4..b882c4c6f4 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VfModule-new.xml index 3b8bea4e4e..3b8bea4e4e 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VfModule-new.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VfModule-supercool.xml index 5a2b7300b1..5a2b7300b1 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VfModule-supercool.xml diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VolumeGroup.xml b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VolumeGroup.xml index 7e913dd418..7e913dd418 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/VfModularity/VolumeGroup.xml +++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/__files/VfModularity/VolumeGroup.xml diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn index eaee5399e6..3355e627c3 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn @@ -37,7 +37,8 @@ <bpmn:extensionElements> <camunda:in source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> <camunda:in source="mso-request-id" target="mso-request-id" /> - <camunda:out source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> + <camunda:out source="generalBuildingBlock" target="gBBInput" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_1uiok7v</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0v8d14a</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn index 5795c1c671..bb7abf7d7d 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0"> - <bpmn:process id="DeleteVfModuleBB" name="Start" isExecutable="true"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0"> + <bpmn:process id="DeleteVfModuleBB" name="DeleteVfModuleBB" isExecutable="true"> <bpmn:startEvent id="DeleteVfModuleBB_Start"> <bpmn:outgoing>SequenceFlow_1537yw5</bpmn:outgoing> </bpmn:startEvent> diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/BaseTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/BaseTest.java index 2bec24e44b..62727b912e 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/BaseTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/BaseTest.java @@ -73,17 +73,17 @@ import com.fasterxml.jackson.databind.ObjectMapper; @ContextConfiguration @AutoConfigureWireMock(port = 0) public abstract class BaseTest extends BuildingBlockTestDataSetup { - + protected Map<String, Object> variables = new HashMap<>(); protected TestRestTemplate restTemplate = new TestRestTemplate(); protected HttpHeaders headers = new HttpHeaders(); - - @Value("${wiremock.server.port") + + @Value("${wiremock.server.port}") protected String wireMockPort; - + @Autowired protected RuntimeService runtimeService; @@ -92,13 +92,13 @@ public abstract class BaseTest extends BuildingBlockTestDataSetup { /* * Mocked for injection via autowiring */ - + @Value("${mso.catalog.db.spring.endpoint}") protected String endpoint; - + @MockBean protected CatalogDbClient MOCK_catalogDbClient; - + @SpyBean protected InjectionHelper MOCK_injectionHelper; @@ -111,21 +111,20 @@ public abstract class BaseTest extends BuildingBlockTestDataSetup { protected NetworkAdapterClientImpl MOCK_networkAdapterClient; @SpyBean protected SDNCClient MOCK_sdncClient; - + @SpyBean protected AAIFlagTasks aaiFlagTasks; - + @SpyBean protected AAIVnfResources aaiVnfResources; - + @SpyBean protected ExceptionBuilder exceptionUtil; - + @SpyBean protected SDNOHealthCheckResources MOCK_sdnoHealthCheckResources; - - + @@ -138,8 +137,8 @@ public abstract class BaseTest extends BuildingBlockTestDataSetup { */ - - + + @SpyBean protected BBInputSetupMapperLayer SPY_bbInputSetupMapperLayer; @SpyBean @@ -148,38 +147,38 @@ public abstract class BaseTest extends BuildingBlockTestDataSetup { protected BBInputSetup SPY_bbInputSetup; @SpyBean protected SniroHomingV2 sniroHoming; - + @SpyBean protected SniroClient sniroClient; - + @SpyBean - protected SDNOHealthCheckTasks sdnoHealthCheckTasks; - + protected SDNOHealthCheckTasks sdnoHealthCheckTasks; + /* * Mocked for injection via the IntectionHelper */ - - + + @Before public void baseTestBefore() { variables.put("gBuildingBlockExecution", new DelegateExecutionImpl(new HashMap<>())); - - + + } @LocalServerPort private int port; - + protected String readFile(String path) throws IOException { return readFile(path, Charset.defaultCharset()); } - + protected String readFile(String path, Charset encoding) throws IOException { byte[] encoded = Files.readAllBytes(Paths.get(path)); return new String(encoded, encoding); } - + protected String readJsonFileAsString(String fileLocation) throws IOException{ ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = mapper.readTree(new File(fileLocation)); @@ -205,5 +204,5 @@ public abstract class BaseTest extends BuildingBlockTestDataSetup { .camundaClass(MockLoggerDelegate.class.getName()).endEvent().name("End Point").done(); repositoryService.createDeployment().addModelInstance(fileName + ".bpmn", modelInstance).deploy(); } - + } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java index 9e6cfdb686..22f85b4794 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java @@ -7,9 +7,9 @@ * 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. @@ -88,20 +88,20 @@ public class BuildingBlockTestDataSetup{ private int volumeGroupCounter; private int vpnBindingCounter; private int vpnBondingLinkCounter; - + protected BuildingBlockExecution execution; - + protected GeneralBuildingBlock gBBInput; - + protected HashMap<ResourceKey, String> lookupKeyMap; - + protected ExtractPojosForBB extractPojosForBB = new ExtractPojosForBB(); - + @Rule public ExpectedException expectedException = ExpectedException.none(); - + protected DelegateExecution delegateExecution; - + @Before public void buildingBlockTestDataSetupBefore() { collectionCounter = 0; @@ -120,183 +120,183 @@ public class BuildingBlockTestDataSetup{ volumeGroupCounter = 0; vpnBindingCounter = 0; vpnBondingLinkCounter = 0; - + execution = new DelegateExecutionImpl(new ExecutionImpl()); execution.setVariable("testProcessKey", "testProcessKeyValue"); - + gBBInput = new GeneralBuildingBlock(); execution.setVariable("gBBInput", gBBInput); - + lookupKeyMap = new HashMap<ResourceKey, String>(); execution.setVariable("lookupKeyMap", lookupKeyMap); - + ExecutionImpl mockExecutionImpl = mock(ExecutionImpl.class); doReturn("test").when(mockExecutionImpl).getProcessInstanceId(); - + ExecutionImpl executionImpl = new ExecutionImpl(); executionImpl.setProcessInstance(mockExecutionImpl); - + delegateExecution = (DelegateExecution) executionImpl; delegateExecution.setVariable("testProcessKey", "testProcessKeyValue"); } - + public Map<String, String> buildUserInput() { Map<String, String> userInput = new HashMap<>(); userInput.put("testUserInputKey", "testUserInputValue"); - + return userInput; } - + public Map<String, String> setUserInput() { Map<String, String> userInput = buildUserInput(); - + gBBInput.setUserInput(userInput); - + return userInput; } - + public RequestContext buildRequestContext() { RequestContext requestContext = new RequestContext(); requestContext.setMsoRequestId(UUID.randomUUID().toString()); requestContext.setProductFamilyId("testProductFamilyId"); requestContext.setRequestorId("testRequestorId"); - + requestContext.setUserParams(new HashMap<>()); - + Map<String,Object> dataMap = new HashMap<>(); dataMap.put("vpnId","testVpnId"); dataMap.put("vpnRegion","testVpnRegion"); dataMap.put("vpnRt","testVpnRt"); dataMap.put("vpnName","vpnName"); dataMap.put("vpnRegion", Arrays.asList(new String[] {"USA", "EMEA", "APAC"})); - + HashMap<String,Object> userParams = new HashMap<>(); userParams.put("vpnData",dataMap); - + List<Map<String,Object>> userParamsList = new ArrayList<>(); userParamsList.add(userParams); - + RequestParameters requestParameters = new RequestParameters(); requestParameters.setUserParams(userParamsList); requestContext.setRequestParameters(requestParameters); - + return requestContext; } - + public RequestContext setRequestContext() { RequestContext requestContext = buildRequestContext(); - + gBBInput.setRequestContext(requestContext); - + return requestContext; } - + public CloudRegion buildCloudRegion() { CloudRegion cloudRegion = new CloudRegion(); cloudRegion.setLcpCloudRegionId("testLcpCloudRegionId"); cloudRegion.setTenantId("testTenantId"); cloudRegion.setCloudOwner("testCloudOwner"); - + return cloudRegion; } - + public CloudRegion setCloudRegion() { CloudRegion cloudRegion = buildCloudRegion(); - + gBBInput.setCloudRegion(cloudRegion); - + return cloudRegion; } - + public OrchestrationContext buildOrchestrationContext() { OrchestrationContext orchestrationContext = new OrchestrationContext(); - + return orchestrationContext; } - + public OrchestrationContext setOrchestrationContext() { OrchestrationContext orchestrationContext = buildOrchestrationContext(); - + gBBInput.setOrchContext(orchestrationContext); - + return orchestrationContext; } - + public Collection buildCollection() { collectionCounter++; - + Collection collection = new Collection(); collection.setId("testId" + collectionCounter); collection.setInstanceGroup(buildInstanceGroup()); - + return collection; } - + public Configuration buildConfiguration() { configurationCounter++; - + Configuration configuration = new Configuration(); configuration.setConfigurationId("testConfigurationId" + configurationCounter); configuration.setConfigurationName("testConfigurationName" + configurationCounter); - + ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration(); modelInfoConfiguration.setModelVersionId("testModelVersionId" + configurationCounter); modelInfoConfiguration.setModelInvariantId("testModelInvariantId" + configurationCounter); modelInfoConfiguration.setModelCustomizationId("testModelCustomizationId" + configurationCounter); - + configuration.setModelInfoConfiguration(modelInfoConfiguration); - + return configuration; } - + public OwningEntity buildOwningEntity() { owningEntityCounter++; - + OwningEntity owningEntity = new OwningEntity(); owningEntity.setOwningEntityId("testOwningEntityId" + owningEntityCounter); owningEntity.setOwningEntityName("testOwningEntityName" + owningEntityCounter); - + return owningEntity; } - + public Project buildProject() { projectCounter++; - + Project project = new Project(); project.setProjectName("testProjectName" + projectCounter); - + return project; } - + public ServiceSubscription buildServiceSubscription() { serviceSubscriptionCounter++; - + ServiceSubscription serviceSubscription = new ServiceSubscription(); serviceSubscription.setTempUbSubAccountId("testTempUbSubAccountId" + serviceSubscriptionCounter); serviceSubscription.setServiceType("testServiceType" + serviceSubscriptionCounter); - + return serviceSubscription; } - + public Customer buildCustomer() { customerCounter++; - + Customer customer = new Customer(); customer.setGlobalCustomerId("testGlobalCustomerId" + customerCounter); customer.setSubscriberType("testSubscriberType" + customerCounter); customer.setServiceSubscription(buildServiceSubscription()); - + return customer; } - + public ServiceInstance buildServiceInstance() { serviceInstanceCounter++; - + ServiceInstance serviceInstance = new ServiceInstance(); serviceInstance.setServiceInstanceId("testServiceInstanceId" + serviceInstanceCounter); serviceInstance.setServiceInstanceName("testServiceInstanceName" + serviceInstanceCounter); - + ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); modelInfoServiceInstance.setModelInvariantUuid("testModelInvariantUUID" + serviceInstanceCounter); modelInfoServiceInstance.setModelUuid("testModelUUID" + serviceInstanceCounter); @@ -304,30 +304,30 @@ public class BuildingBlockTestDataSetup{ modelInfoServiceInstance.setModelName("testModelName" + serviceInstanceCounter); modelInfoServiceInstance.setServiceType("testServiceType" + serviceInstanceCounter); serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); - + serviceInstance.setProject(buildProject()); - + serviceInstance.setOwningEntity(buildOwningEntity()); - + serviceInstance.setCollection(buildCollection()); - + serviceInstance.getConfigurations().add(buildConfiguration()); - + return serviceInstance; } - + public ServiceInstance setServiceInstance() { ServiceInstance serviceInstance = buildServiceInstance(); - + if(gBBInput.getCustomer() == null) { gBBInput.setCustomer(buildCustomer()); } gBBInput.getCustomer().getServiceSubscription().getServiceInstances().add(serviceInstance); lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId()); - + return serviceInstance; } - + public Customer setCustomer() { if(gBBInput.getCustomer() != null) return gBBInput.getCustomer(); Customer customer = new Customer(); @@ -337,64 +337,64 @@ public class BuildingBlockTestDataSetup{ customer.setServiceSubscription(buildServiceSubscription()); gBBInput.setCustomer(customer); - + return customer; } - + public Collection setCollection() { Collection collection = new Collection(); collection.setId("testId"); - + ServiceInstance serviceInstance = null; - + try { serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); } catch(BBObjectNotFoundException e) { serviceInstance = setServiceInstance(); } - + serviceInstance.setCollection(collection); - + return collection; } - + public InstanceGroup setInstanceGroup() { InstanceGroup instanceGroup = new InstanceGroup(); instanceGroup.setId("testId"); instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction"); - + Collection collection = null; - + try { ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); collection = serviceInstance.getCollection(); - + if (collection == null) { collection = setCollection(); } } catch(BBObjectNotFoundException e) { collection = setCollection(); } - + collection.setInstanceGroup(instanceGroup); - + return instanceGroup; } - + public VpnBinding buildVpnBinding() { vpnBindingCounter++; - + VpnBinding vpnBinding = new VpnBinding(); vpnBinding.setVpnId("testVpnId" + vpnBindingCounter); vpnBinding.setVpnName("testVpnName" + vpnBindingCounter); vpnBinding.setCustomerVpnId("testCustomerVpnId" + vpnBindingCounter); - + return vpnBinding; } - + public VpnBinding setVpnBinding() { VpnBinding vpnBinding = buildVpnBinding(); - + Customer customer = gBBInput.getCustomer(); if(customer == null){ @@ -403,106 +403,107 @@ public class BuildingBlockTestDataSetup{ customer.getVpnBindings().add(vpnBinding); lookupKeyMap.put(ResourceKey.VPN_ID, vpnBinding.getVpnId()); - + return vpnBinding; } - + public InstanceGroup buildInstanceGroup() { instanceGroupCounter++; - + InstanceGroup instanceGroup = new InstanceGroup(); instanceGroup.setId("testId" + instanceGroupCounter); instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction" + instanceGroupCounter); - + return instanceGroup; } - + public L3Network buildL3Network() { l3NetworkCounter++; - + L3Network network = new L3Network(); network.setNetworkId("testNetworkId" + l3NetworkCounter); network.setNetworkName("testNetworkName" + l3NetworkCounter); network.setNetworkType("testNetworkType" + l3NetworkCounter); - + ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork(); modelInfoNetwork.setModelInvariantUUID("testModelInvariantUUID" + l3NetworkCounter); modelInfoNetwork.setModelName("testModelName" + l3NetworkCounter); modelInfoNetwork.setModelVersion("testModelVersion" + l3NetworkCounter); modelInfoNetwork.setModelUUID("testModelUUID" + l3NetworkCounter); network.setModelInfoNetwork(modelInfoNetwork); - + return network; } - + public L3Network setL3Network() { L3Network network = buildL3Network(); - + ServiceInstance serviceInstance = null; - + try { serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); } catch(BBObjectNotFoundException e) { serviceInstance = setServiceInstance(); } - + serviceInstance.getNetworks().add(network); lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId()); - + return network; } - + public GenericVnf buildGenericVnf() { genericVnfCounter++; - + GenericVnf genericVnf = new GenericVnf(); genericVnf.setVnfId("testVnfId" + genericVnfCounter); genericVnf.setVnfName("testVnfName" + genericVnfCounter); genericVnf.setVnfType("testVnfType" + genericVnfCounter); - + Platform platform = new Platform(); platform.setPlatformName("testPlatformName"); genericVnf.setPlatform(platform); - + LineOfBusiness lob = new LineOfBusiness(); lob.setLineOfBusinessName("testLineOfBusinessName"); genericVnf.setLineOfBusiness(lob); - + ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); modelInfoGenericVnf.setModelName("testModelName" + genericVnfCounter); modelInfoGenericVnf.setModelCustomizationUuid("testModelCustomizationUUID" + genericVnfCounter); modelInfoGenericVnf.setModelInvariantUuid("testModelInvariantUUID" + genericVnfCounter); modelInfoGenericVnf.setModelVersion("testModelVersion" + genericVnfCounter); modelInfoGenericVnf.setModelUuid("testModelUUID" + genericVnfCounter); + modelInfoGenericVnf.setModelInstanceName("testModelInstanceName" + genericVnfCounter); genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf); - + return genericVnf; } - + public GenericVnf setGenericVnf() { GenericVnf genericVnf = buildGenericVnf(); - + ServiceInstance serviceInstance = null; - + try { serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); } catch(BBObjectNotFoundException e) { serviceInstance = setServiceInstance(); } - + serviceInstance.getVnfs().add(genericVnf); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, genericVnf.getVnfId()); - + return genericVnf; } - + public VfModule buildVfModule() { vfModuleCounter++; - + VfModule vfModule = new VfModule(); vfModule.setVfModuleId("testVfModuleId" + vfModuleCounter); vfModule.setVfModuleName("testVfModuleName" + vfModuleCounter); - + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID" + vfModuleCounter); modelInfoVfModule.setModelVersion("testModelVersion" + vfModuleCounter); @@ -510,128 +511,128 @@ public class BuildingBlockTestDataSetup{ modelInfoVfModule.setModelName("testModelName" + vfModuleCounter); modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID" + vfModuleCounter); vfModule.setModelInfoVfModule(modelInfoVfModule); - + return vfModule; } - + public VfModule setVfModule() { VfModule vfModule = buildVfModule(); - + GenericVnf genericVnf = null; - + try { genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); } catch(BBObjectNotFoundException e) { genericVnf = setGenericVnf(); } - + genericVnf.getVfModules().add(vfModule); lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModule.getVfModuleId()); - + return vfModule; } - + public VolumeGroup buildVolumeGroup() { volumeGroupCounter++; - + VolumeGroup volumeGroup = new VolumeGroup(); volumeGroup.setVolumeGroupId("testVolumeGroupId" + volumeGroupCounter); volumeGroup.setVolumeGroupName("testVolumeGroupName" + volumeGroupCounter); volumeGroup.setHeatStackId("testHeatStackId" + volumeGroupCounter); - + return volumeGroup; } - + public VolumeGroup setVolumeGroup() { VolumeGroup volumeGroup = buildVolumeGroup(); - + GenericVnf genericVnf = null; - + try { genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); } catch(BBObjectNotFoundException e) { genericVnf = setGenericVnf(); } - + genericVnf.getVolumeGroups().add(volumeGroup); lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId()); - + return volumeGroup; } - + public Pnf buildPnf() { pnfCounter++; - + Pnf pnf = new Pnf(); pnf.setPnfId("testPnfId" + pnfCounter); pnf.setPnfName("testPnfName" + pnfCounter); - + return pnf; } - + public ServiceProxy buildServiceProxy() { serviceProxyCounter++; - + ServiceProxy serviceProxy = new ServiceProxy(); serviceProxy.setServiceInstance(buildServiceInstance()); serviceProxy.getServiceInstance().getVnfs().add(buildGenericVnf()); - + Pnf primaryPnf = buildPnf(); primaryPnf.setRole("Primary"); serviceProxy.getServiceInstance().getPnfs().add(primaryPnf); - + Pnf secondaryPnf = buildPnf(); secondaryPnf.setRole("Secondary"); serviceProxy.getServiceInstance().getPnfs().add(secondaryPnf); - + return serviceProxy; } - + public VpnBondingLink buildVpnBondingLink() { vpnBondingLinkCounter++; - + VpnBondingLink vpnBondingLink = new VpnBondingLink(); vpnBondingLink.setVpnBondingLinkId("testVpnBondingLinkId" + vpnBondingLinkCounter); - + Configuration vnrConfiguration = buildConfiguration(); - vnrConfiguration.setNetwork(buildL3Network()); + vnrConfiguration.setNetwork(buildL3Network()); vpnBondingLink.setVnrConfiguration(vnrConfiguration); vpnBondingLink.setVrfConfiguration(buildConfiguration()); - + vpnBondingLink.setInfrastructureServiceProxy(buildServiceProxy()); - + vpnBondingLink.setTransportServiceProxy(buildServiceProxy()); - + return vpnBondingLink; } - + public VpnBondingLink setVpnBondingLink() { VpnBondingLink vpnBondingLink = buildVpnBondingLink(); - + ServiceInstance serviceInstance = null; - + try { serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); } catch(BBObjectNotFoundException e) { serviceInstance = setServiceInstance(); } - + serviceInstance.getVpnBondingLinks().add(vpnBondingLink); lookupKeyMap.put(ResourceKey.VPN_BONDING_LINK_ID, vpnBondingLink.getVpnBondingLinkId()); return vpnBondingLink; } - + public Customer setAvpnCustomer() { Customer customer = buildCustomer(); - + gBBInput.setCustomer(customer); - + return customer; } - + public ServiceProxy setServiceProxy(String uniqueIdentifier, String type) { ServiceProxy serviceProxy = new ServiceProxy(); serviceProxy.setId("testProxyId" + uniqueIdentifier); @@ -642,6 +643,7 @@ public class BuildingBlockTestDataSetup{ modelInfo.setModelName("testProxyModelName" + uniqueIdentifier); modelInfo.setModelUuid("testProxyModelUuid" + uniqueIdentifier); modelInfo.setModelVersion("testProxyModelVersion" + uniqueIdentifier); + modelInfo.setModelInstanceName("testProxyModelInstanceName" + uniqueIdentifier); serviceProxy.setModelInfoServiceProxy(modelInfo); @@ -653,13 +655,14 @@ public class BuildingBlockTestDataSetup{ ar.setId("testAllottedResourceId" + uniqueIdentifier); ModelInfoAllottedResource modelInfo = new ModelInfoAllottedResource(); - modelInfo.setModelInvariantUuid("testProxyModelInvariantUuid" + uniqueIdentifier); - modelInfo.setModelName("testProxyModelName" + uniqueIdentifier); - modelInfo.setModelUuid("testProxyModelUuid" + uniqueIdentifier); - modelInfo.setModelVersion("testProxyModelVersion" + uniqueIdentifier); - + modelInfo.setModelInvariantUuid("testAllottedModelInvariantUuid" + uniqueIdentifier); + modelInfo.setModelName("testAllottedModelName" + uniqueIdentifier); + modelInfo.setModelUuid("testAllottedModelUuid" + uniqueIdentifier); + modelInfo.setModelVersion("testAllottedModelVersion" + uniqueIdentifier); + modelInfo.setModelInstanceName("testAllottedModelInstanceName" + uniqueIdentifier); + ar.setModelInfoAllottedResource(modelInfo); - + return ar; } }
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/buildingblock/SniroHomingV2Test.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/buildingblock/SniroHomingV2Test.java index 4626615e6f..e36029c306 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/buildingblock/SniroHomingV2Test.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/buildingblock/SniroHomingV2Test.java @@ -7,9 +7,9 @@ * 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. @@ -59,6 +59,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +//TODO this class should be in so-bpmn-tasks public class SniroHomingV2Test extends BaseTest{ private ServiceInstance serviceInstance; @@ -127,7 +128,7 @@ public class SniroHomingV2Test extends BaseTest{ sniroHoming.callSniro(execution); String request = FileUtil.readResourceFile(RESOURCE_PATH + "SniroManagerRequest1Vpn.json"); - request = request.replace("28080", wireMockPort); + //request = request.replace("28080", wireMockPort); ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class); verify(sniroClient, times(1)).postDemands(argument.capture()); @@ -148,7 +149,7 @@ public class SniroHomingV2Test extends BaseTest{ sniroHoming.callSniro(execution); String request = FileUtil.readResourceFile(RESOURCE_PATH + "SniroManagerRequest3Vpn.json"); - request = request.replace("28080", wireMockPort); + //request = request.replace("28080", wireMockPort); ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class); verify(sniroClient, times(1)).postDemands(argument.capture()); @@ -167,7 +168,7 @@ public class SniroHomingV2Test extends BaseTest{ sniroHoming.callSniro(execution); String request = FileUtil.readResourceFile(RESOURCE_PATH + "SniroManagerRequest3AR.json"); - request = request.replace("28080", wireMockPort); + //request = request.replace("28080", wireMockPort); ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class); verify(sniroClient, times(1)).postDemands(argument.capture()); diff --git a/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml b/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml index 2d102afe9f..1aa046c0fb 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml +++ b/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml @@ -126,30 +126,6 @@ mso: version: '9' generic-vnf: version: '9' - v8: - customer: - uri: /aai/v8/business/customers/customer - generic-query: - uri: /aai/v8/search/generic-query - l3-network: - uri: /aai/v8/network/l3-networks/l3-network - network-policy: - uri: /aai/v8/network/network-policies/network-policy - nodes-query: - uri: /aai/v8/search/nodes-query - route-table-reference: - uri: /aai/v8/network/route-table-references/route-table-reference - tenant: - uri: /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant - vce: - uri: /aai/v8/network/vces/vce - vpn-binding: - uri: /aai/v8/network/vpn-bindings/vpn-binding - v9: - cloud-region: - uri: /aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic - generic-vnf: - uri: /aai/v9/network/generic-vnfs/generic-vnf global: default: aai: diff --git a/bpmn/so-bpmn-infrastructure-common/pom.xml b/bpmn/so-bpmn-infrastructure-common/pom.xml index 3523703ee8..55d5d9244e 100644 --- a/bpmn/so-bpmn-infrastructure-common/pom.xml +++ b/bpmn/so-bpmn-infrastructure-common/pom.xml @@ -269,7 +269,7 @@ <dependency> <groupId>org.onap.msb.java-sdk</groupId> <artifactId>msb-java-sdk</artifactId> - <version>1.0.0</version> + <version>1.1.1</version> <exclusions> <exclusion> <groupId>com.eclipsesource.jaxrs</groupId> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy index d2903f5396..cd583f77ef 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License") + * 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 * diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy index d665de2ba7..bdb44ca3e2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy @@ -280,6 +280,7 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor { String requestId = execution.getVariable("mso-request-id") String source = execution.getVariable(Prefix + "source") + String networkId = execution.getVariable("networkId") !=null ? execution.getVariable("networkId") : "" String msoCompletionRequest = """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" @@ -290,6 +291,7 @@ public class CreateNetworkInstance extends AbstractServiceTaskProcessor { <source>VID</source> </request-info> <aetgt:status-message>Network has been created successfully.</aetgt:status-message> + <aetgt:networkId>${MsoUtils.xmlEscape(networkId)}</aetgt:networkId> <aetgt:mso-bpel-name>BPMN Network action: CREATE</aetgt:mso-bpel-name> </aetgt:MsoCompletionRequest>""" diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy index 6acabe14a0..ffac4c0174 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy @@ -186,6 +186,10 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId execution.setVariable(prefix + 'lcpCloudRegionId', lcpCloudRegionId) + + def cloudOwner = cloudConfiguration.cloudOwner + execution.setVariable(prefix + 'cloudOwner', cloudOwner) + def tenantId = cloudConfiguration.tenantId execution.setVariable(prefix + 'tenantId', tenantId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy index aa569655f4..965d178cce 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy @@ -109,6 +109,10 @@ class CreateVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { def lcpCloudRegionId = requestMap.requestDetails.cloudConfiguration.lcpCloudRegionId execution.setVariable('lcpCloudRegionId', lcpCloudRegionId) + // cloudOwner + def cloudOwner = requestMap.requestDetails.cloudConfiguration.cloudOwner + execution.setVariable('cloudOwner', cloudOwner) + // tenant def tenantId = requestMap.requestDetails.cloudConfiguration.tenantId execution.setVariable('tenantId', tenantId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy index 06346ea81e..56e5be04a5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License") + * 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 * diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy index 2cbfeac239..7ddfdece9a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy @@ -7,9 +7,9 @@ * 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. @@ -30,11 +30,16 @@ import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.VidUtils; import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.constants.Defaults import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse import org.springframework.web.util.UriUtils + import groovy.json.JsonSlurper /** @@ -135,7 +140,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { execution.setVariable('DELVfModVol_cloudRegion', utils.getNodeText(request, 'aic-cloud-region')) setBasicDBAuthHeader(execution, isDebugLogEnabled) - + msoLogger.debug('Request: ' + createVolumeIncoming) } @@ -184,12 +189,12 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { String cloudRegion = execution.getVariable('DELVfModVol_cloudRegion') - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) + execution.setVariable("DELVfModVol_queryCloudRegionRequest", queryCloudRegionRequest) - msoLogger.debug(" DELVfModVol_queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest) cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) @@ -229,8 +234,9 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { String cloudRegion = execution.getVariable('DELVfModVol_aicCloudRegion') AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String queryAAIVolumeGroupRequest = aaiEndpoint + '/' + URLEncoder.encode(cloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, "UTF-8") + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId) + def queryAAIVolumeGroupRequest = aaiUtil.createAaiUri(uri) msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest) @@ -351,7 +357,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { def serviceId = execution.getVariable('DELVfModVol_serviceId') def messageId = execution.getVariable('DELVfModVol_messageId') - def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) + def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host", execution) if ('true'.equals(useQualifiedHostName)) { notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) @@ -388,8 +394,9 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { String cloudRegion = execution.getVariable('DELVfModVol_aicCloudRegion') AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String deleteAAIVolumeGrpIdRequest = aaiEndpoint + '/' + URLEncoder.encode(cloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(groupId, "UTF-8") + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, groupId).queryParam("resource-version", resourceVersion) + def deleteAAIVolumeGrpIdRequest = aaiUtil.createAaiUri(uri) if(resourceVersion !=null){ deleteAAIVolumeGrpIdRequest = deleteAAIVolumeGrpIdRequest +'?resource-version=' + UriUtils.encode(resourceVersion, 'UTF-8') @@ -436,7 +443,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { requestStatus = "FAILURE" progress = "" } - + String updateInfraRequest = """ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.onap.so/requestsdb"> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy index b6a02f29e7..ebd622ca51 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy @@ -152,26 +152,15 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { oStatus = "Created" } - String statusLine = isBlank(oStatus) ? "" : "<orchestration-status>${MsoUtils.xmlEscape(oStatus)}</orchestration-status>" - - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) - String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) - String serviceInstanceData = - """<service-instance xmlns=\"${namespace}\"> - <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id> - <service-instance-name>${MsoUtils.xmlEscape(serviceInstanceName)}</service-instance-name> - <service-type>${MsoUtils.xmlEscape(aaiServiceType)}</service-type> - <service-role>${MsoUtils.xmlEscape(aaiServiceRole)}</service-role> - ${statusLine} - <model-invariant-id>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-id> - <model-version-id>${MsoUtils.xmlEscape(modelUuid)}</model-version-id> - <input-parameters>${MsoUtils.xmlEscape(uuiRequest)}</input-parameters> - </service-instance>""".trim() - execution.setVariable("serviceInstanceData", serviceInstanceData) - msoLogger.debug(serviceInstanceData) - msoLogger.info(" aai_uri " + aai_uri + " namespace:" + namespace) - msoLogger.info(" 'payload' to create Service Instance in AAI - " + "\n" + serviceInstanceData) + org.onap.aai.domain.yang.ServiceInstance si = new org.onap.aai.domain.yang.ServiceInstance() + si.setServiceInstanceName(serviceInstanceName) + si.setServiceType(aaiServiceType) + si.setServiceRole(aaiServiceRole) + si.setOrchestrationStatus(oStatus) + si.setModelInvariantId(modelInvariantUuid) + si.setModelVersionId(modelUuid) + si.setInputParameters(uuiRequest) + execution.setVariable("serviceInstanceData", si) } catch (BpmnError e) { throw e; @@ -273,41 +262,35 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { } //TODO use create if not exist - public void postProcessAAIPUT(DelegateExecution execution) { - msoLogger.trace("postProcessAAIPUT ") + public void createServiceInstance(DelegateExecution execution) { + msoLogger.trace("createServiceInstance ") String msg = "" + String serviceInstanceId = UUID.randomUUID().toString() try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator") - if(!succInAAI){ - msoLogger.info("Error putting Service-instance in AAI", + serviceInstanceId) - WorkflowException workflowException = execution.getVariable("WorkflowException") - msoLogger.debug("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - } - else - { - //start rollback set up - RollbackData rollbackData = new RollbackData() - def disableRollback = execution.getVariable("disableRollback") - rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) - rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") - rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId) - rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType")) - rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) - execution.setVariable("rollbackData", rollbackData) - } + org.onap.aai.domain.yang.ServiceInstance si = execution.getVariable("serviceInstanceData") + + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), serviceInstanceId) + client.create(uri, si) } catch (BpmnError e) { throw e; } catch (Exception ex) { - msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage() + //start rollback set up + RollbackData rollbackData = new RollbackData() + def disableRollback = execution.getVariable("disableRollback") + rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) + rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") + rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId) + rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType")) + rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) + execution.setVariable("rollbackData", rollbackData) + + msg = "Exception in DoCreateServiceInstance.createServiceInstance. " + ex.getMessage() msoLogger.info(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - msoLogger.trace("Exit postProcessAAIPUT ") + msoLogger.trace("Exit createServiceInstance ") } /** @@ -439,7 +422,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { resourceTemplateUUIDs = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":" } - def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter" + def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.db.endpoint") execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) msoLogger.info("DB Adapter Endpoint is: " + dbAdapterEndpoint) @@ -469,7 +452,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { msoLogger.trace("COMPLETED preInitResourcesOperStatus Process ") } - // if site location is in local Operator, create all resources in local ONAP; + // if site location is in local Operator, create all resources in local ONAP; // if site location is in 3rd Operator, only process sp-partner to create all resources in 3rd ONAP public void doProcessSiteLocation(DelegateExecution execution){ msoLogger.trace("======== Start doProcessSiteLocation Process ======== ") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy index 731d9c24de..51574f63f8 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy @@ -20,6 +20,8 @@ package org.onap.so.bpmn.infrastructure.scripts; +import javax.ws.rs.core.UriBuilder + import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution @@ -33,22 +35,27 @@ import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.logger.MsoLogger -import org.onap.so.rest.APIResponse; -import org.springframework.web.util.UriUtils -import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.AAIObjectPlurals import org.onap.so.client.aai.AAIObjectType -import org.onap.so.client.aai.entities.AAIResultWrapper -import org.onap.so.client.aai.entities.Relationships +import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.json.JSONObject +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.graphinventory.entities.uri.Depth +import org.onap.so.constants.Defaults +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse; +import org.springframework.web.util.UriUtils +import org.onap.aai.domain.yang.VpnBinding +import org.onap.aai.domain.yang.RouteTarget + +import com.fasterxml.jackson.jaxrs.util.EndpointAsBeanProperty + import javax.ws.rs.NotFoundException import groovy.json.* import groovy.xml.XmlUtil - /** * This groovy class supports the <class>DoCreateNetworkInstance.bpmn</class> process. * @@ -360,8 +367,11 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { // Prepare AA&I url with network-name String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String queryAAINameRequest = "${aai_endpoint}${aai_uri}" + "?network-name=" + networkName + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK) + uri.queryParam("network-name", networkName) + String queryAAINameRequest = aaiUriUtil.createAaiUri(uri) + execution.setVariable(Prefix + "queryNameAAIRequest", queryAAINameRequest) msoLogger.debug(Prefix + "queryNameAAIRequest - " + "\n" + queryAAINameRequest) @@ -429,15 +439,14 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { try { String networkInputs = execution.getVariable(Prefix + "networkInputs") String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") - cloudRegion = UriUtils.encode(cloudRegion,"UTF-8") // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) + execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) - msoLogger.debug(Prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest) String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) @@ -508,11 +517,11 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { networkId = UriUtils.encode(networkId,"UTF-8") - // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String queryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) + uri.depth(Depth.ALL) + String queryIdAAIRequest = aaiUriUtil.createAaiUri(uri) + execution.setVariable(Prefix + "queryIdAAIRequest", queryIdAAIRequest) msoLogger.debug(Prefix + "queryIdAAIRequest - " + "\n" + queryIdAAIRequest) @@ -580,10 +589,11 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { networkId = UriUtils.encode(networkId,"UTF-8") // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String requeryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) + uri.depth(Depth.ALL) + String requeryIdAAIRequest = aaiUriUtil.createAaiUri(uri) + execution.setVariable(Prefix + "requeryIdAAIRequest", requeryIdAAIRequest) msoLogger.debug(Prefix + "requeryIdAAIRequest - " + "\n" + requeryIdAAIRequest) @@ -660,91 +670,37 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "vpnCount", vpnCount) msoLogger.debug(Prefix + "vpnCount - " + vpnCount) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - AaiUtil aaiUriUtil = new AaiUtil(this) - if (vpnCount > 0) { execution.setVariable(Prefix + "vpnBindings", vpnBindingUri) msoLogger.debug(" vpnBindingUri List - " + vpnBindingUri) String routeTargets = "" // AII loop call using list vpnBindings - for (i in 0..vpnBindingUri.size()-1) { - + for(i in 0..vpnBindingUri.size()-1) { int counting = i+1 - // prepare url using vpnBinding - String queryVpnBindingAAIRequest = "" - String aai_uri = aaiUriUtil.getNetworkVpnBindingUri(execution) - - // Note: By default, the vpnBinding url is found in 'related-link' of the response, - // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. - if (aai_uri == null || aai_uri == "") { - // using value of 'related-link' from response - if (vpnBindingUri[i].charAt(vpnBindingUri[i].length()-1) == '/') { - queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i].substring(0, vpnBindingUri[i].length()-1) + "?depth=all" - } else { - queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i] + "?depth=all" - } - - } else { - // using uri value in URN mapping - String vpnBindingId = vpnBindingUri[i].substring(vpnBindingUri[i].indexOf("/vpn-binding/")+13, vpnBindingUri[i].length()) - if (vpnBindingId.charAt(vpnBindingId.length()-1) == '/') { - vpnBindingId = vpnBindingId.substring(0, vpnBindingId.length()-1) - } - queryVpnBindingAAIRequest = "${aai_endpoint}${aai_uri}/" + vpnBindingId + "?depth=all" + String vpnBindingId = vpnBindingUri[i].substring(vpnBindingUri[i].indexOf("/vpn-binding/")+13, vpnBindingUri[i].length()) + if (vpnBindingId.charAt(vpnBindingId.length()-1) == '/') { + vpnBindingId = vpnBindingId.substring(0, vpnBindingId.length()-1) } - execution.setVariable(Prefix + "queryVpnBindingAAIRequest", queryVpnBindingAAIRequest) - msoLogger.debug(Prefix + "queryVpnBindingAAIRequest, , vpnBinding #" + counting + " : " + "\n" + queryVpnBindingAAIRequest) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryVpnBindingAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", returnCode) - msoLogger.debug(" ***** AAI query vpn binding Response Code, vpnBinding #" + counting + " : " + returnCode) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiResponseAsString) - msoLogger.debug(" AAI Query Vpn Binding Success REST Response, , vpnBinding #" + counting + " : " + "\n" + aaiResponseAsString) - - String routeTarget = "" - String routeRole = "" - if (utils.nodeExists(aaiResponseAsString, "route-targets")) { - String aaiRouteTargets = utils.getNodeXml(aaiResponseAsString, "route-targets", false) - def aaiRouteTargetsXml = new XmlSlurper().parseText(aaiRouteTargets) - def aaiRouteTarget = aaiRouteTargetsXml.'**'.findAll {it.name() == "route-target"} - for (j in 0..aaiRouteTarget.size()-1) { - routeTarget = utils.getNodeText(XmlUtil.serialize(aaiRouteTarget[j]), "global-route-target") - routeRole = utils.getNodeText(XmlUtil.serialize(aaiRouteTarget[j]), "route-target-role") - routeTargets += "<routeTargets>" + '\n' + - " <routeTarget>" + routeTarget + "</routeTarget>" + '\n' + - " <routeTargetRole>" + routeRole + "</routeTargetRole>" + '\n' + - "</routeTargets>" + '\n' - } - } - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from AAINetworkVpnBinding is 404 (Not Found)." - msoLogger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = " Unexpected Response from AAINetworkVpnBinding - " + returnCode - msoLogger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnBindingId) + AAIResultWrapper wrapper = resourceClient.get(uri.depth(Depth.TWO), NotFoundException.class) + + Optional<VpnBinding> binding = wrapper.asBean(VpnBinding.class) + + String routeTarget = "" + String routeRole = "" + if(binding.get().getRouteTargets() != null) { + List<RouteTarget> targets = binding.get().getRouteTargets().getRouteTarget() + for(RouteTarget target : targets) { + routeTarget = target.getGlobalRouteTarget() + routeRole = target.getRouteTargetRole() + routeTargets += "<routeTargets>" + '\n' + + " <routeTarget>" + routeTarget + "</routeTarget>" + '\n' + + " <routeTargetRole>" + routeRole + "</routeTargetRole>" + '\n' + + "</routeTargets>" + '\n' } } @@ -756,8 +712,8 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { } else { // reset return code to success execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + AaiUtil aaiUriUtil = new AaiUtil(this) + String schemaVersion = aaiUriUtil.getNamespace() String aaiStubResponse = """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> <vpn-binding xmlns="${schemaVersion}"> @@ -771,9 +727,9 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { } - } catch (BpmnError e) { - throw e; - + } catch (NotFoundException e) { + msoLogger.debug("Response Error from AAINetworkVpnBinding is 404 (Not Found).") + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Response Error from AAINetworkVpnBinding is 404 (Not Found).") } catch (Exception ex) { String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkVpnBinding() - " + ex.getMessage() msoLogger.debug(exceptionMessage) @@ -801,7 +757,6 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "networkPolicyCount", networkPolicyCount) msoLogger.debug(Prefix + "networkPolicyCount - " + networkPolicyCount) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) if (networkPolicyCount > 0) { @@ -814,31 +769,14 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { int counting = i+1 - // prepare url using vpnBinding - String queryNetworkPolicyAAIRequest = "" - - String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) - // Note: By default, the network policy url is found in 'related-link' of the response, // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. - if (aai_uri == null || aai_uri == "") { - // using value of 'related-link' from response - if (networkPolicyUriList[i].charAt(networkPolicyUriList[i].length()-1) == '/') { - queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i].substring(0, networkPolicyUriList[i].length()-1) + "?depth=all" - } else { - queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i] + "?depth=all" - } - } else { - // using uri value in URN mapping - String networkPolicyId = networkPolicyUriList[i].substring(networkPolicyUriList[i].indexOf("/network-policy/")+16, networkPolicyUriList[i].length()) - println " networkPolicyId - " + networkPolicyId - if (networkPolicyId.charAt(networkPolicyId.length()-1) == '/') { - networkPolicyId = networkPolicyId.substring(0, networkPolicyId.length()-1) - } - queryNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + networkPolicyId + "?depth=all" - } + URI uri = UriBuilder.fromUri(networkPolicyUriList[i]).build() + AAIResourceUri aaiUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.NETWORK_POLICY, uri) + aaiUri.depth(Depth.ALL) + String queryNetworkPolicyAAIRequest = aaiUriUtil.createAaiUri(aaiUri) execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest", queryNetworkPolicyAAIRequest) msoLogger.debug(Prefix + "queryNetworkPolicyAAIRequest, , NetworkPolicy #" + counting + " : " + "\n" + queryNetworkPolicyAAIRequest) @@ -890,8 +828,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { } else { // reset return code to success execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String schemaVersion = aaiUriUtil.getNamespace() String aaiStubResponse = """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> <network-policy xmlns="${schemaVersion}"> @@ -949,30 +886,11 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { int counting = i+1 // prepare url using tableRef - String queryNetworkTableRefAAIRequest = "" - - String aai_uri = aaiUriUtil.getNetworkTableReferencesUri(execution) - - // Note: By default, the network policy url is found in 'related-link' of the response, - // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. - if (aai_uri == null || aai_uri == "") { - // using value of 'related-link' from response - if (networkTableRefUriList[i].charAt(networkTableRefUriList[i].length()-1) == '/') { - queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i].substring(0, networkTableRefUriList[i].length()-1) + "?depth=all" - } else { - queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i] + "?depth=all" - } - } else { - // using uri value in URN mapping - String networkTableRefId = networkTableRefUriList[i].substring(networkTableRefUriList[i].indexOf("/route-table-reference/")+23, networkTableRefUriList[i].length()) - - if (networkTableRefId.charAt(networkTableRefId.length()-1) == '/') { - networkTableRefId = networkTableRefId.substring(0, networkTableRefId.length()-1) - } - queryNetworkTableRefAAIRequest = "${aai_endpoint}${aai_uri}/" + networkTableRefId + "?depth=all" - - } + URI uri = UriBuilder.fromUri(networkTableRefUriList[i]).build() + AAIResourceUri aaiUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ROUTE_TABLE_REFERENCE, uri) + aaiUri.depth(Depth.ALL) + String queryNetworkTableRefAAIRequest = aaiUriUtil.createAaiUri(aaiUri) execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest", queryNetworkTableRefAAIRequest) msoLogger.debug(Prefix + "queryNetworkTableRefAAIRequest, , NetworkTableRef #" + counting + " : " + "\n" + queryNetworkTableRefAAIRequest) @@ -1024,8 +942,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { } else { // reset return code to success execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String schemaVersion = aaiUriUtil.getNamespace() String aaiStubResponse = """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> <route-table-references xmlns="${schemaVersion}"> @@ -1066,16 +983,17 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { String createNetworkResponse = execution.getVariable(Prefix + "createNetworkResponse") // Prepare url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String updateContrailAAIUrlRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) + uri.depth(Depth.ALL) + String updateContrailAAIUrlRequest = aaiUriUtil.createAaiUri(uri) execution.setVariable(Prefix + "updateContrailAAIUrlRequest", updateContrailAAIUrlRequest) msoLogger.debug(Prefix + "updateContrailAAIUrlRequest - " + "\n" + updateContrailAAIUrlRequest) //Prepare payload (PUT) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(updateContrailAAIUrlRequest) String payload = networkUtils.ContrailNetworkCreatedUpdate(requeryIdAAIResponse, createNetworkResponse, schemaVersion) String payloadXml = utils.formatXml(payload) execution.setVariable(Prefix + "updateContrailAAIPayloadRequest", payloadXml) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy index b44940eb20..38836c3650 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy @@ -40,10 +40,15 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.ServiceInstance import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.infrastructure.aai.groovyflows.AAICreateResources +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.AAIResultWrapper +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.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse -import org.springframework.web.util.UriUtils import groovy.json.* @@ -267,58 +272,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { if (siParamsXml == null) siParamsXml = "" execution.setVariable("siParamsXml", siParamsXml) - - //AAI PUT - String oStatus = execution.getVariable("initialStatus") ?: "Active" - if ("TRANSPORT".equalsIgnoreCase(serviceType)) - { - oStatus = "Created" - } - - String statusLine = isBlank(oStatus) ? "" : "<orchestration-status>${MsoUtils.xmlEscape(oStatus)}</orchestration-status>" - String serviceTypeLine = isBlank(serviceType) ? "" : "<service-type>${MsoUtils.xmlEscape(serviceType)}</service-type>" - String serviceRoleLine = isBlank(serviceRole) ? "" : "<service-role>${MsoUtils.xmlEscape(serviceRole)}</service-role>" - - //QUERY CATALOG DB AND GET WORKLOAD / ENVIRONMENT CONTEXT - String environmentContext = "" - String workloadContext ="" - - try{ - String json = cutils.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid ) - - msoLogger.debug("JSON IS: "+json) - - environmentContext = jsonUtil.getJsonValue(json, "serviceResources.environmentContext") ?: "" - workloadContext = jsonUtil.getJsonValue(json, "serviceResources.workloadContext") ?: "" - msoLogger.debug("Env Context is: "+ environmentContext) - msoLogger.debug("Workload Context is: "+ workloadContext) - }catch(BpmnError e){ - throw e - } catch (Exception ex){ - msg = "Exception in preProcessRequest " + ex.getMessage() - msoLogger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - - //Create AAI Payload - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) - String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) - String serviceInstanceData = - """<service-instance xmlns=\"${namespace}\"> - <service-instance-name>${MsoUtils.xmlEscape(serviceInstanceName)}</service-instance-name> - ${serviceTypeLine} - ${serviceRoleLine} - ${statusLine} - <model-invariant-id>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-id> - <model-version-id>${MsoUtils.xmlEscape(modelUuid)}</model-version-id> - <environment-context>${MsoUtils.xmlEscape(environmentContext)}</environment-context> - <workload-context>${MsoUtils.xmlEscape(workloadContext)}</workload-context> - </service-instance>""".trim() - - execution.setVariable("serviceInstanceData", serviceInstanceData) - msoLogger.debug(" 'payload' to create Service Instance in AAI - " + "\n" + serviceInstanceData) - + } catch (BpmnError e) { throw e; } catch (Exception ex){ @@ -338,16 +292,17 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { String globalCustomerId = execution.getVariable("globalSubscriberId") //VID to AAI name map msoLogger.debug(" ***** getAAICustomerById ***** globalCustomerId:" + globalCustomerId) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) - if (isBlank(aai_endpoint) || isBlank(aai_uri)) + + AAIUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalCustomerId) + String getAAICustomerUrl = aaiUriUtil.createAaiUri(uri) + + if (isBlank(getAAICustomerUrl)) { - msg = "AAI URL is invalid. Endpoint:" + aai_endpoint + aai_uri + msg = "AAI URL is invalid. Endpoint:" + getAAICustomerUrl msoLogger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) } - String getAAICustomerUrl = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalCustomerId,"UTF-8") msoLogger.debug("getAAICustomerById Url:" + getAAICustomerUrl) APIResponse response = aaiUriUtil.executeAAIGetCall(execution, getAAICustomerUrl) @@ -399,42 +354,75 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { } - public void postProcessAAIPUT(DelegateExecution execution) { + public void putServiceInstance(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - msoLogger.trace("postProcessAAIPUT") + msoLogger.trace("putServiceInstance") String msg = "" + String serviceInstanceId = execution.getVariable("serviceInstanceId") try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator") - if(!succInAAI){ - msoLogger.debug("Error putting Service-instance in AAI", + serviceInstanceId) - WorkflowException workflowException = execution.getVariable("WorkflowException") - msoLogger.debug("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - } - else + + String serviceType = execution.getVariable("serviceType") + //AAI PUT + String oStatus = execution.getVariable("initialStatus") ?: "Active" + if ("TRANSPORT".equalsIgnoreCase(serviceType)) { - //start rollback set up - RollbackData rollbackData = new RollbackData() - def disableRollback = execution.getVariable("disableRollback") - rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) - rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") - rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId) - rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType")) - rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) - execution.setVariable("rollbackData", rollbackData) + oStatus = "Created" } + + //QUERY CATALOG DB AND GET WORKLOAD / ENVIRONMENT CONTEXT + String environmentContext = "" + String workloadContext ="" + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + + try{ + String json = cutils.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid ) + + msoLogger.debug("JSON IS: "+json) + + environmentContext = jsonUtil.getJsonValue(json, "serviceResources.environmentContext") ?: "" + workloadContext = jsonUtil.getJsonValue(json, "serviceResources.workloadContext") ?: "" + msoLogger.debug("Env Context is: "+ environmentContext) + msoLogger.debug("Workload Context is: "+ workloadContext) + }catch(BpmnError e){ + throw e + } catch (Exception ex){ + msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + org.onap.aai.domain.yang.ServiceInstance si = new org.onap.aai.domain.yang.ServiceInstance() + si.setServiceInstanceName(execution.getVariable("serviceInstanceName")) + si.setServiceType(serviceType) + si.setServiceRole(execution.getVariable("serviceRole")) + si.setOrchestrationStatus(oStatus) + si.setModelInvariantId(modelInvariantUuid) + si.setModelVersionId(execution.getVariable("modelUuid")) + si.setEnvironmentContext(environmentContext) + si.setWorkloadContext(workloadContext) + + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), serviceInstanceId) + client.create(uri, si) } catch (BpmnError e) { throw e; } catch (Exception ex) { - msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage() + //start rollback set up + RollbackData rollbackData = new RollbackData() + def disableRollback = execution.getVariable("disableRollback") + rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) + rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") + rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId) + rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType")) + rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) + execution.setVariable("rollbackData", rollbackData) + + msg = "Exception in DoCreateServiceInstance.putServiceInstance. " + ex.getMessage() msoLogger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - msoLogger.trace("Exit postProcessAAIPUT") + msoLogger.trace("Exit putServiceInstance") } public void preProcessSDNCAssignRequest(DelegateExecution execution) { diff --git 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 index da3ecbaef0..6783808826 100644 --- 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 @@ -7,9 +7,9 @@ * 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. @@ -27,6 +27,7 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.json.JSONArray import org.json.JSONObject +import org.onap.aai.domain.yang.GenericVnf import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.CatalogDbUtils import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -41,11 +42,15 @@ 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.aai.AAIObjectPlurals import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.entities.AAIResultWrapper +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.constants.Defaults import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse @@ -65,7 +70,7 @@ import com.fasterxml.jackson.databind.ObjectMapper public class DoCreateVfModule extends VfModuleBase { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVfModule.class); - + String Prefix="DCVFM_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() @@ -81,7 +86,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.preProcessRequest(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) execution.setVariable('prefix', Prefix) @@ -100,13 +105,13 @@ public class DoCreateVfModule extends VfModuleBase { if (request == null || request.isEmpty()) { // Building Block-type request - String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") - + String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") + def serviceModelInfo = execution.getVariable("serviceModelInfo") msoLogger.debug("serviceModelInfo: " + serviceModelInfo) String modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid") msoLogger.debug("modelInvariantUuid: " + modelInvariantUuid) - + def vnfModelInfo = execution.getVariable("vnfModelInfo") //tenantId @@ -124,6 +129,11 @@ public class DoCreateVfModule extends VfModuleBase { execution.setVariable("DCVFM_cloudSiteId", cloudSiteId) rollbackData.put("VFMODULE", "aiccloudregion", cloudSiteId) msoLogger.debug("cloudSiteId: " + cloudSiteId) + //cloudOwner + def cloudOwner = execution.getVariable("cloudOwner") + execution.setVariable("DCVFM_cloudOwner", cloudOwner) + rollbackData.put("VFMODULE", "cloudOwner", cloudOwner) + msoLogger.debug("cloudOwner: " + cloudOwner) //vnfType def vnfType = execution.getVariable("vnfType") execution.setVariable("DCVFM_vnfType", vnfType) @@ -238,15 +248,15 @@ public class DoCreateVfModule extends VfModuleBase { execution.setVariable("DCVFM_usePreload", usePreload) msoLogger.debug("usePreload: " + usePreload) //aLaCarte - def aLaCarte = execution.getVariable("aLaCarte") + def aLaCarte = execution.getVariable("aLaCarte") execution.setVariable("DCVFM_aLaCarte", aLaCarte) msoLogger.debug("aLaCarte: " + aLaCarte) - + //get workload and environment context from parent SI String environmentContext = "" String workloadContext ="" String serviceType ="" - + try{ String json = catalog.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid ) serviceType = jsonUtil.getJsonValue(json, "serviceResources.serviceType") @@ -257,7 +267,7 @@ public class DoCreateVfModule extends VfModuleBase { msoLogger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - + try{ AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId) AAIResourcesClient aaiRC = new AAIResourcesClient() @@ -265,14 +275,14 @@ public class DoCreateVfModule extends VfModuleBase { Map<String, Object> aaiJson = aaiRW.asMap() environmentContext = aaiJson.getOrDefault("environment-context","") workloadContext = aaiJson.getOrDefault("workload-context","") - + }catch (Exception ex) { msoLogger.debug("Error retreiving parent service instance information") } - + execution.setVariable("DCVFM_environmentContext",environmentContext) execution.setVariable("DCVFM_workloadContext",workloadContext) - + } else { // The info is inside the request - DEAD CODE @@ -400,7 +410,7 @@ public class DoCreateVfModule extends VfModuleBase { isBaseVfModule = utils.getNodeText(request, "is-base-vf-module") } execution.setVariable("DCVFM_isBaseVfModule", isBaseVfModule) - msoLogger.debug("isBaseVfModule: " + isBaseVfModule) + msoLogger.debug("isBaseVfModule: " + isBaseVfModule) //asdcServiceModelVersion def asdcServiceModelVersion = "" if (utils.nodeExists(request, "asdc-service-model-version")) { @@ -479,7 +489,7 @@ public class DoCreateVfModule extends VfModuleBase { } msoLogger.debug("sdncVersion: " + sdncVersion) execution.setVariable("DCVFM_sdncVersion", sdncVersion) - + execution.setVariable("DCVFM_uuid", uuid) execution.setVariable("DCVFM_baseVfModuleId", "") execution.setVariable("DCVFM_baseVfModuleHeatStackId", "") @@ -544,7 +554,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.sendResponse(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) try { @@ -554,7 +564,7 @@ public class DoCreateVfModule extends VfModuleBase { throw e; } catch (Exception e) { msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); - + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Internal Error') } } @@ -570,7 +580,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.getVfModule(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) try { @@ -614,7 +624,7 @@ public class DoCreateVfModule extends VfModuleBase { * @param execution The flow's execution instance. */ public void queryAAIVfModule(DelegateExecution execution) { - + def method = getClass().getSimpleName() + '.getVfModule(' + 'execution=' + execution.getId() + ')' @@ -625,10 +635,8 @@ public class DoCreateVfModule extends VfModuleBase { def vfModuleId = execution.getVariable('DCVFM_vfModuleId') AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + String endPoint = aaiUriUtil.createAaiUri(uri) try { RESTConfig config = new RESTConfig(endPoint); @@ -688,23 +696,23 @@ public class DoCreateVfModule extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) } } - + /** - * Using the vnfId and vfModuleName provided in the inputs, + * Using the vnfId and vfModuleName provided in the inputs, * query AAI to get the corresponding VF Module info. - * A 200 response is expected with the VF Module info in the response body, - * or a 404 response if the module does not exist yet. Will determine VF Module's + * A 200 response is expected with the VF Module info in the response body, + * or a 404 response if the module does not exist yet. Will determine VF Module's * orchestration status if one exists * * @param execution The flow's execution instance. */ public void queryAAIVfModuleForStatus(DelegateExecution execution) { - + def method = getClass().getSimpleName() + '.queryAAIVfModuleForStatus(' + 'execution=' + execution.getId() + ')' msoLogger.trace('Entered ' + method) - + execution.setVariable('DCVFM_orchestrationStatus', '') try { @@ -712,12 +720,8 @@ public class DoCreateVfModule extends VfModuleBase { def vfModuleName = execution.getVariable('DCVFM_vfModuleName') AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + - "/vf-modules/vf-module?vf-module-name=" + UriUtils.encode(vfModuleName, "UTF-8") - msoLogger.debug("AAI endPoint: " + endPoint) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULES, vnfId).queryParam("vf-module-name",vfModuleName) + String endPoint = aaiUriUtil.createAaiUri(uri) try { RESTConfig config = new RESTConfig(endPoint); @@ -755,7 +759,7 @@ public class DoCreateVfModule extends VfModuleBase { def vfModuleId = utils.getNodeText(vfModuleText, "vf-module-id") execution.setVariable("DCVFM_vfModuleId", vfModuleId) msoLogger.debug("Received orchestration status from A&AI: " + orchestrationStatus) - + } } } catch (Exception ex) { @@ -774,7 +778,7 @@ public class DoCreateVfModule extends VfModuleBase { public void preProcessSDNCAssignRequest(DelegateExecution execution){ - + execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED preProcessSDNCAssignRequest") def vnfId = execution.getVariable("DCVFM_vnfId") @@ -801,30 +805,30 @@ public class DoCreateVfModule extends VfModuleBase { msoLogger.debug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest) }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Occurred Processing preProcessSDNCAssignRequest", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Occurred Processing preProcessSDNCAssignRequest", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareProvision Method:\n" + e.getMessage()) } msoLogger.trace("COMPLETED preProcessSDNCAssignRequest") } public void preProcessSDNCGetRequest(DelegateExecution execution, String element){ - + String sdncVersion = execution.getVariable("DCVFM_sdncVersion") execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED preProcessSDNCGetRequest Process") try{ def serviceInstanceId = execution.getVariable('DCVFM_serviceInstanceId') - + String uuid = execution.getVariable('testReqId') // for junits if(uuid==null){ uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() } - + def callbackUrl = execution.getVariable("DCVFM_sdncCallbackUrl") msoLogger.debug("callbackUrl:" + callbackUrl) - + def vfModuleId = execution.getVariable('DCVFM_vfModuleId') - + def svcInstId = "" if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { svcInstId = vfModuleId @@ -832,7 +836,7 @@ public class DoCreateVfModule extends VfModuleBase { else { svcInstId = serviceInstanceId } - + def msoAction = "" if (!sdncVersion.equals("1707")) { msoAction = "mobility" @@ -840,33 +844,36 @@ public class DoCreateVfModule extends VfModuleBase { else { msoAction = "vfmodule" } - // For VNF, serviceOperation (URI for topology GET) will be retrieved from "selflink" element - // in the response from GenericGetVnf + // For VNF, serviceOperation (URI for topology GET) will be retrieved from "selflink" element // For VF Module, in 1707 serviceOperation will be retrieved from "object-path" element // in SDNC Assign Response // For VF Module for older versions, serviceOperation is constructed using vfModuleId - + String serviceOperation = "" if (element.equals("vnf")) { - def vnfQueryResponse = execution.getVariable("DCVFM_vnfQueryResponse") - serviceOperation = utils.getNodeText(vnfQueryResponse, "selflink") + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable('DCVFM_vnfId')) + AAIResultWrapper wrapper = resourceClient.get(uri) + + Optional<GenericVnf> vnf = wrapper.asBean(GenericVnf.class) + serviceOperation = vnf.get().getSelflink() msoLogger.debug("VNF - service operation: " + serviceOperation) } else if (element.equals("vfmodule")) { String response = execution.getVariable("DCVFM_assignSDNCAdapterResponse") - msoLogger.debug("DCVFM_assignSDNCAdapterResponse is: \n" + response) - + msoLogger.debug("DCVFM_assignSDNCAdapterResponse is: \n" + response) + if (!sdncVersion.equals("1707")) { serviceOperation = "/VNF-API:vnfs/vnf-list/" + vfModuleId msoLogger.debug("VF Module with sdncVersion before 1707 - service operation: " + serviceOperation) } - else { - String data = utils.getNodeXml(response, "response-data") + else { + String data = utils.getNodeXml(response, "response-data") msoLogger.debug("responseData: " + data) serviceOperation = utils.getNodeText(data, "object-path") msoLogger.debug("VF Module with sdncVersion of 1707 - service operation: " + serviceOperation) - } - } + } + } //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE sleep(5000) @@ -890,7 +897,7 @@ public class DoCreateVfModule extends VfModuleBase { msoLogger.debug("Outgoing GetSDNCRequest is: \n" + SDNCGetRequest) }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage()) } msoLogger.trace("COMPLETED preProcessSDNCGetRequest Process") @@ -901,7 +908,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.VNFAdapterCreateVfModule(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) //def xml = execution.getVariable("DoCreateVfModuleRequest") @@ -952,7 +959,7 @@ public class DoCreateVfModule extends VfModuleBase { String workloadContext = execution.getVariable("DCVFM_workloadContext") msoLogger.debug("workloadContext: " + workloadContext) msoLogger.debug("environmentContext: " + environmentContext) - + def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis() @@ -972,9 +979,9 @@ public class DoCreateVfModule extends VfModuleBase { String vfModuleSdncGetResponse = execution.getVariable('DCVFM_getSDNCAdapterResponse') msoLogger.debug("sdncGetResponse: " + vfModuleSdncGetResponse) def sdncVersion = execution.getVariable("sdncVersion") - + if (!sdncVersion.equals("1707")) { - + vfModuleParams = buildVfModuleParams(vnfParamsMap, vfModuleSdncGetResponse, vnfId, vnfName, vfModuleId, vfModuleName, vfModuleIndex, environmentContext, workloadContext) } @@ -982,9 +989,9 @@ public class DoCreateVfModule extends VfModuleBase { //Get SDNC Response Data for Vnf Topology String vnfSdncGetResponse = execution.getVariable('DCVFM_getVnfSDNCAdapterResponse') msoLogger.debug("vnfSdncGetResponse: " + vnfSdncGetResponse) - + vfModuleParams = buildVfModuleParamsFromCombinedTopologies(vnfParamsMap, vnfSdncGetResponse, vfModuleSdncGetResponse, vnfId, vnfName, - vfModuleId, vfModuleName, vfModuleIndex, environmentContext, workloadContext) + vfModuleId, vfModuleName, vfModuleIndex, environmentContext, workloadContext) } def svcInstId = "" @@ -1041,7 +1048,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.validateInfraRequest(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) String processKey = getProcessKey(execution); @@ -1103,7 +1110,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.isVolumeGroupIdPresent(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) def request = execution.getVariable('DoCreateVfModuleRequest') @@ -1124,7 +1131,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.isVolumeGroupNamePresent(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) def request = execution.getVariable('DoCreateVfModuleRequest') @@ -1187,9 +1194,9 @@ public class DoCreateVfModule extends VfModuleBase { }else{ sdncVNFParamsXml = "" } - + String sdncRequest = "" - + if (!sdncVersion.equals("1707")) { sdncRequest = @@ -1231,10 +1238,10 @@ public class DoCreateVfModule extends VfModuleBase { </vnf-request-information> </sdncadapterworkflow:SDNCRequestData> </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - + } - else { - + else { + sdncRequest = """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" @@ -1259,28 +1266,28 @@ public class DoCreateVfModule extends VfModuleBase { <subscription-service-type>${MsoUtils.xmlEscape(serviceId)}</subscription-service-type> ${serviceEcompModelInformation} <service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id> - <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id> - </service-information> + <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id> + </service-information> <vnf-information> <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type> - ${vnfEcompModelInformation} + ${vnfEcompModelInformation} </vnf-information> <vf-module-information> <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id> <vf-module-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vf-module-type> - ${vfModuleEcompModelInformation} + ${vfModuleEcompModelInformation} </vf-module-information> - <vf-module-request-input> + <vf-module-request-input> <vf-module-name>${MsoUtils.xmlEscape(vfModuleName)}</vf-module-name> <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant> - <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region> + <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region> ${sdncVNFParamsXml} </vf-module-request-input> </sdncadapterworkflow:SDNCRequestData> </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - + + /* sdncRequest = """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1" @@ -1303,30 +1310,30 @@ public class DoCreateVfModule extends VfModuleBase { <service-information> <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id> <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type> - ${serviceEcompModelInformation} + ${serviceEcompModelInformation} <service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id> <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id> </service-information> <vnf-information> <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type> - ${vnfEcompModelInformation} + ${vnfEcompModelInformation} </vnf-information> <vf-module-information> <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id> <vf-module-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vf-module-type> - ${vfModuleEcompModelInformation} + ${vfModuleEcompModelInformation} </vf-module-information> - <vf-module-request-input> + <vf-module-request-input> <vf-module-name>${MsoUtils.xmlEscape(vfModuleName)}</vf-module-name> <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant> - <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region> + <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region> ${sdncVNFParamsXml} - </vf-module-request-input> + </vf-module-request-input> </sdncadapterworkflow:SDNCRequestData> </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" */ - + } msoLogger.debug("sdncRequest: " + sdncRequest) @@ -1338,7 +1345,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED preProcessSDNCActivateRequest Process") @@ -1370,7 +1377,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.postProcessVNFAdapterRequest(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) execution.setVariable("prefix",Prefix) try{ @@ -1458,7 +1465,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.preProcessUpdateAAIVfModuleRequestOrch(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED preProcessUpdateAAIVfModuleRequestOrch") @@ -1471,7 +1478,7 @@ public class DoCreateVfModule extends VfModuleBase { if (!contrailServiceInstanceFqdn.equals("")) { setContrailServiceInstanceFqdn = true } - + execution.setVariable("DCVFM_orchestrationStatus", "Created") String updateAAIVfModuleRequest = buildUpdateAAIVfModuleRequest(execution, false, true, true, setContrailServiceInstanceFqdn) @@ -1481,18 +1488,18 @@ public class DoCreateVfModule extends VfModuleBase { msoLogger.debug("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest) }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessUpdateAAIVfModuleRequestOrch", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessUpdateAAIVfModuleRequestOrch", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessUpdateAAIVfModuleRequestOrch Method:\n" + e.getMessage()) } msoLogger.trace("COMPLETED preProcessUpdateAAIVfModuleRequestOrch") } - + public void preProcessUpdateAAIVfModuleRequestStatus(DelegateExecution execution, String status) { def method = getClass().getSimpleName() + '.preProcessUpdateAAIVfModuleStatus(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED preProcessUpdateAAIVfModuleStatus") @@ -1521,7 +1528,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.preProcessUpdateAAIVfModuleRequestGroup(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED preProcessUpdateAAIVfModuleRequestGroup") @@ -1537,7 +1544,7 @@ public class DoCreateVfModule extends VfModuleBase { msoLogger.debug("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest) }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessUpdateAAIVfModuleRequestGroup", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessUpdateAAIVfModuleRequestGroup", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessUpdateAAIVfModuleRequestGroup Method:\n" + e.getMessage()) } msoLogger.trace("COMPLETED preProcessUpdateAAIVfModuleRequestGroup") @@ -1545,7 +1552,7 @@ public class DoCreateVfModule extends VfModuleBase { } public void validateSDNCResponse(DelegateExecution execution, String response, String method){ - + execution.setVariable("prefix",Prefix) msoLogger.debug("STARTED ValidateSDNCResponse Process") @@ -1578,7 +1585,7 @@ public class DoCreateVfModule extends VfModuleBase { } public void preProcessUpdateAfterCreateRequest(DelegateExecution execution){ - + execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED preProcessRequest Process") try{ @@ -1684,25 +1691,25 @@ public class DoCreateVfModule extends VfModuleBase { } return params } - + public String buildCompleteSDNCParamsXml(DelegateExecution execution){ - + String params = "" StringBuilder sb = new StringBuilder() Map<String, String> paramsMap = execution.getVariable("DCVFM_vnfParamsMap") - + for (Map.Entry<String, String> entry : paramsMap.entrySet()) { String paramsXml - String key = entry.getKey(); + String key = entry.getKey(); String value = entry.getValue() - paramsXml = """<${key}>$value</$key>""" + paramsXml = """<${key}>$value</$key>""" params = sb.append(paramsXml) } return params } public void queryCloudRegion (DelegateExecution execution) { - + execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED queryCloudRegion") @@ -1710,13 +1717,12 @@ public class DoCreateVfModule extends VfModuleBase { String cloudRegion = execution.getVariable("DCVFM_cloudSiteId") // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) execution.setVariable("DCVFM_queryCloudRegionRequest", queryCloudRegionRequest) - msoLogger.debug("DCVFM_queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest) cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) @@ -1773,7 +1779,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.prepareCreateAAIVfModuleVolumeGroupRequest(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED prepareCreateAAIVfModuleVolumeGroupRequest") @@ -1787,12 +1793,14 @@ public class DoCreateVfModule extends VfModuleBase { def volumeGroupId = execution.getVariable("DCVFM_volumeGroupId") //def aicCloudRegion = execution.getVariable("DCVFM_cloudSiteId") def aicCloudRegion = execution.getVariable("DCVFM_cloudRegionForVolume") + def cloudOwner = execution.getVariable("DCVFM_cloudOwner") String createAAIVfModuleVolumeGroupRequest = """<CreateAAIVfModuleVolumeGroupRequest> <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id> <volume-group-id>${MsoUtils.xmlEscape(volumeGroupId)}</volume-group-id> <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region> + <cloud-owner>${MsoUtils.xmlEscape(cloudOwner)}</cloud-owner> </CreateAAIVfModuleVolumeGroupRequest>""" createAAIVfModuleVolumeGroupRequest = utils.formatXml(createAAIVfModuleVolumeGroupRequest) @@ -1811,7 +1819,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.createNetworkPoliciesInAAI(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) execution.setVariable("prefix", Prefix) msoLogger.trace("STARTED createNetworkPoliciesInAAI") @@ -1825,109 +1833,81 @@ public class DoCreateVfModule extends VfModuleBase { execution.setVariable("DCVFM_networkPolicyFqdnCount", fqdnCount) msoLogger.debug("DCVFM_networkPolicyFqdnCount - " + fqdnCount) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) - - if (fqdnCount > 0) { - - // AII loop call over contrail network policy fqdn list - for (i in 0..fqdnCount-1) { - - int counting = i+1 - String fqdn = fqdnList[i] - - // Query AAI for this network policy FQDN - - String queryNetworkPolicyByFqdnAAIRequest = "${aai_endpoint}${aai_uri}?network-policy-fqdn=" + UriUtils.encode(fqdn, "UTF-8") - - def aaiRequestId = UUID.randomUUID().toString() - RESTConfig config = new RESTConfig(queryNetworkPolicyByFqdnAAIRequest); - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", aaiRequestId) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - APIResponse response = client.get() - int returnCode = response.getStatusCode() - execution.setVariable("DCVFM_aaiQqueryNetworkPolicyByFqdnReturnCode", returnCode) - msoLogger.debug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (isOneOf(returnCode, 200, 201)) { - msoLogger.debug("The return code is: " + returnCode) - // This network policy FQDN already exists in AAI - execution.setVariable("DCVFM_queryNetworkPolicyByFqdnAAIResponse", aaiResponseAsString) - msoLogger.debug(" QueryAAINetworkPolicyByFQDN Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString) - - } else { - if (returnCode == 404) { - // This network policy FQDN is not in AAI yet. Add it now - msoLogger.debug("The return code is: " + returnCode) - msoLogger.debug("This network policy FQDN is not in AAI yet: " + fqdn) - // Add the network policy with this FQDN to AAI - def networkPolicyId = UUID.randomUUID().toString() - msoLogger.debug("Adding network-policy with network-policy-id " + networkPolicyId) - - String aaiNamespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) - msoLogger.debug('AAI namespace is: ' + aaiNamespace) - String payload = """<network-policy xmlns="${aaiNamespace}"> + + if (fqdnCount > 0) { + + // AII loop call over contrail network policy fqdn list + for (i in 0..fqdnCount-1) { + + int counting = i+1 + String fqdn = fqdnList[i] + + // Query AAI for this network policy FQDN + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + uri.queryParam("network-policy-fqdn", fqdn) + + AAIResourcesClient resourceClient = new AAIResourcesClient() + + + if (resourceClient.exists(uri)) { + + msoLogger.debug(" QueryAAINetworkPolicyByFQDN Success REST Response, , NetworkPolicy #" + counting) + + } else { + // This network policy FQDN is not in AAI yet. Add it now + msoLogger.debug("This network policy FQDN is not in AAI yet: " + fqdn) + // Add the network policy with this FQDN to AAI + def networkPolicyId = UUID.randomUUID().toString() + msoLogger.debug("Adding network-policy with network-policy-id " + networkPolicyId) + + String aaiNamespace = aaiUriUtil.getNamespace() + msoLogger.debug('AAI namespace is: ' + aaiNamespace) + String payload = """<network-policy xmlns="${aaiNamespace}"> <network-policy-id>${MsoUtils.xmlEscape(networkPolicyId)}</network-policy-id> <network-policy-fqdn>${MsoUtils.xmlEscape(fqdn)}</network-policy-fqdn> <heat-stack-id>${MsoUtils.xmlEscape(execution.getVariable("DCVFM_heatStackId"))}</heat-stack-id> </network-policy>""" as String - execution.setVariable("DCVFM_addNetworkPolicyAAIRequestBody", payload) - - String addNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8") - msoLogger.debug("AAI request endpoint: " + addNetworkPolicyAAIRequest) - - def aaiRequestIdPut = UUID.randomUUID().toString() - RESTConfig configPut = new RESTConfig(addNetworkPolicyAAIRequest); - RESTClient clientPut = new RESTClient(configPut).addHeader("X-TransactionId", aaiRequestIdPut) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - msoLogger.debug("invoking PUT call to AAI with payload:"+System.lineSeparator()+payload) - APIResponse responsePut = clientPut.httpPut(payload) - int returnCodePut = responsePut.getStatusCode() - execution.setVariable("DCVFM_aaiAddNetworkPolicyReturnCode", returnCodePut) - msoLogger.debug(" ***** AAI add network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodePut) - - String aaiResponseAsStringPut = responsePut.getResponseBodyAsString() - if (isOneOf(returnCodePut, 200, 201)) { - msoLogger.debug("The return code from adding network policy is: " + returnCodePut) - // This network policy was created in AAI successfully - execution.setVariable("DCVFM_addNetworkPolicyAAIResponse", aaiResponseAsStringPut) - msoLogger.debug(" AddAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsStringPut) - rollbackData.put("VFMODULE", "rollbackCreateNetworkPoliciesAAI", "true") - rollbackData.put("VFMODULE", "contrailNetworkPolicyFqdn" + i, fqdn) - execution.setVariable("rollbackData", rollbackData) - - } else { - // aai all errors - String putErrorMessage = "Unable to add network-policy to AAI createNetworkPoliciesInAAI - " + returnCodePut - msoLogger.debug(putErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, putErrorMessage) - } - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = "Unexpected Response from createNetworkPoliciesInAAI - " + returnCode - msoLogger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } + execution.setVariable("DCVFM_addNetworkPolicyAAIRequestBody", payload) + + AAIResourceUri addUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId) + String addNetworkPolicyAAIRequest = aaiUriUtil.createAaiUri(addUri) + + msoLogger.debug("AAI request endpoint: " + addNetworkPolicyAAIRequest) + + def aaiRequestIdPut = UUID.randomUUID().toString() + RESTConfig configPut = new RESTConfig(addNetworkPolicyAAIRequest); + RESTClient clientPut = new RESTClient(configPut).addHeader("X-TransactionId", aaiRequestIdPut) + .addHeader("X-FromAppId", "MSO") + .addHeader("Content-Type", "application/xml") + .addHeader("Accept","application/xml"); + msoLogger.debug("invoking PUT call to AAI with payload:"+System.lineSeparator()+payload) + APIResponse responsePut = clientPut.httpPut(payload) + int returnCodePut = responsePut.getStatusCode() + execution.setVariable("DCVFM_aaiAddNetworkPolicyReturnCode", returnCodePut) + msoLogger.debug(" ***** AAI add network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodePut) + + String aaiResponseAsStringPut = responsePut.getResponseBodyAsString() + if (isOneOf(returnCodePut, 200, 201)) { + msoLogger.debug("The return code from adding network policy is: " + returnCodePut) + // This network policy was created in AAI successfully + execution.setVariable("DCVFM_addNetworkPolicyAAIResponse", aaiResponseAsStringPut) + msoLogger.debug(" AddAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsStringPut) + rollbackData.put("VFMODULE", "rollbackCreateNetworkPoliciesAAI", "true") + rollbackData.put("VFMODULE", "contrailNetworkPolicyFqdn" + i, fqdn) + execution.setVariable("rollbackData", rollbackData) + + } else { + // aai all errors + String putErrorMessage = "Unable to add network-policy to AAI createNetworkPoliciesInAAI - " + returnCodePut + msoLogger.debug(putErrorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, putErrorMessage) + } + + } - } // end loop + } // end loop } else { @@ -1955,7 +1935,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) try { @@ -2008,7 +1988,7 @@ public class DoCreateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.postProcessUpdateAAIGenericVnf(' + 'execution=' + execution.getId() + ')' - + msoLogger.trace('Entered ' + method) try { @@ -2040,37 +2020,37 @@ public class DoCreateVfModule extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in postProcessUpdateAAIGenericVnf(): ' + e.getMessage()) } } - + public void queryCatalogDB (DelegateExecution execution) { - + String msg = "" msoLogger.trace("queryCatalogDB ") try { boolean twoPhaseDesign = false // check for input - + String vfModuleModelName = execution.getVariable("DCVFM_vfModuleModelName") msoLogger.debug("vfModuleModelName: " + vfModuleModelName) def vnfModelInfo = execution.getVariable("vnfModelInfo") def vnfModelCustomizationUuid = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid") - - msoLogger.debug("vnfModelCustomizationUuid: " + vnfModelCustomizationUuid) - + + msoLogger.debug("vnfModelCustomizationUuid: " + vnfModelCustomizationUuid) + JSONArray vnfs = catalog.getAllVnfsByVnfModelCustomizationUuid(execution, vnfModelCustomizationUuid, "v2") - - msoLogger.debug("Incoming Query Catalog DB for Vnf Response is: " + vnfModelCustomizationUuid) + + msoLogger.debug("Incoming Query Catalog DB for Vnf Response is: " + vnfModelCustomizationUuid) // Only one match here if (vnfs != null) { JSONObject vnfObject = vnfs.get(0) if (vnfObject != null) { String vnfJson = vnfObject.toString() // - ObjectMapper om = new ObjectMapper(); + ObjectMapper om = new ObjectMapper(); VnfResource vnf = om.readValue(vnfJson, VnfResource.class); - + // Get multiStageDesign flag - + String multiStageDesignValue = vnf.getMultiStageDesign() msoLogger.debug("multiStageDesign value from Catalog DB is: " + multiStageDesignValue) if (multiStageDesignValue != null) { @@ -2080,10 +2060,10 @@ public class DoCreateVfModule extends VfModuleBase { } } } - + msoLogger.debug("setting twoPhaseDesign flag to: " + twoPhaseDesign) - - execution.setVariable("DCVFM_twoPhaseDesign", twoPhaseDesign) + + execution.setVariable("DCVFM_twoPhaseDesign", twoPhaseDesign) } catch (BpmnError e) { throw e; } catch (Exception e) { @@ -2091,13 +2071,13 @@ public class DoCreateVfModule extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryCatalogDB(): ' + e.getMessage()) } } - - + + public void preProcessRollback (DelegateExecution execution) { msoLogger.trace("preProcessRollback") try { - + Object workflowException = execution.getVariable("WorkflowException"); if (workflowException instanceof WorkflowException) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy index a0b7dabb32..a553127c5c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy @@ -28,6 +28,10 @@ import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.aai.AAIObjectPlurals +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.rest.APIResponse @@ -477,9 +481,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ execution.setVariable(Prefix + "networkPolicyFqdnCount", fqdnCount) msoLogger.debug("networkPolicyFqdnCount - " + fqdnCount) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) if (fqdnCount > 0) { // AII loop call over contrail network policy fqdn list @@ -489,8 +491,10 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ String fqdn = fqdnList[i] // Query AAI for this network policy FQDN + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + uri.queryParam("network-policy-fqdn", fqdn) + String queryNetworkPolicyByFqdnAAIRequest = aaiUriUtil.createAaiUri(uri) - String queryNetworkPolicyByFqdnAAIRequest = "${aai_endpoint}${aai_uri}?network-policy-fqdn=" + UriUtils.encode(fqdn, "UTF-8") msoLogger.debug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest) def aaiRequestId = UUID.randomUUID().toString() @@ -514,8 +518,9 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ def resourceVersion = utils.getNodeText(aaiResponseAsString, "resource-version") msoLogger.debug("Deleting network-policy with resource-version " + resourceVersion) - String delNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8") + - "?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8") + AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId) + delUri.resourceVersion(resourceVersion) + String delNetworkPolicyAAIRequest = aaiUriUtil.createAaiUri(delUri) msoLogger.debug("AAI request endpoint: " + delNetworkPolicyAAIRequest) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy index 5995b6b099..3b0707a529 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy @@ -7,9 +7,9 @@ * 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. @@ -38,6 +38,11 @@ import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIObjectPlurals +import org.onap.so.constants.Defaults import org.onap.so.rest.APIResponse import org.springframework.web.util.UriUtils import org.onap.so.logger.MsoLogger @@ -46,14 +51,14 @@ import org.onap.so.logger.MessageEnum public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVfModuleVolumeRollback.class); - + String Prefix="DCVFMODVOLRBK_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() VidUtils vidUtils = new VidUtils(this) def className = getClass().getSimpleName() - + /** * This method is executed during the preProcessRequest task of the <class>DoCreateVfModuleVolumeRollback.bpmn</class> process. * @param execution @@ -80,7 +85,7 @@ public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor InitializeProcessVariables(execution) // rollbackData.put("DCVFMODULEVOL", "aiccloudregion", cloudSiteId) RollbackData rollbackData = execution.getVariable("rollbackData") - + // String vnfId = rollbackData.get("DCVFMODULEVOL", "vnfid") // execution.setVariable("DCVFMODVOLRBK_vnfId", vnfId) // String vfModuleId = rollbackData.get("DCVFMODULEVOL", "vfmoduleid") @@ -107,47 +112,48 @@ public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor // execution.setVariable("DCVFMODVOLRBK_heatStackId", heatStackId) // String requestId = rollbackData.get("DCVFMODULEVOL", "msorequestid") // execution.setVariable("DCVFMODVOLRBK_requestId", requestId) - + String volumeGroupName = rollbackData.get("DCVFMODULEVOL", "volumeGroupName") execution.setVariable("DCVFMODVOLRBK_volumeGroupName", volumeGroupName) String lcpCloudRegionId = rollbackData.get("DCVFMODULEVOL", "aiccloudregion") execution.setVariable("DCVFMODVOLRBK_lcpCloudRegionId", lcpCloudRegionId) - + execution.setVariable("DCVFMODVOLRBK_rollbackVnfARequest", rollbackData.get("DCVFMODULEVOL", "rollbackVnfARequest")) execution.setVariable("DCVFMODVOLRBK_backoutOnFailure", rollbackData.get("DCVFMODULEVOL", "backoutOnFailure")) execution.setVariable("DCVFMODVOLRBK_isCreateVnfRollbackNeeded", rollbackData.get("DCVFMODULEVOL", "isCreateVnfRollbackNeeded")) execution.setVariable("DCVFMODVOLRBK_isAAIRollbackNeeded", rollbackData.get("DCVFMODULEVOL", "isAAIRollbackNeeded")) } - + /** * Query AAI volume group by name * @param execution * @param isDebugEnabled */ public void callRESTQueryAAIVolGrpName(DelegateExecution execution, isDebugEnabled) { - + def volumeGroupName = execution.getVariable('DCVFMODVOLRBK_volumeGroupName') def cloudRegion = execution.getVariable('DCVFMODVOLRBK_lcpCloudRegionId') - + // This is for stub testing def testVolumeGroupName = execution.getVariable('test-volume-group-name') if (testVolumeGroupName != null && testVolumeGroupName.length() > 0) { volumeGroupName = testVolumeGroupName } - + AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String queryAAIVolumeNameRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups" + "?volume-group-name=" + UriUtils.encode(volumeGroupName, 'UTF-8') + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion).queryParam("volume-group-name", volumeGroupName) + def queryAAIVolumeNameRequest = aaiUtil.createAaiUri(uri) msoLogger.debug('Query AAI volume group by name: ' + queryAAIVolumeNameRequest) - + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeNameRequest) - + String returnCode = response.getStatusCode() String aaiResponseAsString = response.getResponseBodyAsString() - + msoLogger.debug("AAI query volume group by name return code: " + returnCode) msoLogger.debug("AAI query volume group by name response: " + aaiResponseAsString) @@ -171,31 +177,32 @@ public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor } } } - - - + + + public void callRESTDeleteAAIVolumeGroup(DelegateExecution execution, isDebugEnabled) { callRESTQueryAAIVolGrpName(execution, isDebugEnabled) - + def queryAaiVolumeGroupResponse = execution.getVariable(prefix+'queryAAIVolGrpNameResponse') - + def volumeGroupId = utils.getNodeText(queryAaiVolumeGroupResponse, "volume-group-id") def resourceVersion = utils.getNodeText(queryAaiVolumeGroupResponse, "resource-version") def cloudRegion = execution.getVariable("DCVFMODVOLRBK_lcpCloudRegionId") - + AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String deleteAAIVolumeGrpIdRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups/volume-group" + '/' + volumeGroupId + "?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8") + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId).queryParam("resource-version", resourceVersion) + def deleteAAIVolumeGrpIdRequest = aaiUtil.createAaiUri(uri) msoLogger.debug('Delete AAI volume group : ' + deleteAAIVolumeGrpIdRequest) - + APIResponse response = aaiUtil.executeAAIDeleteCall(execution, deleteAAIVolumeGrpIdRequest) - + String returnCode = response.getStatusCode() String aaiResponseAsString = response.getResponseBodyAsString() - + msoLogger.debug("AAI delete volume group return code: " + returnCode) msoLogger.debug("AAI delete volume group response: " + aaiResponseAsString) @@ -219,18 +226,18 @@ public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor // ******************************* - + public void processJavaException(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) - + try{ msoLogger.debug("Caught a Java Exception in " + Prefix) msoLogger.debug("Started processJavaException Method") msoLogger.debug("Variables List: " + execution.getVariables()) execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") - + }catch(Exception e){ msoLogger.debug("Caught Exception during processJavaException Method: " + e) execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy index f87f32c610..cf5c214d3f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy @@ -37,10 +37,12 @@ import org.onap.so.rest.APIResponse import org.springframework.web.util.UriUtils import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIObjectPlurals import org.onap.so.client.aai.entities.AAIResultWrapper import org.onap.so.client.aai.entities.Relationships import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.constants.Defaults import org.json.JSONObject import javax.ws.rs.NotFoundException @@ -82,7 +84,9 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { if (cloudSiteId == null) { String cloudConfiguration = execution.getVariable("cloudConfiguration") cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.lcpCloudRegionId") + def cloudOwner = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.cloudOwner") execution.setVariable("lcpCloudRegionId", cloudSiteId) + execution.setVariable("cloudOwner", cloudOwner) } // Extract attributes from modelInfo @@ -171,10 +175,9 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { msoLogger.debug('Request cloud region is: ' + cloudRegion) AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String queryCloudRegionRequest = aaiEndpoint + '/' + cloudRegion - msoLogger.debug(queryCloudRegionRequest) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) @@ -220,8 +223,9 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { } AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String queryAAIVolumeNameRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups" + "?volume-group-name=" + UriUtils.encode(volumeGroupName, 'UTF-8') + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion).queryParam("volume-group-name", volumeGroupName) + def queryAAIVolumeNameRequest = aaiUtil.createAaiUri(uri) msoLogger.debug('Query AAI volume group by name: ' + queryAAIVolumeNameRequest) @@ -292,7 +296,7 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { def vnfType = execution.getVariable("vnfType") def tenantId = execution.getVariable("tenantId") def cloudRegion = execution.getVariable('lcpCloudRegionId') - + def cloudOwner = execution.getVariable('cloudOwner') msoLogger.debug("volumeGroupId: " + volumeGroupId) def testGroupId = execution.getVariable('test-volume-group-id') @@ -305,16 +309,17 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { msoLogger.debug("volumeGroupId to be used: " + volumeGroupId) AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String createAAIVolumeGrpNameUrlRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, "UTF-8") - String namespace = aaiUtil.getNamespaceFromUri(aaiUtil.getCloudInfrastructureCloudRegionUri(execution)) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId) + def createAAIVolumeGrpNameUrlRequest = aaiUtil.createAaiUri(uri) + + String namespace = aaiUtil.getNamespaceFromUri(createAAIVolumeGrpNameUrlRequest) msoLogger.debug("AAI namespace is: " + namespace) msoLogger.debug("Request URL for PUT: " + createAAIVolumeGrpNameUrlRequest) NetworkUtils networkUtils = new NetworkUtils() - String payload = networkUtils.createCloudRegionVolumeRequest(volumeGroupId, volumeName, vnfType, vnfId, tenantId, cloudRegion, namespace, modelCustomizationId) + String payload = networkUtils.createCloudRegionVolumeRequest(volumeGroupId, volumeName, vnfType, vnfId, tenantId, cloudOwner, cloudRegion, namespace, modelCustomizationId) String payloadXml = utils.formatXml(payload) msoLogger.debug("Request payload for PUT: " + payloadXml) @@ -541,10 +546,11 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { String cloudRegion = execution.getVariable("lcpCloudRegionId") AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String updateAAIVolumeGroupUrlRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, 'UTF-8') - String namespace = aaiUtil.getNamespaceFromUri(aaiUtil.getCloudInfrastructureCloudRegionUri(execution)) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId) + def updateAAIVolumeGroupUrlRequest = aaiUtil.createAaiUri(uri) + + String namespace = aaiUtil.getNamespaceFromUri(updateAAIVolumeGroupUrlRequest) msoLogger.debug("updateAAIVolumeGroupUrlRequest - " + updateAAIVolumeGroupUrlRequest) @@ -595,11 +601,11 @@ class DoCreateVfModuleVolumeV2 extends VfModuleBase { def vnfId = execution.getVariable('vnfId') AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getNetworkGenericVnfEndpoint(execution) - def String queryAAIRequest = aaiEndpoint + "/" + UriUtils.encode(vnfId, "UTF-8") - - msoLogger.debug("AAI query generic vnf request: " + queryAAIRequest) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + String queryAAIRequest = aaiUtil.createAaiUri(uri) + msoLogger.debug("AAI query generic vnf endpoint: " + queryAAIRequest) + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest) String returnCode = response.getStatusCode() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy index 1585a7bb74..b35aab1176 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy @@ -24,6 +24,7 @@ import static org.apache.commons.lang3.StringUtils.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.GenericVnf import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -105,7 +106,13 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { String vnfName = execution.getVariable("vnfName") if (vnfName.equals("") || vnfName.equals("null")) { - vnfName = null + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable("vnfId")) + if(resourceClient.exists(uri)){ + exceptionUtil.buildWorkflowException(execution, 5000, "Generic Vnf Already Exist.") + } + + } execution.setVariable("DoCVNF_vnfName", vnfName) msoLogger.debug("Incoming Vnf Name is: " + vnfName) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy index 3ee059cb02..3812c081f5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy @@ -7,9 +7,9 @@ * 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. @@ -33,6 +33,11 @@ import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils +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.client.graphinventory.entities.uri.Depth +import org.onap.so.constants.Defaults import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse; @@ -44,7 +49,7 @@ import groovy.json.* public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteNetworkInstance.class); - + String Prefix= "DELNWKI_" String groovyClassName = "DoDeleteNetworkInstance" ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -93,13 +98,13 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "deactivateSDNCResponse", "") execution.setVariable(Prefix + "deactivateSdncReturnCode", "") execution.setVariable(Prefix + "isSdncDeactivateRollbackNeeded", "") - + execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", "") execution.setVariable(Prefix + "isException", false) - + } - + // ************************************************** // Pre or Prepare Request Section // ************************************************** @@ -112,19 +117,19 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { // initialize flow variables InitializeProcessVariables(execution) - + try { // get incoming message/input execution.setVariable("action", "DELETE") String deleteNetwork = execution.getVariable("bpmnRequest") if (deleteNetwork != null) { if (deleteNetwork.contains("requestDetails")) { - // JSON format request is sent, create xml + // JSON format request is sent, create xml try { def prettyJson = JsonOutput.prettyPrint(deleteNetwork.toString()) msoLogger.debug(" Incoming message formatted . . . : " + '\n' + prettyJson) deleteNetwork = vidUtils.createXmlNetworkRequestInfra(execution, deleteNetwork) - + } catch (Exception ex) { String dataErrorMessage = " Invalid json format Request - " + ex.getMessage() msoLogger.debug(dataErrorMessage) @@ -132,26 +137,26 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } } else { // XML format request is sent - + } } else { // vIPR format request is sent, create xml from individual variables deleteNetwork = vidUtils.createXmlNetworkRequestInstance(execution) } - + deleteNetwork = utils.formatXml(deleteNetwork) msoLogger.debug(deleteNetwork) execution.setVariable(Prefix + "networkRequest", deleteNetwork) msoLogger.debug(Prefix + "networkRequest - " + '\n' + deleteNetwork) - + // validate 'backout-on-failure' to override 'mso.rollback' boolean rollbackEnabled = networkUtils.isRollbackEnabled(execution, deleteNetwork) execution.setVariable(Prefix + "rollbackEnabled", rollbackEnabled) msoLogger.debug(Prefix + "rollbackEnabled - " + rollbackEnabled) - + String networkInputs = utils.getNodeXml(deleteNetwork, "network-inputs", false).replace("tag0:","").replace(":tag0","") execution.setVariable(Prefix + "networkInputs", networkInputs) - + // prepare messageId String messageId = execution.getVariable("testMessageId") // for testing if (messageId == null || messageId == "") { @@ -161,11 +166,11 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { msoLogger.debug(Prefix + "messageId, pre-assigned: " + messageId) } execution.setVariable(Prefix + "messageId", messageId) - + String source = utils.getNodeText(deleteNetwork, "source") execution.setVariable(Prefix + "source", source) msoLogger.debug(Prefix + "source - " + source) - + String networkId = "" if (utils.nodeExists(networkInputs, "network-id")) { networkId = utils.getNodeText(networkInputs, "network-id") @@ -188,7 +193,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion) msoLogger.debug("lcpCloudRegion : " + lcpCloudRegion) - + String tenantId = null if (utils.nodeExists(networkInputs, "tenant-id")) { tenantId = utils.getNodeText(networkInputs, "tenant-id") @@ -199,18 +204,18 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } execution.setVariable(Prefix + "tenantId", tenantId) msoLogger.debug("tenantId : " + tenantId) - + String sdncVersion = execution.getVariable("sdncVersion") msoLogger.debug("sdncVersion? : " + sdncVersion) - + // PO Authorization Info / headers Authorization= String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) - + try { def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey", execution)) execution.setVariable("BasicAuthHeaderValuePO",encodedString) execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) - + } catch (IOException ex) { String dataErrorMessage = " Unable to encode PO/SDNC user/password string - " + ex.getMessage() msoLogger.debug(dataErrorMessage ) @@ -227,7 +232,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) } - + } @@ -243,10 +248,11 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { networkId = UriUtils.encode(networkId,"UTF-8") // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String queryAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) + uri.depth(Depth.ALL) + + String queryAAIRequest = aaiUriUtil.createAaiUri(uri) msoLogger.debug(queryAAIRequest) execution.setVariable(Prefix + "queryAAIRequest", queryAAIRequest) msoLogger.debug(Prefix + "AAIRequest - " + "\n" + queryAAIRequest) @@ -279,7 +285,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { exceptionUtil.buildWorkflowException(execution, 2500, relationshipMessage) } else { - // verify if lcpCloudRegion was sent as input, if not get value from AAI Response + // verify if lcpCloudRegion was sent as input, if not get value from AAI Response if (execution.getVariable(Prefix + "lcpCloudRegion") == null ) { String lcpCloudRegion = networkUtils.getCloudRegion(aaiResponseAsString) execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion) @@ -290,7 +296,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "tenantId", tenantId) msoLogger.debug(" Get AAI getTenantId() : " + tenantId) } - + } } msoLogger.debug(Prefix + "isVfRelationshipExist - " + isVfRelationshipExist) @@ -339,15 +345,13 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { String networkInputs = execution.getVariable(Prefix + "networkInputs") // String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") String cloudRegion = execution.getVariable(Prefix + "lcpCloudRegion") - cloudRegion = UriUtils.encode(cloudRegion,"UTF-8") // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion - msoLogger.debug(queryCloudRegionRequest) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) + execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) - msoLogger.debug(Prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest) String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) @@ -392,7 +396,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { String networkType = utils.getNodeText(queryAAIResponse, "network-type") String networkId = utils.getNodeText(queryAAIResponse, "network-id") String backoutOnFailure = execution.getVariable(Prefix + "rollbackEnabled") - + String networkStackId = "" networkStackId = utils.getNodeText(queryAAIResponse, "heat-stack-id") if (networkStackId == 'null' || networkStackId == "" || networkStackId == null) { @@ -412,14 +416,14 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { String notificationUrl = "" //TODO - is this coming from URN? What variable/value to use? //String notificationUrl = execution.getVariable("URN_?????") //TODO - is this coming from URN? What variable/value to use? - String modelCustomizationUuid = "" + String modelCustomizationUuid = "" if (utils.nodeExists(networkRequest, "networkModelInfo")) { String networkModelInfo = utils.getNodeXml(networkRequest, "networkModelInfo", false).replace("tag0:","").replace(":tag0","") modelCustomizationUuid = utils.getNodeText(networkModelInfo, "modelCustomizationUuid") } else { modelCustomizationUuid = utils.getNodeText(networkRequest, "modelCustomizationId") } - + String deleteNetworkRequest = """ <deleteNetworkRequest> <cloudSiteId>${MsoUtils.xmlEscape(cloudSiteId)}</cloudSiteId> @@ -515,7 +519,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { networkId = utils.getNodeText(deleteNetworkInput, "network-id") } if (networkId == 'null') {networkId = ""} - + String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") // get/set 'msoRequestId' and 'mso-request-id' @@ -524,11 +528,11 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable("mso-request-id", requestId) } else { requestId = execution.getVariable("mso-request-id") - } + } execution.setVariable(Prefix + "requestId", requestId) msoLogger.debug(Prefix + "requestId " + requestId) String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse") - + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") // 1. prepare delete topology via SDNC Adapter SUBFLOW call @@ -567,7 +571,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { if (networkId == 'null') {networkId = ""} String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") - + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") // 1. prepare delete topology via SDNC Adapter SUBFLOW call @@ -587,8 +591,8 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } } - - + + public void prepareRpcSDNCDeactivate(DelegateExecution execution) { execution.setVariable("prefix",Prefix) @@ -596,7 +600,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { msoLogger.trace("Inside prepareRpcSDNCDeactivate() of DoDeleteNetworkInstance ") try { - + // get variables String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") @@ -607,7 +611,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } if (networkId == 'null') {networkId = ""} String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") - + String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "deactivate", "DeleteNetworkInstance", cloudRegionId, networkId, null) String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) execution.setVariable(Prefix + "deactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString) @@ -622,7 +626,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } } - + // ************************************************** // Post or Validate Response Section // ************************************************** @@ -640,7 +644,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { msoLogger.debug(" Network Adapter responseCode: " + returnCode) msoLogger.debug("Network Adapter Response - " + "\n" + networkResponse) msoLogger.debug(networkResponse) - + String errorMessage = "" if (returnCode == "200") { msoLogger.debug(" Network Adapter Response is successful - " + "\n" + networkResponse) @@ -658,9 +662,9 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { String rollbackNetworkXml = utils.formatXml(rollbackNetwork) execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkXml) msoLogger.debug(" Network Adapter rollback data - " + "\n" + rollbackNetworkXml) - } - - + } + + } else { // network error if (returnCode.toInteger() > 399 && returnCode.toInteger() < 600) { //4xx, 5xx if (networkResponse.contains("deleteNetworkError") ) { @@ -756,7 +760,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } } - + public void prepareRpcSDNCDeactivateRollback(DelegateExecution execution) { execution.setVariable("prefix",Prefix) @@ -764,7 +768,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { msoLogger.trace("Inside prepareRpcSDNCDeactivateRollback() of DoDeleteNetworkInstance ") try { - + // get variables String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") @@ -789,43 +793,43 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } } - + public void prepareRollbackData(DelegateExecution execution) { execution.setVariable("prefix",Prefix) - + msoLogger.trace("Inside prepareRollbackData() of DoDeleteNetworkInstance ") - + try { - + Map<String, String> rollbackData = new HashMap<String, String>(); String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") if (rollbackNetworkRequest != null) { if (rollbackNetworkRequest != "") { rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) } - } + } String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest") if (rollbackDeactivateSDNCRequest != null) { if (rollbackDeactivateSDNCRequest != "") { rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")) } - } + } execution.setVariable("rollbackData", rollbackData) msoLogger.debug("** rollbackData : " + rollbackData) - + execution.setVariable("WorkflowException", execution.getVariable("WorkflowException")) msoLogger.debug("** WorkflowException : " + execution.getVariable("WorkflowException")) - + } catch (Exception ex) { String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRollbackData() - " + ex.getMessage() msoLogger.debug(exceptionMessage) exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - + } - + } - + public void postProcessResponse (DelegateExecution execution) { execution.setVariable("prefix", Prefix) @@ -833,7 +837,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { msoLogger.trace("Inside postProcessResponse of DoDeleteNetworkInstance ") try { - + msoLogger.debug(" ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException")) if (execution.getVariable(Prefix + "isException") == false) { execution.setVariable(Prefix + "Success", true) @@ -841,10 +845,10 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { if (execution.getVariable(Prefix + "isSilentSuccess") == true) { execution.setVariable("rolledBack", false) } else { - execution.setVariable("rolledBack", true) + execution.setVariable("rolledBack", true) } prepareSuccessRollbackData(execution) // populate rollbackData - + } else { execution.setVariable(Prefix + "Success", false) execution.setVariable("rollbackData", null) @@ -864,25 +868,25 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } } } - + // going to the Main flow: a-la-carte or macro msoLogger.debug(" ***** postProcessResponse(), BAD !!!") exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) throw new BpmnError("MSOWorkflowException") - - } - + + } + } catch(BpmnError b){ msoLogger.debug("Rethrowing MSOWorkflowException") throw b - + } catch (Exception ex) { // caught exception String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, postProcessResponse() - " + ex.getMessage() msoLogger.debug(exceptionMessage) exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) throw new BpmnError("MSOWorkflowException") - + } } @@ -890,18 +894,18 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { public void prepareSuccessRollbackData(DelegateExecution execution) { execution.setVariable("prefix",Prefix) - + msoLogger.trace("Inside prepareSuccessRollbackData() of DoDeleteNetworkInstance ") - + try { - + if (execution.getVariable("sdncVersion") != '1610') { prepareRpcSDNCDeactivateRollback(execution) prepareRpcSDNCUnassignRollback(execution) } else { prepareSDNCRollback(execution) - } - + } + Map<String, String> rollbackData = new HashMap<String, String>(); String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") if (rollbackSDNCRequest != null) { @@ -914,26 +918,26 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { if (rollbackNetworkRequest != "") { rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) } - } + } String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest") if (rollbackDeactivateSDNCRequest != null) { if (rollbackDeactivateSDNCRequest != "") { rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")) } - } + } execution.setVariable("rollbackData", rollbackData) - + msoLogger.debug("** rollbackData : " + rollbackData) execution.setVariable("WorkflowException", null) - + } catch (Exception ex) { String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage() msoLogger.debug(exceptionMessage) exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - + } - + } public void prepareRpcSDNCUnassignRollback(DelegateExecution execution) { @@ -943,7 +947,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { msoLogger.trace("Inside prepareRpcSDNCUnassignRollbac() of DoDeleteNetworkInstance ") try { - + // get variables String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") @@ -952,7 +956,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { String networkId = utils.getNodeText(deleteSDNCResponse, "network-id") if (networkId == 'null') {networkId = ""} String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") - + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") // 1. prepare delete topology via SDNC Adapter SUBFLOW call @@ -962,7 +966,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyDeleteRequesAsString) msoLogger.debug(Prefix + "rollbackSDNCRequest" + "\n" + sndcTopologyDeleteRequesAsString) msoLogger.debug(" Preparing request for RPC SDNC Topology 'assign-CreateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyDeleteRequesAsString) - + } catch (Exception ex) { String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCUnassignRollback() - " + ex.getMessage() @@ -972,7 +976,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } } - + public void prepareSDNCRollback (DelegateExecution execution) { execution.setVariable("prefix", Prefix) @@ -980,7 +984,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { msoLogger.trace("Inside prepareSDNCRollback of DoDeleteNetworkInstance ") try { - + // get variables String sdncCallback = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") @@ -990,7 +994,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { networkId = utils.getNodeText(deleteNetworkInput, "network-id") } if (networkId == 'null') {networkId = ""} - + String serviceInstanceId = utils.getNodeText(deleteNetworkInput, "service-instance-id") // get/set 'msoRequestId' and 'mso-request-id' @@ -999,11 +1003,11 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable("mso-request-id", requestId) } else { requestId = execution.getVariable("mso-request-id") - } + } execution.setVariable(Prefix + "requestId", requestId) - + String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse") - + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") // 1. prepare delete topology via SDNC Adapter SUBFLOW call @@ -1025,33 +1029,33 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } } - + public void setExceptionFlag(DelegateExecution execution){ execution.setVariable("prefix",Prefix) - + msoLogger.trace("Inside setExceptionFlag() of DoDeleteNetworkInstance ") - + try { execution.setVariable(Prefix + "isException", true) - + if (execution.getVariable("SavedWorkflowException1") != null) { execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) } else { execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) } msoLogger.debug(Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException")) - + } catch(Exception ex){ String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance flow. setExceptionFlag(): " + ex.getMessage() msoLogger.debug(exceptionMessage) exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) } - + } - - + + // ******************************* // Build Error Section // ******************************* @@ -1065,7 +1069,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { msoLogger.debug("Variables List: " + execution.getVariables()) execution.setVariable("UnexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") - + }catch(Exception e){ msoLogger.debug("Caught Exception during processJavaException Method: " + e) execution.setVariable("UnexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy index b41b74e509..1a3e8aa4e6 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy @@ -34,6 +34,10 @@ import org.onap.so.bpmn.common.scripts.VfModule import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.aai.AAIObjectPlurals +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.rest.APIResponse @@ -470,9 +474,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("DoDVfMod_networkPolicyFqdnCount", fqdnCount) msoLogger.debug("DoDVfMod_networkPolicyFqdnCount - " + fqdnCount) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) if (fqdnCount > 0) { // AII loop call over contrail network policy fqdn list @@ -482,10 +484,10 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ String fqdn = fqdnList[i] // Query AAI for this network policy FQDN - - String queryNetworkPolicyByFqdnAAIRequest = "${aai_endpoint}${aai_uri}?network-policy-fqdn=" + UriUtils.encode(fqdn, "UTF-8") + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + uri.queryParam("network-policy-fqdn", fqdn) + String queryNetworkPolicyByFqdnAAIRequest = aaiUriUtil.createAaiUri(uri) msoLogger.debug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest) - msoLogger.debug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest) APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyByFqdnAAIRequest) int returnCode = response.getStatusCode() @@ -508,9 +510,10 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ def resourceVersion = utils.getNodeText(aaiResponseAsString, "resource-version") msoLogger.debug("Deleting network-policy with resource-version " + resourceVersion) - String delNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8") + - "?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8") - msoLogger.debug("AAI request endpoint: " + delNetworkPolicyAAIRequest) + AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId) + delUri.resourceVersion(resourceVersion) + String delNetworkPolicyAAIRequest = aaiUriUtil.createAaiUri(delUri) + msoLogger.debug("AAI request endpoint: " + delNetworkPolicyAAIRequest) msoLogger.debug("invoking DELETE call to AAI") @@ -644,11 +647,9 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ def vfModuleId = execution.getVariable('vfModuleId') AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId) + String endPoint = aaiUriUtil.createAaiUri(uri) - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint",execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + - "/vf-modules/vf-module/" + UriUtils.encode(vfModuleId, "UTF-8") msoLogger.debug("AAI endPoint: " + endPoint) try { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy index 1024fc57da..d90c316832 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy @@ -33,6 +33,11 @@ import org.onap.so.bpmn.common.scripts.VfModuleBase import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.graphinventory.entities.uri.Depth +import org.onap.so.client.aai.AAIObjectPlurals +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.rest.APIResponse @@ -129,10 +134,9 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { def vnfId = execution.getVariable('vnfId') AaiUtil aaiUriUtil = new AaiUtil(this) - def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + + String endPoint = aaiUriUtil.createAaiUri(uri) msoLogger.debug("DoDeleteVfModuleFromVnf: AAI endPoint : " + endPoint) @@ -490,9 +494,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { execution.setVariable("DDVFMV_networkPolicyFqdnCount", fqdnCount) msoLogger.debug("DDVFMV_networkPolicyFqdnCount - " + fqdnCount) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) if (fqdnCount > 0) { // AII loop call over contrail network policy fqdn list @@ -503,10 +505,12 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { // Query AAI for this network policy FQDN - String queryNetworkPolicyByFqdnAAIRequest = "${aai_endpoint}${aai_uri}?network-policy-fqdn=" + UriUtils.encode(fqdn, "UTF-8") + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY) + uri.queryParam("network-policy-fqdn", fqdn) + String queryNetworkPolicyByFqdnAAIRequest = aaiUriUtil.createAaiUri(uri) + msoLogger.debug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest) - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyByFqdnAAIRequest) int returnCode = response.getStatusCode() execution.setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", returnCode) @@ -528,8 +532,10 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { def resourceVersion = utils.getNodeText(aaiResponseAsString, "resource-version") msoLogger.debug("Deleting network-policy with resource-version " + resourceVersion) - String delNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8") + - "?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8") + AAIResourceUri delUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId) + delUri.resourceVersion(resourceVersion) + String delNetworkPolicyAAIRequest = aaiUriUtil.createAaiUri(delUri) + msoLogger.debug("AAI request endpoint: " + delNetworkPolicyAAIRequest) msoLogger.debug("invoking DELETE call to AAI") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy index b1cef477be..03e47cf141 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy @@ -7,9 +7,9 @@ * 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. @@ -30,31 +30,35 @@ import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.UrnPropertiesReader; import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.constants.Defaults import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse import org.springframework.web.util.UriUtils class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteVfModuleVolumeV2.class); - + String prefix="DDVMV_" ExceptionUtil exceptionUtil = new ExceptionUtil() XmlParser xmlParser = new XmlParser() JsonUtils jsonUtil = new JsonUtils() - + @Override public void preProcessRequest(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - preProcessRequest(execution, isDebugEnabled) + preProcessRequest(execution, isDebugEnabled) } - + /** * Set default variable values * @param execution * @param isDebugLogEnabled */ public void preProcessRequest (DelegateExecution execution, isDebugEnabled) { - + //Input: // msoRequestId // isDebugLogEnabled @@ -71,13 +75,13 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ // workflowException @TODO: actual variable name is WorkflowException // rolledBack // wasDeleted - + execution.setVariable('prefix', prefix) execution.setVariable('wasDeleted', 'false') - + def tenantId = execution.getVariable("tenantId") def cloudSiteId = execution.getVariable("lcpCloudRegionId") - + // if tenantId or lcpCloudregionId is not passed, get it from cloudRegionConfiguration variable if(!tenantId || !cloudSiteId) { def cloudConfiguration = execution.getVariable("cloudConfiguration") @@ -86,10 +90,12 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ execution.setVariable("tenantId", tenantId) cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "lcpCloudRegionId") execution.setVariable("lcpCloudRegionId", cloudSiteId) + cloudOwner = jsonUtil.getJsonValue(cloudConfiguration, "cloudOwner") + execution.setVariable("cloudOwner", cloudOwner) } } - - + + /** * Set out 'wasDeleted' variable to 'true' * @param execution @@ -98,8 +104,8 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ public void postProcess(DelegateExecution execution, isDebugLogEnabled) { execution.setVariable('wasDeleted', 'true') } - - + + /** * Query and set cloud region to use for AAI calls * Output variables: prefix+'aicCloudRegion', prefix+'cloudRegion' @@ -107,14 +113,12 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ * @param isDebugEnabled */ public void callRESTQueryAAICloudRegion(DelegateExecution execution, isDebugEnabled) { - - String cloudRegion = execution.getVariable('lcpCloudRegionId') - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint",execution) + + String cloudRegion = execution.getVariable('lcpCloudRegionId') AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion - msoLogger.debug(queryCloudRegionRequest) - msoLogger.debug("AAI query cloud region URI - " + queryCloudRegionRequest) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) @@ -125,14 +129,14 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ else{ execution.setVariable(prefix+"aicCloudRegion", cloudRegion) } - } + } else { msoLogger.debug("AAI Query Cloud Region Unsuccessful.") exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable(prefix+"queryCloudRegionReturnCode")) } } - - + + /** * Query AAI Volume Group * Output variables: prefix+'queryAAIVolGrpResponse'; prefix+'volumeGroupHeatStackId' @@ -140,9 +144,9 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ * @param isDebugLogEnabled */ public void callRESTQueryAAIForVolumeGroup(DelegateExecution execution, isDebugLogEnabled) { - - def tenantId = execution.getVariable('tenantId') - def volumeGroupId = execution.getVariable('volumeGroupId') + + def tenantId = execution.getVariable('tenantId') + def volumeGroupId = execution.getVariable('volumeGroupId') if(volumeGroupId == null) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, 'volumeGroupId is not provided in the request') throw new Exception('volume-group-id is not provided in the request') @@ -150,8 +154,9 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ String cloudRegion = execution.getVariable(prefix+'aicCloudRegion') AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String queryAAIVolumeGroupRequest = aaiEndpoint + '/' + URLEncoder.encode(cloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, "UTF-8") + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, volumeGroupId) + def queryAAIVolumeGroupRequest = aaiUtil.createAaiUri(uri) msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest) msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest) @@ -174,7 +179,7 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ execution.setVariable(prefix+'volumeGroupHeatStackId', heatStackId) msoLogger.debug('Heat stack id from AAI response: ' + heatStackId) - + if(hasVfModuleRelationship(aaiResponseAsString)){ msoLogger.debug('Volume Group ' + volumeGroupId + ' currently in use') exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} currently in use - found vf-module relationship.") @@ -182,12 +187,12 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ def volumeGroupTenantId = getTenantIdFromVolumeGroup(aaiResponseAsString) msoLogger.debug('Tenant ID from AAI response: ' + volumeGroupTenantId) - + if (volumeGroupTenantId == null) { msoLogger.debug("Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}") exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}") } - + if (volumeGroupTenantId != tenantId) { def String errorMessage = 'TenantId ' + tenantId + ' in incoming request does not match Tenant Id ' + volumeGroupTenantId + ' retrieved from AAI for Volume Group Id ' + volumeGroupId msoLogger.debug("Error in DeleteVfModuleVolume: " + errorMessage) @@ -206,7 +211,7 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ } } } - + /** * Format VNF Adapter subflow request XML * Variables: prefix+'deleteVnfARequest' @@ -216,7 +221,7 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ public void prepareVnfAdapterDeleteRequest(DelegateExecution execution, isDebugLogEnabled) { def cloudRegion = execution.getVariable(prefix+'aicCloudRegion') def tenantId = execution.getVariable('tenantId') // input parameter (optional) - see preProcessRequest - def volumeGroupId = execution.getVariable('volumeGroupId') // input parameter (required) + def volumeGroupId = execution.getVariable('volumeGroupId') // input parameter (required) def volumeGroupHeatStackId = execution.getVariable(prefix+'volumeGroupHeatStackId') // from AAI query volume group def requestId = execution.getVariable('msoRequestId') // input parameter (required) def serviceId = execution.getVariable('serviceInstanceId') // imput parameter (optional) @@ -247,30 +252,27 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ execution.setVariable(prefix+'deleteVnfARequest', vnfAdapterRestRequest) msoLogger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest) } - - + + /** * Delete volume group in AAI * @param execution * @param isDebugEnabled */ public void callRESTDeleteAAIVolumeGroup(DelegateExecution execution, isDebugEnabled) { - + // get variables String queryAAIVolGrpIdResponse = execution.getVariable(prefix+"queryAAIVolGrpResponse") String groupId = utils.getNodeText(queryAAIVolGrpIdResponse, "volume-group-id") String resourceVersion = utils.getNodeText(queryAAIVolGrpIdResponse, "resource-version") - + String messageId = UUID.randomUUID().toString() String cloudRegion = execution.getVariable(prefix+'aicCloudRegion') AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String deleteAAIVolumeGrpIdRequest = aaiEndpoint + '/' + URLEncoder.encode(cloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(groupId, "UTF-8") - if(resourceVersion !=null){ - deleteAAIVolumeGrpIdRequest = deleteAAIVolumeGrpIdRequest +'?resource-version=' + UriUtils.encode(resourceVersion, 'UTF-8') - } + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegion, groupId).queryParam("resource-version", resourceVersion) + def deleteAAIVolumeGrpIdRequest = aaiUtil.createAaiUri(uri) msoLogger.debug('Delete AAI volume group : ' + deleteAAIVolumeGrpIdRequest) msoLogger.debug("Delete AAI volume group : " + deleteAAIVolumeGrpIdRequest) @@ -297,8 +299,8 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ } } } - - + + /** * Check if volume group has a relationship to vf-module * @param volumeGroupXml @@ -322,7 +324,7 @@ class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor{ return false } - + /** * Extract the Tenant Id from the Volume Group information returned by AAI. * @param volumeGroupXml Volume Group XML returned by AAI. diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy index 699e9bf40a..456a9cfabf 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnf.groovy @@ -27,12 +27,15 @@ import javax.xml.parsers.DocumentBuilderFactory import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.GenericVnf import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.graphinventory.entities.uri.Depth; import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.AAIResultWrapper import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.w3c.dom.Document @@ -80,8 +83,6 @@ class DoDeleteVnf extends AbstractServiceTaskProcessor { execution.setVariable("DoDVNF_vnfId", vnfId) msoLogger.debug("Incoming Vnf(Instance) Id is: " + vnfId) - // Setting for sub flow calls - execution.setVariable("DoDVNF_type", "generic-vnf") }catch(BpmnError b){ msoLogger.debug("Rethrowing MSOWorkflowException") throw b @@ -94,49 +95,42 @@ class DoDeleteVnf extends AbstractServiceTaskProcessor { } - public void processGetVnfResponse(DelegateExecution execution){ + public void getVnf(DelegateExecution execution){ execution.setVariable("prefix",Prefix) - msoLogger.trace("STARTED DoDeleteVnf processGetVnfResponse Process ") + msoLogger.trace("STARTED DoDeleteVnf getVnf Process ") try { - String vnf = execution.getVariable("DoDVNF_genericVnf") - String resourceVersion = utils.getNodeText(vnf, "resource-version") - execution.setVariable("DoDVNF_resourceVersion", resourceVersion) - - if(utils.nodeExists(vnf, "relationship")){ - InputSource source = new InputSource(new StringReader(vnf)); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = docFactory.newDocumentBuilder() - Document vnfXml = docBuilder.parse(source) - - NodeList nodeList = vnfXml.getElementsByTagName("relationship") - for (int x = 0; x < nodeList.getLength(); x++) { - Node node = nodeList.item(x) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - def e = eElement.getElementsByTagName("related-to").item(0).getTextContent() - if(e.equals("volume-group") || e.equals("l3-network")){ - msoLogger.debug("Generic Vnf still has relationship to OpenStack.") - execution.setVariable("DoDVNF_vnfInUse", true) - }else{ - msoLogger.debug("Relationship NOT related to OpenStack") - } + + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, execution.getVariable('vnfId')) + + if(resourceClient.exists(uri)){ + execution.setVariable("GENGV_FoundIndicator", true) + AAIResultWrapper wrapper = resourceClient.get(uri.depth(Depth.ONE)) + if(wrapper.getRelationships().isPresent()){ + List<AAIResourceUri> relationships = wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.CLOUD_REGION) + relationships.addAll(wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.L3_NETWORK)) + if(!relationships.isEmpty()){ + execution.setVariable("DoDVNF_vnfInUse", true) + }else{ + msoLogger.debug("Relationship NOT related to OpenStack") } } - } - if(utils.nodeExists(vnf, "vf-module")){ - execution.setVariable("DoDVNF_vnfInUse", true) - msoLogger.debug("Generic Vnf still has vf-modules.") + Optional<GenericVnf> vnf = wrapper.asBean(GenericVnf.class) + if(!vnf.get().getVfModules().getVfModule().isEmpty()){ + execution.setVariable("DoDVNF_vnfInUse", true) + } + }else{ + execution.setVariable("GENGV_FoundIndicator", false) } - } catch (Exception ex) { - msoLogger.debug("Error Occured in DoDeleteVnf processGetVnfResponse Process " + ex.getMessage()) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoDeleteVnf processGetVnfResponse Process") + msoLogger.debug("Error Occured in DoDeleteVnf getVnf Process " + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoDeleteVnf getVnf Process") } - msoLogger.trace("COMPLETED DoDeleteVnf processGetVnfResponse Process ") + msoLogger.trace("COMPLETED DoDeleteVnf getVnf Process ") } /** diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy index d448dd3e79..ddf2706635 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy @@ -39,6 +39,10 @@ import org.onap.so.bpmn.core.domain.ModuleResource import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.graphinventory.entities.uri.Depth +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.client.aai.AAIObjectType import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse @@ -255,10 +259,9 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { def vnfId = execution.getVariable('vnfId') AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + String endPoint = aaiUriUtil.createAaiUri(uri) + msoLogger.debug("AAI endPoint: " + endPoint) try { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy index cb50fbbee6..5b7fdb2c22 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy @@ -32,6 +32,11 @@ import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.domain.Resource import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.springframework.web.util.UriUtils; import groovy.json.* @@ -269,11 +274,8 @@ public class DoUpdateE2EServiceInstance extends AbstractServiceTaskProcessor { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") utils.log("INFO","Entered " + method, isDebugEnabled) String msg = "" - utils.log("INFO"," ***** preProcessAAIPUT *****", isDebugEnabled) - String serviceInstanceVersion = execution.getVariable("serviceInstanceVersion") - //execution.setVariable("GENPS_serviceResourceVersion", serviceInstanceVersion) //requestDetails.modelInfo.for AAI PUT servieInstanceData //requestDetails.requestInfo. for AAI GET/PUT serviceInstanceData @@ -285,71 +287,48 @@ public class DoUpdateE2EServiceInstance extends AbstractServiceTaskProcessor { String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("modelUuid") + org.onap.aai.domain.yang.ServiceInstance si = new org.onap.aai.domain.yang.ServiceInstance() + si.setServiceInstanceId(serviceInstanceId) + si.setServiceInstanceName(serviceInstanceName) + si.setServiceType(aaiServiceType) + si.setServiceRole(aaiServiceRole) + si.setModelInvariantId(modelInvariantUuid) + si.setModelVersionId(modelUuid) - AaiUtil aaiUriUtil = new AaiUtil(this) - utils.log("INFO","start create aai uri: " + aaiUriUtil, isDebugEnabled) - String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) - utils.log("INFO","aai_uri: " + aai_uri, isDebugEnabled) - String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) - utils.log("INFO","namespace: " + namespace, isDebugEnabled) - - //update target model to aai - String serviceInstanceData = - """<service-instance xmlns=\"${namespace}\"> - <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id> - <service-instance-name>${MsoUtils.xmlEscape(serviceInstanceName)}</service-instance-name> - <service-type>${MsoUtils.xmlEscape(aaiServiceType)}</service-type> - <service-role>${MsoUtils.xmlEscape(aaiServiceRole)}</service-role> - <resource-version>${MsoUtils.xmlEscape(serviceInstanceVersion)}</resource-version> - <model-invariant-id>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-id> - <model-version-id>${MsoUtils.xmlEscape(modelUuid)}</model-version-id> - </service-instance>""".trim() - - execution.setVariable("serviceInstanceData", serviceInstanceData) - utils.log("INFO","serviceInstanceData: " + serviceInstanceData, isDebugEnabled) - utils.logAudit(serviceInstanceData) - utils.log("INFO", " aai_uri " + aai_uri + " namespace:" + namespace, isDebugEnabled) - utils.log("INFO", " 'payload' to update Service Instance in AAI - " + "\n" + serviceInstanceData, isDebugEnabled) + execution.setVariable("serviceInstanceData", si) utils.log("INFO", "Exited " + method, isDebugEnabled) } - public void postProcessAAIPUT(DelegateExecution execution) { + public void updateServiceInstance(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** postProcessAAIPUT ***** ", isDebugEnabled) + utils.log("INFO"," ***** createServiceInstance ***** ", isDebugEnabled) String msg = "" + String serviceInstanceId = execution.getVariable("serviceInstanceId") try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator") - if(!succInAAI){ - utils.log("INFO","Error putting Service-instance in AAI", + serviceInstanceId, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - } - else - { - //start rollback set up - RollbackData rollbackData = new RollbackData() - def disableRollback = execution.getVariable("disableRollback") - rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) - rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") - rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId) - rollbackData.put("SERVICEINSTANCE", "serviceType", execution.getVariable("serviceType")) - rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) - execution.setVariable("rollbackData", rollbackData) - } + org.onap.aai.domain.yang.ServiceInstance si = execution.getVariable("serviceInstanceData") + + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + client.update(uri, si) } catch (BpmnError e) { throw e; } catch (Exception ex) { - msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage() + RollbackData rollbackData = new RollbackData() + def disableRollback = execution.getVariable("disableRollback") + rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) + rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") + rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId) + rollbackData.put("SERVICEINSTANCE", "serviceType", execution.getVariable("serviceType")) + rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) + execution.setVariable("rollbackData", rollbackData) + + msg = "Exception in DoCreateServiceInstance.createServiceInstance. " + ex.getMessage() utils.log("INFO", msg, isDebugEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - utils.log("INFO"," *** Exit postProcessAAIPUT *** ", isDebugEnabled) + utils.log("INFO"," *** Exit createServiceInstance *** ", isDebugEnabled) } public void preProcessRollback (DelegateExecution execution) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy index 257142e8bd..949a566711 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy @@ -25,9 +25,16 @@ import static org.apache.commons.lang3.StringUtils.*; import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.logger.MsoLogger import org.onap.so.bpmn.common.scripts.ExceptionUtil; import groovy.json.* @@ -210,61 +217,38 @@ public class DoUpdateE2EServiceInstanceRollback extends AbstractServiceTaskProce String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelUuid = execution.getVariable("model-version-id-original") - //AAI PUT - AaiUtil aaiUriUtil = new AaiUtil(this) - utils.log("INFO","start create aai uri: " + aaiUriUtil, isDebugEnabled) - String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) - utils.log("INFO","aai_uri: " + aai_uri, isDebugEnabled) - String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) - utils.log("INFO","namespace: " + namespace, isDebugEnabled) - - String serviceInstanceData = - """<service-instance xmlns=\"${namespace}\"> - <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id> - <service-instance-name>${MsoUtils.xmlEscape(serviceInstanceName)}</service-instance-name> - <service-type>${MsoUtils.xmlEscape(aaiServiceType)}</service-type> - <service-role>${MsoUtils.xmlEscape(aaiServiceRole)}</service-role> - <resource-version>${MsoUtils.xmlEscape(serviceInstanceVersion)}</resource-version> - <model-invariant-id>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-id> - <model-version-id>${MsoUtils.xmlEscape(modelUuid)}</model-version-id> - </service-instance>""".trim() - - execution.setVariable("serviceInstanceData", serviceInstanceData) - msoLogger.info("serviceInstanceData: " + serviceInstanceData) - msoLogger.debug(serviceInstanceData) - msoLogger.info(" aai_uri " + aai_uri + " namespace:" + namespace) - msoLogger.info(" 'payload' to update Service Instance in AAI - " + "\n" + serviceInstanceData) + org.onap.aai.domain.yang.ServiceInstance si = new org.onap.aai.domain.yang.ServiceInstance() + si.setServiceInstanceId(serviceInstanceId) + si.setServiceInstanceName(serviceInstanceName) + si.setServiceType(aaiServiceType) + si.setServiceRole(aaiServiceRole) + si.setModelInvariantId(modelInvariantUuid) + si.setModelVersionId(modelUuid) + + execution.setVariable("serviceInstanceData", si) msoLogger.info("Exited " + method) } - public void postProcessAAIPUT(DelegateExecution execution) { - msoLogger.trace("postProcessAAIPUT ") + public void updateServiceInstance(DelegateExecution execution) { + msoLogger.trace("updateServiceInstance ") String msg = "" try { String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator") - if(!succInAAI){ - msoLogger.info("Error putting Service-instance in AAI", + serviceInstanceId) - WorkflowException workflowException = execution.getVariable("WorkflowException") - msoLogger.debug("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - } - else - { + org.onap.aai.domain.yang.ServiceInstance si = execution.getVariable("serviceInstanceData") - } + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + client.update(uri, si) } catch (BpmnError e) { throw e; } catch (Exception ex) { - msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage() + msg = "Exception in DoCreateServiceInstance.updateServiceInstance. " + ex.getMessage() msoLogger.info(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - msoLogger.trace("Exit postProcessAAIPUT ") + msoLogger.trace("Exit updateServiceInstance ") } public void processRollbackException(DelegateExecution execution){ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy index d7f2087c05..dbacd48809 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy @@ -20,6 +20,8 @@ package org.onap.so.bpmn.infrastructure.scripts; +import javax.ws.rs.core.UriBuilder + import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution @@ -33,17 +35,18 @@ import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.logger.MsoLogger -import org.onap.so.rest.APIResponse -import org.springframework.web.util.UriUtils - -import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.AAIObjectType -import org.onap.so.client.aai.entities.AAIResultWrapper -import org.onap.so.client.aai.entities.Relationships +import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.json.JSONObject +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.graphinventory.entities.uri.Depth +import org.onap.so.constants.Defaults +import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.springframework.web.util.UriUtils +import org.onap.aai.domain.yang.VpnBinding +import org.onap.aai.domain.yang.RouteTarget import javax.ws.rs.NotFoundException import groovy.json.* @@ -352,16 +355,15 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { try { String networkInputs = execution.getVariable(Prefix + "networkInputs") String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") - cloudRegion = UriUtils.encode(cloudRegion,"UTF-8") // Prepare AA&I url String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion - msoLogger.debug(queryCloudRegionRequest) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) + execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) - msoLogger.debug(" UPDNETI_queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest) String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) @@ -407,10 +409,11 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "networkId", networkId) // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String queryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) + uri.depth(Depth.ALL) + String queryIdAAIRequest = aaiUriUtil.createAaiUri(uri) + msoLogger.debug(queryIdAAIRequest) execution.setVariable(Prefix + "queryIdAAIRequest", queryIdAAIRequest) msoLogger.debug(Prefix + "queryIdAAIRequest - " + "\n" + queryIdAAIRequest) @@ -474,10 +477,11 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { networkId = UriUtils.encode(networkId,"UTF-8") // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String requeryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) + uri.depth(Depth.ALL) + String requeryIdAAIRequest = aaiUriUtil.createAaiUri(uri) + msoLogger.debug(requeryIdAAIRequest) execution.setVariable(Prefix + "requeryIdAAIRequest", requeryIdAAIRequest) msoLogger.debug(" UPDNETI_requeryIdAAIRequest - " + "\n" + requeryIdAAIRequest) @@ -557,93 +561,37 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "vpnCount", vpnCount) msoLogger.debug(" UPDNETI_vpnCount - " + vpnCount) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - AaiUtil aaiUriUtil = new AaiUtil(this) - if (vpnCount > 0) { execution.setVariable(Prefix + "vpnBindings", vpnBindingUri) msoLogger.debug(" vpnBindingUri List - " + vpnBindingUri) String routeTargets = "" // AII loop call using list vpnBindings - for (i in 0..vpnBindingUri.size()-1) { - + for(i in 0..vpnBindingUri.size()-1) { int counting = i+1 - // prepare url using vpnBinding - String queryVpnBindingAAIRequest = "" - String aai_uri = aaiUriUtil.getNetworkVpnBindingUri(execution) - - // Note: By default, the vpnBinding url is found in 'related-link' of the response, - // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. - if (aai_uri == null || aai_uri == "") { - // using value of 'related-link' from response - if (vpnBindingUri[i].charAt(vpnBindingUri[i].length()-1) == '/') { - queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i].substring(0, vpnBindingUri[i].length()-1) + "?depth=all" - } else { - queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i] + "?depth=all" - } - - } else { - // using uri value in URN mapping - String vpnBindingId = vpnBindingUri[i].substring(vpnBindingUri[i].indexOf("/vpn-binding/")+13, vpnBindingUri[i].length()) - if (vpnBindingId.charAt(vpnBindingId.length()-1) == '/') { - vpnBindingId = vpnBindingId.substring(0, vpnBindingId.length()-1) - } - queryVpnBindingAAIRequest = "${aai_endpoint}${aai_uri}/" + vpnBindingId + "?depth=all" + String vpnBindingId = vpnBindingUri[i].substring(vpnBindingUri[i].indexOf("/vpn-binding/")+13, vpnBindingUri[i].length()) + if (vpnBindingId.charAt(vpnBindingId.length()-1) == '/') { + vpnBindingId = vpnBindingId.substring(0, vpnBindingId.length()-1) } - msoLogger.debug(queryVpnBindingAAIRequest) - execution.setVariable(Prefix + "queryVpnBindingAAIRequest", queryVpnBindingAAIRequest) - msoLogger.debug(" UPDNETI_queryVpnBindingAAIRequest, , vpnBinding #" + counting + " : " + "\n" + queryVpnBindingAAIRequest) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryVpnBindingAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", returnCode) - msoLogger.debug(" ***** AAI query vpn binding Response Code, vpnBinding #" + counting + " : " + returnCode) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - msoLogger.debug(aaiResponseAsString) - execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiResponseAsString) - msoLogger.debug(" AAI Query Vpn Binding Success REST Response, , vpnBinding #" + counting + " : " + "\n" + aaiResponseAsString) - - String routeTarget = "" - String routeRole = "" - if (utils.nodeExists(aaiResponseAsString, "route-targets")) { - String aaiRouteTargets = utils.getNodeXml(aaiResponseAsString, "route-targets", false) - def aaiRouteTargetsXml = new XmlSlurper().parseText(aaiRouteTargets) - def aaiRouteTarget = aaiRouteTargetsXml.'**'.findAll {it.name() == "route-target"} - for (j in 0..aaiRouteTarget.size()-1) { - routeTarget = utils.getNodeText(XmlUtil.serialize(aaiRouteTarget[j]), "global-route-target") - routeRole = utils.getNodeText(XmlUtil.serialize(aaiRouteTarget[j]), "route-target-role") - routeTargets += "<routeTargets>" + '\n' + - " <routeTarget>" + routeTarget + "</routeTarget>" + '\n' + - " <routeTargetRole>" + routeRole + "</routeTargetRole>" + '\n' + - "</routeTargets>" + '\n' - } - } - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from AAINetworkVpnBinding is 404 (Not Found)." - msoLogger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = " Unexpected Response from AAINetworkVpnBinding - " + returnCode - msoLogger.debug(dataErrorMessage) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnBindingId) + AAIResultWrapper wrapper = resourceClient.get(uri.depth(Depth.TWO), NotFoundException.class) + + Optional<VpnBinding> binding = wrapper.asBean(VpnBinding.class) + + String routeTarget = "" + String routeRole = "" + if(binding.get().getRouteTargets() != null) { + List<RouteTarget> targets = binding.get().getRouteTargets().getRouteTarget() + for(RouteTarget target : targets) { + routeTarget = target.getGlobalRouteTarget() + routeRole = target.getRouteTargetRole() + routeTargets += "<routeTargets>" + '\n' + + " <routeTarget>" + routeTarget + "</routeTarget>" + '\n' + + " <routeTargetRole>" + routeRole + "</routeTargetRole>" + '\n' + + "</routeTargets>" + '\n' } } @@ -655,8 +603,8 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { } else { // reset return code to success execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + AaiUtil aaiUriUtil = new AaiUtil(this) + String schemaVersion = aaiUriUtil.getNamespace() String aaiStubResponse = """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> <vpn-binding xmlns="${schemaVersion}"> @@ -670,9 +618,9 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { } - } catch (BpmnError e) { - throw e; - + } catch (NotFoundException e) { + msoLogger.debug("Response Error from AAINetworkVpnBinding is 404 (Not Found).") + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Response Error from AAINetworkVpnBinding is 404 (Not Found).") } catch (Exception ex) { String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkVpnBinding() - " + ex.getMessage() msoLogger.debug(exceptionMessage) @@ -700,7 +648,6 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "networkPolicyCount", networkPolicyCount) msoLogger.debug(" UPDNETI_networkPolicyCount - " + networkPolicyCount) - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) if (networkPolicyCount > 0) { @@ -713,31 +660,11 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { int counting = i+1 - // prepare url using vpnBinding - String queryNetworkPolicyAAIRequest = "" - - String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) - - // Note: By default, the network policy url is found in 'related-link' of the response, - // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. - if (aai_uri == null || aai_uri == "") { - // using value of 'related-link' from response - if (networkPolicyUriList[i].charAt(networkPolicyUriList[i].length()-1) == '/') { - queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i].substring(0, networkPolicyUriList[i].length()-1) + "?depth=all" - } else { - queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i] + "?depth=all" - } - } else { - // using uri value in URN mapping - String networkPolicyId = networkPolicyUriList[i].substring(networkPolicyUriList[i].indexOf("/network-policy/")+16, networkPolicyUriList[i].length()) - println " networkPolicyId - " + networkPolicyId - if (networkPolicyId.charAt(networkPolicyId.length()-1) == '/') { - networkPolicyId = networkPolicyId.substring(0, networkPolicyId.length()-1) - } - queryNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + networkPolicyId + "?depth=all" - - } + URI uri = UriBuilder.fromUri(networkPolicyUriList[i]).build() + AAIResourceUri aaiUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.NETWORK_POLICY, uri) + aaiUri.depth(Depth.ALL) + String queryNetworkPolicyAAIRequest = aaiUriUtil.createAaiUri(aaiUri) msoLogger.debug(queryNetworkPolicyAAIRequest) execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest", queryNetworkPolicyAAIRequest) @@ -791,8 +718,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { } else { // reset return code to success execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String schemaVersion = aaiUriUtil.getNamespace() String aaiStubResponse = """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> <network-policy xmlns="${schemaVersion}"> @@ -850,30 +776,11 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { int counting = i+1 // prepare url using tableRef - String queryNetworkTableRefAAIRequest = "" - - String aai_uri = aaiUriUtil.getNetworkTableReferencesUri(execution) - - // Note: By default, the network policy url is found in 'related-link' of the response, - // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. - if (aai_uri == null || aai_uri == "") { - // using value of 'related-link' from response - if (networkTableRefUriList[i].charAt(networkTableRefUriList[i].length()-1) == '/') { - queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i].substring(0, networkTableRefUriList[i].length()-1) + "?depth=all" - } else { - queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i] + "?depth=all" - } - } else { - // using uri value in URN mapping - String networkTableRefId = networkTableRefUriList[i].substring(networkTableRefUriList[i].indexOf("/route-table-reference/")+23, networkTableRefUriList[i].length()) - - if (networkTableRefId.charAt(networkTableRefId.length()-1) == '/') { - networkTableRefId = networkTableRefId.substring(0, networkTableRefId.length()-1) - } - queryNetworkTableRefAAIRequest = "${aai_endpoint}${aai_uri}/" + networkTableRefId + "?depth=all" - - } + URI uri = UriBuilder.fromUri(networkTableRefUriList[i]).build() + AAIResourceUri aaiUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ROUTE_TABLE_REFERENCE, uri) + aaiUri.depth(Depth.ALL) + String queryNetworkTableRefAAIRequest = aaiUriUtil.createAaiUri(aaiUri) msoLogger.debug(queryNetworkTableRefAAIRequest) execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest", queryNetworkTableRefAAIRequest) @@ -927,8 +834,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { } else { // reset return code to success execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String schemaVersion = aaiUriUtil.getNamespace() String aaiStubResponse = """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> <route-table-references xmlns="${schemaVersion}"> @@ -969,17 +875,17 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { String updateNetworkResponse = execution.getVariable(Prefix + "updateNetworkResponse") // Prepare url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String updateContrailAAIUrlRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId) + uri.depth(Depth.ALL) + String updateContrailAAIUrlRequest = aaiUriUtil.createAaiUri(uri) msoLogger.debug(updateContrailAAIUrlRequest) execution.setVariable(Prefix + "updateContrailAAIUrlRequest", updateContrailAAIUrlRequest) msoLogger.debug(" UPDNETI_updateContrailAAIUrlRequest - " + "\n" + updateContrailAAIUrlRequest) //Prepare payload (PUT) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(updateContrailAAIUrlRequest) String payload = networkUtils.ContrailNetworkCreatedUpdate(requeryIdAAIResponse, updateNetworkResponse, schemaVersion) String payloadXml = utils.formatXml(payload) msoLogger.debug(payloadXml) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy index 451e0293ef..bce19795ac 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy @@ -7,9 +7,9 @@ * 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. @@ -33,11 +33,15 @@ import org.onap.so.bpmn.common.scripts.VfModuleBase import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.entities.AAIResultWrapper +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.aai.entities.uri.AAIResourceUri +import org.onap.so.constants.Defaults import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.rest.APIResponse @@ -111,56 +115,56 @@ public class DoUpdateVfModule extends VfModuleBase { def xml = getVariable(execution, 'DoUpdateVfModuleRequest') msoLogger.debug("DoUpdateVfModule request: " + xml) msoLogger.debug('Received request xml:\n' + xml) - + if (xml == null || xml.isEmpty()) { // Building Block-type request String cloudConfiguration = execution.getVariable("cloudConfiguration") String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") - + def serviceModelInfo = execution.getVariable("serviceModelInfo") msoLogger.debug("serviceModelInfo: " + serviceModelInfo) String modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid") msoLogger.debug("modelInvariantUuid: " + modelInvariantUuid) def vnfModelInfo = execution.getVariable("vnfModelInfo") - + //tenantId def tenantId = execution.getVariable("tenantId") execution.setVariable("DOUPVfMod_tenantId", tenantId) - + //volumeGroupId def volumeGroupId = execution.getVariable("volumeGroupId") execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId) - + //cloudSiteId def cloudSiteId = execution.getVariable("lcpCloudRegionId") execution.setVariable("DOUPVfMod_aicCloudRegion", cloudSiteId) - + msoLogger.debug("cloudSiteId: " + cloudSiteId) //vnfType def vnfType = execution.getVariable("vnfType") execution.setVariable("DOUPVfMod_vnfType", vnfType) - + msoLogger.debug("vnfType: " + vnfType) //vnfName def vnfName = execution.getVariable("vnfName") execution.setVariable("DOUPVfMod_vnfName", vnfName) - + msoLogger.debug("vnfName: " + vnfName) //vnfId def vnfId = execution.getVariable("vnfId") execution.setVariable("DOUPVfMod_vnfId", vnfId) - + msoLogger.debug("vnfId: " + vnfId) //vfModuleName def vfModuleName = execution.getVariable("vfModuleName") execution.setVariable("DOUPVfMod_vfModuleName", vfModuleName) - + msoLogger.debug("vfModuleName: " + vfModuleName) //vfModuleModelName def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName") execution.setVariable("DOUPVfMod_vfModuleModelName", vfModuleModelName) - + msoLogger.debug("vfModuleModelName: " + vfModuleModelName) //modelCustomizationUuid def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid") @@ -168,7 +172,7 @@ public class DoUpdateVfModule extends VfModuleBase { modelCustomizationUuid = "" } execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid) - + msoLogger.debug("modelCustomizationUuid: " + modelCustomizationUuid) //vfModuleId def vfModuleId = execution.getVariable("vfModuleId") @@ -186,12 +190,12 @@ public class DoUpdateVfModule extends VfModuleBase { //serviceInstanceId def serviceInstanceId = execution.getVariable("serviceInstanceId") execution.setVariable("DOUPVfMod_serviceInstanceId", serviceInstanceId) - + msoLogger.debug("serviceInstanceId: " + serviceInstanceId) //source - HARDCODED def source = "VID" execution.setVariable("DOUPVfMod_source", source) - + msoLogger.debug("source: " + source) //backoutOnFailure def disableRollback = execution.getVariable("disableRollback") @@ -239,16 +243,16 @@ public class DoUpdateVfModule extends VfModuleBase { String vnfQueryPath = execution.getVariable("vnfQueryPath") execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath) msoLogger.debug("vnfQueryPath: " + vnfQueryPath) - + Map<String,String> vfModuleInputParams = execution.getVariable("vfModuleInputParams") if (vfModuleInputParams != null) { - execution.setVariable("DOUPVfMod_vnfParamsMap", vfModuleInputParams) - } + execution.setVariable("DOUPVfMod_vnfParamsMap", vfModuleInputParams) + } //get workload and environment context from parent SI String environmentContext = "" String workloadContext ="" String serviceType ="" - + try{ String json = catalog.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid ) serviceType = jsonUtil.getJsonValue(json, "serviceResources.serviceType") @@ -259,7 +263,7 @@ public class DoUpdateVfModule extends VfModuleBase { msoLogger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - + try{ AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId) AAIResourcesClient aaiRC = new AAIResourcesClient() @@ -267,11 +271,11 @@ public class DoUpdateVfModule extends VfModuleBase { Map<String, Object> aaiJson = aaiRW.asMap() environmentContext = aaiJson.getOrDefault("environment-context","") workloadContext = aaiJson.getOrDefault("workload-context","") - + }catch (Exception ex) { msoLogger.debug("Error retreiving parent service instance information") } - + execution.setVariable("DCVFM_environmentContext",environmentContext) execution.setVariable("DCVFM_workloadContext",workloadContext) } @@ -285,7 +289,7 @@ public class DoUpdateVfModule extends VfModuleBase { serviceInstanceId = '' } execution.setVariable('DOUPVfMod_serviceInstanceId', serviceInstanceId) - + def vnfInputs = getRequiredNodeXml(execution, xml, 'vnf-inputs') execution.setVariable('DOUPVfMod_vnfInputs', vnfInputs) execution.setVariable('DOUPVfMod_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id')) @@ -306,14 +310,14 @@ public class DoUpdateVfModule extends VfModuleBase { execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule) } msoLogger.debug("isBaseVfModule: " + isBaseVfModule) - + NetworkUtils networkUtils = new NetworkUtils() def backoutOnFailure = networkUtils.isRollbackEnabled(execution, xml) execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure) - + def String vgi = getNodeTextForce(vnfInputs, 'volume-group-id') execution.setVariable('DOUPVfMod_volumeGroupId', vgi) - + execution.setVariable('DOUPVfMod_vnfParams', utils.getNodeXml(xml, 'vnf-params', false)) } @@ -382,7 +386,7 @@ public class DoUpdateVfModule extends VfModuleBase { def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' + 'execution=' + execution.getId() + ')' - + def prefix = execution.getVariable("prefix") msoLogger.trace('Entered ' + method) @@ -391,14 +395,12 @@ public class DoUpdateVfModule extends VfModuleBase { String cloudRegion = execution.getVariable(prefix + "aicCloudRegion") // Prepare AA&I url - String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion - msoLogger.debug("CloudRegion Request: " + queryCloudRegionRequest) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion) + def queryCloudRegionRequest = aaiUtil.createAaiUri(uri) execution.setVariable(prefix + "queryCloudRegionRequest", queryCloudRegionRequest) - msoLogger.debug(prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest) cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion) @@ -427,9 +429,9 @@ public class DoUpdateVfModule extends VfModuleBase { exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during prepConfirmVolumeGroupTenant(): " + e.getMessage()) } msoLogger.trace('Exited ' + method) - + } - + /** * Prepare a Request for invoking the SDNC Adapter subflow to perform * a VNF topology 'changeassign' operation. @@ -625,19 +627,19 @@ public class DoUpdateVfModule extends VfModuleBase { def asdcServiceModelVersion = execution.getVariable('DOUPVfMod_asdcServiceModelVersion') def modelCustomizationUuid = execution.getVariable('DOUPVfMod_modelCustomizationUuid') def backoutOnFailure = execution.getVariable("DOUPVfMod_backoutOnFailure") - + def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis() def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) if ('true'.equals(useQualifiedHostName)) { notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) } - + String environmentContext = execution.getVariable("DOUPVEnvironment_context") String workloadContext = execution.getVariable("DOUPVWorkload_context") msoLogger.debug("workloadContext: " + workloadContext) msoLogger.debug("environmentContext: " + environmentContext) - + Map<String, String> vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap") String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse') @@ -791,7 +793,7 @@ public class DoUpdateVfModule extends VfModuleBase { ${personaModelCustomizationIdElement} </UpdateAAIVfModuleRequest> """ - + msoLogger.debug('Unformatted updateAAIVfModuleRequest: ' + updateAAIVfModuleRequest) updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest) execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest) @@ -846,7 +848,7 @@ public class DoUpdateVfModule extends VfModuleBase { if (!usePreload) { modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>" } - + def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams') def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml) @@ -974,10 +976,10 @@ public class DoUpdateVfModule extends VfModuleBase { def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + String endPoint = aaiUriUtil.createAaiUri(uri) - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" msoLogger.debug("AAI endPoint: " + endPoint) try { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy index 6b42406883..afe01b9243 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy @@ -33,6 +33,11 @@ import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.domain.ModuleResource import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.graphinventory.entities.uri.Depth +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient +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.rest.APIResponse @@ -152,10 +157,8 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor { def vnfId = execution.getVariable('vnfId') AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - msoLogger.debug('AAI URI is: ' + aai_uri) - - String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE) + String endPoint = aaiUriUtil.createAaiUri(uri) msoLogger.debug("AAI endPoint: " + endPoint) try { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy index 8673ee7662..f45e97fa6e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy @@ -190,6 +190,8 @@ public class ReplaceVnfInfra extends VnfCmBase { execution.setVariable('cloudConfiguration', cloudConfiguration) def lcpCloudRegionId = jsonUtils.getJsonValue(cloudConfiguration, "lcpCloudRegionId") execution.setVariable('lcpCloudRegionId', lcpCloudRegionId) + def cloudOwner = jsonUtils.getJsonValue(cloudConfiguration, "cloudOwner") + execution.setVariable('cloudOwner', cloudOwner) def tenantId = jsonUtils.getJsonValue(cloudConfiguration, "tenantId") execution.setVariable('tenantId', tenantId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy index 416d0d6e60..566afb0d9c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy @@ -175,6 +175,10 @@ public class UpdateVfModuleInfra extends AbstractServiceTaskProcessor { def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId execution.setVariable(prefix + 'lcpCloudRegionId', lcpCloudRegionId) + + def cloudOwner = cloudConfiguration.cloudOwner + execution.setVariable(prefix + 'cloudOwner', cloudOwner) + def tenantId = cloudConfiguration.tenantId execution.setVariable(prefix + 'tenantId', tenantId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy index a926030924..0972ee184e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy @@ -191,6 +191,10 @@ public class UpdateVfModuleInfraV2 { def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId execution.setVariable(prefix + 'lcpCloudRegionId', lcpCloudRegionId) + + def cloudOwner = cloudConfiguration.cloudOwner + execution.setVariable(prefix + 'cloudOwner', cloudOwner) + def tenantId = cloudConfiguration.tenantId execution.setVariable(prefix + 'tenantId', tenantId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy index 7b2d1b78e4..ce93db522e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy @@ -7,9 +7,9 @@ * 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. @@ -30,6 +30,10 @@ import org.onap.so.bpmn.common.scripts.VfModuleBase; import org.onap.so.bpmn.common.scripts.VidUtils; import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient +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.rest.APIResponse @@ -39,10 +43,10 @@ import groovy.json.JsonSlurper class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, UpdateVfModuleVolumeInfraV1.class); - + /** * Initialize the flow's variables. - * + * * @param execution The flow's execution instance. */ private void initProcessVariables(DelegateExecution execution) { @@ -62,7 +66,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { execution.setVariable('UPDVfModVol_volumeGroupTenantId', null) execution.setVariable('UpdateVfModuleVolumeSuccessIndicator', false) } - + /** * Perform initial processing, such as request validation, initialization of variables, etc. @@ -72,33 +76,33 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") preProcessRequest(execution, isDebugEnabled) } - + public void preProcessRequest(DelegateExecution execution, isDebugLogEnabled) { initProcessVariables(execution) String jsonRequest = validateRequest(execution) - + def request = "" - + try { def jsonSlurper = new JsonSlurper() Map reqMap = jsonSlurper.parseText(jsonRequest) - + def serviceInstanceId = execution.getVariable('serviceInstanceId') def volumeGroupId = execution.getVariable('volumeGroupId') //def vnfId = execution.getVariable('vnfId') - + def vidUtils = new VidUtils(this) request = vidUtils.createXmlVolumeRequest(reqMap, 'UPDATE_VF_MODULE_VOL', serviceInstanceId, volumeGroupId) - + execution.setVariable('UPDVfModVol_Request', request) execution.setVariable("UPDVfModVol_isVidRequest", true) - + //need to get persona-model-id aka model-invariantId to use later to validate vf-module relation in AAI - + def modelInvariantId = reqMap.requestDetails.modelInfo.modelInvariantUuid ?: '' execution.setVariable('UPDVfModVol_modelInvariantId', modelInvariantId) - + msoLogger.debug("modelInvariantId from request: " + modelInvariantId) msoLogger.debug("XML request:\n" + request) } @@ -106,15 +110,15 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { msoLogger.debug(" Request is in XML format.") // assume request is in XML format - proceed as usual to process XML request } - + def requestId = execution.getVariable('mso-request-id') - + def requestInfo = getRequiredNodeXml(execution, request, 'request-info') execution.setVariable('UPDVfModVol_requestInfo', requestInfo) execution.setVariable('UPDVfModVol_requestId', requestId) //execution.setVariable('UPDVfModVol_requestId', getRequiredNodeText(execution, requestInfo, 'request-id')) execution.setVariable('UPDVfModVol_source', getNodeTextForce(requestInfo, 'source')) - + def volumeInputs = getRequiredNodeXml(execution, request, 'volume-inputs') execution.setVariable('UPDVfModVol_volumeInputs', volumeInputs) execution.setVariable('UPDVfModVol_volumeGroupId', getRequiredNodeText(execution, volumeInputs, 'volume-group-id')) @@ -126,14 +130,14 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { //execution.setVariable('UPDVfModVol_modelCustomizationId', getRequiredNodeText(execution, volumeInputs, 'model-customization-id')) setBasicDBAuthHeader(execution, isDebugLogEnabled) - + def volumeParams = utils.getNodeXml(request, 'volume-params') execution.setVariable('UPDVfModVol_volumeParams', volumeParams) } /** * Prepare and send the synchronous response. - * + * * @param execution The flow's execution instance. */ public void sendSynchResponse(DelegateExecution execution, isDebugLogEnabled) { @@ -150,7 +154,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { startTime = System.currentTimeMillis() } def volumeInputs = execution.getVariable('UPDVfModVol_volumeInputs') - + String xmlSyncResponse = """ <volume-request xmlns="http://org.onap/so/infra/vnf-request/v1"> <request-info> @@ -167,20 +171,20 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { def syncResponse = '' def isVidRequest = execution.getVariable('UPDVfModVol_isVidRequest') - + if(isVidRequest) { def volumeGroupId = execution.getVariable('volumeGroupId') syncResponse = """{"requestReferences":{"instanceId":"${volumeGroupId}","requestId":"${requestId}"}}""".trim() - } + } else { syncResponse = utils.formatXml(xmlSyncResponse) } - + msoLogger.debug('Sync response: ' + syncResponse) execution.setVariable('UPDVfModVol_syncResponseSent', true) sendWorkflowResponse(execution, 200, syncResponse) } - + /** * Prepare a Request for querying AAI for Volume Group information using the * Volume Group Id and Aic Cloud Region. @@ -192,31 +196,32 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution) - String queryAAIVolumeGroupRequest = aaiEndpoint + '/' + URLEncoder.encode(aicCloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, "UTF-8") - + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId) + def queryAAIVolumeGroupRequest = aaiUtil.createAaiUri(uri) + msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest) msoLogger.debug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest) - + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeGroupRequest) - + String returnCode = response.getStatusCode() String aaiResponseAsString = response.getResponseBodyAsString() - + msoLogger.debug("AAI query volume group by id return code: " + returnCode) msoLogger.debug("AAI query volume group by id response: " + aaiResponseAsString) - + msoLogger.debug("AAI Volume Group return code: " + returnCode) msoLogger.debug("AAI Volume Group response: " + aaiResponseAsString) - + ExceptionUtil exceptionUtil = new ExceptionUtil() - + if ((returnCode == '200') || (returnCode == '204')) { - + execution.setVariable('UPDVfModVol_aaiVolumeGroupResponse', aaiResponseAsString) //def heatStackId = getNodeTextForce(aaiResponseAsString, 'heat-stack-id') //execution.setVariable('UPDVfModVol_volumeGroupHeatStackId', heatStackId) - + def volumeGroupTenantId = getTenantIdFromVolumeGroup(aaiResponseAsString) if (volumeGroupTenantId == null) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id " + volumeGroupId @@ -228,42 +233,42 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { def relatedVfModuleLink = getRelatedVfModuleRelatedLink(aaiResponseAsString) msoLogger.debug("Related VF Module link: " + relatedVfModuleLink) execution.setVariable('UPDVfModVol_relatedVfModuleLink', relatedVfModuleLink) - - } + + } else if (returnCode == '404') { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group " + volumeGroupId + " not found at AAI") - } + } else { WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) throw new BpmnError("MSOWorkflowException") } } - + /** * Query AAI service instance * @param execution * @param isDebugEnabled */ public void queryAAIForGenericVnf(DelegateExecution execution, isDebugEnabled) { - + def vnfId = execution.getVariable('vnfId') - + AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getNetworkGenericVnfEndpoint(execution) - def String queryAAIRequest = aaiEndpoint + "/" + UriUtils.encode(vnfId, "UTF-8") + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) + String queryAAIRequest = aaiUtil.createAaiUri(uri) msoLogger.debug("AAI query generic vnf request: " + queryAAIRequest) - + APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest) - + String returnCode = response.getStatusCode() String aaiResponseAsString = response.getResponseBodyAsString() - + msoLogger.debug("AAI query generic vnf return code: " + returnCode) msoLogger.debug("AAI query generic vnf response: " + aaiResponseAsString) ExceptionUtil exceptionUtil = new ExceptionUtil() - + if (returnCode=='200') { msoLogger.debug('Generic vnf ' + vnfId + ' found in AAI.') execution.setVariable('UPDVfModVol_AAIQueryGenericVfnResponse', aaiResponseAsString) @@ -278,40 +283,40 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { } } } - + /** * Query AAI for VF Module using vf-module-id * @param execution * @param isDebugLogEnabled */ public void queryAAIForVfModule(DelegateExecution execution, isDebugLogEnabled) { - + AaiUtil aaiUtil = new AaiUtil(this) String queryAAIVfModuleRequest = execution.getVariable('UPDVfModVol_relatedVfModuleLink') execution.setVariable('UPDVfModVol_personaModelId', '') - + msoLogger.debug('Query AAI VF Module: ' + queryAAIVfModuleRequest) msoLogger.debug('Query AAI VF Module: ' + queryAAIVfModuleRequest) - + def aaiUrl = UrnPropertiesReader.getVariable("aai.endpoint", execution) msoLogger.debug('A&AI URL: ' + aaiUrl) - + def requestEndpoint = aaiUrl + queryAAIVfModuleRequest msoLogger.debug('A&AI request endpoint: ' + requestEndpoint) - + APIResponse response = aaiUtil.executeAAIGetCall(execution, requestEndpoint) - + String returnCode = response.getStatusCode() String aaiResponseAsString = response.getResponseBodyAsString() - + msoLogger.debug("AAI query vf-module: " + returnCode) msoLogger.debug("AAI query vf-module response: " + aaiResponseAsString) - + msoLogger.debug("AAI query vf-module:: " + returnCode) msoLogger.debug("AAI query vf-module response: " + aaiResponseAsString) - + ExceptionUtil exceptionUtil = new ExceptionUtil() - + if ((returnCode == '200') || (returnCode == '204')) { def personaModelId = utils.getNodeText(aaiResponseAsString, 'model-invariant-id') if(personaModelId == null) { @@ -330,14 +335,14 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { } } /** - * + * */ public String getRelatedVfModuleRelatedLink(xml) { def list = new XmlSlurper().parseText(xml) def vfModuleRelationship = list.'**'.find { node -> node.'related-to'.text() == 'vf-module' } return vfModuleRelationship?.'related-link'?.text() ?: '' } - + /** * Prepare a Request for invoking the VnfAdapterRest subflow to do * a Volume Group update. @@ -345,11 +350,11 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { * @param execution The flow's execution instance. */ public void prepVnfAdapterRest(DelegateExecution execution, isDebugLogEnabled) { - + def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') def tenantId = execution.getVariable('UPDVfModVol_tenantId') def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId') - + def aaiVolumeGroupResponse = execution.getVariable('UPDVfModVol_aaiVolumeGroupResponse') def volumeGroupHeatStackId = getNodeTextForce(aaiVolumeGroupResponse, 'heat-stack-id') def volumeGroupName = getNodeTextForce(aaiVolumeGroupResponse, 'volume-group-name') @@ -358,21 +363,21 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { // Check old attribute name modelCustomizationId = getNodeTextForce(aaiVolumeGroupResponse, 'vf-module-persona-model-customization-id') } - + def vnfType = execution.getVariable('UPDVfModVol_vnfType') def vnfVersion = execution.getVariable('UPDVfModVol_vnfVersion') - + def aaiGenericVnfResponse = execution.getVariable('UPDVfModVol_AAIQueryGenericVfnResponse') def vnfId = utils.getNodeText(aaiGenericVnfResponse, 'vnf-id') def vnfName = utils.getNodeText(aaiGenericVnfResponse, 'vnf-name') - + def volumeParamsXml = execution.getVariable('UPDVfModVol_volumeParams') def volumeGroupParams = transformVolumeParamsToEntries(volumeParamsXml) - + def requestId = execution.getVariable('UPDVfModVol_requestId') def serviceId = execution.getVariable('UPDVfModVol_serviceId') - + def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis() def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution) @@ -425,7 +430,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { execution.setVariable('UPDVfModVol_vnfAdapterRestRequest', vnfAdapterRestRequest) msoLogger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest) } - + /** * Prepare a Request for updating the DB for this Infra request. * @@ -435,7 +440,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { def requestId = execution.getVariable('UPDVfModVol_requestId') ExceptionUtil exceptionUtil = new ExceptionUtil(); - + String updateInfraRequest = """ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.onap.so/requestsdb"> @@ -455,7 +460,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { execution.setVariable('UPDVfModVol_updateInfraRequest', updateInfraRequest) msoLogger.debug('Request for Update Infra Request:\n' + updateInfraRequest) } - + /** * Build a "CompletionHandler" request. * @param execution The flow's execution instance. @@ -471,14 +476,14 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { <source>${MsoUtils.xmlEscape(source)}</source> </request-info> <aetgt:mso-bpel-name>BPMN VF Module Volume action: UPDATE</aetgt:mso-bpel-name> - </aetgt:MsoCompletionRequest> + </aetgt:MsoCompletionRequest> """ content = utils.formatXml(content) msoLogger.debug('Request for Completion Handler:\n' + content) execution.setVariable('UPDVfModVol_CompletionHandlerRequest', content) } - + /** * Build a "FalloutHandler" request. @@ -487,14 +492,14 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { public void prepFalloutHandler(DelegateExecution execution, isDebugLogEnabled) { def requestId = execution.getVariable('UPDVfModVol_requestId') def source = execution.getVariable('UPDVfModVol_source') - + String requestInfo = """ <request-info xmlns="http://org.onap/so/infra/vnf-request/v1"> <request-id>${MsoUtils.xmlEscape(requestId)}</request-id> <action>UPDATE</action> <source>${MsoUtils.xmlEscape(source)}</source> </request-info>""" - + def WorkflowException workflowException = execution.getVariable("WorkflowException") def errorResponseCode = workflowException.getErrorCode() def errorResponseMsg = workflowException.getErrorMessage() @@ -507,55 +512,55 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { <sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" xmlns:reqtype="http://org.onap/so/request/types/v1" xmlns:msoservtypes="http://org.onap/so/request/types/v1" - xmlns:structuredtypes="http://org.onap/so/structured/types/v1"> + xmlns:structuredtypes="http://org.onap/so/structured/types/v1"> ${requestInfo} <sdncadapterworkflow:WorkflowException> <sdncadapterworkflow:ErrorMessage>${MsoUtils.xmlEscape(encErrorResponseMsg)}</sdncadapterworkflow:ErrorMessage> <sdncadapterworkflow:ErrorCode>${MsoUtils.xmlEscape(errorResponseCode)}</sdncadapterworkflow:ErrorCode> - </sdncadapterworkflow:WorkflowException> + </sdncadapterworkflow:WorkflowException> </sdncadapterworkflow:FalloutHandlerRequest> """ content = utils.formatXml(content) msoLogger.debug('Request for Fallout Handler:\n' + content) execution.setVariable('UPDVfModVol_FalloutHandlerRequest', content) } - + /** * Create a WorkflowException for the error case where the Tenant Id from * AAI did not match the Tenant Id in the incoming request. * @param execution The flow's execution instance. */ public void handleTenantIdMismatch(DelegateExecution execution, isDebugLogEnabled) { - + def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId') def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') def tenantId = execution.getVariable('UPDVfModVol_tenantId') def volumeGroupTenantId = execution.getVariable('UPDVfModVol_volumeGroupTenantId') - + def String errorMessage = "TenantId " + tenantId + " in incoming request does not match Tenant Id " + volumeGroupTenantId + - " retrieved from AAI for Volume Group Id " + volumeGroupId + ", AIC Cloud Region " + aicCloudRegion - + " retrieved from AAI for Volume Group Id " + volumeGroupId + ", AIC Cloud Region " + aicCloudRegion + ExceptionUtil exceptionUtil = new ExceptionUtil() msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Error in UpdateVfModuleVol: ' + errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception"); exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) } - + /** * Create a WorkflowException for the error case where the Personal Model Id from * AAI did not match the model invariant ID in the incoming request. * @param execution The flow's execution instance. */ public void handlePersonaModelIdMismatch(DelegateExecution execution, isDebugLogEnabled) { - + def modelInvariantId = execution.getVariable('UPDVfModVol_modelInvariantId') def personaModelId = execution.getVariable('UPDVfModVol_personaModelId') - + def String errorMessage = "Model Invariant ID " + modelInvariantId + " in incoming request does not match persona model ID " + personaModelId + " retrieved from AAI for Volume Group Id " - + ExceptionUtil exceptionUtil = new ExceptionUtil() msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Error in UpdateVfModuleVol: ' + errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception"); exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) } - + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy index f251dc46f8..4978faf46c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy @@ -167,10 +167,12 @@ public class UpdateVnfInfra extends VnfCmBase { def usePreload = reqMap.requestDetails?.requestParameters?.usePreload execution.setVariable('usePreload', usePreload) - def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration - def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId + def cloudConfiguration = jsonOutput.toJson(reqMap.requestDetails?.cloudConfiguration) + def lcpCloudRegionId = jsonUtils.getJsonValue(cloudConfiguration, "lcpCloudRegionId") execution.setVariable('lcpCloudRegionId', lcpCloudRegionId) - def tenantId = cloudConfiguration.tenantId + def cloudOwner = jsonUtils.getJsonValue(cloudConfiguration, "cloudOwner") + execution.setVariable('cloudOwner', cloudOwner) + def tenantId = jsonUtils.getJsonValue(cloudConfiguration, "tenantId") execution.setVariable('tenantId', tenantId) def globalSubscriberId = reqMap.requestDetails?.subscriberInfo?.globalSubscriberId ?: '' diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy index 68d5c19b80..2c1b66ded5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy @@ -143,6 +143,8 @@ public class VnfInPlaceUpdate extends VnfCmBase { def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId execution.setVariable('lcpCloudRegionId', lcpCloudRegionId) + def cloudOwner = cloudConfiguration.cloudOwner + execution.setVariable('cloudOwner', cloudOwner) def tenantId = cloudConfiguration.tenantId execution.setVariable('tenantId', tenantId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy index 85993d6c92..8a3dcbab5d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy @@ -146,6 +146,9 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { String lcpCloudRegionId = jsonUtil.getJsonValue(cloudConfiguration, "lcpCloudRegionId") execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) msoLogger.debug("lcpCloudRegionId: "+ lcpCloudRegionId) + String cloudOwner = jsonUtil.getJsonValue(cloudConfiguration, "cloudOwner") + execution.setVariable("cloudOwner", cloudOwner) + msoLogger.debug("cloudOwner: "+ cloudOwner) String tenantId = jsonUtil.getJsonValue(cloudConfiguration, "tenantId") execution.setVariable("tenantId", tenantId) msoLogger.debug("tenantId: "+ tenantId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java index c04c2dc15b..6062129a71 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAICreateResources.java @@ -70,7 +70,7 @@ public class AAICreateResources { AAIResourcesClient aaiRC = new AAIResourcesClient(); return aaiRC.get(OwningEntities.class, AAIUriFactory - .createResourceUri(AAIObjectPlurals.OWNING_ENTITIES) + .createResourceUri(AAIObjectPlurals.OWNING_ENTITY) .queryParam("owning-entity-name", owningEntityName)) .orElseGet(() -> { msoLogger.debug("No Owning Entity matched by name"); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java index 5fe28b918b..e753f79ebd 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java @@ -28,6 +28,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; + import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpResponse; import org.apache.http.ParseException; @@ -45,17 +47,27 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.runtime.Execution; +import org.onap.aai.domain.yang.LogicalLink; +import org.onap.aai.domain.yang.LogicalLinks; +import org.onap.aai.domain.yang.PInterface; import org.onap.so.bpmn.core.UrnPropertiesReader; -import org.onap.so.bpmn.core.domain.ServiceDecomposition; import org.onap.so.bpmn.core.domain.Resource; +import org.onap.so.bpmn.core.domain.ServiceDecomposition; import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.client.aai.AAIObjectPlurals; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient; +import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.Relationships; +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.bpmn.common.scripts.AaiUtil; +import org.springframework.web.util.UriUtils; + import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import org.springframework.web.util.UriUtils; public class ServicePluginFactory { @@ -307,8 +319,7 @@ public class ServicePluginFactory { @SuppressWarnings("unchecked") private void allocateCrossTPResources(DelegateExecution execution, Map<String, Object> serviceRequestInputs) { - AaiUtil aai = new AaiUtil(); - Map<String, Object> crossTPs = aai.getTPsfromAAI(execution); + Map<String, Object> crossTPs = this.getTPsfromAAI(); if(crossTPs == null || crossTPs.isEmpty()) { serviceRequestInputs.put("local-access-provider-id", ""); @@ -338,6 +349,106 @@ public class ServicePluginFactory { return; } + // This method returns Local and remote TPs information from AAI + public Map getTPsfromAAI() { + Map<String, Object> tpInfo = new HashMap<>(); + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.LOGICAL_LINK); + AAIResourcesClient client = new AAIResourcesClient(); + Optional<LogicalLinks> result = client.get(LogicalLinks.class, uri); + + if (result.isPresent()) { + LogicalLinks links = result.get(); + boolean isRemoteLink = false; + + links.getLogicalLink(); + + for (LogicalLink link : links.getLogicalLink()) { + AAIResultWrapper wrapper = new AAIResultWrapper(link); + Optional<Relationships> optRelationships = wrapper.getRelationships(); + List<AAIResourceUri> pInterfaces = new ArrayList<>(); + if (optRelationships.isPresent()) { + Relationships relationships = optRelationships.get(); + if (!relationships.getRelatedAAIUris(AAIObjectType.EXT_AAI_NETWORK).isEmpty()) { + isRemoteLink = true; + } + pInterfaces.addAll(relationships.getRelatedAAIUris(AAIObjectType.P_INTERFACE)); + } + + if (isRemoteLink) { + // find remote p interface + AAIResourceUri localTP = null; + AAIResourceUri remoteTP = null; + + AAIResourceUri pInterface0 = pInterfaces.get(0); + + if (isRemotePInterface(client, pInterface0)) { + remoteTP = pInterfaces.get(0); + localTP = pInterfaces.get(1); + } else { + localTP = pInterfaces.get(0); + remoteTP = pInterfaces.get(1); + } + + if (localTP != null && remoteTP != null) { + // give local tp + String tpUrl = localTP.build().toString(); + PInterface intfLocal = client.get(PInterface.class, localTP).get(); + tpInfo.put("local-access-node-id", tpUrl.split("/")[6]); + + String[] networkRef = intfLocal.getNetworkRef().split("/"); + if (networkRef.length == 6) { + tpInfo.put("local-access-provider-id", networkRef[1]); + tpInfo.put("local-access-client-id", networkRef[3]); + tpInfo.put("local-access-topology-id", networkRef[5]); + } + String ltpIdStr = tpUrl.substring(tpUrl.lastIndexOf("/") + 1); + if (ltpIdStr.contains("-")) { + tpInfo.put("local-access-ltp-id", ltpIdStr.substring(ltpIdStr.lastIndexOf("-") + 1)); + } + + // give remote tp + tpUrl = remoteTP.build().toString(); + PInterface intfRemote = client.get(PInterface.class, remoteTP).get(); + tpInfo.put("remote-access-node-id", tpUrl.split("/")[6]); + + String[] networkRefRemote = intfRemote.getNetworkRef().split("/"); + + if (networkRefRemote.length == 6) { + tpInfo.put("remote-access-provider-id", networkRefRemote[1]); + tpInfo.put("remote-access-client-id", networkRefRemote[3]); + tpInfo.put("remote-access-topology-id", networkRefRemote[5]); + } + String ltpIdStrR = tpUrl.substring(tpUrl.lastIndexOf("/") + 1); + if (ltpIdStrR.contains("-")) { + tpInfo.put("remote-access-ltp-id", ltpIdStrR.substring(ltpIdStr.lastIndexOf("-") + 1)); + } + return tpInfo; + } + } + } + } + return tpInfo; + } + + // this method check if pInterface is remote + private boolean isRemotePInterface(AAIResourcesClient client, AAIResourceUri uri) { + + 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(); + } + + return false; + } + public String preProcessService(ServiceDecomposition serviceDecomposition, String uuiRequest) { // now only for sotn diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy index 4d5f506599..2f07842cb6 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy @@ -85,6 +85,7 @@ class CreateNetworkInstanceTest { <source>VID</source> </request-info> <aetgt:status-message>Network has been created successfully.</aetgt:status-message> + <aetgt:networkId>fb03f6f0-9012-41c4-87d8-1dbf3c22b889</aetgt:networkId> <aetgt:mso-bpel-name>BPMN Network action: CREATE</aetgt:mso-bpel-name> </aetgt:MsoCompletionRequest>""" @@ -272,6 +273,7 @@ String jsonIncomingRequest = when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") when(mockExecution.getVariable(Prefix + "dbReturnCode")).thenReturn("200") + when(mockExecution.getVariable("networkId")).thenReturn("fb03f6f0-9012-41c4-87d8-1dbf3c22b889") // postProcessResponse(DelegateExecution execution) CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy index 72f79c80d9..d8a82acfa7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -76,7 +76,6 @@ class DoCreateE2EServiceInstanceTest { when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("/mso/sdncadapter/") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.default.aai.customer.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer') DoCreateE2EServiceInstance obj = new DoCreateE2EServiceInstance() obj.preProcessRequest(mockExecution) Mockito.verify(mockExecution, times(7)).setVariable(captor.capture(), captor.capture()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy index cc6f89865f..587abbee52 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -83,7 +83,6 @@ class DoCreateServiceInstanceTest { when(mockExecution.getVariable("serviceDecomposition")).thenReturn(decomposition) when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.default.aai.customer.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer') DoCreateServiceInstance obj = new DoCreateServiceInstance() @@ -93,7 +92,7 @@ class DoCreateServiceInstanceTest { verify(mockExecution).setVariable("sdncCallbackUrl", "http://localhost:28080/mso/SDNCAdapterCallbackService") } - + @Test void testGetAAICustomerById() { @@ -101,7 +100,6 @@ class DoCreateServiceInstanceTest { when(mockExecution.getVariable("prefix")).thenReturn(prefix) when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("globalSubscriberId")).thenReturn("12345") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn("/aai/v9/business/customers/customer") when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") when(mockExecution.getVariable("mso.workflow.custom.DoCreateServiceInstance.aai.version")).thenReturn('8') diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy index fcb0fb0940..447463a079 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -85,7 +85,7 @@ class DoDeleteVfModuleFromVnfTest { Mockito.verify(mockExecution).setVariable("sdncCallbackUrl", "http://localhost:8090/SDNCAdapterCallback") } - + @Test void testDeleteNetworkPoliciesFromAAI() { @@ -106,7 +106,7 @@ class DoDeleteVfModuleFromVnfTest { Mockito.verify(mockExecution).setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", 200) } - + @Test void testQueryAAIForVfModule() { ExecutionEntity mockExecution = setupMock() @@ -115,7 +115,6 @@ class DoDeleteVfModuleFromVnfTest { when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("mso.workflow.global.default.aai.namespace") when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") @@ -126,7 +125,7 @@ class DoDeleteVfModuleFromVnfTest { Mockito.verify(mockExecution, atLeastOnce()).setVariable("DDVMFV_getVnfResponseCode", 200) } - + private ExecutionEntity setupMock() { diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy index beaebceaf7..67b1c23ae1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -77,7 +77,7 @@ class DoUpdateVfModuleTest { Mockito.verify(mockExecution, atLeastOnce()).getVariable("mso.workflow.sdncadapter.callback") } - + @Test void testPrepConfirmVolumeGroupTenant() { @@ -100,7 +100,7 @@ class DoUpdateVfModuleTest { Mockito.verify(mockExecution).setVariable(prefix + "isCloudRegionGood", true) } - + @Test void testPrepSDNCTopologyChg() { ExecutionEntity mockExecution = setupMock() @@ -148,7 +148,7 @@ class DoUpdateVfModuleTest { XmlComparator.assertXMLEquals(sdncChangeAssignRequest, captor.getValue()) } - + @Test void testPrepSDNCTopologyQuery() { @@ -168,7 +168,7 @@ class DoUpdateVfModuleTest { XmlComparator.assertXMLEquals(sdncTopologyRequest, captor.getValue()) } - + @Test void testPrepVnfAdapterRest() { @@ -219,7 +219,7 @@ class DoUpdateVfModuleTest { XmlComparator.assertXMLEquals(createVnfARequest, captor.getValue(), "messageId", "notificationUrl") } - + @Test void testPrepSDNCTopologyAct() { @@ -263,7 +263,6 @@ class DoUpdateVfModuleTest { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("12345") when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy index ba54787dc1..a86029ea30 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy @@ -7,9 +7,9 @@ * 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. @@ -61,7 +61,7 @@ class DoUpdateVnfAndModulesTest { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("vnfId")).thenReturn("12345") when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") @@ -78,7 +78,7 @@ class DoUpdateVnfAndModulesTest { when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("vnfId")).thenReturn("12345") when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") + when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy index 523c791efc..84da045450 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy @@ -576,6 +576,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") verify(mex).setVariable("lcpCloudRegionId", "mdt1") + verify(mex).setVariable("cloudOwner", "my-cloud-owner") verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") } @@ -594,6 +595,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") verify(mex).setVariable("lcpCloudRegionId", "mdt1") + verify(mex).setVariable("cloudOwner", "my-cloud-owner") verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") } @@ -612,6 +614,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") verify(mex).setVariable("lcpCloudRegionId", "mdt1") + verify(mex).setVariable("cloudOwner", "my-cloud-owner") verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy index b7c754938a..c2384b63a5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy @@ -145,6 +145,7 @@ class DeleteVcpeResCustServiceTest extends GroovyTestBase { verify(mex).setVariable("subscriptionServiceType", SVC) verify(mex).setVariable("lcpCloudRegionId", "mdt1") + verify(mex).setVariable("cloudOwner", "my-cloud-owner") verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") assertEquals("""{"tenantId":"8b1df54faa3b49078e3416e21370a3ba","lcpCloudRegionId":"mdt1"}""", map.get("cloudConfiguration")) verify(mex).setVariable("sdncVersion", "1707") diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/resources/application-test.yml b/bpmn/so-bpmn-infrastructure-common/src/test/resources/application-test.yml index 96cdebcc1e..78ecd6ce88 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/resources/application-test.yml +++ b/bpmn/so-bpmn-infrastructure-common/src/test/resources/application-test.yml @@ -1,334 +1,287 @@ -aai: - auth: 757A94191D685FD2092AC1490730A4FC - dme2: - timeout: '30000' - endpoint: http://localhost:${wiremock.server.port} -camunda: - bpm: - admin-user: - id: admin - password: admin - database: - type: h2 - history-level: FULL - metrics: - enabled: false - db-reporter-activate: false -canopi: - auth: 757A94191D685FD2092AC1490730A4FC -csi: - aots: - addincidentmanagement: - endpoint: http://localhost:${wiremock.server.port}/AddIncidentManagementTicketRequest - networkstatus: - endpoint: http://localhost:${wiremock.server.port}/SendManagedNetworkStatusNotification -entitymanager: - packagesToScan: com -mso: - correlation: - timeout: PT60S - logPath: logs - async: - core-pool-size: 50 - max-pool-size: 50 - queue-capacity: 500 - adapters: - completemsoprocess: - endpoint: http://localhost:30253/CompleteMsoProcess - db: - auth: 757A94191D685FD2092AC1490730A4FC - password: wLg4sjrAFUS8rfVfdvTXeQ== - endpoint: http://localhost:${wiremock.server.port}/services/RequestsDbAdapter - spring: - endpoint: http://localhost:${wiremock.server.port} - network: - endpoint: http://localhost:30253/services/NetworkAdapter - rest: - endpoint: http://localhost:30253/services/rest/v1/networks - openecomp: - db: - endpoint: http://localhost:${wiremock.server.port}/services/RequestsDbAdapter - po: - auth: 757A94191D685FD2092AC1490730A4FC - password: 3141634BF7E070AA289CF2892C986C0B - sdnc: - endpoint: http://localhost:${wiremock.server.port}/adapters/SDNCAdapter - rest: - endpoint: http://localhost:${wiremock.server.port}/adapters/rest/v1/sdnc - timeout: PT150S - tenant: - endpoint: http://localhost:30253/services/TenantAdapter - vnf: - endpoint: http://localhost:${wiremock.server.port}/services/VnfAdapter - rest: - endpoint: http://localhost:${wiremock.server.port}/services/rest/v1/vnfs - volume-groups: - rest: - endpoint: http://localhost:30253/services/rest/v1/volume-groups - vnf-async: - endpoint: http://localhost:30253/services/VnfAdapterAsync - adiod: - vce: - service: - model: - invariant: - uuid: 1cc4e2e4-eb6e-404d-a66f-c8733cedcce8 - version: '5.0' - bpmn: - process: - historyTimeToLive: '30' - callbackRetryAttempts: '5' - catalog: - db: - endpoint: http://localhost:${wiremock.server.port}/ecomp/mso/catalog - spring: - endpoint: http://localhost:30258 - csi: - pwd: 4EA237303511EFBBC37F17A351562131 - sendmanagednetworkstatusnotification: - applicationname: NetworkManagementEthernetOverFiber - version: '212' - usrname: mso - db: - auth: Basic YnBlbDptc28tZGItMTUwNyE= - default: - adapter: - namespace: http://com.att.mso - gateway: - service: - model: - name: HNGWaaS for DHV Test - healthcheck: - log: - debug: 'false' - infra: - customer: - id: testCustIdInfra - msoKey: 07a7159d3bf51a0e53be7a8f89699be7 - oam: - network: - role: - gateway: HngwOamNetVto.OAM - portal: HnportalOamNetVto.OAM - po: - timeout: PT60S - portal: - service: - model: - name: HNPortalaaS for DHV Test - request: - db: - endpoint: http://localhost:${wiremock.server.port}/ - rollback: 'true' - sdnc: - firewall: - yang: - model: - version: '2015-05-15' - password: 3141634BF7E070AA289CF2892C986C0B - timeout: - firewall: - minutes: '20' - ucpe: - async: - hours: '120' - minutes: '5' - site-name: CamundaEngine - sriov: - network: - role: - gateway1: HngwSriovProviderNet.SR_IOV_Provider2_1 - gateway2: HngwSriovProviderNet.SR_IOV_Provider2_2 - portal1: HnportalSriovProviderNet3.SR_IOV_Provider2_1 - portal2: HnportalSriovProviderNet3.SR_IOV_Provider2_2 - workflow: - sdnc: - replication: - delay: PT5S - aai: - distribution: - delay: PT5S - CreateGenericVNFV1: - aai: - volume-group: - uri: /aai/v6/cloud-infrastructure/volume-groups/volume-group - DHVCreateService: - aai: - customer: - uri: /aai/v9/business/customers/customer - createvce: - delay: - seconds: '1' - default: - aai: - version: '8' - cloud-region: - version: '9' - generic-vnf: - version: '9' - v11: - customer: - uri: /aai/v11/business/customers/customer - generic-query: - uri: /aai/v11/search/generic-query - generic-vnf: - uri: /aai/v11/network/generic-vnfs/generic-vnf - l3-network: - uri: /aai/v11/network/l3-networks/l3-network - network-policy: - uri: /aai/v11/network/network-policies/network-policy - nodes-query: - uri: /aai/v11/search/nodes-query - route-table-reference: - uri: /aai/v11/network/route-table-references/route-table-reference - tenant: - uri: /aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant - vce: - uri: /aai/v11/network/vces/vce - vpn-binding: - uri: /aai/v11/network/vpn-bindings/vpn-binding - v8: - configuration: - uri: /aai/v11/network/configurations/configuration - customer: - uri: /aai/v8/business/customers/customer - generic-query: - uri: /aai/v8/search/generic-query - l3-network: - uri: /aai/v8/network/l3-networks/l3-network - network-policy: - uri: /aai/v8/network/network-policies/network-policy - nodes-query: - uri: /aai/v8/search/nodes-query - route-table-reference: - uri: /aai/v8/network/route-table-references/route-table-reference - tenant: - uri: /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant - vce: - uri: /aai/v8/network/vces/vce - vpn-binding: - uri: /aai/v8/network/vpn-bindings/vpn-binding - v9: - cloud-region: - uri: /aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic - generic-vnf: - uri: /aai/v9/network/generic-vnfs/generic-vnf - retry: - attempts: '1' - deleteCinderVolumeV1: - aai: - volume-group: - uri: /aai/v6/cloud-infrastructure/volume-groups/volume-group - global: - default: - aai: - namespace: http://org.openecomp.aai.inventory/ - l3ToHigherLayerAddBonding: - model: - invariantid: 50359538-066f-4a8d-807f-f2bc8eaa79dc - name: WAN Bonding v0.1 - version: '0.1' - versionid: 52dbec20-47aa-42e4-936c-331d8e350d44 - message: - endpoint: http://localhost:30252/mso/WorkflowMessage - notification: - name: GenericNotificationServiceATT - sdncadapter: - callback: http://localhost:${wiremock.server.port}/mso/SDNCAdapterCallbackService - vnfadapter: - create: - callback: http://localhost:30253/mso/vnfAdapterNotify - delete: - callback: http://localhost:30253/mso/vnfAdapterNotify - query: - callback: http://localhost:30253/mso/vnfAdapterNotify - rollback: - callback: http://localhost:30253/mso/vnfAdapterNotify -policy: - auth: Basic dGVzdHBkcDphbHBoYTEyMw== - client: - auth: Basic bTAzNzQzOnBvbGljeVIwY2sk - endpoint: https://localhost:8081/pdp/api/ - environment: TEST -sdnc: - auth: Basic YWRtaW46YWRtaW4= - host: https://localhost:8443 - path: /restconf/operations/GENERIC-RESOURCE-API -sdno: - health-check: - dmaap: - password: eHQ1cUJrOUc - publisher: - topic: com.att.sdno.test-health-diagnostic-v02 - subscriber: - topic: com.att.sdno.test-health-diagnostic-v02 - username: testuser -pnf: - dmaap: - host: - port: -sniro: - conductor: - host: http://localhost:30253 - uri: /release - manager: - timeout: PT30M - host: http://localhost:${wiremock.server.port} - uri.v1: /sniro/api/v2/placement - uri.v2: /sniro/api/placement/v2 - headers.auth: Basic dGVzdDp0ZXN0cHdk - headers.patchVersion: 1 - headers.minorVersion: 1 - headers.latestVersion: 2 -server: - port: 8080 - tomcat: - max-threads: 50 - # ssl: - # key-store: /app/msoClientKeyStore.jks - # key-store-password: mso4you - # key-store-type: JKS - # trust-store: /app/msoTrustStore.jks - # trust-store-password: mso_Domain2.0_4you -spring: - h2: - console: - enabled: true - path: /h2 - datasource: - url: jdbc:h2:mem:AZ;;DB_CLOSE_ON_EXIT=FALSE - username: sa - password: sa - driverClassName: org.h2.Driver - security: - usercredentials: - - - username: test - password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' - role: BPMN-Client -# Hibernate -hibernate: - dialect: org.hibernate.dialect.MySQL5Dialect - show_sql: false - -management: - security: - enabled: false - -security: - basic: - enabled: false - -appc: - client: - topic: - read: - name: APPC-TEST-AMDOCS2 - timeout: 360000 - write: APPC-TEST-AMDOCS1-IST - response: - timeout: 360000 - key: LSl8QKolmKcC0yJR - secret: lgjXraD1HutKxv8jEN6tVouu - service: ueb +aai:
+ auth: 757A94191D685FD2092AC1490730A4FC
+ dme2:
+ timeout: '30000'
+ endpoint: http://localhost:${wiremock.server.port}
+camunda:
+ bpm:
+ admin-user:
+ id: admin
+ password: admin
+ database:
+ type: h2
+ history-level: FULL
+ metrics:
+ enabled: false
+ db-reporter-activate: false
+canopi:
+ auth: 757A94191D685FD2092AC1490730A4FC
+csi:
+ aots:
+ addincidentmanagement:
+ endpoint: http://localhost:${wiremock.server.port}/AddIncidentManagementTicketRequest
+ networkstatus:
+ endpoint: http://localhost:${wiremock.server.port}/SendManagedNetworkStatusNotification
+entitymanager:
+ packagesToScan: com
+mso:
+ correlation:
+ timeout: PT60S
+ logPath: logs
+ async:
+ core-pool-size: 50
+ max-pool-size: 50
+ queue-capacity: 500
+ adapters:
+ completemsoprocess:
+ endpoint: http://localhost:30253/CompleteMsoProcess
+ db:
+ auth: 757A94191D685FD2092AC1490730A4FC
+ password: wLg4sjrAFUS8rfVfdvTXeQ==
+ endpoint: http://localhost:${wiremock.server.port}/services/RequestsDbAdapter
+ spring:
+ endpoint: http://localhost:${wiremock.server.port}
+ network:
+ endpoint: http://localhost:30253/services/NetworkAdapter
+ rest:
+ endpoint: http://localhost:30253/services/rest/v1/networks
+ openecomp:
+ db:
+ endpoint: http://localhost:${wiremock.server.port}/services/RequestsDbAdapter
+ po:
+ auth: 757A94191D685FD2092AC1490730A4FC
+ password: 3141634BF7E070AA289CF2892C986C0B
+ sdnc:
+ endpoint: http://localhost:${wiremock.server.port}/adapters/SDNCAdapter
+ rest:
+ endpoint: http://localhost:${wiremock.server.port}/adapters/rest/v1/sdnc
+ timeout: PT150S
+ tenant:
+ endpoint: http://localhost:30253/services/TenantAdapter
+ vnf:
+ endpoint: http://localhost:${wiremock.server.port}/services/VnfAdapter
+ rest:
+ endpoint: http://localhost:${wiremock.server.port}/services/rest/v1/vnfs
+ volume-groups:
+ rest:
+ endpoint: http://localhost:30253/services/rest/v1/volume-groups
+ vnf-async:
+ endpoint: http://localhost:30253/services/VnfAdapterAsync
+ adiod:
+ vce:
+ service:
+ model:
+ invariant:
+ uuid: 1cc4e2e4-eb6e-404d-a66f-c8733cedcce8
+ version: '5.0'
+ bpmn:
+ process:
+ historyTimeToLive: '30'
+ callbackRetryAttempts: '5'
+ catalog:
+ db:
+ endpoint: http://localhost:${wiremock.server.port}/ecomp/mso/catalog
+ spring:
+ endpoint: http://localhost:30258
+ csi:
+ pwd: 4EA237303511EFBBC37F17A351562131
+ sendmanagednetworkstatusnotification:
+ applicationname: NetworkManagementEthernetOverFiber
+ version: '212'
+ usrname: mso
+ db:
+ auth: Basic YnBlbDptc28tZGItMTUwNyE=
+ default:
+ adapter:
+ namespace: http://com.att.mso
+ gateway:
+ service:
+ model:
+ name: HNGWaaS for DHV Test
+ healthcheck:
+ log:
+ debug: 'false'
+ infra:
+ customer:
+ id: testCustIdInfra
+ msoKey: 07a7159d3bf51a0e53be7a8f89699be7
+ oam:
+ network:
+ role:
+ gateway: HngwOamNetVto.OAM
+ portal: HnportalOamNetVto.OAM
+ po:
+ timeout: PT60S
+ portal:
+ service:
+ model:
+ name: HNPortalaaS for DHV Test
+ request:
+ db:
+ endpoint: http://localhost:${wiremock.server.port}/
+ rollback: 'true'
+ sdnc:
+ firewall:
+ yang:
+ model:
+ version: '2015-05-15'
+ password: 3141634BF7E070AA289CF2892C986C0B
+ timeout:
+ firewall:
+ minutes: '20'
+ ucpe:
+ async:
+ hours: '120'
+ minutes: '5'
+ site-name: CamundaEngine
+ sriov:
+ network:
+ role:
+ gateway1: HngwSriovProviderNet.SR_IOV_Provider2_1
+ gateway2: HngwSriovProviderNet.SR_IOV_Provider2_2
+ portal1: HnportalSriovProviderNet3.SR_IOV_Provider2_1
+ portal2: HnportalSriovProviderNet3.SR_IOV_Provider2_2
+ workflow:
+ sdnc:
+ replication:
+ delay: PT5S
+ aai:
+ distribution:
+ delay: PT5S
+ CreateGenericVNFV1:
+ aai:
+ volume-group:
+ uri: /aai/v6/cloud-infrastructure/volume-groups/volume-group
+ DHVCreateService:
+ aai:
+ customer:
+ uri: /aai/v9/business/customers/customer
+ createvce:
+ delay:
+ seconds: '1'
+ default:
+ aai:
+ version: '8'
+ cloud-region:
+ version: '9'
+ generic-vnf:
+ version: '9'
+ retry:
+ attempts: '1'
+ deleteCinderVolumeV1:
+ aai:
+ volume-group:
+ uri: /aai/v6/cloud-infrastructure/volume-groups/volume-group
+ global:
+ default:
+ aai:
+ namespace: http://org.openecomp.aai.inventory/
+ l3ToHigherLayerAddBonding:
+ model:
+ invariantid: 50359538-066f-4a8d-807f-f2bc8eaa79dc
+ name: WAN Bonding v0.1
+ version: '0.1'
+ versionid: 52dbec20-47aa-42e4-936c-331d8e350d44
+ message:
+ endpoint: http://localhost:30252/mso/WorkflowMessage
+ notification:
+ name: GenericNotificationServiceATT
+ sdncadapter:
+ callback: http://localhost:${wiremock.server.port}/mso/SDNCAdapterCallbackService
+ vnfadapter:
+ create:
+ callback: http://localhost:30253/mso/vnfAdapterNotify
+ delete:
+ callback: http://localhost:30253/mso/vnfAdapterNotify
+ query:
+ callback: http://localhost:30253/mso/vnfAdapterNotify
+ rollback:
+ callback: http://localhost:30253/mso/vnfAdapterNotify
+policy:
+ auth: Basic dGVzdHBkcDphbHBoYTEyMw==
+ client:
+ auth: Basic bTAzNzQzOnBvbGljeVIwY2sk
+ endpoint: https://localhost:8081/pdp/api/
+ environment: TEST
+sdnc:
+ auth: Basic YWRtaW46YWRtaW4=
+ host: https://localhost:8443
+ path: /restconf/operations/GENERIC-RESOURCE-API
+sdno:
+ health-check:
+ dmaap:
+ password: eHQ1cUJrOUc
+ publisher:
+ topic: com.att.sdno.test-health-diagnostic-v02
+ subscriber:
+ topic: com.att.sdno.test-health-diagnostic-v02
+ username: testuser
+pnf:
+ dmaap:
+ host:
+ port:
+sniro:
+ conductor:
+ host: http://localhost:30253
+ uri: /release
+ manager:
+ timeout: PT30M
+ host: http://localhost:${wiremock.server.port}
+ uri.v1: /sniro/api/v2/placement
+ uri.v2: /sniro/api/placement/v2
+ headers.auth: Basic dGVzdDp0ZXN0cHdk
+ headers.patchVersion: 1
+ headers.minorVersion: 1
+ headers.latestVersion: 2
+server:
+ port: 8080
+ tomcat:
+ max-threads: 50
+ # ssl:
+ # key-store: /app/msoClientKeyStore.jks
+ # key-store-password: mso4you
+ # key-store-type: JKS
+ # trust-store: /app/msoTrustStore.jks
+ # trust-store-password: mso_Domain2.0_4you
+spring:
+ h2:
+ console:
+ enabled: true
+ path: /h2
+ datasource:
+ url: jdbc:h2:mem:AZ;;DB_CLOSE_ON_EXIT=FALSE
+ username: sa
+ password: sa
+ driverClassName: org.h2.Driver
+ security:
+ usercredentials:
+ -
+ username: test
+ password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu'
+ role: BPMN-Client
+# Hibernate
+hibernate:
+ dialect: org.hibernate.dialect.MySQL5Dialect
+ show_sql: false
+
+management:
+ security:
+ enabled: false
+
+security:
+ basic:
+ enabled: false
+
+appc:
+ client:
+ topic:
+ read:
+ name: APPC-TEST-AMDOCS2
+ timeout: 360000
+ write: APPC-TEST-AMDOCS1-IST
+ response:
+ timeout: 360000
+ key: LSl8QKolmKcC0yJR
+ secret: lgjXraD1HutKxv8jEN6tVouu
+ service: ueb
poolMembers: localhost:3904,localhost:3904,localhost:3904
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/pom.xml b/bpmn/so-bpmn-infrastructure-flows/pom.xml index 63b66cafe5..7d7b89c8fb 100644 --- a/bpmn/so-bpmn-infrastructure-flows/pom.xml +++ b/bpmn/so-bpmn-infrastructure-flows/pom.xml @@ -244,18 +244,6 @@ <version>1.3</version> </dependency> <dependency> - <groupId>org.onap.msb.java-sdk</groupId> - <artifactId>msb-java-sdk</artifactId> - <version>1.0.0</version> - <exclusions> - <exclusion> - <groupId>com.eclipsesource.jaxrs</groupId> - <artifactId>jersey-all</artifactId> - </exclusion> - </exclusions> - </dependency> - - <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateNetworkInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateNetworkInstance.bpmn index 9b21b9309f..b35aa80b83 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateNetworkInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateNetworkInstance.bpmn @@ -30,6 +30,7 @@ networkMod.processJavaException(execution)]]></bpmn2:script> <camunda:in source="networkId" target="networkId" /> <camunda:in source="networkName" target="networkName" /> <camunda:in source="networkModelInfo" target="networkModelInfo" /> + <camunda:in source="cloudOwner" target="cloudOwner" /> <camunda:in source="lcpCloudRegionId" target="lcpCloudRegionId" /> <camunda:in source="tenantId" target="tenantId" /> <camunda:in source="productFamilyId" target="productFamilyId" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService.bpmn index 3b49011c3e..7413e6df83 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService.bpmn @@ -505,6 +505,7 @@ CreateVcpeResCustService.prepareCreateAllottedResourceBRG(execution)]]></bpmn2:s <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> <camunda:in source="productFamilyId" target="productFamilyId" /> <camunda:in source="vnfModelInfo" target="vnfModelInfo" /> + <camunda:in source="cloudOwner" target="cloudOwner" /> <camunda:in source="lcpCloudRegionId" target="lcpCloudRegionId" /> <camunda:in source="tenantId" target="tenantId" /> <camunda:in source="sdncVersion" target="sdncVersion" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustServiceV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustServiceV2.bpmn index 06c517c12d..bfbdc25f18 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustServiceV2.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustServiceV2.bpmn @@ -475,6 +475,7 @@ CreateVcpeResCustService.prepareCreateAllottedResourceTXC(execution)]]></bpmn2:s <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> <camunda:in source="productFamilyId" target="productFamilyId" /> <camunda:in source="vnfModelInfo" target="vnfModelInfo" /> + <camunda:in source="cloudOwner" target="cloudOwner" /> <camunda:in source="lcpCloudRegionId" target="lcpCloudRegionId" /> <camunda:in source="tenantId" target="tenantId" /> <camunda:in source="sdncVersion" target="sdncVersion" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleInfra.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleInfra.bpmn index eefc2ca12c..150d50232a 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleInfra.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleInfra.bpmn @@ -32,6 +32,7 @@ <camunda:in source="CVFMI_globalSubscriberId" target="globalSubscriberId" /> <camunda:in source="CVFMI_sdncVersion" target="sdncVersion" /> <camunda:in source="CVFMI_lcpCloudRegionId" target="lcpCloudRegionId" /> + <camunda:in source="CVFMI_cloudOwner" target="cloudOwner" /> <camunda:in source="CVFMI_tenantId" target="tenantId" /> <camunda:in source="CVFMI_vfModuleId" target="vfModuleId" /> <camunda:in source="CVFMI_vfModuleModelInfo" target="vfModuleModelInfo" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleVolumeInfraV1.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleVolumeInfraV1.bpmn index dcdcdc9d26..c1e60ba46b 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleVolumeInfraV1.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVfModuleVolumeInfraV1.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_CyftwG_HEeaKe-v4u9MasA" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_CyftwG_HEeaKe-v4u9MasA" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="CreateVfModuleVolumeInfraV1" name="CreateVfModuleVolumeInfraV1" isExecutable="true"> <bpmn2:startEvent id="StartEvent_createVfModuleVolumeInfraV1"> <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> @@ -154,6 +154,7 @@ createVfModuleVolumeInfraV1.executeMethod('buildWorkflowException', execution, 2 <camunda:in source="vnfName" target="vnfName" /> <camunda:in source="volumeGroupName" target="volumeGroupName" /> <camunda:in source="vfModuleModelInfo" target="vfModuleModelInfo" /> + <camunda:in source="cloudOwner" target="cloudOwner" /> <camunda:in source="lcpCloudRegionId" target="lcpCloudRegionId" /> <camunda:in source="tenantId" target="tenantId" /> <camunda:in source="vnfType" target="vnfType" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVnfInfra.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVnfInfra.bpmn index 6af8c2248e..d7d4561364 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVnfInfra.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVnfInfra.bpmn @@ -37,6 +37,7 @@ createVnf.sendSyncResponse(execution)]]></bpmn2:script> <camunda:out source="vnfOutputParameters" target="CREVI_vnfOutputParameters" /> <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:in source="CREVI_lcpCloudRegionId" target="lcpCloudRegionId" /> + <camunda:in source="CREVI_cloudOwner" target="cloudOwner" /> <camunda:in source="CREVI_tenantId" target="tenandId" /> <camunda:in source="CREVI_vnfResourceDecomposition" target="vnfResourceDecomposition" /> </bpmn2:extensionElements> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteNetworkInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteNetworkInstance.bpmn index a62e16525d..827dfb034d 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteNetworkInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteNetworkInstance.bpmn @@ -30,6 +30,7 @@ networkMod.processJavaException(execution)]]></bpmn2:script> <camunda:in source="networkId" target="networkId" /> <camunda:in source="networkName" target="networkName" /> <camunda:in source="networkModelInfo" target="networkModelInfo" /> + <camunda:in source="cloudOwner" target="cloudOwner" /> <camunda:in source="lcpCloudRegionId" target="lcpCloudRegionId" /> <camunda:in source="tenantId" target="tenantId" /> <camunda:in source="productFamilyId" target="productFamilyId" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVcpeResCustService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVcpeResCustService.bpmn index 0d287ebca4..fd0d8ff27a 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVcpeResCustService.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteVcpeResCustService.bpmn @@ -240,6 +240,7 @@ DeleteVcpeResCustService.getServiceInstance(execution)]]></bpmn2:script> <camunda:out source="rollbackData" target="rollbackData" /> <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:out source="rolledBack" target="rolledBack" /> + <camunda:in source="cloudOwner" target="cloudOwner" /> <camunda:in source="lcpCloudRegionId" target="lcpCloudRegionId" /> <camunda:in source="tenantId" target="tenantId" /> <camunda:in source="cloudConfiguration" target="cloudConfiguration" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ReplaceVnfInfra.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ReplaceVnfInfra.bpmn index 6a157eb7c0..25b4f5de7f 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ReplaceVnfInfra.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ReplaceVnfInfra.bpmn @@ -362,6 +362,7 @@ uvfm.prepDoCreateVnfAndModules(execution)]]></bpmn2:script> <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> <camunda:in source="productFamilyId" target="productFamilyId" /> <camunda:in source="vnfModelInfo" target="vnfModelInfo" /> + <camunda:in source="cloudOwner" target="cloudOwner" /> <camunda:in source="lcpCloudRegionId" target="lcpCloudRegionId" /> <camunda:in source="tenantId" target="tenantId" /> <camunda:in source="sdncVersion" target="sdncVersion" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateNetworkInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateNetworkInstance.bpmn index e5236f92bf..50600bd49f 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateNetworkInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateNetworkInstance.bpmn @@ -30,6 +30,7 @@ networkMod.processJavaException(execution)</bpmn2:script> <camunda:in source="networkId" target="networkId" /> <camunda:in source="networkName" target="networkName" /> <camunda:in source="networkModelInfo" target="networkModelInfo" /> + <camunda:in source="cloudOwner" target="cloudOwner" /> <camunda:in source="lcpCloudRegionId" target="lcpCloudRegionId" /> <camunda:in source="tenantId" target="tenantId" /> <camunda:in source="productFamilyId" target="productFamilyId" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfra.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfra.bpmn index c35e7ece96..3c5fff2d24 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfra.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfra.bpmn @@ -122,6 +122,7 @@ uvfm.falloutHandlerPrep(execution, 'UPDVfModI_FalloutHandlerRequest') <camunda:in source="UPDVfModI_vnfModelInfo" target="vnfModelInfo" /> <camunda:in source="UPDVfModI_globalSubscriberId" target="globalSubscriberId" /> <camunda:in source="UPDVfModI_lcpCloudRegionId" target="lcpCloudRegionId" /> + <camunda:in source="UPDVfModI_cloudOwner" target="cloudOwner" /> <camunda:in source="UPDVfModI_tenantId" target="tenantId" /> <camunda:in source="UPDVfModI_sdncVersion" target="sdncVersion" /> <camunda:in source="UPDVfModI_vfModuleModelInfo" target="vfModuleModelInfo" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfraV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfraV2.bpmn index 1efb127e33..8d30679849 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfraV2.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVfModuleInfraV2.bpmn @@ -164,6 +164,7 @@ uvfm.vfFlagSet(execution)]]></bpmn2:script> <camunda:in source="UPDVfModI_vnfModelInfo" target="vnfModelInfo" /> <camunda:in source="UPDVfModI_globalSubscriberId" target="globalSubscriberId" /> <camunda:in source="UPDVfModI_lcpCloudRegionId" target="lcpCloudRegionId" /> + <camunda:in source="UPDVfModI_cloudOwner" target="cloudOwner" /> <camunda:in source="UPDVfModI_tenantId" target="tenantId" /> <camunda:in source="UPDVfModI_sdncVersion" target="sdncVersion" /> <camunda:in source="UPDVfModI_vfModuleModelInfo" target="vfModuleModelInfo" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVnfInfra.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVnfInfra.bpmn index e50eb7f805..71fc966233 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVnfInfra.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateVnfInfra.bpmn @@ -142,6 +142,7 @@ uvfm.postProcessRollback(execution)]]></bpmn2:script> <camunda:in source="serviceModelInfo" target="serviceModelInfo" /> <camunda:in source="vnfModelInfo" target="vnfModelInfo" /> <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="cloudOwner" target="cloudOwner" /> <camunda:in source="lcpCloudRegionId" target="lcpCloudRegionId" /> <camunda:in source="tenantId" target="tenantId" /> <camunda:in source="sdncVersion" target="sdncVersion" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn index 9cf21ddc52..01040ba914 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.3" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="DoCreateE2EServiceInstanceV3" name="DoCreateE2EServiceInstanceV3" isExecutable="true"> <bpmn2:startEvent id="createSI_startEvent" name="Start Flow"> <bpmn2:outgoing>SequenceFlow_1qiiycn</bpmn2:outgoing> @@ -12,21 +12,6 @@ def dcsi = new DoCreateE2EServiceInstance() dcsi.preProcessRequest(execution) ]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:callActivity id="CustomE2EPutService" name="Call Custom E2E Put Service" calledElement="CustomE2EPutService"> - <bpmn2:extensionElements> - <camunda:in source="globalSubscriberId" target="GENPS_globalSubscriberId" /> - <camunda:in source="serviceInstanceId" target="GENPS_serviceInstanceId" /> - <camunda:in source="serviceType" target="GENPS_serviceType" /> - <camunda:in sourceExpression="service-instance" target="GENPS_type" /> - <camunda:in source="serviceInstanceData" target="GENPS_payload" /> - <camunda:out source="GENPS_SuccessIndicator" target="GENPS_SuccessIndicator" /> - <camunda:in source="msoRequestId" target="GENPS_requesId" /> - <camunda:out source="WorkflowException" target="WorkflowException" /> - </bpmn2:extensionElements> - <bpmn2:incoming>SequenceFlow_1i7t9hq</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_129ih1g</bpmn2:outgoing> - </bpmn2:callActivity> - <bpmn2:sequenceFlow id="SequenceFlow_129ih1g" sourceRef="CustomE2EPutService" targetRef="ScriptTask_0q37vn9" /> <bpmn2:subProcess id="SubProcess_06d8lk8" name="Sub-process for Application Errors" triggeredByEvent="true"> <bpmn2:startEvent id="StartEvent_0yljq9y"> <bpmn2:outgoing>SequenceFlow_0tgrn11</bpmn2:outgoing> @@ -67,51 +52,17 @@ dcsi.postProcessRollback(execution) </bpmn2:scriptTask> <bpmn2:sequenceFlow id="SequenceFlow_1xzgv5k" sourceRef="ScriptTask_1p0vyip" targetRef="EndEvent_117lkk3" /> </bpmn2:subProcess> - <bpmn2:scriptTask id="ScriptTask_0q37vn9" name="Post Process AAI PUT" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_129ih1g</bpmn2:incoming> + <bpmn2:scriptTask id="ScriptTask_0q37vn9" name=" AAI Create (srv instance) " scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_012h7yx</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_1tkgqu3</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* def ddsi = new DoCreateE2EServiceInstance() -ddsi.postProcessAAIPUT(execution)]]></bpmn2:script> +ddsi.createServiceInstance(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_1qctzm0" sourceRef="Task_0uiekmn" targetRef="Task_0raqlqc" /> - <bpmn2:scriptTask id="Task_0uiekmn" name="Prepare Resource Oper Status" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_1e5j351</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_1qctzm0</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* -def ddsi = new DoCreateE2EServiceInstance() -ddsi.preInitResourcesOperStatus(execution)]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:serviceTask id="Task_0raqlqc" name="Init Resource Oper Status"> - <bpmn2:extensionElements> - <camunda:connector> - <camunda:inputOutput> - <camunda:inputParameter name="url">${CVFMI_dbAdapterEndpoint}</camunda:inputParameter> - <camunda:inputParameter name="headers"> - <camunda:map> - <camunda:entry key="content-type">application/soap+xml</camunda:entry> - <camunda:entry key="Authorization">Basic QlBFTENsaWVudDpwYXNzd29yZDEk</camunda:entry> - </camunda:map> - </camunda:inputParameter> - <camunda:inputParameter name="payload">${CVFMI_initResOperStatusRequest}</camunda:inputParameter> - <camunda:inputParameter name="method">POST</camunda:inputParameter> - <camunda:outputParameter name="CVFMI_dbResponseCode">${statusCode}</camunda:outputParameter> - <camunda:outputParameter name="CVFMI_dbResponse">${response}</camunda:outputParameter> - </camunda:inputOutput> - <camunda:connectorId>http-connector</camunda:connectorId> - </camunda:connector> - </bpmn2:extensionElements> - <bpmn2:incoming>SequenceFlow_1qctzm0</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_1s5aas9</bpmn2:outgoing> - </bpmn2:serviceTask> <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_0bq4fxs" name="Go to Decompose_Service"> <bpmn2:incoming>SequenceFlow_0w9t6tc</bpmn2:incoming> <bpmn2:linkEventDefinition name="Decompose_Service" /> </bpmn2:intermediateThrowEvent> - <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_1mlbhmt" name="GoTo StartService"> - <bpmn2:incoming>SequenceFlow_012h7yx</bpmn2:incoming> - <bpmn2:linkEventDefinition name="StartService" /> - </bpmn2:intermediateThrowEvent> <bpmn2:scriptTask id="ScriptTask_1o01d7d" name="PostProcess Decompose Service " scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_0xjwb45</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_012h7yx</bpmn2:outgoing> @@ -152,17 +103,41 @@ dcsi.prepareDecomposeService(execution)]]></bpmn2:script> </bpmn2:intermediateThrowEvent> <bpmn2:sequenceFlow id="SequenceFlow_1tkgqu3" sourceRef="ScriptTask_0q37vn9" targetRef="IntermediateThrowEvent_16okck2" /> <bpmn2:sequenceFlow id="SequenceFlow_0w9t6tc" sourceRef="preProcessRequest_ScriptTask" targetRef="IntermediateThrowEvent_0bq4fxs" /> - <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_0jrb3xu" name="StartService"> - <bpmn2:outgoing>SequenceFlow_1i7t9hq</bpmn2:outgoing> - <bpmn2:linkEventDefinition name="StartService" /> - </bpmn2:intermediateCatchEvent> - <bpmn2:sequenceFlow id="SequenceFlow_1i7t9hq" sourceRef="IntermediateCatchEvent_0jrb3xu" targetRef="CustomE2EPutService" /> <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_05dus9b" name="StartPrepareResource"> - <bpmn2:outgoing>SequenceFlow_1hbesp9</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_0yuzaen</bpmn2:outgoing> <bpmn2:linkEventDefinition name="StartPrepareResource" /> </bpmn2:intermediateCatchEvent> - <bpmn2:sequenceFlow id="SequenceFlow_1hbesp9" sourceRef="IntermediateCatchEvent_05dus9b" targetRef="ScriptTask_0dpt36a" /> - <bpmn2:callActivity id="CallActivity_1ojtwas" name="Call DoCreateResources" calledElement="DoCreateResourcesV3"> + <bpmn2:sequenceFlow id="SequenceFlow_012h7yx" sourceRef="ScriptTask_1o01d7d" targetRef="ScriptTask_0q37vn9" /> + <bpmn2:scriptTask id="ScriptTask_1rzf8a1" name="Prepare Resource Oper Status" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1y9rkfr</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0n7nbx3</bpmn2:outgoing> + <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* +def ddsi = new DoCreateE2EServiceInstance() +ddsi.preInitResourcesOperStatus(execution)]]></bpmn2:script> + </bpmn2:scriptTask> + <bpmn2:serviceTask id="ServiceTask_1asgesv" name="Init Resource Oper Status"> + <bpmn2:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${CVFMI_dbAdapterEndpoint}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:map> + <camunda:entry key="content-type">application/soap+xml</camunda:entry> + <camunda:entry key="Authorization">Basic QlBFTENsaWVudDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${CVFMI_initResOperStatusRequest}</camunda:inputParameter> + <camunda:inputParameter name="method">POST</camunda:inputParameter> + <camunda:outputParameter name="CVFMI_dbResponseCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="CVFMI_dbResponse">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_0n7nbx3</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0ckto7v</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:callActivity id="CallActivity_1gae03e" name="Call DoCreateResources" calledElement="DoCreateResourcesV3"> <bpmn2:extensionElements> <camunda:in source="nsServiceName" target="nsServiceName" /> <camunda:in source="nsServiceDescription" target="nsServiceDescription" /> @@ -180,71 +155,62 @@ dcsi.prepareDecomposeService(execution)]]></bpmn2:script> <camunda:in source="uuiRequest" target="uuiRequest" /> <camunda:in source="msoRequestId" target="msoRequestId" /> </bpmn2:extensionElements> - <bpmn2:incoming>SequenceFlow_0bf6bzp</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_0d0c20n</bpmn2:outgoing> + <bpmn2:incoming>SequenceFlow_0b1dsaj</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0sphcy5</bpmn2:outgoing> </bpmn2:callActivity> - <bpmn2:scriptTask id="ScriptTask_04b21gb" name="PreProcess for Add Resources" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_0p6ba92</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_0bf6bzp</bpmn2:outgoing> + <bpmn2:scriptTask id="ScriptTask_0ns08tn" name="PreProcess for Add Resources" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_022onug</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0b1dsaj</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* def csi = new DoCreateE2EServiceInstance() csi.preProcessForAddResource(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:scriptTask id="ScriptTask_1y7jr4t" name="PostProcess for Add Resource" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_0d0c20n</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_0a6vgsu</bpmn2:outgoing> + <bpmn2:scriptTask id="ScriptTask_19t13rd" name="PostProcess for Add Resource" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_0sphcy5</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_18gnns6</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* def csi = new DoCreateE2EServiceInstance() csi.postProcessForAddResource(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_0bf6bzp" sourceRef="ScriptTask_04b21gb" targetRef="CallActivity_1ojtwas" /> - <bpmn2:sequenceFlow id="SequenceFlow_0d0c20n" sourceRef="CallActivity_1ojtwas" targetRef="ScriptTask_1y7jr4t" /> - <bpmn2:endEvent id="EndEvent_0hzmoug"> - <bpmn2:incoming>SequenceFlow_0a6vgsu</bpmn2:incoming> + <bpmn2:endEvent id="EndEvent_1x4kvfh"> + <bpmn2:incoming>SequenceFlow_18gnns6</bpmn2:incoming> </bpmn2:endEvent> - <bpmn2:sequenceFlow id="SequenceFlow_0a6vgsu" sourceRef="ScriptTask_1y7jr4t" targetRef="EndEvent_0hzmoug" /> - <bpmn2:sequenceFlow id="SequenceFlow_012h7yx" sourceRef="ScriptTask_1o01d7d" targetRef="IntermediateThrowEvent_1mlbhmt" /> - <bpmn2:scriptTask id="ScriptTask_0dpt36a" name="Process Site Location" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_1hbesp9</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_1e5j351</bpmn2:outgoing> + <bpmn2:scriptTask id="ScriptTask_0jxdler" name="Process Site Location" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_0yuzaen</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_1y9rkfr</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* def dcsi= new DoCreateE2EServiceInstance() dcsi.doProcessSiteLocation(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:scriptTask id="ScriptTask_1a5mdd6" name="Process Link TP Resource Allocation" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_1s5aas9</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_0p6ba92</bpmn2:outgoing> + <bpmn2:scriptTask id="ScriptTask_0ts3c3b" name="Process Link TP Resource Allocation" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_0ckto7v</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_022onug</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* def dcsi= new DoCreateE2EServiceInstance() dcsi.doTPResourcesAllocation(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_0p6ba92" sourceRef="ScriptTask_1a5mdd6" targetRef="ScriptTask_04b21gb" /> - <bpmn2:sequenceFlow id="SequenceFlow_1s5aas9" sourceRef="Task_0raqlqc" targetRef="ScriptTask_1a5mdd6" /> - <bpmn2:sequenceFlow id="SequenceFlow_1e5j351" sourceRef="ScriptTask_0dpt36a" targetRef="Task_0uiekmn" /> + <bpmn2:sequenceFlow id="SequenceFlow_1y9rkfr" sourceRef="ScriptTask_0jxdler" targetRef="ScriptTask_1rzf8a1" /> + <bpmn2:sequenceFlow id="SequenceFlow_0n7nbx3" sourceRef="ScriptTask_1rzf8a1" targetRef="ServiceTask_1asgesv" /> + <bpmn2:sequenceFlow id="SequenceFlow_0ckto7v" sourceRef="ServiceTask_1asgesv" targetRef="ScriptTask_0ts3c3b" /> + <bpmn2:sequenceFlow id="SequenceFlow_0b1dsaj" sourceRef="ScriptTask_0ns08tn" targetRef="CallActivity_1gae03e" /> + <bpmn2:sequenceFlow id="SequenceFlow_0sphcy5" sourceRef="CallActivity_1gae03e" targetRef="ScriptTask_19t13rd" /> + <bpmn2:sequenceFlow id="SequenceFlow_022onug" sourceRef="ScriptTask_0ts3c3b" targetRef="ScriptTask_0ns08tn" /> + <bpmn2:sequenceFlow id="SequenceFlow_18gnns6" sourceRef="ScriptTask_19t13rd" targetRef="EndEvent_1x4kvfh" /> + <bpmn2:sequenceFlow id="SequenceFlow_0yuzaen" sourceRef="IntermediateCatchEvent_05dus9b" targetRef="ScriptTask_0jxdler" /> </bpmn2:process> <bpmn2:error id="Error_2" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmn2:error id="Error_1" name="java.lang.Exception" errorCode="java.lang.Exception" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCreateE2EServiceInstanceV3"> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_47" bpmnElement="createSI_startEvent"> - <dc:Bounds x="18" y="-207" width="36" height="36" /> + <dc:Bounds x="9" y="-22" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="12" y="-166" width="50" height="12" /> + <dc:Bounds x="3" y="19" width="50" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_61" bpmnElement="preProcessRequest_ScriptTask"> - <dc:Bounds x="126" y="-229" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="CallActivity_0khp0qc_di" bpmnElement="CustomE2EPutService"> - <dc:Bounds x="478" y="54" width="100" height="80" /> + <dc:Bounds x="117" y="-44" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_129ih1g_di" bpmnElement="SequenceFlow_129ih1g"> - <di:waypoint xsi:type="dc:Point" x="578" y="94" /> - <di:waypoint xsi:type="dc:Point" x="713" y="94" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="600.5" y="79" width="90" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="SubProcess_06d8lk8_di" bpmnElement="SubProcess_06d8lk8" isExpanded="true"> <dc:Bounds x="15" y="865" width="783" height="195" /> </bpmndi:BPMNShape> @@ -278,7 +244,7 @@ dcsi.doTPResourcesAllocation(execution)]]></bpmn2:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_0q37vn9_di" bpmnElement="ScriptTask_0q37vn9"> - <dc:Bounds x="713" y="54" width="100" height="80" /> + <dc:Bounds x="1012" y="106" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0ocetux_di" bpmnElement="ScriptTask_0ocetux"> <dc:Bounds x="246" y="920" width="100" height="80" /> @@ -302,109 +268,77 @@ dcsi.doTPResourcesAllocation(execution)]]></bpmn2:script> <dc:Bounds x="679" y="960" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1qctzm0_di" bpmnElement="SequenceFlow_1qctzm0"> - <di:waypoint xsi:type="dc:Point" x="376" y="300" /> - <di:waypoint xsi:type="dc:Point" x="447" y="300" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="367" y="279" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_0v81r5h_di" bpmnElement="Task_0uiekmn"> - <dc:Bounds x="276" y="260" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_14tnuxf_di" bpmnElement="Task_0raqlqc"> - <dc:Bounds x="447" y="260" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="IntermediateThrowEvent_11saqvj_di" bpmnElement="IntermediateThrowEvent_0bq4fxs"> - <dc:Bounds x="1315" y="-207" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1290" y="-167" width="88" height="36" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="IntermediateThrowEvent_1mlbhmt_di" bpmnElement="IntermediateThrowEvent_1mlbhmt"> - <dc:Bounds x="1315" y="-57" width="36" height="36" /> + <dc:Bounds x="1306" y="-22" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1288" y="-16" width="90" height="12" /> + <dc:Bounds x="1281" y="18" width="88" height="36" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1o01d7d_di" bpmnElement="ScriptTask_1o01d7d"> - <dc:Bounds x="713" y="-79" width="100" height="80" /> + <dc:Bounds x="704" y="106" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_0biblpc_di" bpmnElement="CallActivity_0biblpc"> - <dc:Bounds x="478" y="-79" width="100" height="80" /> + <dc:Bounds x="469" y="106" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1cllqk3_di" bpmnElement="ScriptTask_1cllqk3"> - <dc:Bounds x="196" y="-79" width="100" height="80" /> + <dc:Bounds x="187" y="106" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="IntermediateCatchEvent_0tv85pg_di" bpmnElement="IntermediateCatchEvent_0tv85pg"> - <dc:Bounds x="26" y="-57" width="36" height="36" /> + <dc:Bounds x="17" y="128" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="2" y="-21" width="88" height="24" /> + <dc:Bounds x="-7" y="164" width="88" height="24" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0xjwb45_di" bpmnElement="SequenceFlow_0xjwb45"> - <di:waypoint xsi:type="dc:Point" x="578" y="-39" /> - <di:waypoint xsi:type="dc:Point" x="713" y="-39" /> + <di:waypoint xsi:type="dc:Point" x="569" y="146" /> + <di:waypoint xsi:type="dc:Point" x="704" y="146" /> <bpmndi:BPMNLabel> - <dc:Bounds x="645.5" y="-60" width="0" height="12" /> + <dc:Bounds x="592" y="125" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0qxzgvq_di" bpmnElement="SequenceFlow_0qxzgvq"> - <di:waypoint xsi:type="dc:Point" x="296" y="-39" /> - <di:waypoint xsi:type="dc:Point" x="478" y="-39" /> + <di:waypoint xsi:type="dc:Point" x="287" y="146" /> + <di:waypoint xsi:type="dc:Point" x="469" y="146" /> <bpmndi:BPMNLabel> - <dc:Bounds x="387" y="-60" width="0" height="12" /> + <dc:Bounds x="333" y="125" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1qiiycn_di" bpmnElement="SequenceFlow_1qiiycn"> - <di:waypoint xsi:type="dc:Point" x="54" y="-189" /> - <di:waypoint xsi:type="dc:Point" x="126" y="-189" /> + <di:waypoint xsi:type="dc:Point" x="45" y="-4" /> + <di:waypoint xsi:type="dc:Point" x="117" y="-4" /> <bpmndi:BPMNLabel> - <dc:Bounds x="90" y="-210" width="0" height="12" /> + <dc:Bounds x="36" y="-25" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_166w91p_di" bpmnElement="SequenceFlow_166w91p"> - <di:waypoint xsi:type="dc:Point" x="62" y="-39" /> - <di:waypoint xsi:type="dc:Point" x="196" y="-39" /> + <di:waypoint xsi:type="dc:Point" x="53" y="146" /> + <di:waypoint xsi:type="dc:Point" x="187" y="146" /> <bpmndi:BPMNLabel> - <dc:Bounds x="129" y="-60" width="0" height="12" /> + <dc:Bounds x="75" y="125" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateThrowEvent_16okck2_di" bpmnElement="IntermediateThrowEvent_16okck2"> - <dc:Bounds x="1315" y="76" width="36" height="36" /> + <dc:Bounds x="1306" y="128" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1299" y="117" width="71" height="24" /> + <dc:Bounds x="1285" y="169" width="82" height="36" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1tkgqu3_di" bpmnElement="SequenceFlow_1tkgqu3"> - <di:waypoint xsi:type="dc:Point" x="813" y="94" /> - <di:waypoint xsi:type="dc:Point" x="1315" y="94" /> + <di:waypoint xsi:type="dc:Point" x="1112" y="146" /> + <di:waypoint xsi:type="dc:Point" x="1222" y="146" /> + <di:waypoint xsi:type="dc:Point" x="1222" y="146" /> + <di:waypoint xsi:type="dc:Point" x="1306" y="146" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1019" y="73" width="90" height="12" /> + <dc:Bounds x="1192" y="140" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0w9t6tc_di" bpmnElement="SequenceFlow_0w9t6tc"> - <di:waypoint xsi:type="dc:Point" x="226" y="-189" /> - <di:waypoint xsi:type="dc:Point" x="771" y="-189" /> - <di:waypoint xsi:type="dc:Point" x="771" y="-189" /> - <di:waypoint xsi:type="dc:Point" x="1315" y="-189" /> + <di:waypoint xsi:type="dc:Point" x="217" y="-4" /> + <di:waypoint xsi:type="dc:Point" x="762" y="-4" /> + <di:waypoint xsi:type="dc:Point" x="762" y="-4" /> + <di:waypoint xsi:type="dc:Point" x="1306" y="-4" /> <bpmndi:BPMNLabel> - <dc:Bounds x="786" y="-195" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="IntermediateCatchEvent_0jrb3xu_di" bpmnElement="IntermediateCatchEvent_0jrb3xu"> - <dc:Bounds x="18" y="76" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="8" y="112" width="60" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1i7t9hq_di" bpmnElement="SequenceFlow_1i7t9hq"> - <di:waypoint xsi:type="dc:Point" x="54" y="94" /> - <di:waypoint xsi:type="dc:Point" x="266" y="94" /> - <di:waypoint xsi:type="dc:Point" x="266" y="94" /> - <di:waypoint xsi:type="dc:Point" x="478" y="94" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="236" y="88" width="90" height="12" /> + <dc:Bounds x="732" y="-10" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateCatchEvent_05dus9b_di" bpmnElement="IntermediateCatchEvent_05dus9b"> @@ -413,83 +347,98 @@ dcsi.doTPResourcesAllocation(execution)]]></bpmn2:script> <dc:Bounds x="-3" y="318" width="82" height="24" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1hbesp9_di" bpmnElement="SequenceFlow_1hbesp9"> - <di:waypoint xsi:type="dc:Point" x="54" y="300" /> - <di:waypoint xsi:type="dc:Point" x="102" y="300" /> + <bpmndi:BPMNEdge id="SequenceFlow_012h7yx_di" bpmnElement="SequenceFlow_012h7yx"> + <di:waypoint xsi:type="dc:Point" x="804" y="146" /> + <di:waypoint xsi:type="dc:Point" x="917" y="146" /> + <di:waypoint xsi:type="dc:Point" x="917" y="146" /> + <di:waypoint xsi:type="dc:Point" x="1012" y="146" /> <bpmndi:BPMNLabel> - <dc:Bounds x="33" y="279" width="90" height="12" /> + <dc:Bounds x="887" y="139" width="90" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="CallActivity_1ojtwas_di" bpmnElement="CallActivity_1ojtwas"> - <dc:Bounds x="971" y="260" width="100" height="80" /> + <bpmndi:BPMNShape id="ScriptTask_1rzf8a1_di" bpmnElement="ScriptTask_1rzf8a1"> + <dc:Bounds x="262" y="260" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1asgesv_di" bpmnElement="ServiceTask_1asgesv"> + <dc:Bounds x="433" y="260" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_04b21gb_di" bpmnElement="ScriptTask_04b21gb"> - <dc:Bounds x="799" y="260" width="100" height="80" /> + <bpmndi:BPMNShape id="CallActivity_1gae03e_di" bpmnElement="CallActivity_1gae03e"> + <dc:Bounds x="957" y="260" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_1y7jr4t_di" bpmnElement="ScriptTask_1y7jr4t"> - <dc:Bounds x="1145" y="260" width="100" height="80" /> + <bpmndi:BPMNShape id="ScriptTask_0ns08tn_di" bpmnElement="ScriptTask_0ns08tn"> + <dc:Bounds x="785" y="260" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0bf6bzp_di" bpmnElement="SequenceFlow_0bf6bzp"> - <di:waypoint xsi:type="dc:Point" x="899" y="300" /> - <di:waypoint xsi:type="dc:Point" x="971" y="300" /> + <bpmndi:BPMNShape id="ScriptTask_19t13rd_di" bpmnElement="ScriptTask_19t13rd"> + <dc:Bounds x="1131" y="260" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1x4kvfh_di" bpmnElement="EndEvent_1x4kvfh"> + <dc:Bounds x="1301" y="282" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="890" y="279" width="90" height="12" /> + <dc:Bounds x="1274" y="322" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0jxdler_di" bpmnElement="ScriptTask_0jxdler"> + <dc:Bounds x="88" y="260" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0ts3c3b_di" bpmnElement="ScriptTask_0ts3c3b"> + <dc:Bounds x="599" y="260" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1y9rkfr_di" bpmnElement="SequenceFlow_1y9rkfr"> + <di:waypoint xsi:type="dc:Point" x="188" y="300" /> + <di:waypoint xsi:type="dc:Point" x="262" y="300" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="180" y="279" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0d0c20n_di" bpmnElement="SequenceFlow_0d0c20n"> - <di:waypoint xsi:type="dc:Point" x="1071" y="300" /> - <di:waypoint xsi:type="dc:Point" x="1145" y="300" /> + <bpmndi:BPMNEdge id="SequenceFlow_0n7nbx3_di" bpmnElement="SequenceFlow_0n7nbx3"> + <di:waypoint xsi:type="dc:Point" x="362" y="300" /> + <di:waypoint xsi:type="dc:Point" x="433" y="300" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1063" y="279" width="90" height="12" /> + <dc:Bounds x="353.5" y="279" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="EndEvent_0hzmoug_di" bpmnElement="EndEvent_0hzmoug"> - <dc:Bounds x="1315" y="282.4076655052265" width="36" height="36" /> + <bpmndi:BPMNEdge id="SequenceFlow_0ckto7v_di" bpmnElement="SequenceFlow_0ckto7v"> + <di:waypoint xsi:type="dc:Point" x="533" y="300" /> + <di:waypoint xsi:type="dc:Point" x="599" y="300" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1333" y="322.4076655052265" width="0" height="12" /> + <dc:Bounds x="521" y="279" width="0" height="12" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0a6vgsu_di" bpmnElement="SequenceFlow_0a6vgsu"> - <di:waypoint xsi:type="dc:Point" x="1245" y="300" /> - <di:waypoint xsi:type="dc:Point" x="1315" y="300" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0b1dsaj_di" bpmnElement="SequenceFlow_0b1dsaj"> + <di:waypoint xsi:type="dc:Point" x="885" y="300" /> + <di:waypoint xsi:type="dc:Point" x="957" y="300" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1235" y="279" width="90" height="12" /> + <dc:Bounds x="876" y="279" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_012h7yx_di" bpmnElement="SequenceFlow_012h7yx"> - <di:waypoint xsi:type="dc:Point" x="813" y="-39" /> - <di:waypoint xsi:type="dc:Point" x="1315" y="-39" /> + <bpmndi:BPMNEdge id="SequenceFlow_0sphcy5_di" bpmnElement="SequenceFlow_0sphcy5"> + <di:waypoint xsi:type="dc:Point" x="1057" y="300" /> + <di:waypoint xsi:type="dc:Point" x="1131" y="300" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1064" y="-61" width="0" height="14" /> + <dc:Bounds x="1049" y="279" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_0dpt36a_di" bpmnElement="ScriptTask_0dpt36a"> - <dc:Bounds x="102" y="260" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_1a5mdd6_di" bpmnElement="ScriptTask_1a5mdd6"> - <dc:Bounds x="613" y="260" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0p6ba92_di" bpmnElement="SequenceFlow_0p6ba92"> - <di:waypoint xsi:type="dc:Point" x="713" y="300" /> - <di:waypoint xsi:type="dc:Point" x="799" y="300" /> + <bpmndi:BPMNEdge id="SequenceFlow_022onug_di" bpmnElement="SequenceFlow_022onug"> + <di:waypoint xsi:type="dc:Point" x="699" y="300" /> + <di:waypoint xsi:type="dc:Point" x="785" y="300" /> <bpmndi:BPMNLabel> - <dc:Bounds x="756" y="279" width="0" height="12" /> + <dc:Bounds x="697" y="279" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1s5aas9_di" bpmnElement="SequenceFlow_1s5aas9"> - <di:waypoint xsi:type="dc:Point" x="547" y="300" /> - <di:waypoint xsi:type="dc:Point" x="613" y="300" /> + <bpmndi:BPMNEdge id="SequenceFlow_18gnns6_di" bpmnElement="SequenceFlow_18gnns6"> + <di:waypoint xsi:type="dc:Point" x="1231" y="300" /> + <di:waypoint xsi:type="dc:Point" x="1301" y="300" /> <bpmndi:BPMNLabel> - <dc:Bounds x="580" y="279" width="0" height="12" /> + <dc:Bounds x="1221" y="279" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1e5j351_di" bpmnElement="SequenceFlow_1e5j351"> - <di:waypoint xsi:type="dc:Point" x="202" y="300" /> - <di:waypoint xsi:type="dc:Point" x="276" y="300" /> + <bpmndi:BPMNEdge id="SequenceFlow_0yuzaen_di" bpmnElement="SequenceFlow_0yuzaen"> + <di:waypoint xsi:type="dc:Point" x="54" y="300" /> + <di:waypoint xsi:type="dc:Point" x="88" y="300" /> <bpmndi:BPMNLabel> - <dc:Bounds x="239" y="279" width="0" height="12" /> + <dc:Bounds x="71" y="279" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn2:definitions> +</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn index 77c62e573d..c699f911d0 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn @@ -14,21 +14,6 @@ dcsi.preProcessRequest(execution) ]]></bpmn2:script> </bpmn2:scriptTask> <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="preProcessRequest_ScriptTask" targetRef="IntermediateThrowEvent_0aggdcl_GoToStartService" /> - <bpmn2:callActivity id="CustomE2EPutService" name="Call Custom E2E Put Service" calledElement="CustomE2EPutService"> - <bpmn2:extensionElements> - <camunda:in source="globalSubscriberId" target="GENPS_globalSubscriberId" /> - <camunda:in source="serviceInstanceId" target="GENPS_serviceInstanceId" /> - <camunda:in source="serviceType" target="GENPS_serviceType" /> - <camunda:in sourceExpression="service-instance" target="GENPS_type" /> - <camunda:in source="serviceInstanceData" target="GENPS_payload" /> - <camunda:out source="GENPS_SuccessIndicator" target="GENPS_SuccessIndicator" /> - <camunda:in source="msoRequestId" target="GENPS_requesId" /> - <camunda:out source="WorkflowException" target="WorkflowException" /> - </bpmn2:extensionElements> - <bpmn2:incoming>SequenceFlow_0zmz5am</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_129ih1g</bpmn2:outgoing> - </bpmn2:callActivity> - <bpmn2:sequenceFlow id="SequenceFlow_129ih1g" sourceRef="CustomE2EPutService" targetRef="ScriptTask_0q37vn9_PostProcessAAIPUT" /> <bpmn2:subProcess id="SubProcess_06d8lk8" name="Sub-process for Application Errors" triggeredByEvent="true"> <bpmn2:startEvent id="StartEvent_0yljq9y"> <bpmn2:outgoing>SequenceFlow_0tgrn11</bpmn2:outgoing> @@ -70,7 +55,7 @@ dcsi.postProcessRollback(execution) <bpmn2:sequenceFlow id="SequenceFlow_1xzgv5k" sourceRef="ScriptTask_1p0vyip" targetRef="EndEvent_117lkk3" /> </bpmn2:subProcess> <bpmn2:scriptTask id="ScriptTask_0q37vn9_PostProcessAAIPUT" name="Post Process AAI PUT" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_129ih1g</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_0zmz5am</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_03fabby</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* def ddsi = new DoCreateE2EServiceInstanceV2() @@ -212,7 +197,7 @@ csi.postOtherControllerType(execution)]]></bpmn2:script> <bpmn2:outgoing>SequenceFlow_0zmz5am</bpmn2:outgoing> <bpmn2:linkEventDefinition name="StartService" /> </bpmn2:intermediateCatchEvent> - <bpmn2:sequenceFlow id="SequenceFlow_0zmz5am" sourceRef="StartEvent_0l5bz4h_StartService" targetRef="CustomE2EPutService" /> + <bpmn2:sequenceFlow id="SequenceFlow_0zmz5am" sourceRef="StartEvent_0l5bz4h_StartService" targetRef="ScriptTask_0q37vn9_PostProcessAAIPUT" /> <bpmn2:sequenceFlow id="SequenceFlow_1rhn48b" sourceRef="StartEvent_StartResource" targetRef="ExclusiveGateway_1pwgsa8" /> <bpmn2:intermediateCatchEvent id="StartEvent_StartResource" name="StartResource"> <bpmn2:outgoing>SequenceFlow_1rhn48b</bpmn2:outgoing> @@ -471,16 +456,6 @@ ddsi.preUpdateServiceOperationStatus(execution)]]></bpmn2:script> <dc:Bounds x="718" y="82" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="CallActivity_0khp0qc_di" bpmnElement="CustomE2EPutService"> - <dc:Bounds x="564" y="244" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_129ih1g_di" bpmnElement="SequenceFlow_129ih1g"> - <di:waypoint xsi:type="dc:Point" x="664" y="284" /> - <di:waypoint xsi:type="dc:Point" x="917" y="284" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="745.5" y="269" width="90" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="SubProcess_06d8lk8_di" bpmnElement="SubProcess_06d8lk8" isExpanded="true"> <dc:Bounds x="-11" y="1751" width="783" height="195" /> </bpmndi:BPMNShape> @@ -731,9 +706,9 @@ ddsi.preUpdateServiceOperationStatus(execution)]]></bpmn2:script> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0zmz5am_di" bpmnElement="SequenceFlow_0zmz5am"> <di:waypoint xsi:type="dc:Point" x="22" y="284" /> - <di:waypoint xsi:type="dc:Point" x="564" y="284" /> + <di:waypoint xsi:type="dc:Point" x="917" y="284" /> <bpmndi:BPMNLabel> - <dc:Bounds x="248" y="263" width="90" height="12" /> + <dc:Bounds x="424.5" y="263" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1rhn48b_di" bpmnElement="SequenceFlow_1rhn48b"> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstance.bpmn index 2c6f5ee61d..e3f1d7721d 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateServiceInstance.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> - <bpmn2:process id="DoCreateServiceInstance" name="DoCreateServiceInstance" isExecutable="true"> + <bpmn2:process id="DoCreateServiceInstance" name="DoCreateServiceInstance " isExecutable="true"> <bpmn2:startEvent id="createSI_startEvent" name="Start Flow"> <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> </bpmn2:startEvent> @@ -12,7 +12,7 @@ def dcsi = new DoCreateServiceInstance() dcsi.getAAICustomerById(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_3" name="" sourceRef="getAAICustomerById_scriptTask" targetRef="callGenericPutService" /> + <bpmn2:sequenceFlow id="SequenceFlow_3" name="" sourceRef="getAAICustomerById_scriptTask" targetRef="ScriptTask_0q37vn9" /> <bpmn2:scriptTask id="preProcessRequest_ScriptTask" name="PreProcess Incoming Request" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing> @@ -54,20 +54,6 @@ dcsi.postProcessSDNCAssign(execution)]]></bpmn2:script> <bpmn2:sequenceFlow id="SequenceFlow_14" name="" sourceRef="PreProcessSDNCAssignRequest" targetRef="CallSDNCAdapterServiceTopologyAssign" /> <bpmn2:sequenceFlow id="SequenceFlow_9" name="" sourceRef="CallSDNCAdapterServiceTopologyAssign" targetRef="PostProcessSDNCAssignRequest" /> <bpmn2:sequenceFlow id="SequenceFlow_10" name="" sourceRef="PostProcessSDNCAssignRequest" targetRef="EndEvent_3" /> - <bpmn2:callActivity id="callGenericPutService" name="Call Generic Put Service" calledElement="GenericPutService"> - <bpmn2:extensionElements> - <camunda:in source="globalSubscriberId" target="GENPS_globalSubscriberId" /> - <camunda:in source="serviceInstanceId" target="GENPS_serviceInstanceId" /> - <camunda:in source="subscriptionServiceType" target="GENPS_serviceType" /> - <camunda:in sourceExpression="service-instance" target="GENPS_type" /> - <camunda:in source="serviceInstanceData" target="GENPS_payload" /> - <camunda:out source="GENPS_SuccessIndicator" target="GENPS_SuccessIndicator" /> - <camunda:in source="msoRequestId" target="GENPS_requesId" /> - <camunda:out source="WorkflowException" target="WorkflowException" /> - </bpmn2:extensionElements> - <bpmn2:incoming>SequenceFlow_3</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_1jhzmzn</bpmn2:outgoing> - </bpmn2:callActivity> <bpmn2:subProcess id="SubProcess_06d8lk8" name="Sub-process for Application Errors" triggeredByEvent="true"> <bpmn2:startEvent id="StartEvent_0yljq9y"> <bpmn2:outgoing>SequenceFlow_0tgrn11</bpmn2:outgoing> @@ -120,12 +106,12 @@ dcsi.postProcessRollback(execution) <bpmn2:sequenceFlow id="SequenceFlow_00v4npo" name="yes" sourceRef="ExclusiveGateway_1nk6aol" targetRef="EndEvent_10659gr"> <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{!execution.getVariable("sendToSDNC")}]]></bpmn2:conditionExpression> </bpmn2:sequenceFlow> - <bpmn2:scriptTask id="ScriptTask_0q37vn9" name="Post Process AAI PUT" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_1jhzmzn</bpmn2:incoming> + <bpmn2:scriptTask id="ScriptTask_0q37vn9" name=" AAI Create (svc instance) " scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_3</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_16sdyz9</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* def ddsi = new DoCreateServiceInstance() -ddsi.postProcessAAIPUT(execution)]]></bpmn2:script> +ddsi.putServiceInstance(execution)]]></bpmn2:script> </bpmn2:scriptTask> <bpmn2:sequenceFlow id="SequenceFlow_0k0wn03" sourceRef="Task_0wj9ajs" targetRef="Task_1g8wthf" /> <bpmn2:scriptTask id="Task_0wj9ajs" name="Create Project" scriptFormat="groovy"> @@ -142,7 +128,6 @@ dcsi.createProject(execution)]]></bpmn2:script> def dcsi = new DoCreateServiceInstance() dcsi.createOwningEntity(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_1jhzmzn" sourceRef="callGenericPutService" targetRef="ScriptTask_0q37vn9" /> <bpmn2:sequenceFlow id="SequenceFlow_0w5i6vf" sourceRef="Task_1g8wthf" targetRef="ExclusiveGateway_1nk6aol" /> <bpmn2:sequenceFlow id="SequenceFlow_16sdyz9" sourceRef="ScriptTask_0q37vn9" targetRef="Task_0wj9ajs" /> <bpmn2:subProcess id="SubProcess_1awd8cm" name="Sub-process for UnexpectedErrors" triggeredByEvent="true"> @@ -189,26 +174,25 @@ dcsi.processJavaException(execution)]]></bpmn2:script> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_3" sourceElement="_BPMNShape_ScriptTask_62"> <di:waypoint xsi:type="dc:Point" x="493" y="97" /> - <di:waypoint xsi:type="dc:Point" x="1022" y="97" /> - <di:waypoint xsi:type="dc:Point" x="1022" y="206" /> + <di:waypoint xsi:type="dc:Point" x="572" y="97" /> <bpmndi:BPMNLabel> - <dc:Bounds x="712.5" y="82" width="90" height="0" /> + <dc:Bounds x="487.5" y="82" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_EndEvent_177" bpmnElement="EndEvent_3"> - <dc:Bounds x="1004" y="1216" width="36" height="36" /> + <dc:Bounds x="1057" y="660" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="977" y="1257" width="90" height="0" /> + <dc:Bounds x="1030" y="701" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_334" bpmnElement="PreProcessSDNCAssignRequest"> - <dc:Bounds x="972" y="810" width="100" height="80" /> + <dc:Bounds x="1025" y="202" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_335" bpmnElement="PostProcessSDNCAssignRequest"> - <dc:Bounds x="972" y="1054" width="100" height="80" /> + <dc:Bounds x="1025" y="493" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="_BPMNShape_CallActivity_74" bpmnElement="CallSDNCAdapterServiceTopologyAssign"> - <dc:Bounds x="972" y="930" width="100" height="80" /> + <dc:Bounds x="1025" y="339" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ScriptTask_61" targetElement="_BPMNShape_ScriptTask_62"> <di:waypoint xsi:type="dc:Point" x="345" y="97" /> @@ -218,29 +202,30 @@ dcsi.processJavaException(execution)]]></bpmn2:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_8" bpmnElement="SequenceFlow_14" sourceElement="_BPMNShape_ScriptTask_334" targetElement="_BPMNShape_CallActivity_74"> - <di:waypoint xsi:type="dc:Point" x="1020" y="890" /> - <di:waypoint xsi:type="dc:Point" x="1020" y="930" /> + <di:waypoint xsi:type="dc:Point" x="1073" y="282" /> + <di:waypoint xsi:type="dc:Point" x="1073" y="339" /> <bpmndi:BPMNLabel> - <dc:Bounds x="990" y="910" width="90" height="0" /> + <dc:Bounds x="1043" y="310.5" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_11" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_CallActivity_74" targetElement="_BPMNShape_ScriptTask_335"> - <di:waypoint xsi:type="dc:Point" x="1022" y="1010" /> - <di:waypoint xsi:type="dc:Point" x="1022" y="1054" /> + <di:waypoint xsi:type="dc:Point" x="1075" y="419" /> + <di:waypoint xsi:type="dc:Point" x="1075" y="459" /> + <di:waypoint xsi:type="dc:Point" x="1075" y="459" /> + <di:waypoint xsi:type="dc:Point" x="1075" y="493" /> <bpmndi:BPMNLabel> - <dc:Bounds x="992" y="1032" width="90" height="0" /> + <dc:Bounds x="1045" y="459" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_12" bpmnElement="SequenceFlow_10" sourceElement="_BPMNShape_ScriptTask_335"> - <di:waypoint xsi:type="dc:Point" x="1023" y="1134" /> - <di:waypoint xsi:type="dc:Point" x="1022" y="1216" /> + <di:waypoint xsi:type="dc:Point" x="1076" y="573" /> + <di:waypoint xsi:type="dc:Point" x="1076" y="617" /> + <di:waypoint xsi:type="dc:Point" x="1075" y="617" /> + <di:waypoint xsi:type="dc:Point" x="1075" y="660" /> <bpmndi:BPMNLabel> - <dc:Bounds x="977.5" y="1160" width="90" height="0" /> + <dc:Bounds x="1030.5" y="602" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="CallActivity_0khp0qc_di" bpmnElement="callGenericPutService"> - <dc:Bounds x="972" y="206" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="SubProcess_06d8lk8_di" bpmnElement="SubProcess_06d8lk8" isExpanded="true"> <dc:Bounds x="99" y="531" width="783" height="195" /> </bpmndi:BPMNShape> @@ -274,31 +259,29 @@ dcsi.processJavaException(execution)]]></bpmn2:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_1nk6aol_di" bpmnElement="ExclusiveGateway_1nk6aol" isMarkerVisible="true"> - <dc:Bounds x="997" y="717" width="50" height="50" /> + <dc:Bounds x="1050" y="72" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="898" y="729" width="86" height="36" /> + <dc:Bounds x="1032" y="32" width="86" height="36" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_156ih25_di" bpmnElement="SequenceFlow_156ih25"> - <di:waypoint xsi:type="dc:Point" x="1022" y="767" /> - <di:waypoint xsi:type="dc:Point" x="1022" y="810" /> + <di:waypoint xsi:type="dc:Point" x="1075" y="122" /> + <di:waypoint xsi:type="dc:Point" x="1075" y="202" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1039" y="770" width="12" height="12" /> + <dc:Bounds x="1084" y="134.8139534883721" width="12" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_10659gr_di" bpmnElement="EndEvent_10659gr"> - <dc:Bounds x="1105" y="724" width="36" height="36" /> + <dc:Bounds x="1168" y="79" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1078" y="765" width="90" height="0" /> + <dc:Bounds x="1141" y="120" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_00v4npo_di" bpmnElement="SequenceFlow_00v4npo"> - <di:waypoint xsi:type="dc:Point" x="1047" y="742" /> - <di:waypoint xsi:type="dc:Point" x="1075" y="742" /> - <di:waypoint xsi:type="dc:Point" x="1075" y="742" /> - <di:waypoint xsi:type="dc:Point" x="1105" y="742" /> + <di:waypoint xsi:type="dc:Point" x="1100" y="97" /> + <di:waypoint xsi:type="dc:Point" x="1168" y="97" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1050.5" y="718" width="18" height="12" /> + <dc:Bounds x="1108.5" y="99.57142857142858" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_0ocetux_di" bpmnElement="ScriptTask_0ocetux"> @@ -324,40 +307,33 @@ dcsi.processJavaException(execution)]]></bpmn2:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_0q37vn9_di" bpmnElement="ScriptTask_0q37vn9"> - <dc:Bounds x="972" y="336" width="100" height="80" /> + <dc:Bounds x="572" y="57" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0k0wn03_di" bpmnElement="SequenceFlow_0k0wn03"> - <di:waypoint xsi:type="dc:Point" x="1022" y="541" /> - <di:waypoint xsi:type="dc:Point" x="1022" y="589" /> + <di:waypoint xsi:type="dc:Point" x="833" y="97" /> + <di:waypoint xsi:type="dc:Point" x="886" y="97" /> <bpmndi:BPMNLabel> - <dc:Bounds x="992" y="559" width="90" height="12" /> + <dc:Bounds x="814.5" y="76" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_0v8y3ex_di" bpmnElement="Task_0wj9ajs"> - <dc:Bounds x="972" y="461" width="100" height="80" /> + <dc:Bounds x="733" y="57" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0lndrbk_di" bpmnElement="Task_1g8wthf"> - <dc:Bounds x="972" y="589" width="100" height="80" /> + <dc:Bounds x="886" y="57" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1jhzmzn_di" bpmnElement="SequenceFlow_1jhzmzn"> - <di:waypoint xsi:type="dc:Point" x="1022" y="286" /> - <di:waypoint xsi:type="dc:Point" x="1022" y="336" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1037" y="305" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0w5i6vf_di" bpmnElement="SequenceFlow_0w5i6vf"> - <di:waypoint xsi:type="dc:Point" x="1022" y="669" /> - <di:waypoint xsi:type="dc:Point" x="1022" y="717" /> + <di:waypoint xsi:type="dc:Point" x="986" y="97" /> + <di:waypoint xsi:type="dc:Point" x="1050" y="97" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1037" y="687" width="0" height="12" /> + <dc:Bounds x="973" y="76" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_16sdyz9_di" bpmnElement="SequenceFlow_16sdyz9"> - <di:waypoint xsi:type="dc:Point" x="1022" y="416" /> - <di:waypoint xsi:type="dc:Point" x="1022" y="461" /> + <di:waypoint xsi:type="dc:Point" x="672" y="97" /> + <di:waypoint xsi:type="dc:Point" x="733" y="97" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1037" y="432.5" width="0" height="12" /> + <dc:Bounds x="657.5" y="76" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="SubProcess_1awd8cm_di" bpmnElement="SubProcess_1awd8cm" isExpanded="true"> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModule.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModule.bpmn index 820d1174be..c16061edb2 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModule.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVfModule.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_pNTO8MRhEeWv36YLr7PC3Q" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_pNTO8MRhEeWv36YLr7PC3Q" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="DoCreateVfModule" name="DoCreateVfModule" isExecutable="true"> <bpmn2:startEvent id="StartEvent_1" name="Start"> <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> @@ -400,13 +400,13 @@ doCreateVfModule.prepUpdateAAIGenericVnf(execution)]]></bpmn2:script> <bpmn2:outgoing>SequenceFlow_112los9</bpmn2:outgoing> </bpmn2:callActivity> <bpmn2:sequenceFlow id="SequenceFlow_0zcfn2x" name="no" sourceRef="ExclusiveGateway_2" targetRef="IntermediateThrowEvent_3" /> - <bpmn2:sequenceFlow id="SequenceFlow_0m382su" name="yes" sourceRef="ExclusiveGateway_2" targetRef="QueryVNF"> + <bpmn2:sequenceFlow id="SequenceFlow_0m382su" name="yes" sourceRef="ExclusiveGateway_2" targetRef="PreProcessSDNCVnfGetRequest"> <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("DCVFM_sdncVersion" ) == '1707'}]]></bpmn2:conditionExpression> </bpmn2:sequenceFlow> <bpmn2:sequenceFlow id="SequenceFlow_0g270u0" sourceRef="PreProcessSDNCVnfGetRequest" targetRef="CallSDNCAdapterVNFTopologyGET" /> <bpmn2:sequenceFlow id="SequenceFlow_1yrlvgb" sourceRef="CallSDNCAdapterVNFTopologyGET" targetRef="PostProcessSDNCVnfGetRequest" /> <bpmn2:scriptTask id="PreProcessSDNCVnfGetRequest" name="PreProcess SDNC VNF Topology GET Request" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_0d00zqi</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_0m382su</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0g270u0</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* def doCreateVfModule = new DoCreateVfModule() @@ -435,19 +435,7 @@ String response = execution.getVariable("DCVFM_getVnfSDNCAdapterResponse") def doCreateVfModule = new DoCreateVfModule() doCreateVfModule.validateSDNCResponse(execution, response, "get")]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_0d00zqi" sourceRef="QueryVNF" targetRef="PreProcessSDNCVnfGetRequest" /> <bpmn2:sequenceFlow id="SequenceFlow_170kw7h" sourceRef="PostProcessSDNCVnfGetRequest" targetRef="IntermediateThrowEvent_3" /> - <bpmn2:callActivity id="QueryVNF" name="Query VNF" calledElement="GenericGetVnf"> - <bpmn2:extensionElements> - <camunda:in source="DCVFM_vnfId" target="GENGV_vnfId" /> - <camunda:in source="DCVFM_vnfTypeToQuery" target="GENGV_type" /> - <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> - <camunda:out source="GENGV_vnf" target="DCVFM_vnfQueryResponse" /> - <camunda:out source="WorkflowException" target="WorkflowException" /> - </bpmn2:extensionElements> - <bpmn2:incoming>SequenceFlow_0m382su</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_0d00zqi</bpmn2:outgoing> - </bpmn2:callActivity> <bpmn2:sequenceFlow id="SequenceFlow_1f53tby" sourceRef="Task_0kuj2a1" targetRef="IntermediateThrowEvent_1" /> <bpmn2:exclusiveGateway id="ExclusiveGateway_0ffvqla" name="Is vf_module_name specified?" default="SequenceFlow_0270n5c"> <bpmn2:incoming>SequenceFlow_1y1ttqe</bpmn2:incoming> @@ -1248,9 +1236,9 @@ doCreateVfModule.preProcessUpdateAAIVfModuleRequestStatus(execution, 'Assigned') <bpmndi:BPMNEdge id="SequenceFlow_0m382su_di" bpmnElement="SequenceFlow_0m382su"> <di:waypoint xsi:type="dc:Point" x="1433" y="418" /> <di:waypoint xsi:type="dc:Point" x="1433" y="521" /> - <di:waypoint xsi:type="dc:Point" x="1513" y="521" /> + <di:waypoint xsi:type="dc:Point" x="1666" y="521" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1439" y="459.5" width="18" height="12" /> + <dc:Bounds x="1363.5900806639468" y="422.98801391242307" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0g270u0_di" bpmnElement="SequenceFlow_0g270u0"> @@ -1276,13 +1264,6 @@ doCreateVfModule.preProcessUpdateAAIVfModuleRequestStatus(execution, 'Assigned') <bpmndi:BPMNShape id="ScriptTask_09wgk9p_di" bpmnElement="PostProcessSDNCVnfGetRequest"> <dc:Bounds x="1969" y="481" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0d00zqi_di" bpmnElement="SequenceFlow_0d00zqi"> - <di:waypoint xsi:type="dc:Point" x="1613" y="521" /> - <di:waypoint xsi:type="dc:Point" x="1666" y="521" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1640" y="506" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_170kw7h_di" bpmnElement="SequenceFlow_170kw7h"> <di:waypoint xsi:type="dc:Point" x="2069" y="521" /> <di:waypoint xsi:type="dc:Point" x="2131" y="521" /> @@ -1292,9 +1273,6 @@ doCreateVfModule.preProcessUpdateAAIVfModuleRequestStatus(execution, 'Assigned') <dc:Bounds x="2146" y="447.5" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="CallActivity_0xev9kl_di" bpmnElement="QueryVNF"> - <dc:Bounds x="1513" y="481" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1f53tby_di" bpmnElement="SequenceFlow_1f53tby"> <di:waypoint xsi:type="dc:Point" x="776" y="282" /> <di:waypoint xsi:type="dc:Point" x="846" y="282" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnf.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnf.bpmn index a093beae91..50436352ea 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnf.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnf.bpmn @@ -13,44 +13,8 @@ DoCreateVnf createVnf = new DoCreateVnf() createVnf.preProcessRequest(execution)]]></bpmn2:script> </bpmn2:scriptTask> <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="initialization" targetRef="callGetService" /> - <bpmn2:exclusiveGateway id="vnfExist" name="Vnf Already Exist?" default="vnfExistYes"> - <bpmn2:incoming>SequenceFlow_7</bpmn2:incoming> - <bpmn2:outgoing>vnfExistYes</bpmn2:outgoing> - <bpmn2:outgoing>vnfExistNo</bpmn2:outgoing> - </bpmn2:exclusiveGateway> - <bpmn2:sequenceFlow id="vnfExistYes" name="Yes" sourceRef="vnfExist" targetRef="vnfExistWorkflowException" /> - <bpmn2:sequenceFlow id="vnfExistNo" name="No" sourceRef="vnfExist" targetRef="prepareCreateGenericVnf"> - <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("GENGV_FoundIndicator" ) == false && execution.getVariable("GENGV_SuccessIndicator" ) == true}]]></bpmn2:conditionExpression> - </bpmn2:sequenceFlow> - <bpmn2:callActivity id="callGetVnf" name="Get Generic Vnf" calledElement="GenericGetVnf"> - <bpmn2:extensionElements> - <camunda:in source="DoCVNF_vnfName" target="GENGV_vnfName" /> - <camunda:in source="DoCVNF_type" target="GENGV_type" /> - <camunda:out source="GENGV_vnf" target="CRTVI_genericVnf" /> - <camunda:out source="GENGV_FoundIndicator" target="GENGV_FoundIndicator" /> - <camunda:out source="GENGV_SuccessIndicator" target="GENGV_SuccessIndicator" /> - <camunda:out source="WorkflowException" target="WorkflowException" /> - <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> - </bpmn2:extensionElements> - <bpmn2:incoming>VnfNameSpecified1</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing> - </bpmn2:callActivity> - <bpmn2:sequenceFlow id="SequenceFlow_7" name="" sourceRef="callGetVnf" targetRef="vnfExist" /> - <bpmn2:scriptTask id="vnfExistWorkflowException" name="Create Workflow Exception" scriptFormat="groovy"> - <bpmn2:incoming>vnfExistYes</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_10</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* -ExceptionUtil exceptionUtil = new ExceptionUtil() -exceptionUtil.buildWorkflowException(execution, 5000, "Generic Vnf Already Exist.")]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_10" name="" sourceRef="vnfExistWorkflowException" targetRef="EndEvent_2" /> - <bpmn2:endEvent id="EndEvent_2"> - <bpmn2:incoming>SequenceFlow_10</bpmn2:incoming> - <bpmn2:errorEventDefinition id="ErrorEventDefinition_2" errorRef="Error_2" /> - </bpmn2:endEvent> <bpmn2:scriptTask id="prepareCreateGenericVnf" name=" AAI Create (generic vnf) " scriptFormat="groovy"> - <bpmn2:incoming>vnfExistNo</bpmn2:incoming> - <bpmn2:incoming>VnfNameNotSpecified1</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_11b2sf3</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_11</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* DoCreateVnf createVnf = new DoCreateVnf() @@ -162,15 +126,6 @@ createVnfInfra.validateSDNCResponse(execution, response, "activate")]]></bpmn2:s DoCreateVnf createVnf = new DoCreateVnf() createVnf.postProcessCreateGenericVnf(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:exclusiveGateway id="ExclusiveGateway_0j73e7c" name="Vnf-name specified?" default="VnfNameSpecified1"> - <bpmn2:incoming>SequenceFlow_1mvplyi</bpmn2:incoming> - <bpmn2:outgoing>VnfNameNotSpecified1</bpmn2:outgoing> - <bpmn2:outgoing>VnfNameSpecified1</bpmn2:outgoing> - </bpmn2:exclusiveGateway> - <bpmn2:sequenceFlow id="VnfNameNotSpecified1" name="No" sourceRef="ExclusiveGateway_0j73e7c" targetRef="prepareCreateGenericVnf"> - <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("DoCVNF_vnfName" ) == null}]]></bpmn2:conditionExpression> - </bpmn2:sequenceFlow> - <bpmn2:sequenceFlow id="VnfNameSpecified1" name="Yes" sourceRef="ExclusiveGateway_0j73e7c" targetRef="callGetVnf" /> <bpmn2:sequenceFlow id="SequenceFlow_1h9jdgr" sourceRef="PreProcessSDNCGetRequest" targetRef="CallSDNCAdapterVNFTopologyGet" /> <bpmn2:sequenceFlow id="SequenceFlow_14xac2y" sourceRef="CallSDNCAdapterVNFTopologyGet" targetRef="PostProcessSDNCGetRequest" /> <bpmn2:sequenceFlow id="SequenceFlow_1q1poly" sourceRef="PostProcessSDNCGetRequest" targetRef="preProcessSDNCActivateRequest" /> @@ -236,12 +191,12 @@ doCreateVnf.prepUpdateAAIGenericVnf(execution)]]></bpmn2:script> </bpmn2:scriptTask> <bpmn2:scriptTask id="callGetService" name="AAI Query (svc instance)" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_1mvplyi</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_11b2sf3</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* DoCreateVnf createVnf = new DoCreateVnf() createVnf.getServiceInstance(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_1mvplyi" sourceRef="callGetService" targetRef="ExclusiveGateway_0j73e7c" /> + <bpmn2:sequenceFlow id="SequenceFlow_11b2sf3" sourceRef="callGetService" targetRef="prepareCreateGenericVnf" /> </bpmn2:process> <bpmn2:error id="Error_1" name="Java Lang Exception" errorCode="java.lang.Exception" /> <bpmn2:error id="Error_2" name="MSO Workflow Exception" errorCode="MSOWorkflowException" /> @@ -265,62 +220,14 @@ createVnf.getServiceInstance(execution)]]></bpmn2:script> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ScriptTask_285"> <di:waypoint xsi:type="dc:Point" x="338" y="240" /> - <di:waypoint xsi:type="dc:Point" x="425" y="240" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="336.5" y="225" width="90" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_CallActivity_60" bpmnElement="callGetVnf"> - <dc:Bounds x="720" y="288" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_232" bpmnElement="vnfExist" isMarkerVisible="true"> - <dc:Bounds x="854" y="302" width="50" height="50" /> + <di:waypoint xsi:type="dc:Point" x="493" y="240" /> <bpmndi:BPMNLabel> - <dc:Bounds x="890" y="332" width="114" height="22" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_9" bpmnElement="SequenceFlow_7" sourceElement="_BPMNShape_CallActivity_60" targetElement="_BPMNShape_ExclusiveGateway_232"> - <di:waypoint xsi:type="dc:Point" x="820" y="328" /> - <di:waypoint xsi:type="dc:Point" x="854" y="327" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="804" y="330" width="6" height="6" /> + <dc:Bounds x="370.5" y="225" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_299" bpmnElement="vnfExistWorkflowException"> - <dc:Bounds x="926" y="367" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_300" bpmnElement="prepareCreateGenericVnf"> - <dc:Bounds x="959" y="200" width="100" height="80" /> + <dc:Bounds x="781" y="200" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_10" bpmnElement="vnfExistYes" sourceElement="_BPMNShape_ExclusiveGateway_232" targetElement="_BPMNShape_ScriptTask_299"> - <di:waypoint xsi:type="dc:Point" x="879" y="352" /> - <di:waypoint xsi:type="dc:Point" x="879" y="407" /> - <di:waypoint xsi:type="dc:Point" x="926" y="407" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="880" y="367" width="29" height="22" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_11" bpmnElement="vnfExistNo" sourceElement="_BPMNShape_ExclusiveGateway_232" targetElement="_BPMNShape_ScriptTask_300"> - <di:waypoint xsi:type="dc:Point" x="879" y="302" /> - <di:waypoint xsi:type="dc:Point" x="879" y="240" /> - <di:waypoint xsi:type="dc:Point" x="959" y="240" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="884" y="254" width="14" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_EndEvent_227" bpmnElement="EndEvent_2"> - <dc:Bounds x="1092" y="389" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1110" y="430" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_12" bpmnElement="SequenceFlow_10" sourceElement="_BPMNShape_ScriptTask_299" targetElement="_BPMNShape_EndEvent_227"> - <di:waypoint xsi:type="dc:Point" x="1026" y="407" /> - <di:waypoint xsi:type="dc:Point" x="1092" y="407" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1034" y="407" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_EndEvent_228" bpmnElement="EndEvent_3"> <dc:Bounds x="1765" y="537" width="36" height="36" /> <bpmndi:BPMNLabel> @@ -328,10 +235,10 @@ createVnf.getServiceInstance(execution)]]></bpmn2:script> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_13" bpmnElement="SequenceFlow_11" sourceElement="_BPMNShape_ScriptTask_300" targetElement="ScriptTask_0y55cyz_di"> - <di:waypoint xsi:type="dc:Point" x="1059" y="240" /> + <di:waypoint xsi:type="dc:Point" x="881" y="240" /> <di:waypoint xsi:type="dc:Point" x="1146" y="240" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1057.5" y="225" width="90" height="0" /> + <dc:Bounds x="968.5" y="225" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_SubProcess_32" bpmnElement="javaErrorHandlingSubProcess" isExpanded="true"> @@ -454,27 +361,6 @@ createVnf.getServiceInstance(execution)]]></bpmn2:script> <bpmndi:BPMNShape id="ScriptTask_0y55cyz_di" bpmnElement="postProcessCreateGenericVnf"> <dc:Bounds x="1146" y="200" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ExclusiveGateway_0j73e7c_di" bpmnElement="ExclusiveGateway_0j73e7c" isMarkerVisible="true"> - <dc:Bounds x="646" y="215" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="653" y="184" width="51" height="24" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0k2oavy_di" bpmnElement="VnfNameNotSpecified1"> - <di:waypoint xsi:type="dc:Point" x="696" y="240" /> - <di:waypoint xsi:type="dc:Point" x="959" y="240" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="821.0502092050209" y="215" width="14" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1pwgmrg_di" bpmnElement="VnfNameSpecified1"> - <di:waypoint xsi:type="dc:Point" x="671" y="265" /> - <di:waypoint xsi:type="dc:Point" x="671" y="328" /> - <di:waypoint xsi:type="dc:Point" x="720" y="328" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="677" y="286.5" width="18" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1h9jdgr_di" bpmnElement="SequenceFlow_1h9jdgr"> <di:waypoint xsi:type="dc:Point" x="777" y="693" /> <di:waypoint xsi:type="dc:Point" x="799" y="693" /> @@ -555,13 +441,13 @@ createVnf.getServiceInstance(execution)]]></bpmn2:script> <dc:Bounds x="1445" y="515" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_019g8vu_di" bpmnElement="callGetService"> - <dc:Bounds x="425" y="200" width="100" height="80" /> + <dc:Bounds x="493" y="200" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1mvplyi_di" bpmnElement="SequenceFlow_1mvplyi"> - <di:waypoint xsi:type="dc:Point" x="525" y="240" /> - <di:waypoint xsi:type="dc:Point" x="646" y="240" /> + <bpmndi:BPMNEdge id="SequenceFlow_11b2sf3_di" bpmnElement="SequenceFlow_11b2sf3"> + <di:waypoint xsi:type="dc:Point" x="593" y="240" /> + <di:waypoint xsi:type="dc:Point" x="781" y="240" /> <bpmndi:BPMNLabel> - <dc:Bounds x="585.5" y="219" width="0" height="12" /> + <dc:Bounds x="687" y="219" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn index 0d48719c6b..b5988538e3 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn @@ -36,6 +36,7 @@ doCreateVnfAndModules.preProcessRequest(execution)]]></bpmn:script> <camunda:in source="vnfModelInfo" target="vnfModelInfo" /> <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> <camunda:in source="sdncVersion" target="sdncVersion" /> + <camunda:in source="cloudOwner" target="cloudOwner" /> <camunda:in source="lcpCloudRegionId" target="lcpCloudRegionId" /> <camunda:in source="tenantId" target="tenantId" /> <camunda:in source="false" target="usePreload" /> @@ -71,6 +72,7 @@ doCreateVnfAndModules.preProcessRequest(execution)]]></bpmn:script> <camunda:in source="vnfModelInfo" target="vnfModelInfo" /> <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> <camunda:in source="sdncVersion" target="sdncVersion" /> + <camunda:in source="cloudOwner" target="cloudOwner" /> <camunda:in source="lcpCloudRegionId" target="lcpCloudRegionId" /> <camunda:in source="tenantId" target="tenantId" /> <camunda:in source="false" target="usePreload" /> @@ -123,6 +125,7 @@ doCreateVnfAndModules.validateAddOnModule(execution)]]></bpmn:script> <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> <camunda:in source="sdncVersion" target="sdncVersion" /> <camunda:out source="vnfName" target="vnfName" /> + <camunda:in source="cloudOwner" target="cloudOwner" /> <camunda:in source="lcpCloudRegionId" target="lcpCloudRegionId" /> <camunda:in source="tenantId" target="tenantId" /> <camunda:in source="rollbackData" target="rollbackData" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnf.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnf.bpmn index d9596f0d14..da7fc652ed 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnf.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnf.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_9MhrcHqVEea26OhQB97uCQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_9MhrcHqVEea26OhQB97uCQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="DoDeleteVnf" name="DoDeleteVnf" isExecutable="true"> <bpmn2:startEvent id="StartEvent_1"> <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> @@ -12,44 +12,29 @@ DoDeleteVnf deleteVnf = new DoDeleteVnf() deleteVnf.preProcessRequest(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="intialization" targetRef="callGetVnf" /> - <bpmn2:callActivity id="callGetVnf" name="Get Generic Vnf" calledElement="GenericGetVnf"> - <bpmn2:extensionElements> - <camunda:out source="GENGV_vnf" target="DoDVNF_genericVnf" /> - <camunda:out source="WorkflowException" target="WorkflowException" /> - <camunda:out source="GENGV_SuccessIndicator" target="GENGV_SuccessIndicator" /> - <camunda:out source="GENGV_FoundIndicator" target="GENGV_FoundIndicator" /> - <camunda:in source="DoDVNF_type" target="GENGV_type" /> - <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> - <camunda:in source="DoDVNF_vnfId" target="GENGV_vnfId" /> - </bpmn2:extensionElements> - <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing> - </bpmn2:callActivity> - <bpmn2:sequenceFlow id="SequenceFlow_5" name="" sourceRef="callGetVnf" targetRef="vnfFoundCheck" /> + <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="intialization" targetRef="processResponse" /> <bpmn2:exclusiveGateway id="vnfFoundCheck" name="Vnf Found?" default="notFound"> - <bpmn2:incoming>SequenceFlow_5</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_0hbmag5</bpmn2:incoming> <bpmn2:outgoing>vnfFound</bpmn2:outgoing> <bpmn2:outgoing>notFound</bpmn2:outgoing> </bpmn2:exclusiveGateway> - <bpmn2:sequenceFlow id="vnfFound" name="Yes" sourceRef="vnfFoundCheck" targetRef="processResponse"> - <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("GENGV_FoundIndicator") == true && execution.getVariable("GENGV_SuccessIndicator") == true}]]></bpmn2:conditionExpression> + <bpmn2:sequenceFlow id="vnfFound" name="Yes" sourceRef="vnfFoundCheck" targetRef="vnfInUseCheck"> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("GENGV_FoundIndicator") == true}]]></bpmn2:conditionExpression> </bpmn2:sequenceFlow> <bpmn2:sequenceFlow id="notFound" name="No" sourceRef="vnfFoundCheck" targetRef="IntermediateThrowEvent_1" /> - <bpmn2:scriptTask id="processResponse" name="Process Response" scriptFormat="groovy"> - <bpmn2:incoming>vnfFound</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> + <bpmn2:scriptTask id="processResponse" name=" AAI Query (generic vnf) " scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0hbmag5</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* DoDeleteVnf deleteVnf = new DoDeleteVnf() -deleteVnf.processGetVnfResponse(execution)]]></bpmn2:script> +deleteVnf.getVnf(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_4" name="" sourceRef="processResponse" targetRef="vnfInUseCheck" /> <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_1" name="Skip Delete"> <bpmn2:incoming>notFound</bpmn2:incoming> <bpmn2:linkEventDefinition id="LinkEventDefinition_1" name="Skip Delete" /> </bpmn2:intermediateThrowEvent> <bpmn2:exclusiveGateway id="vnfInUseCheck" name="Vnf In Use?" default="notInUse"> - <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming> + <bpmn2:incoming>vnfFound</bpmn2:incoming> <bpmn2:outgoing>inUse</bpmn2:outgoing> <bpmn2:outgoing>notInUse</bpmn2:outgoing> </bpmn2:exclusiveGateway> @@ -110,6 +95,7 @@ exceptionUtil.processJavaException(execution)]]></bpmn2:script> DoDeleteVnf delete = new DoDeleteVnf() delete.deleteVnf(execution)]]></bpmn2:script> </bpmn2:scriptTask> + <bpmn2:sequenceFlow id="SequenceFlow_0hbmag5" sourceRef="processResponse" targetRef="vnfFoundCheck" /> </bpmn2:process> <bpmn2:error id="Error_1" name="MSO Workflow Exception" errorCode="MSOWorkflowException" /> <bpmn2:error id="Error_2" name="Java Lang Exception" errorCode="java.lang.Exception" /> @@ -133,67 +119,50 @@ delete.deleteVnf(execution)]]></bpmn2:script> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ScriptTask_311"> <di:waypoint xsi:type="dc:Point" x="422" y="228" /> - <di:waypoint xsi:type="dc:Point" x="504" y="228" /> + <di:waypoint xsi:type="dc:Point" x="485" y="227" /> <bpmndi:BPMNLabel> - <dc:Bounds x="463" y="213" width="0" height="0" /> + <dc:Bounds x="408.5" y="212.5" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_314" bpmnElement="processResponse"> - <dc:Bounds x="704" y="291" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_CallActivity_63" bpmnElement="callGetVnf"> - <dc:Bounds x="504" y="188" width="100" height="80" /> + <dc:Bounds x="485" y="187" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_236" bpmnElement="vnfInUseCheck" isMarkerVisible="true"> - <dc:Bounds x="840" y="305" width="50" height="50" /> + <dc:Bounds x="789" y="306" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="890" y="335" width="73" height="22" /> + <dc:Bounds x="847" y="336" width="58" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_ScriptTask_314" targetElement="_BPMNShape_ExclusiveGateway_236"> - <di:waypoint xsi:type="dc:Point" x="804" y="331" /> - <di:waypoint xsi:type="dc:Point" x="840" y="330" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="799" y="325" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="SequenceFlow_5" sourceElement="_BPMNShape_CallActivity_63" targetElement="_BPMNShape_ExclusiveGateway_237"> - <di:waypoint xsi:type="dc:Point" x="604" y="228" /> - <di:waypoint xsi:type="dc:Point" x="634" y="227" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="630" y="227" width="6" height="6" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_315" bpmnElement="createWorkflowExceptionInUse"> - <dc:Bounds x="912" y="196" width="100" height="80" /> + <dc:Bounds x="861" y="196" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="inUse" sourceElement="_BPMNShape_ExclusiveGateway_236" targetElement="_BPMNShape_ScriptTask_315"> - <di:waypoint xsi:type="dc:Point" x="865" y="305" /> - <di:waypoint xsi:type="dc:Point" x="865" y="236" /> - <di:waypoint xsi:type="dc:Point" x="912" y="236" /> + <di:waypoint xsi:type="dc:Point" x="814" y="306" /> + <di:waypoint xsi:type="dc:Point" x="814" y="236" /> + <di:waypoint xsi:type="dc:Point" x="861" y="236" /> <bpmndi:BPMNLabel> - <dc:Bounds x="867" y="258" width="29" height="22" /> + <dc:Bounds x="821" y="258.40579710144925" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_7" bpmnElement="notInUse" sourceElement="_BPMNShape_ExclusiveGateway_236" targetElement="ScriptTask_1ps8v06_di"> - <di:waypoint xsi:type="dc:Point" x="865" y="355" /> - <di:waypoint xsi:type="dc:Point" x="865" y="424" /> - <di:waypoint xsi:type="dc:Point" x="912" y="424" /> + <di:waypoint xsi:type="dc:Point" x="814" y="356" /> + <di:waypoint xsi:type="dc:Point" x="814" y="424" /> + <di:waypoint xsi:type="dc:Point" x="861" y="424" /> <bpmndi:BPMNLabel> - <dc:Bounds x="874" y="384" width="14" height="12" /> + <dc:Bounds x="823" y="384.4927536231884" width="14" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_EndEvent_236" bpmnElement="EndEvent_1"> - <dc:Bounds x="1100" y="218" width="36" height="36" /> + <dc:Bounds x="1049" y="218" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1118" y="259" width="0" height="0" /> + <dc:Bounds x="1022" y="259" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_8" bpmnElement="SequenceFlow_8" sourceElement="_BPMNShape_ScriptTask_315" targetElement="_BPMNShape_EndEvent_236"> - <di:waypoint xsi:type="dc:Point" x="1012" y="236" /> - <di:waypoint xsi:type="dc:Point" x="1100" y="236" /> + <di:waypoint xsi:type="dc:Point" x="961" y="236" /> + <di:waypoint xsi:type="dc:Point" x="1049" y="236" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1062" y="236" width="6" height="6" /> + <dc:Bounds x="969" y="236" width="90" height="6" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_237" bpmnElement="vnfFoundCheck" isMarkerVisible="true"> @@ -202,12 +171,12 @@ delete.deleteVnf(execution)]]></bpmn2:script> <dc:Bounds x="672" y="240" width="72" height="22" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_9" bpmnElement="vnfFound" sourceElement="_BPMNShape_ExclusiveGateway_237" targetElement="_BPMNShape_ScriptTask_314"> + <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_9" bpmnElement="vnfFound" sourceElement="_BPMNShape_ExclusiveGateway_237" targetElement="_BPMNShape_ExclusiveGateway_236"> <di:waypoint xsi:type="dc:Point" x="659" y="252" /> <di:waypoint xsi:type="dc:Point" x="659" y="331" /> - <di:waypoint xsi:type="dc:Point" x="704" y="331" /> + <di:waypoint xsi:type="dc:Point" x="789" y="331" /> <bpmndi:BPMNLabel> - <dc:Bounds x="659" y="288" width="29" height="22" /> + <dc:Bounds x="664" y="288" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_IntermediateThrowEvent_2" bpmnElement="IntermediateThrowEvent_1"> @@ -225,42 +194,42 @@ delete.deleteVnf(execution)]]></bpmn2:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_EndEvent_237" bpmnElement="EndEvent_2"> - <dc:Bounds x="1174" y="405" width="36" height="36" /> + <dc:Bounds x="1151" y="405" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1192" y="446" width="0" height="0" /> + <dc:Bounds x="1124" y="446" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_238" bpmnElement="ExclusiveGateway_2" isMarkerVisible="true"> - <dc:Bounds x="1062" y="398" width="50" height="50" /> + <dc:Bounds x="1011" y="399" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1087" y="453" width="0" height="0" /> + <dc:Bounds x="991" y="454" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_11" bpmnElement="SequenceFlow_9" sourceElement="ScriptTask_1ps8v06_di" targetElement="_BPMNShape_ExclusiveGateway_238"> - <di:waypoint xsi:type="dc:Point" x="1012" y="424" /> - <di:waypoint xsi:type="dc:Point" x="1062" y="423" /> + <di:waypoint xsi:type="dc:Point" x="961" y="425" /> + <di:waypoint xsi:type="dc:Point" x="1011" y="424" /> <bpmndi:BPMNLabel> - <dc:Bounds x="992" y="405.5" width="90" height="6" /> + <dc:Bounds x="941" y="406.5" width="90" height="6" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_12" bpmnElement="SequenceFlow_10" sourceElement="_BPMNShape_ExclusiveGateway_238"> - <di:waypoint xsi:type="dc:Point" x="1111" y="422" /> - <di:waypoint xsi:type="dc:Point" x="1174" y="423" /> + <di:waypoint xsi:type="dc:Point" x="1060" y="423" /> + <di:waypoint xsi:type="dc:Point" x="1151" y="423" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1143" y="407.5" width="0" height="0" /> + <dc:Bounds x="1060.5" y="408" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_IntermediateCatchEvent_2" bpmnElement="IntermediateCatchEvent_1"> - <dc:Bounds x="1069" y="492" width="36" height="36" /> + <dc:Bounds x="1018" y="492" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1051" y="533" width="73" height="22" /> + <dc:Bounds x="1009" y="533" width="55" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_14" bpmnElement="SequenceFlow_12" sourceElement="_BPMNShape_IntermediateCatchEvent_2" targetElement="_BPMNShape_ExclusiveGateway_238"> - <di:waypoint xsi:type="dc:Point" x="1087" y="492" /> - <di:waypoint xsi:type="dc:Point" x="1087" y="448" /> + <di:waypoint xsi:type="dc:Point" x="1036" y="492" /> + <di:waypoint xsi:type="dc:Point" x="1036" y="449" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1084" y="462" width="6" height="6" /> + <dc:Bounds x="1006" y="467.5" width="90" height="6" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="_BPMNShape_SubProcess_35" bpmnElement="javaErrorHandlingSubProcess" isExpanded="true"> @@ -296,8 +265,16 @@ delete.deleteVnf(execution)]]></bpmn2:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_1ps8v06_di" bpmnElement="deleteVnf"> - <dc:Bounds x="912" y="384" width="100" height="80" /> + <dc:Bounds x="861" y="384" width="100" height="80" /> </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0hbmag5_di" bpmnElement="SequenceFlow_0hbmag5"> + <di:waypoint xsi:type="dc:Point" x="585" y="227" /> + <di:waypoint xsi:type="dc:Point" x="607" y="227" /> + <di:waypoint xsi:type="dc:Point" x="634" y="227" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="596" y="206" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn2:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnfAndModules.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnfAndModules.bpmn index 4d6d0006e3..7563c05e1f 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnfAndModules.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteVnfAndModules.bpmn @@ -193,6 +193,7 @@ ddvam.validateSDNCResponse(execution, response, "unassign")]]></bpmn2:script> <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> <camunda:in source="vnfId" target="vnfId" /> + <camunda:in source="cloudOwner" target="cloudOwner" /> <camunda:in source="lcpCloudRegionId" target="lcpCloudRegionId" /> <camunda:in source="tenantId" target="tenantId" /> <camunda:in source="DDVAM_sdncVersion" target="sdncVersion" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn index ef3340e887..8383ccbd1f 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn @@ -87,59 +87,33 @@ ddsi.preInitResourcesOperStatus(execution)]]></bpmn2:script> <bpmn2:incoming>SequenceFlow_177wo8z</bpmn2:incoming> <bpmn2:linkEventDefinition name="StartDeleteResources" /> </bpmn2:intermediateThrowEvent> - <bpmn2:callActivity id="CallActivity_1nm9zq7" name="Call Custom E2E Put Service" calledElement="CustomE2EPutService"> - <bpmn2:extensionElements> - <camunda:in source="globalSubscriberId" target="GENPS_globalSubscriberId" /> - <camunda:in source="serviceInstanceId" target="GENPS_serviceInstanceId" /> - <camunda:in source="serviceType" target="GENPS_serviceType" /> - <camunda:in sourceExpression="service-instance" target="GENPS_type" /> - <camunda:in source="serviceInstanceData" target="GENPS_payload" /> - <camunda:out source="GENPS_SuccessIndicator" target="GENPS_SuccessIndicator" /> - <camunda:in source="msoRequestId" target="GENPS_requesId" /> - <camunda:out source="WorkflowException" target="WorkflowException" /> - <camunda:in source="GENPS_serviceResourceVersion" target="GENPS_serviceResourceVersion" /> - </bpmn2:extensionElements> + <bpmn2:scriptTask id="ScriptTask_0xtabf8" name=" AAI Create (svc instance) " scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_1kx5ke9</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_0f76thv</bpmn2:outgoing> - </bpmn2:callActivity> - <bpmn2:scriptTask id="ScriptTask_0xtabf8" name="Post Process AAI PUT" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_0f76thv</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_0x0mhlj</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_1cur6kz</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* def ddsi = new DoUpdateE2EServiceInstance() -ddsi.postProcessAAIPUT(execution)]]></bpmn2:script> +ddsi.updateServiceInstance(execution)]]></bpmn2:script> </bpmn2:scriptTask> <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_0a9bdjw" name="UpdateAAI"> <bpmn2:outgoing>SequenceFlow_1demy08</bpmn2:outgoing> <bpmn2:linkEventDefinition name="UpdateAAI" /> </bpmn2:intermediateCatchEvent> <bpmn2:sequenceFlow id="SequenceFlow_1demy08" sourceRef="IntermediateCatchEvent_0a9bdjw" targetRef="ScriptTask_0sis7k0" /> - <bpmn2:sequenceFlow id="SequenceFlow_0f76thv" sourceRef="CallActivity_1nm9zq7" targetRef="ScriptTask_0xtabf8" /> <bpmn2:scriptTask id="ScriptTask_19v8l1w" name="Post Config Service Instance Update" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_0ku36oy</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_1cur6kz</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_07aa121</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* def csi = new DoUpdateE2EServiceInstance() csi.postConfigRequest(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_0z04o3s" name="FinishProcess"> - <bpmn2:outgoing>SequenceFlow_0ku36oy</bpmn2:outgoing> - <bpmn2:linkEventDefinition name="FinishProcess" /> - </bpmn2:intermediateCatchEvent> <bpmn2:endEvent id="EndEvent_0exzmfn"> <bpmn2:incoming>SequenceFlow_07aa121</bpmn2:incoming> </bpmn2:endEvent> <bpmn2:sequenceFlow id="SequenceFlow_07aa121" sourceRef="ScriptTask_19v8l1w" targetRef="EndEvent_0exzmfn" /> - <bpmn2:sequenceFlow id="SequenceFlow_0ku36oy" sourceRef="IntermediateCatchEvent_0z04o3s" targetRef="ScriptTask_19v8l1w" /> <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_06lo96a" name="GoTo UpdateAAI"> <bpmn2:incoming>SequenceFlow_1uu6uiu</bpmn2:incoming> <bpmn2:linkEventDefinition name="UpdateAAI" /> </bpmn2:intermediateThrowEvent> - <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_0hucdtk" name="GoTo FinishProcess"> - <bpmn2:incoming>SequenceFlow_0x0mhlj</bpmn2:incoming> - <bpmn2:linkEventDefinition name="FinishProcess" /> - </bpmn2:intermediateThrowEvent> - <bpmn2:sequenceFlow id="SequenceFlow_0x0mhlj" sourceRef="ScriptTask_0xtabf8" targetRef="IntermediateThrowEvent_0hucdtk" /> <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_09ur9ds" name="GoTo StartAddResources"> <bpmn2:incoming>SequenceFlow_1muxopq</bpmn2:incoming> <bpmn2:linkEventDefinition name="StartAddResources" /> @@ -180,7 +154,7 @@ dcsi.postProcessRollback(execution) def dcsi = new DoUpdateE2EServiceInstance() dcsi.preProcessAAIPUT(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_1kx5ke9" sourceRef="ScriptTask_0sis7k0" targetRef="CallActivity_1nm9zq7" /> + <bpmn2:sequenceFlow id="SequenceFlow_1kx5ke9" sourceRef="ScriptTask_0sis7k0" targetRef="ScriptTask_0xtabf8" /> <bpmn2:sequenceFlow id="SequenceFlow_04xlw7s" sourceRef="preProcessRequest_ScriptTask" targetRef="ScriptTask_0acnvkp" /> <bpmn2:exclusiveGateway id="ExclusiveGateway_06gj84t" name="HasResourcetoAdd?" default="SequenceFlow_01po987"> <bpmn2:incoming>SequenceFlow_0yztz2p</bpmn2:incoming> @@ -245,6 +219,7 @@ dcsi.preProcessAAIPUT(execution)]]></bpmn2:script> <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("hasResourcetoDelete") == true}]]></bpmn2:conditionExpression> </bpmn2:sequenceFlow> <bpmn2:sequenceFlow id="SequenceFlow_070o30v" sourceRef="ExclusiveGateway_1fcnq0g" targetRef="IntermediateThrowEvent_0y1ii4i" /> + <bpmn2:sequenceFlow id="SequenceFlow_1cur6kz" sourceRef="ScriptTask_0xtabf8" targetRef="ScriptTask_19v8l1w" /> </bpmn2:process> <bpmn2:error id="Error_2" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmn2:error id="Error_1" name="java.lang.Exception" errorCode="java.lang.Exception" /> @@ -341,11 +316,8 @@ dcsi.preProcessAAIPUT(execution)]]></bpmn2:script> <dc:Bounds x="1738" y="890" width="86" height="36" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="CallActivity_1nm9zq7_di" bpmnElement="CallActivity_1nm9zq7"> - <dc:Bounds x="1229" y="1333" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0xtabf8_di" bpmnElement="ScriptTask_0xtabf8"> - <dc:Bounds x="1473" y="1333" width="100" height="80" /> + <dc:Bounds x="844" y="1333" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="IntermediateCatchEvent_0a9bdjw_di" bpmnElement="IntermediateCatchEvent_0a9bdjw"> <dc:Bounds x="74" y="1355" width="36" height="36" /> @@ -355,45 +327,27 @@ dcsi.preProcessAAIPUT(execution)]]></bpmn2:script> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1demy08_di" bpmnElement="SequenceFlow_1demy08"> <di:waypoint xsi:type="dc:Point" x="110" y="1373" /> - <di:waypoint xsi:type="dc:Point" x="978" y="1373" /> + <di:waypoint xsi:type="dc:Point" x="293" y="1373" /> <bpmndi:BPMNLabel> - <dc:Bounds x="499" y="1352" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0f76thv_di" bpmnElement="SequenceFlow_0f76thv"> - <di:waypoint xsi:type="dc:Point" x="1329" y="1373" /> - <di:waypoint xsi:type="dc:Point" x="1473" y="1373" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1356" y="1352" width="90" height="12" /> + <dc:Bounds x="156.5" y="1352" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_19v8l1w_di" bpmnElement="ScriptTask_19v8l1w"> - <dc:Bounds x="858" y="1579" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="IntermediateCatchEvent_0z04o3s_di" bpmnElement="IntermediateCatchEvent_0z04o3s"> - <dc:Bounds x="74" y="1601" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="57" y="1641" width="70" height="12" /> - </bpmndi:BPMNLabel> + <dc:Bounds x="1229" y="1333" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_0exzmfn_di" bpmnElement="EndEvent_0exzmfn"> - <dc:Bounds x="1772" y="1601" width="36" height="36" /> + <dc:Bounds x="1750" y="1355" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1700" y="1641" width="90" height="12" /> + <dc:Bounds x="1678" y="1395" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_07aa121_di" bpmnElement="SequenceFlow_07aa121"> - <di:waypoint xsi:type="dc:Point" x="958" y="1619" /> - <di:waypoint xsi:type="dc:Point" x="1772" y="1619" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1320" y="1598" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0ku36oy_di" bpmnElement="SequenceFlow_0ku36oy"> - <di:waypoint xsi:type="dc:Point" x="110" y="1619" /> - <di:waypoint xsi:type="dc:Point" x="858" y="1619" /> + <di:waypoint xsi:type="dc:Point" x="1329" y="1373" /> + <di:waypoint xsi:type="dc:Point" x="1551" y="1373" /> + <di:waypoint xsi:type="dc:Point" x="1551" y="1373" /> + <di:waypoint xsi:type="dc:Point" x="1750" y="1373" /> <bpmndi:BPMNLabel> - <dc:Bounds x="439" y="1598" width="90" height="12" /> + <dc:Bounds x="1521" y="1367" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateThrowEvent_06lo96a_di" bpmnElement="IntermediateThrowEvent_06lo96a"> @@ -402,19 +356,6 @@ dcsi.preProcessAAIPUT(execution)]]></bpmn2:script> <dc:Bounds x="1750" y="1143" width="82" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="IntermediateThrowEvent_0hucdtk_di" bpmnElement="IntermediateThrowEvent_0hucdtk"> - <dc:Bounds x="1762" y="1355" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1756" y="1395" width="70" height="24" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0x0mhlj_di" bpmnElement="SequenceFlow_0x0mhlj"> - <di:waypoint xsi:type="dc:Point" x="1573" y="1373" /> - <di:waypoint xsi:type="dc:Point" x="1762" y="1373" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="1622.5" y="1352" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateThrowEvent_09ur9ds_di" bpmnElement="IntermediateThrowEvent_09ur9ds"> <dc:Bounds x="1762" y="622" width="36" height="36" /> <bpmndi:BPMNLabel> @@ -429,55 +370,55 @@ dcsi.preProcessAAIPUT(execution)]]></bpmn2:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="SubProcess_0jo0nms_di" bpmnElement="SubProcess_0jo0nms" isExpanded="true"> - <dc:Bounds x="236" y="1818" width="1428" height="210" /> + <dc:Bounds x="244" y="1688" width="1428" height="210" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="StartEvent_06768u3_di" bpmnElement="StartEvent_06768u3"> - <dc:Bounds x="266" y="1895" width="36" height="36" /> + <dc:Bounds x="274" y="1765" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="194" y="1936" width="90" height="12" /> + <dc:Bounds x="202" y="1806" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_014jyvb_di" bpmnElement="EndEvent_014jyvb"> - <dc:Bounds x="1581" y="1895" width="36" height="36" /> + <dc:Bounds x="1589" y="1765" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1509" y="1936" width="90" height="12" /> + <dc:Bounds x="1517" y="1806" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1awrp72_di" bpmnElement="ScriptTask_1awrp72"> - <dc:Bounds x="557" y="1873" width="100" height="80" /> + <dc:Bounds x="565" y="1743" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_0vc9jgo_di" bpmnElement="ScriptTask_0vc9jgo"> - <dc:Bounds x="1248" y="1873" width="100" height="80" /> + <dc:Bounds x="1256" y="1743" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_05j3sat_di" bpmnElement="SequenceFlow_05j3sat"> - <di:waypoint xsi:type="dc:Point" x="302" y="1913" /> - <di:waypoint xsi:type="dc:Point" x="557" y="1913" /> + <di:waypoint xsi:type="dc:Point" x="310" y="1783" /> + <di:waypoint xsi:type="dc:Point" x="565" y="1783" /> <bpmndi:BPMNLabel> - <dc:Bounds x="385" y="1892" width="90" height="12" /> + <dc:Bounds x="393" y="1762" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_02znk15_di" bpmnElement="SequenceFlow_02znk15"> - <di:waypoint xsi:type="dc:Point" x="1348" y="1913" /> - <di:waypoint xsi:type="dc:Point" x="1581" y="1913" /> + <di:waypoint xsi:type="dc:Point" x="1356" y="1783" /> + <di:waypoint xsi:type="dc:Point" x="1589" y="1783" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1376" y="1898" width="90" height="12" /> + <dc:Bounds x="1384" y="1768" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_19ly8h7_di" bpmnElement="SequenceFlow_19ly8h7"> - <di:waypoint xsi:type="dc:Point" x="657" y="1913" /> - <di:waypoint xsi:type="dc:Point" x="1248" y="1913" /> + <di:waypoint xsi:type="dc:Point" x="665" y="1783" /> + <di:waypoint xsi:type="dc:Point" x="1256" y="1783" /> <bpmndi:BPMNLabel> - <dc:Bounds x="907.5" y="1892" width="90" height="12" /> + <dc:Bounds x="916" y="1762" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_0sis7k0_di" bpmnElement="ScriptTask_0sis7k0"> - <dc:Bounds x="978" y="1333" width="100" height="80" /> + <dc:Bounds x="293" y="1333" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1kx5ke9_di" bpmnElement="SequenceFlow_1kx5ke9"> - <di:waypoint xsi:type="dc:Point" x="1078" y="1373" /> - <di:waypoint xsi:type="dc:Point" x="1229" y="1373" /> + <di:waypoint xsi:type="dc:Point" x="393" y="1373" /> + <di:waypoint xsi:type="dc:Point" x="844" y="1373" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1108.5" y="1352" width="90" height="12" /> + <dc:Bounds x="573.5" y="1352" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_04xlw7s_di" bpmnElement="SequenceFlow_04xlw7s"> @@ -579,6 +520,13 @@ dcsi.preProcessAAIPUT(execution)]]></bpmn2:script> <dc:Bounds x="630" y="1176" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1cur6kz_di" bpmnElement="SequenceFlow_1cur6kz"> + <di:waypoint xsi:type="dc:Point" x="944" y="1373" /> + <di:waypoint xsi:type="dc:Point" x="1229" y="1373" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1086.5" y="1352" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn2:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstanceRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstanceRollback.bpmn index b53e87d34a..23233abc03 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstanceRollback.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstanceRollback.bpmn @@ -190,31 +190,15 @@ csi.postProcessForAddResource(execution)]]></bpmn2:script> def dcsi = new DoUpdateE2EServiceInstanceRollback() dcsi.preProcessAAIPUT(execution)]]></bpmn2:script> </bpmn2:scriptTask> - <bpmn2:callActivity id="CallActivity_0zs5y0x" name="Call Custom E2E Put Service" calledElement="CustomE2EPutService"> - <bpmn2:extensionElements> - <camunda:in source="serviceInstanceId" target="GENGS_serviceInstanceId" /> - <camunda:in sourceExpression="service-instance" target="GENGS_type" /> - <camunda:out source="GENGS_FoundIndicator" target="GENGS_FoundIndicator" /> - <camunda:out source="GENGS_SuccessIndicator" target="GENGS_SuccessIndicator" /> - <camunda:out source="WorkflowException" target="WorkflowException" /> - <camunda:out source="GENGS_siResourceLink" target="GENGS_siResourceLink" /> - <camunda:out source="GENGS_service" target="GENGS_service" /> - <camunda:in source="globalSubscriberId" target="GENGS_globalCustomerId" /> - <camunda:in source="serviceType" target="GENGS_serviceType" /> - </bpmn2:extensionElements> + <bpmn2:scriptTask id="ScriptTask_1p96syr" name=" AAI Create (svc instance) " scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_1lppnhy</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_0kbisn8</bpmn2:outgoing> - </bpmn2:callActivity> - <bpmn2:scriptTask id="ScriptTask_1p96syr" name="Post Process AAI PUT" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_0kbisn8</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_1azhgda</bpmn2:outgoing> <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* def dcsi = new DoUpdateE2EServiceInstanceRollback() -dcsi.postProcessAAIPUT(execution)]]></bpmn2:script> +dcsi.updateServiceInstance(execution)]]></bpmn2:script> </bpmn2:scriptTask> <bpmn2:sequenceFlow id="SequenceFlow_1a65s3k" sourceRef="IntermediateCatchEvent_0546q5i" targetRef="ScriptTask_0gj4dj5" /> - <bpmn2:sequenceFlow id="SequenceFlow_1lppnhy" sourceRef="ScriptTask_0gj4dj5" targetRef="CallActivity_0zs5y0x" /> - <bpmn2:sequenceFlow id="SequenceFlow_0kbisn8" sourceRef="CallActivity_0zs5y0x" targetRef="ScriptTask_1p96syr" /> + <bpmn2:sequenceFlow id="SequenceFlow_1lppnhy" sourceRef="ScriptTask_0gj4dj5" targetRef="ScriptTask_1p96syr" /> <bpmn2:exclusiveGateway id="ExclusiveGateway_1k16vgh" name="RollBackAAI?" default="SequenceFlow_161uzhj"> <bpmn2:documentation>rollback AAI</bpmn2:documentation> <bpmn2:incoming>SequenceFlow_08p4pkv</bpmn2:incoming> @@ -562,11 +546,8 @@ rbk.postProcessRequest(execution)]]></bpmn2:script> <bpmndi:BPMNShape id="ScriptTask_0gj4dj5_di" bpmnElement="ScriptTask_0gj4dj5"> <dc:Bounds x="687" y="743" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="CallActivity_0zs5y0x_di" bpmnElement="CallActivity_0zs5y0x"> - <dc:Bounds x="841" y="743" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1p96syr_di" bpmnElement="ScriptTask_1p96syr"> - <dc:Bounds x="1014" y="743" width="100" height="80" /> + <dc:Bounds x="929" y="743" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1a65s3k_di" bpmnElement="SequenceFlow_1a65s3k"> <di:waypoint xsi:type="dc:Point" x="192" y="783" /> @@ -577,18 +558,9 @@ rbk.postProcessRequest(execution)]]></bpmn2:script> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1lppnhy_di" bpmnElement="SequenceFlow_1lppnhy"> <di:waypoint xsi:type="dc:Point" x="787" y="783" /> - <di:waypoint xsi:type="dc:Point" x="841" y="783" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="769" y="762" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0kbisn8_di" bpmnElement="SequenceFlow_0kbisn8"> - <di:waypoint xsi:type="dc:Point" x="941" y="783" /> - <di:waypoint xsi:type="dc:Point" x="978" y="783" /> - <di:waypoint xsi:type="dc:Point" x="978" y="783" /> - <di:waypoint xsi:type="dc:Point" x="1014" y="783" /> + <di:waypoint xsi:type="dc:Point" x="929" y="783" /> <bpmndi:BPMNLabel> - <dc:Bounds x="948" y="777" width="90" height="12" /> + <dc:Bounds x="813" y="762" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_1k16vgh_di" bpmnElement="ExclusiveGateway_1k16vgh" isMarkerVisible="true"> @@ -719,10 +691,10 @@ rbk.postProcessRequest(execution)]]></bpmn2:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1azhgda_di" bpmnElement="SequenceFlow_1azhgda"> - <di:waypoint xsi:type="dc:Point" x="1114" y="783" /> + <di:waypoint xsi:type="dc:Point" x="1029" y="783" /> <di:waypoint xsi:type="dc:Point" x="1171" y="783" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1097.5" y="762" width="90" height="12" /> + <dc:Bounds x="1055" y="762" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_055b52t_di" bpmnElement="SequenceFlow_055b52t"> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVnfAndModules.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVnfAndModules.bpmn index ae77461070..c77c684fa4 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVnfAndModules.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateVnfAndModules.bpmn @@ -63,6 +63,7 @@ exceptionUtil.processJavaException(execution)]]></bpmn2:script> <camunda:in source="serviceModelInfo" target="serviceModelInfo" /> <camunda:in source="vnfModelInfo" target="vnfModelInfo" /> <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="cloudOwner" target="cloudOwner" /> <camunda:in source="lcpCloudRegionId" target="lcpCloudRegionId" /> <camunda:in source="tenantId" target="tenantId" /> <camunda:in source="sdncVersion" target="sdncVersion" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json index dc4669e8d9..13dd32226f 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json @@ -24,6 +24,7 @@ "cloudConfiguration": { "lcpCloudRegionId":"mdt1", + "cloudOwner" : "my-cloud-owner", "tenantId":"8b1df54faa3b49078e3416e21370a3ba" }, "requestParameters": diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json index dc4669e8d9..13dd32226f 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json @@ -24,6 +24,7 @@ "cloudConfiguration": { "lcpCloudRegionId":"mdt1", + "cloudOwner" : "my-cloud-owner", "tenantId":"8b1df54faa3b49078e3416e21370a3ba" }, "requestParameters": diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml index 8a5ade6fb6..dc48c79ff9 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml @@ -101,30 +101,6 @@ mso: version: '9' generic-vnf: version: '9' - v8: - customer: - uri: /aai/v8/business/customers/customer - generic-query: - uri: /aai/v8/search/generic-query - l3-network: - uri: /aai/v8/network/l3-networks/l3-network - network-policy: - uri: /aai/v8/network/network-policies/network-policy - nodes-query: - uri: /aai/v8/search/nodes-query - route-table-reference: - uri: /aai/v8/network/route-table-references/route-table-reference - tenant: - uri: /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant - vce: - uri: /aai/v8/network/vces/vce - vpn-binding: - uri: /aai/v8/network/vpn-bindings/vpn-binding - v9: - cloud-region: - uri: /aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic - generic-vnf: - uri: /aai/v9/network/generic-vnfs/generic-vnf global: default: aai: diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yml index 007615e569..f214c61042 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yml +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yml @@ -178,53 +178,6 @@ mso: version: '9' generic-vnf: version: '9' - v11: - customer: - uri: /aai/v11/business/customers/customer - generic-query: - uri: /aai/v11/search/generic-query - generic-vnf: - uri: /aai/v11/network/generic-vnfs/generic-vnf - l3-network: - uri: /aai/v11/network/l3-networks/l3-network - network-policy: - uri: /aai/v11/network/network-policies/network-policy - nodes-query: - uri: /aai/v11/search/nodes-query - route-table-reference: - uri: /aai/v11/network/route-table-references/route-table-reference - tenant: - uri: /aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant - vce: - uri: /aai/v11/network/vces/vce - vpn-binding: - uri: /aai/v11/network/vpn-bindings/vpn-binding - v8: - configuration: - uri: /aai/v11/network/configurations/configuration - customer: - uri: /aai/v8/business/customers/customer - generic-query: - uri: /aai/v8/search/generic-query - l3-network: - uri: /aai/v8/network/l3-networks/l3-network - network-policy: - uri: /aai/v8/network/network-policies/network-policy - nodes-query: - uri: /aai/v8/search/nodes-query - route-table-reference: - uri: /aai/v8/network/route-table-references/route-table-reference - tenant: - uri: /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant - vce: - uri: /aai/v8/network/vces/vce - vpn-binding: - uri: /aai/v8/network/vpn-bindings/vpn-binding - v9: - cloud-region: - uri: /aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic - generic-vnf: - uri: /aai/v9/network/generic-vnfs/generic-vnf retry: attempts: '1' deleteCinderVolumeV1: diff --git a/bpmn/so-bpmn-tasks/pom.xml b/bpmn/so-bpmn-tasks/pom.xml index 3483aed8a7..d46f13434f 100644 --- a/bpmn/so-bpmn-tasks/pom.xml +++ b/bpmn/so-bpmn-tasks/pom.xml @@ -29,7 +29,7 @@ <dependency> <groupId>org.onap.sdnc.northbound</groupId> <artifactId>generic-resource-api-client</artifactId> - <version>1.4.0-SNAPSHOT</version> + <version>1.4.1</version> <exclusions> <exclusion> <groupId>javax.ws.rs</groupId> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java index 7bc48519b0..0190f3df56 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java @@ -7,9 +7,9 @@ * 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. @@ -29,6 +29,7 @@ import java.util.UUID; import org.apache.commons.lang.SerializationUtils; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.delegate.DelegateExecution; import org.json.JSONArray; import org.json.JSONObject; import org.onap.so.bpmn.common.BuildingBlockExecution; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index 58c51f6223..c84e26911c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -20,6 +20,9 @@ package org.onap.so.bpmn.infrastructure.aai.tasks; +import java.util.List; +import java.util.Map; + import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -28,6 +31,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; @@ -209,22 +213,7 @@ public class AAIUpdateTasks { * @throws BBObjectNotFoundException */ public void updateOrchestrationStatusAssignedNetwork(BuildingBlockExecution execution) { - execution.setVariable("aaiNetworkAssignRollback", false); - try { - L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); - L3Network copiedl3network = l3network.shallowCopyId(); - - - l3network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED); - l3network.setHeatStackId(""); - - copiedl3network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED); - copiedl3network.setHeatStackId(""); - aaiNetworkResources.updateNetwork(copiedl3network); - execution.setVariable("aaiNetworkAssignRollback", true); - } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); - } + updateNetwork(execution, OrchestrationStatus.ASSIGNED); } /** @@ -233,18 +222,7 @@ public class AAIUpdateTasks { * @throws BBObjectNotFoundException */ public void updateOrchestrationStatusActiveNetwork(BuildingBlockExecution execution) { - execution.setVariable("aaiNetworkActivateRollback", false); - try { - L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); - L3Network copiedl3network = l3network.shallowCopyId(); - - copiedl3network.setOrchestrationStatus(OrchestrationStatus.ACTIVE); - l3network.setOrchestrationStatus(OrchestrationStatus.ACTIVE); - aaiNetworkResources.updateNetwork(copiedl3network); - execution.setVariable("aaiNetworkActivateRollback", true); - } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); - } + updateNetwork(execution, OrchestrationStatus.ACTIVE); } /** @@ -253,20 +231,35 @@ public class AAIUpdateTasks { * @throws BBObjectNotFoundException */ public void updateOrchestrationStatusCreatedNetwork(BuildingBlockExecution execution) { - execution.setVariable("aaiNetworkActivateRollback", false); + updateNetwork(execution, OrchestrationStatus.CREATED); + } + + protected void updateNetwork(BuildingBlockExecution execution, OrchestrationStatus status) { try { - L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); - L3Network copiedl3network = l3network.shallowCopyId(); - - copiedl3network.setOrchestrationStatus(OrchestrationStatus.CREATED); - l3network.setOrchestrationStatus(OrchestrationStatus.CREATED); - aaiNetworkResources.updateNetwork(copiedl3network); - execution.setVariable("aaiNetworkActivateRollback", true); + L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); + updateNetworkAAI(l3Network, status); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + protected void updateNetworkAAI(L3Network l3Network, OrchestrationStatus status) { + L3Network copiedl3Network = l3Network.shallowCopyId(); + + copiedl3Network.setOrchestrationStatus(status); + l3Network.setOrchestrationStatus(status); + aaiNetworkResources.updateNetwork(copiedl3Network); + + List<Subnet> subnets = l3Network.getSubnets(); + if (subnets != null){ + for (Subnet subnet : subnets){ + Subnet copiedSubnet = subnet.shallowCopyId(); + copiedSubnet.setOrchestrationStatus(status); + aaiNetworkResources.updateSubnet(copiedl3Network, copiedSubnet); + } + } + } + /** * BPMN access method to update status of L3Network Collection to Active in AAI * @param execution @@ -336,6 +329,18 @@ public class AAIUpdateTasks { copiedl3network.setNeutronNetworkId(response.getNeutronNetworkId()); aaiNetworkResources.updateNetwork(copiedl3network); + + Map<String, String> subnetMap = response.getSubnetMap(); + List<Subnet> subnets = l3network.getSubnets(); + if (subnets != null && subnetMap != null){ + for (Subnet subnet: subnets){ + Subnet copiedSubnet = subnet.shallowCopyId(); + copiedSubnet.setNeutronSubnetId(subnetMap.get(copiedSubnet.getSubnetId())); + copiedSubnet.setOrchestrationStatus(OrchestrationStatus.CREATED); + aaiNetworkResources.updateSubnet(copiedl3network, copiedSubnet); + } + } + execution.setVariable("aaiNetworkActivateRollback", true); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnf.java index bf429ee4fc..534e93637a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnf.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnf.java @@ -29,6 +29,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIInstanceGroupResources; import org.springframework.beans.factory.annotation.Autowired; @@ -55,10 +56,10 @@ public class AssignVnf { if(ModelInfoInstanceGroup.TYPE_VNFC.equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) { instanceGroup.setInstanceGroupName(aaiObjectInstanceNameGenerator.generateInstanceGroupName(instanceGroup, vnf)); aaiInstanceGroupResources.createInstanceGroup(instanceGroup); - aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf); + aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.BELONGS_TO); } else if(ModelInfoInstanceGroup.TYPE_NETWORK_INSTANCE_GROUP.equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) { - aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf); + aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.USES); } } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java index 5f263e8b4b..ec79b2825a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java @@ -72,8 +72,8 @@ public class SDNCAssignTasks { } public void assignVnf(BuildingBlockExecution execution) { - try { - GeneralBuildingBlock gBBInput = execution.getVariable("generalBuildingBlock"); + try { + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); RequestContext requestContext = gBBInput.getRequestContext(); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index e7d09f83e0..24246273e8 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -104,6 +104,7 @@ public class WorkflowAction { private static final String USERPARAMSERVICE = "service"; private static final String supportedTypes = "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances"; private static final String HOMINGSOLUTION = "Homing_Solution"; + private static final String FABRIC_CONFIGURATION = "FabricConfiguration"; private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class); @Autowired @@ -177,6 +178,7 @@ public class WorkflowAction { if (orchFlows == null || orchFlows.isEmpty()) { orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte); } + orchFlows = filterOrchFlows(orchFlows, resourceType, execution); String key = ""; ModelInfo modelInfo = sIRequest.getRequestDetails().getModelInfo(); if(modelInfo.getModelType().equals(ModelType.service)) { @@ -238,7 +240,7 @@ public class WorkflowAction { && (requestAction.equalsIgnoreCase("activateInstance") || requestAction.equalsIgnoreCase("unassignInstance") || requestAction.equalsIgnoreCase("deleteInstance") - || requestAction.equalsIgnoreCase("activateFabricConfiguration"))) { + || requestAction.equalsIgnoreCase("activate" + FABRIC_CONFIGURATION))) { // SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and // SERVICE-MACRO-DELETE // Will never get user params with service, macro will have @@ -292,6 +294,7 @@ public class WorkflowAction { execution.setVariable("retryCount", 0); execution.setVariable("isRollback", false); execution.setVariable("flowsToExecute", flowsToExecute); + execution.setVariable("isRollbackComplete", false); } catch (Exception ex) { buildAndThrowException(execution, "Exception in create execution list " + ex.getMessage(), ex); @@ -619,13 +622,13 @@ public class WorkflowAction { } - private List<String> traverseCatalogDbForConfiguration(String vnfCustomizationUUID, String vfModuleCustomizationUUID) { + protected List<String> traverseCatalogDbForConfiguration(String vnfCustomizationUUID, String vfModuleCustomizationUUID) { List<String> configurations = new ArrayList<>(); try{ List<CvnfcCustomization> cvnfcCustomizations = catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(vnfCustomizationUUID, vfModuleCustomizationUUID); for(CvnfcCustomization cvnfc : cvnfcCustomizations){ for(VnfVfmoduleCvnfcConfigurationCustomization customization : cvnfc.getVnfVfmoduleCvnfcConfigurationCustomization()){ - if(customization.getConfigurationResource().getToscaNodeType().contains("FabricConfiguration")){ + if(customization.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)){ configurations.add(customization.getConfigurationResource().getModelUUID()); } } @@ -964,6 +967,17 @@ public class WorkflowAction { } return listToExecute; } + + protected List<OrchestrationFlow> filterOrchFlows(List<OrchestrationFlow> orchFlows, WorkflowType resourceType, DelegateExecution execution) { + List<OrchestrationFlow> result = new ArrayList<>(orchFlows); + if (resourceType.equals(WorkflowType.VFMODULE)) { + List<String> fabricCustomizations = traverseCatalogDbForConfiguration((String)execution.getVariable("vnfId"), (String)execution.getVariable("vfModuleId")); + if (fabricCustomizations.isEmpty()) { + result = orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION)).collect(Collectors.toList()); + } + } + return result; + } protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) { logger.error(msg, ex); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 8a16b54bf4..4e02ca3f6f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -290,16 +290,11 @@ public class WorkflowActionBBTasks { String requestId = (String) execution.getVariable(G_REQUEST_ID); InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); String errorMsg = null; - boolean rollback = false; + boolean rollback = (boolean) execution.getVariable("isRollbackComplete"); try { WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException"); - if(exception.getErrorMessage()!=null || !exception.getErrorMessage().equals("")){ + if(exception != null && (exception.getErrorMessage()!=null || !exception.getErrorMessage().equals(""))){ errorMsg = exception.getErrorMessage(); - rollback = (boolean) execution.getVariable("isRollbackComplete"); - if(rollback){ - errorMsg = errorMsg + " + Rollback has been completed successfully."; - } - request.setStatusMessage(errorMsg); } } catch (Exception ex) { //log error and attempt to extact WorkflowExceptionMessage @@ -308,12 +303,16 @@ public class WorkflowActionBBTasks { if (errorMsg == null){ try { errorMsg = (String) execution.getVariable("WorkflowExceptionErrorMessage"); - request.setStatusMessage(errorMsg); } catch (Exception ex) { logger.error("Failed to extract workflow exception message from WorkflowException",ex); - request.setStatusMessage("Unexpected Error in BPMN"); + errorMsg = "Unexpected Error in BPMN."; } } + if(rollback){ + errorMsg = errorMsg + " + Rollback has been completed successfully."; + } + request.setProgress(Long.valueOf(100)); + request.setStatusMessage(errorMsg); request.setRequestStatus("FAILED"); request.setLastModifiedBy("CamundaBPMN"); requestDbclient.updateInfraActiveRequests(request); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java index 4a1c3f512c..c895566ca5 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java @@ -298,5 +298,8 @@ public class AAIObjectMapper { aaiVpnBinding.setRouteTargets(routeTargets); } } - + + public org.onap.aai.domain.yang.Subnet mapSubnet (Subnet subnet){ + return modelMapper.map(subnet,org.onap.aai.domain.yang.Subnet.class); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java index 056ac3f6e5..57c760b01f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java @@ -33,6 +33,7 @@ import org.onap.so.adapters.nwrest.ContrailNetwork; import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.adapters.nwrest.DeleteNetworkRequest; +import org.onap.so.adapters.nwrest.NetworkTechnology; import org.onap.so.adapters.nwrest.ProviderVlanNetwork; import org.onap.so.adapters.nwrest.RollbackNetworkRequest; import org.onap.so.adapters.nwrest.UpdateNetworkRequest; @@ -82,6 +83,8 @@ public class NetworkAdapterObjectMapper { ProviderVlanNetwork providerVlanNetwork = buildProviderVlanNetwork(l3Network); createNetworkRequest.setProviderVlanNetwork(providerVlanNetwork); + createNetworkRequest.setNetworkTechnology(setNetworkTechnology(l3Network.getModelInfoNetwork().getNetworkTechnology())); + //build and set Contrail Network ContrailNetwork contrailNetwork = buildContrailNetwork(l3Network, customer); createNetworkRequest.setContrailNetwork(contrailNetwork); @@ -100,6 +103,16 @@ public class NetworkAdapterObjectMapper { return createNetworkRequest; } + + protected NetworkTechnology setNetworkTechnology(String networkTechnology) { + if(networkTechnology.equalsIgnoreCase("Contrail")) { + return NetworkTechnology.CONTRAIL; + } else if(networkTechnology.equalsIgnoreCase("Neutron")){ + return NetworkTechnology.NEUTRON; + } else { + return NetworkTechnology.VMWARE; + } + } public DeleteNetworkRequest deleteNetworkRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, ServiceInstance serviceInstance, L3Network l3Network) throws UnsupportedEncodingException { DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest(); @@ -330,9 +343,8 @@ public class NetworkAdapterObjectMapper { private CreateNetworkRequest setFlowFlags(CreateNetworkRequest createNetworkRequest, OrchestrationContext orchestrationContext){ //TODO confirm flag value - createNetworkRequest.setSkipAAI(true); - //revert suppressRollabck=TRUE into backout=FALSE and vice versa - createNetworkRequest.setBackout(orchestrationContext.getIsRollbackEnabled()); + createNetworkRequest.setSkipAAI(true); + createNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); //TODO confirm value - false by default createNetworkRequest.setFailIfExists(true); //NetworkTechnology(NetworkTechnology.NEUTRON); NOOP - default @@ -340,9 +352,8 @@ public class NetworkAdapterObjectMapper { } private void setFlowFlags(UpdateNetworkRequest updateNetworkRequest, OrchestrationContext orchestrationContext){ - updateNetworkRequest.setSkipAAI(true); - //revert suppressRollabck=TRUE into backout=FALSE and vice versa - updateNetworkRequest.setBackout(!Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); + updateNetworkRequest.setSkipAAI(true); + updateNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); //NetworkTechnology(NetworkTechnology.NEUTRON); NOOP - default } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java index ec202b8a3f..93e588f2e1 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java @@ -74,7 +74,7 @@ public class VnfAdapterObjectMapper { createVolumeGroupRequest.setVolumeGroupParams(createVolumeGroupParams(requestContext,genericVnf, volumeGroup, sdncVfModuleQueryResponse)); createVolumeGroupRequest.setSkipAAI(true); - createVolumeGroupRequest.setSuppressBackout(orchestrationContext.getIsRollbackEnabled()); + createVolumeGroupRequest.setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); createVolumeGroupRequest.setFailIfExists(true); createVolumeGroupRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance)); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index 2b58b7bdd7..a36d18c524 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -23,15 +23,18 @@ package org.onap.so.client.adapter.vnf.mapper; import static java.util.Arrays.asList; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Optional; import javax.annotation.PostConstruct; -import javax.validation.Valid; import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; @@ -137,7 +140,7 @@ public class VnfAdapterVfModuleObjectMapper { createVfModuleRequest.setVfModuleParams(buildVfModuleParamsMap(requestContext, serviceInstance, genericVnf, vfModule, sdncVnfQueryResponse, sdncVfModuleQueryResponse)); createVfModuleRequest.setSkipAAI(true); - createVfModuleRequest.setBackout(orchestrationContext.getIsRollbackEnabled()); + createVfModuleRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); createVfModuleRequest.setFailIfExists(true); MsoRequest msoRequest = buildMsoRequest(requestContext, serviceInstance); @@ -303,6 +306,9 @@ public class VnfAdapterVfModuleObjectMapper { buildVfModuleSriovParameters(paramsMap, network, networkKey); // IPV4 and IPV6 Addresses buildVfModuleNetworkInformation(paramsMap, network, key, networkKey); + + buildVlanInformation(paramsMap, network, key, networkKey); + } } } @@ -315,6 +321,36 @@ public class VnfAdapterVfModuleObjectMapper { } } + protected void buildVlanInformation(Map<String, String> paramsMap, + GenericResourceApiVmNetworkData network, String key, String networkKey) { + + String networkString = convertToString(network); + String vlanFilterKey = key + UNDERSCORE + networkKey + UNDERSCORE + "vlan_filter"; + String privateVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "private_vlans"; + String publicVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "public_vlans"; + String guestVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "guest_vlans"; + + if (network.getSegmentationId() != null) { + paramsMap.put(vlanFilterKey, network.getSegmentationId()); + } + + List<String> privateVlans = jsonPath.locateResultList(networkString, "$.related-networks.related-network[?(@.vlan-tags.is-private == true)].vlan-tags.upper-tag-id"); + List<String> publicVlans = jsonPath.locateResultList(networkString, "$.related-networks.related-network[?(@.vlan-tags.is-private == false)].vlan-tags.upper-tag-id"); + List<String> concat = new ArrayList<>(privateVlans); + concat.addAll(publicVlans); + Collection<String> guestVlans = new HashSet<>(concat); + + if (!privateVlans.isEmpty()) { + paramsMap.put(privateVlansKey, Joiner.on(",").join(privateVlans)); + } + if (!publicVlans.isEmpty()) { + paramsMap.put(publicVlansKey, Joiner.on(",").join(publicVlans)); + } + if (!guestVlans.isEmpty()) { + paramsMap.put(guestVlansKey, Joiner.on(",").join(guestVlans)); + } + } + private void buildVfModuleVmNames(Map<String,String> paramsMap, GenericResourceApiVmTopologyData vm, String key) { String values = ""; GenericResourceApiVmtopologydataVmNames vmNames = vm.getVmNames(); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java index 4c4edb7fe9..68f6e8ffa2 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java @@ -26,6 +26,7 @@ import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; @@ -57,6 +58,12 @@ public class AAIInstanceGroupResources { injectionHelper.getAaiClient().connect(instanceGroupUri, vnfURI); } + public void connectInstanceGroupToVnf(InstanceGroup instanceGroup, GenericVnf vnf, AAIEdgeLabel aaiLabel) { + AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); + AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()); + injectionHelper.getAaiClient().connect(instanceGroupUri, vnfURI, aaiLabel); + } + public boolean exists(InstanceGroup instanceGroup) { AAIResourceUri instanceGroupUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); return injectionHelper.getAaiClient().exists(instanceGroupUri); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java index e4984c921d..dc5ba64d2d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java @@ -31,6 +31,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.uri.AAIResourceUri; @@ -55,6 +56,12 @@ public class AAINetworkResources { injectionHelper.getAaiClient().update(networkURI, aaiL3Network); } + public void updateSubnet(L3Network network, Subnet subnet) { + AAIResourceUri subnetURI = AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, network.getNetworkId(), subnet.getSubnetId()); + org.onap.aai.domain.yang.Subnet aaiSubnet = aaiObjectMapper.mapSubnet(subnet); + injectionHelper.getAaiClient().update(subnetURI, aaiSubnet); + } + public void createNetworkConnectToServiceInstance(L3Network network, ServiceInstance serviceInstance) { AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId()); network.setOrchestrationStatus(OrchestrationStatus.INVENTORIED); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java index b5738dcb40..86dd22b65c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java @@ -107,7 +107,7 @@ public class AAIServiceInstanceResources { } public boolean existsOwningEntityName(String owningEntityName) { - AAIResourceUri owningEntityUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.OWNING_ENTITIES).queryParam("owning-entity-name", owningEntityName); + AAIResourceUri owningEntityUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.OWNING_ENTITY).queryParam("owning-entity-name", owningEntityName); AAIResourcesClient aaiRC = injectionHelper.getAaiClient(); return aaiRC.exists(owningEntityUri); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java index 8bd55f0f90..092af30558 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java @@ -7,9 +7,9 @@ * 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. @@ -28,6 +28,7 @@ import org.onap.aai.domain.yang.VpnBindings; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; +import org.onap.so.client.aai.AAIObjectPlurals; 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; @@ -39,10 +40,10 @@ import org.springframework.stereotype.Component; public class AAIVpnBindingResources { @Autowired private InjectionHelper injectionHelper; - + @Autowired private AAIObjectMapper aaiObjectMapper; - + /** * @param customer */ @@ -56,10 +57,10 @@ public class AAIVpnBindingResources { * @return */ public Optional<VpnBindings> getVpnBindingByCustomerVpnId (String customerVpnId) { - AAIResourceUri aaiVpnBindingsResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDINGS) + AAIResourceUri aaiVpnBindingsResourceUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VPN_BINDING) .queryParam("customer-vpn-id",customerVpnId); - return injectionHelper.getAaiClient().get(VpnBindings.class,aaiVpnBindingsResourceUri); - + return injectionHelper.getAaiClient().get(VpnBindings.class,aaiVpnBindingsResourceUri); + } /** diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java index 432399b1b8..3975b25356 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java @@ -86,8 +86,8 @@ public class GeneralTopologyObjectMapper { networkInformation.setFromPreload(null); networkInformation.setNetworkId(network.getNetworkId()); - //TODO fix this after network type filed included in L3Network object type - //networkInformation.setNetworkType(network.getNetwork); + networkInformation.setNetworkType(network.getNetworkType()); + networkInformation.setNetworkTechnology(network.getNetworkTechnology()); return networkInformation; } /* diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java index a9f695b5be..2b4834af42 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/NetworkTopologyOperationRequestMapper.java @@ -87,6 +87,7 @@ public class NetworkTopologyOperationRequestMapper { private GenericResourceApiNetworkrequestinputNetworkRequestInput buildNetworkRequestInput(L3Network network, ServiceInstance serviceInstance, CloudRegion cloudRegion){ GenericResourceApiNetworkrequestinputNetworkRequestInput networkRequestInput = new GenericResourceApiNetworkrequestinputNetworkRequestInput(); networkRequestInput.setTenant(cloudRegion.getTenantId()); + networkRequestInput.setCloudOwner(cloudRegion.getCloudOwner()); networkRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId()); if (network.getNetworkName() != null && !network.getNetworkName().equals("")) { networkRequestInput.setNetworkName(network.getNetworkName()); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java index 7013a50dcf..a6ef02bd4d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java @@ -114,6 +114,7 @@ public class VfModuleTopologyOperationRequestMapper { if (cloudRegion != null) { vfModuleRequestInput.setTenant(cloudRegion.getTenantId()); vfModuleRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId()); + vfModuleRequestInput.setCloudOwner(cloudRegion.getCloudOwner()); } if (vfModule.getVfModuleName() != null && !vfModule.getVfModuleName().equals("")) { vfModuleRequestInput.setVfModuleName(vfModule.getVfModuleName()); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java index 8944d1eaa4..bf128a4838 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java @@ -71,7 +71,8 @@ public class VnfTopologyOperationRequestMapper { vnfRequestInput.setTenant(cloudRegion.getTenantId()); vnfRequestInput.setAicCloudRegion(cloudRegion.getLcpCloudRegionId()); - + vnfRequestInput.setCloudOwner(cloudRegion.getCloudOwner()); + if (StringUtils.isNotBlank(vnf.getVnfName())) { vnfRequestInput.setVnfName(vnf.getVnfName()); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java index b5bb0bed94..380a94f951 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java @@ -52,6 +52,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; @@ -71,6 +72,7 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.exception.BBObjectNotFoundException; +import org.onap.so.db.catalog.beans.OrchestrationStatus; public class TestDataSetup{ private int collectionCounter; @@ -686,4 +688,12 @@ public class TestDataSetup{ serviceInstance.setConfigurations(configurations); return config; } + + public Subnet buildSubnet() { + Subnet subnet = new Subnet(); + subnet.setSubnetId("testSubnetId"); + subnet.setOrchestrationStatus(OrchestrationStatus.PENDING); + subnet.setNeutronSubnetId("testNeutronSubnetId"); + return subnet; + } }
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index d800ae9618..55958946a3 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -21,14 +21,24 @@ package org.onap.so.bpmn.infrastructure.aai.tasks; import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.HashMap; import org.camunda.bpm.engine.delegate.BpmnError; +import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -36,6 +46,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.db.catalog.beans.OrchestrationStatus; @@ -52,6 +63,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ private VolumeGroup volumeGroup; private CloudRegion cloudRegion; private Configuration configuration; + private Subnet subnet; @Before public void before() { @@ -62,6 +74,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ cloudRegion = setCloudRegion(); network = setL3Network(); configuration = setConfiguration(); + subnet = buildSubnet(); } @Test @@ -290,51 +303,14 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ doThrow(Exception.class).when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution); } - - @Test - public void updateOstatusAssignedNetworkTest() throws Exception { - doNothing().when(aaiNetworkResources).updateNetwork(network); - - aaiUpdateTasks.updateOrchestrationStatusAssignedNetwork(execution); - - verify(aaiNetworkResources, times(1)).updateNetwork(network); - assertEquals("", network.getHeatStackId()); - } @Test - public void updateOstatusAssignedNetworkExceptionTest() throws Exception { - expectedException.expect(BpmnError.class); - - doThrow(Exception.class).when(aaiNetworkResources).updateNetwork(network); - - aaiUpdateTasks.updateOrchestrationStatusAssignedNetwork(execution); - } - - @Test - public void updateOstatusActivedNetworkTest() throws Exception { - doNothing().when(aaiNetworkResources).updateNetwork(network); - - aaiUpdateTasks.updateOrchestrationStatusActiveNetwork(execution); - - verify(aaiNetworkResources, times(1)).updateNetwork(network); - } - - @Test - public void updateOstatusCreatedNetworkTest() throws Exception { - doNothing().when(aaiNetworkResources).updateNetwork(network); - - aaiUpdateTasks.updateOrchestrationStatusActiveNetwork(execution); - - verify(aaiNetworkResources, times(1)).updateNetwork(network); - } - - @Test - public void updateOstatusActiveNetworkExceptionTest() throws Exception { + public void updateNetworkExceptionTest() throws Exception { expectedException.expect(BpmnError.class); doThrow(Exception.class).when(aaiNetworkResources).updateNetwork(network); - aaiUpdateTasks.updateOrchestrationStatusActiveNetwork(execution); + aaiUpdateTasks.updateNetwork(execution, OrchestrationStatus.ACTIVE); } @Test @@ -374,20 +350,62 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse(); createNetworkResponse.setNetworkFqdn("testNetworkFqdn"); createNetworkResponse.setNetworkStackId("testNetworkStackId"); + HashMap<String, String> subnetMap = new HashMap<String, String>(); + subnetMap.put("testSubnetId", "testNeutronSubnetId"); + createNetworkResponse.setSubnetMap(subnetMap); + + network.getSubnets().add(subnet); execution.setVariable("createNetworkResponse", createNetworkResponse); doNothing().when(aaiNetworkResources).updateNetwork(network); + doNothing().when(aaiNetworkResources).updateSubnet(network, subnet); + aaiUpdateTasks.updateNetworkCreated(execution); verify(aaiNetworkResources, times(1)).updateNetwork(network); + verify(aaiNetworkResources, times(1)).updateSubnet(network, subnet); assertEquals(createNetworkResponse.getNetworkFqdn(), network.getContrailNetworkFqdn()); assertEquals(OrchestrationStatus.CREATED, network.getOrchestrationStatus()); assertEquals(createNetworkResponse.getNetworkStackId(), network.getHeatStackId()); assertEquals(createNetworkResponse.getNeutronNetworkId(), network.getNeutronNetworkId()); + String neutronSubnetId = createNetworkResponse.getSubnetMap().entrySet().iterator().next().getValue(); + assertEquals(neutronSubnetId, network.getSubnets().get(0).getNeutronSubnetId()); } @Test + public void updateOrchestrationStatusNetworkTest() { + AAIUpdateTasks spy = Mockito.spy(new AAIUpdateTasks()); + doNothing().when(spy).updateNetwork(eq(execution), any()); + spy.updateOrchestrationStatusActiveNetwork(execution); + verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.ACTIVE); + spy.updateOrchestrationStatusAssignedNetwork(execution); + verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.ASSIGNED); + spy.updateOrchestrationStatusCreatedNetwork(execution); + verify(spy, times(1)).updateNetwork(execution, OrchestrationStatus.CREATED); + } + + @Test + public void updateNetworkAAITest() { + + L3Network spy = spy(new L3Network()); + L3Network shallowCopy = mock(L3Network.class); + Subnet mockSubnet = mock(Subnet.class); + Subnet shallowCopySubnet = mock(Subnet.class); + when(mockSubnet.shallowCopyId()).thenReturn(shallowCopySubnet); + doReturn(shallowCopy).when(spy).shallowCopyId(); + + doNothing().when(aaiNetworkResources).updateNetwork(network); + doNothing().when(aaiNetworkResources).updateSubnet(network, subnet); + + spy.getSubnets().add(mockSubnet); + aaiUpdateTasks.updateNetworkAAI(spy, OrchestrationStatus.CREATED); + + verify(shallowCopy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED); + verify(spy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED); + verify(shallowCopySubnet, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED); + } + @Test public void updateNetworkCreatedkExceptionTest() throws Exception { expectedException.expect(BpmnError.class); doThrow(Exception.class).when(aaiNetworkResources).updateNetwork(network); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java index 7cade7703a..dcc95affce 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java @@ -1,3 +1,23 @@ +/*- + * ============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.bpmn.infrastructure.appc.tasks; import static org.mockito.Mockito.times; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java index e1b652a140..8382b9be72 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignVnfTest.java @@ -33,6 +33,7 @@ import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; +import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.springframework.beans.factory.annotation.Autowired; public class AssignVnfTest extends BaseTaskTest { @@ -87,10 +88,10 @@ public class AssignVnfTest extends BaseTaskTest { assignVnf.createInstanceGroups(execution); verify(aaiInstanceGroupResources, times(1)).createInstanceGroup(instanceGroup1); verify(aaiInstanceGroupResources, times(1)).createInstanceGroup(instanceGroup2); - verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup1, genericVnf); - verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup2, genericVnf); - verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup3, genericVnf); - verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup4, genericVnf); + verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup1, genericVnf, AAIEdgeLabel.BELONGS_TO); + verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup2, genericVnf, AAIEdgeLabel.BELONGS_TO); + verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup3, genericVnf, AAIEdgeLabel.USES); + verify(aaiInstanceGroupResources, times(1)).connectInstanceGroupToVnf(instanceGroup4, genericVnf, AAIEdgeLabel.USES); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java new file mode 100644 index 0000000000..b4ec68050e --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java @@ -0,0 +1,178 @@ +/*- + * ============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.bpmn.infrastructure.workflow.tasks; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyBoolean; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.AAIConfigurationResources; +import org.onap.so.db.catalog.beans.ConfigurationResource; +import org.onap.so.db.catalog.beans.CvnfcCustomization; +import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization; +import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; +import org.onap.so.db.catalog.client.CatalogDbClient; + +@RunWith(MockitoJUnitRunner.class) +public class WorkflowActionUnitTest { + + private final static String JSON_FILE_LOCATION = "src/test/resources/__files/Macro/"; + + @Mock + private CatalogDbClient catalogDbClient; + @Mock + private BBInputSetup bbInputSetup; + @Mock + private BBInputSetupUtils bbInputSetupUtils; + @Mock + private ExceptionBuilder exceptionBuilder; + @Mock + private AAIConfigurationResources aaiConfigurationResources; + + @InjectMocks + @Spy + private WorkflowAction workflowAction; + + @Test + public void filterOrchFlowsHasFabricTest() { + + List<OrchestrationFlow> flows = createFlowList( + "DeactivateFabricConfigurationBB", + "flow x", + "flow y", + "ActivateFabricConfigurationBB", + "flow z"); + doReturn(Arrays.asList("yes", "yes")).when(workflowAction).traverseCatalogDbForConfiguration(any(String.class), any(String.class)); + + List<OrchestrationFlow> result = workflowAction.filterOrchFlows(flows, WorkflowType.VFMODULE, mock(DelegateExecution.class)); + + assertThat(result, is(flows)); + } + + @Test + public void filterOrchFlowNoFabricTest() { + List<OrchestrationFlow> flows = createFlowList( + "DeactivateFabricConfigurationBB", + "flow x", + "flow y", + "ActivateFabricConfigurationBB", + "flow z"); + doReturn(Arrays.asList()).when(workflowAction).traverseCatalogDbForConfiguration(any(String.class), any(String.class)); + + List<OrchestrationFlow> result = workflowAction.filterOrchFlows(flows, WorkflowType.VFMODULE, mock(DelegateExecution.class)); + List<OrchestrationFlow> expected = createFlowList( + "flow x", + "flow y", + "flow z"); + + assertThat(result, is(expected)); + } + + @Test + public void traverseCatalogDbForConfigurationTest() { + + CvnfcCustomization cvnfcCustomization = new CvnfcCustomization(); + VnfVfmoduleCvnfcConfigurationCustomization vfModuleCustomization = new VnfVfmoduleCvnfcConfigurationCustomization(); + ConfigurationResource configuration = new ConfigurationResource(); + configuration.setToscaNodeType("FabricConfiguration"); + configuration.setModelUUID("my-uuid"); + vfModuleCustomization.setConfigurationResource(configuration); + cvnfcCustomization.setVnfVfmoduleCvnfcConfigurationCustomization(Collections.singleton(vfModuleCustomization)); + List<CvnfcCustomization> cvnfcCustomizations = Arrays.asList(cvnfcCustomization); + when(catalogDbClient.getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(any(String.class), any(String.class))) + .thenReturn(cvnfcCustomizations); + + List<String> results = workflowAction.traverseCatalogDbForConfiguration("myVnfCustomizationId", "myVfModuleCustomizationId"); + + assertThat(results, is(Arrays.asList("my-uuid"))); + + } + + @Test + public void verifyFilterOrchInvocation() throws Exception { + DelegateExecution execution = mock(DelegateExecution.class); + + when(execution.getVariable(eq("aLaCarte"))).thenReturn(true); + when(execution.getVariable(eq("bpmnRequest"))).thenReturn(getJson("ServiceMacroAssign.json")); + when(execution.getVariable(eq("requestUri"))).thenReturn("/v6/serviceInstances/123/vnfs/1234"); + + OrchestrationFlow flow = new OrchestrationFlow(); + flow.setFlowName("flow x"); + + List<OrchestrationFlow> flows = Arrays.asList(flow); + doReturn(Arrays.asList(flow)).when(workflowAction).queryNorthBoundRequestCatalogDb(any(), any(), any(), anyBoolean()); + workflowAction.selectExecutionList(execution); + + verify(workflowAction, times(1)).filterOrchFlows(eq(flows), any(), any()); + + flow = new OrchestrationFlow(); + flow.setFlowName("flow y"); + flows = Arrays.asList(flow); + when(execution.getVariable(eq("aLaCarte"))).thenReturn(false); + workflowAction.selectExecutionList(execution); + + verify(workflowAction, never()).filterOrchFlows(eq(flows), any(), any()); + + } + + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + filename))); + } + + private List<OrchestrationFlow> createFlowList(String... myList) { + + List<OrchestrationFlow> result = new ArrayList<>(); + for (String name : myList) { + OrchestrationFlow flow = new OrchestrationFlow(); + flow.setFlowName(name); + result.add(flow); + } + + return result; + + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java index 99f1b188c9..d86453b87c 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java @@ -654,4 +654,21 @@ public class AAIObjectMapperTest { assertThat(actualRouteTarget, sameBeanAs(expectedRouteTarget)); } + + @Test + public void mapSubnetTest() { + Subnet subnet = new Subnet(); + subnet.setSubnetId("testSubnetId"); + subnet.setOrchestrationStatus(OrchestrationStatus.PENDING); + subnet.setNeutronSubnetId("testNeutronSubnetId"); + + org.onap.aai.domain.yang.Subnet expectedSubnet = new org.onap.aai.domain.yang.Subnet(); + expectedSubnet.setSubnetId("testSubnetId"); + expectedSubnet.setOrchestrationStatus("Pending"); + expectedSubnet.setNeutronSubnetId("testNeutronSubnetId"); + + org.onap.aai.domain.yang.Subnet actualSubnet = aaiObjectMapper.mapSubnet(subnet); + + assertThat(actualSubnet, sameBeanAs(expectedSubnet)); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java index fddba98f4c..8f0d00ff86 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java @@ -21,6 +21,7 @@ package org.onap.so.client.adapter.network.mapper; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.*; import static org.mockito.Mockito.doReturn; import java.io.UnsupportedEncodingException; @@ -38,6 +39,7 @@ import org.onap.so.adapters.nwrest.ContrailNetwork; import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.adapters.nwrest.DeleteNetworkRequest; +import org.onap.so.adapters.nwrest.NetworkTechnology; import org.onap.so.adapters.nwrest.ProviderVlanNetwork; import org.onap.so.adapters.nwrest.RollbackNetworkRequest; import org.onap.so.adapters.nwrest.UpdateNetworkRequest; @@ -96,6 +98,24 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{ } @Test + public void testSetNetworkTechnology() { + String networkTechnology = "Contrail"; + NetworkTechnology expectedNetworkTechnology = NetworkTechnology.CONTRAIL; + NetworkTechnology actualNetworkTechnology = SPY_networkAdapterObjectMapper.setNetworkTechnology(networkTechnology); + assertEquals("NetworkTechnology matches", expectedNetworkTechnology, actualNetworkTechnology); + + networkTechnology = "Neutron"; + expectedNetworkTechnology = NetworkTechnology.NEUTRON; + actualNetworkTechnology = SPY_networkAdapterObjectMapper.setNetworkTechnology(networkTechnology); + assertEquals("NetworkTechnology matches", expectedNetworkTechnology, actualNetworkTechnology); + + networkTechnology = "Vmware"; + expectedNetworkTechnology = NetworkTechnology.VMWARE; + actualNetworkTechnology = SPY_networkAdapterObjectMapper.setNetworkTechnology(networkTechnology); + assertEquals("NetworkTechnology matches", expectedNetworkTechnology, actualNetworkTechnology); + + } + @Test public void buildCreateNetworkRequestFromBbobjectTest() throws Exception { String cloudRegionPo = "cloudRegionPo"; @@ -108,7 +128,7 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{ expectedCreateNetworkRequest.setNetworkType(l3Network.getNetworkType()); expectedCreateNetworkRequest.setBackout(false); expectedCreateNetworkRequest.setFailIfExists(true); - + expectedCreateNetworkRequest.setNetworkTechnology(NetworkTechnology.CONTRAIL); MsoRequest msoRequest = new MsoRequest(); msoRequest.setRequestId(requestContext.getMsoRequestId()); msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId()); @@ -124,10 +144,11 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{ List<Subnet> subnetList = new ArrayList<Subnet>(); subnetList.add(openstackSubnet); l3Network.getSubnets().add(openstackSubnet); + l3Network.getModelInfoNetwork().setNetworkTechnology("Contrail"); CreateNetworkRequest createNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer); - assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("contrailNetwork").ignoring("providerVlanNetwork").ignoring("subnets").ignoring("networkParams").ignoring("messageId")); + assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("contrailRequest").ignoring("contrailNetwork").ignoring("providerVlanNetwork").ignoring("subnets").ignoring("networkParams").ignoring("messageId")); } @Test @@ -232,7 +253,7 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{ expectedUpdateNetworkRequest.setNetworkParams(userInput); expectedUpdateNetworkRequest.setMsoRequest(msoRequest); expectedUpdateNetworkRequest.setSkipAAI(true); - expectedUpdateNetworkRequest.setBackout(!Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); + expectedUpdateNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); expectedUpdateNetworkRequest.setMessageId("messageId"); expectedUpdateNetworkRequest.setNotificationUrl("http://localhost:28080/mso/WorkflowMesssage/NetworkAResponse/messageId"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java index b2f01f007f..8f5c8dfb5e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java @@ -134,7 +134,7 @@ public class VnfAdapterObjectMapperTest { expectedCreateVolumeGroupRequest.setVolumeGroupParams(volumeGroupParams); expectedCreateVolumeGroupRequest.setSkipAAI(true); - expectedCreateVolumeGroupRequest.setSuppressBackout(orchestrationContext.getIsRollbackEnabled()); + expectedCreateVolumeGroupRequest.setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); expectedCreateVolumeGroupRequest.setFailIfExists(true); MsoRequest msoRequest = new MsoRequest(); @@ -210,7 +210,7 @@ public class VnfAdapterObjectMapperTest { expectedCreateVolumeGroupRequest.setVolumeGroupParams(volumeGroupParams); expectedCreateVolumeGroupRequest.setSkipAAI(true); - expectedCreateVolumeGroupRequest.setSuppressBackout(orchestrationContext.getIsRollbackEnabled()); + expectedCreateVolumeGroupRequest.setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); expectedCreateVolumeGroupRequest.setFailIfExists(true); MsoRequest msoRequest = new MsoRequest(); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java index 0c9e281fc7..32a495e094 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java @@ -22,17 +22,20 @@ package org.onap.so.client.adapter.vnf.mapper; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.HashMap; +import java.util.Map; import org.junit.Before; import org.junit.Test; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVmNetworkData; import org.onap.so.adapters.vnfrest.CreateVfModuleRequest; import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; @@ -132,6 +135,80 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { } @Test + public void createVfModuleWithFalseRollbackRequestMapperTest() throws Exception { + + // prepare and set service instance + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); + modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid"); + modelInfoServiceInstance.setModelName("serviceModelName"); + modelInfoServiceInstance.setModelUuid("serviceModelUuid"); + modelInfoServiceInstance.setModelVersion("serviceModelVersion"); + modelInfoServiceInstance.setEnvironmentContext("environmentContext"); + modelInfoServiceInstance.setWorkloadContext("workloadContext"); + serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); + + RequestContext requestContext = new RequestContext(); + HashMap<String, String> userParams = new HashMap<String, String>(); + userParams.put("key1", "value2"); + requestContext.setMsoRequestId("requestId"); + requestContext.setUserParams(userParams); + requestContext.setProductFamilyId("productFamilyId"); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("vnfId"); + vnf.setVnfType("vnfType"); + vnf.setVnfName("vnfName"); + ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); + modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid"); + modelInfoGenericVnf.setModelName("vnfModelName"); + modelInfoGenericVnf.setModelVersion("vnfModelVersion"); + modelInfoGenericVnf.setModelUuid("vnfModelUuid"); + modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid"); + vnf.setModelInfoGenericVnf(modelInfoGenericVnf); + + Integer vfModuleIndex = 1; + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("vfModuleId"); + vfModule.setVfModuleName("vfModuleName"); + vfModule.setModuleIndex(vfModuleIndex); + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); + modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid"); + modelInfoVfModule.setModelName("vfModuleModelName"); + modelInfoVfModule.setModelVersion("vfModuleModelVersion"); + modelInfoVfModule.setModelUUID("vfModuleModelUuid"); + modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid"); + vfModule.setModelInfoVfModule(modelInfoVfModule); + HashMap<String, String> cloudParams = new HashMap<String, String>(); + cloudParams.put("key3", "value3"); + vfModule.setCloudParams(cloudParams); + + CloudRegion cloudRegion = new CloudRegion(); + cloudRegion.setLcpCloudRegionId("cloudRegionId"); + cloudRegion.setTenantId("tenantId"); + + OrchestrationContext orchestrationContext = new OrchestrationContext(); + orchestrationContext.setIsRollbackEnabled(true); + + String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json"))); + String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json"))); + + CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper( + requestContext, cloudRegion, orchestrationContext, serviceInstance, + vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse); + + + String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestTrueBackout.json"))); + + CreateVfModuleRequest reqMapper1 = omapper.readValue( + jsonToCompare, + CreateVfModuleRequest.class); + + assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl")); + } + + @Test public void createVfModuleRequestWithNoEnvironmentAndWorkloadContextMapperTest() throws Exception { // prepare and set service instance @@ -770,4 +847,18 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl")); } + + @Test + public void networkCloudParamsTest() throws IOException { + + String json = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "grApiVmNetworkSubSectionWith5GParams.json"))); + GenericResourceApiVmNetworkData network = omapper.readValue(json, GenericResourceApiVmNetworkData.class); + Map<String, String> paramsMap = new HashMap<>(); + vfModuleObjectMapper.buildVlanInformation(paramsMap, network, "testKey", "testType"); + + assertEquals("1,3", paramsMap.get("testKey_testType_private_vlans")); + assertEquals("2,3", paramsMap.get("testKey_testType_public_vlans")); + assertEquals("1,2,3", paramsMap.get("testKey_testType_guest_vlans")); + assertEquals("my-segemntation-id", paramsMap.get("testKey_testType_vlan_filter")); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java index aef25e5ded..621e275fdf 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java @@ -40,6 +40,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient; +import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; @RunWith(MockitoJUnitRunner.class) @@ -87,6 +88,12 @@ public class AAIInstanceGroupResourcesTest extends TestDataSetup{ } @Test + public void connectInstanceGroupWithEdgeTest() throws Exception { + aaiInstanceGroupResources.connectInstanceGroupToVnf(instanceGroup, vnf, AAIEdgeLabel.BELONGS_TO); + verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())), eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId())), eq(AAIEdgeLabel.BELONGS_TO)); + } + + @Test public void existsTest() throws Exception { aaiInstanceGroupResources.exists(instanceGroup); verify(MOCK_aaiResourcesClient, times(1)).exists(eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()))); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java index fa3324840c..cf270c21a7 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java @@ -55,6 +55,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.AAIResultWrapper; @@ -74,6 +75,7 @@ public class AAINetworkResourcesTest extends TestDataSetup{ private InstanceGroup instanceGroup; private ServiceInstance serviceInstance; private CloudRegion cloudRegion; + private Subnet subnet; @Mock protected AAIResourcesClient MOCK_aaiResourcesClient; @@ -101,6 +103,9 @@ public class AAINetworkResourcesTest extends TestDataSetup{ serviceInstance = buildServiceInstance(); cloudRegion = buildCloudRegion(); + + subnet = buildSubnet(); + doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient(); } @@ -314,4 +319,15 @@ public class AAINetworkResourcesTest extends TestDataSetup{ aaiNetworkResources.deleteNetworkInstanceGroup(instanceGroup); verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class)); } + + @Test + public void updateSubnetTest() throws Exception { + + doReturn(new org.onap.aai.domain.yang.Subnet()).when(MOCK_aaiObjectMapper).mapSubnet(subnet); + doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Subnet.class)); + + aaiNetworkResources.updateSubnet(network, subnet); + + verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Subnet.class)); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java index 298a3de9ba..ba7dc8d618 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java @@ -20,9 +20,11 @@ package org.onap.so.client.sdnc.mapper; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; import java.util.HashMap; @@ -32,28 +34,31 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.InjectMocks; +import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; +import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; +import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; +import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; import org.onap.so.bpmn.common.data.TestDataSetup; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.sdnc.northbound.client.model.GenericResourceApiConfigurationinformationConfigurationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiGcrequestinputGcRequestInput; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; -import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation; - -public class GeneralTopologyObjectMapperTest extends TestDataSetup{ +public class GeneralTopologyObjectMapperTest extends TestDataSetup { @InjectMocks private GeneralTopologyObjectMapper genObjMapper = new GeneralTopologyObjectMapper(); @@ -222,4 +227,55 @@ public class GeneralTopologyObjectMapperTest extends TestDataSetup{ assertEquals(vnf.getVnfId(),gcRequestInput.getVnfId()); assertNotNull(gcRequestInput.getVnfId()); } + + @Test + public void buildNetworkInformationTest() { + + L3Network network = new L3Network(); + ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork(); + modelInfoNetwork.setModelInvariantUUID("my-uuid"); + modelInfoNetwork.setModelName("my-model-name"); + modelInfoNetwork.setModelVersion("my-model-version"); + modelInfoNetwork.setModelUUID("my-model-uuid"); + modelInfoNetwork.setModelCustomizationUUID("my-customization-uuid"); + network.setModelInfoNetwork(modelInfoNetwork); + network.setNetworkId("my-network-id"); + network.setNetworkType("my-network-type"); + network.setNetworkTechnology("my-network-technology"); + + GenericResourceApiNetworkinformationNetworkInformation networkInformation = new GenericResourceApiNetworkinformationNetworkInformation(); + GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation(); + networkInformation.setNetworkId("my-network-id"); + networkInformation.setNetworkType("my-network-type"); + networkInformation.networkTechnology("my-network-technology"); + networkInformation.setFromPreload(null); + onapModelInformation.setModelInvariantUuid("my-uuid"); + onapModelInformation.setModelName("my-model-name"); + onapModelInformation.setModelVersion("my-model-version"); + onapModelInformation.setModelUuid("my-model-uuid"); + onapModelInformation.setModelCustomizationUuid("my-customization-uuid"); + networkInformation.setOnapModelInformation(onapModelInformation); + + assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network))); + + } + + @Test + public void buildNetworkInformationNoModelTest() { + + L3Network network = new L3Network(); + network.setNetworkId("my-network-id"); + network.setNetworkType("my-network-type"); + network.setNetworkTechnology("my-network-technology"); + + GenericResourceApiNetworkinformationNetworkInformation networkInformation = new GenericResourceApiNetworkinformationNetworkInformation(); + networkInformation.setNetworkId("my-network-id"); + networkInformation.setNetworkType("my-network-type"); + networkInformation.networkTechnology("my-network-technology"); + networkInformation.setFromPreload(null); + + + assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network))); + + } } diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/createNetworkRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/createNetworkRequest.json index 087f8a3971..a9cef565df 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/createNetworkRequest.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/createNetworkRequest.json @@ -5,7 +5,7 @@ "networkName": "APP-C-24595-T-IST-04AShared_data_vDB_net_1", "networkType": "CONTRAIL30_BASIC", "modelCustomizationUuid": "8edf06ef-fd40-42cf-a054-0fc09108d3f0", - "networkTechnology": "NEUTRON", + "networkTechnology": "CONTRAIL", "subnets": [ { "subnetName": "APP-C-24595-T-IST-04AShared_data_vDB_net_1_subnet_1", @@ -35,7 +35,7 @@ "requestId": "6cfde724-76c7-4747-bcb3-67a59a46ca95", "serviceInstanceId": "testServiceInstanceId1" }, - "contrailRequest": false, + "contrailRequest": true, "skipAAI": true, "messageId": "175264dc-fb6b-4aae-ba42-8c77a63fec12", "synchronous": true diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/grApiVmNetworkSubSectionWith5GParams.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/grApiVmNetworkSubSectionWith5GParams.json new file mode 100644 index 0000000000..e83f487a64 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/grApiVmNetworkSubSectionWith5GParams.json @@ -0,0 +1,73 @@ +{ + "network-role": "vmNetworkRole0", + "segmentation-id" : "my-segemntation-id", + "floating-ips": { + "floating-ip-v4": [ + "floatingIpV40", + "floatingIpV41" + ], + "floating-ip-v6": [ + "floatingIpV60", + "floatingIpV61" + ] + }, + "interface-route-prefixes": { + "interface-route-prefix": [ + "interfaceRoutePrefix0", + "interfaceRoutePrefix1" + ] + }, + "sriov-parameters": { + "heat-vlan-filters": { + "heat-vlan-filter": [ + "heatVlanFilter0", + "heatVlanFilter1" + ] + } + }, + "network-information-items": { + "network-information-item": [ + { + "network-ips": { + "network-ip": [ + "ip0", + "ip1" + ] + }, + "ip-version": "ipv4" + }, + { + "network-ips": { + "network-ip": [ + "ip2", + "ip3" + ] + }, + "ip-version": "ipv6" + } + ] + }, + "related-networks" : { + "related-network" : [{ + "vlan-tags" : { + "is-private" : "True", + "upper-tag-id" : "1" + } + },{ + "vlan-tags" : { + "is-private" : "False", + "upper-tag-id" : "2" + } + },{ + "vlan-tags" : { + "is-private" : "True", + "upper-tag-id" : "3" + } + },{ + "vlan-tags" : { + "is-private" : "False", + "upper-tag-id" : "3" + } + }] + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestTrueBackout.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestTrueBackout.json new file mode 100644 index 0000000000..bd06f5f86f --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterCreateVfModuleRequestTrueBackout.json @@ -0,0 +1,68 @@ +{ + "cloudSiteId": "cloudRegionId", + "tenantId": "tenantId", + "vnfId": "vnfId", + "vnfType": "vnfType", + "vfModuleId": "vfModuleId", + "vfModuleName": "vfModuleName", + "vfModuleType": "vfModuleModelName", + "vnfVersion": "serviceModelVersion", + "modelCustomizationUuid": "vfModuleModelCustomizationUuid", + "skipAAI": true, + "backout": true, + "failIfExists": true, + "msoRequest": + { + "requestId": "requestId", + "serviceInstanceId": "serviceInstanceId" + }, + + "vfModuleParams": + { + "vnf_id": "vnfId", + "vnf_name": "vnfName", + "vf_module_id": "vfModuleId", + "vf_module_index": "1", + "vf_module_name": "vfModuleName", + "environment_context": "environmentContext", + "fw_0_subint_ctrl_port_0_ip": "ip0,ip1", + "fw_0_subint_ctrl_port_0_ip_0": "ip0", + "fw_0_subint_ctrl_port_0_ip_1": "ip1", + "fw_0_subint_ctrl_port_0_net_ids": "networkId0", + "fw_0_subint_ctrl_port_0_net_names": "1", + "fw_subint_ctrl_port_0_subintcount": "1", + "fw_0_subint_ctrl_port_0_v6_ip": "ip0,ip1", + "fw_0_subint_ctrl_port_0_v6_ip_0": "ip0", + "fw_0_subint_ctrl_port_0_v6_ip_1": "ip1", + "fw_0_subint_ctrl_port_0_vlan_ids": "1", + "fw_subint_ctrl_port_0_floating_ip": "floatingIpV40", + "fw_subint_ctrl_port_0_floating_v6_ip": "floatingIpV60", + "workload_context": "workloadContext", + "key1": "value2", + "key3": "value3", + "availability_zone_0": "zone0", + "availability_zone_1": "zone1", + "availability_zone_2": "zone2", + "vnfNetworkRole0_net_fqdn": "netFqdnValue0", + "vnfNetworkRole0_net_id": "neutronId0", + "vnfNetworkRole0_net_name": "netName0", + "vnfNetworkRole0_subnet_id": "subnetId0", + "vnfNetworkRole0_v6_subnet_id": "subnetId1", + "vmType0_name_0": "vmName0", + "vmType0_name_1": "vmName1", + "vmType0_names": "vmName0,vmName1", + "vmType0_vmNetworkRole0_floating_ip": "floatingIpV40", + "vmType0_vmNetworkRole0_floating_v6_ip": "floatingIpV60", + "vmType0_vmNetworkRole0_route_prefixes": "[{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix0\"},{\"interface_route_table_routes_route_prefix\": \"interfaceRoutePrefix1\"}]", + "vmNetworkRole0_ATT_VF_VLAN_FILTER": "heatVlanFilter0,heatVlanFilter1", + "vmType0_vmNetworkRole0_ip_0": "ip0", + "vmType0_vmNetworkRole0_ip_1": "ip1", + "vmType0_vmNetworkRole0_ips": "ip0,ip1", + "vmType0_vmNetworkRole0_v6_ip_0": "ip2", + "vmType0_vmNetworkRole0_v6_ip_1": "ip3", + "vmType0_vmNetworkRole0_v6_ips": "ip2,ip3", + "paramOne": "paramOneValue", + "paramTwo": "paramTwoValue", + "paramThree": "paramThreeValue" + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml index 4562ebdaea..6f67a9ccc4 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml +++ b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml @@ -114,30 +114,6 @@ mso: version: '9' generic-vnf: version: '9' - v8: - customer: - uri: /aai/v8/business/customers/customer - generic-query: - uri: /aai/v8/search/generic-query - l3-network: - uri: /aai/v8/network/l3-networks/l3-network - network-policy: - uri: /aai/v8/network/network-policies/network-policy - nodes-query: - uri: /aai/v8/search/nodes-query - route-table-reference: - uri: /aai/v8/network/route-table-references/route-table-reference - tenant: - uri: /aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant - vce: - uri: /aai/v8/network/vces/vce - vpn-binding: - uri: /aai/v8/network/vpn-bindings/vpn-binding - v9: - cloud-region: - uri: /aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic - generic-vnf: - uri: /aai/v9/network/generic-vnfs/generic-vnf global: default: aai: @@ -220,4 +196,4 @@ camunda: bpm: metrics: enabled: false - db-reporter-activate: false
\ No newline at end of file + db-reporter-activate: false diff --git a/common/pom.xml b/common/pom.xml index d8e71b0e44..799d8a4d34 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -62,7 +62,7 @@ <dependency> <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-schema</artifactId> - <version>1.3.0</version> + <version>1.3.1</version> </dependency> <dependency> <groupId>org.modelmapper</groupId> diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java index 553c1e0db0..4f3816ad90 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java @@ -20,22 +20,31 @@ package org.onap.so.client.aai; +import org.onap.aai.domain.yang.NetworkTechnologies; import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals; +import org.onap.so.constants.Defaults; import com.google.common.base.CaseFormat; public enum AAIObjectPlurals implements GraphInventoryObjectPlurals { + CUSTOMER(AAINamespaceConstants.BUSINESS, "/customers"), GENERIC_VNF(AAINamespaceConstants.NETWORK, "/generic-vnfs"), PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers"), P_INTERFACE(AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces"), L3_NETWORK(AAINamespaceConstants.NETWORK, "/l3-networks"), + NETWORK_POLICY(AAINamespaceConstants.NETWORK, "/network-policies"), + VPN_BINDING(AAINamespaceConstants.NETWORK, "/vpn-bindings"), SERVICE_SUBSCRIPTION(AAIObjectType.CUSTOMER.uriTemplate(), "/service-subscriptions"), SERVICE_INSTANCE(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), "/service-instances"), - OWNING_ENTITIES(AAINamespaceConstants.BUSINESS, "/owning-entities"), - VOLUME_GROUP(AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups/"), - AVAILIBILITY_ZONE(AAIObjectType.CLOUD_REGION.uriTemplate(), "/availability-zones/"); - + OWNING_ENTITY(AAINamespaceConstants.BUSINESS, "/owning-entities"), + VOLUME_GROUP(AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups"), + AVAILIBILITY_ZONE(AAIObjectType.CLOUD_REGION.uriTemplate(), "/availability-zones"), + VF_MODULE(AAIObjectType.GENERIC_VNF.uriTemplate(), "/vf-modules"), + CONFIGURATION(AAINamespaceConstants.NETWORK, "/configurations"), + DEFAULT_TENANT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants"), + NETWORK_TECHNOLOGY(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/network-technologies"), + LOGICAL_LINK(AAINamespaceConstants.NETWORK, "/logical-links"); private final String uriTemplate; private final String partialUri; diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java index 4b646f9ed7..0e50818f0f 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java @@ -7,9 +7,9 @@ * 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. @@ -29,13 +29,16 @@ import org.onap.aai.domain.yang.CloudRegion; import org.onap.aai.domain.yang.Collection; import org.onap.aai.domain.yang.Complex; import org.onap.aai.domain.yang.Configuration; +import org.onap.aai.domain.yang.Connector; import org.onap.aai.domain.yang.Customer; +import org.onap.aai.domain.yang.ExtAaiNetwork; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.InstanceGroup; import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.LineOfBusiness; import org.onap.aai.domain.yang.ModelVer; import org.onap.aai.domain.yang.NetworkPolicy; +import org.onap.aai.domain.yang.NetworkTechnology; import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.aai.domain.yang.OwningEntity; import org.onap.aai.domain.yang.PInterface; @@ -46,6 +49,7 @@ import org.onap.aai.domain.yang.Pserver; import org.onap.aai.domain.yang.RouteTableReferences; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aai.domain.yang.ServiceSubscription; +import org.onap.aai.domain.yang.Subnet; import org.onap.aai.domain.yang.Tenant; import org.onap.aai.domain.yang.TunnelXconnect; import org.onap.aai.domain.yang.Vce; @@ -56,12 +60,13 @@ import org.onap.aai.domain.yang.VolumeGroup; import org.onap.aai.domain.yang.VpnBinding; import org.onap.aai.domain.yang.Vserver; import org.onap.so.client.graphinventory.GraphInventoryObjectType; +import org.onap.so.constants.Defaults; import com.google.common.base.CaseFormat; public enum AAIObjectType implements GraphInventoryObjectType { - DEFAULT_CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/cloud-regions/cloud-region/att-aic/{cloud-region-id}"), + DEFAULT_CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/{cloud-region-id}"), CUSTOMER(AAINamespaceConstants.BUSINESS, Customer.class), GENERIC_QUERY("/search", "/generic-query"), BULK_PROCESS("/bulkprocess", ""), @@ -73,10 +78,9 @@ public enum AAIObjectType implements GraphInventoryObjectType { NODES_QUERY("/search", "/nodes-query"), CUSTOM_QUERY("/query", ""), ROUTE_TABLE_REFERENCE(AAINamespaceConstants.NETWORK, RouteTableReferences.class), - DEFAULT_TENANT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/att-aic/AAIAIC25", "/tenants/tenant/{tenant-id}"), + DEFAULT_TENANT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants/tenant/{tenant-id}"), VCE(AAINamespaceConstants.NETWORK, Vce.class), VPN_BINDING(AAINamespaceConstants.NETWORK, VpnBinding.class), - VPN_BINDINGS(AAINamespaceConstants.NETWORK, "/vpn-bindings"), CONFIGURATION(AAINamespaceConstants.NETWORK, Configuration.class), PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Pserver.class), SERVICE_SUBSCRIPTION(AAIObjectType.CUSTOMER.uriTemplate(), ServiceSubscription.class), @@ -101,6 +105,10 @@ public enum AAIObjectType implements GraphInventoryObjectType { VNFC(AAINamespaceConstants.NETWORK, Vnfc.class), VLAN_TAG(AAINamespaceConstants.NETWORK, VlanTag.class), COMPLEX(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Complex.class), + CONNECTOR(AAINamespaceConstants.BUSINESS, Connector.class), + NETWORK_TECHNOLOGY(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, NetworkTechnology.class), + SUBNET(AAIObjectType.L3_NETWORK.uriTemplate(), Subnet.class), + EXT_AAI_NETWORK(AAINamespaceConstants.NETWORK, ExtAaiNetwork.class), UNKNOWN("", ""); private final String uriTemplate; @@ -114,7 +122,7 @@ public enum AAIObjectType implements GraphInventoryObjectType { this.uriTemplate = parentUri + partialUri; this.aaiObjectClass = null; } - + private AAIObjectType(String parentUri, Class<?> aaiObjectClass) { this.parentUri = parentUri; this.partialUri = removeParentUri(aaiObjectClass, parentUri); @@ -126,14 +134,14 @@ public enum AAIObjectType implements GraphInventoryObjectType { public String toString() { return this.uriTemplate(); } - + public static AAIObjectType fromTypeName(String name) { if (map.isEmpty()) { for (AAIObjectType type : AAIObjectType.values()) { map.put(type.typeName(), type); } } - + if (map.containsKey(name)) { return map.get(name); } else { @@ -163,7 +171,7 @@ public enum AAIObjectType implements GraphInventoryObjectType { public String partialUri() { return this.partialUri; } - + protected String removeParentUri(Class<?> aaiObjectClass, String parentUri) { return aaiObjectClass.getAnnotation(Metadata.class).uriTemplate().replace(parentUri, ""); } diff --git a/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java b/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java index 7e4397ec29..e91dc43af9 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java @@ -245,18 +245,22 @@ public class AAIResourcesClient extends AAIClient { String json; try { json = this.createClient(uri).get(String.class) - .orElseThrow(() -> createException(c, uri.build() + " not found in A&AI")); + .orElseThrow(() -> createException(c, uri.build() + " not found in A&AI", Optional.empty())); } catch (NotFoundException e) { - throw createException(c, "could not construct uri for use with A&AI"); + throw createException(c, "could not construct uri for use with A&AI", Optional.of(e)); } return new AAIResultWrapper(json); } - private RuntimeException createException(Class<? extends RuntimeException> c, String message) { + private RuntimeException createException(Class<? extends RuntimeException> c, String message, Optional<Throwable> t) { RuntimeException e; try { - e = c.getConstructor(String.class).newInstance(message); + if (t.isPresent()) { + e = c.getConstructor(String.class, Throwable.class).newInstance(message, t.get()); + } else { + e = c.getConstructor(String.class).newInstance(message); + } } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e1) { throw new IllegalArgumentException("could not create instance for " + c.getName()); diff --git a/common/src/main/java/org/onap/so/constants/Defaults.java b/common/src/main/java/org/onap/so/constants/Defaults.java new file mode 100644 index 0000000000..06c6fae467 --- /dev/null +++ b/common/src/main/java/org/onap/so/constants/Defaults.java @@ -0,0 +1,38 @@ +/*- + * ============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.constants; + +public enum Defaults { + + CLOUD_OWNER("att-aic"); + + + private final String value; + + private Defaults(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } +} diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java index cc2ccb5c2e..9624dcd578 100644 --- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java +++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java @@ -32,8 +32,10 @@ public class MDCTaskDecorator implements TaskDecorator { Map<String, String> contextMap = MDC.getCopyOfContextMap(); return () -> { try { - MDC.setContextMap(contextMap); - runnable.run(); + if(contextMap!=null){ + MDC.setContextMap(contextMap); + runnable.run(); + } } finally { MDC.clear(); } diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/CloudConfiguration.java b/common/src/main/java/org/onap/so/serviceinstancebeans/CloudConfiguration.java index a58949e498..67d852eff8 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/CloudConfiguration.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/CloudConfiguration.java @@ -22,13 +22,16 @@ package org.onap.so.serviceinstancebeans; import java.io.Serializable; +import org.onap.so.constants.Defaults; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.ToStringBuilder; @JsonRootName(value = "cloudConfiguration") -@JsonInclude(Include.NON_DEFAULT) +@JsonInclude(Include.NON_EMPTY) public class CloudConfiguration implements Serializable { private static final long serialVersionUID = 6260165690180745471L; @@ -36,6 +39,8 @@ public class CloudConfiguration implements Serializable { protected String aicNodeClli; @JsonProperty("tenantId") protected String tenantId; + @JsonProperty("cloudOwner") + protected String cloudOwner = Defaults.CLOUD_OWNER.toString(); @JsonProperty("lcpCloudRegionId") protected String lcpCloudRegionId; @@ -96,11 +101,19 @@ public class CloudConfiguration implements Serializable { this.lcpCloudRegionId = lcpCloudRegionId; } - @Override - public String toString() { - return "CloudConfiguration [aicNodeClli=" + aicNodeClli + ", tenantId=" - + tenantId + ", lcpCloudRegionId=" + lcpCloudRegionId + "]"; + public String getCloudOwner() { + return cloudOwner; } + public void setCloudOwner(String cloudOwner) { + this.cloudOwner = cloudOwner; + } + @Override + public String toString() { + return new ToStringBuilder(this).append("aicNodeClli", getAicNodeClli()).append("tenantId", getTenantId()) + .append("cloudOwner", getCloudOwner()).append("lcpCloudRegionId", getLcpCloudRegionId()).toString(); + } + + } diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java index e89c5c7e6a..87cb481dec 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java @@ -120,7 +120,7 @@ public class RequestParameters implements Serializable { public String getUserParamValue(String name){ if(userParams!=null){ for(Map<String, Object> param:userParams){ - if(param.get("name").equals(name)){ + if(param.containsKey("name") && param.get("name").equals(name) && param.containsKey("value")){ return param.get("value").toString(); } } diff --git a/common/src/test/java/org/onap/so/serviceinstancebeans/ServiceInstanceBeansTest.java b/common/src/test/java/org/onap/so/serviceinstancebeans/ServiceInstanceBeansTest.java index 7a4af7808e..5af84fdb86 100644 --- a/common/src/test/java/org/onap/so/serviceinstancebeans/ServiceInstanceBeansTest.java +++ b/common/src/test/java/org/onap/so/serviceinstancebeans/ServiceInstanceBeansTest.java @@ -20,10 +20,16 @@ package org.onap.so.serviceinstancebeans; +import static org.junit.Assert.assertEquals; + +import java.io.IOException; + import org.junit.Test; import org.onap.so.openpojo.rules.HasToStringRule; import org.onap.so.openpojo.rules.ToStringTester; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.openpojo.reflection.PojoClass; import com.openpojo.reflection.PojoClassFilter; import com.openpojo.reflection.filters.FilterEnum; @@ -43,6 +49,17 @@ public class ServiceInstanceBeansTest { public void pojoStructure() { test("org.onap.so.serviceinstancebeans"); } + + @Test + public void cloudConfigurationkeepDefaultValues() throws IOException { + CloudConfiguration cloudConfiguration = new CloudConfiguration(); + cloudConfiguration.setLcpCloudRegionId("myRegionId"); + ObjectMapper mapper = new ObjectMapper(); + + assertEquals("{\"cloudOwner\":\"att-aic\",\"lcpCloudRegionId\":\"myRegionId\"}", mapper.writeValueAsString(cloudConfiguration)); + + + } private void test(String pojoPackage) { Validator validator = ValidatorBuilder.create() diff --git a/logger/logback-spring.xml b/logger/logback-spring.xml new file mode 100644 index 0000000000..dbba5da9b0 --- /dev/null +++ b/logger/logback-spring.xml @@ -0,0 +1,188 @@ +<!-- ============LICENSE_START======================================================= + ECOMP MSO ================================================================================ + Copyright (C) 2017 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========================================================= --> + +<configuration scan="true" debug="false"> + <contextListener class="org.onap.so.logger.LoggerStartupListener" /> + <include resource="org/springframework/boot/logging/logback/base.xml" /> + + <property name="queueSize" value="256" /> + <property name="maxFileSize" value="200MB" /> + <property name="maxHistory" value="30" /> + <property name="totalSizeCap" value="10GB" /> + + <!-- log file names --> + <property name="errorLogName" value="error" /> + <property name="metricsLogName" value="metrics" /> + <property name="auditLogName" value="audit" /> + <property name="debugLogName" value="debug" /> + <property name="saneLogName" value="sane" /> + + <property name="errorPattern" + value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%.-5level|%X{ErrorCode}|%X{ErrorDesc}|%msg%n" /> + + <property name="debugPattern" + value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%msg%n" /> + + <property name="auditPattern" + value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{Timer}|%X{ServerFQDN}|%X{RemoteHost}||||||||%msg%n" /> + + <property name="metricPattern" + value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{Timer}|%X{ServerFQDN}|%X{RemoteHost}||||%X{TargetVirtualEntity}|||||%msg%n" /> + + <property name="defaultPattern" + value="%nopexception%logger + \t%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC} + \t%level + \t%replace(%replace(%message){'\t','\\\\t'}){'\n','\\\\n'} + \t%replace(%replace(%mdc){'\t','\\\\t'}){'\n','\\\\n'} + \t%replace(%replace(%rootException){'\t','\\\\t'}){'\n','\\\\n'} + \t%replace(%replace(%marker){'\t','\\\\t'}){'\n','\\\\n'} + \t%thread + \t%n" /> + + <appender name="SANE" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logs_dir:-.}/${saneLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${logs_dir:-.}/${saneLogName}.%d{yyyy-MM-dd}.%i.log.zip + </fileNamePattern> + + + <maxFileSize>${maxFileSize}</maxFileSize> + <maxHistory>${maxHistory}</maxHistory> + <totalSizeCap>${totalSizeCap}</totalSizeCap> + </rollingPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + <appender name="Audit" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logs_dir:-.}/${auditLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${logs_dir:-.}/${auditLogName}.%d{yyyy-MM-dd}.%i.log.zip + </fileNamePattern> + <maxFileSize>${maxFileSize}</maxFileSize> + <maxHistory>${maxHistory}</maxHistory> + <totalSizeCap>${totalSizeCap}</totalSizeCap> + </rollingPolicy> + <encoder> + <pattern>${auditPattern}</pattern> + </encoder> + </appender> + + <appender name="asyncAudit" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="Audit" /> + </appender> + + <appender name="Metric" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logs_dir:-.}/${metricsLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${logs_dir:-.}/${metricsLogName}.%d{yyyy-MM-dd}.%i.log.zip + </fileNamePattern> + <maxFileSize>${maxFileSize}</maxFileSize> + <maxHistory>${maxHistory}</maxHistory> + <totalSizeCap>${totalSizeCap}</totalSizeCap> + </rollingPolicy> + <encoder> + <pattern>${metricPattern}</pattern> + </encoder> + </appender> + + + <appender name="asyncMetric" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="Metric" /> + </appender> + + <appender name="Error" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <filter class="ch.qos.logback.classic.filter.LevelFilter"> + <level>ERROR</level> + <onMatch>ACCEPT</onMatch> + <onMismatch>DENY</onMismatch> + </filter> + <file>${logs_dir:-.}/${errorLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${logs_dir:-.}/${errorLogName}.%d{yyyy-MM-dd}.%i.log.zip + </fileNamePattern> + <maxFileSize>${maxFileSize}</maxFileSize> + <maxHistory>${maxHistory}</maxHistory> + <totalSizeCap>${totalSizeCap}</totalSizeCap> + </rollingPolicy> + <encoder> + <pattern>${errorPattern}</pattern> + </encoder> + </appender> + + <appender name="asyncError" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="Error" /> + </appender> + + <appender name="Debug" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logs_dir:-.}/${debugLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${logs_dir:-.}/${debugLogName}.%d{yyyy-MM-dd}.%i.log.zip + </fileNamePattern> + <maxFileSize>${maxFileSize}</maxFileSize> + <maxHistory>${maxHistory}</maxHistory> + <totalSizeCap>${totalSizeCap}</totalSizeCap> + </rollingPolicy> + <encoder> + <pattern>${debugPattern}</pattern> + </encoder> + </appender> + + <appender name="asyncDebug" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="Debug" /> + <includeCallerData>true</includeCallerData> + </appender> + + <!-- Spring related loggers --> + <logger name="org.springframework" level="WARN" /> + + <!-- Camunda related loggers --> + <logger name="org.camunda.bpm.engine.jobexecutor.level" level="WARN" /> + <logger + name="org.camunda.bpm.engine.impl.persistence.entity.JobEntity.level" + level="WARN" /> + + <logger name="org.apache.wire" level="DEBUG" /> + <logger name="org.onap" level="DEBUG" /> + <logger name="com.att.ecomp" level="DEBUG" /> + <logger name="org.apache.cxf.interceptor" level="DEBUG" /> + + <logger name="AUDIT" level="INFO" additivity="false"> + <appender-ref ref="asyncAudit" /> + </logger> + + <logger name="METRIC" level="INFO" additivity="false"> + <appender-ref ref="asyncMetric" /> + </logger> + + <root level="WARN"> + <appender-ref ref="asyncDebug" /> + <appender-ref ref="SANE" /> + <appender-ref ref="asyncError" /> + </root> + +</configuration>
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RequestDbFailureException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RequestDbFailureException.java new file mode 100644 index 0000000000..154ae36d41 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RequestDbFailureException.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.apihandlerinfra.exceptions; + +public class RequestDbFailureException extends ApiException { + + private static final String requestDbFailMessage = "Unable to %s due to error contacting requestDb: %s"; + + private RequestDbFailureException(Builder builder) { + super(builder); + } + + public static class Builder extends ApiException.Builder<Builder>{ + + + public Builder(String action, String error, int httpResponseCode, String messageID) { + super(requestDbFailMessage.format(requestDbFailMessage, action, error),httpResponseCode,messageID); + } + + public RequestDbFailureException build() { + return new RequestDbFailureException(this); + } + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index bb7df4b7be..8047893bb4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -45,6 +45,7 @@ import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException; import org.onap.so.apihandlerinfra.exceptions.ClientConnectionException; import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException; import org.onap.so.apihandlerinfra.exceptions.RecipeNotFoundException; +import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.exceptions.VfModuleNotFoundException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; @@ -109,7 +110,8 @@ public class ServiceInstances { private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH,MsoRequest.class); private static String NAME = "name"; private static String VALUE = "value"; - + private static final String SAVE_TO_DB = "save instance to db"; + @Autowired private Environment env; @@ -736,11 +738,16 @@ public class ServiceInstances { if(sir.getNetworkInstanceId () != null){ networkId = sir.getNetworkInstanceId (); } - - if (sir.getCorrelationId() != null) { - correlationId = sir.getCorrelationId(); - } - infraActiveRequestsClient.save(currentActiveReq); + + correlationId = getCorrelationId(sir); + + try{ + infraActiveRequestsClient.save(currentActiveReq); + }catch(Exception e){ + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) + .errorInfo(errorLoggerInfo).build(); + } if(!requestScope.equalsIgnoreCase(ModelType.service.name())){ aLaCarte = true; @@ -753,6 +760,14 @@ public class ServiceInstances { serviceInstanceType,vnfType, vfModuleType,networkType, apiVersion, aLaCarte, requestUri, null, requestScope, sir); } + private String getCorrelationId(ServiceInstancesRequest sir) { + return Optional.of(sir) + .map(ServiceInstancesRequest::getRequestDetails) + .map(RequestDetails::getRequestParameters) + .map(parameters -> parameters.getUserParamValue("pnfId")) + .orElse(""); + } + private String deriveRequestScope(Actions action, ServiceInstancesRequest sir, String requestUri) { if(action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig){ return (ModelType.vnf.name()); @@ -870,7 +885,13 @@ public class ServiceInstances { currentActiveReq.setRequestStatus(Status.IN_PROGRESS.name()); setInstanceId(currentActiveReq, requestScope, jsonResponse.getRequestReferences().getInstanceId(), new HashMap<>()); - infraActiveRequestsClient.save(currentActiveReq); + try{ + infraActiveRequestsClient.save(currentActiveReq); + }catch(Exception e){ + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) + .errorInfo(errorLoggerInfo).build(); + } return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestId, jsonResponse, apiVersion); } } @@ -983,14 +1004,10 @@ public class ServiceInstances { } } catch (Exception e) { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - - - ValidateException validateException = new ValidateException.Builder("Duplicate Check Request", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) + RequestDbFailureException requestDbFailureException = new RequestDbFailureException.Builder("check for duplicate instance", e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) .errorInfo(errorLoggerInfo).build(); - - updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); - - throw validateException; + updateStatus(currentActiveReq, Status.FAILED, requestDbFailureException.getMessage()); + throw requestDbFailureException; } return dup; } @@ -1016,7 +1033,7 @@ public class ServiceInstances { } private void parseRequest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, String version, - String requestJSON, Boolean aLaCarte, String requestId, InfraActiveRequests currentActiveReq) throws ValidateException { + String requestJSON, Boolean aLaCarte, String requestId, InfraActiveRequests currentActiveReq) throws ValidateException, RequestDbFailureException { int reqVersion = Integer.parseInt(version.substring(1)); try { msoRequest.parse(sir, instanceIdMap, action, version, requestJSON, reqVersion, aLaCarte); @@ -1218,6 +1235,7 @@ public class ServiceInstances { targetConfiguration.setAicNodeClli(sourceCloudConfiguration.getAicNodeClli()); targetConfiguration.setTenantId(sourceCloudConfiguration.getTenantId()); targetConfiguration.setLcpCloudRegionId(sourceCloudConfiguration.getLcpCloudRegionId()); + targetConfiguration.setCloudOwner(sourceCloudConfiguration.getCloudOwner()); return Optional.of(targetConfiguration); } return Optional.empty(); @@ -1630,10 +1648,16 @@ public class ServiceInstances { if(sir.getConfigurationId() != null){ configurationId = sir.getConfigurationId(); } - if (sir.getCorrelationId() != null) { - correlationId = sir.getCorrelationId(); + + correlationId = getCorrelationId(sir); + + try{ + infraActiveRequestsClient.save(currentActiveReq); + }catch(Exception e){ + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) + .errorInfo(errorLoggerInfo).build(); } - infraActiveRequestsClient.save(currentActiveReq); if(!requestScope.equalsIgnoreCase(ModelType.service.name())){ aLaCarte = true; @@ -1660,14 +1684,20 @@ public class ServiceInstances { throw validateException; } } - public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage){ + public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage) throws RequestDbFailureException{ if ((status == Status.FAILED) || (status == Status.COMPLETE)) { aq.setStatusMessage (errorMessage); aq.setProgress(new Long(100)); aq.setRequestStatus(status.toString()); Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis()); aq.setEndTime (endTimeStamp); - infraActiveRequestsClient.save(aq); + try{ + infraActiveRequestsClient.save(aq); + }catch(Exception e){ + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) + .errorInfo(errorLoggerInfo).build(); + } } } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java index 464d5e6bba..dfcf9ffc46 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java @@ -2302,4 +2302,94 @@ public class ServiceInstancesTest extends BaseTest{ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText()); } -}
\ No newline at end of file + @Test + public void createServiceInstanceDuplicateError() throws IOException{ + stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR))); + + uri = servInstanceuri + "v5/serviceInstances"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); + RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + assertEquals("Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText()); + } + @Test + public void createServiceInstanceSaveError() throws IOException{ + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB"); + serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + serviceRecipe.setAction(Action.createInstance.toString()); + serviceRecipe.setId(1); + serviceRecipe.setRecipeTimeout(180); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + stubFor(post(urlMatching(".*/infraActiveRequests/")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR))); + stubFor(get(urlMatching(".*/service/.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/serviceRecipe/search.*")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); + + uri = servInstanceuri + "v5/serviceInstances"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); + RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText()); + } + @Test + public void createPortConfigurationSaveError() throws IOException { + stubFor(post(urlMatching(".*/infraActiveRequests/")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR))); + stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + HttpHeaders headers = new HttpHeaders(); + + uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); + RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText()); + } + @Test + public void createPortConfigDbUpdateError() throws IOException { + stubFor(post(urlMatching(".*/infraActiveRequests/")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR))); + + uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); + RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText()); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java index 07d185b3af..b809691b31 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java @@ -59,6 +59,7 @@ import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.stereotype.Component; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; + import uk.co.blackpepper.bowman.ClientFactory; import uk.co.blackpepper.bowman.Configuration; diff --git 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 index 9742a0c85b..4f070e71c9 100644 --- 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 @@ -20,6 +20,14 @@ package org.onap.so.db.catalog.client; +import java.net.URI; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import javax.annotation.PostConstruct; +import javax.ws.rs.core.UriBuilder; + import org.onap.so.db.catalog.beans.BuildingBlockDetail; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.CloudifyManager; @@ -27,6 +35,7 @@ import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; 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.InstanceGroup; import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.NetworkRecipe; @@ -55,17 +64,11 @@ import org.springframework.http.client.BufferingClientHttpRequestFactory; import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.stereotype.Component; + import uk.co.blackpepper.bowman.Client; import uk.co.blackpepper.bowman.ClientFactory; import uk.co.blackpepper.bowman.Configuration; -import javax.annotation.PostConstruct; -import javax.ws.rs.core.UriBuilder; -import java.net.URI; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - @Component("CatalogDbClient") public class CatalogDbClient { @@ -84,6 +87,7 @@ public class CatalogDbClient { private static final String NETWORK_COLLECTION_RESOURCE_CUSTOMIZATION = "/networkCollectionResourceCustomization"; private static final String VNF_RESOURCE_CUSTOMIZATION = "/vnfResourceCustomization"; private static final String SERVICE = "/service"; + private static final String EXTERNAL_SERVICE_TO_INTERNAL_MODEL_MAPPING = "/externalServiceToInternalService"; private static final String VNF_RESOURCE = "/vnfResource"; private static final String VNF_RECIPE = "/vnfRecipe"; private static final String VFMODULE = "/vfModule"; @@ -96,6 +100,8 @@ public class CatalogDbClient { private static final String URI_SEPARATOR = "/"; private static final String SERVICE_MODEL_UUID = "serviceModelUUID"; + private static final String SERVICE_NAME = "serviceName"; + private static final String MODEL_UUID = "modelUUID"; private static final String MODEL_CUSTOMIZATION_UUID = "modelCustomizationUUID"; private static final String ACTION = "action"; private static final String MODEL_NAME = "modelName"; @@ -122,6 +128,10 @@ public class CatalogDbClient { private static final String TARGET_ENTITY = "SO:CatalogDB"; + private String findExternalToInternalServiceByServiceName = "/findByServiceName"; + private String findServiceByModelName = "/findOneByModelName"; + private String findServiceRecipeByActionAndServiceModelUUID = "/findByActionAndServiceModelUUID"; + private String findServiceByModelUUID = "/findOneByModelUUID"; private String findFirstByModelNameURI = "/findFirstByModelNameOrderByModelVersionDesc"; private String findFirstByServiceModelUUIDAndActionURI = "/findFirstByServiceModelUUIDAndAction"; private String findFirstByModelVersionAndModelInvariantUUIDURI = "/findFirstByModelVersionAndModelInvariantUUID"; @@ -196,6 +206,8 @@ public class CatalogDbClient { private final Client<ServiceRecipe> serviceRecipeClient; + private final Client<ExternalServiceToInternalService> externalServiceToInternalServiceClient; + private final Client<CloudSite> cloudSiteClient; private final Client<CloudifyManager> cloudifyManagerClient; @@ -213,6 +225,10 @@ public class CatalogDbClient { @PostConstruct public void init(){ + findExternalToInternalServiceByServiceName = endpoint + EXTERNAL_SERVICE_TO_INTERNAL_MODEL_MAPPING + SEARCH + findExternalToInternalServiceByServiceName; + findServiceByModelName = endpoint + SERVICE + SEARCH + findServiceByModelName; + findServiceRecipeByActionAndServiceModelUUID = endpoint + SERVICE_RECIPE + SEARCH + findServiceRecipeByActionAndServiceModelUUID; + findServiceByModelUUID = endpoint + SERVICE + SEARCH + findServiceByModelUUID; findFirstByModelNameURI = endpoint + SERVICE + SEARCH + findFirstByModelNameURI; findFirstByModelVersionAndModelInvariantUUIDURI = endpoint + SERVICE + SEARCH + findFirstByModelVersionAndModelInvariantUUIDURI; findByModelInvariantUUIDURI = endpoint + SERVICE + SEARCH + findByModelInvariantUUIDURI; @@ -288,6 +304,7 @@ public class CatalogDbClient { serviceRecipeClient = clientFactory.create(ServiceRecipe.class); cvnfcCustomizationClient = clientFactory.create(CvnfcCustomization.class); controllerSelectionReferenceClient = clientFactory.create(ControllerSelectionReference.class); + externalServiceToInternalServiceClient = clientFactory.create(ExternalServiceToInternalService.class); } public CatalogDbClient(String baseUri, String auth) { @@ -329,6 +346,7 @@ public class CatalogDbClient { serviceRecipeClient = clientFactory.create(ServiceRecipe.class); cvnfcCustomizationClient = clientFactory.create(CvnfcCustomization.class); controllerSelectionReferenceClient = clientFactory.create(ControllerSelectionReference.class); + externalServiceToInternalServiceClient = clientFactory.create(ExternalServiceToInternalService.class); } public NetworkCollectionResourceCustomization getNetworkCollectionResourceCustomizationByID(String modelCustomizationUUID) { @@ -495,6 +513,30 @@ public class CatalogDbClient { .queryParam(MODEL_NAME,modelName).build()); } + public ExternalServiceToInternalService findExternalToInternalServiceByServiceName(String serviceName){ + return this.getSingleResource(externalServiceToInternalServiceClient, getUri(UriBuilder + .fromUri(findExternalToInternalServiceByServiceName) + .queryParam(SERVICE_NAME,serviceName).build().toString())); + } + + public ServiceRecipe findServiceRecipeByActionAndServiceModelUUID(String action,String modelUUID){ + return this.getSingleResource(serviceRecipeClient, getUri(UriBuilder + .fromUri(findServiceRecipeByActionAndServiceModelUUID) + .queryParam(ACTION,action) + .queryParam(SERVICE_MODEL_UUID,modelUUID).build().toString())); + } + + public Service getServiceByModelName(String modelName){ + return this.getSingleResource(serviceClient,getUri(UriBuilder + .fromUri(findServiceByModelName) + .queryParam(MODEL_NAME,modelName).build().toString())); + } + + public Service getServiceByModelUUID(String modelModelUUID){ + return this.getSingleResource(serviceClient,getUri(UriBuilder + .fromUri(findServiceByModelUUID) + .queryParam(MODEL_UUID,modelModelUUID).build().toString())); + } public VnfResource getFirstVnfResourceByModelInvariantUUIDAndModelVersion(String modelInvariantUUID, String modelVersion){ return this.getSingleResource(vnfResourceClient, getUri(UriBuilder |