aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy409
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java3
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClientV2.java153
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerConfiguration.java84
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java132
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java9
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn377
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java259
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/ServiceLevelUpgradeTest.json48
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Pnf_aai.json42
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest.json27
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest_catalogdb.json39
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Service_instance_aai.json35
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparable.java (renamed from bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/AbstractServiceLevelPreparable.java)55
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java58
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java13
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java66
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java131
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java67
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/UpdateServiceInstanceInAai.java123
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java116
21 files changed, 1574 insertions, 672 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy
index 08c032fba3..146889351a 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy
@@ -64,208 +64,211 @@ import org.slf4j.LoggerFactory
class SniroHomingV1 extends AbstractServiceTaskProcessor{
private static final Logger logger = LoggerFactory.getLogger( SniroHomingV1.class);
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
- SniroUtils sniroUtils = new SniroUtils(this)
-
- /**
- * This method validates the incoming variables.
- * The method then prepares the sniro request
- * and posts it to sniro's rest api.
- *
- * @param execution
- *
- * @author cb645j
- */
- public void callSniro(DelegateExecution execution){
- execution.setVariable("prefix","HOME_")
- logger.trace("Started Sniro Homing Call Sniro ")
- try{
- execution.setVariable("rollbackData", null)
- execution.setVariable("rolledBack", false)
-
- String requestId = execution.getVariable("msoRequestId")
- logger.debug("Incoming Request Id is: " + requestId)
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- logger.debug("Incoming Service Instance Id is: " + serviceInstanceId)
- ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
- logger.debug("Incoming Service Decomposition is: " + serviceDecomposition)
- String subscriberInfo = execution.getVariable("subscriberInfo")
- logger.debug("Incoming Subscriber Information is: " + subscriberInfo)
-
- if(isBlank(requestId) || isBlank(serviceInstanceId) || isBlank(serviceDecomposition.toString()) || isBlank(subscriberInfo)){
- exceptionUtil.buildAndThrowWorkflowException(execution, 4000, "A required input variable is missing or null")
- }else{
- String subId = jsonUtil.getJsonValue(subscriberInfo, "globalSubscriberId")
- String subName = jsonUtil.getJsonValue(subscriberInfo, "subscriberName")
- String subCommonSiteId = ""
- if(jsonUtil.jsonElementExist(subscriberInfo, "subscriberCommonSiteId")){
- subCommonSiteId = jsonUtil.getJsonValue(subscriberInfo, "subscriberCommonSiteId")
- }
- Subscriber subscriber = new Subscriber(subId, subName, subCommonSiteId)
-
- String cloudConfiguration = execution.getVariable("cloudConfiguration") // TODO Currently not being used
- String homingParameters = execution.getVariable("homingParameters") // (aka. request parameters) Should be json format. TODO confirm its json format
-
- //Authentication
- String authHeader = UrnPropertiesReader.getVariable("sniro.manager.headers.auth", execution)
- execution.setVariable("BasicAuthHeaderValue", authHeader)
-
- //Prepare Callback
- String timeout = execution.getVariable("timeout")
- if(isBlank(timeout)){
- timeout = UrnPropertiesReader.getVariable("sniro.manager.timeout", execution)
- if(isBlank(timeout)) {
- timeout = "PT30M";
- }
- }
- logger.debug("Async Callback Timeout will be: " + timeout)
-
- execution.setVariable("timeout", timeout);
- execution.setVariable("correlator", requestId);
- execution.setVariable("messageType", "SNIROResponse");
-
- //Build Request & Call Sniro
- String sniroRequest = sniroUtils.buildRequest(execution, requestId, serviceDecomposition, subscriber, homingParameters)
- execution.setVariable("sniroRequest", sniroRequest)
- logger.debug("SNIRO Request is: " + sniroRequest)
-
- String endpoint = UrnPropertiesReader.getVariable("sniro.manager.uri.v1", execution)
- String host = UrnPropertiesReader.getVariable("sniro.manager.host", execution)
- String urlString = host + endpoint
- logger.debug("Sniro Url is: " + urlString)
-
- URL url = new URL(urlString);
- HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.SNIRO)
- httpClient.addAdditionalHeader("Authorization", authHeader)
- Response httpResponse = httpClient.post(sniroRequest)
-
- int responseCode = httpResponse.getStatus()
-
- logger.debug("Sniro sync response code is: " + responseCode)
- if(httpResponse.hasEntity()){
- logger.debug("Sniro sync response is: " + httpResponse.readEntity(String.class))
- }
-
- if(responseCode != 202){
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from Sniro.")
- }
-
- logger.trace("Completed Sniro Homing Call Sniro")
- }
- }catch(BpmnError b){
- throw b
- }catch(Exception e){
- logger.debug("Error encountered within Homing CallSniro method: " + e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Homing CallSniro: " + e.getMessage())
- }
- }
-
- /**
- * This method processes the callback response
- * and the contained homing solution. It sets
- * homing solution assignment and license
- * information to the corresponding resources
- *
- * @param execution
- *
- * @author cb645j
- */
- public void processHomingSolution(DelegateExecution execution){
- logger.trace("Started Sniro Homing Process Homing Solution")
- try{
- String response = execution.getVariable("asyncCallbackResponse")
- logger.debug("Sniro Async Callback Response is: " + response)
-
- sniroUtils.validateCallbackResponse(execution, response)
-
- ServiceDecomposition decomposition = execution.getVariable("serviceDecomposition")
- List<Resource> resourceList = decomposition.getServiceResources()
-
- if(JsonUtils.jsonElementExist(response, "solutionInfo.placementInfo")){
- String placements = jsonUtil.getJsonValue(response, "solutionInfo.placementInfo")
- JSONArray arr = new JSONArray(placements)
- for(int i = 0; i < arr.length(); i++){
- JSONObject placement = arr.getJSONObject(i)
- String jsonServiceResourceId = placement.getString("serviceResourceId")
- for(Resource resource:resourceList){
- String serviceResourceId = resource.getResourceId()
- if(serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)){
- //match
- String inventoryType = placement.getString("inventoryType")
- resource.getHomingSolution().setInventoryType(InventoryType.valueOf(inventoryType))
- resource.getHomingSolution().setCloudRegionId(placement.getString("cloudRegionId"))
- resource.getHomingSolution().setRehome(placement.getBoolean("isRehome"))
- JSONArray assignmentArr = placement.getJSONArray("assignmentInfo")
- Map<String, String> assignmentMap = jsonUtil.entryArrayToMap(execution, assignmentArr.toString(), "variableName", "variableValue")
- resource.getHomingSolution().setCloudOwner(assignmentMap.get("cloudOwner"))
- resource.getHomingSolution().setAicClli(assignmentMap.get("aicClli"))
- resource.getHomingSolution().setAicVersion(assignmentMap.get("aicVersion"))
- if(inventoryType.equalsIgnoreCase("service")){
- VnfResource vnf = new VnfResource()
- vnf.setVnfHostname(assignmentMap.get("vnfHostName"))
- resource.getHomingSolution().setVnf(vnf)
- resource.getHomingSolution().setServiceInstanceId(placement.getString("serviceInstanceId"))
- }
- }
- }
- }
- }
-
- if(JsonUtils.jsonElementExist(response, "solutionInfo.licenseInfo")){
- String licenseInfo = jsonUtil.getJsonValue(response, "solutionInfo.licenseInfo")
- JSONArray licenseArr = new JSONArray(licenseInfo)
- for(int l = 0; l < licenseArr.length(); l++){
- JSONObject license = licenseArr.getJSONObject(l)
- String jsonServiceResourceId = license.getString("serviceResourceId")
- for(Resource resource:resourceList){
- String serviceResourceId = resource.getResourceId()
- if(serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)){
- //match
- String jsonEntitlementPoolList = jsonUtil.getJsonValue(license.toString(), "entitlementPoolList")
- List<String> entitlementPoolList = jsonUtil.StringArrayToList(execution, jsonEntitlementPoolList)
- resource.getHomingSolution().getLicense().setEntitlementPoolList(entitlementPoolList)
-
- String jsonLicenseKeyGroupList = jsonUtil.getJsonValue(license.toString(), "licenseKeyGroupList")
- List<String> licenseKeyGroupList = jsonUtil.StringArrayToList(execution, jsonLicenseKeyGroupList)
- resource.getHomingSolution().getLicense().setLicenseKeyGroupList(licenseKeyGroupList)
- }
- }
- }
- }
- execution.setVariable("serviceDecomposition", decomposition)
-
- logger.trace("Completed Sniro Homing Process Homing Solution")
- }catch(BpmnError b){
- throw b
- }catch(Exception e){
- logger.debug("Error encountered within Homing ProcessHomingSolution method: " + e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Sniro Homing Process Solution")
- }
- }
-
- /**
- * This method logs the start of DHVCreateService
- * to make debugging easier.
- *
- * @param - execution
- * @author cb645j
- */
- public String logStart(DelegateExecution execution){
- String requestId = execution.getVariable("testReqId")
- if(isBlank(requestId)){
- requestId = execution.getVariable("msoRequestId")
- }
- execution.setVariable("DHVCS_requestId", requestId)
- logger.trace("STARTED Homing Subflow for request: " + requestId + " ")
- logger.debug("****** Homing Subflow Global Debug Enabled: " + execution.getVariable("isDebugLogEnabled") + " *****")
- logger.trace("STARTED Homing Subflow for request: " + requestId + " ")
- }
-
-
- /**
- * Auto-generated method stub
- */
- public void preProcessRequest(DelegateExecution execution){}
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ JsonUtils jsonUtil = new JsonUtils()
+ SniroUtils sniroUtils = new SniroUtils(this)
+
+ /**
+ * This method validates the incoming variables.
+ * The method then prepares the sniro request
+ * and posts it to sniro's rest api.
+ *
+ * @param execution
+ *
+ * @author cb645j
+ */
+ public void callSniro(DelegateExecution execution){
+ execution.setVariable("prefix","HOME_")
+ logger.trace("Started Sniro Homing Call Sniro ")
+ try{
+ execution.setVariable("rollbackData", null)
+ execution.setVariable("rolledBack", false)
+
+ String requestId = execution.getVariable("msoRequestId")
+ logger.debug("Incoming Request Id is: " + requestId)
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ logger.debug("Incoming Service Instance Id is: " + serviceInstanceId)
+ ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
+ logger.debug("Incoming Service Decomposition is: " + serviceDecomposition)
+ String subscriberInfo = execution.getVariable("subscriberInfo")
+ logger.debug("Incoming Subscriber Information is: " + subscriberInfo)
+
+ if(isBlank(requestId) || isBlank(serviceInstanceId) || isBlank(serviceDecomposition.toString()) || isBlank(subscriberInfo)){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 4000, "A required input variable is missing or null")
+ }else{
+ String subId = jsonUtil.getJsonValue(subscriberInfo, "globalSubscriberId")
+ String subName = jsonUtil.getJsonValue(subscriberInfo, "subscriberName")
+ String subCommonSiteId = ""
+ if(jsonUtil.jsonElementExist(subscriberInfo, "subscriberCommonSiteId")){
+ subCommonSiteId = jsonUtil.getJsonValue(subscriberInfo, "subscriberCommonSiteId")
+ }
+ Subscriber subscriber = new Subscriber(subId, subName, subCommonSiteId)
+
+ String cloudConfiguration = execution.getVariable("cloudConfiguration") // TODO Currently not being used
+ String homingParameters = execution.getVariable("homingParameters") // (aka. request parameters) Should be json format. TODO confirm its json format
+
+ //Authentication
+ String authHeader = UrnPropertiesReader.getVariable("sniro.manager.headers.auth", execution)
+ execution.setVariable("BasicAuthHeaderValue", authHeader)
+
+ //Prepare Callback
+ String timeout = execution.getVariable("timeout")
+ if(isBlank(timeout)){
+ timeout = UrnPropertiesReader.getVariable("sniro.manager.timeout", execution)
+ if(isBlank(timeout)) {
+ timeout = "PT30M";
+ }
+ }
+ logger.debug("Async Callback Timeout will be: " + timeout)
+
+ execution.setVariable("timeout", timeout);
+ execution.setVariable("correlator", requestId);
+ execution.setVariable("messageType", "SNIROResponse");
+
+ //Build Request & Call Sniro
+ String sniroRequest = sniroUtils.buildRequest(execution, requestId, serviceDecomposition, subscriber, homingParameters)
+ execution.setVariable("sniroRequest", sniroRequest)
+ logger.debug("SNIRO Request is: " + sniroRequest)
+
+ String endpoint = UrnPropertiesReader.getVariable("sniro.manager.uri.v1", execution)
+ String host = UrnPropertiesReader.getVariable("sniro.manager.host", execution)
+ String urlString = host + endpoint
+ logger.debug("Sniro Url is: " + urlString)
+
+ URL url = new URL(urlString);
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.SNIRO)
+ httpClient.addAdditionalHeader("Authorization", authHeader)
+ Response httpResponse = httpClient.post(sniroRequest)
+
+ int responseCode = httpResponse.getStatus()
+
+ logger.debug("Sniro sync response code is: " + responseCode)
+ if(httpResponse.hasEntity()){
+ logger.debug("Sniro sync response is: " + httpResponse.readEntity(String.class))
+ }
+
+ if(responseCode != 202){
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from Sniro.")
+ }
+
+ logger.trace("Completed Sniro Homing Call Sniro")
+ }
+ }catch(BpmnError b){
+ throw b
+ }catch(Exception e){
+ logger.debug("Error encountered within Homing CallSniro method: " + e)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Homing CallSniro: " + e.getMessage())
+ }
+ }
+
+ /**
+ * This method processes the callback response
+ * and the contained homing solution. It sets
+ * homing solution assignment and license
+ * information to the corresponding resources
+ *
+ * @param execution
+ *
+ * @author cb645j
+ */
+ public void processHomingSolution(DelegateExecution execution){
+ logger.trace("Started Sniro Homing Process Homing Solution")
+ try{
+ String response = execution.getVariable("asyncCallbackResponse")
+ logger.debug("Sniro Async Callback Response is: " + response)
+
+ sniroUtils.validateCallbackResponse(execution, response)
+
+ ServiceDecomposition decomposition = execution.getVariable("serviceDecomposition")
+ List<Resource> resourceList = decomposition.getServiceResources()
+
+ if(JsonUtils.jsonElementExist(response, "solutionInfo.placementInfo")){
+ String placements = jsonUtil.getJsonValue(response, "solutionInfo.placementInfo")
+ JSONArray arr = new JSONArray(placements)
+ for(int i = 0; i < arr.length(); i++){
+ JSONObject placement = arr.getJSONObject(i)
+ String jsonServiceResourceId = placement.getString("serviceResourceId")
+ for(Resource resource:resourceList){
+ String serviceResourceId = resource.getResourceId()
+ if(serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)){
+ //match
+ String inventoryType = placement.getString("inventoryType")
+ resource.getHomingSolution().setInventoryType(InventoryType.valueOf(inventoryType))
+ resource.getHomingSolution().setCloudRegionId(placement.getString("cloudRegionId"))
+ resource.getHomingSolution().setRehome(placement.getBoolean("isRehome"))
+ JSONArray assignmentArr = placement.getJSONArray("assignmentInfo")
+ Map<String, String> assignmentMap = jsonUtil.entryArrayToMap(execution, assignmentArr.toString(), "variableName", "variableValue")
+ resource.getHomingSolution().setCloudOwner(assignmentMap.get("cloudOwner"))
+ resource.getHomingSolution().setAicClli(assignmentMap.get("aicClli"))
+ resource.getHomingSolution().setAicVersion(assignmentMap.get("aicVersion"))
+ if(inventoryType.equalsIgnoreCase("service")){
+ VnfResource vnf = new VnfResource()
+ vnf.setVnfHostname(assignmentMap.get("vnfHostName"))
+ resource.getHomingSolution().setVnf(vnf)
+ resource.getHomingSolution().setServiceInstanceId(placement.getString("serviceInstanceId"))
+ }
+ if(placement.getBoolean("isRehome")) {
+ resource.getHomingSolution().setAllottedResourceId(assignmentMap.get("serviceResourceId"))
+ }
+ }
+ }
+ }
+ }
+
+ if(JsonUtils.jsonElementExist(response, "solutionInfo.licenseInfo")){
+ String licenseInfo = jsonUtil.getJsonValue(response, "solutionInfo.licenseInfo")
+ JSONArray licenseArr = new JSONArray(licenseInfo)
+ for(int l = 0; l < licenseArr.length(); l++){
+ JSONObject license = licenseArr.getJSONObject(l)
+ String jsonServiceResourceId = license.getString("serviceResourceId")
+ for(Resource resource:resourceList){
+ String serviceResourceId = resource.getResourceId()
+ if(serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)){
+ //match
+ String jsonEntitlementPoolList = jsonUtil.getJsonValue(license.toString(), "entitlementPoolList")
+ List<String> entitlementPoolList = jsonUtil.StringArrayToList(execution, jsonEntitlementPoolList)
+ resource.getHomingSolution().getLicense().setEntitlementPoolList(entitlementPoolList)
+
+ String jsonLicenseKeyGroupList = jsonUtil.getJsonValue(license.toString(), "licenseKeyGroupList")
+ List<String> licenseKeyGroupList = jsonUtil.StringArrayToList(execution, jsonLicenseKeyGroupList)
+ resource.getHomingSolution().getLicense().setLicenseKeyGroupList(licenseKeyGroupList)
+ }
+ }
+ }
+ }
+ execution.setVariable("serviceDecomposition", decomposition)
+
+ logger.trace("Completed Sniro Homing Process Homing Solution")
+ }catch(BpmnError b){
+ throw b
+ }catch(Exception e){
+ logger.debug("Error encountered within Homing ProcessHomingSolution method: " + e)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Sniro Homing Process Solution")
+ }
+ }
+
+ /**
+ * This method logs the start of DHVCreateService
+ * to make debugging easier.
+ *
+ * @param - execution
+ * @author cb645j
+ */
+ public String logStart(DelegateExecution execution){
+ String requestId = execution.getVariable("testReqId")
+ if(isBlank(requestId)){
+ requestId = execution.getVariable("msoRequestId")
+ }
+ execution.setVariable("DHVCS_requestId", requestId)
+ logger.trace("STARTED Homing Subflow for request: " + requestId + " ")
+ logger.debug("****** Homing Subflow Global Debug Enabled: " + execution.getVariable("isDebugLogEnabled") + " *****")
+ logger.trace("STARTED Homing Subflow for request: " + requestId + " ")
+ }
+
+
+ /**
+ * Auto-generated method stub
+ */
+ public void preProcessRequest(DelegateExecution execution){}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
index e237462a1d..009686d0fc 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
@@ -1552,7 +1552,8 @@ public class BBInputSetup implements JavaDelegate {
}
parameter.setApplicationId(applicationId);
this.populateGenericVnf(parameter);
- } else if (bbName.contains(PNF) || bbName.equals("ControllerExecutionBB")) {
+ } else if (bbName.contains(PNF) || (bbName.contains(CONTROLLER)
+ && (PNF).equalsIgnoreCase(executeBB.getBuildingBlock().getBpmnScope()))) {
String pnfId = lookupKeyMap.get(ResourceKey.PNF);
resources.getPnfs().stream()
.filter(pnfs -> Objects.equals(key, pnfs.getModelInfo().getModelCustomizationId())).findFirst()
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClientV2.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClientV2.java
deleted file mode 100644
index dc5b6308bb..0000000000
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClientV2.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.client.appc;
-
-import org.onap.appc.client.lcm.api.AppcClientServiceFactoryProvider;
-import org.onap.appc.client.lcm.api.AppcLifeCycleManagerServiceFactory;
-import org.onap.appc.client.lcm.api.ApplicationContext;
-import org.onap.appc.client.lcm.api.LifeCycleManagerStateful;
-import org.onap.appc.client.lcm.exceptions.AppcClientException;
-import org.onap.appc.client.lcm.model.*;
-import org.onap.appc.client.lcm.model.Flags.Force;
-import org.onap.appc.client.lcm.model.Flags.Mode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import javax.annotation.PostConstruct;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.time.Instant;
-import java.util.Properties;
-import java.util.UUID;
-
-@Component
-@Deprecated
-public class ApplicationControllerClientV2 {
-
- private static final String CLIENT_NAME = "MSO";
- private static final String API_VER = "2.00";
- private static final String ORIGINATOR_ID = "MSO";
- private static final int FLAGS_TTL = 65000;
- private static Logger logger = LoggerFactory.getLogger(ApplicationControllerClientV2.class);
-
- // @Autowired
- ApplicationControllerConfiguration applicationControllerConfiguration;
-
- // @Autowired
- private ApplicationControllerSupport appCSupport;
-
- private static LifeCycleManagerStateful client;
-
- // @PostConstruct
- public void buildClient() {
- client = this.getAppCClient("");
- }
-
- // @PostConstruct
- public void buildClient(String controllerType) {
- client = this.getAppCClient(controllerType);
- }
-
- public Status runCommand(Action action, ActionIdentifiers actionIdentifiers, Payload payload, String requestID)
- throws ApplicationControllerOrchestratorException {
- Object requestObject;
- requestObject = createRequest(action, actionIdentifiers, payload, requestID);
- appCSupport.logLCMMessage(requestObject);
- Method lcmMethod = appCSupport.getAPIMethod(action.name(), client, false);
- try {
- Object response = lcmMethod.invoke(client, requestObject);
- return appCSupport.getStatusFromGenericResponse(response);
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(String.format("%s : %s", "Unable to invoke action", action.toString()), e);
- }
- }
-
- public LifeCycleManagerStateful getAppCClient(String controllerType) {
- if (client == null)
- try {
- client = AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class)
- .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties(controllerType));
- } catch (AppcClientException e) {
- logger.error("Error in getting LifeCycleManagerStateful Client", e);
- }
- return client;
- }
-
- protected Properties getLCMProperties(String controllerType) {
- Properties properties = new Properties();
- properties.put("topic.read", applicationControllerConfiguration.getReadTopic());
- properties.put("topic.read.timeout", applicationControllerConfiguration.getReadTimeout());
- properties.put("client.response.timeout", applicationControllerConfiguration.getResponseTimeout());
- properties.put("topic.write", applicationControllerConfiguration.getWrite());
- properties.put("poolMembers", applicationControllerConfiguration.getPoolMembers());
- properties.put("client.key", applicationControllerConfiguration.getClientKey());
- properties.put("client.secret", applicationControllerConfiguration.getClientSecret());
- properties.put("client.name", CLIENT_NAME);
- properties.put("service", applicationControllerConfiguration.getService());
- return properties;
- }
-
- public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId) {
- Object requestObject = appCSupport.getInput(action.name());
- try {
- CommonHeader commonHeader = buildCommonHeader(requestId);
- requestObject.getClass().getDeclaredMethod("setCommonHeader", CommonHeader.class).invoke(requestObject,
- commonHeader);
- requestObject.getClass().getDeclaredMethod("setAction", Action.class).invoke(requestObject, action);
- requestObject.getClass().getDeclaredMethod("setActionIdentifiers", ActionIdentifiers.class)
- .invoke(requestObject, identifier);
- if (payload != null) {
- requestObject.getClass().getDeclaredMethod("setPayload", Payload.class).invoke(requestObject, payload);
- }
- } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
- logger.error("Error building Appc request", e);
- }
- return requestObject;
- }
-
- private CommonHeader buildCommonHeader(String requestId) {
- CommonHeader commonHeader = new CommonHeader();
- commonHeader.setApiVer(API_VER);
- commonHeader.setOriginatorId(ORIGINATOR_ID);
- commonHeader.setRequestId(requestId == null ? UUID.randomUUID().toString() : requestId);
- commonHeader.setSubRequestId(requestId);
- Flags flags = new Flags();
- String flagsMode = "NORMAL";
- Mode mode = Mode.valueOf(flagsMode);
- flags.setMode(mode);
- String flagsForce = "FALSE";
- Force force = Force.valueOf(flagsForce);
- flags.setForce(force);
- flags.setTtl(FLAGS_TTL);
- commonHeader.setFlags(flags);
- Instant timestamp = Instant.now();
- ZULU zulu = new ZULU(timestamp.toString());
- commonHeader.setTimestamp(zulu);
- return commonHeader;
- }
-
- public Flags createRequestFlags() {
- Flags flags = new Flags();
- flags.setTtl(6000);
- return flags;
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerConfiguration.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerConfiguration.java
deleted file mode 100644
index b39ba5f63f..0000000000
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerConfiguration.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.client.appc;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class ApplicationControllerConfiguration {
- @Value("${appc.client.topic.read.name}")
- private String readTopic;
-
- @Value("${appc.client.topic.read.timeout}")
- private String readTimeout;
-
- @Value("${appc.client.response.timeout}")
- private String responseTimeout;
-
- @Value("${appc.client.topic.write}")
- private String write;
-
- @Value("${appc.client.poolMembers}")
- private String poolMembers;
-
- @Value("${appc.client.key}")
- private String clientKey;
-
- @Value("${appc.client.secret}")
- private String clientSecret;
-
- @Value("${appc.client.service}")
- private String service;
-
- public String getClientKey() {
- return clientKey;
- }
-
- public String getClientSecret() {
- return clientSecret;
- }
-
- public String getPoolMembers() {
- return poolMembers;
- }
-
- public String getReadTimeout() {
- return readTimeout;
- }
-
- public String getResponseTimeout() {
- return responseTimeout;
- }
-
- public String getReadTopic() {
- return readTopic;
- }
-
- public String getService() {
- return service;
- }
-
- public String getWrite() {
- return write;
- }
-}
-
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java
deleted file mode 100644
index c242017838..0000000000
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.client.appc;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.appc.client.lcm.model.Action;
-import org.onap.appc.client.lcm.model.ActionIdentifiers;
-import org.onap.appc.client.lcm.model.CheckLockInput;
-import org.onap.appc.client.lcm.model.Status;
-import org.onap.so.BaseTest;
-import java.util.Properties;
-import java.util.UUID;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public class ApplicationControllerClientV2Test {
-
- @Mock
- ApplicationControllerSupport applicationControllerSupport;
-
- @Mock
- ApplicationControllerConfiguration applicationControllerConfiguration;
-
- @InjectMocks
- ApplicationControllerClientV2 client;
-
-
- @Before
- public void setup() {
- when(applicationControllerConfiguration.getReadTopic()).thenReturn("APPC-TEST-AMDOCS2");
- when(applicationControllerConfiguration.getReadTimeout()).thenReturn("120000");
- when(applicationControllerConfiguration.getResponseTimeout()).thenReturn("120000");
- when(applicationControllerConfiguration.getWrite()).thenReturn("APPC-TEST-AMDOCS1-DEV3");
- when(applicationControllerConfiguration.getService()).thenReturn("ueb");
- when(applicationControllerConfiguration.getPoolMembers())
- .thenReturn("localhost:3904,localhost:3904,localhost:3904");
- when(applicationControllerConfiguration.getClientKey()).thenReturn("iaEMAfjsVsZnraBP");
- when(applicationControllerConfiguration.getClientSecret()).thenReturn("wcivUjsjXzmGFBfxMmyJu9dz");
- // client.buildClient();
- }
-
- @BeforeClass
- public static void beforeClass() {
- System.setProperty("mso.config.path", "src/test/resources");
- }
-
- @Ignore
- @Test
- public void createRequest_CheckLock_RequestBuilt() {
- ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
- actionIdentifiers.setVnfId("vnfId");
- // when(applicationControllerSupport.getInput(eq(Action.CheckLock.name()))).thenReturn(new CheckLockInput());
- CheckLockInput checkLockInput =
- (CheckLockInput) client.createRequest(Action.CheckLock, actionIdentifiers, null, "requestId");
- assertEquals(checkLockInput.getAction().name(), "CheckLock");
- }
-
- @Ignore
- @Test
- public void runCommand_liveAppc() {
- ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
- // actionIdentifiers.setVnfId("ca522254-2ba4-4fbd-b15b-0ef0d9cfda5f");
- actionIdentifiers.setVnfId("2d2bf10e-81a5-");
- Status status;
- // when(applicationControllerSupport.getInput(eq(Action.Lock.name()))).thenReturn(new LockInput());
- // when(applicationControllerSupport.getAPIMethod(anyString(),any(),anyBoolean())).thenCallRealMethod();
- try {
- status = client.runCommand(Action.Lock, actionIdentifiers, null, UUID.randomUUID().toString());
- } catch (ApplicationControllerOrchestratorException e) {
- status = new Status();
- status.setCode(e.getAppcCode());
- status.setMessage(e.getMessage());
- }
- assertEquals("Status of run command is correct", status.getCode(), 306);
- }
-
- @Ignore
- @Test
- public void runCommand_CheckLock_RequestBuilt() {
- ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
- actionIdentifiers.setVnfId("fusion-vpp-vnf-001");
- Status status;
- try {
- status = client.runCommand(Action.Unlock, actionIdentifiers, null, "requestId");
- } catch (ApplicationControllerOrchestratorException e) {
- status = new Status();
- status.setCode(e.getAppcCode());
- status.setMessage(e.getMessage());
- }
- assertEquals("Status of run command is correct", status.getCode(), 309);
- }
-
- @Ignore
- @Test
- public void test_getLCMPropertiesHelper() {
- Properties properties = client.getLCMProperties("");
- assertEquals(properties.get("topic.write"), "APPC-TEST-AMDOCS1-DEV3");
- assertEquals(properties.get("topic.read.timeout"), "120000");
- assertEquals(properties.get("client.response.timeout"), "120000");
- assertEquals(properties.get("topic.read"), "APPC-TEST-AMDOCS2");
- assertEquals(properties.get("poolMembers"), "localhost:3904,localhost:3904,localhost:3904");
- assertEquals(properties.get("client.key"), "iaEMAfjsVsZnraBP");
- assertEquals(properties.get("client.secret"), "wcivUjsjXzmGFBfxMmyJu9dz");
- }
-
-}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java
index 309b053589..ddfb29e97e 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java
@@ -37,6 +37,7 @@ public class HomingSolution extends JsonWrapper implements Serializable {
private InventoryType inventoryType;
private boolean isRehome;
private String serviceInstanceId; // TODO should start using si object instead
+ private String allottedResourceId;
private String cloudOwner;
private String cloudRegionId;
private String aicClli;
@@ -74,6 +75,14 @@ public class HomingSolution extends JsonWrapper implements Serializable {
this.serviceInstanceId = serviceInstanceId;
}
+ public String getAllottedResourceId() {
+ return allottedResourceId;
+ }
+
+ public void setAllottedResourceId(String allottedResourceId) {
+ this.allottedResourceId = allottedResourceId;
+ }
+
public String getCloudOwner() {
return cloudOwner;
}
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn
new file mode 100644
index 0000000000..a1d4178962
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn
@@ -0,0 +1,377 @@
+<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1k6npmy" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.0.0">
+ <bpmn:process id="ServiceLevelUpgrade" name="ServiceLevelUpgrade" isExecutable="true">
+ <bpmn:startEvent id="Event_02mc8tr">
+ <bpmn:outgoing>Flow_0nrz340</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:serviceTask id="Activity_18vue7u" name="Service Upgrade Dispatcher" camunda:delegateExpression="${ServiceLevelRequestDispatcher}">
+ <bpmn:incoming>Flow_0nrz340</bpmn:incoming>
+ <bpmn:outgoing>Flow_1b392qs</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:endEvent id="Event_12983th">
+ <bpmn:incoming>Flow_10jgbxm</bpmn:incoming>
+ <bpmn:terminateEventDefinition id="TerminateEventDefinition_1pnutu7" />
+ </bpmn:endEvent>
+ <bpmn:exclusiveGateway id="Gateway_02fectw" default="Flow_0y1ebox">
+ <bpmn:incoming>Flow_1y3cptr</bpmn:incoming>
+ <bpmn:outgoing>Flow_0y1ebox</bpmn:outgoing>
+ <bpmn:outgoing>Flow_0mbp7mv</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:endEvent id="Event_0ldlupa">
+ <bpmn:incoming>Flow_0y1ebox</bpmn:incoming>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_1dih7c9" errorRef="Error_01a8p43" />
+ </bpmn:endEvent>
+ <bpmn:exclusiveGateway id="Gateway_1nr51kr" default="Flow_0mxq0qe">
+ <bpmn:incoming>Flow_0trmo7s</bpmn:incoming>
+ <bpmn:outgoing>Flow_1z06yyv</bpmn:outgoing>
+ <bpmn:outgoing>Flow_0mxq0qe</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:endEvent id="Event_16k9r1c">
+ <bpmn:incoming>Flow_0mxq0qe</bpmn:incoming>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_042otuj" errorRef="Error_0e5owqi" />
+ </bpmn:endEvent>
+ <bpmn:exclusiveGateway id="Gateway_1vq11i7" default="Flow_1tcnzdx">
+ <bpmn:incoming>Flow_1ru18s3</bpmn:incoming>
+ <bpmn:outgoing>Flow_1tcnzdx</bpmn:outgoing>
+ <bpmn:outgoing>Flow_0l67uzl</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:endEvent id="Event_03tpudy">
+ <bpmn:incoming>Flow_1tcnzdx</bpmn:incoming>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_16r0jc3" errorRef="Error_04y00c4" />
+ </bpmn:endEvent>
+ <bpmn:serviceTask id="Activity_0snmatn" name="Service Level Upgrade" camunda:delegateExpression="${ServiceLevelUpgrade}">
+ <bpmn:incoming>Flow_1z06yyv</bpmn:incoming>
+ <bpmn:outgoing>Flow_01gwzx9</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:serviceTask id="Activity_0ft7fa2" name="Service Level Postcheck" camunda:delegateExpression="${ServiceLevelPostcheck}">
+ <bpmn:incoming>Flow_05ohtnj</bpmn:incoming>
+ <bpmn:outgoing>Flow_1ru18s3</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:serviceTask id="Activity_09bqns0" name="Service Level Preparation" camunda:delegateExpression="${ServiceLevelPreparation}">
+ <bpmn:incoming>Flow_1v0mxe7</bpmn:incoming>
+ <bpmn:outgoing>Flow_1p4xkdj</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:scriptTask id="Activity_0qgmx7a" name="Send Response" scriptFormat="groovy">
+ <bpmn:incoming>Flow_1b392qs</bpmn:incoming>
+ <bpmn:outgoing>Flow_1v0mxe7</bpmn:outgoing>
+ <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
+def pnfSwUpgrade = new PNFSoftwareUpgrade()
+pnfSwUpgrade.sendResponse(execution)</bpmn:script>
+ </bpmn:scriptTask>
+ <bpmn:scriptTask id="Activity_1n4rk7m" name="Prepare Completion" scriptFormat="groovy">
+ <bpmn:incoming>Flow_0l67uzl</bpmn:incoming>
+ <bpmn:outgoing>Flow_0frhsd0</bpmn:outgoing>
+ <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
+def pnfSwUpgrade = new PNFSoftwareUpgrade()
+pnfSwUpgrade.prepareCompletion(execution)</bpmn:script>
+ </bpmn:scriptTask>
+ <bpmn:callActivity id="Activity_1lz38px" name="Complete Process" calledElement="CompleteMsoProcess">
+ <bpmn:incoming>Flow_0frhsd0</bpmn:incoming>
+ <bpmn:outgoing>Flow_10jgbxm</bpmn:outgoing>
+ </bpmn:callActivity>
+ <bpmn:subProcess id="Activity_0ui6tp1" name="Subprocess for FalloutHandler" triggeredByEvent="true">
+ <bpmn:startEvent id="Event_08f3m9h">
+ <bpmn:outgoing>Flow_0iayg6u</bpmn:outgoing>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_1d67w55" />
+ </bpmn:startEvent>
+ <bpmn:scriptTask id="Activity_1k2f3ha" name="Prepare FalloutHandler" scriptFormat="groovy">
+ <bpmn:incoming>Flow_0iayg6u</bpmn:incoming>
+ <bpmn:outgoing>Flow_0lb7zv5</bpmn:outgoing>
+ <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
+def pnfSwUpgrade = new PNFSoftwareUpgrade()
+pnfSwUpgrade.prepareFalloutHandler(execution)</bpmn:script>
+ </bpmn:scriptTask>
+ <bpmn:callActivity id="Activity_0ai3z2q" name="Call FalloutHandler" calledElement="FalloutHandler">
+ <bpmn:incoming>Flow_0lb7zv5</bpmn:incoming>
+ <bpmn:outgoing>Flow_1peoyur</bpmn:outgoing>
+ </bpmn:callActivity>
+ <bpmn:endEvent id="Event_0ngb9wx">
+ <bpmn:incoming>Flow_1peoyur</bpmn:incoming>
+ <bpmn:terminateEventDefinition id="TerminateEventDefinition_1e5scwm" />
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="Flow_1peoyur" sourceRef="Activity_0ai3z2q" targetRef="Event_0ngb9wx" />
+ <bpmn:sequenceFlow id="Flow_0lb7zv5" sourceRef="Activity_1k2f3ha" targetRef="Activity_0ai3z2q" />
+ <bpmn:sequenceFlow id="Flow_0iayg6u" sourceRef="Event_08f3m9h" targetRef="Activity_1k2f3ha" />
+ </bpmn:subProcess>
+ <bpmn:sequenceFlow id="Flow_0nrz340" sourceRef="Event_02mc8tr" targetRef="Activity_18vue7u" />
+ <bpmn:sequenceFlow id="Flow_1b392qs" sourceRef="Activity_18vue7u" targetRef="Activity_0qgmx7a" />
+ <bpmn:sequenceFlow id="Flow_10jgbxm" sourceRef="Activity_1lz38px" targetRef="Event_12983th" />
+ <bpmn:sequenceFlow id="Flow_01gwzx9" sourceRef="Activity_0snmatn" targetRef="Activity_1q4o9fx" />
+ <bpmn:sequenceFlow id="Flow_0y1ebox" name="Failure" sourceRef="Gateway_02fectw" targetRef="Event_0ldlupa" />
+ <bpmn:sequenceFlow id="Flow_1p4xkdj" sourceRef="Activity_09bqns0" targetRef="Activity_0n17xou" />
+ <bpmn:sequenceFlow id="Flow_1z06yyv" name="Success" sourceRef="Gateway_1nr51kr" targetRef="Activity_0snmatn">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:sequenceFlow id="Flow_0mxq0qe" name="Failure" sourceRef="Gateway_1nr51kr" targetRef="Event_16k9r1c" />
+ <bpmn:sequenceFlow id="Flow_1ru18s3" sourceRef="Activity_0ft7fa2" targetRef="Gateway_1vq11i7" />
+ <bpmn:sequenceFlow id="Flow_1tcnzdx" name="Failure" sourceRef="Gateway_1vq11i7" targetRef="Event_03tpudy" />
+ <bpmn:sequenceFlow id="Flow_0l67uzl" name="Success" sourceRef="Gateway_1vq11i7" targetRef="Activity_1n4rk7m">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:sequenceFlow id="Flow_1v0mxe7" sourceRef="Activity_0qgmx7a" targetRef="Activity_09bqns0" />
+ <bpmn:sequenceFlow id="Flow_0frhsd0" sourceRef="Activity_1n4rk7m" targetRef="Activity_1lz38px" />
+ <bpmn:sequenceFlow id="Flow_0mbp7mv" name="Success" sourceRef="Gateway_02fectw" targetRef="Activity_1hp67qz">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:callActivity id="Activity_0n17xou" name="BPMN to Execute" calledElement="${healthCheckWorkflow}">
+ <bpmn:extensionElements>
+ <camunda:in source="bpmnRequest" target="bpmnRequest" />
+ <camunda:out source="WorkflowException" target="WorkflowException" />
+ <camunda:in source="msoRequestId" target="msoRequestId" />
+ <camunda:out source="WorkflowExceptionErrorMessage" target="WorkflowExceptionErrorMessage" />
+ <camunda:out source="ControllerStatus" target="ControllerStatus" />
+ <camunda:in source="isRollback" target="isRollback" />
+ <camunda:in source="pnfName" target="pnfName" />
+ </bpmn:extensionElements>
+ <bpmn:incoming>Flow_1p4xkdj</bpmn:incoming>
+ <bpmn:outgoing>Flow_0trmo7s</bpmn:outgoing>
+ </bpmn:callActivity>
+ <bpmn:sequenceFlow id="Flow_0trmo7s" sourceRef="Activity_0n17xou" targetRef="Gateway_1nr51kr" />
+ <bpmn:callActivity id="Activity_1q4o9fx" name="BPMN to Execute" calledElement="${softwareUpgradeWorkflow}">
+ <bpmn:extensionElements>
+ <camunda:in source="bpmnRequest" target="bpmnRequest" />
+ <camunda:out source="WorkflowException" target="WorkflowException" />
+ <camunda:in source="msoRequestId" target="msoRequestId" />
+ <camunda:out source="WorkflowExceptionErrorMessage" target="WorkflowExceptionErrorMessage" />
+ <camunda:out source="ControllerStatus" target="ControllerStatus" />
+ <camunda:in source="isRollback" target="isRollback" />
+ <camunda:in source="pnfName" target="pnfName" />
+ </bpmn:extensionElements>
+ <bpmn:incoming>Flow_01gwzx9</bpmn:incoming>
+ <bpmn:outgoing>Flow_1y3cptr</bpmn:outgoing>
+ </bpmn:callActivity>
+ <bpmn:sequenceFlow id="Flow_1y3cptr" sourceRef="Activity_1q4o9fx" targetRef="Gateway_02fectw" />
+ <bpmn:serviceTask id="Activity_1hp67qz" name="Update ServiceInstance To AAI" camunda:delegateExpression="${UpdateServiceInstanceInAai}">
+ <bpmn:incoming>Flow_0mbp7mv</bpmn:incoming>
+ <bpmn:outgoing>Flow_0dyc3kv</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="Flow_0dyc3kv" sourceRef="Activity_1hp67qz" targetRef="Gateway_18ch73t" />
+ <bpmn:exclusiveGateway id="Gateway_18ch73t" default="Flow_0ny61qm">
+ <bpmn:incoming>Flow_0dyc3kv</bpmn:incoming>
+ <bpmn:outgoing>Flow_05ohtnj</bpmn:outgoing>
+ <bpmn:outgoing>Flow_0ny61qm</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:sequenceFlow id="Flow_05ohtnj" name="Success&#10;&#10;" sourceRef="Gateway_18ch73t" targetRef="Activity_0ft7fa2">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("ControllerStatus").equals("Success")}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:endEvent id="Event_1fhov6x">
+ <bpmn:incoming>Flow_0ny61qm</bpmn:incoming>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_0od3xnw" errorRef="Error_01a8p43" />
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="Flow_0ny61qm" name="Failure&#10;" sourceRef="Gateway_18ch73t" targetRef="Event_1fhov6x" />
+ </bpmn:process>
+ <bpmn:error id="Error_01a8p43" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
+ <bpmn:error id="Error_0e5owqi" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
+ <bpmn:error id="Error_1at4rzq" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
+ <bpmn:error id="Error_04y00c4" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ServiceLevelUpgrade">
+ <bpmndi:BPMNEdge id="Flow_0ny61qm_di" bpmnElement="Flow_0ny61qm">
+ <di:waypoint x="1190" y="278" />
+ <di:waypoint x="1190" y="334" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1152" y="290" width="35" height="27" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_05ohtnj_di" bpmnElement="Flow_05ohtnj">
+ <di:waypoint x="1206" y="262" />
+ <di:waypoint x="1300" y="262" />
+ <di:waypoint x="1300" y="372" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1232" y="244" width="43" height="40" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0dyc3kv_di" bpmnElement="Flow_0dyc3kv">
+ <di:waypoint x="1120" y="262" />
+ <di:waypoint x="1174" y="262" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1y3cptr_di" bpmnElement="Flow_1y3cptr">
+ <di:waypoint x="860" y="262" />
+ <di:waypoint x="904" y="262" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0trmo7s_di" bpmnElement="Flow_0trmo7s">
+ <di:waypoint x="450" y="262" />
+ <di:waypoint x="501" y="262" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0mbp7mv_di" bpmnElement="Flow_0mbp7mv">
+ <di:waypoint x="936" y="262" />
+ <di:waypoint x="1020" y="262" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="948" y="248" width="43" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0frhsd0_di" bpmnElement="Flow_0frhsd0">
+ <di:waypoint x="312" y="482" />
+ <di:waypoint x="372" y="482" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1v0mxe7_di" bpmnElement="Flow_1v0mxe7">
+ <di:waypoint x="532" y="122" />
+ <di:waypoint x="562" y="122" />
+ <di:waypoint x="562" y="192" />
+ <di:waypoint x="172" y="192" />
+ <di:waypoint x="172" y="262" />
+ <di:waypoint x="212" y="262" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0l67uzl_di" bpmnElement="Flow_0l67uzl">
+ <di:waypoint x="1054" y="412" />
+ <di:waypoint x="172" y="412" />
+ <di:waypoint x="172" y="482" />
+ <di:waypoint x="212" y="482" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="663" y="398" width="43" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1tcnzdx_di" bpmnElement="Flow_1tcnzdx">
+ <di:waypoint x="1070" y="428" />
+ <di:waypoint x="1070" y="494" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1032" y="451" width="35" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1ru18s3_di" bpmnElement="Flow_1ru18s3">
+ <di:waypoint x="1250" y="412" />
+ <di:waypoint x="1086" y="412" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0mxq0qe_di" bpmnElement="Flow_0mxq0qe">
+ <di:waypoint x="517" y="278" />
+ <di:waypoint x="517" y="334" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="472" y="296" width="35" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1z06yyv_di" bpmnElement="Flow_1z06yyv">
+ <di:waypoint x="533" y="262" />
+ <di:waypoint x="590" y="262" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="540" y="248" width="43" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1p4xkdj_di" bpmnElement="Flow_1p4xkdj">
+ <di:waypoint x="312" y="262" />
+ <di:waypoint x="350" y="262" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0y1ebox_di" bpmnElement="Flow_0y1ebox">
+ <di:waypoint x="920" y="278" />
+ <di:waypoint x="918" y="335" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="879" y="296" width="35" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_01gwzx9_di" bpmnElement="Flow_01gwzx9">
+ <di:waypoint x="690" y="262" />
+ <di:waypoint x="760" y="262" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_10jgbxm_di" bpmnElement="Flow_10jgbxm">
+ <di:waypoint x="472" y="482" />
+ <di:waypoint x="524" y="480" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1b392qs_di" bpmnElement="Flow_1b392qs">
+ <di:waypoint x="362" y="122" />
+ <di:waypoint x="432" y="122" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0nrz340_di" bpmnElement="Flow_0nrz340">
+ <di:waypoint x="186" y="120" />
+ <di:waypoint x="262" y="122" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="Event_02mc8tr_di" bpmnElement="Event_02mc8tr">
+ <dc:Bounds x="154" y="104" width="32" height="32" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="-6" y="-188" width="51" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_18vue7u_di" bpmnElement="Activity_18vue7u">
+ <dc:Bounds x="262" y="82" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_12983th_di" bpmnElement="Event_12983th">
+ <dc:Bounds x="524" y="464" width="32" height="32" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="-132" y="-188" width="20" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Gateway_02fectw_di" bpmnElement="Gateway_02fectw" isMarkerVisible="true">
+ <dc:Bounds x="904" y="246" width="32" height="32" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_0ldlupa_di" bpmnElement="Event_0ldlupa">
+ <dc:Bounds x="905" y="334" width="32" height="32" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Gateway_1nr51kr_di" bpmnElement="Gateway_1nr51kr" isMarkerVisible="true">
+ <dc:Bounds x="501" y="246" width="32" height="32" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_16k9r1c_di" bpmnElement="Event_16k9r1c">
+ <dc:Bounds x="501" y="334" width="32" height="32" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Gateway_1vq11i7_di" bpmnElement="Gateway_1vq11i7" isMarkerVisible="true">
+ <dc:Bounds x="1054" y="396" width="32" height="32" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_03tpudy_di" bpmnElement="Event_03tpudy">
+ <dc:Bounds x="1054" y="494" width="32" height="32" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_0snmatn_di" bpmnElement="Activity_0snmatn">
+ <dc:Bounds x="590" y="222" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_0ft7fa2_di" bpmnElement="Activity_0ft7fa2">
+ <dc:Bounds x="1250" y="372" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_09bqns0_di" bpmnElement="Activity_09bqns0">
+ <dc:Bounds x="212" y="222" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_0qgmx7a_di" bpmnElement="Activity_0qgmx7a">
+ <dc:Bounds x="432" y="82" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1n4rk7m_di" bpmnElement="Activity_1n4rk7m">
+ <dc:Bounds x="212" y="442" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1lz38px_di" bpmnElement="Activity_1lz38px">
+ <dc:Bounds x="372" y="442" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_0ui6tp1_di" bpmnElement="Activity_0ui6tp1" isExpanded="true">
+ <dc:Bounds x="362" y="572" width="650" height="190" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="Flow_0iayg6u_di" bpmnElement="Flow_0iayg6u">
+ <di:waypoint x="466" y="670" />
+ <di:waypoint x="532" y="672" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0lb7zv5_di" bpmnElement="Flow_0lb7zv5">
+ <di:waypoint x="632" y="672" />
+ <di:waypoint x="702" y="672" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1peoyur_di" bpmnElement="Flow_1peoyur">
+ <di:waypoint x="802" y="672" />
+ <di:waypoint x="874" y="670" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="Event_08f3m9h_di" bpmnElement="Event_08f3m9h">
+ <dc:Bounds x="434" y="654" width="32" height="32" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="-161" y="-188" width="78" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1k2f3ha_di" bpmnElement="Activity_1k2f3ha">
+ <dc:Bounds x="532" y="632" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_0ai3z2q_di" bpmnElement="Activity_0ai3z2q">
+ <dc:Bounds x="702" y="632" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_0ngb9wx_di" bpmnElement="Event_0ngb9wx">
+ <dc:Bounds x="874" y="654" width="32" height="32" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="-132" y="-188" width="20" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_0n17xou_di" bpmnElement="Activity_0n17xou">
+ <dc:Bounds x="350" y="222" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1q4o9fx_di" bpmnElement="Activity_1q4o9fx">
+ <dc:Bounds x="760" y="222" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1hp67qz_di" bpmnElement="Activity_1hp67qz">
+ <dc:Bounds x="1020" y="222" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Gateway_18ch73t_di" bpmnElement="Gateway_18ch73t" isMarkerVisible="true">
+ <dc:Bounds x="1174" y="246" width="32" height="32" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_1fhov6x_di" bpmnElement="Event_1fhov6x">
+ <dc:Bounds x="1174" y="334" width="32" height="32" />
+ </bpmndi:BPMNShape>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</bpmn:definitions>
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java
new file mode 100644
index 0000000000..00dda299b6
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java
@@ -0,0 +1,259 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.process;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.okJson;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static org.assertj.core.api.Assertions.fail;
+import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat;
+import com.google.protobuf.Struct;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.camunda.bpm.engine.runtime.ProcessInstance;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aaiclient.client.aai.AAIVersion;
+import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers;
+import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
+import org.onap.so.BaseBPMNTest;
+import org.onap.so.GrpcNettyServer;
+import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames;
+import org.onap.so.bpmn.mock.FileUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * Basic Integration test for ServiceLevelUpgrade.bpmn workflow.
+ */
+public class ServiceLevelUpgradeTest extends BaseBPMNTest {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ private static final long WORKFLOW_WAIT_TIME = 1000L;
+
+ private static final String TEST_PROCESSINSTANCE_KEY = "ServiceLevelUpgrade";
+ private static final AAIVersion VERSION = AAIVersion.LATEST;
+ private static final Map<String, Object> executionVariables = new HashMap();
+ private static final String REQUEST_ID = "50ae41ad-049c-4fe2-9950-539f111120f5";
+ private static final String SERVICE_INSTANCE_ID = "5df8b6de-2083-11e7-93ae-92361f002676";
+ private final String[] actionNames = new String[5];
+ private final String CLASSNAME = getClass().getSimpleName();
+ private String requestObject;
+ private String responseObject;
+
+ @Autowired
+ private GrpcNettyServer grpcNettyServer;
+
+ @Before
+ public void setUp() throws IOException {
+ actionNames[0] = "healthCheck";
+ actionNames[1] = "preCheck";
+ actionNames[2] = "downloadNESw";
+ actionNames[3] = "activateNESw";
+ actionNames[4] = "postCheck";
+
+ executionVariables.clear();
+
+ requestObject = FileUtil.readResourceFile("request/" + CLASSNAME + ".json");
+ responseObject = FileUtil.readResourceFile("response/" + CLASSNAME + ".json");
+
+ executionVariables.put("bpmnRequest", requestObject);
+ executionVariables.put("requestId", REQUEST_ID);
+ executionVariables.put("serviceInstanceId", SERVICE_INSTANCE_ID);
+
+
+ /**
+ * This variable indicates that the flow was invoked asynchronously. It's injected by {@link WorkflowProcessor}.
+ */
+ executionVariables.put("isAsyncProcess", "true");
+ executionVariables.put(ExecutionVariableNames.PRC_CUSTOMIZATION_UUID, "38dc9a92-214c-11e7-93ae-92361f002680");
+
+ /**
+ * Temporary solution to add pnfCorrelationId to context. this value is getting from the request to SO api
+ * handler and then convert to CamudaInput
+ */
+ executionVariables.put(ExecutionVariableNames.PNF_CORRELATION_ID, "PNFDemo");
+ }
+
+
+ @Test
+ public void workflow_validInput_expectedOutput() throws InterruptedException {
+
+ mockCatalogDb();
+ mockRequestDb();
+ mockAai();
+
+ final String msoRequestId = UUID.randomUUID().toString();
+ executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId);
+
+ final String testBusinessKey = UUID.randomUUID().toString();
+ logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey);
+
+ ProcessInstance pi =
+ runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables);
+
+ int waitCount = 10;
+ while (!isProcessInstanceEnded() && waitCount >= 0) {
+ Thread.sleep(WORKFLOW_WAIT_TIME);
+ waitCount--;
+ }
+
+ // Layout is to reflect the bpmn visual layout
+ assertThat(pi).isEnded().hasPassedInOrder("Event_02mc8tr", "Activity_18vue7u", "Activity_0qgmx7a",
+ "Activity_09bqns0", "Activity_0n17xou", "Gateway_1nr51kr", "Activity_0snmatn", "Activity_1q4o9fx",
+ "Gateway_02fectw", "Activity_1hp67qz", "Gateway_18ch73t", "Activity_0ft7fa2", "Gateway_1vq11i7",
+ "Activity_1n4rk7m", "Activity_1lz38px", "Event_12983th");
+
+ List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages();
+ assertThat(detailedMessages.size() == 5);
+ int count = 0;
+ try {
+ for (ExecutionServiceInput eSI : detailedMessages) {
+ for (String action : actionNames) {
+ if (action.equals(eSI.getActionIdentifiers().getActionName())
+ && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) {
+ checkWithActionName(eSI, action);
+ count++;
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("PNFSoftwareUpgrade request exception", e);
+ }
+ assertThat(count == actionNames.length);
+ }
+
+ private boolean isProcessInstanceEnded() {
+ return runtimeService.createProcessInstanceQuery().processDefinitionKey(TEST_PROCESSINSTANCE_KEY)
+ .singleResult() == null;
+ }
+
+ private void checkWithActionName(ExecutionServiceInput executionServiceInput, String action) {
+
+ logger.info("Checking the " + action + " request");
+ ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers();
+
+ /**
+ * the fields of actionIdentifiers should match the one in the response/PnfHealthCheck_catalogdb.json.
+ */
+ assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_pnf_software_upgrade_restconf");
+ assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0");
+ assertThat(actionIdentifiers.getActionName()).isEqualTo(action);
+ assertThat(actionIdentifiers.getMode()).isEqualTo("async");
+
+ CommonHeader commonHeader = executionServiceInput.getCommonHeader();
+ assertThat(commonHeader.getOriginatorId()).isEqualTo("SO");
+
+ Struct payload = executionServiceInput.getPayload();
+ Struct requeststruct = payload.getFieldsOrThrow(action + "-request").getStructValue();
+
+ assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).isEqualTo("PNFDemo");
+ Struct propertiesStruct = requeststruct.getFieldsOrThrow(action + "-properties").getStructValue();
+
+ assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo("PNFDemo");
+ assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue())
+ .isEqualTo("d88da85c-d9e8-4f73-b837-3a72a431622b");
+ assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue())
+ .isEqualTo("38dc9a92-214c-11e7-93ae-92361f002680");
+ }
+
+ private void mockAai() {
+
+ final String sIUrl =
+ "/business/customers/customer/5df8b6de-2083-11e7-93ae-92361f002676/service-subscriptions/service-subscription/pNF/service-instances/service-instance/ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce";
+ final String aaiPnfEntry = FileUtil.readResourceFile("response/Pnf_aai.json");
+ final String aaiServiceInstanceEntry = FileUtil.readResourceFile("response/Service_instance_aai.json");
+
+ /**
+ * PUT the PNF correlation ID to AAI.
+ */
+ wireMockServer.stubFor(put(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")));
+
+ /**
+ * Get the PNF entry from AAI.
+ */
+ wireMockServer.stubFor(
+ get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry)));
+
+ /**
+ * Post the pnf to AAI
+ */
+ wireMockServer.stubFor(post(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")));
+
+ /**
+ * Get the Service Instance to AAI.
+ */
+ wireMockServer.stubFor(get(urlEqualTo("/aai/" + VERSION + sIUrl)).willReturn(okJson(aaiServiceInstanceEntry)));
+
+ /**
+ * Post the Service Instance to AAI.
+ */
+ wireMockServer.stubFor(post(urlEqualTo("/aai/" + VERSION + sIUrl)));
+ }
+
+ private void mockRequestDb() {
+ /**
+ * Update Request DB
+ */
+ wireMockServer.stubFor(put(urlEqualTo("/infraActiveRequests/" + REQUEST_ID)));
+
+ }
+
+ /**
+ * Mock the catalobdb rest interface.
+ */
+ private void mockCatalogDb() {
+
+ String catalogdbClientResponse = FileUtil.readResourceFile("response/" + CLASSNAME + "_catalogdb.json");
+
+
+ /**
+ * Return valid json for the model UUID in the request file.
+ */
+ wireMockServer
+ .stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=d88da85c-d9e8-4f73-b837-3a72a431622b"))
+ .willReturn(okJson(responseObject)));
+
+ /**
+ * Return valid json for the service model InvariantUUID as specified in the request file.
+ */
+ wireMockServer.stubFor(
+ get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=fe41489e-1563-46a3-b90a-1db629e4375b"))
+ .willReturn(okJson(responseObject)));
+
+ /**
+ * Return valid spring data rest json for the service model UUID as specified in the request file.
+ */
+ wireMockServer.stubFor(get(urlEqualTo(
+ "/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=d88da85c-d9e8-4f73-b837-3a72a431622b"))
+ .willReturn(okJson(catalogdbClientResponse)));
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/ServiceLevelUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/ServiceLevelUpgradeTest.json
new file mode 100644
index 0000000000..b5cce60094
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/ServiceLevelUpgradeTest.json
@@ -0,0 +1,48 @@
+{
+ "requestDetails":{
+ "subscriberInfo":{
+ "globalSubscriberId":"ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce"
+ },
+ "requestInfo":{
+ "suppressRollback": false,
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "requestorId": "demo",
+ "instanceName":"testInstanceName",
+ "source":"VID"
+ },
+ "cloudConfiguration":{
+ "lcpCloudRegionId": "RegionOne",
+ "tenantId": "7320ec4a5b9d4589ba7c4412ccfd290f",
+ "cloudOwner": "CloudOwner"
+ },
+ "requestParameters":{
+ "subscriptionServiceType": "pNF",
+ "userParams":[
+ {
+ "name":"targetSoftwareVersion",
+ "value":"demo-sw-ver2.0.0"
+ },
+ {
+ "name":"pnfName",
+ "value":"PNFDemo"
+ }
+ ],
+ "aLaCarte": false,
+ "payload": "{\"k1\": \"v1\"}"
+ },
+ "project":{
+ "projectName": "ServiceLevelUpgrade"
+ },
+ "owningEntity":{
+ "owningEntityId":"67f2e84c-734d-4e90-a1e4-d2ffa2e75849",
+ "owningEntityName":"OE-Test"
+ },
+ "modelInfo":{
+ "modelVersion": "2.0",
+ "modelVersionId": "d88da85c-d9e8-4f73-b837-3a72a431622b",
+ "modelInvariantId": "fe41489e-1563-46a3-b90a-1db629e4375b",
+ "modelName": "Demo_svc",
+ "modelType": "service"
+ }
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Pnf_aai.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Pnf_aai.json
new file mode 100644
index 0000000000..865600c800
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Pnf_aai.json
@@ -0,0 +1,42 @@
+{
+ "pnf-name": "PNFDemo",
+ "pnf-id": "27c6e19d-6d9f-4085-98a9-d3fcbaf3a616",
+ "equip-type": "val8",
+ "equip-vendor": "Ericsson",
+ "equip-model": "val6",
+ "ipaddress-v4-oam": "10.10.10.43",
+ "sw-version": "5gDUv18.05.201",
+ "in-maint": false,
+ "serial-number": "6061ZW3",
+ "ipaddress-v6-oam": "2001:0db8:0:0:0:0:1428:57ab",
+ "resource-version": "1595010038094",
+ "nf-role": "gNB",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "related-link": "/aai/v11/business/customers/customer/ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce/service-subscriptions/service-subscription/pNF/service-instances/service-instance/5df8b6de-2083-11e7-93ae-92361f002676",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "ETE_Customer_807c7a02-249c-4db8-9fa9-bee973fe08ce"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "pNF"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "5df8b6de-2083-11e7-93ae-92361f002676"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "Service_Ete_Name123452c4-3d7f-42ce-8188-818fab951269"
+ }
+ ]
+ }
+ ]
+ }
+}, \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest.json
new file mode 100644
index 0000000000..ec92552c5e
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest.json
@@ -0,0 +1,27 @@
+{
+ "serviceResources":{
+ "modelInfo":{
+ "modelVersion": "2.0",
+ "modelVersionId": "d88da85c-d9e8-4f73-b837-3a72a431622b",
+ "modelInvariantId": "fe41489e-1563-46a3-b90a-1db629e4375b",
+ "modelName": "Demo_svc",
+ "modelType": "service"
+ },
+ "serviceType":"pNF",
+ "environmentContext":"Luna",
+ "serviceRole":"NA",
+ "workloadContext":"Oxygen",
+ "serviceVnfs":[
+
+ ],
+ "serviceNetworks":[
+
+ ],
+ "serviceAllottedResources":[
+
+ ],
+ "configResource":[
+
+ ]
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest_catalogdb.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest_catalogdb.json
new file mode 100644
index 0000000000..faec947fec
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/ServiceLevelUpgradeTest_catalogdb.json
@@ -0,0 +1,39 @@
+{
+ "_embedded": {
+ "pnfResourceCustomization": [
+ {
+ "modelCustomizationUUID": "38dc9a92-214c-11e7-93ae-92361f002680",
+ "modelInstanceName": "PNF routing",
+ "created": "2019-03-08 12:00:29.000",
+ "nfFunction": "routing",
+ "nfType": "routing",
+ "nfRole": "routing",
+ "nfNamingCode": "routing",
+ "multiStageDesign": null,
+ "resourceInput": null,
+ "blueprintName": "test_pnf_software_upgrade_restconf",
+ "blueprintVersion": "1.0.0",
+ "skipPostInstConf": false,
+ "softwareVersion": "1.0.0",
+ "creationTimestamp": "2019-03-08T12:00:29.000+0000",
+ "controllerActor": "cds",
+ "_links": {
+ "self": {
+ "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680"
+ },
+ "pnfResourceCustomization": {
+ "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680"
+ },
+ "pnfResources": {
+ "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680/pnfResources"
+ }
+ }
+ }
+ ]
+ },
+ "_links": {
+ "self": {
+ "href": "http://localhost:41023/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=4df8b6de-2083-11e7-93ae-92361f002676"
+ }
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Service_instance_aai.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Service_instance_aai.json
new file mode 100644
index 0000000000..53fb210478
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/Service_instance_aai.json
@@ -0,0 +1,35 @@
+{
+ "service-instance-id": "5df8b6de-2083-11e7-93ae-92361f002676",
+ "service-instance-name": "Service_Ete_Name123452c4-3d7f-42ce-8188-818fab951269",
+ "environment-context": "General_Revenue-Bearing",
+ "workload-context": "Production",
+ "model-version-id": "d88da85c-d9e8-4f73-b837-3a72a431622b",
+ "modelInvariantId": "fe41489e-1563-46a3-b90a-1db629e4375b",
+ "resource-version": "1595258335377",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/5df8b6de-2083-11e7-93ae-92361f002676/service-data/service-topology/",
+ "orchestration-status": "Assigned",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "owning-entity",
+ "related-link": "/aai/v11/business/owning-entities/owning-entity/67f2e84c-734d-4e90-a1e4-d2ffa2e75849",
+ "relationship-data": [
+ {
+ "relationship-key": "owning-entity.owning-entity-id",
+ "relationship-value": "67f2e84c-734d-4e90-a1e4-d2ffa2e75849"
+ }
+ ]
+ },
+ {
+ "related-to": "pnf",
+ "related-link": "/aai/v11/network/pnfs/pnf/PNFDemo",
+ "relationship-data": [
+ {
+ "relationship-key": "pnf.pnf-name",
+ "relationship-value": "PNFDemo"
+ }
+ ]
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/AbstractServiceLevelPreparable.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparable.java
index 36db549486..e26195158d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/AbstractServiceLevelPreparable.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparable.java
@@ -20,40 +20,58 @@
package org.onap.so.bpmn.infrastructure.service.level;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelConstants;
import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.db.catalog.beans.Workflow;
+import org.onap.so.db.catalog.client.CatalogDbClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.ArrayList;
-import java.util.List;
/**
- * Abstract class for Service level upgrade Execution, it should be extended for service level upgrade tasks.
+ * Parent class for Service level upgrade Execution, it should be extended for service level upgrade tasks.
*/
-public abstract class AbstractServiceLevelPreparable {
+public class ServiceLevelPreparable {
- protected static final String WORKFLOW_TO_INVOKE = "healthCheckWorkflow";
- protected static final String GENERIC_PNF_HEALTH_CHECK_WORKFLOW = "GenericPnfHealthCheck";
- protected static final String GENERIC_PNF_SOFTWARE_UPGRADE_WORKFLOW = "GenericPnfSoftwareUpgrade";
- protected static final String RESOURCE_TYPE = "RESOURCE_TYPE";
- protected static final int ERROR_CODE = 601;
-
- // TODO This value needs to be updated once vnf health check workflow is available
- protected static final String GENERIC_VNF_HEALTH_CHECK_WORKFLOW = "GenericVNFHealthCheck";
-
- protected static final Logger LOG = LoggerFactory.getLogger(AbstractServiceLevelPreparable.class);
+ protected static final Logger LOG = LoggerFactory.getLogger(ServiceLevelPreparable.class);
@Autowired
protected ExceptionBuilder exceptionBuilder;
+ @Autowired
+ protected CatalogDbClient catalogDbClient;
+
/**
- * This method fetches workflow names to be invoked based on the controller scope .
+ * Fetches workflow names based on the controller scope and operation name.
*
* @param scope Controller scope
+ * @param operationName healthcheck/softwareUpgrade
* @return String value of Workflow name
*/
- protected abstract String fetchWorkflowUsingScope(DelegateExecution execution, final String scope);
+ protected String fetchWorkflowUsingScope(final String scope, String operationName) {
+ Optional<String> wflName = Optional.empty();
+ try {
+ List<Workflow> workflows = catalogDbClient.findWorkflowByOperationName(operationName);
+ if (!workflows.isEmpty()) {
+ wflName = Optional.ofNullable(
+ workflows.stream().filter(workflow -> workflow.getResourceTarget().equalsIgnoreCase(scope))
+ .findFirst().get().getName());
+ }
+ } catch (Exception e) {
+ // do nothing and assign the default workflow in finally
+ LOG.error("Error occurred while fetching workflow name from CatalogDb {}", e);
+ } finally {
+ if (wflName.isEmpty()) {
+ wflName = Optional.of(ServiceLevelConstants.WORKFLOW_OPERATIONS_MAP.get(operationName).get(scope));
+ }
+ }
+ return wflName.get();
+
+ }
/**
* This method validates the execution parameters to be passed for health check workflow.
@@ -61,8 +79,7 @@ public abstract class AbstractServiceLevelPreparable {
* @param execution Delegate execution obj
* @param scope Controller scope * Throws workflow exception if validation fails
*/
- protected void validateParamsWithScope(DelegateExecution execution, final String scope, List<String> params)
- throws Exception {
+ protected void validateParamsWithScope(DelegateExecution execution, final String scope, List<String> params) {
List<String> invalidVariables = new ArrayList<>();
for (String param : params) {
if (!execution.hasVariable(param) || execution.getVariable(param) == null
@@ -72,7 +89,7 @@ public abstract class AbstractServiceLevelPreparable {
}
if (invalidVariables.size() > 0) {
LOG.error("Validation error for the {} health check attributes: {}", scope, invalidVariables);
- exceptionBuilder.buildAndThrowWorkflowException(execution, ERROR_CODE,
+ exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE,
"Validation of health check workflow parameters failed for the scope: " + scope);
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java
new file mode 100644
index 0000000000..d94641846d
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.service.level.impl;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+public class ServiceLevelConstants {
+ public static final String BPMN_REQUEST = "bpmnRequest";
+ public static final String RESOURCE_TYPE = "resourceType";
+ public static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
+ public static final String PNF_NAME = "pnfName";
+ public static final String PNF = "pnf";
+ public static final String VNF = "vnf";
+ public static final String EMPTY_STRING = "";
+ public static final String HEALTH_CHECK_WORKFLOW_TO_INVOKE = "healthCheckWorkflow";
+ public static final String SOFTWARE_WORKFLOW_TO_INVOKE = "softwareUpgradeWorkflow";
+ public static final String HEALTH_CHECK_OPERATION = "ResourceHealthCheck";
+ public static final String SW_UP_OPERATION = "ResourceSoftwareUpgrade";
+ public static final String CONTROLLER_STATUS = "ControllerStatus";
+ public static final int ERROR_CODE = 601;
+
+ // TODO GenericVNFHealthCheck and GenericVnfSoftwareUpgrade workflow names should be updated once the workflow is
+ // implemented.
+ public static final Map<String, String> DEFAULT_HEALTH_CHECK_WORKFLOWS =
+ Map.of(PNF, "GenericPnfHealthCheck", VNF, "GenericVNFHealthCheck");
+
+ public static final Map<String, String> DEFAULT_SOFTWARE_UP_WORKFLOWS =
+ Map.of(PNF, "PNFSoftwareUpgrade", VNF, "GenericVnfSoftwareUpgrade");
+
+ // Maps operation name with workflows
+ public static final Map<String, Map<String, String>> WORKFLOW_OPERATIONS_MAP = Map.of(HEALTH_CHECK_OPERATION,
+ DEFAULT_HEALTH_CHECK_WORKFLOWS, SW_UP_OPERATION, DEFAULT_SOFTWARE_UP_WORKFLOWS);
+
+ public static final List<String> VALID_CONTROLLER_SCOPE = Arrays.asList(PNF, VNF);
+
+
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java
new file mode 100644
index 0000000000..fad28e315e
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPostcheck.java
@@ -0,0 +1,13 @@
+package org.onap.so.bpmn.infrastructure.service.level.impl;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ServiceLevelPostcheck implements JavaDelegate {
+ @Override
+ public void execute(DelegateExecution delegateExecution) throws Exception {
+ // TODO : Set serviceInstance to aai
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java
index 52521ce16b..59884ecbc2 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelPreparation.java
@@ -20,12 +20,14 @@
package org.onap.so.bpmn.infrastructure.service.level.impl;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.onap.so.bpmn.infrastructure.service.level.AbstractServiceLevelPreparable;
+import org.onap.so.bpmn.infrastructure.service.level.ServiceLevelPreparable;
import org.springframework.stereotype.Component;
-import java.util.Arrays;
-import java.util.List;
/**
@@ -33,45 +35,39 @@ import java.util.List;
* validation.
*/
@Component("ServiceLevelPreparation")
-public class ServiceLevelPreparation extends AbstractServiceLevelPreparable implements JavaDelegate {
+public class ServiceLevelPreparation extends ServiceLevelPreparable implements JavaDelegate {
+
+ private static final List<String> PNF_HEALTH_CHECK_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID,
+ ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST, ServiceLevelConstants.PNF_NAME);
- // Health check parameters to be validated for pnf resource
- private static final List<String> PNF_HC_PARAMS = Arrays.asList("SERVICE_MODEL_INFO", "SERVICE_INSTANCE_NAME",
- "PNF_CORRELATION_ID", "MODEL_UUID", "PNF_UUID", "PRC_BLUEPRINT_NAME", "PRC_BLUEPRINT_VERSION",
- "PRC_CUSTOMIZATION_UUID", "RESOURCE_CUSTOMIZATION_UUID_PARAM", "PRC_INSTANCE_NAME", "PRC_CONTROLLER_ACTOR",
- "REQUEST_PAYLOAD");
+ // TODO Update the list with vnf health check parameters if any validation needed
+ private static final List<String> VNF_HEALTH_CHECK_PARAMS = Collections.emptyList();
+
+ private static final Map<String, List<String>> HEALTH_CHECK_PARAMS_MAP = Map.of(ServiceLevelConstants.PNF,
+ PNF_HEALTH_CHECK_PARAMS, ServiceLevelConstants.VNF, VNF_HEALTH_CHECK_PARAMS);
@Override
public void execute(DelegateExecution execution) throws Exception {
- if (execution.hasVariable(RESOURCE_TYPE) && execution.getVariable(RESOURCE_TYPE) != null) {
- final String controllerScope = (String) execution.getVariable(RESOURCE_TYPE);
+ if (execution.hasVariable(ServiceLevelConstants.RESOURCE_TYPE)
+ && execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE) != null) {
+ final String controllerScope = (String) execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE);
LOG.debug("Scope retrieved from delegate execution: " + controllerScope);
- final String wflName = fetchWorkflowUsingScope(execution, controllerScope);
- LOG.debug("Health check workflow fetched for the scope: {}", wflName);
- validateParamsWithScope(execution, controllerScope, PNF_HC_PARAMS);
- LOG.info("Parameters validated successfully for {}", wflName);
- execution.setVariable(WORKFLOW_TO_INVOKE, wflName);
+ if (ServiceLevelConstants.VALID_CONTROLLER_SCOPE.contains(controllerScope)) {
+ final String wflName =
+ fetchWorkflowUsingScope(controllerScope, ServiceLevelConstants.HEALTH_CHECK_OPERATION);
+ LOG.debug("Health check workflow fetched for the scope: {} is: {}", controllerScope, wflName);
+ validateParamsWithScope(execution, controllerScope, HEALTH_CHECK_PARAMS_MAP.get(controllerScope));
+ LOG.info("Parameters validated successfully for {}", wflName);
+ execution.setVariable(ServiceLevelConstants.HEALTH_CHECK_WORKFLOW_TO_INVOKE, wflName);
+ execution.setVariable(ServiceLevelConstants.CONTROLLER_STATUS, ServiceLevelConstants.EMPTY_STRING);
+ } else {
+ exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE,
+ "Invalid Controller scope to prepare resource level health check");
+ }
} else {
- exceptionBuilder.buildAndThrowWorkflowException(execution, ERROR_CODE,
- "Controller scope not found to invoke resource level health check");
- }
- }
-
- @Override
- public String fetchWorkflowUsingScope(DelegateExecution execution, final String scope) {
- String wflName = null;
- switch (scope.toLowerCase()) {
- case "pnf":
- wflName = GENERIC_PNF_HEALTH_CHECK_WORKFLOW;
- break;
- case "vnf":
- wflName = GENERIC_VNF_HEALTH_CHECK_WORKFLOW;
- break;
- default:
- exceptionBuilder.buildAndThrowWorkflowException(execution, ERROR_CODE,
- "No valid health check work flow retrieved for the scope: " + scope);
+ exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE,
+ "Resource type not found in the execution to invoke resource level health check");
}
- return wflName;
}
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java
new file mode 100644
index 0000000000..5b20a86cb7
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelRequestDispatcher.java
@@ -0,0 +1,131 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.service.level.impl;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aaiclient.client.aai.AAIRestClientI;
+import org.onap.aaiclient.client.aai.AAIRestClientImpl;
+import org.onap.so.bpmn.core.json.JsonUtils;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.io.IOException;
+import java.util.Optional;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*;
+
+/**
+ * This implementation of {@link JavaDelegate} is used to populate the execution object for Service level upgrade
+ */
+@Component
+public class ServiceLevelRequestDispatcher implements JavaDelegate {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+
+ @Autowired
+ private ObjectMapper mapper;
+
+ @Override
+ public void execute(DelegateExecution delegateExecution) throws Exception {
+ logger.debug("Running execute block for activity id: {}, name: {}", delegateExecution.getCurrentActivityId(),
+ delegateExecution.getCurrentActivityName());
+
+ RequestDetails bpmnRequestDetails = requestVerification(delegateExecution);
+
+ final String serviceInstanceId = String.valueOf(delegateExecution.getVariable(SERVICE_INSTANCE_ID));
+ final String serviceType = bpmnRequestDetails.getRequestParameters().getSubscriptionServiceType();
+ final String globalSubscriberId = bpmnRequestDetails.getSubscriberInfo().getGlobalSubscriberId();
+
+ final String modelInvariantId = bpmnRequestDetails.getModelInfo().getModelInvariantId();
+ final String modelId = bpmnRequestDetails.getModelInfo().getModelUuid();
+ final String modelVersion = bpmnRequestDetails.getModelInfo().getModelVersion();
+
+ if (ServiceLevelConstants.PNF.equalsIgnoreCase(serviceType)) {
+ getAndSetPnfNameFromServiceInstance(serviceInstanceId, serviceType, globalSubscriberId, delegateExecution);
+ }
+
+ // TODO : handling for vnf
+
+ logger.trace("Completed dispatcher request for ServiceLevelUpgrade.");
+ }
+
+ private void getAndSetPnfNameFromServiceInstance(final String serviceInstanceId, final String serviceType,
+ final String globalSubscriberId, DelegateExecution delegateExecution) {
+
+ AAIRestClientI restClient = new AAIRestClientImpl();
+
+ Optional<ServiceInstance> optionalSi =
+ restClient.getServiceInstanceById(serviceInstanceId, serviceType, globalSubscriberId);
+
+ if (!optionalSi.isPresent()) {
+
+ }
+
+ optionalSi.ifPresentOrElse(serviceInstance -> {
+ final String pnfName = serviceInstance.getRelationshipList().getRelationship().stream()
+ .filter(x -> x.getRelatedTo().contains("pnf")).findFirst().get().getRelationshipData().stream()
+ .filter(data -> data.getRelationshipKey().contains("pnf.pnf-name")).findFirst().get()
+ .getRelationshipValue();
+ if (pnfName == null || pnfName.isEmpty()) {
+ logger.warn(
+ "Unable to find the PNF for service instance id: " + serviceInstance.getServiceInstanceId());
+ return;
+ }
+ delegateExecution.setVariable(ServiceLevelConstants.PNF_NAME, pnfName);
+ delegateExecution.setVariable(ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.PNF);
+ }, () -> {
+ throwExceptionWithWarn(delegateExecution, "Unable to find the service instance: " + serviceInstanceId);
+ });
+ }
+
+ private RequestDetails requestVerification(DelegateExecution delegateExecution) throws IOException {
+ RequestDetails bpmnRequestDetails = mapper.readValue(JsonUtils.getJsonValue(
+ String.valueOf(delegateExecution.getVariable(ServiceLevelConstants.BPMN_REQUEST)), "requestDetails"),
+ RequestDetails.class);
+
+ throwIfNull(delegateExecution, bpmnRequestDetails.getModelInfo(), SERVICE_MODEL_INFO);
+ throwIfNull(delegateExecution, bpmnRequestDetails.getRequestInfo(), "RequestInfo");
+ throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters(), "RequestParameters");
+ throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters().getUserParams(), "UserParams");
+
+ return bpmnRequestDetails;
+ }
+
+ private void throwIfNull(DelegateExecution delegateExecution, Object obj, String param) {
+ if (obj == null) {
+ throwExceptionWithWarn(delegateExecution,
+ "Unable to find the parameter: " + param + " in the execution context");
+ }
+ }
+
+ private void throwExceptionWithWarn(DelegateExecution delegateExecution, String exceptionMsg) {
+ logger.warn(exceptionMsg);
+ exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ServiceLevelConstants.ERROR_CODE, exceptionMsg);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java
new file mode 100644
index 0000000000..9d7d8efb65
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelUpgrade.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.service.level.impl;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.so.bpmn.infrastructure.service.level.ServiceLevelPreparable;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ServiceLevelUpgrade extends ServiceLevelPreparable implements JavaDelegate {
+
+ private static final List<String> PNF_SOFTWARE_UP_PARAMS = Arrays.asList(ServiceLevelConstants.SERVICE_INSTANCE_ID,
+ ServiceLevelConstants.RESOURCE_TYPE, ServiceLevelConstants.BPMN_REQUEST, ServiceLevelConstants.PNF_NAME);
+
+ // TODO Update the list with vnf software upgrade parameters if any validation needed
+ private static final List<String> VNF_SOFTWARE_UP_PARAMS = Collections.emptyList();
+
+ private static final Map<String, List<String>> SOFTWARE_UP_PARAMS_MAP = Map.of(ServiceLevelConstants.PNF,
+ PNF_SOFTWARE_UP_PARAMS, ServiceLevelConstants.VNF, VNF_SOFTWARE_UP_PARAMS);
+
+
+ @Override
+ public void execute(DelegateExecution execution) throws Exception {
+ if (execution.hasVariable(ServiceLevelConstants.RESOURCE_TYPE)
+ && execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE) != null) {
+ final String controllerScope = (String) execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE);
+ LOG.debug("Scope retrieved from delegate execution: " + controllerScope);
+ if (ServiceLevelConstants.VALID_CONTROLLER_SCOPE.contains(controllerScope)) {
+ final String wflName = fetchWorkflowUsingScope(controllerScope, ServiceLevelConstants.SW_UP_OPERATION);
+ LOG.debug("Software Upgrade workflow fetched for the scope: {} is: {}", controllerScope, wflName);
+ validateParamsWithScope(execution, controllerScope, SOFTWARE_UP_PARAMS_MAP.get(controllerScope));
+ LOG.info("Parameters validated successfully for {}", wflName);
+ execution.setVariable(ServiceLevelConstants.SOFTWARE_WORKFLOW_TO_INVOKE, wflName);
+ execution.setVariable(ServiceLevelConstants.CONTROLLER_STATUS, "");
+ } else {
+ exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE,
+ "Invalid Controller scope for resource level software upgrade");
+ }
+ } else {
+ exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE,
+ "Resource type not found in the execution to invoke resource level software upgrade");
+ }
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/UpdateServiceInstanceInAai.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/UpdateServiceInstanceInAai.java
new file mode 100644
index 0000000000..c9bd607b8b
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/UpdateServiceInstanceInAai.java
@@ -0,0 +1,123 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.service.level.impl;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aaiclient.client.aai.AAIRestClientI;
+import org.onap.aaiclient.client.aai.AAIRestClientImpl;
+import org.onap.so.bpmn.core.json.JsonUtils;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.io.IOException;
+import java.util.Optional;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_MODEL_INFO;
+
+@Component
+public class UpdateServiceInstanceInAai implements JavaDelegate {
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+ private static final String BPMN_REQUEST = "bpmnRequest";
+ private static final String PNF_RESOURCE = "pnf";
+ private static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
+
+ // ERROR CODE for variable not found in the delegation Context
+ private static final int ERROR_CODE = 601;
+
+ @Autowired
+ private ObjectMapper mapper;
+
+ @Override
+ public void execute(DelegateExecution delegateExecution) throws Exception {
+ logger.debug("Running execute block for activity id: {}, name: {}", delegateExecution.getCurrentActivityId(),
+ delegateExecution.getCurrentActivityName());
+
+ RequestDetails bpmnRequestDetails = requestVerification(delegateExecution);
+
+ final String serviceInstanceId = String.valueOf(delegateExecution.getVariable(SERVICE_INSTANCE_ID));
+ final String serviceType = bpmnRequestDetails.getRequestParameters().getSubscriptionServiceType();
+ final String globalSubscriberId = bpmnRequestDetails.getSubscriberInfo().getGlobalSubscriberId();
+
+ final String modelId = bpmnRequestDetails.getModelInfo().getModelUuid();
+
+ if (PNF_RESOURCE.equalsIgnoreCase(serviceType)) {
+ getAndSetServiceInstance(serviceInstanceId, serviceType, globalSubscriberId, modelId);
+ }
+
+ // TODO : handling for vnf
+
+ logger.trace("Completed updating request for ServiceLevelUpgrade.");
+ }
+
+ private void getAndSetServiceInstance(final String serviceInstanceId, final String serviceType,
+ final String globalSubscriberId, String modelVersionId) {
+
+ AAIRestClientI restClient = new AAIRestClientImpl();
+
+ Optional<ServiceInstance> optionalSi =
+ restClient.getServiceInstanceById(serviceInstanceId, serviceType, globalSubscriberId);
+
+ if (!optionalSi.isPresent()) {
+ // throwExceptionWithWarn(delegateExecution, "Unable to find the service instance: " + serviceInstanceId);
+ }
+
+ ServiceInstance serviceInstance = optionalSi.get();
+
+ serviceInstance.setModelVersionId(modelVersionId);
+
+ restClient.updateServiceInstance(serviceInstanceId, serviceType, globalSubscriberId, serviceInstance);
+
+ }
+
+ private RequestDetails requestVerification(DelegateExecution delegateExecution) throws IOException {
+ RequestDetails bpmnRequestDetails = mapper.readValue(
+ JsonUtils.getJsonValue(String.valueOf(delegateExecution.getVariable(BPMN_REQUEST)), "requestDetails"),
+ RequestDetails.class);
+
+ throwIfNull(delegateExecution, bpmnRequestDetails.getModelInfo(), SERVICE_MODEL_INFO);
+ throwIfNull(delegateExecution, bpmnRequestDetails.getRequestInfo(), "RequestInfo");
+ throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters(), "RequestParameters");
+ throwIfNull(delegateExecution, bpmnRequestDetails.getRequestParameters().getUserParams(), "UserParams");
+
+ return bpmnRequestDetails;
+ }
+
+ private void throwIfNull(DelegateExecution delegateExecution, Object obj, String param) {
+ if (obj == null) {
+ throwExceptionWithWarn(delegateExecution,
+ "Unable to find the parameter: " + param + " in the execution context");
+ }
+ }
+
+ private void throwExceptionWithWarn(DelegateExecution delegateExecution, String exceptionMsg) {
+ logger.warn(exceptionMsg);
+ exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, exceptionMsg);
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java
index a99ee7d2df..0b1c5b0f5e 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelPreparationTest.java
@@ -20,6 +20,13 @@
package org.onap.so.bpmn.infrastructure.service.level;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.when;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
@@ -27,86 +34,79 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Spy;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelConstants;
import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelPreparation;
import org.onap.so.client.exception.ExceptionBuilder;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.onap.so.bpmn.infrastructure.service.level.AbstractServiceLevelPreparable.RESOURCE_TYPE;
-import static org.onap.so.bpmn.infrastructure.service.level.AbstractServiceLevelPreparable.WORKFLOW_TO_INVOKE;
-
+import org.onap.so.db.catalog.beans.Workflow;
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {ServiceLevelPreparation.class, ExceptionBuilder.class})
-public class ServiceLevelPreparationTest {
+public class ServiceLevelPreparationTest extends BaseTaskTest {
private static final String TEST_PNF_SCOPE = "pnf";
private static final String TEST_PROCESS_KEY = "testProcessKey";
private static final String PROCESS_KEY_VALUE = "testProcessKeyValue";
- private static final List<String> PNF_HEALTH_CHECK_PARAMS = Arrays.asList("SERVICE_MODEL_INFO",
- "SERVICE_INSTANCE_NAME", "PNF_CORRELATION_ID", "MODEL_UUID", "PNF_UUID", "PRC_BLUEPRINT_NAME",
- "PRC_BLUEPRINT_VERSION", "PRC_CUSTOMIZATION_UUID", "RESOURCE_CUSTOMIZATION_UUID_PARAM", "PRC_INSTANCE_NAME",
- "PRC_CONTROLLER_ACTOR", "REQUEST_PAYLOAD");
- private Map<String, String> pnfHealthCheckTestParams = new HashMap<>();
+ private static final String BPMN_REQUEST = "bpmnRequest";
+ private static final String RESOURCE_TYPE = "resourceType";
+ private static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
+ private static final String PNF_NAME = "pnfName";
+ private static final String HEALTH_CHECK_OPERATION = "ResourceHealthCheck";
+ private static final String PNF_HEALTH_CHECK_WORKFLOW = "PNFHealthCheck";
+ private static final Map<String, List<String>> HEALTH_CHECK_PARAMS_MAP = Map.of(TEST_PNF_SCOPE,
+ Arrays.asList(SERVICE_INSTANCE_ID, RESOURCE_TYPE, BPMN_REQUEST, PNF_NAME), "vnf", Collections.emptyList());
- @Autowired
- private ServiceLevelPreparation serviceLevelPrepare;
-
- @Autowired
- private ExceptionBuilder exceptionBuilder;
+ private List<Workflow> workflowList = new ArrayList<>();
@Rule
public ExpectedException thrown = ExpectedException.none();
+ @InjectMocks
+ private ServiceLevelPreparation serviceLevelPrepare;
+
+ @InjectMocks
+ @Spy
+ private ExceptionBuilder exceptionBuilder;
+
private DelegateExecution execution = new DelegateExecutionFake();
private DelegateExecution invalidExecution = new DelegateExecutionFake();
@Before
public void setUpPnfUpgradeTest() {
- pnfHealthCheckTestParams.put("TEST_SERVICE_MODEL_INFO", "d4c6855e-3be2-5dtu-9390-c999a38829bc");
- pnfHealthCheckTestParams.put("TEST_SERVICE_INSTANCE_NAME", "test_service_id");
- pnfHealthCheckTestParams.put("TEST_PNF_CORRELATION_ID", "pnfCorrelationId");
- pnfHealthCheckTestParams.put("TEST_MODEL_UUID", "6bc0b04d-1873-4721-b53d-6615225b2a28");
- pnfHealthCheckTestParams.put("TEST_PNF_UUID", "c93g70d9-8de3-57f1-7de1-f5690ac2b005");
- pnfHealthCheckTestParams.put("TEST_PRC_BLUEPRINT_NAME", "serviceUpgrade");
- pnfHealthCheckTestParams.put("TEST_PRC_BLUEPRINT_VERSION", "1.0.2");
- pnfHealthCheckTestParams.put("TEST_PRC_CUSTOMIZATION_UUID", "PRC_customizationUuid");
- pnfHealthCheckTestParams.put("TEST_RESOURCE_CUSTOMIZATION_UUID_PARAM", "9acb3a83-8a52-412c-9a45-901764938144");
- pnfHealthCheckTestParams.put("TEST_PRC_INSTANCE_NAME", "Demo_pnf");
- pnfHealthCheckTestParams.put("TEST_PRC_CONTROLLER_ACTOR", "cds");
- pnfHealthCheckTestParams.put("TEST_REQUEST_PAYLOAD", "test_payload");
-
- for (String param : PNF_HEALTH_CHECK_PARAMS) {
- execution.setVariable(param, pnfHealthCheckTestParams.get("TEST_" + param));
- }
execution.setVariable(RESOURCE_TYPE, TEST_PNF_SCOPE);
execution.setVariable(TEST_PROCESS_KEY, PROCESS_KEY_VALUE);
+ execution.setVariable(BPMN_REQUEST, "bpmnRequestValue");
+ execution.setVariable(SERVICE_INSTANCE_ID, "serviceInstanceIdValue");
+ execution.setVariable(PNF_NAME, "PnfDemo");
invalidExecution.setVariables(execution.getVariables());
+
+ Workflow pnfWorkflow = new Workflow();
+ pnfWorkflow.setName(PNF_HEALTH_CHECK_WORKFLOW);
+ pnfWorkflow.setOperationName(HEALTH_CHECK_OPERATION);
+ pnfWorkflow.setResourceTarget(TEST_PNF_SCOPE);
+ workflowList.add(pnfWorkflow);
+
+ when(catalogDbClient.findWorkflowByOperationName(HEALTH_CHECK_OPERATION)).thenReturn(workflowList);
}
@Test
public void executePnfUpgradeSuccessTest() throws Exception {
serviceLevelPrepare.execute(execution);
// Expect the pnf health check workflow to be set in to execution if validation is successful
- assertThat(String.valueOf(execution.getVariable(WORKFLOW_TO_INVOKE))).isEqualTo("GenericPnfHealthCheck");
+ assertThat(String.valueOf(execution.getVariable(ServiceLevelConstants.HEALTH_CHECK_WORKFLOW_TO_INVOKE)))
+ .isEqualTo("PNFHealthCheck");
}
@Test
public void validateFailureParamsForPnfTest() throws Exception {
- invalidExecution.removeVariable("PNF_UUID");
- invalidExecution.setVariable("PRC_BLUEPRINT_NAME", null);
+ invalidExecution.removeVariable(BPMN_REQUEST);
// BPMN exception is thrown in case of validation failure or invalid execution
thrown.expect(BpmnError.class);
- serviceLevelPrepare.validateParamsWithScope(invalidExecution, TEST_PNF_SCOPE, PNF_HEALTH_CHECK_PARAMS);
+ serviceLevelPrepare.validateParamsWithScope(invalidExecution, TEST_PNF_SCOPE,
+ HEALTH_CHECK_PARAMS_MAP.get(TEST_PNF_SCOPE));
}
@Test
@@ -125,6 +125,32 @@ public class ServiceLevelPreparationTest {
}
+ @Test
+ public void validateDefaultWorkflowIsSetWithoutDBData() throws Exception {
+ // Mock empty workflow list in db response
+ when(catalogDbClient.findWorkflowByOperationName(HEALTH_CHECK_OPERATION)).thenReturn(new ArrayList<Workflow>());
+ serviceLevelPrepare.execute(execution);
+ // Expect default workflow gets assigned when workflow name not found in db.
+ assertThat(String.valueOf(execution.getVariable(ServiceLevelConstants.HEALTH_CHECK_WORKFLOW_TO_INVOKE)))
+ .isEqualTo(ServiceLevelConstants.DEFAULT_HEALTH_CHECK_WORKFLOWS.get(TEST_PNF_SCOPE));
+ }
+
+ @Test
+ public void validateWorkflowSetFromDb() throws Exception {
+ Workflow vnfWorkflow = new Workflow();
+ vnfWorkflow.setName("VNFHealthCheck");
+ vnfWorkflow.setOperationName(HEALTH_CHECK_OPERATION);
+ vnfWorkflow.setResourceTarget("vnf");
+ workflowList.add(vnfWorkflow);
+ // Mock db response with multiple worklfows mapped with same operation name
+ when(catalogDbClient.findWorkflowByOperationName(HEALTH_CHECK_OPERATION)).thenReturn(workflowList);
+ serviceLevelPrepare.execute(execution);
+
+ // Expect right workflow gets assigned from db based on the controller scope.
+ assertThat(String.valueOf(execution.getVariable(ServiceLevelConstants.HEALTH_CHECK_WORKFLOW_TO_INVOKE)))
+ .isEqualTo(PNF_HEALTH_CHECK_WORKFLOW);
+ }
+
}