diff options
69 files changed, 7081 insertions, 244 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 ca0180ae4b..b26b49ec70 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 @@ -81,7 +81,9 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); private static final Integer DEFAULT_MSB_PORT = 80; private static final String DEFAULT_MSB_IP = "127.0.0.1"; + private static final String DEFAULT_MSB_SCHEME = "http"; private static final String ONAP_IP = "ONAP_IP"; + private static final String MSB_SCHEME = "MSB_SCHEME"; private final HttpClientFactory httpClientFactory = new HttpClientFactory(); @Autowired @@ -795,10 +797,14 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { msbIp = environment.getProperty("mso.msb-ip", DEFAULT_MSB_IP); } Integer msbPort = environment.getProperty("mso.msb-port", Integer.class, DEFAULT_MSB_PORT); + String msbScheme = System.getenv().get(MSB_SCHEME); + if (null == msbScheme || msbScheme.isEmpty()) { + msbScheme = environment.getProperty("mso.msb-scheme", DEFAULT_MSB_SCHEME); + } String path = "/api/multicloud/v1/" + cloudOwner + "/" + cloudSiteId + "/infra_workload"; - String endpoint = UriBuilder.fromPath(path).host(msbIp).port(msbPort).scheme("http").build().toString(); + String endpoint = UriBuilder.fromPath(path).host(msbIp).port(msbPort).scheme(msbScheme).build().toString(); if (workloadId != null) { String middlepart = null; if (isName) { diff --git a/adapters/mso-adapter-utils/src/test/resources/application-test.yaml b/adapters/mso-adapter-utils/src/test/resources/application-test.yaml index 32a4db6b80..117d616cd4 100644 --- a/adapters/mso-adapter-utils/src/test/resources/application-test.yaml +++ b/adapters/mso-adapter-utils/src/test/resources/application-test.yaml @@ -53,6 +53,7 @@ mso: logPath: logs msb-ip: localhost msb-port: ${wiremock.server.port} + msb-scheme: http catalog: db: spring: diff --git a/adapters/mso-nssmf-adapter/pom.xml b/adapters/mso-nssmf-adapter/pom.xml index b6b52ce7c5..3e9c2fe6d7 100644 --- a/adapters/mso-nssmf-adapter/pom.xml +++ b/adapters/mso-nssmf-adapter/pom.xml @@ -28,6 +28,7 @@ <artifactId>adapters</artifactId> <version>1.6.0-SNAPSHOT</version> </parent> + <groupId>org.onap.so.adapters</groupId> <artifactId>mso-nssmf-adapter</artifactId> <packaging>jar</packaging> <name>mso-nssmf-adapter</name> diff --git a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml index 20fd812ab9..6171e7a624 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml +++ b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml @@ -66,6 +66,7 @@ mso: logPath: logs msb-ip: localhost msb-port: ${wiremock.server.port} + msb-scheme: http catalog: db: spring: 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 d0f86c722e..d59984bb52 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 @@ -6,12 +6,14 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ + * Modifications Copyright (c) 2020 Nokia + * ================================================================================ * 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. @@ -52,21 +54,25 @@ public final class ASDCStatusCallBack implements IStatusCallback { try { - if (iStatus.getStatus() != null) { - if (iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_OK) - || iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_ERROR)) { - WatchdogDistributionStatus watchdogDistributionStatus = watchdogDistributionStatusRepository - .findById(iStatus.getDistributionID()).orElseGet(() -> null); - if (watchdogDistributionStatus == null) { - watchdogDistributionStatus = new WatchdogDistributionStatus(); - watchdogDistributionStatus.setDistributionId(iStatus.getDistributionID()); - watchdogDistributionStatusRepository.save(watchdogDistributionStatus); - } - logger.debug(event); - toscaInstaller.installTheComponentStatus(iStatus); - - } + if (iStatus.getStatus() == null) { + logger.info("Missing status on Status Object. "); + return; + } + if (!iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_OK) + && !iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_ERROR)) { + logger.info("Status is not 'Component Done OK' or 'Component Done Error'"); + return; } + WatchdogDistributionStatus watchdogDistributionStatus = + watchdogDistributionStatusRepository.findById(iStatus.getDistributionID()).orElseGet(() -> null); + if (watchdogDistributionStatus == null) { + watchdogDistributionStatus = new WatchdogDistributionStatus(); + watchdogDistributionStatus.setDistributionId(iStatus.getDistributionID()); + watchdogDistributionStatusRepository.save(watchdogDistributionStatus); + } + logger.debug(event); + toscaInstaller.installTheComponentStatus(iStatus); + } catch (ArtifactInstallerException e) { logger.error("Error in ASDCStatusCallback {}", e.getMessage(), e); logger.debug("Error in ASDCStatusCallback {}", e.getMessage()); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/FinalDistributionStatusMessage.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/FinalDistributionStatusMessage.java index 13cace404e..0a1b1c531e 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/FinalDistributionStatusMessage.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/FinalDistributionStatusMessage.java @@ -4,12 +4,14 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2020 Nokia + * ================================================================================ * 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 +39,6 @@ public class FinalDistributionStatusMessage implements IFinalDistrStatusMessage public FinalDistributionStatusMessage(String distributionId, final DistributionStatusEnum distributionStatusEnum, final long timestampL, String consumerId) { - // componentName = componentname; consumerID = consumerId; distributionID = distributionId; status = distributionStatusEnum; @@ -68,6 +69,7 @@ public class FinalDistributionStatusMessage implements IFinalDistrStatusMessage this.timestamp = timestamp; } + @Override public String getComponentName() { return componentName; } @@ -76,6 +78,7 @@ public class FinalDistributionStatusMessage implements IFinalDistrStatusMessage this.componentName = componentName; } + @Override public String getConsumerID() { return consumerID; } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java index 7bd9c752a4..34f21ab813 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java @@ -4,12 +4,14 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2020 Nokia + * ================================================================================ * 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. @@ -50,43 +52,37 @@ public class JsonStatusData implements IStatusData { @Override public String getDistributionID() { - // return (String)this.attributesMap.get("distributionID"); return "35120a87-1f82-4276-9735-f6de5a244d65"; } @Override public String getConsumerID() { - // return (String)this.attributesMap.get("consumerID"); return "mso.123456"; } @Override public String getComponentName() { - // return (String)this.attributesMap.get("componentName"); return "SDN-C"; } @Override public Long getTimestamp() { - // return (String)this.attributesMap.get("timestamp"); return null; } @Override public String getArtifactURL() { - // return (String)this.attributesMap.get("artifactURL"); return "/sdc/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml"; } @Override public DistributionStatusEnum getStatus() { - // return (DistributionStatusEnum)this.attributesMap.get(DistributionStatusEnum.DEPLOY_OK); return DistributionStatusEnum.COMPONENT_DONE_OK; } /** * Method instantiate a INotificationData implementation from a JSON file. - * + * * @param notifFilePath The file path in String * @return A JsonNotificationData instance * @throws IOException in case of the file is not readable or not accessible @@ -96,19 +92,6 @@ public class JsonStatusData implements IStatusData { InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream(notifFilePath + "status-structure.json"); - // String fileLocation = System.getProperty("mso.config.path") + "notif-structure.json"; - - // String source = fileLocation; - // InputStream is = IOUtils.toInputStream(source, "UTF-8"); - - // String myString = IOUtils.toString(is, "UTF-8"); - - - // System.out.println(myString); - - if (is == null) { - // throw new FileExistsException("Resource Path does not exist: "+notifFilePath); - } return mapper.readValue(is, JsonStatusData.class); } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleStructure.java index 36d6ab96c0..11c1cc33cf 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleStructure.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2020 Nokia + * ================================================================================ * 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 @@ -25,8 +27,6 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import org.onap.sdc.api.notification.IVfModuleMetadata; -import org.onap.so.asdc.client.ASDCConfiguration; import org.onap.so.asdc.client.exceptions.ArtifactInstallerException; import org.onap.so.db.catalog.beans.VfModule; @@ -73,23 +73,6 @@ public final class VfModuleStructure { } } - public List<VfModuleArtifact> getOrderedArtifactList() { - - List<VfModuleArtifact> artifactsList = new LinkedList<>(); - - artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT)); - artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_ENV)); - artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL)); - - artifactsList.addAll((artifactsMap.get(ASDCConfiguration.HEAT_NESTED))); - - artifactsList.addAll((artifactsMap.get(ASDCConfiguration.HEAT_ARTIFACT))); - - artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL)); - - return null; - } - public IVfModuleData getVfModuleMetadata() { return vfModuleMetadata; } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java index f954fe0c5a..f5b0e17cf5 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java @@ -7,6 +7,8 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ + * Modifications Copyright (c) 2020 Nokia + * ================================================================================ * 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 @@ -77,39 +79,38 @@ public class VfResourceStructure extends ResourceStructure { private Service catalogService; - public VfResourceStructure(INotificationData notificationdata, IResourceInstance resourceinstance) { - super(notificationdata, resourceinstance); + public VfResourceStructure(INotificationData notificationData, IResourceInstance resourceInstance) { + super(notificationData, resourceInstance); this.resourceType = ResourceType.VF_RESOURCE; vfModulesStructureList = new LinkedList<>(); vfModulesMetadataList = new ArrayList<>(); } - public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo, + public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactInfo, IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException { - this.addArtifactToStructure(distributionClient, artifactinfo, clientResult, null); + this.addArtifactToStructure(artifactInfo, clientResult, null); } - public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo, - IDistributionClientDownloadResult clientResult, String modifiedHeatTemplate) - throws UnsupportedEncodingException { - VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactinfo, clientResult, modifiedHeatTemplate); - addArtifactByType(artifactinfo, clientResult, vfModuleArtifact); - if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifactinfo.getArtifactType())) { + public void addArtifactToStructure(IArtifactInfo artifactInfo, IDistributionClientDownloadResult clientResult, + String modifiedHeatTemplate) throws UnsupportedEncodingException { + VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactInfo, clientResult, modifiedHeatTemplate); + addArtifactByType(artifactInfo, clientResult, vfModuleArtifact); + if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifactInfo.getArtifactType())) { logger.debug("VF_MODULE_ARTIFACT: " + new String(clientResult.getArtifactPayload(), "UTF-8")); logger.debug(ASDCNotificationLogging.dumpVfModuleMetaDataList(vfModulesMetadataList)); } } - public void addWorkflowArtifactToStructure(IArtifactInfo artifactinfo, + public void addWorkflowArtifactToStructure(IArtifactInfo artifactInfo, IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException { - WorkflowArtifact workflowArtifact = new WorkflowArtifact(artifactinfo, clientResult); - workflowArtifactsMapByUUID.put(artifactinfo.getArtifactUUID(), workflowArtifact); + WorkflowArtifact workflowArtifact = new WorkflowArtifact(artifactInfo, clientResult); + workflowArtifactsMapByUUID.put(artifactInfo.getArtifactUUID(), workflowArtifact); } - protected void addArtifactByType(IArtifactInfo artifactinfo, IDistributionClientDownloadResult clientResult, + protected void addArtifactByType(IArtifactInfo artifactInfo, IDistributionClientDownloadResult clientResult, VfModuleArtifact vfModuleArtifact) { - switch (artifactinfo.getArtifactType()) { + switch (artifactInfo.getArtifactType()) { case ASDCConfiguration.HEAT: case ASDCConfiguration.HEAT_ENV: case ASDCConfiguration.HEAT_VOL: @@ -118,7 +119,7 @@ public class VfResourceStructure extends ResourceStructure { case ASDCConfiguration.HEAT_NET: case ASDCConfiguration.OTHER: case ASDCConfiguration.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT: - artifactsMapByUUID.put(artifactinfo.getArtifactUUID(), vfModuleArtifact); + artifactsMapByUUID.put(artifactInfo.getArtifactUUID(), vfModuleArtifact); break; case ASDCConfiguration.VF_MODULES_METADATA: vfModulesMetadataList = this.decodeVfModuleArtifact(clientResult.getArtifactPayload()); @@ -196,9 +197,7 @@ public class VfResourceStructure extends ResourceStructure { public List<IVfModuleData> decodeVfModuleArtifact(byte[] arg0) { try { - List<IVfModuleData> listVFModuleMetaData = - new ObjectMapper().readValue(arg0, new TypeReference<List<VfModuleMetaData>>() {}); - return listVFModuleMetaData; + return new ObjectMapper().readValue(arg0, new TypeReference<List<VfModuleMetaData>>() {}); } catch (JsonParseException e) { logger.debug("JsonParseException : ", e); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java index 195aa7e302..db75c31b08 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java @@ -6,6 +6,8 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ + * Modifications Copyright (c) 2020 Nokia + * ================================================================================ * 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 @@ -27,6 +29,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.net.URI; +import java.net.URISyntaxException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Enumeration; @@ -107,18 +110,15 @@ public class BpmnInstaller { logger.error(LoggingAnchor.FIVE, MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), csarFilePath, ex.getMessage(), ErrorCode.DataError.getValue(), "ASDC reading CSAR with workflows failed"); } - return; } public boolean containsWorkflows(String csarFilePath) { - boolean workflowsInCsar = false; try (ZipFile zipFile = new ZipFile(csarFilePath)) { Enumeration<? extends ZipEntry> zipEntries = zipFile.entries(); while (zipEntries.hasMoreElements()) { String fileName = zipEntries.nextElement().getName(); if (fileName.endsWith(BPMN_SUFFIX)) { - workflowsInCsar = true; - break; + return true; } } } catch (Exception e) { @@ -126,10 +126,11 @@ public class BpmnInstaller { logger.error(LoggingAnchor.FIVE, MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), csarFilePath, e.getMessage(), ErrorCode.DataError.getValue(), "ASDC Unable to check CSAR entries"); } - return workflowsInCsar; + return false; } - protected HttpResponse sendDeploymentRequest(String bpmnFileName, String version) throws Exception { + protected HttpResponse sendDeploymentRequest(String bpmnFileName, String version) + throws IOException, URISyntaxException { HttpClient client = HttpClientBuilder.create().build(); URI deploymentUri = new URI(this.env.getProperty(CAMUNDA_URL) + CREATE_DEPLOYMENT_PATH); HttpPost post = new HttpPost(deploymentUri); @@ -141,7 +142,7 @@ public class BpmnInstaller { return client.execute(post); } - protected HttpEntity buildMimeMultipart(String bpmnFileName, String version) throws Exception { + protected HttpEntity buildMimeMultipart(String bpmnFileName, String version) throws IOException { FileInputStream bpmnFileStream = new FileInputStream( Paths.get(getMsoConfigPath(), "ASDC", version, bpmnFileName).normalize().toString()); @@ -182,17 +183,14 @@ public class BpmnInstaller { return requestEntity; } - /* protected void extractBpmnFileFromCsar(ZipInputStream zipIn, String fileName) throws IOException */ protected void extractBpmnFileFromCsar(ZipInputStream zipIn, String fileName) { String filePath = Paths.get(System.getProperty("mso.config.path"), "ASDC", fileName).normalize().toString(); - /* BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath)); */ try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath))) { byte[] bytesIn = new byte[4096]; - int read = 0; + int read; while ((read = zipIn.read(bytesIn)) != -1) { outputStream.write(bytesIn, 0, read); } - /* outputStream.close(); */ } catch (IOException e) { logger.error("Unable to open file.", e); } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index 3175839725..1c7ebb7d9a 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -1297,6 +1297,9 @@ public class ToscaResourceInstaller { heatTemplate.setParameters(heatParam); vfModuleArtifact.setHeatTemplate(heatTemplate); } else { + if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) { + existingHeatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout()); + } vfModuleArtifact.setHeatTemplate(existingHeatTemplate); } } 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 976ad1466d..e83e7e2ea2 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.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.HttpClientFactory import org.onap.so.client.aai.AAIResourcesClient import org.springframework.web.util.UriUtils import org.slf4j.Logger @@ -677,4 +678,8 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess public AAIResourcesClient getAAIClient(){ return new AAIResourcesClient(); } + + HttpClientFactory getHttpClientFactory(){ + return new HttpClientFactory() + } } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy index ce474fa713..b35042e3c0 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy @@ -49,8 +49,8 @@ class RequestDBUtil { String operationType = operationStatus.getOperation() String result = operationStatus.getResult() String progress = operationStatus.getProgress() - String operationContent = operationStatus.getOperationContent() - String reason = operationStatus.getReason() + String operationContent = operationStatus.getOperationContent()?: "" + String reason = operationStatus.getReason()?: "" String payload = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java index eb2567d47c..9b46611468 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java @@ -31,12 +31,14 @@ public class SDNCLcmPropertiesImpl implements SDNCLcmProperties { public static final String SDNC_HOST = "sdnc.host"; public static final String SDNC_AUTH = "sdnc.auth"; public static final String LCM_PATH = "sdnc.lcm.path"; + public static final String LCM_ACTION_TIMEOUT = "sdnc.lcm.actionTimeout"; public static final String DMAAP_HOST = "sdnc.dmaap.host"; public static final String DMAAP_AUTH = "sdnc.dmaap.auth"; - public static final String DMAAP_PARTITION = "sdnc.dmaap.partition"; public static final String DMAAP_TIMEOUT = "sdnc.dmaap.timeout"; public static final String DMAAP_ENVIRONMENT = "sdnc.dmaap.environment"; + + public static final String LCM_DMAAP_PARTITION = "sdnc.lcm.dmaap.partition"; public static final String LCM_DMAAP_READ_TOPIC = "sdnc.lcm.dmapp.readTopic"; public static final String LCM_DMAAP_WRITE_TOPIC = "sdnc.lcm.dmaap.writeTopic"; @@ -56,6 +58,12 @@ public class SDNCLcmPropertiesImpl implements SDNCLcmProperties { } @Override + public long getActionTimeout() { + String actionTimeout = UrnPropertiesReader.getVariable(LCM_ACTION_TIMEOUT); + return (actionTimeout != null) ? Long.parseLong(actionTimeout) : SDNCConstants.LCM_ACTION_TIMEOUT; + } + + @Override public String getBasicAuth() { return UrnPropertiesReader.getVariable(SDNC_AUTH); } @@ -72,7 +80,7 @@ public class SDNCLcmPropertiesImpl implements SDNCLcmProperties { @Override public String getDmaapPartition() { - String partition = UrnPropertiesReader.getVariable(DMAAP_PARTITION); + String partition = UrnPropertiesReader.getVariable(LCM_DMAAP_PARTITION); return (partition != null) ? partition : SDNCConstants.LCM_DMAAP_PARTITION; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java index fd9412e70e..dcbb120c69 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java @@ -45,5 +45,6 @@ public interface SDNCConstants { String LCM_DMAAP_READ_TOPIC = "SDNC-LCM-WRITE"; String LCM_DMAAP_WRITE_TOPIC = "SDNC-LCM-READ"; - int LCM_TIMEOUT = 300; + long LCM_ACTION_TIMEOUT = 300000; // Millisecond + int LCM_OUTPUT_SUCCESS_CODE = 400; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmActionConstants.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmActionConstants.java new file mode 100644 index 0000000000..8ab40cb08d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmActionConstants.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm; + +public interface SDNCLcmActionConstants { + String ACTIVATE_N_E_SW = "ActivateNESw"; + String DOWNLOAD_N_E_SW = "DownloadNESw"; + String UPGRADE_POST_CHECK = "UpgradePostCheck"; + String UPGRADE_PRE_CHECK = "UpgradePreCheck"; +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java index 5616db3577..0f17c547b5 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java @@ -39,6 +39,10 @@ public class SDNCLcmClientBuilder { sdncLcmProperties = pros; } + public SDNCLcmProperties getSDNCLcmProperties() { + return sdncLcmProperties; + } + public SDNCLcmRestClient newSDNCLcmRestClient(String operation) throws SDNCLcmClientBuilderException { URI pathUri; try { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java index df5fb3be0b..a21196e08f 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java @@ -27,6 +27,8 @@ public interface SDNCLcmProperties extends RestProperties { String getPath(); + long getActionTimeout(); + String getBasicAuth(); String getDmaapHost(); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayload.java new file mode 100644 index 0000000000..d86d114a9f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayload.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "swVersionToBeActivated"}) +public class ActivateNESwPayload { + + @JsonProperty(value = "ipaddress-v4-oam", required = true) + private String ipaddressV4Oam; + + @JsonProperty(value = "playbook-name") + private String playbookName; + + @JsonProperty(value = "swVersionToBeActivated", required = true) + private String swVersionToBeActivated; + + public String getIpaddressV4Oam() { + return ipaddressV4Oam; + } + + public void setIpaddressV4Oam(String value) { + this.ipaddressV4Oam = value; + } + + public String getPlaybookName() { + return playbookName; + } + + public void setPlaybookName(String value) { + this.playbookName = value; + } + + public String getSwVersionToBeActivated() { + return swVersionToBeActivated; + } + + public void setSwVersionToBeActivated(String value) { + this.swVersionToBeActivated = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayload.java new file mode 100644 index 0000000000..5dc5cf503d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayload.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "swToBeDownloaded"}) +public class DownloadNESwPayload { + + @JsonProperty(value = "ipaddress-v4-oam", required = true) + private String ipaddressV4Oam; + + @JsonProperty(value = "playbook-name") + private String playbookName; + + @JsonProperty(value = "swToBeDownloaded", required = true) + private List<SwToBeDownloadedElement> swToBeDownloaded = new ArrayList<>(); + + public String getIpaddressV4Oam() { + return ipaddressV4Oam; + } + + public void setIpaddressV4Oam(String value) { + this.ipaddressV4Oam = value; + } + + public String getPlaybookName() { + return playbookName; + } + + public void setPlaybookName(String value) { + this.playbookName = value; + } + + public List<SwToBeDownloadedElement> getSwToBeDownloaded() { + return swToBeDownloaded; + } + + public void setSwToBeDownloaded(List<SwToBeDownloadedElement> value) { + this.swToBeDownloaded = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java new file mode 100644 index 0000000000..1a3529d7c4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"swLocation", "swFileSize", "swFileCompression", "swFileFormat"}) +public class SwToBeDownloadedElement { + + @JsonProperty(value = "swLocation", required = true) + private String swLocation; + + @JsonProperty(value = "swFileSize") + private long swFileSize; + + @JsonProperty(value = "swFileCompression") + private String swFileCompression; + + @JsonProperty(value = "swFileFormat") + private String swFileFormat; + + public String getSwLocation() { + return swLocation; + } + + public void setSwLocation(String value) { + this.swLocation = value; + } + + public long getSwFileSize() { + return swFileSize; + } + + public void setSwFileSize(long value) { + this.swFileSize = value; + } + + public String getSwFileCompression() { + return swFileCompression; + } + + public void setSwFileCompression(String value) { + this.swFileCompression = value; + } + + public String getSwFileFormat() { + return swFileFormat; + } + + public void setSwFileFormat(String value) { + this.swFileFormat = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayload.java new file mode 100644 index 0000000000..76937d262c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayload.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "oldSwVersion", "targetSwVersion", "ruleName", "additionalData"}) +public class UpgradePostCheckPayload { + + @JsonProperty(value = "ipaddress-v4-oam", required = true) + private String ipaddressV4Oam; + + @JsonProperty(value = "playbook-name") + private String playbookName; + + @JsonProperty(value = "oldSwVersion", required = true) + private String oldSwVersion; + + @JsonProperty(value = "targetSwVersion", required = true) + private String targetSwVersion; + + @JsonProperty(value = "ruleName", required = true) + private String ruleName; + + @JsonProperty(value = "additionalData") + private String additionalData; + + public String getIpaddressV4Oam() { + return ipaddressV4Oam; + } + + public void setIpaddressV4Oam(String value) { + this.ipaddressV4Oam = value; + } + + public String getPlaybookName() { + return playbookName; + } + + public void setPlaybookName(String value) { + this.playbookName = value; + } + + public String getOldSwVersion() { + return oldSwVersion; + } + + public void setOldSwVersion(String value) { + this.oldSwVersion = value; + } + + public String getTargetSwVersion() { + return targetSwVersion; + } + + public void setTargetSwVersion(String value) { + this.targetSwVersion = value; + } + + public String getRuleName() { + return ruleName; + } + + public void setRuleName(String value) { + this.ruleName = value; + } + + public String getAdditionalData() { + return additionalData; + } + + public void setAdditionalData(String value) { + this.additionalData = value; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayload.java new file mode 100644 index 0000000000..d1a95b8418 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayload.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "oldSwVersion", "targetSwVersion", "ruleName", "additionalData"}) +public class UpgradePreCheckPayload { + + @JsonProperty(value = "ipaddress-v4-oam", required = true) + private String ipaddressV4Oam; + + @JsonProperty(value = "playbook-name") + private String playbookName; + + @JsonProperty(value = "oldSwVersion", required = true) + private String oldSwVersion; + + @JsonProperty(value = "targetSwVersion", required = true) + private String targetSwVersion; + + @JsonProperty(value = "ruleName", required = true) + private String ruleName; + + @JsonProperty(value = "additionalData") + private String additionalData; + + public String getIpaddressV4Oam() { + return ipaddressV4Oam; + } + + public void setIpaddressV4Oam(String value) { + this.ipaddressV4Oam = value; + } + + public String getPlaybookName() { + return playbookName; + } + + public void setPlaybookName(String value) { + this.playbookName = value; + } + + public String getOldSwVersion() { + return oldSwVersion; + } + + public void setOldSwVersion(String value) { + this.oldSwVersion = value; + } + + public String getTargetSwVersion() { + return targetSwVersion; + } + + public void setTargetSwVersion(String value) { + this.targetSwVersion = value; + } + + public String getRuleName() { + return ruleName; + } + + public void setRuleName(String value) { + this.ruleName = value; + } + + public String getAdditionalData() { + return additionalData; + } + + public void setAdditionalData(String value) { + this.additionalData = value; + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtilTest.groovy new file mode 100644 index 0000000000..6b63bbe56c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtilTest.groovy @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.so.db.request.beans.OperationStatus + +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +class RequestDBUtilTest extends MsoGroovyTest { + + @Before + void init() throws IOException { + super.init("DoDeleteSliceServiceTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void prepareUpdateOperationStatus(){ + when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint")).thenReturn("http://sdc-wfd-be:8080") + OperationStatus operationStatus = new OperationStatus() + operationStatus.setServiceId("testServiceId") + operationStatus.setOperationId("testOperationId") + operationStatus.setUserId("testUserId") + operationStatus.setOperation("testOpertation") + operationStatus.setResult("testResult") + operationStatus.setProgress("testProgress") + operationStatus.setOperationContent("testOperationContent") + operationStatus.setReason("testReason") + + RequestDBUtil requestDBUtil = new RequestDBUtil() + requestDBUtil.prepareUpdateOperationStatus(mockExecution, operationStatus) + + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus = captor.getAllValues() + assertNotNull(updateOperationStatus) + } + + @Test + void testGetOperationStatus(){ + when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint")).thenReturn("http://sdc-wfd-be:8080") + + RequestDBUtil requestDBUtil = new RequestDBUtil() + requestDBUtil.getOperationStatus(mockExecution, "testServiceId","testOperationId") + + Mockito.verify(mockExecution,times(1)).setVariable(eq("getOperationStatus"), captor.capture()) + String getOperationStatus = captor.getAllValues() + assertNotNull(getOperationStatus) + + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java index 5483792a84..3757769769 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java @@ -42,7 +42,7 @@ public class SDNCLcmDmaapClientTest extends BaseTest { protected static final String DMAAP_HOST_PROP = SDNCLcmPropertiesImpl.DMAAP_HOST; protected static final String DMAAP_WRITE_TOPIC_PROP = SDNCLcmPropertiesImpl.LCM_DMAAP_WRITE_TOPIC; protected static final String DMAAP_READ_TOPIC_PROP = SDNCLcmPropertiesImpl.LCM_DMAAP_READ_TOPIC; - protected static final String DMAAP_PARTITION_PROP = SDNCLcmPropertiesImpl.DMAAP_PARTITION; + protected static final String DMAAP_PARTITION_PROP = SDNCLcmPropertiesImpl.LCM_DMAAP_PARTITION; protected String testWriteTopic = "TEST-WRITE-TOPIC"; protected String testReadTopic = "TEST-READ-TOPIC"; diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayloadTest.java new file mode 100644 index 0000000000..bee07f2022 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayloadTest.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class ActivateNESwPayloadTest extends LcmBasePayloadTest { + private static String expectedActivateNESwPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"test_playbook\"," + "\"swVersionToBeActivated\":\"v2\"" + "}"; + + public ActivateNESwPayload buildActivateNESwPayload() { + ActivateNESwPayload activateNESwPayload = new ActivateNESwPayload(); + + activateNESwPayload.setIpaddressV4Oam(ipaddressV4Oam); + activateNESwPayload.setPlaybookName(playbookName); + activateNESwPayload.setSwVersionToBeActivated("v2"); + + return activateNESwPayload; + } + + @Test + public final void testActivateNESwPayload() { + ActivateNESwPayload activateNESwPayload = buildActivateNESwPayload(); + + try { + String activateNESwPayloadString = convertToSting(activateNESwPayload); + assertEquals(expectedActivateNESwPayload, activateNESwPayloadString); + } catch (Exception e) { + fail("Convert ActivateNESwPayload to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java new file mode 100644 index 0000000000..f9fa679790 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import java.util.Collections; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class DownloadNESwPayloadTest extends LcmBasePayloadTest { + private static String expectedSwToBeDownloadedElement = "{" + "\"swLocation\":\"http://192.168.1.20/test.zip\"," + + "\"swFileSize\":123456," + "\"swFileCompression\":\"ZIP\"," + "\"swFileFormat\":\"binary\"" + "}"; + + private static String expectedDownloadNESwPayload = + "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + "\"playbook-name\":\"test_playbook\"," + + "\"swToBeDownloaded\":[" + expectedSwToBeDownloadedElement + "]" + "}"; + + public SwToBeDownloadedElement buildSwToBeDownloadedElement() { + SwToBeDownloadedElement swToBeDownloadedElement = new SwToBeDownloadedElement(); + + swToBeDownloadedElement.setSwLocation("http://192.168.1.20/test.zip"); + swToBeDownloadedElement.setSwFileSize(123456); + swToBeDownloadedElement.setSwFileCompression("ZIP"); + swToBeDownloadedElement.setSwFileFormat("binary"); + + return swToBeDownloadedElement; + } + + public DownloadNESwPayload buildDownloadNESwPayload() { + DownloadNESwPayload downloadNESwPayload = new DownloadNESwPayload(); + + downloadNESwPayload.setIpaddressV4Oam(ipaddressV4Oam); + downloadNESwPayload.setPlaybookName(playbookName); + + SwToBeDownloadedElement swToBeDownloadedElement = buildSwToBeDownloadedElement(); + downloadNESwPayload.setSwToBeDownloaded(Collections.singletonList(swToBeDownloadedElement)); + + return downloadNESwPayload; + } + + @Test + public final void testSwToBeDownloadedElement() { + SwToBeDownloadedElement swToBeDownloadedElement = buildSwToBeDownloadedElement(); + + try { + String swToBeDownloadedElementString = convertToSting(swToBeDownloadedElement); + assertEquals(expectedSwToBeDownloadedElement, swToBeDownloadedElementString); + } catch (Exception e) { + fail("Convert SwToBeDownloadedElement to String error: " + e.toString()); + } + } + + @Test + public final void testDownloadNESwPayload() { + DownloadNESwPayload downloadNESwPayload = buildDownloadNESwPayload(); + + try { + String downloadNESwPayloadString = convertToSting(downloadNESwPayload); + assertEquals(expectedDownloadNESwPayload, downloadNESwPayloadString); + } catch (Exception e) { + fail("Convert DownloadNESwPayload to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/LcmBasePayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/LcmBasePayloadTest.java new file mode 100644 index 0000000000..5452166d03 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/LcmBasePayloadTest.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class LcmBasePayloadTest { + private static Logger logger = LoggerFactory.getLogger(LcmBasePayloadTest.class); + + protected String ipaddressV4Oam = "192.168.1.10"; + protected String playbookName = "test_playbook"; + + public String convertToSting(Object msgObject) throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + + String msgString = mapper.writeValueAsString(msgObject); + logger.debug(msgObject.getClass().getSimpleName() + "\n" + msgString); + + return msgString; + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayloadTest.java new file mode 100644 index 0000000000..acd447e890 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayloadTest.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class UpgradePostCheckPayloadTest extends LcmBasePayloadTest { + private static String expectedUpgradePostCheckPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"test_playbook\"," + "\"oldSwVersion\":\"v1\"," + "\"targetSwVersion\":\"v2\"," + + "\"ruleName\":\"r102\"," + "\"additionalData\":\"{}\"" + "}"; + + public UpgradePostCheckPayload buildUpgradePostCheckPayload() { + UpgradePostCheckPayload upgradePostCheckPayload = new UpgradePostCheckPayload(); + + upgradePostCheckPayload.setIpaddressV4Oam(ipaddressV4Oam); + upgradePostCheckPayload.setPlaybookName(playbookName); + upgradePostCheckPayload.setOldSwVersion("v1"); + upgradePostCheckPayload.setTargetSwVersion("v2"); + upgradePostCheckPayload.setRuleName("r102"); + upgradePostCheckPayload.setAdditionalData("{}"); + + return upgradePostCheckPayload; + } + + @Test + public final void testUpgradePostCheckPayload() { + UpgradePostCheckPayload upgradePostCheckPayload = buildUpgradePostCheckPayload(); + + try { + String upgradePostCheckPayloadString = convertToSting(upgradePostCheckPayload); + assertEquals(expectedUpgradePostCheckPayload, upgradePostCheckPayloadString); + } catch (Exception e) { + fail("Convert UpgradePostCheckPayload to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayloadTest.java new file mode 100644 index 0000000000..8bc0714fff --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayloadTest.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.client.sdnc.lcm.beans.payload; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class UpgradePreCheckPayloadTest extends LcmBasePayloadTest { + private static String expectedUpgradePreCheckPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"test_playbook\"," + "\"oldSwVersion\":\"v1\"," + "\"targetSwVersion\":\"v2\"," + + "\"ruleName\":\"r101\"," + "\"additionalData\":\"{}\"" + "}"; + + public UpgradePreCheckPayload buildUpgradePreCheckPayload() { + UpgradePreCheckPayload upgradePreCheckPayload = new UpgradePreCheckPayload(); + + upgradePreCheckPayload.setIpaddressV4Oam(ipaddressV4Oam); + upgradePreCheckPayload.setPlaybookName(playbookName); + upgradePreCheckPayload.setOldSwVersion("v1"); + upgradePreCheckPayload.setTargetSwVersion("v2"); + upgradePreCheckPayload.setRuleName("r101"); + upgradePreCheckPayload.setAdditionalData("{}"); + + return upgradePreCheckPayload; + } + + @Test + public final void testUpgradePreCheckPayload() { + UpgradePreCheckPayload upgradePreCheckPayload = buildUpgradePreCheckPayload(); + + try { + String upgradePreCheckPayloadString = convertToSting(upgradePreCheckPayload); + assertEquals(expectedUpgradePreCheckPayload, upgradePreCheckPayloadString); + } catch (Exception e) { + fail("Convert UpgradePreCheckPayload to String error: " + e.toString()); + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/HandleOrchestrationTask.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/HandleOrchestrationTask.groovy new file mode 100644 index 0000000000..89490ff620 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/HandleOrchestrationTask.groovy @@ -0,0 +1,127 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 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.infrastructure.scripts + +import com.fasterxml.jackson.databind.ObjectMapper +import org.onap.so.db.request.beans.OrchestrationTask + +import static org.apache.commons.lang3.StringUtils.* +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +class HandleOrchestrationTask extends AbstractServiceTaskProcessor { + private static final Logger logger = LoggerFactory.getLogger(HandleOrchestrationTask.class) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + def supportedMethod = ["GET", "POST", "PUT"] + def validStatus = [200, 201] + + @Override + public void preProcessRequest(DelegateExecution execution) { + logger.debug("Start preProcessRequest") + String method = execution.getVariable("method") + if (!supportedMethod.contains(method)) { + String msg = "Method: " + method + " is not supported" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + String taskId = execution.getVariable("taskId") + if (isBlank(taskId)) { + String msg = "taskId is empty" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.requestDb.endpoint",execution) + def orchestrationTaskEndpoint = dbAdapterEndpoint + "/orchestrationTask/" + if (!"POST".equals(method)) { + orchestrationTaskEndpoint = orchestrationTaskEndpoint + taskId + } + execution.setVariable("url", orchestrationTaskEndpoint) + logger.debug("DB Adapter Endpoint is: " + orchestrationTaskEndpoint) + def dbAdapterAuth = UrnPropertiesReader.getVariable("mso.adapters.requestDb.auth") + Map<String, String> headerMap = [:] + headerMap.put("content-type", "application/json") + headerMap.put("Authorization", dbAdapterAuth) + execution.setVariable("headerMap", headerMap) + logger.debug("DB Adapter Header is: " + headerMap) + + String requestId = execution.getVariable("requestId") + if (("POST".equals(method) || "PUT".equals(method)) && isBlank(requestId)) { + String msg = "requestId is empty" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + String taskName = execution.getVariable("taskName") + if (("POST".equals(method) || "PUT".equals(method)) && isBlank(taskName)) { + String msg = "task name is empty" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + String taskStatus = execution.getVariable("taskStatus") + if (("POST".equals(method) || "PUT".equals(method)) && isBlank(taskStatus)) { + String msg = "task status is empty" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + String isManual = execution.getVariable("isManual") + if (("POST".equals(method) || "PUT".equals(method)) && isBlank(isManual)) { + String msg = "isManual is empty" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + String paramJson = execution.getVariable("paramJson") + + String payload = "" + if ("POST".equals(method) || "PUT".equals(method)) { + OrchestrationTask task = new OrchestrationTask() + task.setTaskId(taskId) + task.setRequestId(requestId) + task.setName(taskName) + task.setStatus(taskStatus) + task.setIsManual(isManual) + task.setParams(paramJson) + ObjectMapper objectMapper = new ObjectMapper() + payload = objectMapper.writeValueAsString(task) + logger.debug("Outgoing payload is \n" + payload) + } + execution.setVariable("payload", payload) + logger.debug("End preProcessRequest") + } + + public void postProcess(DelegateExecution execution) { + Integer statusCode = execution.getVariable("statusCode") + logger.debug("statusCode: " + statusCode) + String response = execution.getVariable("response") + logger.debug("response: " + response) + if (!validStatus.contains(statusCode)) { + String msg = "Error in sending orchestrationTask request. \nstatusCode: " + statusCode + "\nresponse: " + response + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } +} + diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy index 7cc1a559c3..c3f36ef545 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy @@ -273,7 +273,6 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { execution.setVariable("orchestrationTaskId", taskId) logger.debug("BusinessKey: " + taskId) String serviceInstanceId = execution.getVariable("serviceInstanceId") - String operationId = execution.getVariable("operationId") String serviceInstanceName = execution.getVariable("serviceInstanceName") String taskName = "SliceServiceTask" String taskStatus = "Planning" @@ -286,17 +285,11 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { execution.setVariable("CSSOT_requestMethod", requestMethod) Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") - Map<String, Object> sliceProfileTn = execution.getVariable("sliceProfileTn") - Map<String, Object> sliceProfileCn = execution.getVariable("sliceProfileCn") - Map<String, Object> sliceProfileAn = execution.getVariable("sliceProfileAn") SliceTaskParams sliceTaskParams = new SliceTaskParams() sliceTaskParams.setServiceId(serviceInstanceId) sliceTaskParams.setServiceName(serviceInstanceName) sliceTaskParams.setServiceProfile(serviceProfile) - sliceTaskParams.setSliceProfileTn(sliceProfileTn) - sliceTaskParams.setSliceProfileCn(sliceProfileCn) - sliceTaskParams.setSliceProfileAn(sliceProfileAn) execution.setVariable("sliceTaskParams", sliceTaskParams) String paramJson = sliceTaskParams.convertToJson() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy index 00b0b37b18..b121083954 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy @@ -141,7 +141,7 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { * save e2eslice-service instance id and service name * @param execution */ - private void queryCommunicationSeriveFromAAI(DelegateExecution execution) + void queryCommunicationSeriveFromAAI(DelegateExecution execution) { LOGGER.trace(" ***** begin queryCommunicationSeriveFromAAI *****") String serviceInstanceId = execution.getVariable("serviceInstanceId") @@ -186,12 +186,11 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { String globalSubscriberId = execution.getVariable("globalSubscriberId") String serviceType = execution.getVariable("serviceType") - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(aaiObjectType, globalSubscriberId, serviceType, instanceId) - if (!resourceClient.exists(resourceUri)) { + if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg) } - AAIResultWrapper wrapper = resourceClient.get(resourceUri, NotFoundException.class) + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) return wrapper } @@ -215,7 +214,7 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { requestBody.replaceAll("\\s+", "") String basicAuthValue = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution) - HttpClient httpClient = new HttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) + HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) httpClient.addAdditionalHeader("Authorization", basicAuthValue) httpClient.addAdditionalHeader("Accept", "application/json") Response httpResponse = httpClient.delete(requestBody) @@ -233,6 +232,41 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { } /** + * prepare update operation status + * @param execution + */ + private void handleNSSMFWFResponse(Response httpResponse, DelegateExecution execution){ + LOGGER.debug(" ======== STARTED prepareUpdateOperationStatus Process ======== ") + + int nsmfResponseCode = httpResponse.getStatus() + LOGGER.debug("nsmfResponseCode${nsmfResponseCode}") + + if (nsmfResponseCode >= 200 && nsmfResponseCode < 204 && httpResponse.hasEntity()) { + String nsmfResponse = httpResponse.readEntity(String.class) + def e2eOperationId = jsonUtil.getJsonValue(nsmfResponse, "operationId") + execution.setVariable("e2eOperationId", e2eOperationId) + execution.setVariable("progress","20") + execution.setVariable("operationContent","waiting nsmf service delete finished") + + execution.setVariable("currentCycle",0) + execution.setVariable("isNSMFTimeOut", "no") + execution.setVariable("isNSMFWFRspSucceed","yes") + } + else + { + String serviceName = execution.getVariable("serviceInstanceName") + execution.setVariable("progress", "100") + execution.setVariable("result", "error") + execution.setVariable("operationContent", "terminate service failure.") + execution.setVariable("reason","NSMF WF asynchronous response failed, status Code:${nsmfResponseCode}") + execution.setVariable("isNSMFWFRspSucceed","no") + LOGGER.error("nsmf async response error,nsmfResponseCode:${nsmfResponseCode},serivceName:${serviceName}") + } + setOperationStatus(execution) + LOGGER.debug("======== COMPLETED prepareUpdateOperationStatus Process ======== ") + } + + /** * prepare to call sub process * @param execution */ @@ -272,22 +306,20 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { String profileId try { - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_PROFILE_ALL, globalSubscriberId, serviceType, serviceInstanceId) - AAIResultWrapper wrapper = resourceClient.get(resourceUri, NotFoundException.class) + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) Optional<CommunicationServiceProfiles> csProfilesOpt = wrapper.asBean(CommunicationServiceProfiles.class) if(csProfilesOpt.isPresent()){ - CommunicationServiceProfiles csProf - iles = csProfilesOpt.get() + CommunicationServiceProfiles csProfiles = csProfilesOpt.get() CommunicationServiceProfile csProfile = csProfiles.getCommunicationServiceProfile().get(0) profileId = csProfile ? csProfile.getProfileId() : "" } resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_SERVICE_PROFILE, globalSubscriberId, serviceType, serviceInstanceId, profileId) - if (!resourceClient.exists(resourceUri)) { + if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "communication service profile was not found in aai") } - - resourceClient.delete(resourceUri) + + getAAIClient().delete(resourceUri) LOGGER.debug("end delete communication service profile from AAI") } catch (any) @@ -308,9 +340,8 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { try { LOGGER.debug("start delete communication service from AAI") - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), execution.getVariable("serviceInstanceId")) - resourceClient.delete(serviceInstanceUri) + getAAIClient().delete(serviceInstanceUri) execution.setVariable("progress", "100") execution.setVariable("result", "finished") @@ -330,12 +361,10 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { LOGGER.debug("Starting sendSyncError") try { - String errorMessage + String errorMessage = "Sending Sync Error." if (execution.getVariable("WorkflowException") instanceof WorkflowException) { WorkflowException wfe = execution.getVariable("WorkflowException") errorMessage = wfe.getErrorMessage() - } else { - errorMessage = "Sending Sync Error." } String buildworkflowException = @@ -397,6 +426,7 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { void prepareFailureStatus(DelegateExecution execution) { + execution.setVariable("result", "finished") execution.setVariable("progress", "100") execution.setVariable("operationContent", "terminate service failure.") setOperationStatus(execution) @@ -426,4 +456,5 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { execution.setVariable(paraName, paramValue) } } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy index f0d43cf8d7..d8160a97bc 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy @@ -45,19 +45,19 @@ import static org.apache.commons.lang3.StringUtils.isBlank class DeleteSliceService extends AbstractServiceTaskProcessor { - String Prefix="DELSS_" + private final String PREFIX ="DeleteSliceService" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() private RequestDBUtil requestDBUtil = new RequestDBUtil() - private static final Logger logger = LoggerFactory.getLogger( DeleteSliceService.class) + private static final Logger LOGGER = LoggerFactory.getLogger( DeleteSliceService.class) @Override void preProcessRequest(DelegateExecution execution) { - execution.setVariable("prefix", Prefix) + execution.setVariable("prefix", PREFIX) String msg = "" - logger.trace("Starting preProcessRequest") + LOGGER.debug("*****${PREFIX} preProcessRequest *****") try { // check for incoming json message/input @@ -71,7 +71,7 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { msg = "e2eslice-service id is null" exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) } - logger.info("Input Request: ${siRequest}, reqId: ${requestId}, e2eslice-service: ${serviceInstanceId}") + LOGGER.info("Input Request: ${siRequest}, reqId: ${requestId}, e2eslice-service: ${serviceInstanceId}") //subscriberInfo checkAndSetRequestParam(siRequest,"globalSubscriberId",false, execution) @@ -82,17 +82,17 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { execution.setVariable("progress", "0") execution.setVariable("result", "processing") execution.setVariable("operationType", "DELETE") - execution.setVariable("operationContent", "Prepare init service") + execution.setVariable("operationContent", "Delete Slice service operation start") updateServiceOperationStatus(execution) } catch (BpmnError e) { throw e } catch (Exception ex) { msg = "Exception in preProcessRequest " + ex.getMessage() - logger.debug(msg) + LOGGER.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - logger.trace("Exit preProcessRequest") + LOGGER.debug("*****${PREFIX} Exit preProcessRequest *****") } /** @@ -100,40 +100,39 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { * @param execution */ void sendAsyncResponse(DelegateExecution execution) { - logger.trace("Staring sendSyncResponse") + LOGGER.trace("${PREFIX} Start sendSyncResponse ") try { String operationId = execution.getVariable("operationId") String syncResponse = """{"operationId":"${operationId}"}""".trim() - logger.info("sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse) + LOGGER.info("sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse) sendWorkflowResponse(execution, 202, syncResponse) } catch (Exception ex) { String msg = "Exception in sendSyncResponse: " + ex.getMessage() exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - logger.trace("Exit sendSyncResponse") + LOGGER.trace("${PREFIX} Exit sendSyncResponse") } /** * Deletes the slice service instance in aai */ void deleteSliceServiceInstance(DelegateExecution execution) { - logger.trace("Entered deleteSliceServiceInstance") + LOGGER.trace("${PREFIX} Start deleteSliceServiceInstance") try { - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), execution.getVariable("serviceInstanceId")) - resourceClient.delete(serviceInstanceUri) + getAAIClient().delete(serviceInstanceUri) execution.setVariable("progress", "100") execution.setVariable("result", "finished") execution.setVariable("operationContent", "NSMF completes slicing service termination.") updateServiceOperationStatus(execution) - logger.trace("Exited deleteSliceServiceInstance") + LOGGER.trace("${PREFIX} Exited deleteSliceServiceInstance") }catch(Exception e){ - logger.debug("Error occured within deleteSliceServiceInstance method: " + e) + LOGGER.debug("Error occured within deleteSliceServiceInstance method: " + e) exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Error occured during deleteSliceServiceInstance from aai") } } @@ -161,7 +160,7 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { * delete service profile from aai * @param execution */ - private void delServiceProfileFromAAI(DelegateExecution execution) + void delServiceProfileFromAAI(DelegateExecution execution) { String globalSubscriberId = execution.getVariable("globalSubscriberId") String serviceType = execution.getVariable("serviceType") @@ -170,9 +169,8 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { try { - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE_ALL, globalSubscriberId, serviceType, serviceInstanceId) - AAIResultWrapper wrapper = resourceClient.get(resourceUri, NotFoundException.class) + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) Optional<ServiceProfiles> serviceProfilesOpt =wrapper.asBean(ServiceProfiles.class) if(serviceProfilesOpt.isPresent()){ ServiceProfiles serviceProfiles = serviceProfilesOpt.get() @@ -180,29 +178,27 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { profileId = serviceProfile ? serviceProfile.getProfileId() : "" } resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE, globalSubscriberId, serviceType, serviceInstanceId, profileId) - if (!resourceClient.exists(resourceUri)) { + if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } - resourceClient.delete(resourceUri) + getAAIClient().delete(resourceUri) } catch (any) { String msg = "delete service profile from aai failed! cause-"+any.getCause() - logger.error(any.printStackTrace()) + LOGGER.error(any.printStackTrace()) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); } } void sendSyncError(DelegateExecution execution) { - logger.info("Starting sendSyncError") + LOGGER.debug("${PREFIX} Start sendSyncError") try { - String errorMessage + String errorMessage = "Sending Sync Error." if (execution.getVariable("WorkflowException") instanceof WorkflowException) { WorkflowException wfe = execution.getVariable("WorkflowException") errorMessage = wfe.getErrorMessage() - } else { - errorMessage = "Sending Sync Error." } String buildworkflowException = @@ -211,17 +207,17 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { <aetgt:ErrorCode>7000</aetgt:ErrorCode> </aetgt:WorkflowException>""" - logger.debug(buildworkflowException) + LOGGER.debug(buildworkflowException) sendWorkflowResponse(execution, 500, buildworkflowException) } catch (Exception ex) { - logger.error("Sending Sync Error Activity Failed. " + "\n" + ex.getMessage()) + LOGGER.error("Sending Sync Error Activity Failed. " + "\n" + ex.getMessage()) } } void prepareEndOperationStatus(DelegateExecution execution){ - logger.debug(" ======== STARTED prepareEndOperationStatus Process ======== ") + LOGGER.debug(" ======== ${PREFIX} STARTED prepareEndOperationStatus Process ======== ") execution.setVariable("progress", "100") execution.setVariable("result", "error") @@ -233,7 +229,7 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { execution.setVariable("reason",errorMessage) updateServiceOperationStatus(execution) - logger.debug("======== COMPLETED prepareEndOperationStatus Process ======== ") + LOGGER.debug("======== ${PREFIX} COMPLETED prepareEndOperationStatus Process ======== ") } /** @@ -250,7 +246,7 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { String paramValue = jsonUtil.getJsonValue(siRequest, paraName) if (isBlank(paramValue)) { msg = "Input ${paraName} is null" - logger.error(msg) + LOGGER.error(msg) if(isErrorException) { exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy new file mode 100644 index 0000000000..d5b554d841 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy @@ -0,0 +1,338 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import com.google.common.reflect.TypeToken +import com.google.gson.Gson +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.AllottedResource +import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.RelationshipList +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.so.beans.nsmf.SliceTaskParams +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceProxy +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.AAIEdgeLabel +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.db.request.client.RequestsDbClient +import org.onap.so.db.request.beans.OrchestrationTask +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.UriBuilder + +import static org.apache.commons.lang3.StringUtils.isBlank + +class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor{ + + private static final Logger logger = LoggerFactory.getLogger( DoAllocateNSIandNSSI.class); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + JsonUtils jsonUtil = new JsonUtils() + RequestsDbClient requestsDbClient = new RequestsDbClient() + + /** + * Pre Process the BPMN Flow Request + * Inclouds: + * generate the nsOperationKey + * generate the nsParameters + */ + + void preProcessRequest (DelegateExecution execution) { + String msg = "" + logger.trace("Enter preProcessRequest()") + Map<String, Object> nssiMap = new HashMap<>() + execution.setVariable("nssiMap", nssiMap) + boolean isMoreNSSTtoProcess = true + execution.setVariable("isMoreNSSTtoProcess", isMoreNSSTtoProcess) + List<String> nsstSequence = new ArrayList<>(Arrays.asList("cn")) + execution.setVariable("nsstSequence", nsstSequence) + logger.trace("Exit preProcessRequest") + } + + void retriveSliceOption(DelegateExecution execution) { + logger.trace("Enter retriveSliceOption() of DoAllocateNSIandNSSI") + String uuiRequest = execution.getVariable("uuiRequest") + boolean isNSIOptionAvailable = false + List<String> nssiAssociated = new ArrayList<>() + SliceTaskParams sliceParams = execution.getVariable("sliceTaskParams") + try + { + String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.nstar0_allottedresource0_providing_service_uuid") + String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.nstar0_allottedresource0_providing_service_invariant_uuid") + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + //Params sliceParams = new Gson().fromJson(params, new TypeToken<Params>() {}.getType()); + execution.setVariable("sliceParams", sliceParams) + }catch (Exception ex) { + logger.debug( "Unable to get the task information from request DB: " + ex) + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Unable to get task information from request DB.") + } + + if(isBlank(sliceParams.getSuggestNsiId())) + { + isNSIOptionAvailable=false + } + else + { + isNSIOptionAvailable=true + execution.setVariable('nsiServiceInstanceId',sliceParams.getSuggestNsiId()) + execution.setVariable('nsiServiceInstanceName',sliceParams.getSuggestNsiName()) + } + execution.setVariable("isNSIOptionAvailable",isNSIOptionAvailable) + logger.trace("Exit retriveSliceOption() of DoAllocateNSIandNSSI") + } + + void updateRelationship(DelegateExecution execution) { + logger.trace("Enter update relationship in DoAllocateNSIandNSSI()") + String nsiServiceInstanceId = execution.getVariable("nsiServiceInstanceId") + String allottedResourceId = execution.getVariable("allottedResourceId") + //Need to check whether nsi exist : Begin + org.onap.aai.domain.yang.ServiceInstance nsiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance() + SliceTaskParams sliceParams = execution.getVariable("sliceParams") + + String nsiServiceInstanceID = sliceParams.getSuggestNsiId() + + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nsiServiceInstanceID) + //AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.QUERY_ALLOTTED_RESOURCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nsiServiceInstanceID) + + try { + AAIResultWrapper wrapper = resourceClient.get(nsiServiceuri, NotFoundException.class) + Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class) + nsiServiceInstance = si.get() + //allottedResourceId=nsiServiceInstance.getAllottedResources().getAllottedResource().get(0).getId() + +// if(resourceClient.exists(nsiServiceuri)){ +// execution.setVariable("nsi_resourceLink", nsiServiceuri.build().toString()) +// }else{ +// exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai to " + +// "associate for service :"+serviceInstanceId) +// } + }catch(BpmnError e) { + throw e; + }catch (Exception ex){ + String msg = "NSI suggested in the option doesn't exist. " + nsiServiceInstanceID + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nsiServiceInstanceId, allottedResourceId) + getAAIClient().connect(allottedResourceUri,nsiServiceuri) + + List<String> nssiAssociated = new ArrayList<>() + RelationshipList relationshipList = nsiServiceInstance.getRelationshipList() + List<Relationship> relationships = relationshipList.getRelationship() + for(Relationship relationship in relationships) + { + if(relationship.getRelatedTo().equalsIgnoreCase("service-instance")) + { + String NSSIassociated = relationship.getRelatedLink().substring(relationship.getRelatedLink().lastIndexOf("/") + 1); + if(!NSSIassociated.equals(nsiServiceInstanceID)) + nssiAssociated.add(NSSIassociated) + } + } + execution.setVariable("nssiAssociated",nssiAssociated) + execution.setVariable("nsiServiceInstanceName",nsiServiceInstance.getServiceInstanceName()) + logger.trace("Exit update relationship in DoAllocateNSIandNSSI()") + } + + void prepareNssiModelInfo(DelegateExecution execution){ + logger.trace("Enter prepareNssiModelInfo in DoAllocateNSIandNSSI()") + List<String> nssiAssociated = new ArrayList<>() + Map<String, Object> nssiMap = new HashMap<>() + nssiAssociated=execution.getVariable("nssiAssociated") + for(String nssiID in nssiAssociated) + { + try { + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nssiID) + AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class) + Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class) + org.onap.aai.domain.yang.ServiceInstance nssi = si.get() + nssiMap.put(nssi.getEnvironmentContext(),"""{ + "serviceInstanceId":"${nssi.getServiceInstanceId()}", + "modelUuid":"${nssi.getModelVersionId()}" + }""") + + }catch(NotFoundException e) + { + logger.debug("NSSI Service Instance not found in AAI: " + nssiID) + }catch(Exception e) + { + logger.debug("NSSI Service Instance not found in AAI: " + nssiID) + } + execution.setVariable("nssiMap",nssiMap) + + } + logger.trace("Exit prepareNssiModelInfo in DoAllocateNSIandNSSI()") + } + + void createNSIinAAI(DelegateExecution execution) { + logger.trace("Enter CreateNSIinAAI in DoAllocateNSIandNSSI()") + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + org.onap.aai.domain.yang.ServiceInstance nsi = new ServiceInstance(); + String sliceInstanceId = UUID.randomUUID().toString() + execution.setVariable("sliceInstanceId",sliceInstanceId) + nsi.setServiceInstanceId(sliceInstanceId) + String sliceInstanceName = "nsi_"+execution.getVariable("serviceInstanceName") + nsi.setServiceInstanceName(sliceInstanceName) + String serviceType = execution.getVariable("serviceType") + nsi.setServiceType(serviceType) + String serviceStatus = "deactivated" + nsi.setOrchestrationStatus(serviceStatus) + String modelInvariantUuid = serviceDecomposition.getModelInfo().getModelInvariantUuid() + String modelUuid = serviceDecomposition.getModelInfo().getModelUuid() + nsi.setModelInvariantId(modelInvariantUuid) + nsi.setModelVersionId(modelUuid) + String uuiRequest = execution.getVariable("uuiRequest") + String serviceInstanceLocationid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.plmnIdList") + nsi.setServiceInstanceLocationId(serviceInstanceLocationid) + //String snssai = jsonUtil.getJsonValue(uuiRequest, "service.requestInputs.snssai") + //nsi.setEnvironmentContext(snssai) + String serviceRole = "nsi" + nsi.setServiceRole(serviceRole) + try { + + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), sliceInstanceId) + client.create(uri, nsi) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + Map<String, Object> nssiMap = new HashMap<>() + List<ServiceProxy> serviceProxyList = serviceDecomposition.getServiceProxy() + List<String> nsstModelInfoList = new ArrayList<>() + for(ServiceProxy serviceProxy : serviceProxyList) + { + //String nsstModelUuid = serviceProxy.getModelInfo().getModelUuid() + String nsstModelUuid = serviceProxy.getSourceModelUuid() + //String nsstModelInvariantUuid = serviceProxy.getModelInfo().getModelInvariantUuid() + String nsstServiceModelInfo = """{ + "modelInvariantUuid":"", + "modelUuid":"${nsstModelUuid}", + "modelVersion":"" + }""" + nsstModelInfoList.add(nsstServiceModelInfo) + } + int currentIndex=0 + int maxIndex=nsstModelInfoList.size() + if(maxIndex < 1) + { + msg = "Exception in DoAllocateNSIandNSSI. There is no NSST associated with NST " + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + execution.setVariable("nsstModelInfoList",nsstModelInfoList) + execution.setVariable("currentIndex",currentIndex) + execution.setVariable("maxIndex",maxIndex) + execution.setVariable('nsiServiceInstanceId',sliceInstanceId) + execution.setVariable("nsiServiceInstanceName",sliceInstanceName) + logger.trace("Exit CreateNSIinAAI in DoAllocateNSIandNSSI()") + } + + void getOneNsstInfo(DelegateExecution execution){ + List<String> nsstModelInfoList = new ArrayList<>() + nsstModelInfoList = execution.getVariable("nsstModelInfoList") + int currentIndex = execution.getVariable("currentIndex") + int maxIndex = execution.getVariable("maxIndex") + boolean isMoreNSSTtoProcess = true + String nsstServiceModelInfo = nsstModelInfoList.get(currentIndex) + execution.setVariable("serviceModelInfo", nsstServiceModelInfo) + execution.setVariable("currentIndex", currentIndex) + currentIndex = currentIndex+1 + if(currentIndex <= maxIndex ) + isMoreNSSTtoProcess = false + execution.setVariable("isMoreNSSTtoProcess", isMoreNSSTtoProcess) + } + + void createNSSTMap(DelegateExecution execution){ + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + String modelUuid= serviceDecomposition.getModelInfo().getModelUuid() + String content = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0).getContent() + //String nsstID = jsonUtil.getJsonValue(content, "metadata.id") + //String vendor = jsonUtil.getJsonValue(content, "metadata.vendor") + //String type = jsonUtil.getJsonValue(content, "metadata.type") + String domain = jsonUtil.getJsonValue(content, "metadata.domainType") + + Map<String, Object> nssiMap = execution.getVariable("nssiMap") + String servicename = execution.getVariable("serviceInstanceName") + String nsiname = "nsi_"+servicename + nssiMap.put(domain,"""{ + "serviceInstanceId":"", + "modelUuid":"${modelUuid}" + }""") + execution.setVariable("nssiMap",nssiMap) + } + + void prepareNSSIList(DelegateExecution execution){ + logger.trace("Enter prepareNSSIList in DoAllocateNSIandNSSI()") + Map<String, Object> nssiMap = new HashMap<>() + Boolean isMoreNSSI = false + nssiMap = execution.getVariable("nssiMap") + List<String> keys=new ArrayList<String>(nssiMap.values()) + List<String> nsstSequence = execution.getVariable("nsstSequence") + Integer currentIndex=0; + execution.setVariable("currentNssiIndex",currentIndex) + Integer maxIndex=keys.size() + execution.setVariable("maxIndex",maxIndex) + if(maxIndex>0) + isMoreNSSI=true + execution.setVariable("isMoreNSSI",isMoreNSSI) + logger.trace("Exit prepareNSSIList in DoAllocateNSIandNSSI()") + } + + + void getOneNSSIInfo(DelegateExecution execution){ + logger.trace("Enter getOneNSSIInfo in DoAllocateNSIandNSSI()") + + //ServiceDecomposition serviceDecompositionObj = execution.getVariable("serviceDecompositionObj") + Map<String, Object> nssiMap=execution.getVariable("nssiMap") + List<String> nsstSequence = execution.getVariable("nsstSequence") + String currentNSST= nsstSequence.get(execution.getVariable("currentNssiIndex")) + boolean isNSSIOptionAvailable = false + String nsstInput=nssiMap.get(currentNSST) + execution.setVariable("nsstInput",nsstInput) + String modelUuid = jsonUtil.getJsonValue(nsstInput, "modelUuid") + String nssiInstanceId = jsonUtil.getJsonValue(nsstInput, "serviceInstanceId") + String nssiserviceModelInfo = """{ + "modelInvariantUuid":"", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + Integer currentIndex = execution.getVariable("currentNssiIndex") + currentIndex=currentIndex+1; + execution.setVariable("currentNssiIndex",currentIndex) + execution.setVariable("nssiserviceModelInfo",nssiserviceModelInfo) + execution.setVariable("nssiInstanceId",nssiInstanceId) + logger.trace("Exit getOneNSSIInfo in DoAllocateNSIandNSSI()") + } + + void updateCurrentIndex(DelegateExecution execution){ + + logger.trace("Enter updateCurrentIndex in DoAllocateNSIandNSSI()") + Integer currentIndex = execution.getVariable("currentNssiIndex") + Integer maxIndex = execution.getVariable("maxIndex") + if(currentIndex>=maxIndex) + { + Boolean isMoreNSSI=false + execution.setVariable("isMoreNSSI",isMoreNSSI) + } + logger.trace("Exit updateCurrentIndex in DoAllocateNSIandNSSI()") + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy new file mode 100644 index 0000000000..d786cb0ba1 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy @@ -0,0 +1,771 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aai.domain.yang.SliceProfile +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.beans.nsmf.AllocateAnNssi +import org.onap.so.beans.nsmf.AllocateCnNssi +import org.onap.so.beans.nsmf.AllocateTnNssi +import org.onap.so.beans.nsmf.AnSliceProfile +import org.onap.so.beans.nsmf.CnSliceProfile +import org.onap.so.beans.nsmf.EsrInfo +import org.onap.so.beans.nsmf.JobStatusRequest +import org.onap.so.beans.nsmf.NetworkType +import org.onap.so.beans.nsmf.NsiInfo +import org.onap.so.beans.nsmf.NssiAllocateRequest +import org.onap.so.beans.nsmf.PerfReq +import org.onap.so.beans.nsmf.PerfReqEmbbList +import org.onap.so.beans.nsmf.PerfReqUrllcList +import org.onap.so.beans.nsmf.ResourceSharingLevel +import org.onap.so.beans.nsmf.ServiceProfile +import org.onap.so.beans.nsmf.SliceTaskParams +import org.onap.so.beans.nsmf.TnSliceProfile +import org.onap.so.beans.nsmf.UeMobilityLevel +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +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.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import com.fasterxml.jackson.databind.ObjectMapper; +import javax.ws.rs.core.Response + +import static org.apache.commons.lang3.StringUtils.isBlank + + +class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor{ + + private static final Logger logger = LoggerFactory.getLogger( DoAllocateNSSI.class); + private static final ObjectMapper MAPPER = new ObjectMapper(); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + JsonUtils jsonUtil = new JsonUtils() + + /** + * Pre Process the BPMN Flow Request + * Inclouds: + * generate the nsOperationKey + * generate the nsParameters + */ + void preProcessRequest (DelegateExecution execution) { + logger.trace("Enter preProcessRequest()") + String msg = "" + String nssmfOperation = "" + String msoRequestId = execution.getVariable("msoRequestId") + String nsstInput = execution.getVariable("nsstInput") + String modelUuid = jsonUtil.getJsonValue(nsstInput, "modelUuid") + //modelUuid="2763777c-27bd-4df7-93b8-c690e23f4d3f" + String nssiInstanceId = jsonUtil.getJsonValue(nsstInput, "serviceInstanceId") + String serviceModelInfo = """{ + "modelInvariantUuid":"", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo",serviceModelInfo) + execution.setVariable("nssiInstanceId",nssiInstanceId) + String nssiProfileID = UUID.randomUUID().toString() + execution.setVariable("nssiProfileID",nssiProfileID) + if(isBlank(nssiInstanceId)) + { + nssmfOperation="create" + nssiInstanceId = UUID.randomUUID().toString() + }else { + nssmfOperation = "update" + } + execution.setVariable("nssmfOperation",nssmfOperation) + execution.setVariable("nssiInstanceId",nssiInstanceId) + + def isDebugLogEnabled ="false" + def isNSSICreated = false + execution.setVariable("isNSSICreated",isNSSICreated) + + int currentCycle = 0 + execution.setVariable("currentCycle", currentCycle) + + logger.trace("Exit preProcessRequest") + } + + + void getNSSTInfo(DelegateExecution execution){ + logger.trace("Enter getNSSTInfo in DoAllocateNSSI()") + ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition") + ModelInfo modelInfo = serviceDecomposition.getModelInfo() + String serviceRole = "nssi" + String nssiServiceInvariantUuid = serviceDecomposition.modelInfo.getModelInvariantUuid() + String nssiServiceUuid = serviceDecomposition.modelInfo.getModelUuid() + String nssiServiceType = serviceDecomposition.getServiceType() + String uuiRequest = execution.getVariable("uuiRequest") + String nssiServiceName = "nssi_"+jsonUtil.getJsonValue(uuiRequest, "service.name") + execution.setVariable("nssiServiceName",nssiServiceName) + execution.setVariable("nssiServiceType",nssiServiceType) + execution.setVariable("nssiServiceInvariantUuid",nssiServiceInvariantUuid) + execution.setVariable("nssiServiceUuid",nssiServiceUuid) + execution.setVariable("serviceRole",serviceRole) + + String content = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0).getContent() + String nsstID = jsonUtil.getJsonValue(content, "metadata.id") + String nsstVendor = jsonUtil.getJsonValue(content, "metadata.vendor") + String nsstDomain = jsonUtil.getJsonValue(content, "metadata.domainType") + String nsstType = jsonUtil.getJsonValue(content, "metadata.type") + + execution.setVariable("nsstID",nsstID) + execution.setVariable("nsstVendor",nsstVendor) + execution.setVariable("nsstDomain",nsstDomain) + execution.setVariable("nssiServiceUuid",nssiServiceUuid) + execution.setVariable("nsstType",nsstType) + + String nsstContentInfo = """{ + "NsstID":"${nsstID}", + "Vendor":"${nsstVendor}", + "type":"${nsstType}" + }""" + + logger.trace("Exit getNSSTInfo in DoAllocateNSSI()") + } + + void timeDelay(DelegateExecution execution) { + logger.trace("Enter timeDelay in DoAllocateNSSI()") + try { + Thread.sleep(60000); + int currentCycle = execution.getVariable("currentCycle") + currentCycle=currentCycle+1 + if(currentCycle>60) + { + logger.trace("Completed all the retry times... but still nssmf havent completed the creation process...") + exceptionUtil.buildAndThrowWorkflowException(execution, 500, "NSSMF creation didnt complete by time...") + } + execution.setVariable("currentCycle",currentCycle) + } catch(InterruptedException e) { + logger.info("Time Delay exception" + e) + } + logger.trace("Exit timeDelay in DoAllocateNSSI()") + } + + + void sendUpdateRequestNSSMF(DelegateExecution execution) { + logger.trace("Enter sendUpdateRequestNSSMF in DoAllocateNSSI()") + String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution) + logger.debug( "get NSSMF: " + urlString) + + //Prepare auth for NSSMF - Begin + def authHeader = "" + String basicAuth = UrnPropertiesReader.getVariable("mso.nssmf.auth", execution) + String domain = execution.getVariable("nsstDomain") + String nssmfRequest = buildUpdateNSSMFRequest(execution, domain.toUpperCase()) + + //send request to update NSSI option - Begin + URL url = new URL(urlString+"/api/rest/provMns/v1/NSS/SliceProfiles") + HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) + Response httpResponse = httpClient.post(nssmfRequest) + + int responseCode = httpResponse.getStatus() + logger.debug("NSSMF sync response code is: " + responseCode) + + if(responseCode < 199 && responseCode > 299){ + String nssmfResponse ="NSSMF response have nobody" + if(httpResponse.hasEntity()) + nssmfResponse = httpResponse.readEntity(String.class) + logger.trace("received error message from NSSMF : "+nssmfResponse) + logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()") + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.") + } + + if(httpResponse.hasEntity()){ + String nssmfResponse = httpResponse.readEntity(String.class) + execution.setVariable("nssmfResponse", nssmfResponse) + String nssiId = jsonUtil.getJsonValue(nssmfResponse, "nssiId") + String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId") + execution.setVariable("nssiId",nssiId) + execution.setVariable("jobId",jobId) + }else{ + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.") + } + logger.trace("Exit sendUpdateRequestNSSMF in DoAllocateNSSI()") + } + + void sendCreateRequestNSSMF(DelegateExecution execution) { + logger.trace("Enter sendCreateRequestNSSMF in DoAllocateNSSI()") + String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution) + logger.debug( "get NSSMF: " + urlString) + + //Prepare auth for NSSMF - Begin + String domain = execution.getVariable("nsstDomain") + String nssmfRequest = buildCreateNSSMFRequest(execution, domain.toUpperCase()) + + //send request to get NSI option - Begin + URL url = new URL(urlString+"/api/rest/provMns/v1/NSS/SliceProfiles") + HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) + Response httpResponse = httpClient.post(nssmfRequest) + + int responseCode = httpResponse.getStatus() + logger.debug("NSSMF sync response code is: " + responseCode) + + if(responseCode < 199 || responseCode > 299 ){ + String nssmfResponse ="NSSMF response have nobody" + if(httpResponse.hasEntity()) + nssmfResponse = httpResponse.readEntity(String.class) + logger.trace("received error message from NSSMF : "+nssmfResponse) + logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()") + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.") + } + + if(httpResponse.hasEntity()){ + String nssmfResponse = httpResponse.readEntity(String.class) + execution.setVariable("nssmfResponse", nssmfResponse) + String nssiId = jsonUtil.getJsonValue(nssmfResponse, "nssiId") + String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId") + execution.setVariable("nssiId",nssiId) + execution.setVariable("jobId",jobId) + }else{ + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.") + } + logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()") + + } + + void getNSSMFProgresss(DelegateExecution execution) { + logger.trace("Enter getNSSMFProgresss in DoAllocateNSSI()") + + String endpoint = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution) + logger.debug( "get NSSMF: " + endpoint) + + //Prepare auth for NSSMF - Begin + def authHeader = "" + String basicAuth = UrnPropertiesReader.getVariable("mso.nssmf.auth", execution) + + String nssmfRequest = buildNSSMFProgressRequest(execution) + String strUrl="/api/rest/provMns/v1/NSS/jobs/"+execution.getVariable("jobId") + //send request to update NSSI option - Begin + URL url = new URL(endpoint+strUrl) + HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) + Response httpResponse = httpClient.post(nssmfRequest) + + int responseCode = httpResponse.getStatus() + logger.debug("NSSMF sync response code is: " + responseCode) + + if(responseCode < 199 || responseCode > 299){ + String nssmfResponse ="NSSMF response have nobody" + if(httpResponse.hasEntity()) + nssmfResponse = httpResponse.readEntity(String.class) + logger.trace("received error message from NSSMF : "+nssmfResponse) + logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()") + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.") + } + + if(httpResponse.hasEntity()){ + String nssmfResponse = httpResponse.readEntity(String.class) + Boolean isNSSICreated = false + execution.setVariable("nssmfResponse", nssmfResponse) + Integer progress = java.lang.Integer.parseInt(jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.progress")) + String status = jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.status") + String statusDescription = jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.statusDescription") + execution.setVariable("nssmfProgress",progress) + execution.setVariable("nssmfStatus",status) + execution.setVariable("nddmfStatusDescription",statusDescription) + if(progress>99) + isNSSICreated = true + execution.setVariable("isNSSICreated",isNSSICreated) + + }else{ + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.") + } + logger.trace("Exit getNSSMFProgresss in DoAllocateNSSI()") + + } + + void updateRelationship(DelegateExecution execution) { + logger.trace("Enter updateRelationship in DoAllocateNSSI()") + String nssiInstanceId = execution.getVariable("nssiInstanceId") + String nsiInstanceId = execution.getVariable("nsiServiceInstanceId") + try{ + AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nsiInstanceId); + AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiInstanceId) + getAAIClient().connect(nsiServiceuri, nssiServiceUri, AAIEdgeLabel.COMPOSED_OF); + }catch(Exception ex) { + String msg = "Exception in DoAllocateNSSI InstantiateNSSI service while creating relationship " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.trace("Exit updateRelationship in DoAllocateNSSI()") + } + + + void instantiateNSSIService(DelegateExecution execution) { + logger.trace("Enter instantiateNSSIService in DoAllocateNSSI()") + //String nssiInstanceId = execution.getVariable("nssiInstanceId") + String nssiInstanceId = execution.getVariable("nssiId") + execution.setVariable("nssiInstanceId",nssiInstanceId) + String sliceInstanceId = execution.getVariable("nsiServiceInstanceId") + try { + org.onap.aai.domain.yang.ServiceInstance nssi = new ServiceInstance(); + Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile") + + nssi.setServiceInstanceId(nssiInstanceId) + nssi.setServiceInstanceName(execution.getVariable("nssiServiceName")) + //nssi.setServiceType(execution.getVariable("nssiServiceType")) + nssi.setServiceType(serviceProfileMap.get("sST").toString()) + String serviceStatus = "deactivated" + nssi.setOrchestrationStatus(serviceStatus) + String modelInvariantUuid = execution.getVariable("nssiServiceInvariantUuid") + String modelUuid = execution.getVariable("nssiServiceUuid") + nssi.setModelInvariantId(modelInvariantUuid) + nssi.setModelVersionId(modelUuid) + String uuiRequest = execution.getVariable("uuiRequest") + String serviceInstanceLocationid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.plmnIdList") + nssi.setServiceInstanceLocationId(serviceInstanceLocationid) + //String snssai = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.sNSSAI") + String envContext=execution.getVariable("nsstDomain") + nssi.setEnvironmentContext(envContext) + nssi.setServiceRole(execution.getVariable("serviceRole")) + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), nssiInstanceId) + client.create(uri, nssi) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + try{ + AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, sliceInstanceId); + AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiInstanceId) + getAAIClient().connect(nsiServiceuri, nssiServiceUri, AAIEdgeLabel.COMPOSED_OF); + }catch(Exception ex) { + String msg = "Exception in DoAllocateNSSI InstantiateNSSI service while creating relationship " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + + + def rollbackData = execution.getVariable("RollbackData") + if (rollbackData == null) { + rollbackData = new RollbackData(); + } + //rollbackData.put("SERVICEINSTANCE", "disableRollback", idisableRollback.toStrng()) + rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") + rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", nssiInstanceId) + rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType")) + rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) + execution.setVariable("rollbackData", rollbackData) + execution.setVariable("RollbackData", rollbackData) + logger.debug("RollbackData:" + rollbackData) + logger.trace("Exit instantiateNSSIService in DoAllocateNSSI()") + } + + + void createSliceProfile(DelegateExecution execution) { + logger.trace("Enter createSliceProfile in DoAllocateNSSI()") + String sliceserviceInstanceId = execution.getVariable("nssiInstanceId") + String nssiProfileID = execution.getVariable("nssiProfileID") + Map<String, Object> sliceProfileMap = execution.getVariable("sliceProfileCn") + Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile") + SliceProfile sliceProfile = new SliceProfile() + sliceProfile.setServiceAreaDimension("") + sliceProfile.setPayloadSize(0) + sliceProfile.setJitter(0) + sliceProfile.setSurvivalTime(0) + //sliceProfile.setCsAvailability() + //sliceProfile.setReliability() + sliceProfile.setExpDataRate(0) + sliceProfile.setTrafficDensity(0) + sliceProfile.setConnDensity(0) + sliceProfile.setExpDataRateUL(Integer.parseInt(sliceProfileMap.get("expDataRateUL").toString())) + sliceProfile.setExpDataRateDL(Integer.parseInt(sliceProfileMap.get("expDataRateDL").toString())) + sliceProfile.setActivityFactor(Integer.parseInt(sliceProfileMap.get("activityFactor").toString())) + sliceProfile.setResourceSharingLevel(sliceProfileMap.get("activityFactor").toString()) + sliceProfile.setUeMobilityLevel(serviceProfileMap.get("uEMobilityLevel").toString()) + sliceProfile.setCoverageAreaTAList(serviceProfileMap.get("coverageAreaTAList").toString()) + sliceProfile.setMaxNumberOfUEs(Integer.parseInt(sliceProfileMap.get("activityFactor").toString())) + sliceProfile.setLatency(Integer.parseInt(sliceProfileMap.get("latency").toString())) + sliceProfile.setProfileId(nssiProfileID) + sliceProfile.setE2ELatency(0) + + try { + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, + execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), sliceserviceInstanceId, nssiProfileID) + client.create(uri, sliceProfile) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + def rollbackData = execution.getVariable("RollbackData") + if (rollbackData == null) { + rollbackData = new RollbackData(); + } + //rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) + rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") + rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", sliceserviceInstanceId) + rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("serviceType")) + rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) + execution.setVariable("rollbackData", rollbackData) + execution.setVariable("RollbackData", rollbackData) + logger.debug("RollbackData:" + rollbackData) + logger.trace("Exit createSliceProfile in DoAllocateNSSI()") + } + + + String buildCreateNSSMFRequest(DelegateExecution execution, String domain) { + + NssiAllocateRequest request = new NssiAllocateRequest() + String strRequest = "" + //String uuiRequest = execution.getVariable("uuiRequest") + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + + switch (domain) { + case "AN": + EsrInfo esrInfo = new EsrInfo() + esrInfo.setNetworkType(execution.getVariable("networkType")) + esrInfo.setVendor(execution.getVariable("nsstVendor")) + + NsiInfo nsiInfo = new NsiInfo() + nsiInfo.setNsiId(execution.getVariable("nsiInstanceID")) + nsiInfo.setNsiName(execution.getVariable("nsiInstanceName")) + + AnSliceProfile anSliceProfile = new AnSliceProfile() + anSliceProfile.setLatency(execution.getVariable("latency")) + anSliceProfile.setCoverageAreaTAList(execution.getVariable("coverageAreaList")) + anSliceProfile.setQi(execution.getVariable("qi")) + + AllocateAnNssi allocateAnNssi = new AllocateAnNssi() + allocateAnNssi.setNsstId(execution.getVariable("nsstId")) + allocateAnNssi.setNssiName(execution.getVariable("nssiName")) + allocateAnNssi.setNsiInfo(nsiInfo) + allocateAnNssi.setSliceProfile(anSliceProfile) + String anScriptName = sliceTaskParams.getAnScriptName() + allocateAnNssi.setScriptName(anScriptName) + + request.setAllocateAnNssi(allocateAnNssi) + request.setEsrInfo(esrInfo) + break; + case "CN": + Map<String, Object> sliceProfileCn =execution.getVariable("sliceProfileCn") + Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") + NsiInfo nsiInfo = new NsiInfo() + nsiInfo.setNsiId(execution.getVariable("nsiServiceInstanceId")) + nsiInfo.setNsiName(execution.getVariable("nsiServiceInstanceName")) + + EsrInfo esrInfo = new EsrInfo() + esrInfo.setNetworkType(NetworkType.fromString(domain)) + esrInfo.setVendor(execution.getVariable("nsstVendor")) + execution.setVariable("esrInfo",esrInfo) + + + PerfReqEmbbList perfReqEmbb = new PerfReqEmbbList() + perfReqEmbb.setActivityFactor(sliceProfileCn.get("activityFactor")) + perfReqEmbb.setAreaTrafficCapDL(sliceProfileCn.get("areaTrafficCapDL")) + perfReqEmbb.setAreaTrafficCapUL(sliceProfileCn.get("areaTrafficCapUL")) + perfReqEmbb.setExpDataRateDL(sliceProfileCn.get("expDataRateDL")) + perfReqEmbb.setExpDataRateUL(sliceProfileCn.get("expDataRateUL")) + + List<PerfReqEmbbList> listPerfReqEmbbList = new ArrayList<>() + listPerfReqEmbbList.add(perfReqEmbb) + + PerfReq perfReq = new PerfReq() + perfReq.setPerfReqEmbbList(listPerfReqEmbbList) + + PerfReqUrllcList perfReqUrllc = new PerfReqUrllcList() + perfReqUrllc.setConnDensity(0) + perfReqUrllc.setTrafficDensity(0) + perfReqUrllc.setExpDataRate(0) + perfReqUrllc.setReliability(0) + perfReqUrllc.setCsAvailability(0) + perfReqUrllc.setSurvivalTime(0) + perfReqUrllc.setJitter(0) + perfReqUrllc.setE2eLatency(0) + perfReqUrllc.setPayloadSize("0") + perfReqUrllc.setServiceAreaDimension("") + + List<PerfReqUrllcList> perfReqUrllcList = new ArrayList<>() + perfReqUrllcList.add(perfReqUrllc) + perfReq.setPerfReqUrllcList(perfReqUrllcList) + + CnSliceProfile cnSliceProfile = new CnSliceProfile() + cnSliceProfile.setSliceProfileId(execution.getVariable("nssiProfileID")) + String plmnStr = serviceProfile.get("plmnIdList") + List<String> plmnIdList=Arrays.asList(plmnStr.split("\\|")) + cnSliceProfile.setPlmnIdList(plmnIdList) + + String resourceSharingLevel = serviceProfile.get("resourceSharingLevel").toString() + cnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(resourceSharingLevel)) + + String coverageArea = serviceProfile.get("coverageAreaTAList") + List<String> coverageAreaList=Arrays.asList(coverageArea.split("\\|")) + cnSliceProfile.setCoverageAreaTAList(coverageAreaList) + + String ueMobilityLevel = serviceProfile.get("uEMobilityLevel").toString() + cnSliceProfile.setUeMobilityLevel(UeMobilityLevel.fromString(ueMobilityLevel)) + + int latency = serviceProfile.get("latency") + cnSliceProfile.setLatency(latency) + + int maxUE = serviceProfile.get("maxNumberofUEs") + cnSliceProfile.setMaxNumberofUEs(maxUE) + + String snssai = serviceProfile.get("sNSSAI") + List<String> snssaiList = Arrays.asList(snssai.split("\\|")) + cnSliceProfile.setSnssaiList(snssaiList) + + cnSliceProfile.setPerfReq(perfReq) + + AllocateCnNssi allocateCnNssi = new AllocateCnNssi() + allocateCnNssi.setNsstId(execution.getVariable("nsstid")) + allocateCnNssi.setNssiName(execution.getVariable("nssiName")) + allocateCnNssi.setSliceProfile(cnSliceProfile) + allocateCnNssi.setNsiInfo(nsiInfo) + String cnScriptName = sliceTaskParams.getCnScriptName() + allocateCnNssi.setScriptName(cnScriptName) + request.setAllocateCnNssi(allocateCnNssi) + request.setEsrInfo(esrInfo) + break; + case "TN": + EsrInfo esrInfo = new EsrInfo() + esrInfo.setNetworkType(execution.getVariable("networkType")) + esrInfo.setVendor(execution.getVariable("vendor")) + + TnSliceProfile tnSliceProfile = new TnSliceProfile() + tnSliceProfile.setLatency(execution.getVariable("latency")) + tnSliceProfile.setBandwidth(execution.getVariable("bandWidth")) + + NsiInfo nsiInfo = new NsiInfo() + nsiInfo.setNsiId(execution.getVariable("nsiInstanceID")) + nsiInfo.setNsiName(execution.getVariable("nsiInstanceName")) + + AllocateTnNssi allocateTnNssi = new AllocateTnNssi() + allocateTnNssi.setSliceProfile(tnSliceProfile) + allocateTnNssi.setNsiInfo(nsiInfo) + allocateTnNssi.setNsstId(execution.getVariable("nsstid")) + String tnScriptName = sliceTaskParams.getTnScriptName() + allocateTnNssi.setScriptName(tnScriptName) + + request.setAllocateTnNssi(allocateTnNssi) + request.setEsrInfo(esrInfo) + break; + default: + break; + } + try { + strRequest = MAPPER.writeValueAsString(request); + } catch (IOException e) { + logger.error("Invalid get progress request bean to convert as string"); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Invalid get progress request bean to convert as string") + } + return strRequest + } + + + String buildUpdateNSSMFRequest(DelegateExecution execution, String domain) { + NssiAllocateRequest request = new NssiAllocateRequest() + String nsstInput = execution.getVariable("nsstInput") + String nssiId = jsonUtil.getJsonValue(nsstInput, "serviceInstanceId") + String strRequest = "" + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + switch (domain) { + case "AN": + EsrInfo esrInfo = new EsrInfo() + esrInfo.setNetworkType(execution.getVariable("nsstType")) + esrInfo.setVendor(execution.getVariable("vendor")) + + NsiInfo nsiInfo = new NsiInfo() + nsiInfo.setNsiId(execution.getVariable("nsiInstanceID")) + nsiInfo.setNsiName(execution.getVariable("nsiInstanceName")) + + AnSliceProfile anSliceProfile = new AnSliceProfile() + anSliceProfile.setLatency(execution.getVariable("latency")) + anSliceProfile.setCoverageAreaTAList(execution.getVariable("coverageAreaList")) + anSliceProfile.setQi(execution.getVariable("qi")) + + AllocateAnNssi allocateAnNssi = new AllocateAnNssi() + allocateAnNssi.setNsstId(execution.getVariable("nsstId")) + allocateAnNssi.setNssiName(execution.getVariable("nssiName")) + allocateAnNssi.setNsiInfo(nsiInfo) + allocateAnNssi.setSliceProfile(anSliceProfile) + String anScriptName = sliceTaskParams.getAnScriptName() + allocateAnNssi.setScriptName(anScriptName) + request.setAllocateAnNssi(allocateAnNssi) + request.setEsrInfo(esrInfo) + break; + case "CN": + Map<String, Object> sliceProfileCn =execution.getVariable("sliceProfileCn") + Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") + NsiInfo nsiInfo = new NsiInfo() + nsiInfo.setNsiId(execution.getVariable("nsiServiceInstanceId")) + nsiInfo.setNsiName(execution.getVariable("nsiServiceInstanceName")) + + EsrInfo esrInfo = new EsrInfo() + esrInfo.setNetworkType(NetworkType.fromString(domain)) + esrInfo.setVendor(execution.getVariable("nsstVendor")) + execution.setVariable("esrInfo",esrInfo) + + + PerfReqEmbbList perfReqEmbb = new PerfReqEmbbList() + perfReqEmbb.setActivityFactor(sliceProfileCn.get("activityFactor")) + perfReqEmbb.setAreaTrafficCapDL(sliceProfileCn.get("areaTrafficCapDL")) + perfReqEmbb.setAreaTrafficCapUL(sliceProfileCn.get("areaTrafficCapUL")) + perfReqEmbb.setExpDataRateDL(sliceProfileCn.get("expDataRateDL")) + perfReqEmbb.setExpDataRateUL(sliceProfileCn.get("expDataRateUL")) + + List<PerfReqEmbbList> listPerfReqEmbbList = new ArrayList<>() + listPerfReqEmbbList.add(perfReqEmbb) + + PerfReq perfReq = new PerfReq() + perfReq.setPerfReqEmbbList(listPerfReqEmbbList) + + PerfReqUrllcList perfReqUrllc = new PerfReqUrllcList() + perfReqUrllc.setConnDensity(0) + perfReqUrllc.setTrafficDensity(0) + perfReqUrllc.setExpDataRate(0) + perfReqUrllc.setReliability(0) + perfReqUrllc.setCsAvailability(0) + perfReqUrllc.setSurvivalTime(0) + perfReqUrllc.setJitter(0) + perfReqUrllc.setE2eLatency(0) + perfReqUrllc.setPayloadSize("0") + perfReqUrllc.setServiceAreaDimension("") + + List<PerfReqUrllcList> perfReqUrllcList = new ArrayList<>() + perfReqUrllcList.add(perfReqUrllc) + perfReq.setPerfReqUrllcList(perfReqUrllcList) + + CnSliceProfile cnSliceProfile = new CnSliceProfile() + cnSliceProfile.setSliceProfileId(execution.getVariable("nssiProfileID")) + String plmnStr = serviceProfile.get("plmnIdList") + List<String> plmnIdList=Arrays.asList(plmnStr.split("\\|")) + cnSliceProfile.setPlmnIdList(plmnIdList) + + String resourceSharingLevel = serviceProfile.get("resourceSharingLevel").toString() + cnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(resourceSharingLevel)) + + String coverageArea = serviceProfile.get("coverageAreaTAList") + List<String> coverageAreaList=Arrays.asList(coverageArea.split("\\|")) + cnSliceProfile.setCoverageAreaTAList(coverageAreaList) + + String ueMobilityLevel = serviceProfile.get("uEMobilityLevel").toString() + cnSliceProfile.setUeMobilityLevel(UeMobilityLevel.fromString(ueMobilityLevel)) + + int latency = serviceProfile.get("latency") + cnSliceProfile.setLatency(latency) + + int maxUE = serviceProfile.get("maxNumberofUEs") + cnSliceProfile.setMaxNumberofUEs(maxUE) + + String snssai = serviceProfile.get("sNSSAI") + List<String> snssaiList = Arrays.asList(snssai.split("\\|")) + cnSliceProfile.setSnssaiList(snssaiList) + + cnSliceProfile.setPerfReq(perfReq) + + AllocateCnNssi allocateCnNssi = new AllocateCnNssi() + allocateCnNssi.setNsstId(execution.getVariable("nsstid")) + allocateCnNssi.setNssiName(execution.getVariable("nssiName")) + allocateCnNssi.setSliceProfile(cnSliceProfile) + allocateCnNssi.setNsiInfo(nsiInfo) + allocateCnNssi.setNssiId(nssiId) // need to check this + String cnScriptName = sliceTaskParams.getCnScriptName() + allocateCnNssi.setScriptName(cnScriptName) + request.setAllocateCnNssi(allocateCnNssi) + request.setEsrInfo(esrInfo) + break; + case "TN": + EsrInfo esrInfo = new EsrInfo() + esrInfo.setNetworkType(execution.getVariable("networkType")) + esrInfo.setVendor(execution.getVariable("vendor")) + + TnSliceProfile tnSliceProfile = new TnSliceProfile() + tnSliceProfile.setLatency(execution.getVariable("latency")) + tnSliceProfile.setBandwidth(execution.getVariable("bandWidth")) + + NsiInfo nsiInfo = new NsiInfo() + nsiInfo.setNsiId(execution.getVariable("nsiInstanceID")) + nsiInfo.setNsiName(execution.getVariable("nsiInstanceName")) + + AllocateTnNssi allocateTnNssi = new AllocateTnNssi() + allocateTnNssi.setSliceProfile(tnSliceProfile) + allocateTnNssi.setNsiInfo(nsiInfo) + allocateTnNssi.setNsstId(execution.getVariable("nsstid")) + String tnScriptName = sliceTaskParams.getTnScriptName() + allocateTnNssi.setScriptName(tnScriptName) + request.setAllocateTnNssi(allocateTnNssi) + request.setEsrInfo(esrInfo) + break; + default: + break; + } + try { + strRequest = MAPPER.writeValueAsString(request); + } catch (IOException e) { + logger.error("Invalid get progress request bean to convert as string"); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Invalid get progress request bean to convert as string") + } + return strRequest + } + + String buildNSSMFProgressRequest(DelegateExecution execution){ + JobStatusRequest request = new JobStatusRequest() + String strRequest = "" + EsrInfo esrInfo = execution.getVariable("esrInfo") + request.setNsiId(execution.getVariable("nsiServiceInstanceId")) + request.setNssiId(execution.getVariable("nssiId")) + request.setEsrInfo(esrInfo) + + try { + strRequest = MAPPER.writeValueAsString(request); + } catch (IOException e) { + logger.error("Invalid get progress request bean to convert as string"); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Invalid get progress request bean to convert as string") + } + return strRequest + } + + public void prepareUpdateOrchestrationTask(DelegateExecution execution) { + logger.debug("Start prepareUpdateOrchestrationTask progress") + String requestMethod = "PUT" + String progress = execution.getVariable("nssmfProgress") + String status = execution.getVariable("nssmfStatus") + String statusDescription=execution.getVariable("nddmfStatusDescription") + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + String domain = execution.getVariable("nsstDomain") + switch (domain.toUpperCase()) { + case "AN": + sliceTaskParams.setAnProgress(progress) + sliceTaskParams.setAnStatus(status) + sliceTaskParams.setAnStatusDescription(statusDescription) + break; + case "CN": + sliceTaskParams.setCnProgress(progress) + sliceTaskParams.setCnStatus(status) + sliceTaskParams.setCnStatusDescription(statusDescription) + break; + case "TN": + sliceTaskParams.setTnProgress(progress) + sliceTaskParams.setTnStatus(status) + sliceTaskParams.setTnStatusDescription(statusDescription) + break; + default: + break; + } + String paramJson = sliceTaskParams.convertToJson() + execution.setVariable("CSSOT_paramJson", paramJson) + execution.setVariable("CSSOT_requestMethod", requestMethod) + logger.debug("Finish prepareUpdateOrchestrationTask progress") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy new file mode 100644 index 0000000000..ae239d9e68 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy @@ -0,0 +1,232 @@ +package org.onap.so.bpmn.infrastructure.scripts + + +import org.onap.so.bpmn.core.domain.AllottedResource +import org.onap.aai.domain.yang.AllottedResource + +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.OwningEntity +import org.onap.aai.domain.yang.ServiceProfile; +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.core.RollbackData +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.ModelInfo +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.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.slf4j.Logger +import org.slf4j.LoggerFactory + + + +class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{ + + private static final Logger logger = LoggerFactory.getLogger( DoCreateSliceServiceInstance.class); + JsonUtils jsonUtil = new JsonUtils() + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() + + /** + * Pre Process the BPMN Flow Request + * Inclouds: + * generate the nsOperationKey + * generate the nsParameters + */ + void preProcessRequest (DelegateExecution execution) { + String msg = "" + logger.trace("Enter preProcessRequest()") + //Need update + //1. Prepare service parameter. + //2. Prepare slice profile parameters. + + String sliceserviceInstanceId = execution.getVariable("serviceInstanceId") + String allottedResourceId = UUID.randomUUID().toString() + execution.setVariable("sliceserviceInstanceId", sliceserviceInstanceId) + execution.setVariable("allottedResourceId", allottedResourceId) + + String uuiRequest = execution.getVariable("uuiRequest") + String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceInvariantUuid") + String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceUuid") + //here modelVersion is not set, we use modelUuid to decompose the service. + def isDebugLogEnabled = true + execution.setVariable("serviceInstanceId",sliceserviceInstanceId) + execution.setVariable("isDebugLogEnabled",isDebugLogEnabled) + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + + logger.trace("Exit preProcessRequest") + } + + + void createServiceProfile(DelegateExecution execution) { + + String sliceserviceInstanceId = execution.getVariable("sliceserviceInstanceId") + Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile") + String serviceProfileID = UUID.randomUUID().toString() + ServiceProfile serviceProfile = new ServiceProfile(); + serviceProfile.setProfileId(serviceProfileID) + serviceProfile.setLatency(Integer.parseInt(serviceProfileMap.get("latency").toString())) + serviceProfile.setMaxNumberOfUEs(Integer.parseInt(serviceProfileMap.get("maxNumberofUEs").toString())) + serviceProfile.setCoverageAreaTAList(serviceProfileMap.get("coverageAreaTAList").toString()) + serviceProfile.setUeMobilityLevel(serviceProfileMap.get("uEMobilityLevel").toString()) + serviceProfile.setResourceSharingLevel(serviceProfileMap.get("resourceSharingLevel").toString()) + serviceProfile.setExpDataRateUL(Integer.parseInt(serviceProfileMap.get("expDataRateUL").toString())) + serviceProfile.setExpDataRateDL(Integer.parseInt(serviceProfileMap.get("expDataRateDL").toString())) + serviceProfile.setAreaTrafficCapUL(Integer.parseInt(serviceProfileMap.get("areaTrafficCapUL").toString())) + serviceProfile.setAreaTrafficCapDL(Integer.parseInt(serviceProfileMap.get("areaTrafficCapDL").toString())) + serviceProfile.setActivityFactor(Integer.parseInt(serviceProfileMap.get("activityFactor").toString())) + + serviceProfile.setJitter(0) + serviceProfile.setSurvivalTime(0) + serviceProfile.setCsAvailability(new Object()) + serviceProfile.setReliability(new Object()) + serviceProfile.setExpDataRate(0) + serviceProfile.setTrafficDensity(0) + serviceProfile.setConnDensity(0) + try { + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE, execution.getVariable("globalSubscriberId"), + execution.getVariable("subscriptionServiceType"), sliceserviceInstanceId, serviceProfileID) + client.create(uri, serviceProfile) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + } + + void instantiateSliceService(DelegateExecution execution) { + + ServiceDecomposition serviceDecomposition= execution.getVariable("sliceServiceDecomposition") + String uuiRequest = execution.getVariable("uuiRequest") + ModelInfo modelInfo = serviceDecomposition.getModelInfo() + String serviceRole = "e2eslice-service" + String serviceType = execution.getVariable("serviceType") + Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") + String ssInstanceId = execution.getVariable("serviceInstanceId") + try { + org.onap.aai.domain.yang.ServiceInstance ss = new org.onap.aai.domain.yang.ServiceInstance() + ss.setServiceInstanceId(ssInstanceId) + String sliceInstanceName = execution.getVariable("serviceInstanceName") + ss.setServiceInstanceName(sliceInstanceName) + ss.setServiceType(serviceType) + String serviceStatus = "deactivated" + ss.setOrchestrationStatus(serviceStatus) + String modelInvariantUuid = modelInfo.getModelInvariantUuid() + String modelUuid = modelInfo.getModelUuid() + ss.setModelInvariantId(modelInvariantUuid) + ss.setModelVersionId(modelUuid) + String serviceInstanceLocationid = serviceProfile.get("plmnIdList") + ss.setServiceInstanceLocationId(serviceInstanceLocationid) + String snssai = serviceProfile.get("sNSSAI") + ss.setEnvironmentContext(snssai) + ss.setServiceRole(serviceRole) + AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), ssInstanceId) + client.create(uri, ss) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + + def rollbackData = execution.getVariable("RollbackData") + if (rollbackData == null) { + rollbackData = new RollbackData(); + } + //rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) + rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") + rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", ssInstanceId) + rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType")) + rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) + execution.setVariable("rollbackData", rollbackData) + execution.setVariable("RollbackData", rollbackData) + logger.debug("RollbackData:" + rollbackData) + + } + + + void createAllottedResource(DelegateExecution execution) { + String serviceInstanceId = execution.getVariable('sliceserviceInstanceId') + + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri ssServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId) + +// try { +// +// if(resourceClient.exists(ssServiceuri)){ +// execution.setVariable("ssi_resourceLink", uri.build().toString()) +// }else{ +// exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai to " + +// "associate allotted resource for service :"+serviceInstanceId) +// } +// }catch(BpmnError e) { +// throw e; +// }catch (Exception ex){ +// String msg = "Exception in getServiceInstance. " + ex.getMessage() +// logger.debug(msg) +// exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) +// } + + try { + String allottedResourceId = execution.getVariable("allottedResourceId") + ServiceDecomposition serviceDecomposition = execution.getVariable("sliceServiceDecomposition") + List<org.onap.so.bpmn.core.domain.AllottedResource> allottedResourceList = serviceDecomposition.getAllottedResources() + for(org.onap.so.bpmn.core.domain.AllottedResource allottedResource : allottedResourceList) + { + //AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceFromParentURI(ssServiceuri, AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId) + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, + execution.getVariable("globalSubscriberId"),execution.getVariable("subscriptionServiceType"), + execution.getVariable("sliceserviceInstanceId"), allottedResourceId) + execution.setVariable("allottedResourceUri", allottedResourceUri) + String arType = allottedResource.getAllottedResourceType() + String arRole = allottedResource.getAllottedResourceRole() + String modelInvariantId = allottedResource.getModelInfo().getModelInvariantUuid() + String modelVersionId = allottedResource.getModelInfo().getModelUuid() + + org.onap.aai.domain.yang.AllottedResource resource = new org.onap.aai.domain.yang.AllottedResource() + resource.setId(allottedResourceId) + resource.setType(arType) + resource.setAllottedResourceName("Allotted_"+ execution.getVariable("serviceInstanceName")) + resource.setRole(arRole) + resource.setModelInvariantId(modelInvariantId) + resource.setModelVersionId(modelVersionId) + getAAIClient().create(allottedResourceUri, resource) + //AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath(ssServiceuri).build()) + //getAAIClient().connect(allottedResourceUri,ssServiceuri) + } + //execution.setVariable("aaiARPath", allottedResourceUri.build().toString()); + + }catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception in createAaiAR " + ex.getMessage()) + } + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy new file mode 100644 index 0000000000..c66a89b9c6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy @@ -0,0 +1,524 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import com.fasterxml.jackson.core.type.TypeReference +import groovy.json.JsonBuilder +import groovy.json.JsonSlurper +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.RelationshipList +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.beans.nsmf.SliceTaskParams +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.OofUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceProxy +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +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.db.request.client.RequestsDbClient +import org.onap.so.db.request.beans.OrchestrationTask +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response + +import static org.apache.commons.lang3.StringUtils.isBlank + +public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ + + private static final Logger logger = LoggerFactory.getLogger( DoCreateSliceServiceOption.class) + + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + JsonUtils jsonUtil = new JsonUtils() + + RequestsDbClient requestsDbClient = new RequestsDbClient() + + OofUtils oofUtils = new OofUtils() + + /** + * Pre Process the BPMN Flow Request + * Inclouds: + * generate the nsOperationKey + * generate the nsParameters + */ + void preProcessRequest (DelegateExecution execution) { + String msg = "" + logger.trace("Enter preProcessRequest()") + String taskID = execution.getVariable("taskID") + Boolean isSharable = true + String resourceSharingLevel = execution.getVariable("resourceSharingLevel") + if (resourceSharingLevel.equals("shared")) + isSharable = true + execution.setVariable("isSharable",isSharable) + logger.trace("Exit preProcessRequest") + + } + + + void getNSIOptionfromOOF(DelegateExecution execution) { + + String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) + logger.debug( "get NSI option OOF Url: " + urlString) + boolean isNSISuggested = true + execution.setVariable("isNSISuggested",isNSISuggested) + String nsiInstanceId = "" + String nsiName = "" + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + //Prepare auth for OOF - Begin + def authHeader = "" + String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution) + String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + + String basicAuthValue = utils.encrypt(basicAuth, msokey) + if (basicAuthValue != null) { + logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue) + try { + authHeader = utils.getBasicAuth(basicAuthValue, msokey) + execution.setVariable("BasicAuthHeaderValue", authHeader) + } catch (Exception ex) { + logger.debug( "Unable to encode username and password string: " + ex) + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " + + "encode username and password string") + } + } else { + logger.debug( "Unable to obtain BasicAuth - BasicAuth value null") + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " + + "value null") + } + //Prepare auth for OOF - End + + String requestId = execution.getVariable("msoRequestId") + Map<String, Object> profileInfo = execution.getVariable("serviceProfile") + String nstModelUuid = execution.getVariable("nstModelUuid") + String nstModelInvariantUuid = execution.getVariable("nstModelInvariantUuid") + String nstInfo = """"NSTInfo" : { + "invariantUUID":"${nstModelInvariantUuid}", + "UUID":"${nstModelUuid}" + }""" + + String oofRequest = oofUtils.buildSelectNSIRequest(execution, requestId, nstInfo, profileInfo) + + //send request to get NSI option - Begin + URL url = new URL(urlString+"/api/oof/v1/selectnsi") + HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.OOF) + httpClient.addAdditionalHeader("Authorization", authHeader) + Response httpResponse = httpClient.post(oofRequest) + + int responseCode = httpResponse.getStatus() + logger.debug("OOF sync response code is: " + responseCode) + + if(responseCode != 200){ + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") + logger.debug("Info: No NSI suggested by OOF" ) + } + + if(httpResponse.hasEntity()){ + String OOFResponse = httpResponse.readEntity(String.class) + execution.setVariable("OOFResponse", OOFResponse) + int index = 0 //This needs to be changed to derive a value when we add policy to decide the solution options. + Map OOFResponseObject = new JsonSlurper().parseText(OOFResponse) + if(execution.getVariable("isSharable" ) == true && OOFResponseObject.get("solutions").containsKey("sharedNSIsolutions")) { + nsiInstanceId = OOFResponseObject.get("solutions").get("sharedNSIsolutions").get(0).get("NSISolution").NSIId + nsiName = OOFResponseObject.get("solutions").get("sharedNSIsolutions").get(0).get("NSISolution").NSIName + sliceTaskParams.setNstId(nsiInstanceId) + sliceTaskParams.setSuggestNsiName(nsiName) + execution.setVariable("nsiInstanceId",nsiInstanceId) + execution.setVariable("nsiName",nsiName) + }else { + if(OOFResponseObject.get("solutions").containsKey("newNSISolutions")) { + List NSSImap = OOFResponseObject.get("solutions").get("newNSISolutions").get(index).get("NSSISolutions") + for(Map nssi : NSSImap) { + String nssiName = nssi.get("NSSISolution").NSSIName + String nssiId = nssi.get("NSSISolution").NSSIId + String domain = nssi.get("NSSISolution").domain.toUpperCase() + switch (domain) { + case "AN": + sliceTaskParams.setAnSuggestNssiId(nssiId) + sliceTaskParams.setAnSuggestNssiName(nssiName) + break; + case "CN": + sliceTaskParams.setCnSuggestNssiId(nssiId) + sliceTaskParams.setCnSuggestNssiName(nssiName) + break; + case "TN": + sliceTaskParams.setTnSuggestNssiId(nssiId) + sliceTaskParams.setTnSuggestNssiName(nssiName) + break; + default: + break; + } + } + } + + } + execution.setVariable("sliceTaskParams", sliceTaskParams) + logger.debug("Info: No NSI suggested by OOF" ) + } + //send request to get NSI option - Begin + + + //send request to get NSI service Info - Begin + + /*** + * Need to check whether its needed. + */ +// logger.debug("Begin to query OOF suggetsed NSI from AAI ") +// if(isBlank(nsiInstanceId)){ +// isNSISuggested = false +// execution.setVariable("isNSISuggested",isNSISuggested) +// }else +// { +// try { +// String globalSubscriberId = execution.getVariable('globalSubscriberId') +// String serviceType = execution.getVariable('subscriptionServiceType') +// AAIResourcesClient resourceClient = new AAIResourcesClient() +// AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nsiInstanceId) +// AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class) +// Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class) +// org.onap.aai.domain.yang.ServiceInstance nsiServiceInstance = si.get() +// execution.setVariable("nsiServiceInstance",nsiServiceInstance) +// isNSISuggested = true +// execution.setVariable("isNSISuggested",isNSISuggested) +// SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") +// sliceTaskParams.setSuggestNsiId(nsiInstanceId) +// sliceTaskParams.setSuggestNsiName(si.get().getServiceInstanceName()) +// execution.setVariable("sliceTaskParams", sliceTaskParams) +// logger.debug("Info: NSI suggested by OOF exist in AAI ") +// }catch(BpmnError e) { +// throw e +// }catch(Exception ex) { +// String msg = "Internal Error in getServiceInstance: " + ex.getMessage() +// //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) +// logger.debug("Info: NSI suggested by OOF doesnt exist in AAI " + nsiInstanceId) +// } +// } + //send request to get NSI service Info - End + //${OrchestrationTaskHandler.createOrchestrationTask(execution.getVariable("OrchestrationTask"))} + logger.debug( "*** Completed options Call to OOF ***") + + } + + + public void parseServiceProfile(DelegateExecution execution) { + logger.debug("Start parseServiceProfile") + String serviceType = execution.getVariable("serviceType") + Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") + + // set sliceProfile for three domains + Map<String, Object> sliceProfileTn = getSliceProfile(serviceType, "TN", serviceProfile) + Map<String, Object> sliceProfileCn = getSliceProfile(serviceType, "CN", serviceProfile) + Map<String, Object> sliceProfileAn = getSliceProfile(serviceType, "AN", serviceProfile) + + execution.setVariable("sliceProfileTn", sliceProfileTn) + execution.setVariable("sliceProfileCn", sliceProfileCn) + execution.setVariable("sliceProfileAn", sliceProfileAn) + logger.debug("sliceProfileTn: " + sliceProfileTn) + logger.debug("sliceProfileCn: " + sliceProfileCn) + logger.debug("sliceProfileAn: " + sliceProfileAn) + + logger.debug("Finish parseServiceProfile") + } + + public Map getSliceProfile(String serviceType, String domain, Map<String, Object> serviceProfile) { + String variablePath = "nsmf." + serviceType + ".profileMap" + domain + String profileMapStr = UrnPropertiesReader.getVariable(variablePath) + logger.debug("Profile map for " + domain + " : " + profileMapStr) + Map<String, String> profileMaps = objectMapper.readValue(profileMapStr, new TypeReference<Map<String, String>>(){}) + Map<String, Object> sliceProfileTn = [:] + for (Map.Entry<String, String> profileMap : profileMaps) { + sliceProfileTn.put(profileMap.key, serviceProfile.get(profileMap.value)) + } + + return sliceProfileTn + } + + + void prepareNSSIList(DelegateExecution execution) + { + ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition") + List<String> nssiAssociated = new ArrayList<>() + Map<String, String> nssimap = new HashMap<>() + String nsiInstanceId=execution.getVariable("nsiInstanceId") + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("subscriptionServiceType") + + try { + + ServiceInstance si = execution.getVariable("nsiServiceInstance") + //List<Relationship> relationships = si.getRelationshipList().getRelationship().stream().filter(relation -> + // relation.getRelatedTo().equalsIgnoreCase("service-instance")) + RelationshipList relationshipList = si.getRelationshipList() + List<Relationship> relationships = relationshipList.getRelationship() + for(Relationship relationship in relationships) + { + if(relationship.getRelatedTo().equalsIgnoreCase("service-instance")) + { + String NSSIassociated = relationship.getRelatedLink().substring(relationship.getRelatedLink().lastIndexOf("/") + 1); + if(!NSSIassociated.equals(nsiInstanceId)) + nssiAssociated.add(NSSIassociated) + } + } + }catch(BpmnError e) { + throw e + }catch(Exception ex) { + String msg = "Internal Error in getServiceInstance: " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + Map<String, Object> params = execution.getVariable("params") + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + for(String nssiID in nssiAssociated) + { + try { + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nssiID) + AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class) + Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class) + org.onap.aai.domain.yang.ServiceInstance nssi = si.get() + + String domain = nssi.getEnvironmentContext().toString().toUpperCase() + switch (domain) { + case "AN": + sliceTaskParams.setAnSuggestNssiId(nssi.getServiceInstanceId()) + sliceTaskParams.setAnSuggestNssiName(nssi.getServiceInstanceName()) + break; + case "CN": + sliceTaskParams.setCnSuggestNssiId(nssi.getServiceInstanceId()) + sliceTaskParams.setCnSuggestNssiName(nssi.getServiceInstanceName()) + break; + case "TN": + sliceTaskParams.setTnSuggestNssiId(nssi.getServiceInstanceId()) + sliceTaskParams.setTnSuggestNssiName(nssi.getServiceInstanceName()) + break; + default: + break; + } + }catch(NotFoundException e) + { + logger.debug("NSSI Service Instance not found in AAI: " + nssiID) + }catch(Exception e) + { + logger.debug("NSSI Service Instance not found in AAI: " + nssiID) + } + + } + String nstName = serviceDecomposition.getModelInfo().getModelName() + sliceTaskParams.setNstName(nstName) + String nstId = serviceDecomposition.getModelInfo().getModelUuid() + sliceTaskParams.setNstId(nstId) + execution.setVariable("sliceTaskParams",sliceTaskParams) + + } + + + void updateOptionsInDB(DelegateExecution execution) { + logger.debug("Updating options with default value since not sharable : Begin ") + String taskID = execution.getVariable("taskID") + String params = execution.getVariable("params") + logger.debug("Updating options with default value since not sharable : End ") + + } + + void prepareNSTDecompose(DelegateExecution execution) { + + String modelUuid = execution.getVariable("nstModelUuid") + String modelInvariantUuid = execution.getVariable("nstModelInvariantUuid") + + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + } + + void prepareNSSTDecompose(DelegateExecution execution) { + Boolean isMoreNSSTtoProcess = false + Integer maxNSST = execution.getVariable("maxNSST") + Integer currentNSST=execution.getVariable("currentNSST") + List<String> nsstModelUUIDList = new ArrayList<>() + nsstModelUUIDList = execution.getVariable("nsstModelUUIDList") + String modelUuid = nsstModelUUIDList.get(currentNSST) + String serviceModelInfo = """{ + "modelInvariantUuid":"", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + currentNSST=currentNSST+1 + if(currentNSST<maxNSST) + isMoreNSSTtoProcess=true + execution.setVariable("isMoreNSSTtoProcess",isMoreNSSTtoProcess) + execution.setVariable("maxNSST",maxNSST) + execution.setVariable("currentNSST",currentNSST) + } + + + void updateStatusInDB(DelegateExecution execution) { + + String taskID = execution.getVariable("taskID") + //OrchestrationTask orchestrationTask = requestsDbClient.getNetworkSliceOption(taskID); + //orchestrationTask.setTaskStage("wait to confirm") + //requestsDbClient.updateNetworkSliceOption(orchestrationTask) + } + + void prepareNSSTlistfromNST(DelegateExecution execution) { + //Need to update this part from decomposition. + logger.trace("Enter prepareNSSTlistfromNST()") + Boolean isMoreNSSTtoProcess = false + ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition") + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + String nstName = serviceDecomposition.getModelInfo().getModelName() + sliceTaskParams.setNstName(nstName) + String nstId = serviceDecomposition.getModelInfo().getModelUuid() + sliceTaskParams.setNstId(nstId) + execution.setVariable("sliceTaskParams",sliceTaskParams) + + List<ServiceProxy> proxyList = serviceDecomposition.getServiceProxy() + List<String> nsstModelUUIDList = new ArrayList<>() + for(ServiceProxy serviceProxy:proxyList) + nsstModelUUIDList.add(serviceProxy.getSourceModelUuid()) + execution.setVariable("nsstModelUUIDList",nsstModelUUIDList) + Integer maxNSST = nsstModelUUIDList.size() + Integer currentNSST=0 + execution.setVariable("maxNSST",maxNSST) + execution.setVariable("currentNSST",currentNSST) + if(currentNSST<maxNSST) + isMoreNSSTtoProcess=true + execution.setVariable("isMoreNSSTtoProcess",isMoreNSSTtoProcess) + logger.trace("Exit prepareNSSTlistfromNST()") + + } + + + void getNSSTOption(DelegateExecution execution) { + ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition") + String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String serviceType = execution.getVariable("subscriptionServiceType") + String nssiInstanceId ="" + String nssiName ="" + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + logger.debug( "get NSI option OOF Url: " + urlString) + boolean isNSISuggested = false + execution.setVariable("isNSISuggested",isNSISuggested) + + //Prepare auth for OOF - Begin + def authHeader = "" + String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution) + String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution) + + String basicAuthValue = utils.encrypt(basicAuth, msokey) + if (basicAuthValue != null) { + logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue) + try { + authHeader = utils.getBasicAuth(basicAuthValue, msokey) + execution.setVariable("BasicAuthHeaderValue", authHeader) + } catch (Exception ex) { + logger.debug( "Unable to encode username and password string: " + ex) + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " + + "encode username and password string") + } + } else { + logger.debug( "Unable to obtain BasicAuth - BasicAuth value null") + exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " + + "value null") + } + //Prepare auth for OOF - End + //Prepare send request to OOF - Begin + String requestId = execution.getVariable("msoRequestId") + Map<String, Object> profileInfo = execution.getVariable("serviceProfile") + String nsstModelInvariantUuid = serviceDecomposition.getModelInfo().getModelInvariantUuid() + String nsstModelUuid = serviceDecomposition.getModelInfo().getModelUuid() + String nsstInfo = """"NSSTInfo": { + "invariantUUID":"${nsstModelInvariantUuid}", + "UUID":"${nsstModelUuid}" + }""" + String oofRequest = oofUtils.buildSelectNSSIRequest(execution, requestId, nsstInfo ,profileInfo) + + + URL url = new URL(urlString+"/api/oof/v1/selectnssi") + HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.OOF) + httpClient.addAdditionalHeader("Authorization", authHeader) + Response httpResponse = httpClient.post(oofRequest) + + int responseCode = httpResponse.getStatus() + logger.debug("OOF sync response code is: " + responseCode) + + if(responseCode != 200){ + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") + } + + if(httpResponse.hasEntity()){ + String OOFResponse = httpResponse.readEntity(String.class) + execution.setVariable("OOFResponse", OOFResponse) + nssiInstanceId = jsonUtil.getJsonValue(OOFResponse, "NSSIIInfo.NSSIID") + nssiName = jsonUtil.getJsonValue(OOFResponse, "NSSIInfo.NSSIName") + execution.setVariable("nssiInstanceId",nssiInstanceId) + execution.setVariable("nssiName",nssiName) + } + if(isBlank(nssiInstanceId)){ + logger.debug( "There is no valid NSST suggested by OOF.") + }else + { + try { + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nssiInstanceId) + AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class) + Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class) + org.onap.aai.domain.yang.ServiceInstance nssi = si.get() + + String domain = nssi.getEnvironmentContext().toString().toUpperCase() + switch (domain) { + case "AN": + sliceTaskParams.setAnSuggestNssiId(nssi.getServiceInstanceId()) + sliceTaskParams.setAnSuggestNssiName(nssi.getServiceInstanceName()) + break; + case "CN": + sliceTaskParams.setCnSuggestNssiId(nssi.getServiceInstanceId()) + sliceTaskParams.setCnSuggestNssiName(nssi.getServiceInstanceName()) + break; + case "TN": + sliceTaskParams.setTnSuggestNssiId(nssi.getServiceInstanceId()) + sliceTaskParams.setTnSuggestNssiName(nssi.getServiceInstanceName()) + break; + default: + break; + } + }catch(NotFoundException e) + { + logger.debug("NSSI Service Instance not found in AAI: " + nssiInstanceId) + }catch(Exception e) + { + logger.debug("NSSI Service Instance not found in AAI: " + nssiInstanceId) + } + } + + + //Prepare send request to OOF - End + +// String content = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0).getContent() +// String nsstID = jsonUtil.getJsonValue(content, "metadata.id") +// String vendor = jsonUtil.getJsonValue(content, "metadata.vendor") +// String domain = jsonUtil.getJsonValue(content, "metadata.domainType") +// String type = jsonUtil.getJsonValue(content, "metadata.type") +// String nsstContentInfo = """{ +// "NsstID":"${nsstID}", +// "Vendor":"${vendor}", +// "type":"${type}" +// }""" + + logger.debug("Prepare NSSI option completed ") + } +} + diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy index d8897a2468..8d8e97328d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy @@ -76,7 +76,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * * @param execution */ - private void prepareDecomposeService(DelegateExecution execution) + void prepareDecomposeService(DelegateExecution execution) { LOGGER.trace(" *****${PREFIX} Start prepareDecomposeService *****") try @@ -103,7 +103,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * get vendor Info * @param execution */ - private void processDecomposition(DelegateExecution execution) { + void processDecomposition(DelegateExecution execution) { LOGGER.debug("*****${PREFIX} start processDecomposition *****") try { @@ -130,7 +130,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * send deallocate request to nssmf * @param execution */ - private void sendRequestToNSSMF(DelegateExecution execution) + void sendRequestToNSSMF(DelegateExecution execution) { LOGGER.debug("*****${PREFIX} start sendRequestToNSSMF *****") def currentNSSI = execution.getVariable("currentNSSI") @@ -160,7 +160,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor URL url = new URL(nssmfRequest) LOGGER.info("deallocate nssmfRequest:${nssmfRequest}, reqBody: ${json}") - HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) + HttpClient httpClient = getHttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) Response httpResponse = httpClient.post(json) checkNssmfResponse(httpResponse, execution) @@ -176,7 +176,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * send to nssmf query progress * @param execution */ - private void getJobStatus(DelegateExecution execution) + void getJobStatus(DelegateExecution execution) { def currentNSSI = execution.getVariable("currentNSSI") String jobId = currentNSSI['jobId'] @@ -198,7 +198,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor URL url = new URL(nssmfRequest) LOGGER.info("get deallocate job status, nssmfRequest:${nssmfRequest}, requestBody: ${json}") - HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) + HttpClient httpClient = getHttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) Response httpResponse = httpClient.post(json) checkNssmfResponse(httpResponse, execution) @@ -248,7 +248,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * prepare update requestdb * @param execution */ - private void handleJobStatus(DelegateExecution execution) + void handleJobStatus(DelegateExecution execution) { def currentNSSI = execution.getVariable("currentNSSI") int currentProgress = currentNSSI["jobProgress"] @@ -267,7 +267,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor LOGGER.debug("update operation, currentProgress=${currentProgress}, proportion=${proportion}, progress = ${progress}" ) } - private void timeDelay(DelegateExecution execution) { + void timeDelay(DelegateExecution execution) { try { Thread.sleep(10000); } catch(InterruptedException e) { @@ -279,7 +279,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * delete slice profile from aai * @param execution */ - private void delSliceProfileFromAAI(DelegateExecution execution) + void delSliceProfileFromAAI(DelegateExecution execution) { LOGGER.debug("*****${PREFIX} start delSliceProfileFromAAI *****") def currentNSSI = execution.getVariable("currentNSSI") @@ -291,12 +291,11 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor try { LOGGER.debug("delete nssiServiceInstanceId:${nssiServiceInstanceId}, profileId:${profileId}") - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, globalSubscriberId, serviceType, nssiServiceInstanceId, profileId) - if (!resourceClient.exists(resourceUri)) { + if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } - resourceClient.delete(resourceUri) + getAAIClient().delete(resourceUri) } catch (any) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy index 7c2a2be6ac..76086dab49 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy @@ -29,7 +29,6 @@ import org.onap.aai.domain.yang.SliceProfiles import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil 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 @@ -309,12 +308,11 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { String globalSubscriberId = execution.getVariable("globalSubscriberId") String serviceType = execution.getVariable("serviceType") - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(aaiObjectType, globalSubscriberId, serviceType, instanceId) - if (!resourceClient.exists(resourceUri)) { + if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg) } - AAIResultWrapper wrapper = resourceClient.get(resourceUri, NotFoundException.class) + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) LOGGER.trace(" *****${PREFIX} Exit queryAAI *****") return wrapper } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy new file mode 100644 index 0000000000..63cd3c72f9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy @@ -0,0 +1,463 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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.scripts + +import com.fasterxml.jackson.databind.ObjectMapper +import com.google.gson.Gson +import com.google.gson.reflect.TypeToken +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.beans.nsmf.* +import org.onap.so.bpmn.common.scripts.* +import org.onap.so.bpmn.common.util.OofInfraUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.ServiceArtifact +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.logger.ErrorCode +import org.onap.so.logger.LoggingAnchor +import org.onap.so.logger.MessageEnum +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.springframework.web.util.UriUtils + +import javax.ws.rs.core.Response +import java.lang.reflect.Type + +/** + * This class supports the DoCreateVnf building block subflow + * with the creation of a generic vnf for + * infrastructure. + * + */ +class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor { + + private static final Logger logger = LoggerFactory.getLogger( DoSendCommandToNSSMF.class); + String Prefix="DoCNSSMF_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils(this) + SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() + OofInfraUtils oofInfraUtils = new OofInfraUtils() + + /** + * This method gets and validates the incoming + * request. + * + * @param - execution + * + */ + public void preProcessRequest(DelegateExecution execution) { + + execution.setVariable("prefix",Prefix) + logger.debug("STARTED Do sendcommandtoNssmf PreProcessRequest Process") + + /*******************/ + try{ + // Get Variables + String e2eserviceInstanceId = execution.getVariable("e2eserviceInstanceId") + String serviceInstanceId = execution.getVariable("e2eserviceInstanceId") + execution.setVariable("e2eserviceInstanceId", e2eserviceInstanceId) + execution.setVariable("serviceInstanceId", serviceInstanceId) + logger.debug("Incoming e2eserviceInstanceId is: " + e2eserviceInstanceId) + + String NSIserviceid = execution.getVariable("NSIserviceid") + execution.setVariable("NSIserviceid", NSIserviceid) + logger.debug("Incoming NSI id is: " + NSIserviceid) + + + String nssiMap = execution.getVariable("nssiMap") + Type type = new TypeToken<HashMap<String, NSSI>>(){}.getType() + Map<String, NSSI> DonssiMap = new Gson().fromJson(nssiMap,type) + String strDonssiMap = mapToJsonStr(DonssiMap) + execution.setVariable("DonssiMap",strDonssiMap) + logger.debug("Incoming DonssiMap is: " + strDonssiMap) + + String requestId = execution.getVariable("msoRequestId") + execution.setVariable("msoRequestId", requestId) + + String operationType = execution.getVariable("operationType") + execution.setVariable("operationType", operationType) + logger.debug("Incoming operationType is: " + operationType) + + if (operationType == "activation") { + execution.setVariable("activationSequence","an,tn,cn") + }else { + execution.setVariable("activationSequence","cn,tn,an") + } + execution.setVariable("activationIndex",0) + execution.setVariable("miniute", "0") + execution.setVariable("activateNumberSlice",0) + + logger.info("the end !!") + }catch(BpmnError b){ + logger.debug("Rethrowing MSOWorkflowException") + throw b + }catch(Exception e){ + logger.info("the end of catch !!") + logger.debug(" Error Occured in DoSendCommandToNSSMF PreProcessRequest method!" + e.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoSendCommandToNSSMF PreProcessRequest") + + } + logger.trace("COMPLETED DoSendCommandToNSSMF PreProcessRequest Process") + } + private String mapToJsonStr(Map<String, NSSI> stringNSSIHashMap) { + HashMap<String, NSSI> map = new HashMap<String, NSSI>() + for(Map.Entry<String, NSSI> child:stringNSSIHashMap.entrySet()) + { + map.put(child.getKey(), child.getValue()) + } + return new Gson().toJson(map) + } + public void getNSSIformlist(DelegateExecution execution) { + + String nssiMap = execution.getVariable("DonssiMap") + Type type = new TypeToken<HashMap<String, NSSI>>(){}.getType() + Map<String, NSSI> DonssiMap = new Gson().fromJson(nssiMap,type) + String isNSSIActivate = execution.getVariable("isNSSIActivate") + + String activationSequence01 = execution.getVariable("activationSequence") + String[] strlist = activationSequence01.split(",") + + int activationIndex = execution.getVariable("activationIndex") + int indexcurrent = 0 + if (isNSSIActivate == "true") + { + execution.setVariable("isGetSuccessfull", "false") + }else{for (int index = activationIndex; index < 3;index++) { + String domaintype01 = strlist[index] + if (DonssiMap.containsKey(domaintype01)) { + NSSI nssiobject = DonssiMap.get(domaintype01) + execution.setVariable("domainType", domaintype01) + execution.setVariable("nssiId", nssiobject.getNssiId()) + execution.setVariable("modelInvariantUuid", nssiobject.getModelInvariantId()) + execution.setVariable("modelUuid", nssiobject.getModelVersionId()) + execution.setVariable("isGetSuccessfull", "true") + String modelInvariantUuid = execution.getVariable("modelInvariantUuid") + String modelUuid = execution.getVariable("modelUuid") + //here modelVersion is not set, we use modelUuid to decompose the service. + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + indexcurrent = index + execution.setVariable("activationIndex", indexcurrent) + break + }else + { + indexcurrent = index + 1 + + } + } + if ( activationIndex > 2) { + execution.setVariable("isGetSuccessfull", "false") + } + execution.setVariable("activationIndex", indexcurrent)} + + } + /** + * get vendor Info + * @param execution + */ + private void processDecomposition(DelegateExecution execution) { + logger.debug("***** processDecomposition *****") + + try { + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") as ServiceDecomposition + ServiceArtifact serviceArtifact = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0) + String content = serviceArtifact.getContent() + String vendor = jsonUtil.getJsonValue(content, "metadata.vendor") + //String domainType = jsonUtil.getJsonValue(content, "metadata.domainType") + + execution.setVariable("vendor", vendor) + // currentNSSI['domainType'] = domainType + logger.info("processDecomposition, current vendor-domainType:" + vendor) + + } catch (any) { + String exceptionMessage = "Bpmn error encountered in deallocate nssi. processDecomposition() - " + any.getMessage() + logger.debug(exceptionMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + logger.debug("***** Exit processDecomposition *****") + } + public void UpdateIndex(DelegateExecution execution) { + def activationIndex = execution.getVariable("activationIndex") + int activateNumberSlice = execution.getVariable("activateNumberSlice") as Integer + def activationCount= execution.getVariable("activationCount") + //DecimalFormat df1 = new DecimalFormat("##%") + int rate = (activateNumberSlice / activationCount) * 100 + if (rate == 100) + { + execution.setVariable("isNSSIActivate","true") + } + else{ + execution.setVariable("isNSSIActivate","false") + } + activationIndex = activationIndex + 1 + execution.setVariable("activationIndex",activationIndex) + logger.trace("the Progress of activation is " + rate.toString() + "%" ) + try{ + String serviceId = execution.getVariable("serviceInstanceId") + String operationId = UUID.randomUUID().toString() + String operationType = execution.getVariable("operationType") + String userId = "" + String result = (operationType.equals("activation"))? "ACTIVATING": "DEACTIVATING" + int progress = rate + String reason = "" + String operationContent = "Service activation in progress" + logger.debug("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId) + serviceId = UriUtils.encode(serviceId,"UTF-8") + execution.setVariable("e2eserviceInstanceId", serviceId) + execution.setVariable("operationId", operationId) + execution.setVariable("operationType", operationType) + + def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint",execution) + execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) + logger.debug("DB Adapter Endpoint is: " + dbAdapterEndpoint) + + String payload = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:initServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId> + <operationId>${MsoUtils.xmlEscape(operationId)}</operationId> + <operationType>${MsoUtils.xmlEscape(operationType)}</operationType> + <userId>${MsoUtils.xmlEscape(userId)}</userId> + <result>${MsoUtils.xmlEscape(result)}</result> + <operationContent>${MsoUtils.xmlEscape(operationContent)}</operationContent> + <progress>${MsoUtils.xmlEscape(progress)}</progress> + <reason>${MsoUtils.xmlEscape(reason)}</reason> + </ns:initServiceOperationStatus> + </soapenv:Body> + </soapenv:Envelope>""" + + payload = utils.formatXml(payload) + execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload) + logger.debug("Outgoing CVFMI_updateServiceOperStatusRequest: \n" + payload) + + }catch(Exception e){ + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + "Exception Occured Processing Activate Slice .", "BPMN", + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e) + execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during Activate Slice Method:\n" + e.getMessage()) + } + logger.trace("finished Activate Slice") + } + public void WaitForReturn(DelegateExecution execution) { + //logger.debug("Query : "+ Jobid) + def miniute=execution.getVariable("miniute") + Thread.sleep(10000) + int miniute01 = Integer.parseInt(miniute) + 1 + logger.debug("waiting for : "+ miniute + "miniutes") + execution.setVariable("miniute", String.valueOf(miniute01)) + } + public void GetTheStatusOfActivation(DelegateExecution execution) { + + String snssai= execution.getVariable("snssai") + String domaintype = execution.getVariable("domainType") + String NSIserviceid=execution.getVariable("NSIserviceid") + String nssiId = execution.getVariable("nssiId") + String Jobid=execution.getVariable("JobId") + def miniute=execution.getVariable("miniute") + String vendor = execution.getVariable("vendor") + String jobstatus ="error" + + + logger.debug("Query the jobid activation of SNSSAI: "+ Jobid) + logger.debug("the domain is : "+ domaintype) + logger.debug("the NSSID is : "+nssiId) + logger.debug("the NSIserviceid is : "+NSIserviceid) + + JobStatusRequest jobStatusRequest = new JobStatusRequest() + + EsrInfo info = new EsrInfo() + info.setNetworkType(NetworkType.fromString(domaintype)) + info.setVendor(vendor) + + jobStatusRequest.setNsiId(NSIserviceid) + jobStatusRequest.setNssiId(nssiId) + jobStatusRequest.setEsrInfo(info) + + + ObjectMapper mapper = new ObjectMapper() + String Reqjson = mapper.writeValueAsString(jobStatusRequest) + String isActivateSuccessfull=false + + String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution) + String nssmfRequest = urlString + "/api/rest/provMns/v1/NSS/jobs/" +Jobid + + //send request to active NSSI TN option + URL url = new URL(nssmfRequest) + + HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) + Response httpResponse = httpClient.post(Reqjson) + + int responseCode = httpResponse.getStatus() + logger.debug("NSSMF activation response code is: " + responseCode) + + if (responseCode == 404) { + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad job status Response from NSSMF.") + isActivateSuccessfull = false + execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) + jobstatus="error" + }else if(responseCode == 200) { + if (httpResponse.hasEntity()) { + JobStatusResponse jobStatusResponse = httpResponse.readEntity(JobStatusResponse.class) + execution.setVariable("statusDescription", jobStatusResponse.getResponseDescriptor().getStatusDescription()) + jobstatus = jobStatusResponse.getResponseDescriptor().getStatus() + switch(jobstatus) { + case "started": + case "processing": + isActivateSuccessfull = "waitting" + execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) + break + case "finished": + isActivateSuccessfull = "true" + execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) + execution.setVariable("activateNumberSlice",execution.getVariable("activateNumberSlice")+ 1) + break + case "error": + default: + isActivateSuccessfull = "false" + execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) + + } + if(Integer.parseInt(miniute) > 6 ) + { + isActivateSuccessfull = "false" + execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a timeout job status Response from NSSMF.") + } + }else + { + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad job status Response from NSSMF.") + isActivateSuccessfull = false + execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) + } + } else { + isActivateSuccessfull = false + execution.setVariable("isActivateSuccessfull", isActivateSuccessfull) + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad job status Response from NSSMF.") + } + } + public void SendCommandToNssmf(DelegateExecution execution) { + + String snssai= execution.getVariable("snssai") + String domaintype = execution.getVariable("domainType") + String NSIserviceid=execution.getVariable("NSIserviceid") + String nssiId = execution.getVariable("nssiId") + String vendor = execution.getVariable("vendor") + + + logger.debug("the domain is : "+domaintype) + logger.debug("SNSSAI: "+snssai +" will be activated") + logger.debug("the NSSID is : "+nssiId) + logger.debug("the NSIserviceid is : "+NSIserviceid) + + EsrInfo esr = new EsrInfo(); + esr.setNetworkType(NetworkType.fromString(domaintype)) + esr.setVendor(vendor) + + ActDeActNssi actNssi = new ActDeActNssi(); + actNssi.setNsiId(NSIserviceid); + actNssi.setNssiId(nssiId); + NssiActDeActRequest actRequest = new NssiActDeActRequest(); + actRequest.setActDeActNssi(actNssi); + actRequest.setEsrInfo(esr) + + ObjectMapper mapper = new ObjectMapper(); + String json = mapper.writeValueAsString(actRequest); + + + String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution) + + //Prepare auth for NSSMF - Begin + def authHeader = "" + String basicAuth = UrnPropertiesReader.getVariable("mso.nssmf.auth", execution) + String operationType = execution.getVariable("operationType") + + String nssmfRequest = urlString + "/api/rest/provMns/v1/NSS/" + snssai + "/" + operationType + + //send request to active NSSI TN option + URL url = new URL(nssmfRequest) + + HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) + Response httpResponse = httpClient.post(json) + + int responseCode = httpResponse.getStatus() + logger.debug("NSSMF activate response code is: " + responseCode) + checkNssmfResponse(httpResponse, execution) + + NssiResponse nssmfResponse = httpResponse.readEntity(NssiResponse.class) + String jobId = nssmfResponse.getJobId() ?: "" + execution.setVariable("JobId", jobId) + + } + private void checkNssmfResponse(Response httpResponse, DelegateExecution execution) { + int responseCode = httpResponse.getStatus() + logger.debug("NSSMF response code is: " + responseCode) + + if ( responseCode < 200 || responseCode > 202 || !httpResponse.hasEntity()) { + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Response from NSSMF.") + String isNSSIActivated = "false" + execution.setVariable("isNSSIActivated", isNSSIActivated) + execution.setVariable("isNSSIActivate","false") + }else{ + String isNSSIActivated = "true" + execution.setVariable("isNSSIActivated", isNSSIActivated) + } + } + + + void sendSyncError (DelegateExecution execution) { + logger.trace("start sendSyncError") + try { + String errorMessage = "" + if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + WorkflowException wfe = execution.getVariable("WorkflowException") + errorMessage = wfe.getErrorMessage() + } else { + errorMessage = "Sending Sync Error." + } + + String buildworkflowException = + """<aetgt:WorkflowException xmlns:aetgt="http://org.onap/so/workflow/schema/v1"> + <aetgt:ErrorMessage>${MsoUtils.xmlEscape(errorMessage)}</aetgt:ErrorMessage> + <aetgt:ErrorCode>7000</aetgt:ErrorCode> + </aetgt:WorkflowException>""" + + logger.debug(buildworkflowException) + sendWorkflowResponse(execution, 500, buildworkflowException) + + } catch (Exception ex) { + logger.debug("Sending Sync Error Activity Failed. " + "\n" + ex.getMessage()) + } + logger.trace("finished sendSyncError") + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java index fab3496559..3ea8b190ad 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java @@ -35,8 +35,10 @@ public class ExecutionVariableNames { public final static String TIMEOUT_FOR_NOTIFICATION = "timeoutForPnfEntryNotification"; public final static String PNF_UUID = "pnfUuid"; public final static String SERVICE_INSTANCE_ID = "serviceInstanceId"; + public final static String REQUEST_ID = "requestId"; public final static String MSO_REQUEST_ID = "msoRequestId"; public final static String MODEL_UUID = "modelUuid"; + public final static String REQUEST_PAYLOAD = "requestPayload"; public final static String SERVICE_MODEL_INFO = "serviceModelInfo"; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java index 4482d2a327..6c140061c0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java @@ -69,7 +69,7 @@ public class NfSoftwareUpgradeDispatcher implements JavaDelegate { @Override public void execute(DelegateExecution delegateExecution) throws Exception { - logger.debug("Running execute block for activity id:{}, name:{}", delegateExecution.getCurrentActivityId(), + logger.debug("Running execute block for activity id: {}, name: {}", delegateExecution.getCurrentActivityId(), delegateExecution.getCurrentActivityName()); RequestDetails bpmnRequestDetails = requestVerification(delegateExecution); @@ -82,9 +82,10 @@ public class NfSoftwareUpgradeDispatcher implements JavaDelegate { final List<PnfResourceCustomization> pnfCustomizations = getPnfResourceCustomizations(delegateExecution, serviceModelUuid); final PnfResourceCustomization pnfResourceCustomization = pnfCustomizations.get(0); + final String payload = bpmnRequestDetails.getRequestParameters().getPayload(); populateExecution(delegateExecution, bpmnRequestDetails, pnfResourceCustomization, pnf, serviceInstanceName, - pnfName, serviceModelUuid, userParams); + pnfName, serviceModelUuid, userParams, payload); logger.trace("Completed preProcessRequest PnfSoftwareUpgradeServiceRequest Request "); } @@ -104,7 +105,7 @@ public class NfSoftwareUpgradeDispatcher implements JavaDelegate { private void populateExecution(DelegateExecution delegateExecution, RequestDetails bpmnRequestDetails, PnfResourceCustomization pnfResourceCustomization, Pnf pnf, String serviceInstanceName, String pnfName, - String serviceModelUuid, List<Map<String, Object>> userParams) { + String serviceModelUuid, List<Map<String, Object>> userParams, String payload) { delegateExecution.setVariable(SERVICE_MODEL_INFO, bpmnRequestDetails.getModelInfo()); delegateExecution.setVariable(SERVICE_INSTANCE_NAME, serviceInstanceName); @@ -124,6 +125,8 @@ public class NfSoftwareUpgradeDispatcher implements JavaDelegate { delegateExecution.setVariable(param.get("name").toString(), param.get("value").toString()); } } + + delegateExecution.setVariable(REQUEST_PAYLOAD, payload); } private Pnf getPnfByPnfName(DelegateExecution delegateExecution, String pnfName) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationServiceTest.groovy new file mode 100644 index 0000000000..7e02779f10 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationServiceTest.groovy @@ -0,0 +1,224 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.so.bpmn.common.scripts.MsoGroovyTest + +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +class ActivateCommunicationServiceTest extends MsoGroovyTest { + + @Before + void init() throws IOException { + super.init("ActivateCommunicationService") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest() { + + String req = """ + { + "globalSubscriberId": "5GCustomer", + "serviceType": "5G", + "operationId": "test123" + } + """ + when(mockExecution.getVariable("bpmnRequest")).thenReturn(req) + when(mockExecution.getVariable("mso-request-id")).thenReturn("54321") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + + + ActivateCommunicationService service = new ActivateCommunicationService() + service.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(5)).setVariable(captor.capture(), captor.capture()) + } + + @Test + void testPrepareInitOperationStatus() { + + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111") + + ActivateCommunicationService service = new ActivateCommunicationService() + + service.prepareInitOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String res = captor.getValue() + assertNotNull(res) + } + + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("operationId")).thenReturn("123456") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + ActivateCommunicationService service = new ActivateCommunicationService() + service.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertEquals(updateVolumeGroupRequest, true) + } + + @Test + void testPreRequestSend2NSMF() { + when(mockExecution.getVariable("e2e_service-instance.service-instance-id")).thenReturn("12333") + when(mockExecution.getVariable("requestParam")).thenReturn("activate") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("test111") + when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("5GConsumer") + ActivateCommunicationService service = new ActivateCommunicationService() + service.preRequestSend2NSMF(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("CSMF_NSMFRequest"), captor.capture()) + String resultSuccess = captor.getValue() + + String expect = """ + { + "globalSubscriberId":"test111", + "serviceType":"5GConsumer" + } + """ + assertEquals(expect.replaceAll("\\s+", ""), resultSuccess.replaceAll("\\s+", "")) + } + + @Test + void testProcessNSMFResponseSuccess() { + when(mockExecution.getVariable("CSMF_NSMFResponseCode")).thenReturn(202) + when(mockExecution.getVariable("CSMF_NSMFResponse")).thenReturn(""" + { + "operationId": "e3819a23-3777-4172-a834-35ee78acf3f4" + } + """) + + ActivateCommunicationService service = new ActivateCommunicationService() + service.processNSMFResponse(mockExecution) + Mockito.verify(mockExecution, times(2)).setVariable(captor.capture(), captor.capture()) + def resultSuccess = captor.getAllValues() + + def expect = new ArrayList<>() + expect.add("e2eOperationId") + expect.add("e3819a23-3777-4172-a834-35ee78acf3f4") + expect.add("ProcessNsmfSuccess") + expect.add("OK") + assertEquals(expect, resultSuccess) + } + + @Test + void testProcessNSMFResponseError() { + when(mockExecution.getVariable("CSMF_NSMFResponseCode")).thenReturn(500) + ActivateCommunicationService service = new ActivateCommunicationService() + service.processNSMFResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("ProcessNsmfSuccess"), captor.capture()) + String resultSuccess = captor.getValue() + assertEquals("ERROR", resultSuccess) + } + + @Test + void testPrepareUpdateOperationStatus() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + when(mockExecution.getVariable("operationType")).thenReturn("activate") + + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111") + when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint")) + .thenReturn("http://localhost:28090/dbadapters/RequestsDbAdapter") + ActivateCommunicationService service = new ActivateCommunicationService() + + service.prepareUpdateOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String res = captor.getValue() + + String expect = getExpectPayload("updateServiceOperationStatus", "processing", "20", + "communication service activate operation processing: waiting nsmf service create finished") + + assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", "")) + } + + private static getExpectPayload = { String type, String result, String progress, String operationContent -> + String expect = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:${type} xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>12345</serviceId> + <operationId>54321</operationId> + <operationType>activate</operationType> + <userId>11111</userId> + <result>${result}</result> + <operationContent>${operationContent}</operationContent> + <progress>${progress}</progress> + <reason></reason> + </ns:${type}> + </soapenv:Body> + </soapenv:Envelope> + """ + return expect + } + + @Test + void testPrepareCallCheckProcessStatus() { + ActivateCommunicationService service = new ActivateCommunicationService() + service.prepareCallCheckProcessStatus(mockExecution) + Mockito.verify(mockExecution, times(9)).setVariable(captor.capture(), captor.capture()) + def resultSuccess = captor.getAllValues() + assertNotNull(resultSuccess) + } + + @Test + void testPrepareCompleteStatus() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + when(mockExecution.getVariable("operationType")).thenReturn("activate") + when(mockExecution.getVariable("operationContent")) + .thenReturn("communication service activate operation finished") + + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111") + when(mockExecution.getVariable("operationStatus")) + .thenReturn("deactivated") + ActivateCommunicationService service = new ActivateCommunicationService() + + service.prepareCompleteStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String res = captor.getValue() + + String expect = getExpectPayload("updateServiceOperationStatus", "deactivated", "100", + "communication service activate operation finished") + + assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", "")) + } + +} + + diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy new file mode 100644 index 0000000000..8c08e51efe --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy @@ -0,0 +1,308 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +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 javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response + +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.* + +class DeleteCommunicationServiceTest extends MsoGroovyTest { + + private HttpClientFactory httpClientFactoryMock + private HttpClient httpClientMock + + @Before + void init() throws IOException { + super.init("DeleteCommunicationServiceTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "globalSubscriberId ":"5GCustomer", + "serviceType ":"5G" + }""".replaceAll("\\\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82") + + DeleteCommunicationService delCS = new DeleteCommunicationService() + delCS.preProcessRequest(mockExecution) + Mockito.verify(mockExecution,times(3)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testPreInitUpdateOperationStatus(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("result")).thenReturn("processing") + when(mockExecution.getVariable("progress")).thenReturn("0") + when(mockExecution.getVariable("operationContent")).thenReturn("delete communication service operation start") + + DeleteCommunicationService delCS = new DeleteCommunicationService() + delCS.preInitUpdateOperationStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testQueryCommunicationSeriveFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DeleteCommunicationService obj = spy(DeleteCommunicationService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQueryCommunicationServiceReturn()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.queryCommunicationSeriveFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("e2eSliceServiceInstanceId"), captor.capture()) + String e2eSliceServiceInstanceId = captor.getValue() + assertNotNull(e2eSliceServiceInstanceId) + } + + @Test + void testPrepareCallCheckProcessStatus(){ + DeleteCommunicationService dcs = new DeleteCommunicationService() + dcs.prepareCallCheckProcessStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("endProgress"), captor.capture()) + int endProgress = captor.getValue() + assertEquals(90,endProgress) + } + + @Test + void testDelCSProfileFromAAI() + { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQueryCommunicationServiceProfile()) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_PROFILE_ALL, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_SERVICE_PROFILE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be", "5G-111111") + + DeleteCommunicationService obj = spy(DeleteCommunicationService.class) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.exists(profileUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + doNothing().when(client).delete(profileUri) + obj.delCSProfileFromAAI(mockExecution) + Mockito.verify(client,times(1)).delete(profileUri) + } + + @Test + void testPrepareFailureStatus(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("result")).thenReturn("finished") + when(mockExecution.getVariable("progress")).thenReturn("100") + when(mockExecution.getVariable("operationContent")).thenReturn("terminate service failure.") + + DeleteCommunicationService dcs = new DeleteCommunicationService() + dcs.prepareFailureStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testDelCSFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DeleteCommunicationService obj = spy(DeleteCommunicationService.class) + when(obj.getAAIClient()).thenReturn(client) + doNothing().when(client).delete(serviceInstanceUri) + + obj.delCSFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testPreFailedOperationStatus(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("result")).thenReturn("error") + when(mockExecution.getVariable("progress")).thenReturn("100") + when(mockExecution.getVariable("operationContent")).thenReturn("terminate service failure") + + DeleteCommunicationService deleteCommunicationService = new DeleteCommunicationService() + WorkflowException exception = new WorkflowException("11113",7000,"terminate service failure") + when(mockExecution.getVariable("WorkflowException")).thenReturn(exception) + deleteCommunicationService.preFailedOperationStatus(mockExecution) + + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testSendRequest2NSMFWF(){ + httpClientMock = mock(HttpClient.class) + httpClientFactoryMock = mock(HttpClientFactory.class) + String url ="http://so.onap:8080/onap/so/infra/e2eServiceInstances/v3/5G-777" + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("progress")).thenReturn("20") + when(mockExecution.getVariable("operationContent")).thenReturn("waiting nsmf service delete finished") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("mso.infra.endpoint.url")).thenReturn("http://so.onap:8080/onap/so/infra") + when(mockExecution.getVariable("e2eSliceServiceInstanceId")).thenReturn("5G-777") + when(mockExecution.getVariable("e2eOperationId")).thenReturn("e151059a-d924-4629-845f-264db19e50b3") + when(httpClientFactoryMock.newJsonClient(new URL(url), ONAPComponents.SO)).thenReturn(httpClientMock) + DeleteCommunicationService obj = spy(DeleteCommunicationService.class) + + Response responseMock = mock(Response.class) + when(responseMock.getStatus()).thenReturn(200) + when(responseMock.hasEntity()).thenReturn(true) + when(responseMock.getEntity()).thenReturn(getNSSMFResponse()) + when(obj.getHttpClientFactory()).thenReturn(httpClientFactoryMock) + when(httpClientMock.delete(anyString())).thenReturn(responseMock) + + obj.sendRequest2NSMFWF(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + private String getNSSMFResponse(){ + String response = """{ + "service":{ + "serviceId":"e151059a-d924-4629-845f-264db19e50b4", + "operationId":"e151059a-d924-4629-845f-264db19e50b3" + } + }""" + return response + } + + + + + private String mockQueryCommunicationServiceReturn() + { + String expect = + """{ + "service-instance-id": "5G-666", + "service-instance-name": "eMBB_Slice_Communication_Service_5GCustomer", + "service-type": "eMBB", + "service-role": "communication-service", + "environment-context": "01-010101", + "workload-context": "12", + "created-at": "2019-12-11 19:56:00", + "description": "", + "model-invariant-id": "e75698d9-925a-4cdd-a6c0-edacbe6a0b51", + "model-version-id": "8ee5926d-720b-4bb2-86f9-d20e921c143b", + "service-instance-location-id": "300-01|300-02", + "resource-version": "1582623470778", + "orchestration-status": "created", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-777", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-777" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_e2e_Slice_Service_5GCustomer" + } + ] + } + ] + } + }""" + return expect + } + + private String mockQueryCommunicationServiceProfile() + { + String expect = + """{ + "communication-service-profile": [ + { + "profile-id": "5G-111111", + "max-number-of-UEs": 50, + "coverage-area-list": "longgang,futian", + "latency": 20, + "exp-data-rate-UL": 300, + "exp-data-rate-DL": 500, + "ue-mobility-level": "stationary", + "resource-sharing-level": "Non-Shared", + "resource-version": "1577454950460" + } + ] + }""" + return expect + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy new file mode 100644 index 0000000000..fb50fcc43b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy @@ -0,0 +1,171 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.core.WorkflowException +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 javax.ws.rs.NotFoundException + +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.doNothing +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when + +class DeleteSliceServiceTest extends MsoGroovyTest { + @Before + void init() throws IOException { + super.init("DeleteSliceServiceTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("eb0863e9-a69b-4b17-8a56-f05ad110bef7") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + when(mockExecution.getVariable("result")).thenReturn("processing") + when(mockExecution.getVariable("progress")).thenReturn("0") + when(mockExecution.getVariable("operationContent")).thenReturn("Delete Slice service operation start") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "globalSubscriberId ":"5GCustomer", + "serviceType ":"5G" + }""".replaceAll("\\\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82") + + DeleteSliceService delSS = new DeleteSliceService() + delSS.preProcessRequest(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus = captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testDeleteSliceServiceInstance(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + when(mockExecution.getVariable("result")).thenReturn("finished") + when(mockExecution.getVariable("progress")).thenReturn("100") + when(mockExecution.getVariable("operationContent")).thenReturn("NSMF completes slicing service termination.") + + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DeleteSliceService obj = spy(DeleteSliceService.class) + when(obj.getAAIClient()).thenReturn(client) + doNothing().when(client).delete(serviceInstanceUri) + + obj.deleteSliceServiceInstance(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testDelServiceProfileFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQuerySliceServiceProfile()) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE_ALL, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be", "5G-2222222") + + DeleteSliceService obj = spy(DeleteSliceService.class) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.exists(profileUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + doNothing().when(client).delete(profileUri) + obj.delServiceProfileFromAAI(mockExecution) + Mockito.verify(client,times(1)).delete(profileUri) + } + + @Test + void testPrepareEndOperationStatus(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("result")).thenReturn("error") + when(mockExecution.getVariable("progress")).thenReturn("100") + when(mockExecution.getVariable("operationContent")).thenReturn("terminate service failure") + + DeleteSliceService deleteSliceService = new DeleteSliceService() + WorkflowException exception = new WorkflowException("11113",7000,"terminate service failure") + when(mockExecution.getVariable("WorkflowException")).thenReturn(exception) + deleteSliceService.prepareEndOperationStatus(mockExecution) + + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + + } + + private String mockQuerySliceServiceProfile(){ + String expect = + """{ + "service-profile": [ + { + "profile-id": "5G-2222222", + "latency": 50, + "max-number-of-UEs": 500, + "coverage-area-TA-list": "longgang,futian", + "ue-mobility-level": "stationary", + "resource-sharing-level": "Non-Shared", + "exp-data-rate-UL": 10, + "exp-data-rate-DL": 30, + "area-traffic-cap-UL": 100, + "area-traffic-cap-DL": 100, + "activity-factor": 80, + "jitter": 10, + "survival-time": 30, + "cs-availability": 95.5, + "reliability": 99.9, + "exp-data-rate": 80, + "traffic-density": 100, + "conn-density": 80, + "resource-version": "1577454958647" + } + ] + }""" + return expect + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy new file mode 100644 index 0000000000..493e2c9e1e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy @@ -0,0 +1,258 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.beans.nsmf.JobStatusResponse +import org.onap.so.beans.nsmf.NssiResponse +import org.onap.so.beans.nsmf.ResponseDescriptor +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.core.domain.ServiceArtifact +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceInfo +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +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 javax.ws.rs.core.Response + +import static org.junit.Assert.assertNotNull +import static org.junit.Assert.assertTrue +import static org.mockito.ArgumentMatchers.anyString +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.doNothing +import static org.mockito.Mockito.mock +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +class DoDeallocateNSSITest extends MsoGroovyTest { + + private HttpClientFactory httpClientFactoryMock + private HttpClient httpClientMock + + @Before + void init() throws IOException { + super.init("DoDeallocateNSSITest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + + @Test + void testPreProcessRequest(){ + def currentNSSI = [:] + currentNSSI.put("nssiServiceInstanceId","5G-999") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + DoDeallocateNSSI ddnssi = new DoDeallocateNSSI() + ddnssi.preProcessRequest(mockExecution) + Mockito.verify(mockExecution,times(1)).getVariable("currentNSSI") + } + + @Test + void testPrepareDecomposeService(){ + def currentNSSI = [:] + currentNSSI.put("modelInvariantId", "21d57d4b-52ad-4d3c-a798-248b5bb9124b") + currentNSSI.put("modelVersionId", "bfba363e-e39c-4bd9-a9d5-1371c28f4d22") + currentNSSI.put("nssiServiceInstanceId","5G-999") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + DoDeallocateNSSI ddnssi = new DoDeallocateNSSI() + ddnssi.prepareDecomposeService(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("serviceModelInfo"), captor.capture()) + String serviceModelInfo = captor.getValue() + assertNotNull(serviceModelInfo) + } + + @Test + void testProcessDecomposition(){ + def currentNSSI = [:] + ServiceArtifact artifact = new ServiceArtifact() + artifact.setContent(getArtifactContent()) + ServiceInfo serviceInfo = new ServiceInfo() + List<ServiceArtifact> artifactList = new ArrayList<>() + artifactList.add(artifact) + serviceInfo.setServiceArtifact(artifactList) + ServiceDecomposition decomposition = new ServiceDecomposition() + decomposition.setServiceInfo(serviceInfo) + when(mockExecution.getVariable("serviceDecomposition")).thenReturn(decomposition) + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + DoDeallocateNSSI ddnssi = new DoDeallocateNSSI() + ddnssi.processDecomposition(mockExecution) + String vendor = currentNSSI.get("vendor") + assertNotNull(vendor) + } + + @Test + void testHandleJobStatus(){ + def currentNSSI = [:] + currentNSSI.put("jobProgress", 10) + currentNSSI.put("proportion", 90) + currentNSSI.put("statusDescription","") + currentNSSI.put("e2eServiceInstanceId","21d57d4b-52ad-4d3c-a798-248b5bb9124b") + currentNSSI.put("operationId","4c614769-f58a-4556-8ad9-dcd903077c82") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + DoDeallocateNSSI ddnssi = new DoDeallocateNSSI() + ddnssi.handleJobStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testDelSliceProfileFromAAI(){ + def currentNSSI = [:] + currentNSSI.put("nssiServiceInstanceId", "5G-999") + currentNSSI.put("profileId", "ddf57704-fe8d-417b-882d-2f2a12ddb225") + currentNSSI.put("globalSubscriberId","5GCustomer") + currentNSSI.put("serviceType","5G") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, "5GCustomer", "5G", "5G-999", "ddf57704-fe8d-417b-882d-2f2a12ddb225") + DoDeallocateNSSI obj = spy(DoDeallocateNSSI.class) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(profileUri)).thenReturn(true) + doNothing().when(client).delete(profileUri) + + obj.delSliceProfileFromAAI(mockExecution) + Mockito.verify(client,times(1)).delete(profileUri) + } + + @Test + void testSendRequestToNSSMF(){ + httpClientFactoryMock = mock(HttpClientFactory.class) + httpClientMock = mock(HttpClient.class) + + def currentNSSI = [:] + currentNSSI.put("snssai", "01-010101") + currentNSSI.put("profileId", "ddf57704-fe8d-417b-882d-2f2a12ddb225") + currentNSSI.put("nssiServiceInstanceId","5G-999") + currentNSSI.put("nsiServiceInstanceId","5G-888") + + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + when(mockExecution.getVariable("mso.adapters.nssmf.endpoint")).thenReturn("http://so-nssmf-adapter.onap:8088") + String nssmfRequest = "http://so-nssmf-adapter.onap:8088/api/rest/provMns/v1/NSS/SliceProfiles/ddf57704-fe8d-417b-882d-2f2a12ddb225" + + when(httpClientFactoryMock.newJsonClient(new URL(nssmfRequest), ONAPComponents.EXTERNAL)).thenReturn(httpClientMock) + DoDeallocateNSSI obj = spy(DoDeallocateNSSI.class) + when(obj.getHttpClientFactory()).thenReturn(httpClientFactoryMock) + Response responseMock = mock(Response.class) + NssiResponse response = new NssiResponse() + response.setNssiId("NSSI-C-004-HDBHZ-NSSMF-01-A-HW") + response.setJobId("a5c5913d-448a-bcb1-9b800a944d84") + when(httpClientMock.post(anyString())).thenReturn(responseMock) + when(responseMock.getStatus()).thenReturn(202) + when(responseMock.readEntity(NssiResponse.class)) thenReturn(response) + when(responseMock.hasEntity()).thenReturn(true) + + obj.sendRequestToNSSMF(mockExecution) + String jobId = currentNSSI['jobId'] + assertNotNull(jobId) + } + + @Test + void testGetJobStatus(){ + httpClientFactoryMock = mock(HttpClientFactory.class) + httpClientMock = mock(HttpClient.class) + + def currentNSSI = [:] + currentNSSI.put("jobId", "a5c5913d-448a-bcb1-9b800a944d84") + currentNSSI.put("nssiServiceInstanceId","5G-999") + currentNSSI.put("nsiServiceInstanceId","5G-888") + currentNSSI.put("jobProgress",60) + + when(mockExecution.getVariable("isNSSIDeAllocated")).thenReturn(false) + when(mockExecution.getVariable("isNSSIDeAllocated")).thenReturn(false) + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + when(mockExecution.getVariable("mso.adapters.nssmf.endpoint")).thenReturn("http://so-nssmf-adapter.onap:8088") + String nssmfRequest = "http://so-nssmf-adapter.onap:8088/api/rest/provMns/v1/NSS/jobs/a5c5913d-448a-bcb1-9b800a944d84" + + when(httpClientFactoryMock.newJsonClient(new URL(nssmfRequest), ONAPComponents.EXTERNAL)).thenReturn(httpClientMock) + DoDeallocateNSSI obj = spy(DoDeallocateNSSI.class) + when(obj.getHttpClientFactory()).thenReturn(httpClientFactoryMock) + Response responseMock = mock(Response.class) + ResponseDescriptor descriptor = new ResponseDescriptor() + descriptor.setProgress(100) + descriptor.setStatusDescription("finished deallocate nssi") + JobStatusResponse jobStatusResponse = new JobStatusResponse() + jobStatusResponse.setResponseDescriptor(descriptor) + when(httpClientMock.post(anyString())).thenReturn(responseMock) + when(responseMock.getStatus()).thenReturn(202) + when(responseMock.readEntity(JobStatusResponse.class)) thenReturn(jobStatusResponse) + when(responseMock.hasEntity()).thenReturn(true) + + obj.getJobStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("isNSSIDeAllocated"), captor.capture()) + boolean value = captor.getValue() + assertTrue(value) + } + + + private String getArtifactContent(){ + String content = + """ + { + "metadata":{ + "id":"NSST-C-001-HDBNJ-NSSMF-01-A-HW", + "vendor":"HW", + "version":"1.0", + "name":"eMBB_demo", + "description":"eMBB for demo", + "type":"embb", + "domainType":"cn" + }, + "capabilities":{ + "latency":{ + "type":"integer", + "constrainstsl":"less_or_equal", + "value":"20" + }, + "areaTrafficCapDL":{ + "type":"integer", + "constrainstsl":"less_or_equal", + "value":"300" + }, + "areaTrafficCapUL":{ + "type":"integer", + "constrainstsl":"less_or_equal", + "value":"300" + }, + "maxNumberofUEs":{ + "type":"integer", + "constrainstsl":"less_or_equal", + "value":"300" + } + } + } + """ + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy new file mode 100644 index 0000000000..8a18376819 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy @@ -0,0 +1,460 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +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 javax.ws.rs.NotFoundException + +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.junit.Assert.assertTrue +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.doNothing +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when + +class DoDeleteSliceServiceTest extends MsoGroovyTest { + @Before + void init() throws IOException { + super.init("DoDeleteSliceServiceTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest(){ + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("e2a747a0-2ca6-476d-ac28-de999cf3fbfe") + + DoDeleteSliceService doDeleteSliceService = new DoDeleteSliceService() + doDeleteSliceService.preProcessRequest(mockExecution) + + Mockito.verify(mockExecution,times(1)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testQueryE2ESliceSeriveFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQuerySliceServiceReturn()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.queryE2ESliceSeriveFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("snssai"), captor.capture()) + String snssai = captor.getValue() + assertNotNull(snssai) + } + + @Test + void testGetAllottedResFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE_ALL, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQueryAllottedResource()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.getAllottedResFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("nsiId"), captor.capture()) + String nsiId = captor.getValue() + assertNotNull(nsiId) + } + + @Test + void testGetNSIFromAAI(){ + when(mockExecution.getVariable("nsiId")).thenReturn("5G-888") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5G-888") + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockNSIReturn()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.getNSIFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("nssiIdList"), captor.capture()) + List<String> nssiIdList = captor.getValue() + assertNotNull(nssiIdList) + } + + @Test + void testGetNSSIListFromAAI(){ + List<String> nssiIdList = [] + nssiIdList.add("5G-999") + + when(mockExecution.getVariable("nssiIdList")).thenReturn(nssiIdList) + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5G-999") + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockNSSIReturn()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.getNSSIListFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("nssiInstanceList"), captor.capture()) + List<ServiceInstance> nssiInstanceList = captor.getValue() + assertNotNull(nssiInstanceList) + } + + @Test + void testGetCurrentNSSI(){ + ServiceInstance nssi = new ServiceInstance() + nssi.setServiceInstanceId("5G-999") + nssi.setModelInvariantId("21d57d4b-52ad-4d3c-a798-248b5bb9124a") + nssi.setModelVersionId("bfba363e-e39c-4bd9-a9d5-1371c28f4d22") + List<ServiceInstance> nssiInstanceList = [] + nssiInstanceList.add(nssi) + when(mockExecution.getVariable("currentNSSIIndex")).thenReturn(0) + when(mockExecution.getVariable("nssiInstanceList")).thenReturn(nssiInstanceList) + when(mockExecution.getVariable("snssai")).thenReturn("01-010101") + when(mockExecution.getVariable("nsiId")).thenReturn("5G-888") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5G-777") + when(mockExecution.getVariable("msoRequestId")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + when(mockExecution.getVariable("proportion")).thenReturn("90") + + DoDeleteSliceService ddss = new DoDeleteSliceService() + ddss.getCurrentNSSI(mockExecution) + verify(mockExecution,times(1)).setVariable(eq("currentNSSI"), captor.capture()) + Map currentNSSI = captor.getValue() + assertTrue(currentNSSI.size()>0) + } + + @Test + void testQuerySliceProfileFromAAI(){ + def currentNSSI = [:] + currentNSSI.put("nssiServiceInstanceId","5G-999") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResultWrapper wrapper = new AAIResultWrapper(mockSliceProfile()) + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE_ALL, "5GCustomer", "5G", "5G-999") + + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(profileUri)).thenReturn(true) + when(client.get(profileUri, NotFoundException.class)).thenReturn(wrapper) + obj.querySliceProfileFromAAI(mockExecution) + verify(mockExecution,times(1)).setVariable(eq("currentNSSI"), captor.capture()) + Map value = captor.getValue() + assertNotNull(currentNSSI.get('profileId')) + } + + @Test + void parseNextNSSI(){ + ServiceInstance nssi = new ServiceInstance() + nssi.setServiceInstanceId("5G-999") + nssi.setModelInvariantId("21d57d4b-52ad-4d3c-a798-248b5bb9124b") + nssi.setModelVersionId("bfba363e-e39c-4bd9-a9d5-1371c28f4d22") + List<ServiceInstance> nssiInstanceList = [] + nssiInstanceList.add(nssi) + when(mockExecution.getVariable("currentNSSIIndex")).thenReturn(0) + when(mockExecution.getVariable("nssiInstanceList")).thenReturn(nssiInstanceList) + + DoDeleteSliceService ddss = new DoDeleteSliceService() + ddss.parseNextNSSI(mockExecution) + verify(mockExecution,times(1)).setVariable(eq("isAllNSSIFinished"), captor.capture()) + boolean isAllNSSIFinished = captor.getValue() + assertTrue(isAllNSSIFinished) + } + + private String mockSliceProfile(){ + String expect = + """{ + "slice-profile": [ + { + "profile-id": "ddf57704-fe8d-417b-882d-2f2a12ddb225", + "latency": 20, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "[{\\"province\\":\\"??\\",\\"city\\":\\"???\\",\\"county\\":\\"???\\",\\"street\\":\\"?????\\"}]", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 100, + "exp-data-rate-DL": 100, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "s-nssai": "01003", + "resource-version": "1580800791373" + } + ] + } + """ + return expect + } + + private String mockNSSIReturn(){ + String expect = + """ + { + "service-instance-id": "5G-999", + "service-instance-name": "eMBB_Slice_NSSI_5GCustomer", + "service-type": "eMBB", + "service-role": "nssi", + "environment-context": "cn", + "model-invariant-id": "21d57d4b-52ad-4d3c-a798-248b5bb9124a", + "model-version-id": "bfba363e-e39c-4bd9-a9d5-1371c28f4d22", + "service-instance-location-id": "300-01|300-02", + "resource-version": "1578449638032", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-888", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-888" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_e2e_Slice_Service_5GCustomer" + } + ] + } + ] + } + } + """ + return expect + } + + private String mockNSIReturn(){ + String expect = + """ + { + "service-instance-id": "5G-888", + "service-instance-name": "eMBB_e2e_Slice_Service_5GCustomer", + "service-type": "embb", + "service-role": "nsi", + "model-invariant-id": "0e9bcb9a-c832-433b-a0c1-74866768f608", + "model-version-id": "2c5fd79d-0f84-4057-9222-952cb6f27036", + "service-instance-location-id": "300-01|300-02", + "resource-version": "1579691104911", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-999", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-999" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_Slice_NSSI_5GCustomer" + } + ] + }, + { + "related-to": "allotted-resource", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-777/allotted-resources/allotted-resource/5G-1234", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-777" + }, + { + "relationship-key": "allotted-resource.id", + "relationship-value": "5G-1234" + } + ], + "related-to-property": [ + { + "property-key": "allotted-resource.description" + }, + { + "property-key": "allotted-resource.allotted-resource-name" + } + ] + } + ] + } + } + """ + return expect + } + + private String mockQueryAllottedResource(){ + String expect = + """{ + "allotted-resource": [ + { + "id": "5G-1234", + "resource-version": "1577454983471", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-888", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-888" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_e2e_Slice_Service_5GCustomer" + } + ] + } + ] + } + } + ] + } + """ + return expect + } + + String mockQuerySliceServiceReturn(){ + String expect = + """{ + "service-instance-id": "5G-777", + "service-instance-name": "eMBB_e2e_Slice_Service_5GCustomer", + "service-type": "embb", + "service-role": "e2eslice-service", + "environment-context": "01-010101", + "model-invariant-id": "e65d737a-41e0-4ad1-958f-56defdf2e907", + "model-version-id": "f2f5967e-72d3-4c5c-b880-e214e71dba4e", + "service-instance-location-id": "300-01|300-02", + "resource-version": "1578449638436", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-666", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-666" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_Slice_Communication_Service_5GCustomer" + } + ] + } + ] + } + } + """ + return expect + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn index 3e1c1179bf..013e1b62c2 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn @@ -428,10 +428,7 @@ css.sendSyncResponse(execution)</bpmn:script> <camunda:in source="nstModelUuid" target="nstModelUuid" /> <camunda:in source="nstModelInvariantUuid" target="nstModelInvariantUuid" /> <camunda:in source="serviceProfile" target="serviceProfile" /> - <camunda:in source="sliceProfileTn" target="sliceProfileTn" /> <camunda:in source="msoRequestId" target="msoRequestId" /> - <camunda:in source="sliceProfileCn" target="sliceProfileCn" /> - <camunda:in source="sliceProfileAn" target="sliceProfileAn" /> <camunda:in source="sliceTaskParams" target="sliceTaskParams" /> <camunda:in source="resourceSharingLevel" target="resourceSharingLevel" /> <camunda:out source="sliceTaskParams" target="sliceTaskParams" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSIandNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSIandNSSI.bpmn new file mode 100644 index 0000000000..9c090e0594 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSIandNSSI.bpmn @@ -0,0 +1,361 @@ +<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.3"> + <bpmn:process id="DoAllocateNSIandNSSI" name="DoAllocateNSIandNSSI" isExecutable="true"> + <bpmn:scriptTask id="Task_09nzhwk" name="Generate NSI and create NSI in AAI with E2ESS and NSI relationship" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1e40h52</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1uiz85h</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.createNSIinAAI(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="ExclusiveGateway_0b9d9l0" name="Is nsi option available?" default="SequenceFlow_1h5bw41"> + <bpmn:incoming>SequenceFlow_0dj0jvq</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1h5bw41</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0ueeeca</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:scriptTask id="ScriptTask_1ehyrsg" name="Update AAI relationship for E2ESS and NSI" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0ueeeca</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0xfhbqw</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new DoAllocateNSIandNSSI() +dcsi.updateRelationship(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="CallActivity_1s23hty" name="Call Decompose Service" calledElement="DecomposeService"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> + <camunda:in source="serviceModelInfo" target="serviceModelInfo" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1h5bw41</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1e40h52</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="ScriptTask_1q3ftu4" name="Prepare NSSI model info and instance id" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0xfhbqw</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0uhaps2</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new DoAllocateNSIandNSSI() +dcsi.prepareNssiModelInfo(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:startEvent id="allocateslice_StartEvent" name="allocatensi_StartEvent"> + <bpmn:outgoing>SequenceFlow_1qo2pln</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="PreprocessIncomingRequest_task" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1qo2pln</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0khtova</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoAllocateNSIandNSSI() +dcso.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_0o93dvp" name="read NSI options from request DB" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0khtova</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0dj0jvq</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dansi = new DoAllocateNSIandNSSI() +dansi.retriveSliceOption(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="CallActivity_1k1oonn" name="Call Decompose Service" calledElement="DecomposeService"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> + <camunda:in source="serviceModelInfo" target="serviceModelInfo" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1dhpkhd</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0hxky5e</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="ScriptTask_0gunols" name="Get one NSST Info" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1uiz85h</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1ui528w</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1dhpkhd</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.getOneNsstInfo(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_1lpgn98" name="prepare NSST Info" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0hxky5e</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_19jztxv</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.createNSSTMap(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:endEvent id="EndEvent_1x6k78c"> + <bpmn:incoming>SequenceFlow_0u8fycy</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="finishNSCreate_Task" name="Get a NSSI to process" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_16nvnxi</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0cq2q6g</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new DoAllocateNSIandNSSI() +dcsi.getOneNSSIInfo(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="ExclusiveGateway_07qkrrb" name="Is there more NSSI to process?" default="SequenceFlow_0u8fycy"> + <bpmn:incoming>SequenceFlow_0g5bwvl</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1jaxstd</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_16nvnxi</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0u8fycy</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:callActivity id="CallActivity_130tuxn" name="Call DoAllocateNSSI" calledElement="DoAllocateNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="nsstInput" target="nsstInput" /> + <camunda:in source="serviceProfile" target="serviceProfile" /> + <camunda:in source="sliceProfileTn" target="sliceProfileTn" /> + <camunda:in source="sliceProfileCn" target="sliceProfileCn" /> + <camunda:in source="sliceProfileAn" target="sliceProfileAn" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="uuiRequest" target="uuiRequest" /> + <camunda:in source="nsiServiceInstanceId" target="nsiServiceInstanceId" /> + <camunda:in source="nsiServiceInstanceName" target="nsiServiceInstanceName" /> + <camunda:in source="nssiserviceModelInfo" target="nssiserviceModelInfo" /> + <camunda:in source="sliceTaskParams" target="sliceTaskParams" /> + <camunda:in source="taskId" target="CSSOT_taskId" /> + <camunda:in source="taskName" target="CSSOT_name" /> + <camunda:in source="taskStatus" target="CSSOT_status" /> + <camunda:in source="isManual" target="CSSOT_isManual" /> + <camunda:in source="isNSIOptionAvailable" target="isNSIOptionAvailable" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0cq2q6g</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_00b8ryw</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="ScriptTask_0anyn7v" name="Update current Index" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_00b8ryw</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1jaxstd</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new DoAllocateNSIandNSSI() +dcsi.updateCurrentIndex(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="instantiate_NSTask" name="Prepare NSSI list (with and without shared NSSI)" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0uhaps2</bpmn:incoming> + <bpmn:incoming>SequenceFlow_04yx9ii</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0g5bwvl</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoAllocateNSIandNSSI() +dcso.prepareNSSIList(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="ExclusiveGateway_1jg3el3" name="Is NSST available?" default="SequenceFlow_04yx9ii"> + <bpmn:incoming>SequenceFlow_19jztxv</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_04yx9ii</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1ui528w</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_0uhaps2" sourceRef="ScriptTask_1q3ftu4" targetRef="instantiate_NSTask" /> + <bpmn:sequenceFlow id="SequenceFlow_1e40h52" sourceRef="CallActivity_1s23hty" targetRef="Task_09nzhwk" /> + <bpmn:sequenceFlow id="SequenceFlow_0xfhbqw" sourceRef="ScriptTask_1ehyrsg" targetRef="ScriptTask_1q3ftu4" /> + <bpmn:sequenceFlow id="SequenceFlow_0dj0jvq" sourceRef="ScriptTask_0o93dvp" targetRef="ExclusiveGateway_0b9d9l0" /> + <bpmn:sequenceFlow id="SequenceFlow_0ueeeca" name="Yes" sourceRef="ExclusiveGateway_0b9d9l0" targetRef="ScriptTask_1ehyrsg"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isNSIOptionAvailable" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1h5bw41" name="No" sourceRef="ExclusiveGateway_0b9d9l0" targetRef="CallActivity_1s23hty" /> + <bpmn:sequenceFlow id="SequenceFlow_1uiz85h" sourceRef="Task_09nzhwk" targetRef="ScriptTask_0gunols" /> + <bpmn:sequenceFlow id="SequenceFlow_1qo2pln" sourceRef="allocateslice_StartEvent" targetRef="PreprocessIncomingRequest_task" /> + <bpmn:sequenceFlow id="SequenceFlow_0khtova" sourceRef="PreprocessIncomingRequest_task" targetRef="ScriptTask_0o93dvp" /> + <bpmn:sequenceFlow id="SequenceFlow_0g5bwvl" sourceRef="instantiate_NSTask" targetRef="ExclusiveGateway_07qkrrb" /> + <bpmn:sequenceFlow id="SequenceFlow_0hxky5e" sourceRef="CallActivity_1k1oonn" targetRef="ScriptTask_1lpgn98" /> + <bpmn:sequenceFlow id="SequenceFlow_1dhpkhd" sourceRef="ScriptTask_0gunols" targetRef="CallActivity_1k1oonn" /> + <bpmn:sequenceFlow id="SequenceFlow_19jztxv" sourceRef="ScriptTask_1lpgn98" targetRef="ExclusiveGateway_1jg3el3" /> + <bpmn:sequenceFlow id="SequenceFlow_0u8fycy" name="No" sourceRef="ExclusiveGateway_07qkrrb" targetRef="EndEvent_1x6k78c" /> + <bpmn:sequenceFlow id="SequenceFlow_16nvnxi" name="Yes" sourceRef="ExclusiveGateway_07qkrrb" targetRef="finishNSCreate_Task"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isMoreNSSI" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0cq2q6g" sourceRef="finishNSCreate_Task" targetRef="CallActivity_130tuxn" /> + <bpmn:sequenceFlow id="SequenceFlow_1jaxstd" sourceRef="ScriptTask_0anyn7v" targetRef="ExclusiveGateway_07qkrrb" /> + <bpmn:sequenceFlow id="SequenceFlow_00b8ryw" sourceRef="CallActivity_130tuxn" targetRef="ScriptTask_0anyn7v" /> + <bpmn:sequenceFlow id="SequenceFlow_04yx9ii" name="No" sourceRef="ExclusiveGateway_1jg3el3" targetRef="instantiate_NSTask" /> + <bpmn:sequenceFlow id="SequenceFlow_1ui528w" sourceRef="ExclusiveGateway_1jg3el3" targetRef="ScriptTask_0gunols"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isMoreNSSTtoProcess" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoAllocateNSIandNSSI"> + <bpmndi:BPMNEdge id="SequenceFlow_0uhaps2_di" bpmnElement="SequenceFlow_0uhaps2"> + <di:waypoint x="978" y="350" /> + <di:waypoint x="1736" y="350" /> + <di:waypoint x="1736" y="487" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1e40h52_di" bpmnElement="SequenceFlow_1e40h52"> + <di:waypoint x="799" y="527" /> + <di:waypoint x="878" y="527" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0xfhbqw_di" bpmnElement="SequenceFlow_0xfhbqw"> + <di:waypoint x="799" y="350" /> + <di:waypoint x="878" y="350" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0dj0jvq_di" bpmnElement="SequenceFlow_0dj0jvq"> + <di:waypoint x="520" y="527" /> + <di:waypoint x="583" y="527" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0ueeeca_di" bpmnElement="SequenceFlow_0ueeeca"> + <di:waypoint x="608" y="502" /> + <di:waypoint x="608" y="350" /> + <di:waypoint x="699" y="350" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="584" y="422" width="19" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1h5bw41_di" bpmnElement="SequenceFlow_1h5bw41"> + <di:waypoint x="633" y="527" /> + <di:waypoint x="699" y="527" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="630" y="509" width="14" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1uiz85h_di" bpmnElement="SequenceFlow_1uiz85h"> + <di:waypoint x="978" y="527" /> + <di:waypoint x="1036" y="527" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="631" y="108" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1qo2pln_di" bpmnElement="SequenceFlow_1qo2pln"> + <di:waypoint x="210" y="527" /> + <di:waypoint x="268" y="527" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="266" y="123" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0khtova_di" bpmnElement="SequenceFlow_0khtova"> + <di:waypoint x="368" y="527" /> + <di:waypoint x="420" y="527" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="436" y="108" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0g5bwvl_di" bpmnElement="SequenceFlow_0g5bwvl"> + <di:waypoint x="1786" y="527" /> + <di:waypoint x="1871" y="527" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0hxky5e_di" bpmnElement="SequenceFlow_0hxky5e"> + <di:waypoint x="1300" y="527" /> + <di:waypoint x="1388" y="527" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1dhpkhd_di" bpmnElement="SequenceFlow_1dhpkhd"> + <di:waypoint x="1136" y="527" /> + <di:waypoint x="1200" y="527" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_19jztxv_di" bpmnElement="SequenceFlow_19jztxv"> + <di:waypoint x="1488" y="527" /> + <di:waypoint x="1564" y="527" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0u8fycy_di" bpmnElement="SequenceFlow_0u8fycy"> + <di:waypoint x="1896" y="502" /> + <di:waypoint x="1896" y="409" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1904" y="453" width="14" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_16nvnxi_di" bpmnElement="SequenceFlow_16nvnxi"> + <di:waypoint x="1921" y="527" /> + <di:waypoint x="1991" y="527" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1942" y="500" width="19" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0cq2q6g_di" bpmnElement="SequenceFlow_0cq2q6g"> + <di:waypoint x="2091" y="527" /> + <di:waypoint x="2197" y="527" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="556.5" y="574" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1jaxstd_di" bpmnElement="SequenceFlow_1jaxstd"> + <di:waypoint x="1991" y="665" /> + <di:waypoint x="1896" y="665" /> + <di:waypoint x="1896" y="552" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_00b8ryw_di" bpmnElement="SequenceFlow_00b8ryw"> + <di:waypoint x="2247" y="567" /> + <di:waypoint x="2247" y="665" /> + <di:waypoint x="2091" y="665" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_04yx9ii_di" bpmnElement="SequenceFlow_04yx9ii"> + <di:waypoint x="1614" y="527" /> + <di:waypoint x="1686" y="527" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1643" y="509" width="14" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1ui528w_di" bpmnElement="SequenceFlow_1ui528w"> + <di:waypoint x="1589" y="552" /> + <di:waypoint x="1589" y="671" /> + <di:waypoint x="1086" y="671" /> + <di:waypoint x="1086" y="567" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1dw39hg_di" bpmnElement="Task_09nzhwk"> + <dc:Bounds x="878" y="487" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_0b9d9l0_di" bpmnElement="ExclusiveGateway_0b9d9l0" isMarkerVisible="true"> + <dc:Bounds x="583" y="502" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="578" y="559" width="60" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1ehyrsg_di" bpmnElement="ScriptTask_1ehyrsg"> + <dc:Bounds x="699" y="310" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_1s23hty_di" bpmnElement="CallActivity_1s23hty"> + <dc:Bounds x="699" y="487" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1q3ftu4_di" bpmnElement="ScriptTask_1q3ftu4"> + <dc:Bounds x="878" y="310" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="allocateslice_StartEvent"> + <dc:Bounds x="174" y="509" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="152" y="545" width="82" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_03j6ogo_di" bpmnElement="PreprocessIncomingRequest_task"> + <dc:Bounds x="268" y="487" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0o93dvp_di" bpmnElement="ScriptTask_0o93dvp"> + <dc:Bounds x="420" y="487" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_1k1oonn_di" bpmnElement="CallActivity_1k1oonn"> + <dc:Bounds x="1200" y="487" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0gunols_di" bpmnElement="ScriptTask_0gunols"> + <dc:Bounds x="1036" y="487" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1lpgn98_di" bpmnElement="ScriptTask_1lpgn98"> + <dc:Bounds x="1388" y="487" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_15pcuuc_di" bpmnElement="EndEvent_1x6k78c"> + <dc:Bounds x="1878" y="373" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="412" y="617" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0xxyfku_di" bpmnElement="finishNSCreate_Task"> + <dc:Bounds x="1991" y="487" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_07qkrrb_di" bpmnElement="ExclusiveGateway_07qkrrb" isMarkerVisible="true"> + <dc:Bounds x="1871" y="502" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1853" y="575" width="86" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_130tuxn_di" bpmnElement="CallActivity_130tuxn"> + <dc:Bounds x="2197" y="487" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0anyn7v_di" bpmnElement="ScriptTask_0anyn7v"> + <dc:Bounds x="1991" y="625" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1qmmew8_di" bpmnElement="instantiate_NSTask"> + <dc:Bounds x="1686" y="487" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_1jg3el3_di" bpmnElement="ExclusiveGateway_1jg3el3" isMarkerVisible="true"> + <dc:Bounds x="1564" y="502" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1564" y="465" width="50" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSSI.bpmn new file mode 100644 index 0000000000..445c9378af --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSSI.bpmn @@ -0,0 +1,364 @@ +<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.3"> + <bpmn:process id="DoAllocateNSSI" name="DoAllocateNSSI" isExecutable="true"> + <bpmn:startEvent id="allocatenssi_StartEvent" name="allocatenssi_StartEvent"> + <bpmn:outgoing>SequenceFlow_1qo2pln</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="SequenceFlow_1qo2pln" sourceRef="allocatenssi_StartEvent" targetRef="PreprocessIncomingRequest_task" /> + <bpmn:sequenceFlow id="SequenceFlow_0khtova" sourceRef="PreprocessIncomingRequest_task" targetRef="CallActivity_09l7bhc" /> + <bpmn:scriptTask id="Task_09nzhwk" name="send create request to NSSMF adapter" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1h5bw41</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1uiz85h</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.sendCreateRequestNSSMF(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="PreprocessIncomingRequest_task" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1qo2pln</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0khtova</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="instantiate_NSTask" name="create slice profile" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0yie00u</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0kzlbeh</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1r8qkgf</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_09pv5lu</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.createSliceProfile(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:endEvent id="EndEvent_1x6k78c"> + <bpmn:incoming>SequenceFlow_09pv5lu</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="finishNSCreate_Task" name="Get NSSI progress" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1smrx3b</bpmn:incoming> + <bpmn:incoming>SequenceFlow_08xcz0v</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1lpxjvi</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.getNSSMFProgresss(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1uiz85h" sourceRef="Task_09nzhwk" targetRef="ExclusiveGateway_0xz0xx2" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_0b9d9l0" name="Is NSSI sharable?" default="SequenceFlow_0ueeeca"> + <bpmn:incoming>SequenceFlow_0dj0jvq</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1h5bw41</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0ueeeca</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_1h5bw41" name="No" sourceRef="ExclusiveGateway_0b9d9l0" targetRef="Task_09nzhwk"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("nssmfOperation" ) == "create")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:scriptTask id="ScriptTask_1ehyrsg" name="send update request to NSSMF adapter" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0ueeeca</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0xfhbqw</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.sendUpdateRequestNSSMF(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0ueeeca" name="Yes" sourceRef="ExclusiveGateway_0b9d9l0" targetRef="ScriptTask_1ehyrsg" /> + <bpmn:scriptTask id="ScriptTask_0o93dvp" name="Get NSST from Catalog DB" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_03bz6dh</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0dj0jvq</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.getNSSTInfo(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0dj0jvq" sourceRef="ScriptTask_0o93dvp" targetRef="ExclusiveGateway_0b9d9l0" /> + <bpmn:sequenceFlow id="SequenceFlow_0xfhbqw" sourceRef="ScriptTask_1ehyrsg" targetRef="ExclusiveGateway_0xz0xx2" /> + <bpmn:scriptTask id="ScriptTask_1mv1npn" name="create NSSI and update relationship" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_07azk0i</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0yie00u</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.instantiateNSSIService(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1lpxjvi" sourceRef="finishNSCreate_Task" targetRef="ScriptTask_1fvkcir" /> + <bpmn:callActivity id="CallActivity_09l7bhc" name="Call Decompose Service" calledElement="DecomposeService"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> + <camunda:in source="serviceModelInfo" target="serviceModelInfo" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0khtova</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_03bz6dh</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_03bz6dh" sourceRef="CallActivity_09l7bhc" targetRef="ScriptTask_0o93dvp" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_1cgffe3" name="Completed"> + <bpmn:incoming>SequenceFlow_1xzq95u</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1kxwt7k</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0stj4cv</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:scriptTask id="ScriptTask_1escji6" name="Time delay" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0stj4cv</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_08xcz0v</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.timeDelay(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_08xcz0v" sourceRef="ScriptTask_1escji6" targetRef="finishNSCreate_Task" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_0xz0xx2"> + <bpmn:incoming>SequenceFlow_0xfhbqw</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1uiz85h</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1smrx3b</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_1kxwt7k" name="true" sourceRef="ExclusiveGateway_1cgffe3" targetRef="ExclusiveGateway_09hoejm"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isNSSICreated" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0stj4cv" name="false" sourceRef="ExclusiveGateway_1cgffe3" targetRef="ScriptTask_1escji6"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isNSSICreated" ) == false)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1smrx3b" sourceRef="ExclusiveGateway_0xz0xx2" targetRef="finishNSCreate_Task" /> + <bpmn:sequenceFlow id="SequenceFlow_0yie00u" sourceRef="ScriptTask_1mv1npn" targetRef="instantiate_NSTask" /> + <bpmn:sequenceFlow id="SequenceFlow_09pv5lu" sourceRef="instantiate_NSTask" targetRef="EndEvent_1x6k78c" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_09hoejm" name="Is NSSI sharable?" default="SequenceFlow_0c2o5zl2"> + <bpmn:incoming>SequenceFlow_1kxwt7k</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_07azk0i</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0c2o5zl2</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_07azk0i" sourceRef="ExclusiveGateway_09hoejm" targetRef="ScriptTask_1mv1npn"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("nssmfOperation" ) == "create")}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:scriptTask id="ScriptTask_0y2xmwi" name="Update relationship" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_14lzy4o</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0kzlbeh</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.updateRelationship(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0c2o5zl2" sourceRef="ExclusiveGateway_09hoejm" targetRef="ScriptTask_0y2xmwi" /> + <bpmn:sequenceFlow id="SequenceFlow_0kzlbeh" sourceRef="ScriptTask_0y2xmwi" targetRef="instantiate_NSTask" /> + <bpmn:scriptTask id="ScriptTask_1fvkcir" name="Prepare Update Orchestration Task" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1lpxjvi</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0jjbci8</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.prepareUpdateOrchestrationTask(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="CallActivity_11d0poc" name="Call HandleOrchestrationTask" calledElement="HandleOrchestrationTask"> + <bpmn:extensionElements> + <camunda:out source="statusCode" target="CSSOT_dbResponseCode" /> + <camunda:out source="response" target="CSSOT_dbResponse" /> + <camunda:in source="CSSOT_taskId" target="taskId" /> + <camunda:in source="msoRequestId" target="requestId" /> + <camunda:in source="CSSOT_name" target="taskName" /> + <camunda:in source="CSSOT_status" target="taskStatus" /> + <camunda:in source="CSSOT_isManual" target="isManual" /> + <camunda:in source="CSSOT_paramJson" target="paramJson" /> + <camunda:in source="CSSOT_requestMethod" target="method" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0jjbci8</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1xzq95u</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_0jjbci8" sourceRef="ScriptTask_1fvkcir" targetRef="CallActivity_11d0poc" /> + <bpmn:sequenceFlow id="SequenceFlow_1xzq95u" sourceRef="CallActivity_11d0poc" targetRef="ExclusiveGateway_1cgffe3" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_19tascw" name="Is NSI option available?" default="SequenceFlow_14lzy4o"> + <bpmn:incoming>SequenceFlow_0c2o5zl2</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_14lzy4o</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1r8qkgf</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_14lzy4o" sourceRef="ExclusiveGateway_19tascw" targetRef="ScriptTask_0y2xmwi" /> + <bpmn:sequenceFlow id="SequenceFlow_1r8qkgf" sourceRef="ExclusiveGateway_19tascw" targetRef="instantiate_NSTask"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isNSIOptionAvailable" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoAllocateNSSI"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="allocatenssi_StartEvent"> + <dc:Bounds x="175" y="509" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="152" y="545" width="85" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1qo2pln_di" bpmnElement="SequenceFlow_1qo2pln"> + <di:waypoint x="211" y="527" /> + <di:waypoint x="269" y="527" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="266" y="123" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0khtova_di" bpmnElement="SequenceFlow_0khtova"> + <di:waypoint x="369" y="527" /> + <di:waypoint x="444" y="527" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="436" y="108" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1dw39hg_di" bpmnElement="Task_09nzhwk"> + <dc:Bounds x="887" y="659" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_03j6ogo_di" bpmnElement="PreprocessIncomingRequest_task"> + <dc:Bounds x="269" y="487" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1qmmew8_di" bpmnElement="instantiate_NSTask"> + <dc:Bounds x="2286" y="467" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_15pcuuc_di" bpmnElement="EndEvent_1x6k78c"> + <dc:Bounds x="2482" y="489" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="412" y="617" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0xxyfku_di" bpmnElement="finishNSCreate_Task"> + <dc:Bounds x="1238" y="467" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1uiz85h_di" bpmnElement="SequenceFlow_1uiz85h"> + <di:waypoint x="987" y="699" /> + <di:waypoint x="1103" y="699" /> + <di:waypoint x="1103" y="532" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="631" y="108" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_0b9d9l0_di" bpmnElement="ExclusiveGateway_0b9d9l0" isMarkerVisible="true"> + <dc:Bounds x="778" y="502" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="838" y="520" width="90" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1h5bw41_di" bpmnElement="SequenceFlow_1h5bw41"> + <di:waypoint x="803" y="552" /> + <di:waypoint x="803" y="699" /> + <di:waypoint x="883" y="699" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="836" y="681" width="14" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1ehyrsg_di" bpmnElement="ScriptTask_1ehyrsg"> + <dc:Bounds x="894" y="310" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0ueeeca_di" bpmnElement="SequenceFlow_0ueeeca"> + <di:waypoint x="803" y="502" /> + <di:waypoint x="803" y="350" /> + <di:waypoint x="894" y="350" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="831" y="358" width="19" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0o93dvp_di" bpmnElement="ScriptTask_0o93dvp"> + <dc:Bounds x="618" y="487" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0dj0jvq_di" bpmnElement="SequenceFlow_0dj0jvq"> + <di:waypoint x="718" y="527" /> + <di:waypoint x="778" y="527" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0xfhbqw_di" bpmnElement="SequenceFlow_0xfhbqw"> + <di:waypoint x="994" y="350" /> + <di:waypoint x="1103" y="350" /> + <di:waypoint x="1103" y="482" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1mv1npn_di" bpmnElement="ScriptTask_1mv1npn"> + <dc:Bounds x="2089" y="467" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1lpxjvi_di" bpmnElement="SequenceFlow_1lpxjvi"> + <di:waypoint x="1338" y="507" /> + <di:waypoint x="1411" y="507" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="CallActivity_09l7bhc_di" bpmnElement="CallActivity_09l7bhc"> + <dc:Bounds x="444" y="487" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_03bz6dh_di" bpmnElement="SequenceFlow_03bz6dh"> + <di:waypoint x="544" y="527" /> + <di:waypoint x="618" y="527" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_1cgffe3_di" bpmnElement="ExclusiveGateway_1cgffe3" isMarkerVisible="true"> + <dc:Bounds x="1773" y="482" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1771" y="458" width="54" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1escji6_di" bpmnElement="ScriptTask_1escji6"> + <dc:Bounds x="1748" y="624" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_08xcz0v_di" bpmnElement="SequenceFlow_08xcz0v"> + <di:waypoint x="1748" y="664" /> + <di:waypoint x="1288" y="664" /> + <di:waypoint x="1288" y="547" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_0xz0xx2_di" bpmnElement="ExclusiveGateway_0xz0xx2" isMarkerVisible="true"> + <dc:Bounds x="1078" y="482" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1kxwt7k_di" bpmnElement="SequenceFlow_1kxwt7k"> + <di:waypoint x="1823" y="507" /> + <di:waypoint x="1928" y="507" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1866" y="489" width="19" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0stj4cv_di" bpmnElement="SequenceFlow_0stj4cv"> + <di:waypoint x="1798" y="532" /> + <di:waypoint x="1798" y="624" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1801" y="575" width="24" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1smrx3b_di" bpmnElement="SequenceFlow_1smrx3b"> + <di:waypoint x="1128" y="507" /> + <di:waypoint x="1238" y="507" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0yie00u_di" bpmnElement="SequenceFlow_0yie00u"> + <di:waypoint x="2189" y="507" /> + <di:waypoint x="2286" y="507" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_09pv5lu_di" bpmnElement="SequenceFlow_09pv5lu"> + <di:waypoint x="2386" y="507" /> + <di:waypoint x="2482" y="507" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_09hoejm_di" bpmnElement="ExclusiveGateway_09hoejm" isMarkerVisible="true"> + <dc:Bounds x="1928" y="482" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1908" y="542" width="90" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_07azk0i_di" bpmnElement="SequenceFlow_07azk0i"> + <di:waypoint x="1978" y="507" /> + <di:waypoint x="2089" y="507" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0y2xmwi_di" bpmnElement="ScriptTask_0y2xmwi"> + <dc:Bounds x="2089" y="310" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0kzlbeh_di" bpmnElement="SequenceFlow_0kzlbeh"> + <di:waypoint x="2189" y="350" /> + <di:waypoint x="2336" y="350" /> + <di:waypoint x="2336" y="467" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1fvkcir_di" bpmnElement="ScriptTask_1fvkcir"> + <dc:Bounds x="1411" y="467" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_11d0poc_di" bpmnElement="CallActivity_11d0poc"> + <dc:Bounds x="1587" y="467" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0jjbci8_di" bpmnElement="SequenceFlow_0jjbci8"> + <di:waypoint x="1511" y="507" /> + <di:waypoint x="1587" y="507" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1xzq95u_di" bpmnElement="SequenceFlow_1xzq95u"> + <di:waypoint x="1687" y="507" /> + <di:waypoint x="1773" y="507" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_19tascw_di" bpmnElement="ExclusiveGateway_19tascw" isMarkerVisible="true"> + <dc:Bounds x="1928" y="325" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1854" y="337" width="64" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0c2o5zl_di" bpmnElement="SequenceFlow_0c2o5zl2"> + <di:waypoint x="1953" y="482" /> + <di:waypoint x="1953" y="375" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_14lzy4o_di" bpmnElement="SequenceFlow_14lzy4o"> + <di:waypoint x="1978" y="350" /> + <di:waypoint x="2089" y="350" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1r8qkgf_di" bpmnElement="SequenceFlow_1r8qkgf"> + <di:waypoint x="1953" y="325" /> + <di:waypoint x="1953" y="205" /> + <di:waypoint x="2336" y="205" /> + <di:waypoint x="2336" y="465" /> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceInstance.bpmn new file mode 100644 index 0000000000..894f7d39dc --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceInstance.bpmn @@ -0,0 +1,103 @@ +<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.3"> + <bpmn:process id="DoCreateSliceServiceInstance" name="DoCreateSliceServiceInstance" isExecutable="true"> + <bpmn:startEvent id="createNS_StartEvent" name="createNS_StartEvent"> + <bpmn:outgoing>SequenceFlow_1qo2pln</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="SequenceFlow_1qo2pln" sourceRef="createNS_StartEvent" targetRef="PreprocessIncomingRequest_task" /> + <bpmn:sequenceFlow id="SequenceFlow_0khtova" sourceRef="PreprocessIncomingRequest_task" targetRef="instantiate_NSTask" /> + <bpmn:scriptTask id="Task_09nzhwk" name="Create service profile" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_17u69c4</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1uiz85h</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new DoCreateSliceServiceInstance() +dcsi.createServiceProfile(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="PreprocessIncomingRequest_task" name="Preprocess Incoming Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1qo2pln</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0khtova</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new DoCreateSliceServiceInstance() +dcsi.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="instantiate_NSTask" name="create Slice Service in AAI" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0khtova</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0g5bwvl</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new DoCreateSliceServiceInstance() +dcsi.instantiateSliceService(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:endEvent id="EndEvent_1x6k78c"> + <bpmn:incoming>SequenceFlow_1uiz85h</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1uiz85h" sourceRef="Task_09nzhwk" targetRef="EndEvent_1x6k78c" /> + <bpmn:sequenceFlow id="SequenceFlow_0g5bwvl" sourceRef="instantiate_NSTask" targetRef="ScriptTask_18rzwzb" /> + <bpmn:scriptTask id="ScriptTask_18rzwzb" name="Create Allottedsource" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0g5bwvl</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_17u69c4</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcsi = new DoCreateSliceServiceInstance() +dcsi.createAllottedResource(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_17u69c4" sourceRef="ScriptTask_18rzwzb" targetRef="Task_09nzhwk" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCreateSliceServiceInstance"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="createNS_StartEvent"> + <dc:Bounds x="175" y="111" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="152" y="147" width="83" height="24" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1qo2pln_di" bpmnElement="SequenceFlow_1qo2pln"> + <di:waypoint x="211" y="129" /> + <di:waypoint x="251" y="129" /> + <di:waypoint x="251" y="129" /> + <di:waypoint x="293" y="129" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="266" y="123" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0khtova_di" bpmnElement="SequenceFlow_0khtova"> + <di:waypoint x="393" y="129" /> + <di:waypoint x="474" y="129" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="436" y="108" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1dw39hg_di" bpmnElement="Task_09nzhwk"> + <dc:Bounds x="851" y="89" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_03j6ogo_di" bpmnElement="PreprocessIncomingRequest_task"> + <dc:Bounds x="293" y="89" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1qmmew8_di" bpmnElement="instantiate_NSTask"> + <dc:Bounds x="474" y="89" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_15pcuuc_di" bpmnElement="EndEvent_1x6k78c"> + <dc:Bounds x="1049" y="111" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="412" y="617" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1uiz85h_di" bpmnElement="SequenceFlow_1uiz85h"> + <di:waypoint x="951" y="129" /> + <di:waypoint x="1049" y="129" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="631" y="108" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0g5bwvl_di" bpmnElement="SequenceFlow_0g5bwvl"> + <di:waypoint x="574" y="129" /> + <di:waypoint x="658" y="129" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_18rzwzb_di" bpmnElement="ScriptTask_18rzwzb"> + <dc:Bounds x="658" y="89" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_17u69c4_di" bpmnElement="SequenceFlow_17u69c4"> + <di:waypoint x="758" y="129" /> + <di:waypoint x="851" y="129" /> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn new file mode 100644 index 0000000000..435f91921d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn @@ -0,0 +1,338 @@ +<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.3"> + <bpmn:process id="DoCreateSliceServiceOption" name="DoCreateSliceServiceOption" isExecutable="true"> + <bpmn:startEvent id="createNS_StartEvent" name="createOption_StartEvent"> + <bpmn:outgoing>SequenceFlow_1qo2pln</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:sequenceFlow id="SequenceFlow_1qo2pln" sourceRef="createNS_StartEvent" targetRef="PreprocessIncomingRequest_task" /> + <bpmn:sequenceFlow id="SequenceFlow_0khtova" sourceRef="PreprocessIncomingRequest_task" targetRef="ExclusiveGateway_0b9d9l0" /> + <bpmn:scriptTask id="Task_09nzhwk" name="send request to OOF for NSI options" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1h5bw41</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1utpplq</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.getNSIOptionfromOOF(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="PreprocessIncomingRequest_task" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1qo2pln</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0khtova</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0cq2q6g" sourceRef="finishNSCreate_Task" targetRef="ScriptTask_0j3wd2o" /> + <bpmn:endEvent id="EndEvent_1x6k78c"> + <bpmn:incoming>SequenceFlow_01ak5x3</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1ap8kar</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0hnsycl</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="finishNSCreate_Task" name="prepare list of NSSI associated with NSI" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_15679e8</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0cq2q6g</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.prepareNSSIList(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="ExclusiveGateway_0b9d9l0" default="SequenceFlow_0ueeeca"> + <bpmn:incoming>SequenceFlow_0khtova</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1h5bw41</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0ueeeca</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_1h5bw41" name="NSI Sharable" sourceRef="ExclusiveGateway_0b9d9l0" targetRef="Task_09nzhwk"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isSharable" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:scriptTask id="ScriptTask_1ehyrsg" name="update task status in request DB" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0ueeeca</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0ojueqq</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.updateStatusInDB(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0ueeeca" name="NSI Not Sharable" sourceRef="ExclusiveGateway_0b9d9l0" targetRef="ScriptTask_1ehyrsg" /> + <bpmn:endEvent id="EndEvent_00n990e"> + <bpmn:incoming>SequenceFlow_0ojueqq</bpmn:incoming> + </bpmn:endEvent> + <bpmn:scriptTask id="ScriptTask_0j3wd2o" name="updated options in request DB" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0cq2q6g</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_01ak5x3</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.updateOptionsInDB(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_01ak5x3" sourceRef="ScriptTask_0j3wd2o" targetRef="EndEvent_1x6k78c" /> + <bpmn:scriptTask id="ScriptTask_0kecvrc" name="prepare list of NSST associated with NST" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1614gtr</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0lt2cdo</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.prepareNSSTlistfromNST(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="ScriptTask_1mlytov" name="send request to OOF for NSSI options" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0a5f5y6</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1r9n9ef</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.getNSSTOption(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="ExclusiveGateway_1y1wzs9"> + <bpmn:incoming>SequenceFlow_0lt2cdo</bpmn:incoming> + <bpmn:incoming>SequenceFlow_00gq7h2</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1ap8kar</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0m2mr0o</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_1ap8kar" sourceRef="ExclusiveGateway_1y1wzs9" targetRef="EndEvent_1x6k78c"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isMoreNSSTtoProcess" ) == false)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0lt2cdo" sourceRef="ScriptTask_0kecvrc" targetRef="ExclusiveGateway_1y1wzs9" /> + <bpmn:sequenceFlow id="SequenceFlow_0m2mr0o" sourceRef="ExclusiveGateway_1y1wzs9" targetRef="ScriptTask_1e5ysya"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isMoreNSSTtoProcess" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:scriptTask id="ScriptTask_0ojz4lj" name="save NSI and NSSI options in DB" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1r9n9ef</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_00gq7h2</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.updateOptionsInDB(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1r9n9ef" sourceRef="ScriptTask_1mlytov" targetRef="ScriptTask_0ojz4lj" /> + <bpmn:sequenceFlow id="SequenceFlow_00gq7h2" sourceRef="ScriptTask_0ojz4lj" targetRef="ExclusiveGateway_1y1wzs9" /> + <bpmn:sequenceFlow id="SequenceFlow_0ojueqq" sourceRef="ScriptTask_1ehyrsg" targetRef="EndEvent_00n990e" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_1mdr1l2" default="SequenceFlow_1614gtr"> + <bpmn:incoming>SequenceFlow_041f5ne</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_15679e8</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1614gtr</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_15679e8" sourceRef="ExclusiveGateway_1mdr1l2" targetRef="finishNSCreate_Task"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isNSISuggested" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1614gtr" sourceRef="ExclusiveGateway_1mdr1l2" targetRef="ScriptTask_0kecvrc" /> + <bpmn:scriptTask id="ScriptTask_0uu3j3h" name="prepare NST decomposition" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0wy6oag</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1jnsyix</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.prepareNSTDecompose(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="CallActivity_1qs8xd5" name="Call Decompose Service" calledElement="DecomposeService"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> + <camunda:in source="serviceModelInfo" target="serviceModelInfo" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1jnsyix</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_041f5ne</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="ScriptTask_1e5ysya" name="prepare NSST decomposition" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0m2mr0o</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_016vi3s</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.prepareNSSTDecompose(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_016vi3s" sourceRef="ScriptTask_1e5ysya" targetRef="CallActivity_1rfnoe2" /> + <bpmn:callActivity id="CallActivity_1rfnoe2" name="Call Decompose Service" calledElement="DecomposeService"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="serviceInstanceId" target="serviceInstanceId" /> + <camunda:in source="serviceModelInfo" target="serviceModelInfo" /> + <camunda:in source="isDebugLogEnabled" target="isDebugLogEnabled" /> + <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_016vi3s</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0a5f5y6</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:sequenceFlow id="SequenceFlow_0a5f5y6" sourceRef="CallActivity_1rfnoe2" targetRef="ScriptTask_1mlytov" /> + <bpmn:sequenceFlow id="SequenceFlow_1utpplq" sourceRef="Task_09nzhwk" targetRef="ExclusiveGateway_1skfk7w" /> + <bpmn:sequenceFlow id="SequenceFlow_1jnsyix" sourceRef="ScriptTask_0uu3j3h" targetRef="CallActivity_1qs8xd5" /> + <bpmn:sequenceFlow id="SequenceFlow_041f5ne" sourceRef="CallActivity_1qs8xd5" targetRef="ExclusiveGateway_1mdr1l2" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_1skfk7w" default="SequenceFlow_0wy6oag"> + <bpmn:incoming>SequenceFlow_1utpplq</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0wy6oag</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0hnsycl</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_0wy6oag" sourceRef="ExclusiveGateway_1skfk7w" targetRef="ScriptTask_0uu3j3h" /> + <bpmn:sequenceFlow id="SequenceFlow_0hnsycl" sourceRef="ExclusiveGateway_1skfk7w" targetRef="EndEvent_1x6k78c"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{(execution.getVariable("isNSISuggested" ) == true)}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCreateSliceServiceOption"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="createNS_StartEvent"> + <dc:Bounds x="175" y="187" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="150" y="223" width="87" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1qo2pln_di" bpmnElement="SequenceFlow_1qo2pln"> + <di:waypoint x="211" y="205" /> + <di:waypoint x="251" y="205" /> + <di:waypoint x="251" y="205" /> + <di:waypoint x="293" y="205" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="266" y="123" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0khtova_di" bpmnElement="SequenceFlow_0khtova"> + <di:waypoint x="393" y="205" /> + <di:waypoint x="448" y="205" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="436" y="108" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1dw39hg_di" bpmnElement="Task_09nzhwk"> + <dc:Bounds x="594" y="165" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_03j6ogo_di" bpmnElement="PreprocessIncomingRequest_task"> + <dc:Bounds x="293" y="165" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0cq2q6g_di" bpmnElement="SequenceFlow_0cq2q6g"> + <di:waypoint x="1536" y="205" /> + <di:waypoint x="1592" y="205" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="556.5" y="574" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_15pcuuc_di" bpmnElement="EndEvent_1x6k78c"> + <dc:Bounds x="1813" y="187" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="412" y="617" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0xxyfku_di" bpmnElement="finishNSCreate_Task"> + <dc:Bounds x="1436" y="165" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_0b9d9l0_di" bpmnElement="ExclusiveGateway_0b9d9l0" isMarkerVisible="true"> + <dc:Bounds x="448" y="180" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1h5bw41_di" bpmnElement="SequenceFlow_1h5bw41"> + <di:waypoint x="498" y="205" /> + <di:waypoint x="594" y="205" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="514" y="187" width="66" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1ehyrsg_di" bpmnElement="ScriptTask_1ehyrsg"> + <dc:Bounds x="602" y="-197" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0ueeeca_di" bpmnElement="SequenceFlow_0ueeeca"> + <di:waypoint x="473" y="180" /> + <di:waypoint x="473" y="-157" /> + <di:waypoint x="602" y="-157" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="415" y="14" width="86" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_00n990e_di" bpmnElement="EndEvent_00n990e"> + <dc:Bounds x="785" y="-175" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0j3wd2o_di" bpmnElement="ScriptTask_0j3wd2o"> + <dc:Bounds x="1592" y="165" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_01ak5x3_di" bpmnElement="SequenceFlow_01ak5x3"> + <di:waypoint x="1692" y="205" /> + <di:waypoint x="1813" y="205" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0kecvrc_di" bpmnElement="ScriptTask_0kecvrc"> + <dc:Bounds x="1297" y="391" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1mlytov_di" bpmnElement="ScriptTask_1mlytov"> + <dc:Bounds x="1781" y="533" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_1y1wzs9_di" bpmnElement="ExclusiveGateway_1y1wzs9" isMarkerVisible="true"> + <dc:Bounds x="1461" y="406" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1ap8kar_di" bpmnElement="SequenceFlow_1ap8kar"> + <di:waypoint x="1486" y="406" /> + <di:waypoint x="1486" y="315" /> + <di:waypoint x="1831" y="315" /> + <di:waypoint x="1831" y="223" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0lt2cdo_di" bpmnElement="SequenceFlow_0lt2cdo"> + <di:waypoint x="1397" y="431" /> + <di:waypoint x="1461" y="431" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0m2mr0o_di" bpmnElement="SequenceFlow_0m2mr0o"> + <di:waypoint x="1511" y="431" /> + <di:waypoint x="1592" y="431" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0ojz4lj_di" bpmnElement="ScriptTask_0ojz4lj"> + <dc:Bounds x="1592" y="533" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1r9n9ef_di" bpmnElement="SequenceFlow_1r9n9ef"> + <di:waypoint x="1781" y="573" /> + <di:waypoint x="1692" y="573" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_00gq7h2_di" bpmnElement="SequenceFlow_00gq7h2"> + <di:waypoint x="1592" y="573" /> + <di:waypoint x="1486" y="573" /> + <di:waypoint x="1486" y="456" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0ojueqq_di" bpmnElement="SequenceFlow_0ojueqq"> + <di:waypoint x="702" y="-157" /> + <di:waypoint x="785" y="-157" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_1mdr1l2_di" bpmnElement="ExclusiveGateway_1mdr1l2" isMarkerVisible="true"> + <dc:Bounds x="1322" y="180" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_15679e8_di" bpmnElement="SequenceFlow_15679e8"> + <di:waypoint x="1372" y="205" /> + <di:waypoint x="1436" y="205" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1614gtr_di" bpmnElement="SequenceFlow_1614gtr"> + <di:waypoint x="1347" y="230" /> + <di:waypoint x="1347" y="391" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0uu3j3h_di" bpmnElement="ScriptTask_0uu3j3h"> + <dc:Bounds x="967" y="165" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_1qs8xd5_di" bpmnElement="CallActivity_1qs8xd5"> + <dc:Bounds x="1136" y="165" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1e5ysya_di" bpmnElement="ScriptTask_1e5ysya"> + <dc:Bounds x="1592" y="391" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_016vi3s_di" bpmnElement="SequenceFlow_016vi3s"> + <di:waypoint x="1692" y="431" /> + <di:waypoint x="1781" y="431" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="CallActivity_1rfnoe2_di" bpmnElement="CallActivity_1rfnoe2"> + <dc:Bounds x="1781" y="391" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0a5f5y6_di" bpmnElement="SequenceFlow_0a5f5y6"> + <di:waypoint x="1881" y="431" /> + <di:waypoint x="1968" y="431" /> + <di:waypoint x="1968" y="573" /> + <di:waypoint x="1881" y="573" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1utpplq_di" bpmnElement="SequenceFlow_1utpplq"> + <di:waypoint x="694" y="205" /> + <di:waypoint x="796" y="205" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1jnsyix_di" bpmnElement="SequenceFlow_1jnsyix"> + <di:waypoint x="1067" y="205" /> + <di:waypoint x="1136" y="205" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_041f5ne_di" bpmnElement="SequenceFlow_041f5ne"> + <di:waypoint x="1236" y="205" /> + <di:waypoint x="1322" y="205" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_1skfk7w_di" bpmnElement="ExclusiveGateway_1skfk7w" isMarkerVisible="true"> + <dc:Bounds x="796" y="180" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0wy6oag_di" bpmnElement="SequenceFlow_0wy6oag"> + <di:waypoint x="846" y="205" /> + <di:waypoint x="967" y="205" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0hnsycl_di" bpmnElement="SequenceFlow_0hnsycl"> + <di:waypoint x="821" y="180" /> + <di:waypoint x="821" y="90" /> + <di:waypoint x="1831" y="90" /> + <di:waypoint x="1831" y="187" /> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoSendCommandToNSSMF.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoSendCommandToNSSMF.bpmn new file mode 100644 index 0000000000..4f12ca7f41 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoSendCommandToNSSMF.bpmn @@ -0,0 +1,344 @@ +<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_13dsy4w" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.1"> + <bpmn:collaboration id="Collaboration_0htncd8"> + <bpmn:participant id="DoSendCommandToNSSMF01" name="DoSendCommandToNSSMF" processRef="DoSendCommandToNSSMF" /> + </bpmn:collaboration> + <bpmn:process id="DoSendCommandToNSSMF" name="DoSendCommandToNSSMF" isExecutable="true"> + <bpmn:scriptTask id="Task_0qx12sa" name="Get one NSSI info from list" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0umnozs</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1vuuuhr</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1ea3pk8</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def csi= new DoSendCommandToNSSMF() +csi.getNSSIformlist(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="ExclusiveGateway_18qkm4u" name="Activation completed?"> + <bpmn:incoming>SequenceFlow_1yjsv5s</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1qxmooy</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1lh0it1</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0swcqw8</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:exclusiveGateway id="ExclusiveGateway_07yenxg" name="Get successful?"> + <bpmn:incoming>SequenceFlow_1ea3pk8</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_080lgb0</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1oi86yc</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_1vuuuhr" sourceRef="ServiceTask_0myj742" targetRef="Task_0qx12sa" /> + <bpmn:sequenceFlow id="SequenceFlow_1oeexsj" sourceRef="Task_1a9qxuo" targetRef="ServiceTask_0myj742" /> + <bpmn:sequenceFlow id="SequenceFlow_1ea3pk8" sourceRef="Task_0qx12sa" targetRef="ExclusiveGateway_07yenxg" /> + <bpmn:sequenceFlow id="SequenceFlow_1yjsv5s" sourceRef="Task_1y09kt4" targetRef="ExclusiveGateway_18qkm4u" /> + <bpmn:sequenceFlow id="SequenceFlow_0swcqw8" name="waitting" sourceRef="ExclusiveGateway_18qkm4u" targetRef="Task_08qjojj"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("isActivateSuccessfull") == "waitting"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1lh0it1" name="no" sourceRef="ExclusiveGateway_18qkm4u" targetRef="EndEvent_0k52g73"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("isActivateSuccessfull") == "false"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_1qxmooy" name="yes" sourceRef="ExclusiveGateway_18qkm4u" targetRef="Task_1a9qxuo"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("isActivateSuccessfull") == "true"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_080lgb0" name="yes" sourceRef="ExclusiveGateway_07yenxg" targetRef="CallActivity_0018jhc"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("isGetSuccessfull") == "true"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_08xfw41" sourceRef="Task_0xfp2r8" targetRef="ExclusiveGateway_0ljwjfh" /> + <bpmn:sequenceFlow id="SequenceFlow_1s2oozd" name="yes" sourceRef="ExclusiveGateway_0ljwjfh" targetRef="Task_08qjojj"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("isNSSIActivated") == "true"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_020xvv4" name="no" sourceRef="ExclusiveGateway_0ljwjfh" targetRef="EndEvent_0k52g73"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("isNSSIActivated") == "false"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_10162l8" sourceRef="Task_08qjojj" targetRef="Task_1y09kt4" /> + <bpmn:sequenceFlow id="SequenceFlow_1pfo460" sourceRef="StartEvent_1" targetRef="ScriptTask_1otgwej" /> + <bpmn:sequenceFlow id="SequenceFlow_1oi86yc" name="no" sourceRef="ExclusiveGateway_07yenxg" targetRef="EndEvent_0d1g3mv"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("isGetSuccessfull") == "false"}</bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:endEvent id="EndEvent_0d1g3mv"> + <bpmn:incoming>SequenceFlow_1oi86yc</bpmn:incoming> + </bpmn:endEvent> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>SequenceFlow_1pfo460</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="ScriptTask_1otgwej" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1pfo460</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0umnozs</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoSendCommandToNSSMF() +dcso.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:subProcess id="SubProcess_0iljxjd" name="sub process for fallouthandler and rollback" triggeredByEvent="true"> + <bpmn:startEvent id="StartEvent_0hmwdqq"> + <bpmn:outgoing>SequenceFlow_0oiiwjo</bpmn:outgoing> + <bpmn:errorEventDefinition id="ErrorEventDefinition_1il80ww" /> + </bpmn:startEvent> + <bpmn:endEvent id="EndEvent_1wd8iqk"> + <bpmn:incoming>SequenceFlow_0uckyao</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_0oiiwjo" sourceRef="StartEvent_0hmwdqq" targetRef="Task_01ooik6" /> + <bpmn:sequenceFlow id="SequenceFlow_0uckyao" sourceRef="Task_01ooik6" targetRef="EndEvent_1wd8iqk" /> + <bpmn:scriptTask id="Task_01ooik6" name="Send Error Response" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0oiiwjo</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0uckyao</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def csi= new DoSendCommandToNSSMF() +csi.sendSyncError(execution)</bpmn:script> + </bpmn:scriptTask> + </bpmn:subProcess> + <bpmn:sequenceFlow id="SequenceFlow_0umnozs" sourceRef="ScriptTask_1otgwej" targetRef="Task_0qx12sa" /> + <bpmn:sequenceFlow id="SequenceFlow_1ucjcm1" sourceRef="CallActivity_0018jhc" targetRef="ScriptTask_0q7is68" /> + <bpmn:endEvent id="EndEvent_0k52g73"> + <bpmn:incoming>SequenceFlow_020xvv4</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1lh0it1</bpmn:incoming> + <bpmn:errorEventDefinition id="ErrorEventDefinition_0fypnen" errorRef="Error_08p7hsc" /> + </bpmn:endEvent> + <bpmn:scriptTask id="Task_08qjojj" name="wait for Return" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1s2oozd</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0swcqw8</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_10162l8</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def csi= new DoSendCommandToNSSMF() +csi.WaitForReturn(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:scriptTask id="Task_1y09kt4" name="Get the activation status" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_10162l8</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1yjsv5s</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def csi= new DoSendCommandToNSSMF() +csi.GetTheStatusOfActivation(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:exclusiveGateway id="ExclusiveGateway_0ljwjfh" name="Activation successful?"> + <bpmn:incoming>SequenceFlow_08xfw41</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1s2oozd</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_020xvv4</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:scriptTask id="Task_0xfp2r8" name="SendCommandToNssmf" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1a6iu8c</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_08xfw41</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def csi= new DoSendCommandToNSSMF() +csi.SendCommandToNssmf(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:callActivity id="CallActivity_0018jhc" name="Call Decompose Service" calledElement="DecomposeService"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="nssiId" target="serviceInstanceId" /> + <camunda:in source="serviceModelInfo" target="serviceModelInfo" /> + <camunda:out source="serviceDecomposition" target="serviceDecomposition" /> + <camunda:out source="serviceDecompositionString" target="serviceDecompositionString" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_080lgb0</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1ucjcm1</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="ScriptTask_0q7is68" name="processDecomposition" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1ucjcm1</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1a6iu8c</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def csi= new DoSendCommandToNSSMF() +csi.processDecomposition(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1a6iu8c" sourceRef="ScriptTask_0q7is68" targetRef="Task_0xfp2r8" /> + <bpmn:serviceTask id="ServiceTask_0myj742" name="Update Service Operation Status"> + <bpmn: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 YnBlbDpwYXNzd29yZDEk</camunda:entry> + </camunda:map> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${CVFMI_updateServiceOperStatusRequest}</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> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1oeexsj</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1vuuuhr</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:scriptTask id="Task_1a9qxuo" name="Update Index" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1qxmooy</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1oeexsj</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def csi= new DoSendCommandToNSSMF() +csi.UpdateIndex(execution)</bpmn:script> + </bpmn:scriptTask> + </bpmn:process> + <bpmn:error id="Error_08p7hsc" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0htncd8"> + <bpmndi:BPMNShape id="Participant_1x12pgg_di" bpmnElement="DoSendCommandToNSSMF01" isHorizontal="true"> + <dc:Bounds x="160" y="60" width="2080" height="1000" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0d1g3mv_di" bpmnElement="EndEvent_0d1g3mv"> + <dc:Bounds x="1642" y="302" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="262" y="302" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0uckyao_di" bpmnElement="SequenceFlow_0uckyao"> + <di:waypoint x="1120" y="860" /> + <di:waypoint x="1257" y="860" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0oiiwjo_di" bpmnElement="SequenceFlow_0oiiwjo"> + <di:waypoint x="843" y="860" /> + <di:waypoint x="1020" y="860" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_0hmwdqq_di" bpmnElement="StartEvent_0hmwdqq"> + <dc:Bounds x="807" y="842" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1wd8iqk_di" bpmnElement="EndEvent_1wd8iqk"> + <dc:Bounds x="1257" y="842" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0s82iw4_di" bpmnElement="Task_0xfp2r8"> + <dc:Bounds x="1230" y="280" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_18qkm4u_di" bpmnElement="ExclusiveGateway_18qkm4u" isMarkerVisible="true"> + <dc:Bounds x="835" y="595" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="832" y="558" width="55" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1ea3pk8_di" bpmnElement="SequenceFlow_1ea3pk8"> + <di:waypoint x="770" y="320" /> + <di:waypoint x="815" y="320" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_08xfw41_di" bpmnElement="SequenceFlow_08xfw41"> + <di:waypoint x="1330" y="320" /> + <di:waypoint x="1415" y="320" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1yjsv5s_di" bpmnElement="SequenceFlow_1yjsv5s"> + <di:waypoint x="1390" y="620" /> + <di:waypoint x="885" y="620" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_0ljwjfh_di" bpmnElement="ExclusiveGateway_0ljwjfh" isMarkerVisible="true"> + <dc:Bounds x="1415" y="295" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1412" y="265" width="60" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1s2oozd_di" bpmnElement="SequenceFlow_1s2oozd"> + <di:waypoint x="1440" y="345" /> + <di:waypoint x="1440" y="420" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1451" y="373" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_0k52g73_di" bpmnElement="EndEvent_0k52g73"> + <dc:Bounds x="1532" y="302" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_020xvv4_di" bpmnElement="SequenceFlow_020xvv4"> + <di:waypoint x="1465" y="320" /> + <di:waypoint x="1532" y="320" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1494" y="302" width="12" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_121jfnq_di" bpmnElement="Task_0qx12sa"> + <dc:Bounds x="670" y="280" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_07yenxg_di" bpmnElement="ExclusiveGateway_07yenxg" isMarkerVisible="true"> + <dc:Bounds x="815" y="295" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="800" y="353" width="80" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_080lgb0_di" bpmnElement="SequenceFlow_080lgb0"> + <di:waypoint x="865" y="320" /> + <di:waypoint x="930" y="320" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="869" y="302" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_10162l8_di" bpmnElement="SequenceFlow_10162l8"> + <di:waypoint x="1440" y="500" /> + <di:waypoint x="1440" y="580" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1qxmooy_di" bpmnElement="SequenceFlow_1qxmooy"> + <di:waypoint x="835" y="620" /> + <di:waypoint x="770" y="620" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="813" y="623" width="18" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0aspjme_di" bpmnElement="Task_1a9qxuo"> + <dc:Bounds x="670" y="580" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_170g0ll_di" bpmnElement="Task_08qjojj"> + <dc:Bounds x="1390" y="420" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1meh39q_di" bpmnElement="Task_1y09kt4"> + <dc:Bounds x="1390" y="580" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1lh0it1_di" bpmnElement="SequenceFlow_1lh0it1"> + <di:waypoint x="860" y="645" /> + <di:waypoint x="860" y="720" /> + <di:waypoint x="1550" y="720" /> + <di:waypoint x="1550" y="338" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1110" y="702" width="12" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0swcqw8_di" bpmnElement="SequenceFlow_0swcqw8"> + <di:waypoint x="860" y="595" /> + <di:waypoint x="860" y="460" /> + <di:waypoint x="1390" y="460" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1067" y="443" width="38" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1oeexsj_di" bpmnElement="SequenceFlow_1oeexsj"> + <di:waypoint x="720" y="580" /> + <di:waypoint x="720" y="520" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0myj742_di" bpmnElement="ServiceTask_0myj742"> + <dc:Bounds x="670" y="440" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1vuuuhr_di" bpmnElement="SequenceFlow_1vuuuhr"> + <di:waypoint x="720" y="440" /> + <di:waypoint x="720" y="360" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1pfo460_di" bpmnElement="SequenceFlow_1pfo460"> + <di:waypoint x="298" y="320" /> + <di:waypoint x="420" y="320" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1oi86yc_di" bpmnElement="SequenceFlow_1oi86yc"> + <di:waypoint x="840" y="295" /> + <di:waypoint x="840" y="230" /> + <di:waypoint x="1660" y="230" /> + <di:waypoint x="1660" y="302" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="884" y="212" width="12" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1otgwej_di" bpmnElement="ScriptTask_1otgwej"> + <dc:Bounds x="420" y="280" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="SubProcess_1hlwd77_di" bpmnElement="SubProcess_0iljxjd" isExpanded="true"> + <dc:Bounds x="700" y="780" width="810" height="180" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_1c5l0io_di" bpmnElement="Task_01ooik6"> + <dc:Bounds x="1020" y="820" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0umnozs_di" bpmnElement="SequenceFlow_0umnozs"> + <di:waypoint x="520" y="320" /> + <di:waypoint x="670" y="320" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="CallActivity_0018jhc_di" bpmnElement="CallActivity_0018jhc"> + <dc:Bounds x="930" y="280" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1ucjcm1_di" bpmnElement="SequenceFlow_1ucjcm1"> + <di:waypoint x="1030" y="320" /> + <di:waypoint x="1070" y="320" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0q7is68_di" bpmnElement="ScriptTask_0q7is68"> + <dc:Bounds x="1070" y="280" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1a6iu8c_di" bpmnElement="SequenceFlow_1a6iu8c"> + <di:waypoint x="1170" y="320" /> + <di:waypoint x="1230" y="320" /> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/HandleOrchestrationTask.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/HandleOrchestrationTask.bpmn new file mode 100644 index 0000000000..09a14be26b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/HandleOrchestrationTask.bpmn @@ -0,0 +1,90 @@ +<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1gbzu9i" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.1.2"> + <bpmn:process id="HandleOrchestrationTask" name="HandleOrchestrationTask" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1" name="Start"> + <bpmn:outgoing>SequenceFlow_0lbtmuu</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="ScriptTask_0r0a9ga" name="Preprocess Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0lbtmuu</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0uzjpd6</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def hot = new HandleOrchestrationTask() +hot.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:serviceTask id="ServiceTask_1iat8g5" name="Send Orchestration Task Request"> + <bpmn:extensionElements> + <camunda:connector> + <camunda:inputOutput> + <camunda:inputParameter name="url">${url}</camunda:inputParameter> + <camunda:inputParameter name="headers"> + <camunda:script scriptFormat="groovy">execution.getVariable("headerMap")</camunda:script> + </camunda:inputParameter> + <camunda:inputParameter name="payload">${payload}</camunda:inputParameter> + <camunda:inputParameter name="method">${method}</camunda:inputParameter> + <camunda:outputParameter name="statusCode">${statusCode}</camunda:outputParameter> + <camunda:outputParameter name="response">${response}</camunda:outputParameter> + </camunda:inputOutput> + <camunda:connectorId>http-connector</camunda:connectorId> + </camunda:connector> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_0uzjpd6</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_06rrzml</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:scriptTask id="ScriptTask_119zm52" name="Post Process" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_06rrzml</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1qthzdo</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def hot = new HandleOrchestrationTask() +hot.postProcess(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_0uzjpd6" sourceRef="ScriptTask_0r0a9ga" targetRef="ServiceTask_1iat8g5" /> + <bpmn:sequenceFlow id="SequenceFlow_06rrzml" sourceRef="ServiceTask_1iat8g5" targetRef="ScriptTask_119zm52" /> + <bpmn:sequenceFlow id="SequenceFlow_0lbtmuu" sourceRef="StartEvent_1" targetRef="ScriptTask_0r0a9ga" /> + <bpmn:endEvent id="EndEvent_18t5h42" name="End"> + <bpmn:incoming>SequenceFlow_1qthzdo</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1qthzdo" sourceRef="ScriptTask_119zm52" targetRef="EndEvent_18t5h42" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="HandleOrchestrationTask"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="179" y="103" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="185" y="146" width="25" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0r0a9ga_di" bpmnElement="ScriptTask_0r0a9ga"> + <dc:Bounds x="284" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1iat8g5_di" bpmnElement="ServiceTask_1iat8g5"> + <dc:Bounds x="466" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_119zm52_di" bpmnElement="ScriptTask_119zm52"> + <dc:Bounds x="644" y="81" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0uzjpd6_di" bpmnElement="SequenceFlow_0uzjpd6"> + <di:waypoint x="384" y="121" /> + <di:waypoint x="466" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_06rrzml_di" bpmnElement="SequenceFlow_06rrzml"> + <di:waypoint x="566" y="121" /> + <di:waypoint x="644" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0lbtmuu_di" bpmnElement="SequenceFlow_0lbtmuu"> + <di:waypoint x="215" y="121" /> + <di:waypoint x="284" y="121" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_18t5h42_di" bpmnElement="EndEvent_18t5h42"> + <dc:Bounds x="820" y="103" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="828" y="146" width="20" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1qthzdo_di" bpmnElement="SequenceFlow_1qthzdo"> + <di:waypoint x="744" y="121" /> + <di:waypoint x="820" y="121" /> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> + diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java index 95e270a071..40034aa26c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java @@ -24,7 +24,6 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext; import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable; import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable; -import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.ExceptionBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,9 +43,6 @@ public abstract class LcmControllerDE implements ControllerRunnable<DelegateExec @Autowired protected List<ControllerPreparable<DelegateExecution>> prepareList; - @Autowired - protected ApplicationControllerAction client; - @Override public void prepare(ControllerContext<DelegateExecution> context) { prepareList.stream().filter(prepare -> prepare.understand(context)) diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/common/SoPropertyConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/common/SoPropertyConstants.java new file mode 100644 index 0000000000..badce18a51 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/common/SoPropertyConstants.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.infrastructure.decisionpoint.impl.camunda.controller.common; + +public interface SoPropertyConstants { + String TARGET_SOFTWARE_VERSION = "targetSoftwareVersion"; + + String SO_ACTION = "action"; + String SO_ACTION_MODE = "mode"; + + String ACTION_ACTIVATE_N_E_SW = "activateNESw"; + String ACTION_DOWNLOAD_N_E_SW = "downloadNESw"; + String ACTION_POST_CHECK = "postCheck"; + String ACTION_PRE_CHECK = "preCheck"; + + String CONTROLLER_STATUS = "ControllerStatus"; +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilder.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilder.java new file mode 100644 index 0000000000..b29009ff1d --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilder.java @@ -0,0 +1,153 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.infrastructure.decisionpoint.impl.camunda.controller.sdnc; + +import java.util.Arrays; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.client.sdnc.lcm.beans.payload.*; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_PAYLOAD; +import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common.SoPropertyConstants; + +public class SDNCLcmPayloadBuilder { + + private static Logger logger = LoggerFactory.getLogger(SDNCLcmPayloadBuilder.class); + + public static ActivateNESwPayload buildActivateNESwPayload(DelegateExecution execution) { + String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD)); + + ActivateNESwPayload activateNESwPayload = new ActivateNESwPayload(); + + String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam"); + activateNESwPayload.setIpaddressV4Oam(ipaddressV4Oam); + + String targetSwVersion = String.valueOf(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION)); + if (targetSwVersion == null) { + targetSwVersion = JsonUtils.getJsonValue(requestPayload, "targetSwVersion"); + } + activateNESwPayload.setSwVersionToBeActivated(targetSwVersion); + + String playbookName = JsonUtils.getJsonValue(requestPayload, "activateNESwPlaybook"); + if (playbookName != null) { + activateNESwPayload.setPlaybookName(playbookName); + } + + return activateNESwPayload; + } + + public static DownloadNESwPayload buildDownloadNESwPayload(DelegateExecution execution) { + String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD)); + + DownloadNESwPayload downloadNESwPayload = new DownloadNESwPayload(); + + String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam"); + downloadNESwPayload.setIpaddressV4Oam(ipaddressV4Oam); + + String swToBeDownloadedString = JsonUtils.getJsonValue(requestPayload, "swToBeDownloaded"); + SwToBeDownloadedElement[] swToBeDownloadedArray; + + ObjectMapper mapper = new ObjectMapper(); + try { + swToBeDownloadedArray = mapper.readValue(swToBeDownloadedString, SwToBeDownloadedElement[].class); + downloadNESwPayload.setSwToBeDownloaded(Arrays.asList(swToBeDownloadedArray)); + } catch (Exception e) { + logger.error("Parse SwToBeDownloaded error: ", e); + } + + String playbookName = JsonUtils.getJsonValue(requestPayload, "downloadNESwPlaybook"); + if (playbookName != null) { + downloadNESwPayload.setPlaybookName(playbookName); + } + + return downloadNESwPayload; + } + + public static UpgradePostCheckPayload buildUpgradePostCheckPayload(DelegateExecution execution) { + String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD)); + + UpgradePostCheckPayload upgradePostCheckPayload = new UpgradePostCheckPayload(); + + String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam"); + upgradePostCheckPayload.setIpaddressV4Oam(ipaddressV4Oam); + + String oldSwVersion = JsonUtils.getJsonValue(requestPayload, "oldSwVersion"); + upgradePostCheckPayload.setOldSwVersion(oldSwVersion); + + String targetSwVersion = String.valueOf(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION)); + if (targetSwVersion == null) { + targetSwVersion = JsonUtils.getJsonValue(requestPayload, "targetSwVersion"); + } + upgradePostCheckPayload.setTargetSwVersion(targetSwVersion); + + String ruleName = JsonUtils.getJsonValue(requestPayload, "postCheckRuleName"); + upgradePostCheckPayload.setRuleName(ruleName); + + String additionalData = JsonUtils.getJsonValue(requestPayload, "postCheckAdditionalData"); + upgradePostCheckPayload.setAdditionalData(additionalData); + + String playbookName = JsonUtils.getJsonValue(requestPayload, "postCheckPlaybook"); + if (playbookName != null) { + upgradePostCheckPayload.setPlaybookName(playbookName); + } + + return upgradePostCheckPayload; + } + + public static UpgradePreCheckPayload buildUpgradePreCheckPayload(DelegateExecution execution) { + String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD)); + + UpgradePreCheckPayload upgradePreCheckPayload = new UpgradePreCheckPayload(); + + String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam"); + upgradePreCheckPayload.setIpaddressV4Oam(ipaddressV4Oam); + + String oldSwVersion = JsonUtils.getJsonValue(requestPayload, "oldSwVersion"); + upgradePreCheckPayload.setOldSwVersion(oldSwVersion); + + String targetSwVersion = String.valueOf(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION)); + if (targetSwVersion == null) { + targetSwVersion = JsonUtils.getJsonValue(requestPayload, "targetSwVersion"); + } + upgradePreCheckPayload.setTargetSwVersion(targetSwVersion); + + String ruleName = JsonUtils.getJsonValue(requestPayload, "preCheckRuleName"); + upgradePreCheckPayload.setRuleName(ruleName); + + String additionalData = JsonUtils.getJsonValue(requestPayload, "preCheckAdditionalData"); + upgradePreCheckPayload.setAdditionalData(additionalData); + + String playbookName = JsonUtils.getJsonValue(requestPayload, "preCheckPlaybook"); + if (playbookName != null) { + upgradePreCheckPayload.setPlaybookName(playbookName); + } + + return upgradePreCheckPayload; + } + + public static String convertToSting(Object msgObject) throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + return mapper.writeValueAsString(msgObject); + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java index db0d402f6e..ed865e058f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix + * Modifications Copyright (C) 2020 Huawei * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,16 +20,24 @@ package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.sdnc; +import java.util.List; +import java.util.UUID; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.stereotype.Component; import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.core.json.JsonUtils; import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext; +import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common.SoPropertyConstants; import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.LcmControllerDE; -import org.springframework.stereotype.Component; +import org.onap.so.client.sdnc.common.SDNCConstants; +import org.onap.so.client.sdnc.lcm.*; +import org.onap.so.client.sdnc.lcm.beans.*; +import org.onap.so.client.sdnc.lcm.beans.payload.*; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_PAYLOAD; -/** - * This class is created to demonstrate how to support {@link DelegateExecution} API based SDNC controller. - * - * Function wise, it's similar to the Appc Controller, like in the AppcClient groovy code. - */ @Component public class SdncControllerDE extends LcmControllerDE { @@ -44,14 +53,33 @@ public class SdncControllerDE extends LcmControllerDE { return true; } - /** - * This method is left empty intentionally. If you are planning to use the SDNC Controller, please implement here. - * - * You can use the {@ref ApplicationControllerAction}, {@ref ApplicationControllerOrchestrator}, - * {@ref ApplicationControllerClient} or create your own SDNC Client proxy. - */ @Override protected int callLcmClient(ControllerContext<DelegateExecution> context) { + DelegateExecution execution = context.getExecution(); + + logger.debug("Running activity for id: {}, name: {}", execution.getCurrentActivityId(), + execution.getCurrentActivityName()); + + boolean result; + try { + LcmInput lcmInput = buildLcmInput(execution); + if (lcmInput != null) { + result = sendLcmRequest(execution, lcmInput); + } else { + logger.error("Build LCM Input error"); + result = false; + } + } catch (Exception e) { + logger.error("Call SDNC LCM Client failure: ", e); + result = false; + } + + if (result) { + execution.setVariable(SoPropertyConstants.CONTROLLER_STATUS, "Success"); + } else { + execution.setVariable(SoPropertyConstants.CONTROLLER_STATUS, "Failure"); + } + return 0; } @@ -59,4 +87,177 @@ public class SdncControllerDE extends LcmControllerDE { protected int getErrorCode() { return SDNC_DELEGATE_EXECUTION_ERROR_CODE; } + + private LcmOutput sendSyncRequest(String operation, LcmInput lcmInput) { + SDNCLcmClientBuilder sdncLcmClientBuilder = new SDNCLcmClientBuilder(); + SDNCLcmRestClient sdncLcmRestClient; + try { + sdncLcmRestClient = sdncLcmClientBuilder.newSDNCLcmRestClient(operation); + } catch (SDNCLcmClientBuilderException e) { + logger.error("Create SDNCLcmRestClient error: ", e); + return null; + } + + return sdncLcmRestClient.sendRequest(lcmInput); + } + + private LcmOutput selectLcmOutputFromDmaapResponses(List<LcmDmaapResponse> lcmDmaapResponses, LcmInput lcmInput) { + String expectedCorrelationId = + lcmInput.getCommonHeader().getRequestId() + "-" + lcmInput.getCommonHeader().getSubRequestId(); + + for (LcmDmaapResponse lcmDmaapResponse : lcmDmaapResponses) { + String correlationId = lcmDmaapResponse.getCorrelationId(); + if (expectedCorrelationId.equals(correlationId)) { + return lcmDmaapResponse.getBody().getOutput(); + } + } + + return null; + } + + private LcmOutput sendAsyncRequest(String operation, LcmInput lcmInput) { + SDNCLcmClientBuilder sdncLcmClientBuilder = new SDNCLcmClientBuilder(); + SDNCLcmDmaapClient sdncLcmDmaapClient; + try { + sdncLcmDmaapClient = sdncLcmClientBuilder.newSDNCLcmDmaapClient(); + } catch (SDNCLcmClientBuilderException e) { + logger.error("Create SDNCLcmDmaapClient error: ", e); + return null; + } + + LcmDmaapRequest lcmDmaapRequest = SDNCLcmMessageBuilder.buildLcmDmaapRequest(operation, lcmInput); + try { + sdncLcmDmaapClient.sendRequest(lcmDmaapRequest); + } catch (Exception e) { + logger.error("SDNCLcmDmaapClient sends request error: ", e); + return null; + } + + long timeout = sdncLcmClientBuilder.getSDNCLcmProperties().getActionTimeout(); + long startTime = System.currentTimeMillis(); + while (true) { + List<LcmDmaapResponse> lcmDmaapResponses = sdncLcmDmaapClient.getResponse(); + if (lcmDmaapResponses.size() > 0) { + LcmOutput lcmOutput = selectLcmOutputFromDmaapResponses(lcmDmaapResponses, lcmInput); + if (lcmOutput != null) { + return lcmOutput; + } + } + + long stopTime = System.currentTimeMillis(); + if ((stopTime - startTime) > timeout) { + logger.error("Timeout for SDNC LCM action {}", lcmInput.getAction()); + return null; + } + } + } + + public static String toLowerHyphen(String lcmAction) { + String regex = "([a-z0-9A-Z])(?=[A-Z])"; + String replacement = "$1-"; + return lcmAction.replaceAll(regex, replacement).toLowerCase(); + } + + private LcmInput buildLcmInput(DelegateExecution execution) throws JsonProcessingException { + String requestId = String.valueOf(execution.getVariable(REQUEST_ID)); + String requestAction = String.valueOf(execution.getVariable(SoPropertyConstants.SO_ACTION)); + String pnfName = String.valueOf(execution.getVariable(PNF_CORRELATION_ID)); + logger.debug(String.format("requestId: %s, action: %s, pnfName: %s", requestId, requestAction, pnfName)); + + String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD)); + logger.debug("SO request payload: " + requestPayload); + + String lcmAction; + String lcmPayload; + + switch (requestAction) { + case SoPropertyConstants.ACTION_PRE_CHECK: + lcmAction = SDNCLcmActionConstants.UPGRADE_PRE_CHECK; + + UpgradePreCheckPayload upgradePreCheckPayload; + upgradePreCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePreCheckPayload(execution); + lcmPayload = SDNCLcmPayloadBuilder.convertToSting(upgradePreCheckPayload); + break; + case SoPropertyConstants.ACTION_DOWNLOAD_N_E_SW: + lcmAction = SDNCLcmActionConstants.DOWNLOAD_N_E_SW; + + DownloadNESwPayload downloadNESwPayload; + downloadNESwPayload = SDNCLcmPayloadBuilder.buildDownloadNESwPayload(execution); + lcmPayload = SDNCLcmPayloadBuilder.convertToSting(downloadNESwPayload); + break; + case SoPropertyConstants.ACTION_ACTIVATE_N_E_SW: + lcmAction = SDNCLcmActionConstants.ACTIVATE_N_E_SW; + + ActivateNESwPayload activateNESwPayload; + activateNESwPayload = SDNCLcmPayloadBuilder.buildActivateNESwPayload(execution); + lcmPayload = SDNCLcmPayloadBuilder.convertToSting(activateNESwPayload); + break; + case SoPropertyConstants.ACTION_POST_CHECK: + lcmAction = SDNCLcmActionConstants.UPGRADE_POST_CHECK; + + UpgradePostCheckPayload upgradePostCheckPayload; + upgradePostCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePostCheckPayload(execution); + lcmPayload = SDNCLcmPayloadBuilder.convertToSting(upgradePostCheckPayload); + break; + default: + logger.error("Unsupported SO Action: " + requestAction); + return null; + } + + logger.debug("SDNC LCM payload for {}: {}", lcmAction, lcmPayload); + + String subRequestId = UUID.randomUUID().toString(); + LcmInput lcmInput = + SDNCLcmMessageBuilder.buildLcmInputForPnf(requestId, subRequestId, pnfName, lcmAction, lcmPayload); + + ObjectMapper mapper = new ObjectMapper(); + String lcmInputMsg = mapper.writeValueAsString(lcmInput); + logger.debug("SDNC input message:\n" + lcmInputMsg); + + return lcmInput; + } + + private boolean parseLcmOutput(LcmOutput lcmOutput, String lcmAction) { + if (lcmOutput == null) { + logger.error("Call SDNC LCM API failure"); + return false; + } + + LcmStatus lcmStatus = lcmOutput.getStatus(); + + if (lcmStatus.getCode() == SDNCConstants.LCM_OUTPUT_SUCCESS_CODE) { + logger.debug("Call SDNC LCM API success: " + lcmStatus.getMessage()); + } else { + logger.error("Call SDNC LCM API failure: " + lcmStatus.getMessage()); + } + + String outputPayload = lcmOutput.getPayload(); + logger.debug("SDNC LCM action: {}, result: {}", lcmAction, outputPayload); + if (outputPayload != null) { + String result = JsonUtils.getJsonValue(outputPayload, "result"); + if ("Success".equals(result)) { + logger.debug("Run SDNC LCM action {} success", lcmAction); + return true; + } else { + String reason = JsonUtils.getJsonValue(outputPayload, "reason"); + logger.error("Run SDNC LCM action {} failure, reason: {}", lcmAction, reason); + } + } + + return false; + } + + private boolean sendLcmRequest(DelegateExecution execution, LcmInput lcmInput) { + String actionMode = String.valueOf(execution.getVariable(SoPropertyConstants.SO_ACTION_MODE)); + String lcmOperation = toLowerHyphen(lcmInput.getAction()); + + LcmOutput lcmOutput; + if ("async".equals(actionMode)) { + lcmOutput = sendAsyncRequest(lcmOperation, lcmInput); + } else { + lcmOutput = sendSyncRequest(lcmOperation, lcmInput); + } + + return parseLcmOutput(lcmOutput, lcmInput.getAction()); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilderTest.java new file mode 100644 index 0000000000..61f2ee3432 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilderTest.java @@ -0,0 +1,135 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.infrastructure.decisionpoint.impl.camunda.controller.sdnc; + +import com.fasterxml.jackson.core.JsonProcessingException; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.junit.Before; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.junit.runner.RunWith; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.when; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_PAYLOAD; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common.SoPropertyConstants; +import org.onap.so.client.sdnc.lcm.beans.payload.*; + +@RunWith(SpringJUnit4ClassRunner.class) +public class SDNCLcmPayloadBuilderTest { + private static Logger logger = LoggerFactory.getLogger(SDNCLcmPayloadBuilderTest.class); + + protected static String payload = "{" + "\"ipaddressV4Oam\": \"192.168.1.10\"," + "\"oldSwVersion\": \"v1\"," + + "\"preCheckRuleName\": \"r101\"," + "\"preCheckAdditionalData\": \"{}\"," + + "\"preCheckPlaybook\": \"precheck_playbook\"," + "\"swToBeDownloaded\": \"[{" + + "\\\"swLocation\\\": \\\"http://192.168.1.20/test.zip\\\"," + "\\\"swFileSize\\\": 123456," + + "\\\"swFileCompression\\\": \\\"ZIP\\\"," + "\\\"swFileFormat\\\": \\\"binary\\\"}]\"," + + "\"downloadNESwPlaybook\": \"downloadnesw_playbook\"," + + "\"activateNESwPlaybook\": \"activatenesw_playbook\"," + "\"postCheckRuleName\": \"r102\"," + + "\"postCheckAdditionalData\": \"{}\"," + "\"postCheckPlaybook\": \"postcheck_playbook\"" + "}"; + protected String targetSoftwareVersion = "v2"; + + @MockBean + private DelegateExecution execution; + + public static String getRequestPayload() { + return payload; + } + + @Before + public void setUp() { + when(execution.getVariable(REQUEST_PAYLOAD)).thenReturn(payload); + when(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION)).thenReturn(targetSoftwareVersion); + } + + + @Test + public final void testBuildActivateNESwPayload() { + String expectedPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"activatenesw_playbook\"," + "\"swVersionToBeActivated\":\"v2\"" + "}"; + + ActivateNESwPayload activateNESwPayload = SDNCLcmPayloadBuilder.buildActivateNESwPayload(execution); + try { + String payload = SDNCLcmPayloadBuilder.convertToSting(activateNESwPayload); + logger.debug("ActivateNESwPayload:\n" + payload); + + assertEquals(expectedPayload, payload); + } catch (JsonProcessingException e) { + fail("Convert ActivateNESwPayload to String error: " + e.toString()); + } + } + + @Test + public final void testBuildDownloadNESwPayload() { + String expectedSwToBeDownloadedElement = "{" + "\"swLocation\":\"http://192.168.1.20/test.zip\"," + + "\"swFileSize\":123456," + "\"swFileCompression\":\"ZIP\"," + "\"swFileFormat\":\"binary\"" + "}"; + String expectedPayload = + "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + "\"playbook-name\":\"downloadnesw_playbook\"," + + "\"swToBeDownloaded\":[" + expectedSwToBeDownloadedElement + "]" + "}"; + + DownloadNESwPayload downloadNESwPayload = SDNCLcmPayloadBuilder.buildDownloadNESwPayload(execution); + try { + String payload = SDNCLcmPayloadBuilder.convertToSting(downloadNESwPayload); + logger.debug("DownloadNESwPayload:\n" + payload); + + assertEquals(expectedPayload, payload); + } catch (JsonProcessingException e) { + fail("Convert DownloadNESwPayload to String error: " + e.toString()); + } + } + + @Test + public final void testBuildUpgradePostCheckPayload() { + String expectedPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"postcheck_playbook\"," + "\"oldSwVersion\":\"v1\"," + + "\"targetSwVersion\":\"v2\"," + "\"ruleName\":\"r102\"," + "\"additionalData\":\"{}\"" + "}"; + + UpgradePostCheckPayload upgradePostCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePostCheckPayload(execution); + try { + String payload = SDNCLcmPayloadBuilder.convertToSting(upgradePostCheckPayload); + logger.debug("UpgradePostCheckPayload:\n" + payload); + + assertEquals(expectedPayload, payload); + } catch (JsonProcessingException e) { + fail("Convert UpgradePostCheckPayload to String error: " + e.toString()); + } + } + + @Test + public final void testBuildUpgradePreCheckPayload() { + String expectedPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"precheck_playbook\"," + "\"oldSwVersion\":\"v1\"," + + "\"targetSwVersion\":\"v2\"," + "\"ruleName\":\"r101\"," + "\"additionalData\":\"{}\"" + "}"; + + UpgradePreCheckPayload upgradePreCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePreCheckPayload(execution); + try { + String payload = SDNCLcmPayloadBuilder.convertToSting(upgradePreCheckPayload); + logger.debug("UpgradePreCheckPayload:\n" + payload); + + assertEquals(expectedPayload, payload); + } catch (JsonProcessingException e) { + fail("Convert UpgradePreCheckPayload to String error: " + e.toString()); + } + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java index 674167624e..02c7dca9ae 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java @@ -28,7 +28,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext; import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable; -import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.ExceptionBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; @@ -48,9 +47,6 @@ public class SdncControllerDETest { @MockBean private ControllerPreparable<DelegateExecution> preparable; - @MockBean - protected ApplicationControllerAction client; - @Before public void setUp() { when(controllerContext.getControllerActor()).thenReturn("sdnc"); 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 b96df4ff9e..7de60181a6 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 @@ -164,6 +164,8 @@ public class AAIObjectType implements GraphInventoryObjectType, Serializable { new AAIObjectType(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), "/slice-profiles", "sliceProfiles"); public static final AAIObjectType COMMUNICATION_PROFILE_ALL = new AAIObjectType( AAIObjectType.SERVICE_INSTANCE.uriTemplate(), "/communication-service-profiles", "communicationProfiles"); + public static final AAIObjectType QUERY_ALLOTTED_RESOURCE = + new AAIObjectType(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), "?depth=2", "service-Instance"); private final String uriTemplate; private final String parentUri; diff --git a/common/src/main/java/org/onap/so/client/dmaap/DmaapConsumer.java b/common/src/main/java/org/onap/so/client/dmaap/DmaapConsumer.java index 4de546e9da..cbad59e968 100644 --- a/common/src/main/java/org/onap/so/client/dmaap/DmaapConsumer.java +++ b/common/src/main/java/org/onap/so/client/dmaap/DmaapConsumer.java @@ -20,12 +20,12 @@ package org.onap.so.client.dmaap; -import com.google.common.base.Stopwatch; import java.io.IOException; import java.util.concurrent.TimeUnit; import org.onap.so.client.dmaap.exceptions.DMaaPConsumerFailure; import org.onap.so.client.dmaap.exceptions.ExceededMaximumPollingTime; import org.onap.so.client.dmaap.rest.RestConsumer; +import com.google.common.base.Stopwatch; public abstract class DmaapConsumer extends DmaapClient { static final int MAX_ELAPSED_TIME = 180000; @@ -40,7 +40,6 @@ public abstract class DmaapConsumer extends DmaapClient { public boolean consume() throws Exception { Consumer mrConsumer = this.getConsumer(); - boolean accepted = false; Stopwatch stopwatch = Stopwatch.createUnstarted(); try { while (this.continuePolling()) { @@ -54,20 +53,17 @@ public abstract class DmaapConsumer extends DmaapClient { Iterable<String> itr = mrConsumer.fetch(); stopwatch.stop(); for (String message : itr) { - if (!accepted && this.isAccepted(message)) { + if (this.isAccepted(message)) { logger.info("accepted message found for " + this.getRequestId() + " on " + this.getTopic()); - accepted = true; } - if (accepted) { - logger.info("received dmaap message: " + message); - if (this.isFailure(message)) { - this.stopProcessingMessages(); - final String errorMsg = "failure received from dmaap topic " + this.getTopic(); - logger.error(errorMsg); - throw new DMaaPConsumerFailure(errorMsg); - } else { - this.processMessage(message); - } + logger.info("received dmaap message: " + message); + if (this.isFailure(message)) { + this.stopProcessingMessages(); + final String errorMsg = "failure received from dmaap topic " + this.getTopic(); + logger.error(errorMsg); + throw new DMaaPConsumerFailure(errorMsg); + } else { + this.processMessage(message); } } } diff --git a/common/src/main/java/org/onap/so/constants/OrchestrationRequestFormat.java b/common/src/main/java/org/onap/so/constants/OrchestrationRequestFormat.java index 641bbb28c7..141352edce 100644 --- a/common/src/main/java/org/onap/so/constants/OrchestrationRequestFormat.java +++ b/common/src/main/java/org/onap/so/constants/OrchestrationRequestFormat.java @@ -21,5 +21,5 @@ package org.onap.so.constants; public enum OrchestrationRequestFormat { - DETAIL, STATUSDETAIL, SIMPLE + DETAIL, STATUSDETAIL, SIMPLE, SIMPLENOTASKINFO } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java index 7bc6fbc9f8..de90039d5c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java @@ -437,11 +437,13 @@ public class OrchestrationRequests { String retryStatusMessage = iar.getRetryStatusMessage(); String taskName = null; - if (flowStatusMessage != null && !flowStatusMessage.equals("Successfully completed all Building Blocks") - && !flowStatusMessage.equals("All Rollback flows have completed successfully")) { - taskName = camundaRequestHandler.getTaskName(iar.getRequestId()); - if (taskName != null) { - flowStatusMessage = flowStatusMessage + " TASK INFORMATION: " + taskName; + if (format == null || !format.equalsIgnoreCase(OrchestrationRequestFormat.SIMPLENOTASKINFO.toString())) { + if (flowStatusMessage != null && !flowStatusMessage.equals("Successfully completed all Building Blocks") + && !flowStatusMessage.equals("All Rollback flows have completed successfully")) { + taskName = camundaRequestHandler.getTaskName(iar.getRequestId()); + if (taskName != null) { + flowStatusMessage = flowStatusMessage + " TASK INFORMATION: " + taskName; + } } } @@ -542,7 +544,8 @@ public class OrchestrationRequests { } protected boolean isRequestProcessingDataRequired(String format) { - if (StringUtils.isNotEmpty(format) && format.equalsIgnoreCase(OrchestrationRequestFormat.SIMPLE.name())) { + if (StringUtils.isNotEmpty(format) && (format.equalsIgnoreCase(OrchestrationRequestFormat.SIMPLE.name()) + || format.equalsIgnoreCase(OrchestrationRequestFormat.SIMPLENOTASKINFO.toString()))) { return false; } else { return true; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java index 47aa3cccb5..22c82bf75c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java @@ -27,6 +27,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; import static org.mockito.Mockito.doReturn; import javax.ws.rs.core.Response; import org.apache.commons.lang.StringUtils; @@ -187,6 +188,50 @@ public class OrchestrationRequestsUnitTest { } @Test + public void mapRequestStatusNoTaskInfoTest() throws ApiException { + InstanceReferences instanceReferences = new InstanceReferences(); + instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); + RequestStatus requestStatus = new RequestStatus(); + requestStatus.setRequestState(iar.getRequestStatus()); + requestStatus.setStatusMessage( + "FLOW STATUS: FlowStatus RETRY STATUS: RetryStatusMessage ROLLBACK STATUS: RollbackStatusMessage"); + + Request expected = new Request(); + expected.setRequestId(REQUEST_ID); + expected.setInstanceReferences(instanceReferences); + expected.setRequestStatus(requestStatus); + expected.setRequestScope(SERVICE); + + includeCloudRequest = false; + + Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, + OrchestrationRequestFormat.SIMPLENOTASKINFO.toString()); + assertThat(expected, sameBeanAs(actual)); + } + + @Test + public void mapRequestStatusNullFormatTest() throws ApiException { + doReturn("TaskName").when(camundaRequestHandler).getTaskName(REQUEST_ID); + InstanceReferences instanceReferences = new InstanceReferences(); + instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); + RequestStatus requestStatus = new RequestStatus(); + requestStatus.setRequestState(iar.getRequestStatus()); + requestStatus.setStatusMessage( + "FLOW STATUS: FlowStatus TASK INFORMATION: TaskName RETRY STATUS: RetryStatusMessage ROLLBACK STATUS: RollbackStatusMessage"); + + Request expected = new Request(); + expected.setRequestId(REQUEST_ID); + expected.setInstanceReferences(instanceReferences); + expected.setRequestStatus(requestStatus); + expected.setRequestScope(SERVICE); + + includeCloudRequest = false; + + Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, null); + assertThat(expected, sameBeanAs(actual)); + } + + @Test public void mapRequestStatusAndExtSysErrSrcToRequestDetailTest() throws ApiException { doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID); InstanceReferences instanceReferences = new InstanceReferences(); @@ -338,4 +383,10 @@ public class OrchestrationRequestsUnitTest { orchestrationRequests.infraActiveRequestLookup(iar.getRequestId()); } + @Test + public void isRequestProcessingDataRequiredTest() { + boolean required = orchestrationRequests.isRequestProcessingDataRequired("simpleNoTaskInfo"); + assertFalse(required); + } + } diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.so-app b/packages/docker/src/main/docker/docker-files/Dockerfile.so-app index e8f02f12c6..84bd2987e3 100644 --- a/packages/docker/src/main/docker/docker-files/Dockerfile.so-app +++ b/packages/docker/src/main/docker/docker-files/Dockerfile.so-app @@ -1,4 +1,4 @@ -FROM onap/so/base-image:1.0 +FROM registry.gitlab.com/onap-integration/docker/onap-java ARG http_proxy ENV HTTP_PROXY=$http_proxy @@ -7,22 +7,18 @@ ARG https_proxy ENV HTTPS_PROXY=$https_proxy ENV https_proxy=$HTTPS_PROXY -RUN mkdir /app && mkdir /app/config && mkdir /app/certificates && mkdir /app/logs && mkdir /app/ca-certificates +USER root +RUN mkdir -p /app/{config,certificates,logs,ca-certificates} +RUN chown -R onap:onap /app && chmod 700 /app/*.sh +USER onap COPY maven/app.jar /app COPY configs/logging/logback-spring.xml /app COPY scripts/start-app.sh /app COPY scripts/wait-for.sh /app COPY ca-certificates/onap-ca.crt /app/ca-certificates/onap-ca.crt -RUN chown -R so:so /app && chmod 700 /app/*.sh - -## TODO for Casablanca: install this in the openstack-adapter container -## Install heatbridge -#RUN apt-get install -y python && apt-get install -y python-pip && echo 'PIP Installed, doing upgrade' && pip install --upgrade pip -#RUN mkdir /opt/mso/heatbridge -#COPY heatbridge/heatbridge-0.3.0.dev0-py2-none-any.whl /opt/mso/heatbridge -#RUN pip install /opt/mso/heatbridge/heatbridge-0.3.0.dev0-py2-none-any.whl +RUN chmod 700 /app/*.sh # Springboot configuration (required) VOLUME /app/config diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image b/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image deleted file mode 100644 index c0b298e778..0000000000 --- a/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image +++ /dev/null @@ -1,17 +0,0 @@ -FROM docker.io/openjdk:8-jdk-alpine - -ARG http_proxy -ARG https_proxy -ENV HTTP_PROXY=$http_proxy -ENV HTTPS_PROXY=$https_proxy -ENV http_proxy=$HTTP_PROXY -ENV https_proxy=$HTTPS_PROXY - -# Update the package list and upgrade installed packages -RUN apk update && apk upgrade - -# Install commonly needed tools -RUN apk --no-cache add curl netcat-openbsd sudo nss - -# Create 'so' user -RUN addgroup -g 1000 so && adduser -S -u 1000 -G so -s /bin/sh so diff --git a/packages/docker/src/main/docker/docker-files/scripts/start-app.sh b/packages/docker/src/main/docker/docker-files/scripts/start-app.sh index 75d64fefa0..ebab3c6ea3 100644 --- a/packages/docker/src/main/docker/docker-files/scripts/start-app.sh +++ b/packages/docker/src/main/docker/docker-files/scripts/start-app.sh @@ -16,9 +16,9 @@ then update-ca-certificates --fresh fi - # Re-exec this script as the 'so' user. + # Re-exec this script as the 'onap' user. this=`readlink -f $0` - exec su so -c "$this" + exec su onap -c "$this" fi touch /app/app.jar |