diff options
Diffstat (limited to 'bpmn')
25 files changed, 934 insertions, 497 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy index 4eb9eedad5..c91316ee5c 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy @@ -50,7 +50,7 @@ import org.onap.so.db.catalog.beans.HomingInstance import org.slf4j.Logger import org.slf4j.LoggerFactory import com.google.gson.JsonObject - +import com.google.gson.JsonParser import com.fasterxml.jackson.databind.ObjectMapper class OofUtils { @@ -596,6 +596,7 @@ String correlator = requestId String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator ObjectMapper objectMapper = new ObjectMapper(); String profileJson = objectMapper.writeValueAsString(profileInfo); +JsonParser parser = new JsonParser() //Prepare requestInfo object JsonObject requestInfo = new JsonObject() @@ -615,9 +616,11 @@ nsstInfo.addProperty("name", name) JsonObject json = new JsonObject() json.add("requestInfo", requestInfo) json.add("NSSTInfo", nsstInfo) -json.addProperty("sliceProfile", profileJson) +json.add("sliceProfile", (JsonObject) parser.parse(profileJson)) + return json.toString() } + /** * Method to create NSI/NSSI termination request * (OOF response will be synchronous in G-Release) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy index 23dfdce753..4e8be5d6e5 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy @@ -144,7 +144,7 @@ class RequestDBUtil { <ns:initResourceOperationStatus xmlns:ns="http://org.onap.so/requestsdb"> <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId> <operationId>${MsoUtils.xmlEscape(operationId)}</operationId> - <operationType>${MsoUtils.xmlEscape(operType)}</operationType> + <operType>${MsoUtils.xmlEscape(operType)}</operType> <resourceTemplateUUIDs>${MsoUtils.xmlEscape(resourceTemplateUUID)}</resourceTemplateUUIDs> </ns:initResourceOperationStatus> </soapenv:Body> @@ -192,8 +192,9 @@ class RequestDBUtil { <ns:updateResourceOperationStatus xmlns:ns="http://org.onap.so/requestsdb"> <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId> <operationId>${MsoUtils.xmlEscape(operationId)}</operationId> - <resourceTemplateUUIDs>${MsoUtils.xmlEscape(resourceTemplateUUID)}</resourceTemplateUUIDs> - <operationType>${MsoUtils.xmlEscape(operType)}</operationType> + <resourceTemplateUUID>${MsoUtils.xmlEscape(resourceTemplateUUID)}</resourceTemplateUUID> + <operType>${MsoUtils.xmlEscape(operType)}</operType> + <resourceInstanceID>${MsoUtils.xmlEscape(resourceInstanceID)}</resourceInstanceID> <jobId>${MsoUtils.xmlEscape(jobId)}</jobId> <status>${MsoUtils.xmlEscape(status)}</status> <progress>${MsoUtils.xmlEscape(progress)}</progress> 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 146889351a..522aec7931 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 @@ -204,6 +204,7 @@ class SniroHomingV1 extends AbstractServiceTaskProcessor{ if(inventoryType.equalsIgnoreCase("service")){ VnfResource vnf = new VnfResource() vnf.setVnfHostname(assignmentMap.get("vnfHostName")) + vnf.setResourceId(assignmentMap.get("vnfId")) resource.getHomingSolution().setVnf(vnf) resource.getHomingSolution().setServiceInstanceId(placement.getString("serviceInstanceId")) } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java index ea7de687ee..c02afc3327 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Copyright (C) 2020 Nokia. + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -26,6 +28,7 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; import javax.annotation.PostConstruct; +import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.listener.ListenerRunner; @@ -49,17 +52,21 @@ public class FlowManipulatorListenerRunner extends ListenerRunner { } public void modifyFlows(List<ExecuteBuildingBlock> flowsToExecute, BuildingBlockExecution execution) { + int sequenceBeforeFlowManipulator; + do { + sequenceBeforeFlowManipulator = execution.getVariable(BBConstants.G_CURRENT_SEQUENCE); + ExecuteBuildingBlock currentBB = flowsToExecute.get(execution.getCurrentSequence()); + List<FlowManipulator> filtered = filterListeners(flowManipulators, + (item -> item.shouldRunFor(currentBB.getBuildingBlock().getBpmnFlowName(), + execution.getCurrentSequence() == 0, execution))); - ExecuteBuildingBlock currentBB = flowsToExecute.get(execution.getCurrentSequence()); - List<FlowManipulator> filtered = filterListeners(flowManipulators, - (item -> item.shouldRunFor(currentBB.getBuildingBlock().getBpmnFlowName(), - execution.getCurrentSequence() == 0, execution))); - - logger.info("Running flow manipulators:\n{}", - filtered.stream().map(item -> item.getClass().getName()).collect(Collectors.joining("\n"))); - filtered.forEach(item -> item.run(flowsToExecute, currentBB, execution)); - + logger.info("Running flow manipulators:\n{}", + filtered.stream().map(item -> item.getClass().getName()).collect(Collectors.joining("\n"))); + filtered.forEach(item -> item.run(flowsToExecute, currentBB, execution)); + } while (isBuildingBlockSkipped(sequenceBeforeFlowManipulator, execution)); } - + private boolean isBuildingBlockSkipped(int sequenceBeforeFlowManipulator, BuildingBlockExecution execution) { + return sequenceBeforeFlowManipulator != (int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE); + } } 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 8923051f84..2f6713dcd1 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 @@ -1622,6 +1622,7 @@ public class BBInputSetup implements JavaDelegate { parameter.setInstanceName(vfModules.getInstanceName()); parameter.setInstanceParams(vfModules.getInstanceParams()); this.populateVfModule(parameter); + gBB.getRequestContext().setIsHelm(parameter.getIsHelm()); } } else if (bbName.contains(NETWORK)) { networks = findNetworksByKey(key, resources); @@ -1928,7 +1929,7 @@ public class BBInputSetup implements JavaDelegate { Optional<Relationships> relationshipsOp = aaiGenericVnfWrapper.getRelationships(); if (relationshipsOp.isPresent()) { Relationships relationships = relationshipsOp.get(); - this.mapPlatform(relationships.getByType(Types.PLATFORM), genericVnf); + this.mapPlatform(relationships.getByType(Types.PLATFORM, uri -> uri.nodesOnly(true)), genericVnf); this.mapLineOfBusiness(relationships.getByType(Types.LINE_OF_BUSINESS), genericVnf); genericVnf.getVolumeGroups().addAll(mapVolumeGroups(relationships.getByType(Types.VOLUME_GROUP))); genericVnf.getInstanceGroups().addAll(mapInstanceGroups(relationships.getByType(Types.INSTANCE_GROUP))); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java index 692d581b0d..98a14fc0e5 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java @@ -22,9 +22,10 @@ package org.onap.so.client.restproperties; import java.net.MalformedURLException; import java.net.URL; -import org.onap.so.bpmn.core.UrnPropertiesReader; import org.onap.aaiclient.client.aai.AAIProperties; import org.onap.aaiclient.client.aai.AAIVersion; +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.client.CacheProperties; import org.springframework.stereotype.Component; @Component @@ -33,6 +34,11 @@ public class AAIPropertiesImpl implements AAIProperties { public static final String MSO_MSO_KEY = "mso.msoKey"; public static final String AAI_AUTH = "aai.auth"; public static final String AAI_ENDPOINT = "aai.endpoint"; + public static final String AAI_READ_TIMEOUT = "aai.readTimeout"; + public static final String AAI_ENABLE_CACHING = "aai.caching.enable"; + public static final String AAI_CACHE_MAX_AGE = "aai.caching.maxAge"; + + private UrnPropertiesReader reader; @Override public URL getEndpoint() throws MalformedURLException { @@ -58,4 +64,25 @@ public class AAIPropertiesImpl implements AAIProperties { public String getKey() { return UrnPropertiesReader.getVariable(MSO_MSO_KEY); } + + @Override + public Long getReadTimeout() { + return Long.valueOf(reader.getVariable(AAI_READ_TIMEOUT, "60000")); + } + + @Override + public boolean isCachingEnabled() { + return Boolean.parseBoolean(reader.getVariable(AAI_ENABLE_CACHING, "false")); + } + + @Override + public CacheProperties getCacheProperties() { + return new AAICacheProperties() { + @Override + public Long getMaxAge() { + return Long.valueOf(reader.getVariable(AAI_CACHE_MAX_AGE, "60000")); + } + }; + } + } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Resource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Resource.java index 57b8c1387d..2a84fccca0 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Resource.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Resource.java @@ -81,6 +81,7 @@ public abstract class Resource extends JsonWrapper implements Serializable { return homingSolution; } + @Deprecated public void setHomingSolution(HomingSolution homingSolution) { this.homingSolution = homingSolution; } diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn index 9e2c0db6ea..a32e9e8f62 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateVfModuleBB.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.0"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1"> <bpmn:process id="CreateVfModuleBB" name="CreateVfModuleBB" isExecutable="true"> <bpmn:startEvent id="CreateVfModuleBB_Start"> <bpmn:outgoing>SequenceFlow_1xr6chl</bpmn:outgoing> @@ -46,7 +46,8 @@ <bpmn:sequenceFlow id="SequenceFlow_0rds4rj" sourceRef="UpdateVfModuleHeatStackId" targetRef="UpdateVfModuleStatus" /> <bpmn:sequenceFlow id="SequenceFlow_1vbwdaw" sourceRef="UpdateVfModuleStatus" targetRef="CreateVfModuleBB_End" /> <bpmn:serviceTask id="CreateNetworkPolicies" name="AAI Create (network policies)" camunda:expression="${AAICreateTasks.createNetworkPolicies(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_1yn8o6d</bpmn:incoming> + <bpmn:incoming>Flow_10aq7a8</bpmn:incoming> + <bpmn:incoming>Flow_1il4743</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0xqhep5</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0xqhep5" sourceRef="CreateNetworkPolicies" targetRef="UpdateVnfIpv4OamAddress" /> @@ -66,16 +67,14 @@ </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_15do1tu" sourceRef="UpdateVfModuleContrailServiceInstanceFqdn" targetRef="UpdateVfModuleHeatStackId" /> <bpmn:serviceTask id="ServiceTask_01zrt6x" name=" Create Cloud Variable " camunda:expression="${CreateVFModule.createInventoryVariable(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_1mg8eym</bpmn:incoming> <bpmn:incoming>SequenceFlow_0uetprw</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1io8r33</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_1io8r33" sourceRef="ServiceTask_01zrt6x" targetRef="ServiceTask_00d84m7" /> <bpmn:serviceTask id="ServiceTask_00d84m7" name=" AAI Create (inventory) " camunda:type="external" camunda:topic="InventoryCreate"> <bpmn:incoming>SequenceFlow_1io8r33</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1yn8o6d</bpmn:outgoing> + <bpmn:outgoing>Flow_10aq7a8</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:sequenceFlow id="SequenceFlow_1yn8o6d" sourceRef="ServiceTask_00d84m7" targetRef="CreateNetworkPolicies" /> <bpmn:exclusiveGateway id="CheckIfIsHelm" name="Check If Is Helm"> <bpmn:incoming>SequenceFlow_1ig2ix4</bpmn:incoming> <bpmn:outgoing>YesHelm</bpmn:outgoing> @@ -83,12 +82,11 @@ </bpmn:exclusiveGateway> <bpmn:serviceTask id="CnfAdapter" name="Cnf Adapter" camunda:expression="${CnfAdapterCreateTasks.createInstance(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn:incoming>YesHelm</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1mg8eym</bpmn:outgoing> + <bpmn:outgoing>Flow_1il4743</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="YesHelm" name="Yes Helm" sourceRef="CheckIfIsHelm" targetRef="CnfAdapter"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isHelm")}</bpmn:conditionExpression> </bpmn:sequenceFlow> - <bpmn:sequenceFlow id="SequenceFlow_1mg8eym" sourceRef="CnfAdapter" targetRef="ServiceTask_01zrt6x" /> <bpmn:sequenceFlow id="SequenceFlow_1ig2ix4" sourceRef="QueryVfModule" targetRef="CheckIfIsHelm" /> <bpmn:sequenceFlow id="NoHelm" name="No Helm" sourceRef="CheckIfIsHelm" targetRef="CreateVfModule" /> <bpmn:sequenceFlow id="SequenceFlow_0dehck5" sourceRef="CreateVfModule" targetRef="VnfAdapter" /> @@ -108,93 +106,61 @@ <bpmn:sequenceFlow id="Flow_1sqy91r" sourceRef="Event_1pengt4" targetRef="Activity_1p8hxyt" /> <bpmn:sequenceFlow id="Flow_03q6ty9" sourceRef="Activity_1p8hxyt" targetRef="Event_108oetk" /> </bpmn:subProcess> + <bpmn:sequenceFlow id="Flow_10aq7a8" sourceRef="ServiceTask_00d84m7" targetRef="CreateNetworkPolicies" /> + <bpmn:sequenceFlow id="Flow_1il4743" sourceRef="CnfAdapter" targetRef="CreateNetworkPolicies" /> </bpmn:process> <bpmn:error id="Error_0t7oivz" name="AAIInventoryFailure" errorCode="AAIInventoryFailure" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateVfModuleBB"> - <bpmndi:BPMNShape id="StartEvent_0kxwniy_di" bpmnElement="CreateVfModuleBB_Start"> - <dc:Bounds x="156" y="88" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="77" y="124" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_13t22km_di" bpmnElement="QueryVfModule"> - <dc:Bounds x="513" y="66" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1xr6chl_di" bpmnElement="SequenceFlow_1xr6chl"> - <di:waypoint x="192" y="106" /> - <di:waypoint x="313" y="106" /> + <bpmndi:BPMNEdge id="SequenceFlow_0uetprw_di" bpmnElement="SequenceFlow_0uetprw"> + <di:waypoint x="1009" y="146" /> + <di:waypoint x="1009" y="326" /> <bpmndi:BPMNLabel> - <dc:Bounds x="156" y="91" width="0" height="0" /> + <dc:Bounds x="1024" y="228" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="EndEvent_0qdq7wj_di" bpmnElement="CreateVfModuleBB_End"> - <dc:Bounds x="1300" y="450" width="36" height="36" /> + <bpmndi:BPMNEdge id="SequenceFlow_0dehck5_di" bpmnElement="SequenceFlow_0dehck5"> + <di:waypoint x="894" y="106" /> + <di:waypoint x="959" y="106" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1176" y="446" width="90" height="0" /> + <dc:Bounds x="926.5" y="85" width="0" height="12" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_1dgenhy_di" bpmnElement="CreateVfModule"> - <dc:Bounds x="794" y="66" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1s4rpyp_di" bpmnElement="SequenceFlow_1s4rpyp"> - <di:waypoint x="413" y="106" /> - <di:waypoint x="513" y="106" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1g7zahc_di" bpmnElement="NoHelm"> + <di:waypoint x="721" y="106" /> + <di:waypoint x="794" y="106" /> <bpmndi:BPMNLabel> - <dc:Bounds x="321" y="91" width="90" height="0" /> + <dc:Bounds x="736" y="85" width="44" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_1frb5h2_di" bpmnElement="QueryVnf"> - <dc:Bounds x="313" y="66" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="CallActivity_1i1pfzb_di" bpmnElement="VnfAdapter"> - <dc:Bounds x="959" y="66" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_0fpfn71_di" bpmnElement="UpdateVfModuleStatus"> - <dc:Bounds x="1124" y="428" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_04k1b85_di" bpmnElement="UpdateVfModuleHeatStackId"> - <dc:Bounds x="959" y="428" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0rds4rj_di" bpmnElement="SequenceFlow_0rds4rj"> - <di:waypoint x="1059" y="468" /> - <di:waypoint x="1124" y="468" /> + <bpmndi:BPMNEdge id="SequenceFlow_1ig2ix4_di" bpmnElement="SequenceFlow_1ig2ix4"> + <di:waypoint x="613" y="106" /> + <di:waypoint x="671" y="106" /> <bpmndi:BPMNLabel> - <dc:Bounds x="950" y="409" width="90" height="0" /> + <dc:Bounds x="652" y="85" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1vbwdaw_di" bpmnElement="SequenceFlow_1vbwdaw"> - <di:waypoint x="1224" y="468" /> - <di:waypoint x="1265" y="468" /> - <di:waypoint x="1265" y="468" /> - <di:waypoint x="1300" y="468" /> + <bpmndi:BPMNEdge id="SequenceFlow_0q1janp_di" bpmnElement="YesHelm"> + <di:waypoint x="696" y="131" /> + <di:waypoint x="696" y="210" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1138" y="424" width="90" height="0" /> + <dc:Bounds x="688" y="177" width="47" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_1v8zx4s_di" bpmnElement="CreateNetworkPolicies"> - <dc:Bounds x="324" y="428" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0xqhep5_di" bpmnElement="SequenceFlow_0xqhep5"> - <di:waypoint x="424" y="468" /> - <di:waypoint x="477" y="468" /> + <bpmndi:BPMNEdge id="SequenceFlow_1io8r33_di" bpmnElement="SequenceFlow_1io8r33"> + <di:waypoint x="959" y="366" /> + <di:waypoint x="746" y="366" /> <bpmndi:BPMNLabel> - <dc:Bounds x="309" y="409" width="90" height="0" /> + <dc:Bounds x="569" y="297" width="90" height="20" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_015ayw5_di" bpmnElement="UpdateVnfIpv4OamAddress"> - <dc:Bounds x="477" y="428" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1yo6mvv_di" bpmnElement="SequenceFlow_1yo6mvv"> - <di:waypoint x="577" y="468" /> - <di:waypoint x="646" y="468" /> + <bpmndi:BPMNEdge id="SequenceFlow_15do1tu_di" bpmnElement="SequenceFlow_15do1tu"> + <di:waypoint x="894" y="468" /> + <di:waypoint x="959" y="468" /> <bpmndi:BPMNLabel> - <dc:Bounds x="470" y="409" width="90" height="0" /> + <dc:Bounds x="785" y="399" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_0mlfsc9_di" bpmnElement="UpdateVnfManagementV6Address"> - <dc:Bounds x="646" y="428" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1i03uy2_di" bpmnElement="SequenceFlow_1i03uy2"> <di:waypoint x="746" y="468" /> <di:waypoint x="794" y="468" /> @@ -202,93 +168,129 @@ <dc:Bounds x="628" y="409" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_0wctnhw_di" bpmnElement="UpdateVfModuleContrailServiceInstanceFqdn"> - <dc:Bounds x="794" y="428" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_15do1tu_di" bpmnElement="SequenceFlow_15do1tu"> - <di:waypoint x="894" y="468" /> - <di:waypoint x="959" y="468" /> + <bpmndi:BPMNEdge id="SequenceFlow_1yo6mvv_di" bpmnElement="SequenceFlow_1yo6mvv"> + <di:waypoint x="577" y="468" /> + <di:waypoint x="646" y="468" /> <bpmndi:BPMNLabel> - <dc:Bounds x="785" y="399" width="90" height="0" /> + <dc:Bounds x="470" y="409" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_01zrt6x_di" bpmnElement="ServiceTask_01zrt6x"> - <dc:Bounds x="665" y="326" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1io8r33_di" bpmnElement="SequenceFlow_1io8r33"> - <di:waypoint x="665" y="366" /> - <di:waypoint x="563" y="366" /> + <bpmndi:BPMNEdge id="SequenceFlow_0xqhep5_di" bpmnElement="SequenceFlow_0xqhep5"> + <di:waypoint x="424" y="468" /> + <di:waypoint x="477" y="468" /> <bpmndi:BPMNLabel> - <dc:Bounds x="569" y="297" width="90" height="20" /> + <dc:Bounds x="309" y="409" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_00d84m7_di" bpmnElement="ServiceTask_00d84m7"> - <dc:Bounds x="463" y="326" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1yn8o6d_di" bpmnElement="SequenceFlow_1yn8o6d"> - <di:waypoint x="463" y="366" /> - <di:waypoint x="255" y="366" /> - <di:waypoint x="255" y="463" /> - <di:waypoint x="324" y="463" /> + <bpmndi:BPMNEdge id="SequenceFlow_1vbwdaw_di" bpmnElement="SequenceFlow_1vbwdaw"> + <di:waypoint x="1224" y="468" /> + <di:waypoint x="1265" y="468" /> + <di:waypoint x="1265" y="468" /> + <di:waypoint x="1300" y="468" /> <bpmndi:BPMNLabel> - <dc:Bounds x="225" y="361" width="90" height="20" /> + <dc:Bounds x="1138" y="424" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ExclusiveGateway_1g3vemz_di" bpmnElement="CheckIfIsHelm" isMarkerVisible="true"> - <dc:Bounds x="690.2114427860697" y="81.35572139303483" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="673" y="48" width="84" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ServiceTask_0tag50w_di" bpmnElement="CnfAdapter"> - <dc:Bounds x="665" y="166" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_0q1janp_di" bpmnElement="YesHelm"> - <di:waypoint x="715" y="131" /> - <di:waypoint x="715" y="166" /> + <bpmndi:BPMNEdge id="SequenceFlow_0rds4rj_di" bpmnElement="SequenceFlow_0rds4rj"> + <di:waypoint x="1059" y="468" /> + <di:waypoint x="1124" y="468" /> <bpmndi:BPMNLabel> - <dc:Bounds x="730" y="136" width="0" height="12" /> + <dc:Bounds x="950" y="409" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1mg8eym_di" bpmnElement="SequenceFlow_1mg8eym"> - <di:waypoint x="715" y="246" /> - <di:waypoint x="715" y="326" /> + <bpmndi:BPMNEdge id="SequenceFlow_1s4rpyp_di" bpmnElement="SequenceFlow_1s4rpyp"> + <di:waypoint x="413" y="106" /> + <di:waypoint x="513" y="106" /> <bpmndi:BPMNLabel> - <dc:Bounds x="846" y="291.5" width="0" height="12" /> + <dc:Bounds x="321" y="91" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1ig2ix4_di" bpmnElement="SequenceFlow_1ig2ix4"> - <di:waypoint x="613" y="106" /> - <di:waypoint x="691" y="106" /> + <bpmndi:BPMNEdge id="SequenceFlow_1xr6chl_di" bpmnElement="SequenceFlow_1xr6chl"> + <di:waypoint x="192" y="106" /> + <di:waypoint x="313" y="106" /> <bpmndi:BPMNLabel> - <dc:Bounds x="652" y="85" width="0" height="12" /> + <dc:Bounds x="156" y="91" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_1g7zahc_di" bpmnElement="NoHelm"> - <di:waypoint x="740" y="106" /> - <di:waypoint x="794" y="106" /> + <bpmndi:BPMNEdge id="Flow_10aq7a8_di" bpmnElement="Flow_10aq7a8"> + <di:waypoint x="646" y="366" /> + <di:waypoint x="374" y="366" /> + <di:waypoint x="374" y="428" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1il4743_di" bpmnElement="Flow_1il4743"> + <di:waypoint x="646" y="250" /> + <di:waypoint x="200" y="250" /> + <di:waypoint x="200" y="468" /> + <di:waypoint x="324" y="468" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_0kxwniy_di" bpmnElement="CreateVfModuleBB_Start"> + <dc:Bounds x="156" y="88" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="767" y="85" width="0" height="12" /> + <dc:Bounds x="77" y="124" width="0" height="0" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0dehck5_di" bpmnElement="SequenceFlow_0dehck5"> - <di:waypoint x="894" y="106" /> - <di:waypoint x="959" y="106" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_13t22km_di" bpmnElement="QueryVfModule"> + <dc:Bounds x="513" y="66" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_0qdq7wj_di" bpmnElement="CreateVfModuleBB_End"> + <dc:Bounds x="1300" y="450" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="926.5" y="85" width="0" height="12" /> + <dc:Bounds x="1176" y="446" width="90" height="0" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0uetprw_di" bpmnElement="SequenceFlow_0uetprw"> - <di:waypoint x="1009" y="146" /> - <di:waypoint x="1009" y="366" /> - <di:waypoint x="765" y="366" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1dgenhy_di" bpmnElement="CreateVfModule"> + <dc:Bounds x="794" y="66" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1frb5h2_di" bpmnElement="QueryVnf"> + <dc:Bounds x="313" y="66" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_1i1pfzb_di" bpmnElement="VnfAdapter"> + <dc:Bounds x="959" y="66" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0fpfn71_di" bpmnElement="UpdateVfModuleStatus"> + <dc:Bounds x="1124" y="428" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_04k1b85_di" bpmnElement="UpdateVfModuleHeatStackId"> + <dc:Bounds x="959" y="428" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1v8zx4s_di" bpmnElement="CreateNetworkPolicies"> + <dc:Bounds x="324" y="428" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_015ayw5_di" bpmnElement="UpdateVnfIpv4OamAddress"> + <dc:Bounds x="477" y="428" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0mlfsc9_di" bpmnElement="UpdateVnfManagementV6Address"> + <dc:Bounds x="646" y="428" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0wctnhw_di" bpmnElement="UpdateVfModuleContrailServiceInstanceFqdn"> + <dc:Bounds x="794" y="428" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_01zrt6x_di" bpmnElement="ServiceTask_01zrt6x"> + <dc:Bounds x="959" y="326" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_00d84m7_di" bpmnElement="ServiceTask_00d84m7"> + <dc:Bounds x="646" y="326" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0tag50w_di" bpmnElement="CnfAdapter"> + <dc:Bounds x="646" y="210" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_1g3vemz_di" bpmnElement="CheckIfIsHelm" isMarkerVisible="true"> + <dc:Bounds x="671" y="81" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1024" y="228" width="0" height="12" /> + <dc:Bounds x="655" y="48" width="82" height="14" /> </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> + </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_10eqhmz_di" bpmnElement="Activity_10eqhmz" isExpanded="true"> <dc:Bounds x="240" y="590" width="340" height="180" /> </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="Flow_03q6ty9_di" bpmnElement="Flow_03q6ty9"> + <di:waypoint x="460" y="680" /> + <di:waypoint x="512" y="680" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="Flow_1sqy91r_di" bpmnElement="Flow_1sqy91r"> + <di:waypoint x="316" y="680" /> + <di:waypoint x="360" y="680" /> + </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="Event_108oetk_di" bpmnElement="Event_108oetk"> <dc:Bounds x="512" y="662" width="36" height="36" /> </bpmndi:BPMNShape> @@ -298,14 +300,6 @@ <bpmndi:BPMNShape id="Activity_1p8hxyt_di" bpmnElement="Activity_1p8hxyt"> <dc:Bounds x="360" y="640" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="Flow_1sqy91r_di" bpmnElement="Flow_1sqy91r"> - <di:waypoint x="316" y="680" /> - <di:waypoint x="360" y="680" /> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="Flow_03q6ty9_di" bpmnElement="Flow_03q6ty9"> - <di:waypoint x="460" y="680" /> - <di:waypoint x="512" y="680" /> - </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy index 9100f2773b..e2d9c16328 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy @@ -149,16 +149,17 @@ class AllocateSliceSubnet extends AbstractServiceTaskProcessor { def prepareInitOperationStatus = { DelegateExecution execution -> logger.debug(Prefix + "prepareInitOperationStatus Start") - String serviceId = execution.getVariable("dummyServiceId") + String modelUuid = execution.getVariable("modelUuid") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") - logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) + logger.debug("Generated new job for Service Instance serviceId:" + modelUuid + " jobId:" + jobId) ResourceOperationStatus initStatus = new ResourceOperationStatus() - initStatus.setServiceId(serviceId) - initStatus.setOperationId(jobId) - initStatus.setResourceTemplateUUID(nsiId) - initStatus.setOperType("Allocate") + initStatus.setServiceId(nsiId) // set nsiId to this field + initStatus.setOperationId(jobId) // set jobId to this field + initStatus.setResourceTemplateUUID(modelUuid) // set modelUuid to this field + initStatus.setOperType("ALLOCATE") + //initStatus.setResourceInstanceID() // set nssiId to this field requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) logger.debug(Prefix + "prepareInitOperationStatus Exit") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy index 4108ccecff..1d8de352fb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AnNssmfutils.groovy @@ -37,6 +37,7 @@ import java.sql.Timestamp import java.util.List import static org.apache.commons.lang3.StringUtils.isBlank import com.google.gson.JsonObject +import com.google.gson.JsonParser import com.fasterxml.jackson.databind.ObjectMapper import org.onap.aaiclient.client.aai.AAIObjectType import org.onap.aaiclient.client.aai.AAIResourcesClient @@ -48,7 +49,6 @@ import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.T import javax.ws.rs.NotFoundException import org.onap.so.beans.nsmf.AllocateTnNssi import org.onap.so.beans.nsmf.DeAllocateNssi -import org.onap.so.beans.nsmf.EsrInfo import org.onap.so.beans.nsmf.ServiceInfo import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.aai.domain.yang.ServiceInstance @@ -65,12 +65,11 @@ class AnNssmfUtils { JsonUtils jsonUtil = new JsonUtils() public String buildSelectRANNSSIRequest(String requestId, String messageType, String UUID,String invariantUUID, String name, Map<String, Object> profileInfo, List<String> nsstInfoList, JsonArray capabilitiesList, Boolean preferReuse){ - + JsonParser parser = new JsonParser() def transactionId = requestId logger.debug( "transactionId is: " + transactionId) String correlator = requestId String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator - ObjectMapper objectMapper = new ObjectMapper(); String profileJson = objectMapper.writeValueAsString(profileInfo); String nsstInfoListString = objectMapper.writeValueAsString(nsstInfoList); //Prepare requestInfo object @@ -91,8 +90,8 @@ class AnNssmfUtils { JsonObject json = new JsonObject() json.add("requestInfo", requestInfo) json.add("NSTInfo", ranNsstInfo) - json.addProperty("serviceProfile", profileJson) - json.addProperty("NSSTInfo", nsstInfoListString) + json.add("serviceProfile", (JsonObject) parser.parse(profileJson)) + //json.add("NSSTInfo", (JsonArray) parser.parse(nsstInfoListString)) json.add("subnetCapabilities", capabilitiesList) json.addProperty("preferReuse", preferReuse) @@ -100,29 +99,33 @@ class AnNssmfUtils { } public String buildCreateTNNSSMFSubnetCapabilityRequest() { - EsrInfo esrInfo = new EsrInfo() - esrInfo.setNetworkType("TN") - esrInfo.setVendor("ONAP") + JsonObject esrInfo = new JsonObject() + esrInfo.addProperty("networkType", "tn") + esrInfo.addProperty("vendor", "ONAP_internal") JsonArray subnetTypes = new JsonArray() subnetTypes.add("TN_FH") subnetTypes.add("TN_MH") JsonObject response = new JsonObject() - response.add("subnetCapabilityQuery", subnetTypes) - response.addProperty("esrInfo", objectMapper.writeValueAsString(esrInfo)) + JsonObject subnetTypesObj = new JsonObject() + subnetTypesObj.add("subnetTypes", subnetTypes) + response.add("subnetCapabilityQuery", subnetTypesObj) + response.add("esrInfo", esrInfo) return response.toString() } public String buildCreateANNFNSSMFSubnetCapabilityRequest() { - EsrInfo esrInfo = new EsrInfo() - esrInfo.setNetworkType("AN") - esrInfo.setVendor("ONAP") + JsonObject esrInfo = new JsonObject() + esrInfo.addProperty("networkType", "an") + esrInfo.addProperty("vendor", "ONAP_internal") JsonArray subnetTypes = new JsonArray() subnetTypes.add("AN_NF") JsonObject response = new JsonObject() - response.add("subnetCapabilityQuery", subnetTypes) - response.addProperty("esrInfo", objectMapper.writeValueAsString(esrInfo)) + JsonObject subnetTypesObj = new JsonObject() + subnetTypesObj.add("subnetTypes", subnetTypes) + response.add("subnetCapabilityQuery", subnetTypesObj) + response.add("esrInfo", esrInfo) return response.toString() } public void createDomainWiseSliceProfiles(List<String> ranConstituentSliceProfiles, DelegateExecution execution) { @@ -190,16 +193,19 @@ public void createSliceProfilesInAai(DelegateExecution execution) { ANNF_sliceProfileInstance.setServiceType(serviceType) String serviceStatus = "deactivated" ANNF_sliceProfileInstance.setOrchestrationStatus(serviceStatus) - String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "plmnIdList") + String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "pLMNIdList") ANNF_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid) String serviceRole = "slice-profile-instance" ANNF_sliceProfileInstance.setServiceRole(serviceRole) - List<String> snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class) + ArrayList<String> snssaiList = execution.getVariable("snssaiList") String snssai = snssaiList.get(0) ANNF_sliceProfileInstance.setEnvironmentContext(snssai) ANNF_sliceProfileInstance.setWorkloadContext("AN-NF") ANNF_sliceProfileInstance.setSliceProfiles(ANNF_SliceProfiles) - logger.debug("completed ANNF sliceprofileinstance build "+ ANNF_sliceProfileInstance.toString()) + String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "resourceSharingLevel") + ANNF_sliceProfileInstance.setServiceFunction(serviceFunctionAnnf) + logger.debug("completed ANNF sliceprofileinstance build : "+ ANNF_sliceProfileInstance.toString()) + //TNFH slice profile instance creation TNFH_sliceProfileInstance.setServiceInstanceId(TNFH_sliceProfileInstanceId) sliceInstanceName = "sliceprofile_"+TNFH_sliceProfileId @@ -207,13 +213,16 @@ public void createSliceProfilesInAai(DelegateExecution execution) { serviceType = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "sST") TNFH_sliceProfileInstance.setServiceType(serviceType) TNFH_sliceProfileInstance.setOrchestrationStatus(serviceStatus) - serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "plmnIdList") + serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "pLMNIdList") TNFH_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid) TNFH_sliceProfileInstance.setServiceRole(serviceRole) TNFH_sliceProfileInstance.setEnvironmentContext(snssai) TNFH_sliceProfileInstance.setWorkloadContext("TN-FH") TNFH_sliceProfileInstance.setSliceProfiles(TNFH_SliceProfiles) - logger.debug("completed TNFH sliceprofileinstance build "+TNFH_sliceProfileInstance) + String serviceFunctionTnFH = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "resourceSharingLevel") + TNFH_sliceProfileInstance.setServiceFunction(serviceFunctionTnFH) + logger.debug("completed TNFH sliceprofileinstance build : "+TNFH_sliceProfileInstance) + //TNMH slice profile instance creation TNMH_sliceProfileInstance.setServiceInstanceId(TNMH_sliceProfileInstanceId) sliceInstanceName = "sliceprofile_"+TNMH_sliceProfileId @@ -221,13 +230,16 @@ public void createSliceProfilesInAai(DelegateExecution execution) { serviceType = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "sST") TNMH_sliceProfileInstance.setServiceType(serviceType) TNMH_sliceProfileInstance.setOrchestrationStatus(serviceStatus) - serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "plmnIdList") + serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "pLMNIdList") TNMH_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid) TNMH_sliceProfileInstance.setServiceRole(serviceRole) TNMH_sliceProfileInstance.setEnvironmentContext(snssai) TNMH_sliceProfileInstance.setWorkloadContext("TN-MH") TNMH_sliceProfileInstance.setSliceProfiles(TNMH_SliceProfiles) - logger.debug("completed TNMH sliceprofileinstance build "+TNMH_sliceProfileInstance) + String serviceFunctionTnMH = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "resourceSharingLevel") + TNMH_sliceProfileInstance.setServiceFunction(serviceFunctionTnMH) + logger.debug("completed TNMH sliceprofileinstance build : "+TNMH_sliceProfileInstance) + String msg = "" try { @@ -261,12 +273,10 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe result.setJitter(profile.get("jitter")) result.setLatency(profile.get("latency")) result.setResourceSharingLevel(profile.get("resourceSharingLevel")) - result.setSNssai(profile.get("sNSSAI")) result.setUeMobilityLevel(profile.get("uEMobilityLevel")) result.setMaxNumberOfUEs(profile.get("maxNumberofUEs")) result.setActivityFactor(profile.get("activityFactor")) result.setCoverageAreaTAList(profile.get("coverageAreaTAList")) - result.setCsAvailability(profile.get("cSAvailabilityTarget")) result.setExpDataRateDL(profile.get("expDataRateDL")) result.setExpDataRateUL(profile.get("expDataRateUL")) result.setSurvivalTime(profile.get("survivalTime")) @@ -280,7 +290,6 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe result.setJitter(profile.get("jitter")) result.setLatency(profile.get("latency")) result.setResourceSharingLevel(profile.get("resourceSharingLevel")) - result.setSNssai(profile.get("sNSSAI")) result.setProfileId(execution.getVariable("TNFH_sliceProfileId")) break case "TN-MH": @@ -288,7 +297,6 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe result.setJitter(profile.get("jitter")) result.setLatency(profile.get("latency")) result.setResourceSharingLevel(profile.get("resourceSharingLevel")) - result.setSNssai(profile.get("sNSSAI")) result.setProfileId(execution.getVariable("TNMH_sliceProfileId")) break default: @@ -307,13 +315,13 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe String msg AAIResourcesClient client = new AAIResourcesClient() try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(instanceId).relationshipAPI()) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(instanceId)).relationshipAPI() client.create(uri, relationship) } catch (BpmnError e) { throw e } catch (Exception ex) { - msg = "Exception in CreateCommunicationService.createRelationShipInAAI. " + ex.getMessage() + msg = "Exception in AN NSSMF Utils : CreateRelationShipInAAI. " + ex.getMessage() logger.info(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } @@ -333,10 +341,9 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe } public String buildCreateNSSMFRequest(DelegateExecution execution, String domainType, String action) { - EsrInfo esrInfo = new EsrInfo() - esrInfo.setNetworkType("TN") - esrInfo.setVendor("ONAP") - String esrInfoString = objectMapper.writeValueAsString(esrInfo) + JsonObject esrInfo = new JsonObject() + esrInfo.addProperty("networkType", "tn") + esrInfo.addProperty("vendor", "ONAP_internal") JsonObject response = new JsonObject() JsonObject allocateTnNssi = new JsonObject() JsonObject serviceInfo = new JsonObject() @@ -404,7 +411,7 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId")) serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType")) - response.addProperty("esrInfo", esrInfoString) + response.add("esrInfo", esrInfo) response.add("serviceInfo", serviceInfo) response.add("allocateTnNssi", allocateTnNssi) return response.toString() @@ -429,9 +436,9 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe deAllocateNssi.addProperty("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId")) } - EsrInfo esrInfo = new EsrInfo() - esrInfo.setVendor("ONAP") - esrInfo.setNetworkType("TN") + JsonObject esrInfo = new JsonObject() + esrInfo.addProperty("networkType", "tn") + esrInfo.addProperty("vendor", "ONAP_internal") JsonObject serviceInfo = new JsonObject() serviceInfo.addProperty("serviceInvariantUuid", null) @@ -441,9 +448,9 @@ private SliceProfile createSliceProfile(String domainType, DelegateExecution exe JsonObject json = new JsonObject() json.add("deAllocateNssi", deAllocateNssi) - json.addProperty("esrInfo", objectMapper.writeValueAsString(esrInfo)) + json.add("esrInfo", esrInfo) json.add("serviceInfo", serviceInfo) return json.toString() } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy index 67845910eb..bb6fe212b3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy @@ -43,6 +43,7 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.db.request.beans.OperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory +import org.springframework.util.StringUtils import org.springframework.web.util.UriUtils import static org.apache.commons.lang3.StringUtils.isBlank @@ -317,14 +318,9 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { Map<String, ?> csInputMap = new HashMap<>() for (String csInput : csInputs) { - def value - if (jsonUtil.getJsonValue(csInput, "type") == "integer") { - value = jsonUtil.getJsonValue(csInput, "default") - csInputMap.put(jsonUtil.getJsonValue(csInput, "name"), isBlank(value) ? 0 : (value as Integer)) - } else if (jsonUtil.getJsonValue(csInput, "type") == "string") { - csInputMap.put(jsonUtil.getJsonValue(csInput, "name"), - jsonUtil.getJsonValue(csInput, "default")) - } + String key = jsonUtil.getJsonValue(csInput, "name") + def value = jsonUtil.getJsonValue(csInput, "default") + csInputMap.put(key, getDefaultPropertiesByType(value, key)) } csInputMap.put("expDataRateDL", expDataRateDL) csInputMap.put("expDataRateUL", expDataRateUL) @@ -336,6 +332,7 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { csInputMap.put("useInterval", useInterval) execution.setVariable("csInputMap", csInputMap) + logger.debug(Prefix + "csInputMap is = " + csInputMap.toString()) } catch (BpmnError e) { throw e } catch (Exception ex) { @@ -365,53 +362,45 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { Map<String, ?> csInputMap = execution.getVariable("csInputMap") as Map Map<String, ?> e2eInputMap = new HashMap<>() - String key - def value - for (String e2eInput in e2eInputs) { - key = jsonUtil.getJsonValue(e2eInput, "name") + String key = jsonUtil.getJsonValue(e2eInput, "name") String type = jsonUtil.getJsonValue(e2eInput, "type") - if (type == "integer") { - def temp - value = csInputMap.containsKey(key) ? csInputMap.getOrDefault(key, 0) : (isBlank(temp = jsonUtil.getJsonValue(e2eInput, "default")) ? 0 : temp) - - e2eInputMap.put(key, value as Integer) - } else if(type == "string") { - e2eInputMap.put(key, csInputMap.containsKey(key) - ? csInputMap.getOrDefault(key, null) : (jsonUtil.getJsonValue(e2eInput, "default"))) + def value + if (csInputMap.containsKey(key)) { + value = csInputMap.get(key) + } else { + value = jsonUtil.getJsonValue(e2eInput, "default") } + e2eInputMap.put(key, getDefaultPropertiesByType(value, type)) } //TODO temp solution e2eInputMap.put("sNSSAI", execution.getVariable("sNSSAI_id")) e2eInputMap.put("sST", execution.getVariable("csServiceType")) - Integer activityFactor = 60 + Integer activityFactor = Integer.parseInt(e2eInputMap.get("activityFactor").toString()) Integer random = new Random().nextInt(5) + 2 Integer dLThptPerUE = Integer.parseInt(csInputMap.get("expDataRateDL").toString()) Integer uLThptPerUE = Integer.parseInt(csInputMap.get("expDataRateUL").toString()) - Integer maxNumberofUEs = Integer.parseInt(csInputMap.get("maxNumberofUEs").toString()) + Integer maxNumberofUEs = Integer.parseInt(e2eInputMap.get("maxNumberofUEs").toString()) Integer dLThptPerSlice = dLThptPerUE * maxNumberofUEs * activityFactor * random Integer uLThptPerSlice = uLThptPerUE * maxNumberofUEs * activityFactor * random Integer maxNumberofConns = maxNumberofUEs * activityFactor * 3 e2eInputMap.put("jitter", 10) - e2eInputMap.put("activityFactor", activityFactor) - e2eInputMap.put("maxNumberofUEs", maxNumberofUEs) e2eInputMap.put("dLThptPerUE", dLThptPerUE) e2eInputMap.put("uLThptPerUE", uLThptPerUE) e2eInputMap.put("dLThptPerSlice", dLThptPerSlice) e2eInputMap.put("uLThptPerSlice", uLThptPerSlice) e2eInputMap.put("maxNumberofConns", maxNumberofConns) - e2eInputMap.put("coverageAreaTAList", csInputMap.get("coverageAreaList")) execution.setVariable("e2eInputMap", e2eInputMap) execution.setVariable("e2eServiceType", e2eServiceDecomposition.getServiceType()) execution.setVariable("e2eModelInvariantUuid", e2eServiceDecomposition.getModelInfo().getModelInvariantUuid()) execution.setVariable("e2eModelUuid", e2eServiceDecomposition.getModelInfo().getModelUuid()) - + logger.debug(Prefix + "e2eInputMap is = " + e2eInputMap.toString()) } catch (BpmnError e) { throw e } catch (Exception ex) { @@ -423,6 +412,25 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { logger.debug(Prefix + "generateE2EServiceProfile Exit") } + static def getDefaultPropertiesByType(def value, String type) { + + def defaultValue + switch (type) { + case "string": + defaultValue = "" + break + case "integer": + defaultValue = 0 + break + case "float": + defaultValue = 0.0 + break + default: + defaultValue = null + break + } + return StringUtils.isEmpty(value) ? defaultValue : value + } /** * call createE2EService get operation id, @@ -453,7 +461,7 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { } """ execution.setVariable("CSMF_NSMFRequest", payload.replaceAll("\\s+", "")) - + logger.debug(Prefix + "Sent to NSMF Request = " + payload) } catch (BpmnError e) { throw e } catch (Exception ex) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy index c136d52b13..e5d390e2aa 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy @@ -354,6 +354,8 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { nstInfo.setName(nstSolution.get("NSTName") as String) sliceTaskParams.setNSTInfo(nstInfo) + sliceTaskParams.setNstId(nstSolution.get("UUID") as String) + sliceTaskParams.setNstName(nstSolution.get("NSTName") as String) execution.setVariable("sliceTaskParams", sliceTaskParams) @@ -399,7 +401,10 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { OrchestrationTask orchestrationTask = objectMapper.readValue(response, OrchestrationTask.class) String paramJson = orchestrationTask.getParams() logger.debug("paramJson: " + paramJson) - SliceTaskParamsAdapter sliceTaskParams = new SliceTaskParamsAdapter() + + SliceTaskParamsAdapter sliceTaskParams = + execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter + sliceTaskParams.convertFromJson(paramJson) execution.setVariable("sliceTaskParams", sliceTaskParams) logger.debug("Finish processUserOptions") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy index fc14da3a7d..e1719aa5d6 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateAccessNSSI.groovy @@ -31,17 +31,16 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.db.request.beans.ResourceOperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory -import java.sql.Timestamp import java.util.List import static org.apache.commons.lang3.StringUtils.isBlank import com.google.gson.JsonObject import com.fasterxml.jackson.databind.ObjectMapper import com.google.gson.JsonArray +import com.google.gson.JsonParser import org.onap.aai.domain.yang.Relationship import org.onap.aaiclient.client.aai.AAIResourcesClient import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri import org.onap.so.beans.nsmf.AllocateTnNssi -import org.onap.so.beans.nsmf.EsrInfo import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.ServiceInstance @@ -99,8 +98,8 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { execution.setVariable("sliceProfile", sliceProfile) } String sliceProfileId = jsonUtil.getJsonValue(sliceProfile, "sliceProfileId") - def snssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "snssaiList")) - def plmnIdList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "plmnIdList")) + def snssaiList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "sNSSAI")) + def plmnIdList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "pLMNIdList")) def coverageAreaTAList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceProfile, "coverageAreaTAList")) if (isBlank(sliceProfileId) || (snssaiList.empty) || (plmnIdList.empty) @@ -185,7 +184,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { List<String> nsstInfoList = new ArrayList<>() for(ServiceProxy serviceProxy : serviceProxyList) { - String nsstModelUuid = serviceProxy.getModelInfo().getModelUuid() + String nsstModelUuid = serviceProxy.getSourceModelUuid() String nsstModelInvariantUuid = serviceProxy.getModelInfo().getModelInvariantUuid() String name = serviceProxy.getModelInfo().getModelName() String nsstServiceModelInfo = """{ @@ -203,7 +202,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { logger.info(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - execution.setVariable("ranNsstInfoList",nsstInfoList) + execution.setVariable("ranNsstInfoList", objectMapper.writeValueAsString(nsstInfoList)) execution.setVariable("ranModelVersion", ranModelVersion) execution.setVariable("ranModelName", ranModelName) execution.setVariable("currentIndex",currentIndex) @@ -255,7 +254,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) logger.debug( "get NSSI option OOF Url: " + urlString) - + JsonParser parser = new JsonParser() //build oof request body boolean ranNssiPreferReuse = execution.getVariable("ranNssiPreferReuse"); String requestId = execution.getVariable("msoRequestId") @@ -265,7 +264,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String modelInvariantUuid = execution.getVariable("modelInvariantUuid") String modelName = execution.getVariable("ranModelName") String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); - List<String> nsstInfoList = objectMapper.readValue(execution.getVariable("nsstInfoList"), List.class) + List<String> nsstInfoList = objectMapper.readValue(execution.getVariable("ranNsstInfoList"), List.class) JsonArray capabilitiesList = new JsonArray() String FHCapabilities = execution.getVariable("FHCapabilities") String MHCapabilities = execution.getVariable("MHCapabilities") @@ -274,11 +273,11 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { JsonObject MH = new JsonObject() JsonObject ANNF = new JsonObject() FH.addProperty("domainType", "TN_FH") - FH.addProperty("capabilityDetails", FHCapabilities) + FH.add("capabilityDetails", (JsonObject) parser.parse(FHCapabilities)) MH.addProperty("domainType", "TN_MH") - MH.addProperty("capabilityDetails", MHCapabilities) + MH.add("capabilityDetails", (JsonObject) parser.parse(MHCapabilities)) ANNF.addProperty("domainType", "AN_NF") - ANNF.addProperty("capabilityDetails", FHCapabilities) + ANNF.add("capabilityDetails", (JsonObject) parser.parse(ANNFCapabilities)) capabilitiesList.add(FH) capabilitiesList.add(MH) capabilitiesList.add(ANNF) @@ -302,13 +301,18 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String oofResponse = execution.getVariable("nssiSelection_asyncCallbackResponse") String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus") if(requestStatus.equals("completed")) { - List<String> solution = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(oofResponse, "solutions")) - boolean existingNSI = jsonUtil.getJsonValue(solution.get(0), "existingNSI") + String solutions = jsonUtil.getJsonValue(oofResponse, "solutions") + logger.debug("solutions value : "+solutions) + JsonParser parser = new JsonParser() + JsonArray solution = parser.parse(solutions) + JsonObject sol = solution.get(0) + boolean existingNSI = sol.get("existingNSI").getAsBoolean() + logger.debug("existingNSI value : "+existingNSI) if(existingNSI) { - def sharedNSISolution = jsonUtil.getJsonValue(solution.get(0), "sharedNSISolution") - execution.setVariable("sharedRanNSSISolution", sharedNSISolution) + JsonObject sharedNSISolution = sol.get("sharedNSISolution").getAsJsonObject() + execution.setVariable("sharedRanNSSISolution", sharedNSISolution.toString()) logger.debug("sharedRanNSSISolution from OOF "+sharedNSISolution) - String RANServiceInstanceId = jsonUtil.getJsonValue(solution.get(0), "sharedNSISolution.NSIId") + String RANServiceInstanceId = sharedNSISolution.get("NSIId").getAsString() execution.setVariable("RANServiceInstanceId", RANServiceInstanceId) ServiceInstance serviceInstance = new ServiceInstance(); serviceInstance.setInstanceId(RANServiceInstanceId); @@ -317,9 +321,10 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { execution.setVariable("ranNsstServiceDecomposition", serviceDecomposition) execution.setVariable("isRspRanNssi", true) }else { - def sliceProfiles = jsonUtil.getJsonValue(solution.get(0), "newNSISolution.sliceProfiles") - execution.setVariable("RanConstituentSliceProfiles", sliceProfiles) + JsonObject newNSISolution = sol.get("newNSISolution").getAsJsonObject() + JsonArray sliceProfiles = newNSISolution.get("slice_profiles").getAsJsonArray() logger.debug("RanConstituentSliceProfiles list from OOF "+sliceProfiles) + execution.setVariable("RanConstituentSliceProfiles", sliceProfiles.toString()) } }else { String statusMessage = jsonUtil.getJsonValue(oofResponse, "statusMessage") @@ -362,11 +367,11 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { def createModifyNssiQueryJobStatus = { DelegateExecution execution -> logger.debug(Prefix+"createModifyNssiQueryJobStatus method start") - EsrInfo esrInfo = new EsrInfo() - esrInfo.setNetworkType("AN") - esrInfo.setVendor("ONAP") - String esrInfoString = objectMapper.writeValueAsString(esrInfo) - execution.setVariable("esrInfo", esrInfoString) + JsonObject esrInfo = new JsonObject() + esrInfo.addProperty("networkType", "tn") + esrInfo.addProperty("vendor", "ONAP_internal") + + execution.setVariable("esrInfo", esrInfo.toString()) JsonObject serviceInfo = new JsonObject() serviceInfo.addProperty("nssiId", execution.getVariable("RANServiceInstanceId")) serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) @@ -491,12 +496,16 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String oofResponse = execution.getVariable("nfNssiSelection_asyncCallbackResponse") String requestStatus = jsonUtil.getJsonValue(oofResponse, "requestStatus") if(requestStatus.equals("completed")) { - List<String> solution = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(oofResponse, "solutions")) + String solutions = jsonUtil.getJsonValue(oofResponse, "solutions") + logger.debug("nssi solutions value : "+solutions) + JsonParser parser = new JsonParser() + JsonArray solution = parser.parse(solutions) if(solution.size()>=1) { - String ranNfNssiId = jsonUtil.getJsonValue(solution.get(0), "NSSIId") - String invariantUuid = jsonUtil.getJsonValue(solution.get(0), "invariantUUID") - String uuid = jsonUtil.getJsonValue(solution.get(0), "UUID") - String nssiName = jsonUtil.getJsonValue(solution.get(0), "NSSIName") + JsonObject sol = solution.get(0) + String ranNfNssiId = sol.get("NSSIId").getAsString() + String invariantUuid = sol.get("invariantUUID").getAsString() + String uuid = sol.get("UUID").getAsString() + String nssiName = sol.get("NSSIName").getAsString() execution.setVariable("RANNFServiceInstanceId", ranNfNssiId) execution.setVariable("RANNFInvariantUUID", invariantUuid) execution.setVariable("RANNFUUID", uuid) @@ -528,7 +537,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug(Prefix+"processRanNfModifyRsp method start") anNssmfUtils.processRanNfModifyRsp(execution) //create RAN NSSI - org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new ServiceInstance(); + org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new org.onap.aai.domain.yang.ServiceInstance(); //AN instance creation ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId")) String sliceInstanceName = execution.getVariable("servicename") @@ -593,8 +602,8 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { def updateAaiWithRANInstances = { DelegateExecution execution -> logger.debug(Prefix+"updateAaiWithRANInstances method start") //create RAN NSSI - org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new ServiceInstance(); - org.onap.aai.domain.yang.ServiceInstance ANNFServiceInstance = new ServiceInstance(); + org.onap.aai.domain.yang.ServiceInstance ANServiceInstance = new org.onap.aai.domain.yang.ServiceInstance(); + org.onap.aai.domain.yang.ServiceInstance ANNFServiceInstance = new org.onap.aai.domain.yang.ServiceInstance(); //AN instance creation ANServiceInstance.setServiceInstanceId(execution.getVariable("RANServiceInstanceId")) String sliceInstanceName = execution.getVariable("servicename") @@ -603,15 +612,16 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { ANServiceInstance.setServiceType(serviceType) String serviceStatus = "deactivated" ANServiceInstance.setOrchestrationStatus(serviceStatus) - String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "plmnIdList") + String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "pLMNIdList") ANServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid) String serviceRole = "nssi" ANServiceInstance.setServiceRole(serviceRole) - List<String> snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class) + List<String> snssaiList = execution.getVariable("snssaiList") String snssai = snssaiList.get(0) ANServiceInstance.setEnvironmentContext(snssai) ANServiceInstance.setWorkloadContext("AN") - + String serviceFunctionAn = jsonUtil.getJsonValue(execution.getVariable("sliceProfile"), "resourceSharingLevel") + ANServiceInstance.setServiceFunction(serviceFunctionAn) logger.debug("completed AN service instance build "+ ANServiceInstance.toString()) //create RAN NF NSSI ANNFServiceInstance.setServiceInstanceId(execution.getVariable("RANNFServiceInstanceId")) @@ -619,13 +629,15 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { ANNFServiceInstance.setServiceInstanceName(sliceInstanceName) ANNFServiceInstance.setServiceType(serviceType) ANNFServiceInstance.setOrchestrationStatus(serviceStatus) - serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "plmnIdList") + serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "pLMNIdList") ANNFServiceInstance.setServiceInstanceLocationId(serviceInstanceLocationid) ANNFServiceInstance.setServiceRole(serviceRole) - snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class) + snssaiList = execution.getVariable("snssaiList") snssai = snssaiList.get(0) ANNFServiceInstance.setEnvironmentContext(snssai) ANNFServiceInstance.setWorkloadContext("AN-NF") + String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "resourceSharingLevel") + ANNFServiceInstance.setServiceFunction(serviceFunctionAnnf) logger.debug("completed AN service instance build "+ ANNFServiceInstance.toString()) String msg = "" @@ -695,11 +707,10 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { } private void createTnAllocateNssiJobQuery(DelegateExecution execution, String domainType) { - EsrInfo esrInfo = new EsrInfo() - esrInfo.setNetworkType("TN") - esrInfo.setVendor("ONAP") - String esrInfoString = objectMapper.writeValueAsString(esrInfo) - execution.setVariable("esrInfo", esrInfoString) + JsonObject esrInfo = new JsonObject() + esrInfo.addProperty("networkType", "tn") + esrInfo.addProperty("vendor", "ONAP_internal") + execution.setVariable("esrInfo", esrInfo.toString()) JsonObject serviceInfo = new JsonObject() serviceInfo.addProperty("nssiId", null) serviceInfo.addProperty("nsiId", execution.getVariable("nsiId")) @@ -853,7 +864,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { updateStatus.setResourceTemplateUUID(nsiId) updateStatus.setResourceInstanceID(nssiId) updateStatus.setOperType("Allocate") - updateStatus.setProgress(100) + updateStatus.setProgress("100") updateStatus.setStatus("finished") requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus) @@ -875,7 +886,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { updateStatus.setResourceTemplateUUID(nsiId) updateStatus.setResourceInstanceID(nssiId) updateStatus.setOperType("Allocate") - updateStatus.setProgress(0) + updateStatus.setProgress("0") updateStatus.setStatus("failed") requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus) } @@ -883,8 +894,6 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { private String buildSdnrAllocateRequest(DelegateExecution execution, String action, String rpcName, String callbackUrl) { String requestId = execution.getVariable("msoRequestId") - Date date = new Date().getTime() - Timestamp time = new Timestamp(date) Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class) sliceProfile.put("sliceProfileId", execution.getVariable("ANNF_sliceProfileInstanceId")) sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSessions")) @@ -897,7 +906,7 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { JsonObject commonHeader = new JsonObject() JsonObject payload = new JsonObject() JsonObject payloadInput = new JsonObject() - commonHeader.addProperty("TimeStamp", time.toString()) + commonHeader.addProperty("TimeStamp",new Date(System.currentTimeMillis()).format("yyyy-MM-dd'T'HH:mm:ss.sss", TimeZone.getDefault())) commonHeader.addProperty("APIver", "1.0") commonHeader.addProperty("RequestID", requestId) commonHeader.addProperty("SubRequestID", "1") @@ -912,12 +921,12 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { payload.add("input", payloadInput) input.add("CommonHeader", commonHeader) input.addProperty("Action", action) - input.add("Payload", payload) + input.addProperty("Payload", payload.toString()) body.add("input", input) response.add("body", body) response.addProperty("version", "1.0") response.addProperty("rpc-name", rpcName) - response.addProperty("correlation-id", requestId+"-1") + response.addProperty("correlation-id", (requestId+"-1")) response.addProperty("type", "request") return response.toString() } @@ -979,8 +988,15 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { String DUEG_routeId = UUID.randomUUID().toString() execution.setVariable("tranportEp_ID_DUEG", DUEG_routeId) NetworkRoute DUEG_ep = new NetworkRoute() - DU_ep.setRouteId(DUEG_routeId) - DU_ep.setNextHop("Host3") + DUEG_ep.setRouteId(DUEG_routeId) + DUEG_ep.setFunction(function) + DUEG_ep.setRole(role) + DUEG_ep.setType(type) + DUEG_ep.setIpAddress("192.168.100.5") + DUEG_ep.setLogicalInterfaceId("1234") + DUEG_ep.setPrefixLength(prefixLength) + DUEG_ep.setAddressFamily(addressFamily) + DUEG_ep.setNextHop("Host3") //CUIN String CUIN_routeId = UUID.randomUUID().toString() execution.setVariable("tranportEp_ID_CUIN", CUIN_routeId) @@ -1005,9 +1021,9 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { logger.debug("creating DUIN endpoint . ID : "+DUIN_routeId+" node details : "+DU_ep.toString()) networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUIN_routeId) client.create(networkRouteUri, DU_ep) - logger.debug("creating DUEG endpoint . ID : "+DUEG_routeId+" node details : "+DU_ep.toString()) + logger.debug("creating DUEG endpoint . ID : "+DUEG_routeId+" node details : "+DUEG_ep.toString()) networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), DUEG_routeId) - client.create(networkRouteUri, DU_ep) + client.create(networkRouteUri, DUEG_ep) logger.debug("creating CUIN endpoint . ID : "+CUIN_routeId+" node details : "+CUIN_ep.toString()) networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), CUIN_routeId) client.create(networkRouteUri, CUIN_ep) @@ -1041,3 +1057,4 @@ class DoAllocateAccessNSSI extends AbstractServiceTaskProcessor { } } } + diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy index 1d7acd31c1..1f3cf6ed52 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy @@ -20,6 +20,11 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.beans.nsmf.ConnectionLink +import org.onap.so.beans.nsmf.EndPoint +import org.onap.so.beans.nsmf.NsiInfo +import org.onap.so.beans.nsmf.SliceProfileAdapter +import org.onap.so.beans.nsmf.TransportSliceNetwork import org.onap.so.beans.nsmf.oof.SubnetType import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import javax.ws.rs.NotFoundException @@ -36,15 +41,12 @@ import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder import org.onap.so.beans.nsmf.AllocateAnNssi import org.onap.so.beans.nsmf.AllocateCnNssi import org.onap.so.beans.nsmf.AllocateTnNssi -import org.onap.so.beans.nsmf.AnSliceProfile -import org.onap.so.beans.nsmf.CnSliceProfile import org.onap.so.beans.nsmf.EsrInfo import org.onap.so.beans.nsmf.NssiResponse import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest import org.onap.so.beans.nsmf.ServiceInfo import org.onap.so.beans.nsmf.SliceTaskInfo import org.onap.so.beans.nsmf.SliceTaskParamsAdapter -import org.onap.so.beans.nsmf.TnSliceProfile import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils import org.slf4j.Logger @@ -144,7 +146,10 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ String msg try { - AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sliceInstanceId)) + AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(sliceInstanceId)) client.create(nsiServiceUri, nsi) execution.setVariable("nsiServiceUri", nsiServiceUri) @@ -152,7 +157,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ } catch (BpmnError e) { throw e } catch (Exception ex) { - msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage() + msg = "Exception in DoAllocateNSIandNSSI.createNSIinAAI: " + ex.getMessage() logger.info(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } @@ -168,16 +173,30 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ */ void createRelationship(DelegateExecution execution) { //relation ship - String allottedResourceId = execution.getVariable("allottedResourceId") - SliceTaskParamsAdapter sliceParams = - execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter + logger.debug("Enter createRelationship in DoAllocateNSIandNSSI") + //String allottedResourceId = execution.getVariable("allottedResourceId") + //SliceTaskParamsAdapter sliceParams = + // execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter + String msg + try { + + AAIResourceUri nsiServiceUri = execution.getVariable("nsiServiceUri") as AAIResourceUri + logger.debug("Creating Allotted resource relationship, nsiServiceUri: " + nsiServiceUri.toString()) - AAIResourceUri nsiServiceUri = execution.getVariable("nsiServiceUri") as AAIResourceUri - logger.info("Creating Allotted resource relationship, nsiServiceUri: " + nsiServiceUri) + //AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sliceParams.suggestNsiId).allottedResource(allottedResourceId)) - AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sliceParams.suggestNsiId).allottedResource(allottedResourceId)) + AAIResourceUri allottedResourceUri = execution.getVariable("allottedResourceUri") as AAIResourceUri + logger.debug("Creating Allotted resource relationship, allottedResourceUri: " + allottedResourceUri.toString()) - client.connect(allottedResourceUri, nsiServiceUri) + client.connect(allottedResourceUri, nsiServiceUri) + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in DoAllocateNSIandNSSI.createRelationship. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("Exit createRelationship in DoAllocateNSIandNSSI") } /** @@ -196,7 +215,10 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ String nsiServiceInstanceID = sliceParams.getSuggestNsiId() //sliceParams.setServiceId(nsiServiceInstanceID) - AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(nsiServiceInstanceID)) + AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(nsiServiceInstanceID)) try { AAIResultWrapper wrapper = client.get(nsiServiceUri, NotFoundException.class) @@ -207,8 +229,9 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sliceParams.suggestNsiId).allottedResource(allottedResourceId)) - + //AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sliceParams.suggestNsiId).allottedResource(allottedResourceId)) + AAIResourceUri allottedResourceUri = execution.getVariable("allottedResourceUri") as AAIResourceUri + logger.debug("updateRelationship Allotted resource relationship, allottedResourceUri: " + allottedResourceUri.toString()) client.connect(allottedResourceUri, nsiServiceUri) execution.setVariable("sliceTaskParams", sliceParams) @@ -233,31 +256,23 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ String serviceInstanceId = UUID.randomUUID().toString() execution.setVariable("ranSliceProfileInstanceId", serviceInstanceId) //todo: - String serviceType = "" - String serviceRole = "slice-profile" String oStatus = "deactivated" SliceTaskParamsAdapter sliceParams = execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter - SliceTaskInfo<AnSliceProfile> sliceTaskInfo = sliceParams.anSliceTaskInfo + SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.anSliceTaskInfo sliceTaskInfo.setSliceInstanceId(serviceInstanceId) // create slice profile - ServiceInstance rspi = new ServiceInstance() - rspi.setServiceInstanceName(sliceTaskInfo.NSSTInfo.name) - rspi.setServiceType(serviceType) - rspi.setServiceRole(serviceRole) - rspi.setOrchestrationStatus(oStatus) - rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID) - rspi.setModelVersionId(sliceTaskInfo.NSSTInfo.UUID) - rspi.setInputParameters(execution.getVariable("uuiRequest")) - rspi.setWorkloadContext(execution.getVariable("useInterval")) - rspi.setEnvironmentContext(execution.getVariable("sNSSAI_id")) + ServiceInstance rspi = createSliceProfileInstance(sliceTaskInfo, oStatus) //timestamp format YYYY-MM-DD hh:mm:ss rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault())) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId)) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId) + .serviceSubscription(subscriptionServiceType) + .serviceInstance(serviceInstanceId)) client.create(uri, rspi) execution.setVariable("sliceTaskParams", sliceParams) @@ -275,15 +290,15 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ SliceTaskParamsAdapter sliceParams = execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter - SliceTaskInfo<AnSliceProfile> sliceTaskInfo = sliceParams.anSliceTaskInfo - AnSliceProfile anSliceProfile = sliceTaskInfo.sliceProfile + SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.anSliceTaskInfo + SliceProfileAdapter anSliceProfile = sliceTaskInfo.sliceProfile String profileId = UUID.randomUUID().toString() anSliceProfile.setSliceProfileId(profileId) SliceProfile sliceProfile = new SliceProfile() sliceProfile.setProfileId(profileId) - sliceProfile.setCoverageAreaTAList(anSliceProfile.coverageAreaTAList as String) + sliceProfile.setCoverageAreaTAList(anSliceProfile.coverageAreaTAList) //todo:... AAIResourceUri uri = AAIUriFactory.createResourceUri( AAIFluentTypeBuilder.business().customer(globalSubscriberId) @@ -304,12 +319,24 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ //todo: SliceTaskParamsAdapter sliceParams = execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter - SliceTaskInfo<AnSliceProfile> sliceTaskInfo = sliceParams.anSliceTaskInfo + SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.anSliceTaskInfo NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest() AllocateAnNssi allocateAnNssi = new AllocateAnNssi() - allocateAnNssi.sliceProfile = sliceTaskInfo.sliceProfile + allocateAnNssi.sliceProfile = sliceTaskInfo.sliceProfile.trans2AnProfile() + allocateAnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID + allocateAnNssi.nssiId = sliceTaskInfo.suggestNssiId + allocateAnNssi.nssiName = sliceTaskInfo.NSSTInfo.name + NsiInfo nsiInfo = new NsiInfo() + nsiInfo.nsiId = sliceParams.suggestNsiId + allocateAnNssi.nsiInfo = nsiInfo + //endPoint + EndPoint endPoint = new EndPoint() + endPoint.setIpAddress(sliceTaskInfo.sliceProfile.ipAddress) + endPoint.setLogicInterfaceId(sliceTaskInfo.sliceProfile.logicInterfaceId) + endPoint.setNextHopInfo(sliceTaskInfo.sliceProfile.nextHopInfo) + allocateAnNssi.setEndPoint(endPoint) EsrInfo esrInfo = new EsrInfo() //todo: vendor and network @@ -348,33 +375,25 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ String serviceInstanceId = UUID.randomUUID().toString() execution.setVariable("cnSliceProfileInstanceId", serviceInstanceId) //todo: - String serviceType = "" - String serviceRole = "slice-profile" String oStatus = "deactivated" SliceTaskParamsAdapter sliceParams = execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter - SliceTaskInfo<CnSliceProfile> sliceTaskInfo = sliceParams.cnSliceTaskInfo + SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.cnSliceTaskInfo sliceTaskInfo.setSliceInstanceId(serviceInstanceId) // create slice profile - ServiceInstance rspi = new ServiceInstance() - rspi.setServiceInstanceName(sliceTaskInfo.NSSTInfo.name) - rspi.setServiceType(serviceType) - rspi.setServiceRole(serviceRole) - rspi.setOrchestrationStatus(oStatus) - rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID) - rspi.setModelVersionId(sliceTaskInfo.NSSTInfo.UUID) - rspi.setInputParameters(uuiRequest) - rspi.setWorkloadContext(useInterval) - rspi.setEnvironmentContext(sNSSAI_id) + ServiceInstance rspi = createSliceProfileInstance(sliceTaskInfo, oStatus) //timestamp format YYYY-MM-DD hh:mm:ss rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault())) execution.setVariable("communicationServiceInstance", rspi) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId)) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId) + .serviceSubscription(subscriptionServiceType) + .serviceInstance(serviceInstanceId)) client.create(uri, rspi) execution.setVariable("sliceTaskParams", sliceParams) } @@ -392,8 +411,8 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ SliceTaskParamsAdapter sliceParams = execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter - SliceTaskInfo<CnSliceProfile> sliceTaskInfo = sliceParams.cnSliceTaskInfo - CnSliceProfile cnSliceProfile = sliceTaskInfo.sliceProfile + SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.cnSliceTaskInfo + SliceProfileAdapter cnSliceProfile = sliceTaskInfo.sliceProfile String profileId = UUID.randomUUID().toString() cnSliceProfile.setSliceProfileId(profileId) @@ -402,7 +421,11 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ sliceProfile.setProfileId(profileId) sliceProfile.setCoverageAreaTAList(cnSliceProfile.coverageAreaTAList as String) //todo:... - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(sliceTaskInfo.sliceInstanceId).sliceProfile(profileId)) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId) + .serviceSubscription(subscriptionServiceType) + .serviceInstance(sliceTaskInfo.sliceInstanceId) + .sliceProfile(profileId)) client.create(uri, sliceProfile) execution.setVariable("sliceTaskParams", sliceParams) } @@ -416,7 +439,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ //todo: SliceTaskParamsAdapter sliceParams = execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter - SliceTaskInfo<CnSliceProfile> sliceTaskInfo = sliceParams.cnSliceTaskInfo + SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.cnSliceTaskInfo NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest() @@ -424,8 +447,16 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ allocateCnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID allocateCnNssi.nssiId = sliceTaskInfo.suggestNssiId allocateCnNssi.nssiName = sliceTaskInfo.NSSTInfo.name - allocateCnNssi.sliceProfile = sliceTaskInfo.sliceProfile - allocateCnNssi.nsiInfo.nsiId = sliceParams.suggestNsiId + allocateCnNssi.sliceProfile = sliceTaskInfo.sliceProfile.trans2CnProfile() + NsiInfo nsiInfo = new NsiInfo() + nsiInfo.nsiId = sliceParams.suggestNsiId + allocateCnNssi.nsiInfo = nsiInfo + // endPoint + EndPoint endPoint = new EndPoint() + endPoint.setIpAddress(sliceTaskInfo.sliceProfile.ipAddress) + endPoint.setLogicInterfaceId(sliceTaskInfo.sliceProfile.logicInterfaceId) + endPoint.setNextHopInfo(sliceTaskInfo.sliceProfile.nextHopInfo) + allocateCnNssi.setEndPoint(endPoint) EsrInfo esrInfo = new EsrInfo() //todo: vendor and network @@ -462,37 +493,29 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ String globalSubscriberId = execution.getVariable("globalSubscriberId") String subscriptionServiceType = execution.getVariable("subscriptionServiceType") - String serviceType = "" - String serviceRole = "slice-profile" String oStatus = "deactivated" SliceTaskParamsAdapter sliceParams = execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter - SliceTaskInfo<TnSliceProfile> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo + SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo String serviceInstanceId = UUID.randomUUID().toString() sliceTaskInfo.setSliceInstanceId(serviceInstanceId) //execution.setVariable("cnSliceProfileInstanceId", serviceInstanceId) //todo: // create slice profile - ServiceInstance rspi = new ServiceInstance() - rspi.setServiceInstanceName(sliceTaskInfo.NSSTInfo.name) - rspi.setServiceType(serviceType) - rspi.setServiceRole(serviceRole) - rspi.setOrchestrationStatus(oStatus) - rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID) - rspi.setModelVersionId(sliceTaskInfo.NSSTInfo.UUID) - rspi.setInputParameters(uuiRequest) - rspi.setWorkloadContext(useInterval) - rspi.setEnvironmentContext(sNSSAI_id) + ServiceInstance rspi = createSliceProfileInstance(sliceTaskInfo, oStatus) //timestamp format YYYY-MM-DD hh:mm:ss rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault())) execution.setVariable("communicationServiceInstance", rspi) - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId)) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId) + .serviceSubscription(subscriptionServiceType) + .serviceInstance(serviceInstanceId)) client.create(uri, rspi) execution.setVariable("sliceTaskParams", sliceParams) @@ -510,16 +533,20 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ SliceTaskParamsAdapter sliceParams = execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter - SliceTaskInfo<TnSliceProfile> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo + SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo - TnSliceProfile tnSliceProfile = sliceTaskInfo.sliceProfile + SliceProfileAdapter tnSliceProfile = sliceTaskInfo.sliceProfile String profileId = UUID.randomUUID().toString() tnSliceProfile.setSliceProfileId(profileId) SliceProfile sliceProfile = new SliceProfile() sliceProfile.setProfileId(profileId) //todo:... - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(sliceTaskInfo.sliceInstanceId).sliceProfile(profileId)) + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(globalSubscriberId) + .serviceSubscription(subscriptionServiceType) + .serviceInstance(sliceTaskInfo.sliceInstanceId) + .sliceProfile(profileId)) client.create(uri, sliceProfile) execution.setVariable("sliceTaskParams", sliceParams) @@ -534,16 +561,30 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ //todo: SliceTaskParamsAdapter sliceParams = execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter - SliceTaskInfo<TnSliceProfile> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo + SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest() AllocateTnNssi allocateTnNssi = new AllocateTnNssi() //todo: AllocateTnNssi - //todo: endpointId -> set into tn - allocateTnNssi.setTransportSliceNetworks() - allocateTnNssi.setNetworkSliceInfos() + //todo: endPointId -> set into tn + List<TransportSliceNetwork> transportSliceNetworks = new ArrayList<>() + TransportSliceNetwork transportSliceNetwork = new TransportSliceNetwork() + List<ConnectionLink> connectionLinks = new ArrayList<>() + ConnectionLink connectionLink = new ConnectionLink() + connectionLink.setTransportEndpointA(sliceParams.anSliceTaskInfo.endPointId) + connectionLink.setTransportEndpointB(sliceParams.cnSliceTaskInfo.endPointId) + connectionLinks.add(connectionLink) + transportSliceNetwork.setConnectionLinks(connectionLinks) + transportSliceNetworks.add(transportSliceNetwork) + allocateTnNssi.setTransportSliceNetworks(transportSliceNetworks) + allocateTnNssi.setNetworkSliceInfos() + allocateTnNssi.setSliceProfile(sliceTaskInfo.sliceProfile.trans2TnProfile()) + NsiInfo nsiInfo = new NsiInfo() + nsiInfo.setNsiId(sliceParams.suggestNsiId) + nsiInfo.setNsiName(sliceParams.suggestNsiName) + allocateTnNssi.setNsiInfo(nsiInfo) //allocateTnNssi.networkSliceInfos @@ -591,7 +632,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ String sliceProfileInstanceId = sliceParams.anSliceTaskInfo.sliceInstanceId String serviceProfileInstanceId = sliceParams.serviceId //nsi id - //todo: aai -> nssi -> relationship -> endpointId -> set into tn + //todo: aai -> nssi -> relationship -> endPointId -> set into tn String endPointId = getEndpointIdFromAAI(execution, nssiId) execution.setVariable("endPointIdAn", endPointId) @@ -625,7 +666,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ String sliceProfileInstanceId = sliceParams.cnSliceTaskInfo.sliceInstanceId String serviceProfileInstanceId = sliceParams.serviceId //nsi id - //todo: aai -> nssi -> relationship -> endpointId -> set into tn + //todo: aai -> nssi -> relationship -> endPointId -> set into tn String endPointId = getEndpointIdFromAAI(execution, nssiId) execution.setVariable("endPointIdCn", endPointId) @@ -653,7 +694,10 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter //sliceParams.setServiceId(nsiServiceInstanceID) - AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(nssiId)) + AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(nssiId)) String endpointId = null @@ -666,7 +710,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } else { ServiceInstance nssiInstance = si.get() - //todo: handle relationship and return endpointId + //todo: handle relationship and return endPointId if (nssiInstance.relationshipList == null) { String msg = "relationshipList of " + nssiId + " is null" logger.debug(msg) @@ -730,14 +774,39 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ //relation ship Relationship relationship = new Relationship() - AAIResourceUri targetInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(targetId)) + AAIResourceUri targetInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(targetId)) logger.info("Creating relationship, targetInstanceUri: " + targetInstanceUri) relationship.setRelatedLink(targetInstanceUri.build().toString()) - AAIResourceUri sourceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sourceId)).relationshipAPI() + AAIResourceUri sourceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business() + .customer(execution.getVariable("globalSubscriberId")) + .serviceSubscription(execution.getVariable("subscriptionServiceType")) + .serviceInstance(sourceId)) + .relationshipAPI() client.create(sourceInstanceUri, relationship) } + static def createSliceProfileInstance(SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo, String oStatus) { + // create slice profile + ServiceInstance rspi = new ServiceInstance() + rspi.setServiceInstanceName(sliceTaskInfo.NSSTInfo.name) + rspi.setServiceType(sliceTaskInfo.sliceProfile.getSST()) + rspi.setServiceRole("slice-profile") + rspi.setOrchestrationStatus(oStatus) + rspi.setServiceInstanceLocationId(sliceTaskInfo.sliceProfile.getPLMNIdList()) + rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID) + rspi.setModelVersionId(sliceTaskInfo.NSSTInfo.UUID) + rspi.setWorkloadContext(sliceTaskInfo.subnetType.subnetType) + rspi.setEnvironmentContext(sliceTaskInfo.sliceProfile.getSNSSAIList()) + + //timestamp format YYYY-MM-DD hh:mm:ss + rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault())) + return rspi + } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy index 896d7ff4b1..e5c1b56d55 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy @@ -99,8 +99,12 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { if (response != null) { JobStatusResponse jobStatusResponse = objectMapper.readValue(response, JobStatusResponse.class) - execution.setVariable("nssiAllocateStatus", jobStatusResponse) + if (StringUtils.isBlank(nssiId)) { + nssiAllocateResult.setNssiId(jobStatusResponse.getResponseDescriptor().getNssiId()) + execution.setVariable("nssiAllocateResult", nssiAllocateResult) + } + execution.setVariable("nssiAllocateStatus", jobStatusResponse) if (jobStatusResponse.getResponseDescriptor().getProgress() == 100) { execution.setVariable("jobFinished", true) } @@ -119,8 +123,9 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { SliceTaskInfo sliceTaskInfo = execution.getVariable("sliceTaskInfo") as SliceTaskInfo sliceTaskInfo.progress = response.getProgress() - sliceTaskInfo.status = response.getStatus() + sliceTaskInfo.status = response.getStatus().toLowerCase() sliceTaskInfo.statusDescription = response.getStatusDescription() + sliceTaskInfo.endPointId = response.getEndPointId() updateNssiResult(sliceParams, subnetType, sliceTaskInfo) String paramJson = sliceParams.convertToJson() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy index fc80a9f658..ec70bd3780 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy @@ -246,6 +246,7 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{ client.create(allottedResourceUri, resource) + execution.setVariable("allottedResourceId", allottedResourceId) } }catch (Exception ex) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy index 2cce68a2b6..9450227467 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy @@ -22,13 +22,12 @@ package org.onap.so.bpmn.infrastructure.scripts import com.fasterxml.jackson.databind.ObjectMapper import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.beans.nsmf.AnSliceProfile -import org.onap.so.beans.nsmf.CnSliceProfile import org.onap.so.beans.nsmf.EsrInfo import org.onap.so.beans.nsmf.NetworkType import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest +import org.onap.so.beans.nsmf.QuerySubnetCapability +import org.onap.so.beans.nsmf.SliceProfileAdapter import org.onap.so.beans.nsmf.SliceTaskParamsAdapter -import org.onap.so.beans.nsmf.TnSliceProfile import org.onap.so.beans.nsmf.oof.SubnetCapability import org.onap.so.beans.nsmf.oof.SubnetType import org.onap.so.beans.nsmf.oof.TemplateInfo @@ -45,6 +44,7 @@ import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.util.StringUtils + class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ private static final Logger logger = LoggerFactory.getLogger(DoCreateSliceServiceOption.class) @@ -185,6 +185,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ execution.setVariable("sliceTaskParams", sliceParams) execution.setVariable("subnetCapabilities", subnetCapabilities) + execution.setVariable("queryNsiFirst", true) logger.debug("sliceTaskParams= " + sliceParams.toString()) } @@ -290,13 +291,12 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest() List<String> subnetTypes = new ArrayList<>() - subnetTypes.add(subnetType.subnetType) - Map<String, Object> paramMap = new HashMap<>() - paramMap.put("subnetTypes", subnetTypes) + QuerySubnetCapability req = new QuerySubnetCapability() + req.setSubnetTypes(subnetTypes) - request.setSubnetCapabilityQuery(paramMap) + request.setSubnetCapabilityQuery(req) EsrInfo esrInfo = new EsrInfo() esrInfo.setVendor(vendor) @@ -362,66 +362,73 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ Map<String, Object> resMap = objectMapper.readValue(oofResponse, Map.class) String requestStatus = resMap.get("requestStatus") - if (StringUtils.isEmpty(requestStatus)) { + if (!StringUtils.isEmpty(requestStatus) && requestStatus == "error") { exceptionUtil.buildWorkflowException(execution, 7000, "get nsi from oof error: " + oofResponse) + return } List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions") Map<String, Object> solution = nsiSolutions.get(0) - String resourceSharingLevel = execution.getVariable("resourceSharingLevel") - Boolean isSharable = resourceSharingLevel == "shared" + //String resourceSharingLevel = execution.getVariable("resourceSharingLevel") + //Boolean isSharable = resourceSharingLevel == "shared" if (solution != null) { - if (isSharable && solution.get("existingNSI")) { - //sharedNSISolution - processSharedNSI(solution, sliceTaskParams) - execution.setVariable("needQuerySliceProfile", true) - } - else { - if(execution.getVariable("needQuerySliceProfile")){ + if (execution.getVariable("queryNsiFirst")) { + if (solution.get("existingNSI")) { + execution.setVariable("needQuerySliceProfile", true) + } else { + processNewNSI(solution, sliceTaskParams) execution.setVariable("needQuerySliceProfile", false) } - processNewNSI(solution, sliceTaskParams) + execution.setVariable("queryNsiFirst", false) + } else { + processSharedNSI(solution, sliceTaskParams) + execution.setVariable("needQuerySliceProfile", false) } } execution.setVariable("sliceTaskParams", sliceTaskParams) + logger.debug("after req to oof for nis select, sliceTaskParams = " + sliceTaskParams) logger.debug("*** Completed options Call to OOF ***") } - private void processSharedNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) { + private static void processSharedNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) { Map<String, Object> sharedNSISolution = solution.get("sharedNSISolution") as Map - String nsiId = sharedNSISolution.get("NSIId") String nsiName = sharedNSISolution.get("NSIName") sliceParams.setSuggestNsiId(nsiId) sliceParams.setSuggestNsiName(nsiName) + List<Map> sliceProfiles = sharedNSISolution.get("sliceProfiles") as List<Map> + handleSliceProfiles(sliceProfiles, sliceParams) } - private void processNewNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) { + private static void processNewNSI(Map<String, Object> solution, SliceTaskParamsAdapter sliceParams) { Map<String, Object> newNSISolution = solution.get("newNSISolution") as Map List<Map> sliceProfiles = newNSISolution.get("sliceProfiles") as List<Map> + handleSliceProfiles(sliceProfiles, sliceParams) + } + + static def handleSliceProfiles(List<Map> sliceProfiles, SliceTaskParamsAdapter sliceParams) { for (Map sliceProfile : sliceProfiles) { String domainType = sliceProfile.get("domainType") + sliceProfile.remove("domainType") + SliceProfileAdapter adapter = objectMapper.readValue(objectMapper.writeValueAsString(sliceProfile), SliceProfileAdapter.class) switch (domainType.toLowerCase()) { case "tn-bh": - sliceParams.tnBHSliceTaskInfo.sliceProfile = sliceProfile as TnSliceProfile + sliceParams.tnBHSliceTaskInfo.sliceProfile = adapter break case "an-nf": case "an": - sliceParams.anSliceTaskInfo.sliceProfile = sliceProfile as AnSliceProfile + sliceParams.anSliceTaskInfo.sliceProfile = adapter break case "cn": - sliceParams.cnSliceTaskInfo.sliceProfile = sliceProfile as CnSliceProfile + sliceParams.cnSliceTaskInfo.sliceProfile = adapter break default: break } - - //todo - } } @@ -485,7 +492,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ String selection = resMap.get("selection") if ("NSMF".equalsIgnoreCase(selection)) { - execution.setVariable("NEED_CN_NSSI_SELECTION", true) + //execution.setVariable("NEED_CN_NSSI_SELECTION", true) } } @@ -597,7 +604,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ TemplateInfo nsstInfo = nssiNeedHandlerInfo.get("nsstInfo") as TemplateInfo Map<String, Object> profileInfo = nssiNeedHandlerInfo.get("sliceProfile") as Map - profileInfo.remove("profileId") + //profileInfo.remove("profileId") String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) logger.debug( "get NSI option OOF Url: " + urlString) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy index 8a276ed330..88db2161f7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy @@ -321,17 +321,17 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { String status, String progress, String statusDescription) { - String serviceId = execution.getVariable("dummyServiceId") + String modelUuid = execution.getVariable("modelUuid") String ssInstanceId = execution.getVariable("sliceServiceInstanceId") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") ResourceOperationStatus roStatus = new ResourceOperationStatus() - roStatus.setServiceId(serviceId) + roStatus.setServiceId(nsiId) roStatus.setOperationId(jobId) - roStatus.setResourceTemplateUUID(nsiId) + roStatus.setResourceTemplateUUID(modelUuid) roStatus.setResourceInstanceID(ssInstanceId) - roStatus.setOperType("Allocate") + roStatus.setOperType("ALLOCATE") roStatus.setProgress(progress) roStatus.setStatus(status) roStatus.setStatusDescription(statusDescription) diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn index 9656c86ae5..1a9281f7d9 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn @@ -5,7 +5,7 @@ <bpmn:outgoing>SequenceFlow_03s744c</bpmn:outgoing> </bpmn:startEvent> <bpmn:intermediateCatchEvent id="IntermediateCatchEvent_0vilb24" name="Waiting for confirmation"> - <bpmn:outgoing>SequenceFlow_060j650</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0sub2c2</bpmn:outgoing> <bpmn:linkEventDefinition id="LinkEventDefinition_197u5pe" name="WaitingForConfirmation" /> </bpmn:intermediateCatchEvent> <bpmn:scriptTask id="ScriptTask_1tc44ge" name="PreProcess Incoming Request" scriptFormat="groovy"> @@ -44,6 +44,8 @@ css.processUserOptions(execution)</bpmn:script> <camunda:in source="sliceTaskParams" target="sliceTaskParams" /> <camunda:in source="sliceTaskParams" target="sliceTaskParams" /> <camunda:out source="sliceTaskParams" target="sliceTaskParams" /> + <camunda:out source="allottedResourceId" target="allottedResourceId" /> + <camunda:out source="allottedResourceUri" target="allottedResourceUri" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_1dfon41</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0jhqtls</bpmn:outgoing> @@ -281,6 +283,7 @@ css.prepareUpdateOrchestrationTask(execution)</bpmn:script> <camunda:out source="rolledBack" target="rolledBack" /> <camunda:in source="allottedResourceId" target="allottedResourceId" /> <camunda:out source="sliceTaskParams" target="sliceTaskParams" /> + <camunda:in source="allottedResourceUri" target="allottedResourceUri" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_1bevt3a</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0mlrlbv</bpmn:outgoing> @@ -355,7 +358,6 @@ css.prepareCreateOrchestrationTask(execution)</bpmn:script> </bpmn:intermediateCatchEvent> <bpmn:sequenceFlow id="SequenceFlow_14c2tav" sourceRef="IntermediateCatchEvent_0gceuxu" targetRef="ScriptTask_1ayg9y8" /> <bpmn:sequenceFlow id="SequenceFlow_00kcej9" sourceRef="CallActivity_0n47zoh" targetRef="IntermediateThrowEvent_1v96asi" /> - <bpmn:sequenceFlow id="SequenceFlow_060j650" sourceRef="IntermediateCatchEvent_0vilb24" targetRef="ScriptTask_04qudo2" /> <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_0lpvnze" name="Goto Create Slice Service"> <bpmn:incoming>SequenceFlow_12wo878</bpmn:incoming> <bpmn:linkEventDefinition id="LinkEventDefinition_1oxsvp3" name="CreateSliceService" /> @@ -369,20 +371,12 @@ def css = new CreateSliceService() css.processNSTSolutions(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_1f6dyxo" sourceRef="ScriptTask_13roglo" targetRef="CallActivity_0v4mw2x" /> - <bpmn:receiveTask id="ReceiveTask_02qzb6i" name="Waiting for confirmation" /> <bpmn:endEvent id="EndEvent_0bz8a65"> - <bpmn:incoming>SequenceFlow_1vesvto</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1fk2cn3</bpmn:incoming> <bpmn:errorEventDefinition id="ErrorEventDefinition_1hni1r1" errorRef="Error_0p2naox" /> </bpmn:endEvent> - <bpmn:boundaryEvent id="BoundaryEvent_0p4swyp" attachedToRef="ReceiveTask_02qzb6i"> - <bpmn:outgoing>SequenceFlow_1vesvto</bpmn:outgoing> - <bpmn:timerEventDefinition id="TimerEventDefinition_112p48l"> - <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT2H</bpmn:timeDuration> - </bpmn:timerEventDefinition> - </bpmn:boundaryEvent> - <bpmn:sequenceFlow id="SequenceFlow_1vesvto" sourceRef="BoundaryEvent_0p4swyp" targetRef="EndEvent_0bz8a65" /> <bpmn:scriptTask id="ScriptTask_04qudo2" name="Prepare Get User Options" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_060j650</bpmn:incoming> + <bpmn:incoming>SequenceFlow_031cwkd</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0ti386y</bpmn:outgoing> <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* def css = new CreateSliceService() @@ -427,10 +421,36 @@ def css = new CreateSliceService() css.prepareSelectNSTRequest(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="SequenceFlow_02sve8o" sourceRef="ScriptTask_1ayg9y8" targetRef="CallActivity_0xf2g6c" /> + <bpmn:subProcess id="SubProcess_1sxkpqq" name="Wait for Confim Message"> + <bpmn:incoming>SequenceFlow_0sub2c2</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_031cwkd</bpmn:outgoing> + <bpmn:startEvent id="StartEvent_1hd68zf"> + <bpmn:outgoing>SequenceFlow_0recnor</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:endEvent id="EndEvent_05npq16"> + <bpmn:incoming>SequenceFlow_1htsa6t</bpmn:incoming> + </bpmn:endEvent> + <bpmn:intermediateCatchEvent id="IntermediateCatchEvent_1iti8re" name="Catch Confim Message"> + <bpmn:incoming>SequenceFlow_0recnor</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1htsa6t</bpmn:outgoing> + <bpmn:messageEventDefinition id="MessageEventDefinition_1rxlviw" messageRef="Message_0c4b2r5" /> + </bpmn:intermediateCatchEvent> + <bpmn:sequenceFlow id="SequenceFlow_1htsa6t" name="" sourceRef="IntermediateCatchEvent_1iti8re" targetRef="EndEvent_05npq16" /> + <bpmn:sequenceFlow id="SequenceFlow_0recnor" name="" sourceRef="StartEvent_1hd68zf" targetRef="IntermediateCatchEvent_1iti8re" /> + </bpmn:subProcess> + <bpmn:boundaryEvent id="BoundaryEvent_0xqq1ch" name="Timeout" attachedToRef="SubProcess_1sxkpqq"> + <bpmn:outgoing>SequenceFlow_1fk2cn3</bpmn:outgoing> + <bpmn:timerEventDefinition id="TimerEventDefinition_0jxhpup"> + <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT2H</bpmn:timeDuration> + </bpmn:timerEventDefinition> + </bpmn:boundaryEvent> + <bpmn:sequenceFlow id="SequenceFlow_1fk2cn3" sourceRef="BoundaryEvent_0xqq1ch" targetRef="EndEvent_0bz8a65" /> + <bpmn:sequenceFlow id="SequenceFlow_0sub2c2" sourceRef="IntermediateCatchEvent_0vilb24" targetRef="SubProcess_1sxkpqq" /> + <bpmn:sequenceFlow id="SequenceFlow_031cwkd" sourceRef="SubProcess_1sxkpqq" targetRef="ScriptTask_04qudo2" /> </bpmn:process> - <bpmn:message id="Message_0c4b2r5" name="SliceServiceTask" /> <bpmn:error id="Error_03akl5v" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmn:error id="Error_0p2naox" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn:message id="Message_0c4b2r5" name="SliceServiceTask" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateSliceService"> <bpmndi:BPMNEdge id="SequenceFlow_0kixzdj_di" bpmnElement="SequenceFlow_0kixzdj"> @@ -446,20 +466,20 @@ css.prepareSelectNSTRequest(execution)</bpmn:script> <di:waypoint x="274" y="965" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_10ng1vx_di" bpmnElement="SequenceFlow_10ng1vx"> - <di:waypoint x="1294" y="805" /> + <di:waypoint x="1320" y="805" /> <di:waypoint x="1396" y="805" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_19lsayh_di" bpmnElement="SequenceFlow_19lsayh"> - <di:waypoint x="1124" y="805" /> - <di:waypoint x="1194" y="805" /> + <di:waypoint x="1174" y="805" /> + <di:waypoint x="1220" y="805" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0477975_di" bpmnElement="SequenceFlow_0477975"> - <di:waypoint x="1294" y="620" /> + <di:waypoint x="1320" y="620" /> <di:waypoint x="1396" y="620" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0thd6ny_di" bpmnElement="SequenceFlow_0thd6ny"> - <di:waypoint x="1124" y="620" /> - <di:waypoint x="1194" y="620" /> + <di:waypoint x="1160" y="620" /> + <di:waypoint x="1220" y="620" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1qv8qw1_di" bpmnElement="SequenceFlow_1qv8qw1"> <di:waypoint x="1174" y="965" /> @@ -504,23 +524,23 @@ css.prepareSelectNSTRequest(execution)</bpmn:script> <di:waypoint x="1220" y="350" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_038lb9m_di" bpmnElement="SequenceFlow_038lb9m"> - <di:waypoint x="884" y="645" /> - <di:waypoint x="884" y="805" /> - <di:waypoint x="1024" y="805" /> + <di:waypoint x="984" y="645" /> + <di:waypoint x="984" y="805" /> + <di:waypoint x="1074" y="805" /> <bpmndi:BPMNLabel> - <dc:Bounds x="886" y="722" width="27" height="14" /> + <dc:Bounds x="986" y="722" width="27" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_12t5exy_di" bpmnElement="SequenceFlow_12t5exy"> - <di:waypoint x="909" y="620" /> - <di:waypoint x="1024" y="620" /> + <di:waypoint x="1009" y="620" /> + <di:waypoint x="1060" y="620" /> <bpmndi:BPMNLabel> - <dc:Bounds x="911" y="602" width="42" height="14" /> + <dc:Bounds x="998" y="602" width="42" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_197cm2e_di" bpmnElement="SequenceFlow_197cm2e"> - <di:waypoint x="804" y="620" /> - <di:waypoint x="859" y="620" /> + <di:waypoint x="930" y="620" /> + <di:waypoint x="959" y="620" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_07e12rt_di" bpmnElement="SequenceFlow_07e12rt"> <di:waypoint x="350" y="122" /> @@ -543,12 +563,12 @@ css.prepareSelectNSTRequest(execution)</bpmn:script> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1jgtb0y_di" bpmnElement="ScriptTask_1jgtb0y"> - <dc:Bounds x="704" y="580" width="100" height="80" /> + <dc:Bounds x="830" y="580" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ExclusiveGateway_0elbczl_di" bpmnElement="ExclusiveGateway_0elbczl" isMarkerVisible="true"> - <dc:Bounds x="859" y="595" width="50" height="50" /> + <dc:Bounds x="959" y="595" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="846" y="577" width="78" height="14" /> + <dc:Bounds x="946" y="577" width="78" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_139l55g_di" bpmnElement="CallActivity_139l55g"> @@ -620,16 +640,16 @@ css.prepareSelectNSTRequest(execution)</bpmn:script> <dc:Bounds x="1220" y="310" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_12h8542_di" bpmnElement="ScriptTask_12h8542"> - <dc:Bounds x="1024" y="580" width="100" height="80" /> + <dc:Bounds x="1060" y="580" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_0o89wmf_di" bpmnElement="CallActivity_0o89wmf"> - <dc:Bounds x="1194" y="580" width="100" height="80" /> + <dc:Bounds x="1220" y="580" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_0jdzpem_di" bpmnElement="CallActivity_0jdzpem"> - <dc:Bounds x="1194" y="765" width="100" height="80" /> + <dc:Bounds x="1220" y="765" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1mscu5w_di" bpmnElement="ScriptTask_1mscu5w"> - <dc:Bounds x="1024" y="765" width="100" height="80" /> + <dc:Bounds x="1074" y="765" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="IntermediateCatchEvent_0pkvfun_di" bpmnElement="IntermediateCatchEvent_0pkvfun"> <dc:Bounds x="177" y="947" width="36" height="36" /> @@ -700,10 +720,6 @@ css.prepareSelectNSTRequest(execution)</bpmn:script> <di:waypoint x="1320" y="350" /> <di:waypoint x="1402" y="350" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_060j650_di" bpmnElement="SequenceFlow_060j650"> - <di:waypoint x="213" y="620" /> - <di:waypoint x="394" y="620" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateThrowEvent_0lpvnze_di" bpmnElement="IntermediateThrowEvent_0lpvnze"> <dc:Bounds x="1402" y="106" width="36" height="36" /> <bpmndi:BPMNLabel> @@ -721,32 +737,22 @@ css.prepareSelectNSTRequest(execution)</bpmn:script> <di:waypoint x="810" y="350" /> <di:waypoint x="880" y="350" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ReceiveTask_02qzb6i_di" bpmnElement="ReceiveTask_02qzb6i"> - <dc:Bounds x="254" y="580" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_0bz8a65_di" bpmnElement="EndEvent_0bz8a65"> - <dc:Bounds x="286" y="757" width="36" height="36" /> + <dc:Bounds x="354" y="772" width="36" height="36" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="BoundaryEvent_0p4swyp_di" bpmnElement="BoundaryEvent_0p4swyp"> - <dc:Bounds x="286" y="642" width="36" height="36" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_1vesvto_di" bpmnElement="SequenceFlow_1vesvto"> - <di:waypoint x="304" y="678" /> - <di:waypoint x="304" y="757" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_04qudo2_di" bpmnElement="ScriptTask_04qudo2"> - <dc:Bounds x="394" y="580" width="100" height="80" /> + <dc:Bounds x="550" y="580" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0ti386y_di" bpmnElement="SequenceFlow_0ti386y"> - <di:waypoint x="494" y="620" /> - <di:waypoint x="534" y="620" /> + <di:waypoint x="650" y="620" /> + <di:waypoint x="688" y="620" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_1vu3zcv_di" bpmnElement="CallActivity_1vu3zcv"> - <dc:Bounds x="534" y="580" width="100" height="80" /> + <dc:Bounds x="688" y="580" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1whq7vc_di" bpmnElement="SequenceFlow_1whq7vc"> - <di:waypoint x="634" y="620" /> - <di:waypoint x="704" y="620" /> + <di:waypoint x="788" y="620" /> + <di:waypoint x="830" y="620" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_0xf2g6c_di" bpmnElement="CallActivity_0xf2g6c"> <dc:Bounds x="520" y="310" width="100" height="80" /> @@ -762,6 +768,47 @@ css.prepareSelectNSTRequest(execution)</bpmn:script> <di:waypoint x="410" y="350" /> <di:waypoint x="520" y="350" /> </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="SubProcess_1sxkpqq_di" bpmnElement="SubProcess_1sxkpqq" isExpanded="true"> + <dc:Bounds x="240" y="540" width="280" height="160" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="BoundaryEvent_0xqq1ch_di" bpmnElement="BoundaryEvent_0xqq1ch"> + <dc:Bounds x="354" y="682" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="395" y="712" width="40" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="StartEvent_1hd68zf_di" bpmnElement="StartEvent_1hd68zf"> + <dc:Bounds x="272" y="602" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_05npq16_di" bpmnElement="EndEvent_05npq16"> + <dc:Bounds x="460" y="602" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_1iti8re_di" bpmnElement="IntermediateCatchEvent_1iti8re"> + <dc:Bounds x="367" y="602" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="353" y="644" width="67" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1htsa6t_di" bpmnElement="SequenceFlow_1htsa6t"> + <di:waypoint x="403" y="620" /> + <di:waypoint x="460" y="620" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0recnor_di" bpmnElement="SequenceFlow_0recnor"> + <di:waypoint x="308" y="620" /> + <di:waypoint x="367" y="620" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1fk2cn3_di" bpmnElement="SequenceFlow_1fk2cn3"> + <di:waypoint x="372" y="718" /> + <di:waypoint x="372" y="772" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0sub2c2_di" bpmnElement="SequenceFlow_0sub2c2"> + <di:waypoint x="213" y="620" /> + <di:waypoint x="240" y="620" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_031cwkd_di" bpmnElement="SequenceFlow_031cwkd"> + <di:waypoint x="520" y="620" /> + <di:waypoint x="550" y="620" /> + </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java index 663b097b78..685dbe2dca 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java @@ -121,8 +121,7 @@ public class VnfAdapterCreateTasks { try { volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID); } catch (BBObjectNotFoundException bbException) { - logger.error("Exception occurred if bb object not found in VnfAdapterCreateTasks createVfModule ", - bbException); + logger.info("Volume Group not found in GBB. "); } CloudRegion cloudRegion = gBBInput.getCloudRegion(); RequestContext requestContext = gBBInput.getRequestContext(); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 43a85051be..554385d043 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -78,6 +78,7 @@ public class WorkflowActionBBTasks { private static final String ROLLBACKTOCREATEDNOCONFIGURATION = "RollbackToCreatedNoConfiguration"; private static final String REPLACEINSTANCE = "replaceInstance"; private static final String VFMODULE = "VfModule"; + private static final String CONFIGURATION_PATTERN = "(Ad|De)(.*)FabricConfiguration(.*)"; protected String maxRetries = "mso.rainyDay.maxRetries"; private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBTasks.class); @@ -99,19 +100,26 @@ public class WorkflowActionBBTasks { private RequestsDbListenerRunner requestsDbListener; public void selectBB(DelegateExecution execution) { - List<ExecuteBuildingBlock> flowsToExecute = - (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); - execution.setVariable("MacroRollback", false); - - flowManipulatorListenerRunner.modifyFlows(flowsToExecute, new DelegateExecutionImpl(execution)); - int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE); + try { + List<ExecuteBuildingBlock> flowsToExecute = + (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); + execution.setVariable("MacroRollback", false); + try { + flowManipulatorListenerRunner.modifyFlows(flowsToExecute, new DelegateExecutionImpl(execution)); + } catch (NullPointerException ex) { + workflowAction.buildAndThrowException(execution, "Error in FlowManipulator Modify Flows", ex); + } + int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE); - ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence); + ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence); - execution.setVariable("buildingBlock", ebb); - currentSequence++; - execution.setVariable(COMPLETED, currentSequence >= flowsToExecute.size()); - execution.setVariable(G_CURRENT_SEQUENCE, currentSequence); + execution.setVariable("buildingBlock", ebb); + currentSequence++; + execution.setVariable(COMPLETED, currentSequence >= flowsToExecute.size()); + execution.setVariable(G_CURRENT_SEQUENCE, currentSequence); + } catch (Exception e) { + workflowAction.buildAndThrowException(execution, "Internal Error occured during selectBB", e); + } } public void updateFlowStatistics(DelegateExecution execution) { @@ -414,12 +422,9 @@ public class WorkflowActionBBTasks { String handlingCode = (String) execution.getVariable(HANDLINGCODE); final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE); int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE); - String requestAction = (String) execution.getVariable(G_ACTION); ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence - 1); String bbFlowName = ebb.getBuildingBlock().getBpmnFlowName(); - if ("ActivateVfModuleBB".equalsIgnoreCase(bbFlowName) && aLaCarte && "Success".equalsIgnoreCase(handlingCode) - && !(requestAction.equalsIgnoreCase("replaceInstance") - || requestAction.equalsIgnoreCase("replaceInstanceRetainAssignments"))) { + if ("ActivateVfModuleBB".equalsIgnoreCase(bbFlowName) && aLaCarte && "Success".equalsIgnoreCase(handlingCode)) { postProcessingExecuteBBActivateVfModule(execution, ebb, flowsToExecute); } } @@ -427,6 +432,7 @@ public class WorkflowActionBBTasks { protected void postProcessingExecuteBBActivateVfModule(DelegateExecution execution, ExecuteBuildingBlock ebb, List<ExecuteBuildingBlock> flowsToExecute) { try { + String requestAction = (String) execution.getVariable(G_ACTION); String serviceInstanceId = ebb.getWorkflowResourceIds().getServiceInstanceId(); String vnfId = ebb.getWorkflowResourceIds().getVnfId(); String vfModuleId = ebb.getResourceId(); @@ -441,26 +447,44 @@ public class WorkflowActionBBTasks { for (Vnfc vnfc : vnfcs) { String modelCustomizationId = vnfc.getModelCustomizationId(); logger.debug("Processing Vnfc: {}", modelCustomizationId); - CvnfcConfigurationCustomization fabricConfig = catalogDbClient.getCvnfcCustomization(serviceModelUUID, - vnfCustomizationUUID, vfModuleCustomizationUUID, modelCustomizationId); - if (fabricConfig != null && fabricConfig.getConfigurationResource() != null - && fabricConfig.getConfigurationResource().getToscaNodeType() != null - && fabricConfig.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) { - String configurationId = getConfigurationId(vnfc); - ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys(); - configurationResourceKeys.setCvnfcCustomizationUUID(modelCustomizationId); - configurationResourceKeys.setVfModuleCustomizationUUID(vfModuleCustomizationUUID); - configurationResourceKeys.setVnfResourceCustomizationUUID(vnfCustomizationUUID); - configurationResourceKeys.setVnfcName(vnfc.getVnfcName()); - ExecuteBuildingBlock addConfigBB = getExecuteBBForConfig(ADD_FABRIC_CONFIGURATION_BB, ebb, - configurationId, configurationResourceKeys); - flowsToExecute.add(addConfigBB); - flowsToExecute.forEach(executeBB -> logger.info("Flows to Execute After Post Processing: {}", - executeBB.getBuildingBlock().getBpmnFlowName())); - execution.setVariable("flowsToExecute", flowsToExecute); - execution.setVariable(COMPLETED, false); + if (requestAction.equalsIgnoreCase("replaceInstance") + || requestAction.equalsIgnoreCase("replaceInstanceRetainAssignments")) { + List<ExecuteBuildingBlock> configBBs = flowsToExecute.stream() + .filter(item -> item.getBuildingBlock().getBpmnFlowName().matches(CONFIGURATION_PATTERN)) + .collect(Collectors.toList()); + if (configBBs != null && configBBs.size() > 0) { + for (ExecuteBuildingBlock bb : configBBs) { + if (bb.getConfigurationResourceKeys() != null) { + bb.getConfigurationResourceKeys().setCvnfcCustomizationUUID(modelCustomizationId); + bb.getConfigurationResourceKeys().setVnfcName(vnfc.getVnfcName()); + } + } + execution.setVariable("flowsToExecute", flowsToExecute); + execution.setVariable(COMPLETED, false); + } } else { - logger.debug("No cvnfcCustomization found for customizationId: {}", modelCustomizationId); + CvnfcConfigurationCustomization fabricConfig = catalogDbClient.getCvnfcCustomization( + serviceModelUUID, vnfCustomizationUUID, vfModuleCustomizationUUID, modelCustomizationId); + if (fabricConfig != null && fabricConfig.getConfigurationResource() != null + && fabricConfig.getConfigurationResource().getToscaNodeType() != null && fabricConfig + .getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) { + String configurationId = getConfigurationId(vnfc); + ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys(); + configurationResourceKeys.setCvnfcCustomizationUUID(modelCustomizationId); + configurationResourceKeys.setVfModuleCustomizationUUID(vfModuleCustomizationUUID); + configurationResourceKeys.setVnfResourceCustomizationUUID(vnfCustomizationUUID); + configurationResourceKeys.setVnfcName(vnfc.getVnfcName()); + ExecuteBuildingBlock addConfigBB = getExecuteBBForConfig(ADD_FABRIC_CONFIGURATION_BB, ebb, + configurationId, configurationResourceKeys); + flowsToExecute.add(addConfigBB); + flowsToExecute.stream() + .forEach(executeBB -> logger.info("Flows to Execute After Post Processing: {}", + executeBB.getBuildingBlock().getBpmnFlowName())); + execution.setVariable("flowsToExecute", flowsToExecute); + execution.setVariable(COMPLETED, false); + } else { + logger.debug("No cvnfcCustomization found for customizationId: {}", modelCustomizationId); + } } } } catch (EntityNotFoundException e) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java index b74aa9056d..6765999924 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java @@ -54,14 +54,14 @@ public class CnfAdapterClient { @Autowired private Environment env; - private static final String INSTANCE_CREATE_PATH = "/api/multicloud-k8s/v1/v1/instance"; + private static final String INSTANCE_CREATE_PATH = "/api/cnf-adapter/v1/instance"; @Retryable(value = {HttpServerErrorException.class}, maxAttempts = 3, backoff = @Backoff(delay = 3000)) public InstanceResponse createVfModule(InstanceRequest request) throws CnfAdapterClientException { try { // String uri = env.getRequiredProperty("mso.cnf.adapter.endpoint"); //TODO: This needs to be added as well // for configuration - String uri = "https://localhost:32780"; // TODO: What is the correct uri? + String uri = "http://cnf-adapter:8090"; // TODO: What is the correct uri? String endpoint = UriBuilder.fromUri(uri).path(INSTANCE_CREATE_PATH).build().toString(); HttpEntity<?> entity = getHttpEntity(request); ResponseEntity<InstanceResponse> result = @@ -81,7 +81,7 @@ public class CnfAdapterClient { try { // String uri = env.getRequiredProperty("mso.cnf.adapter.endpoint"); //TODO: This needs to be added as well // for configuration - String uri = "https://localhost:32780"; // TODO: What is the correct uri? + String uri = "http://cnf-adapter:8090"; // TODO: What is the correct uri? String endpoint = UriBuilder.fromUri(uri).path("/api/cnf-adapter/v1/healthcheck").build().toString(); HttpEntity<?> entity = new HttpEntity<>(getHttpHeaders()); ResponseEntity<InstanceResponse> result = diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java index 6278d48e03..7291b713ca 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/AttributeNameValue.java @@ -21,18 +21,16 @@ package org.onap.so.client.adapter.vnf.mapper; import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonProperty; public class AttributeNameValue implements Serializable { private static final long serialVersionUID = -5215028275587848311L; + @JsonProperty("attribute_name") private String attributeName; + @JsonProperty("attribute_value") private transient Object attributeValue; - public AttributeNameValue(String attributeName, Object attributeValue) { - this.attributeName = attributeName; - this.attributeValue = attributeValue; - } - public String getAttributeName() { return attributeName; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index 59da22f8e1..7c686bd165 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -235,7 +235,10 @@ public class VnfAdapterVfModuleObjectMapper { logger.error("No value tag found for attribute: {}", attributeName); throw new MissingValueTagException("No value tag found for " + attributeName); } - directives.append(new AttributeNameValue(attributeName, attributeValue.toString())); + String nameValue = new StringBuilder().append("{\"attribute_name\": \"").append(attributeName) + .append("\", \"attribute_value\": \"").append(attributeValue.toString()).append("\"}") + .toString(); + directives.append(nameValue); if (i < (srcMap.size() - 1 + noOfDirectivesSize)) directives.append(", "); i++; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index 3290bb3dce..b7529bdeb8 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -29,6 +29,7 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; @@ -47,23 +48,30 @@ import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; +import org.onap.so.client.namingservice.NamingRequestObject; +import org.onap.so.db.catalog.beans.ConfigurationResource; +import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.RequestDetails; import org.springframework.core.env.Environment; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; public class WorkflowActionBBTasksTest extends BaseTaskTest { @@ -96,6 +104,9 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { @Rule public ExpectedException thrown = ExpectedException.none(); + @Mock + private DelegateExecution mockExecution; + @Before public void before() throws Exception { execution = new DelegateExecutionFake(); @@ -602,7 +613,207 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test - public void postProcessingExecuteBBActivateVfModuleTest() throws CloneNotSupportedException { + public void postProcessingExecuteBBActivateVfModuleNotReplaceInstanceTest() throws CloneNotSupportedException { + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("1"); + workflowResourceIds.setVnfId("1"); + + BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule); + ebbActivateVfModule.setWorkflowResourceIds(workflowResourceIds); + ebbActivateVfModule.setResourceId("1"); + + ServiceInstance service = new ServiceInstance(); + service.setServiceInstanceName("name"); + service.setModelVersionId("1"); + doReturn(service).when(bbSetupUtils).getAAIServiceInstanceById("1"); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfName("name"); + vnf.setModelCustomizationId("1"); + doReturn(vnf).when(bbSetupUtils).getAAIGenericVnf("1"); + + VfModule vfModule = new VfModule(); + vfModule.setVfModuleName("name"); + vfModule.setModelCustomizationId("1"); + doReturn(vfModule).when(bbSetupUtils).getAAIVfModule("1", "1"); + + List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>(); + org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc(); + vnfc.setModelInvariantId("1"); + vnfc.setVnfcName("name"); + vnfc.setModelCustomizationId("2"); + vnfcs.add(vnfc); + doReturn(vnfcs).when(workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any()); + + CvnfcConfigurationCustomization vfModuleCustomization = new CvnfcConfigurationCustomization(); + ConfigurationResource configuration = new ConfigurationResource(); + configuration.setToscaNodeType("FabricConfiguration"); + configuration.setModelUUID("1"); + vfModuleCustomization.setConfigurationResource(configuration); + + doReturn(vfModuleCustomization).when(catalogDbClient).getCvnfcCustomization("1", "1", "1", "2"); + + prepareDelegateExecution(); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + flowsToExecute.add(ebbActivateVfModule); + + execution.setVariable("requestAction", "createInstance"); + execution.setVariable("completed", true); + + ArgumentCaptor<DelegateExecution> executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class); + ArgumentCaptor<ExecuteBuildingBlock> bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class); + ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class); + workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbActivateVfModule, flowsToExecute); + verify(workflowActionBBTasks, times(1)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(), + bbCaptor.capture(), listCaptor.capture()); + assertEquals(false, executionCaptor.getAllValues().get(0).getVariable("completed")); + assertEquals(2, ((ArrayList) executionCaptor.getAllValues().get(0).getVariable("flowsToExecute")).size()); + assertEquals("2", + ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues().get(0) + .getVariable("flowsToExecute")).get(1)).getConfigurationResourceKeys() + .getCvnfcCustomizationUUID()); + assertEquals("AddFabricConfigurationBB", ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues() + .get(0).getVariable("flowsToExecute")).get(1)).getBuildingBlock().getBpmnFlowName()); + } + + @Test + public void postProcessingExecuteBBActivateVfModuleReplaceInstanceHasConfigurationTest() + throws CloneNotSupportedException { + + BuildingBlock bbAddFabric = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB"); + ExecuteBuildingBlock ebbAddFabric = new ExecuteBuildingBlock().setBuildingBlock(bbAddFabric); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("1"); + workflowResourceIds.setVnfId("1"); + ebbAddFabric.setWorkflowResourceIds(workflowResourceIds); + ebbAddFabric.setResourceId("1"); + + BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule); + ebbActivateVfModule.setWorkflowResourceIds(workflowResourceIds); + ebbActivateVfModule.setResourceId("1"); + ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys(); + ebbAddFabric.setConfigurationResourceKeys(configurationResourceKeys); + + ServiceInstance service = new ServiceInstance(); + service.setServiceInstanceName("name"); + service.setModelVersionId("1"); + doReturn(service).when(bbSetupUtils).getAAIServiceInstanceById("1"); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfName("name"); + vnf.setModelCustomizationId("1"); + doReturn(vnf).when(bbSetupUtils).getAAIGenericVnf("1"); + + VfModule vfModule = new VfModule(); + vfModule.setVfModuleName("name"); + vfModule.setModelCustomizationId("1"); + doReturn(vfModule).when(bbSetupUtils).getAAIVfModule("1", "1"); + + List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>(); + org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc(); + vnfc.setModelInvariantId("1"); + vnfc.setVnfcName("name"); + vnfc.setModelCustomizationId("2"); + vnfcs.add(vnfc); + doReturn(vnfcs).when(workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any()); + + CvnfcConfigurationCustomization vfModuleCustomization = new CvnfcConfigurationCustomization(); + ConfigurationResource configuration = new ConfigurationResource(); + configuration.setToscaNodeType("FabricConfiguration"); + configuration.setModelUUID("1"); + vfModuleCustomization.setConfigurationResource(configuration); + + doReturn(vfModuleCustomization).when(catalogDbClient).getCvnfcCustomization("1", "1", "1", "2"); + + prepareDelegateExecution(); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + flowsToExecute.add(ebbActivateVfModule); + flowsToExecute.add(ebbAddFabric); + + ArgumentCaptor<DelegateExecution> executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class); + ArgumentCaptor<ExecuteBuildingBlock> bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class); + ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class); + + execution.setVariable("requestAction", "replaceInstance"); + execution.setVariable("completed", true); + workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbActivateVfModule, flowsToExecute); + verify(workflowActionBBTasks, times(1)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(), + bbCaptor.capture(), listCaptor.capture()); + assertEquals(false, executionCaptor.getAllValues().get(0).getVariable("completed")); + assertEquals(2, ((ArrayList) executionCaptor.getAllValues().get(0).getVariable("flowsToExecute")).size()); + assertEquals("2", + ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues().get(0) + .getVariable("flowsToExecute")).get(1)).getConfigurationResourceKeys() + .getCvnfcCustomizationUUID()); + } + + @Test + public void postProcessingExecuteBBActivateVfModuleReplaceInstanceHasNoConfigurationTest() + throws CloneNotSupportedException { + + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("1"); + workflowResourceIds.setVnfId("1"); + + BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule); + ebbActivateVfModule.setWorkflowResourceIds(workflowResourceIds); + ebbActivateVfModule.setResourceId("1"); + + ServiceInstance service = new ServiceInstance(); + service.setServiceInstanceName("name"); + service.setModelVersionId("1"); + doReturn(service).when(bbSetupUtils).getAAIServiceInstanceById("1"); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfName("name"); + vnf.setModelCustomizationId("1"); + doReturn(vnf).when(bbSetupUtils).getAAIGenericVnf("1"); + + VfModule vfModule = new VfModule(); + vfModule.setVfModuleName("name"); + vfModule.setModelCustomizationId("1"); + doReturn(vfModule).when(bbSetupUtils).getAAIVfModule("1", "1"); + + List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>(); + org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc(); + vnfc.setModelInvariantId("1"); + vnfc.setVnfcName("name"); + vnfc.setModelCustomizationId("2"); + vnfcs.add(vnfc); + doReturn(vnfcs).when(workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any()); + + CvnfcConfigurationCustomization vfModuleCustomization = new CvnfcConfigurationCustomization(); + ConfigurationResource configuration = new ConfigurationResource(); + configuration.setToscaNodeType("FabricConfiguration"); + configuration.setModelUUID("1"); + vfModuleCustomization.setConfigurationResource(configuration); + + doReturn(vfModuleCustomization).when(catalogDbClient).getCvnfcCustomization("1", "1", "1", "2"); + + prepareDelegateExecution(); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + flowsToExecute.add(ebbActivateVfModule); + + ArgumentCaptor<DelegateExecution> executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class); + ArgumentCaptor<ExecuteBuildingBlock> bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class); + ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class); + + execution.setVariable("requestAction", "replaceInstance"); + execution.setVariable("completed", true); + + workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbActivateVfModule, flowsToExecute); + verify(workflowActionBBTasks, times(1)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(), + bbCaptor.capture(), listCaptor.capture()); + assertEquals(true, executionCaptor.getAllValues().get(0).getVariable("completed")); + } + + + + @Test + public void getExecuteBBForConfigTest() throws CloneNotSupportedException { BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule); |