diff options
36 files changed, 921 insertions, 314 deletions
diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V5.3__Add_Add_Column_To_WatchDog_Model_Id_Lookup.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V5.3__Add_Add_Column_To_WatchDog_Model_Id_Lookup.sql new file mode 100644 index 0000000000..9a5bef6cc8 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V5.3__Add_Add_Column_To_WatchDog_Model_Id_Lookup.sql @@ -0,0 +1,6 @@ +use requestdb; + +ALTER TABLE watchdog_service_mod_ver_id_lookup ADD DISTRIBUTION_NOTIFICATION LONGTEXT NULL AFTER SERVICE_MODEL_VERSION_ID; +ALTER TABLE watchdog_service_mod_ver_id_lookup ADD CONSUMER_ID varchar(200) NULL AFTER DISTRIBUTION_NOTIFICATION; + +CREATE INDEX watchdog_service_mod_ver_id_lookup_serv_mod_ver_id_idx ON watchdog_service_mod_ver_id_lookup (SERVICE_MODEL_VERSION_ID ASC);
\ No newline at end of file diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java index ca1d0331fd..7a02f47d3f 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java @@ -28,6 +28,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.file.Paths; import java.util.List; +import java.util.Optional; import org.onap.sdc.api.IDistributionClient; import org.onap.sdc.api.consumer.IDistributionStatusMessage; @@ -55,11 +56,16 @@ import org.onap.so.asdc.util.ASDCNotificationLogging; import org.onap.so.db.request.beans.WatchdogDistributionStatus; import org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository; import org.onap.so.logger.MessageEnum; - import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; + @Component public class ASDCController { @@ -555,6 +561,22 @@ public class ASDCController { LOGGER.recordMetricEvent (subStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully sent Final notification to ASDC", "ASDC", null, null); } + private Optional<String> getNotificationJson(INotificationData iNotif) { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + mapper.setSerializationInclusion(Include.NON_EMPTY); + mapper.setSerializationInclusion(Include.NON_ABSENT); + mapper.enable(MapperFeature.USE_ANNOTATIONS); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + Optional<String> returnValue = Optional.empty(); + try { + returnValue = Optional.of(mapper.writeValueAsString(iNotif)); + } catch (JsonProcessingException e) { + LOGGER.error("Error converting incoming ASDC notification to JSON" , e); + } + return returnValue; + } + public void treatNotification (INotificationData iNotif) { int noOfArtifacts = 0; @@ -571,7 +593,9 @@ public class ASDCController { LOGGER.debug(ASDCNotificationLogging.dumpASDCNotification(iNotif)); LOGGER.info(MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF, iNotif.getServiceUUID(), "ASDC", "treatNotification"); this.changeControllerStatus(ASDCControllerStatus.BUSY); - toscaInstaller.processWatchdog(iNotif.getDistributionID(),iNotif.getServiceUUID()); + Optional<String> notificationMessage = getNotificationJson(iNotif); + toscaInstaller.processWatchdog(iNotif.getDistributionID(), iNotif.getServiceUUID(), notificationMessage, + asdcConfig.getConsumerID()); // Process only the Resource artifacts in MSO this.processResourceNotification(iNotif); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java index 7dab49f82a..ed97f5bdea 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java @@ -24,6 +24,8 @@ import java.util.ArrayList; import java.util.List; import org.onap.sdc.api.notification.IArtifactInfo; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.EqualsBuilder; public class ArtifactInfoImpl implements IArtifactInfo { @@ -168,4 +170,23 @@ public class ArtifactInfoImpl implements IArtifactInfo { public void setRelatedArtifacts(List<ArtifactInfoImpl> relatedArtifacts) { this.relatedArtifactsImpl = relatedArtifacts; } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof ArtifactInfoImpl)) { + return false; + } + ArtifactInfoImpl castOther = (ArtifactInfoImpl) other; + return new EqualsBuilder().append(artifactUUID, castOther.artifactUUID) + .append(artifactVersion, castOther.artifactVersion).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(artifactName).append(artifactType).append(artifactURL) + .append(artifactChecksum).append(artifactDescription).append(artifactTimeout).append(artifactVersion) + .append(artifactUUID).append(generatedFromUUID).append(generatedArtifact).append(relatedArtifactsInfo) + .append(relatedArtifactsImpl).toHashCode(); + } + } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java index 294221352c..a1c660f75f 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java @@ -23,11 +23,15 @@ package org.onap.so.asdc.client.test.emulators; import java.util.ArrayList; import java.util.List; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.sdc.api.notification.INotificationData; import org.onap.sdc.api.notification.IResourceInstance; import org.springframework.stereotype.Component; +import com.fasterxml.jackson.annotation.JsonIgnore; + @Component public class NotificationDataImpl implements INotificationData { @@ -114,6 +118,7 @@ public class NotificationDataImpl implements INotificationData { return ret; } + @JsonIgnore public List<ResourceInfoImpl> getResourcesImpl(){ return resources; } @@ -172,4 +177,22 @@ public class NotificationDataImpl implements INotificationData { } return ret; } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof NotificationDataImpl)) { + return false; + } + NotificationDataImpl castOther = (NotificationDataImpl) other; + return new EqualsBuilder().append(serviceUUID, castOther.serviceUUID) + .append(serviceVersion, castOther.serviceVersion).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(distributionID).append(serviceName).append(serviceVersion) + .append(serviceUUID).append(serviceDescription).append(serviceInvariantUUID).append(resources) + .append(serviceArtifacts).append(workloadContext).toHashCode(); + } + } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java index eb4764dec1..dad7e64931 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java @@ -23,9 +23,13 @@ package org.onap.so.asdc.client.test.emulators; import java.util.ArrayList; import java.util.List; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.sdc.api.notification.IResourceInstance; +import com.fasterxml.jackson.annotation.JsonIgnore; + public class ResourceInfoImpl implements IResourceInstance{ ResourceInfoImpl (){} private String resourceInstanceName; @@ -120,7 +124,8 @@ public class ResourceInfoImpl implements IResourceInstance{ this.artifacts = artifacts; } - public List<ArtifactInfoImpl> getArtifactsImpl(){ + @JsonIgnore + public List<ArtifactInfoImpl> getArtifactsImpl() { return artifacts; } @@ -155,4 +160,21 @@ public class ResourceInfoImpl implements IResourceInstance{ public void setSubcategory(String subcategory) { this.subcategory = subcategory; } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof ResourceInfoImpl)) { + return false; + } + ResourceInfoImpl castOther = (ResourceInfoImpl) other; + return new EqualsBuilder().append(resourceUUID, castOther.resourceUUID) + .append(resourceVersion, castOther.resourceVersion).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(resourceInstanceName).append(resourceCustomizationUUID).append(resourceName) + .append(resourceVersion).append(resourceType).append(resourceUUID).append(resourceInvariantUUID) + .append(category).append(subcategory).append(artifacts).toHashCode(); + } } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index ebc705ce30..2f4d5ea6a1 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -689,8 +689,10 @@ public class ToscaResourceInstaller { } } - public void processWatchdog(String distributionId, String servideUUID) { - WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId,servideUUID); + public void processWatchdog(String distributionId, String servideUUID, Optional<String> distributionNotification, + String consumerId) { + WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId, servideUUID, + distributionNotification, consumerId); watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup); WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId); diff --git a/asdc-controller/src/test/resources/data.sql b/asdc-controller/src/test/resources/data.sql index 681ee3bda7..70737abf5a 100644 --- a/asdc-controller/src/test/resources/data.sql +++ b/asdc-controller/src/test/resources/data.sql @@ -59,6 +59,6 @@ insert into requestdb.watchdog_per_component_distribution_status(DISTRIBUTION_ID ('testStatusExceptionTosca', 'AAI', 'COMPONENT_MALFORMED'), ('testStatusExceptionTosca', 'SDNC', 'COMPONENT_MALFORMED'); -insert into requestdb.watchdog_service_mod_ver_id_lookup(DISTRIBUTION_ID, SERVICE_MODEL_VERSION_ID) values -('watchdogTestStatusSuccess', '5df8b6de-2083-11e7-93ae-92361f002671'), -('watchdogTestStatusNull', '00000000-0000-0000-0000-000000000000'); +insert into requestdb.watchdog_service_mod_ver_id_lookup(DISTRIBUTION_ID, SERVICE_MODEL_VERSION_ID, DISTRIBUTION_NOTIFICATION, CONSUMER_ID) values +('watchdogTestStatusSuccess', '5df8b6de-2083-11e7-93ae-92361f002671', NULL, NULL), +('watchdogTestStatusNull', '00000000-0000-0000-0000-000000000000', NULL, NULL); diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql index 17423f8434..010b36dcf1 100644 --- a/asdc-controller/src/test/resources/schema.sql +++ b/asdc-controller/src/test/resources/schema.sql @@ -1008,6 +1008,8 @@ CREATE TABLE `watchdog_per_component_distribution_status` ( CREATE TABLE `watchdog_service_mod_ver_id_lookup` ( `DISTRIBUTION_ID` varchar(45) NOT NULL, `SERVICE_MODEL_VERSION_ID` varchar(45) NOT NULL, + `DISTRIBUTION_NOTIFICATION` LONGTEXT NULL, + `CONSUMER_ID` varchar(200) NULL, `CREATE_TIME` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `MODIFY_TIME` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`DISTRIBUTION_ID`,`SERVICE_MODEL_VERSION_ID`) 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 08252f66b8..97fad57e7d 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="1.7.1"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0"> <bpmn:process id="CreateVfModuleBB" name="CreateVfModuleBB" isExecutable="true"> <bpmn:startEvent id="CreateVfModuleBB_Start"> <bpmn:outgoing>SequenceFlow_1xr6chl</bpmn:outgoing> @@ -23,13 +23,17 @@ <bpmn:outgoing>SequenceFlow_1s4rpyp</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_16g4dz0" sourceRef="CreateVfModule" targetRef="VnfAdapter" /> - <bpmn:sequenceFlow id="SequenceFlow_0ecr393" sourceRef="VnfAdapter" targetRef="UpdateVfModuleHeatStackId" /> + <bpmn:sequenceFlow id="SequenceFlow_0ecr393" sourceRef="VnfAdapter" targetRef="CreateNetworkPolicies" /> <bpmn:callActivity id="VnfAdapter" name="Vnf Adapter" calledElement="VnfAdapter"> <bpmn:extensionElements> <camunda:in source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:in source="VNFREST_Request" target="VNFREST_Request" /> <camunda:out source="heatStackId" target="heatStackId" /> + <camunda:out source="contrailServiceInstanceFqdn" target="contrailServiceInstanceFqdn" /> + <camunda:out source="oamManagementV4Address" target="oamManagementV4Address" /> + <camunda:out source="oamManagementV6Address" target="oamManagementV6Address" /> + <camunda:out source="contrailNetworkPolicyFqdnList" target="contrailNetworkPolicyFqdnList" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_16g4dz0</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0ecr393</bpmn:outgoing> @@ -39,7 +43,7 @@ <bpmn:outgoing>SequenceFlow_1vbwdaw</bpmn:outgoing> </bpmn:serviceTask> <bpmn:serviceTask id="UpdateVfModuleHeatStackId" name=" AAI Update (vf module) " camunda:expression="${AAIUpdateTasks.updateHeatStackIdVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_0ecr393</bpmn:incoming> + <bpmn:incoming>SequenceFlow_15do1tu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0rds4rj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:subProcess id="SubProcess_1getwnf" name="Error Handling " triggeredByEvent="true"> @@ -55,29 +59,49 @@ </bpmn:subProcess> <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_0ecr393</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0xqhep5</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0xqhep5" sourceRef="CreateNetworkPolicies" targetRef="UpdateVnfIpv4OamAddress" /> + <bpmn:serviceTask id="UpdateVnfIpv4OamAddress" name="AAI Update (VNF) " camunda:expression="${AAIUpdateTasks.updateIpv4OamAddressVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0xqhep5</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1yo6mvv</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_1yo6mvv" sourceRef="UpdateVnfIpv4OamAddress" targetRef="UpdateVnfManagementV6Address" /> + <bpmn:serviceTask id="UpdateVnfManagementV6Address" name="AAI Update (VNF)" camunda:expression="${AAIUpdateTasks.updateManagementV6AddressVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_1yo6mvv</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1i03uy2</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_1i03uy2" sourceRef="UpdateVnfManagementV6Address" targetRef="UpdateVfModuleContrailServiceInstanceFqdn" /> + <bpmn:serviceTask id="UpdateVfModuleContrailServiceInstanceFqdn" name="AAI Update (vf module) " camunda:expression="${AAIUpdateTasks.updateContrailServiceInstanceFqdnVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_1i03uy2</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_15do1tu</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_15do1tu" sourceRef="UpdateVfModuleContrailServiceInstanceFqdn" targetRef="UpdateVfModuleHeatStackId" /> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateVfModuleBB"> <bpmndi:BPMNShape id="StartEvent_0kxwniy_di" bpmnElement="CreateVfModuleBB_Start"> - <dc:Bounds x="100" y="88" width="36" height="36" /> + <dc:Bounds x="59" y="88" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="106" y="124" width="24" height="12" /> + <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="416" y="66" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1xr6chl_di" bpmnElement="SequenceFlow_1xr6chl"> - <di:waypoint xsi:type="dc:Point" x="136" y="106" /> + <di:waypoint xsi:type="dc:Point" x="95" y="106" /> <di:waypoint xsi:type="dc:Point" x="216" y="106" /> <bpmndi:BPMNLabel> - <dc:Bounds x="131" y="91" width="90" height="0" /> + <dc:Bounds x="156" y="91" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_0qdq7wj_di" bpmnElement="CreateVfModuleBB_End"> - <dc:Bounds x="1299" y="88" width="36" height="36" /> + <dc:Bounds x="1118" y="293" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1272" y="128" width="90" height="12" /> + <dc:Bounds x="1136" y="333" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_1dgenhy_di" bpmnElement="CreateVfModule"> @@ -102,61 +126,107 @@ </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_16g4dz0_di" bpmnElement="SequenceFlow_16g4dz0"> <di:waypoint xsi:type="dc:Point" x="712" y="106" /> - <di:waypoint xsi:type="dc:Point" x="777" y="106" /> + <di:waypoint xsi:type="dc:Point" x="790" y="106" /> <bpmndi:BPMNLabel> - <dc:Bounds x="700" y="85" width="90" height="12" /> + <dc:Bounds x="751" y="91" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0ecr393_di" bpmnElement="SequenceFlow_0ecr393"> - <di:waypoint xsi:type="dc:Point" x="877" y="107" /> - <di:waypoint xsi:type="dc:Point" x="931" y="107" /> + <di:waypoint xsi:type="dc:Point" x="890" y="107" /> + <di:waypoint xsi:type="dc:Point" x="994" y="107" /> + <di:waypoint xsi:type="dc:Point" x="994" y="209" /> + <di:waypoint xsi:type="dc:Point" x="73" y="209" /> + <di:waypoint xsi:type="dc:Point" x="73" y="306" /> + <di:waypoint xsi:type="dc:Point" x="142" y="306" /> <bpmndi:BPMNLabel> - <dc:Bounds x="859" y="92" width="90" height="0" /> + <dc:Bounds x="534" y="194" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_1i1pfzb_di" bpmnElement="VnfAdapter"> - <dc:Bounds x="777" y="66" width="100" height="80" /> + <dc:Bounds x="790" y="66" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0fpfn71_di" bpmnElement="UpdateVfModuleStatus"> - <dc:Bounds x="1117" y="66" width="100" height="80" /> + <dc:Bounds x="942" y="271" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_04k1b85_di" bpmnElement="UpdateVfModuleHeatStackId"> - <dc:Bounds x="931" y="68" width="100" height="80" /> + <dc:Bounds x="777" y="271" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="SubProcess_1getwnf_di" bpmnElement="SubProcess_1getwnf" isExpanded="true"> - <dc:Bounds x="172" y="276" width="231" height="135" /> + <dc:Bounds x="136" y="439" width="231" height="135" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="StartEvent_1c8o652_di" bpmnElement="StartEvent_1c8o652"> - <dc:Bounds x="211" y="334" width="36" height="36" /> + <dc:Bounds x="175" y="497" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="184" y="370" width="0" height="12" /> + <dc:Bounds x="148" y="533" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_1emam1w_di" bpmnElement="EndEvent_1emam1w"> - <dc:Bounds x="348" y="334" width="36" height="36" /> + <dc:Bounds x="312" y="497" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="321" y="370" width="0" height="12" /> + <dc:Bounds x="285" y="533" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0gcots6_di" bpmnElement="SequenceFlow_0gcots6"> - <di:waypoint xsi:type="dc:Point" x="247" y="352" /> - <di:waypoint xsi:type="dc:Point" x="348" y="352" /> + <di:waypoint xsi:type="dc:Point" x="211" y="515" /> + <di:waypoint xsi:type="dc:Point" x="312" y="515" /> <bpmndi:BPMNLabel> - <dc:Bounds x="297.5" y="331" width="0" height="12" /> + <dc:Bounds x="262" y="494" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0rds4rj_di" bpmnElement="SequenceFlow_0rds4rj"> - <di:waypoint xsi:type="dc:Point" x="1031" y="107" /> - <di:waypoint xsi:type="dc:Point" x="1117" y="107" /> + <di:waypoint xsi:type="dc:Point" x="877" y="311" /> + <di:waypoint xsi:type="dc:Point" x="942" y="311" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1074" y="85" width="0" height="13" /> + <dc:Bounds x="910" y="296" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1vbwdaw_di" bpmnElement="SequenceFlow_1vbwdaw"> - <di:waypoint xsi:type="dc:Point" x="1217" y="106" /> - <di:waypoint xsi:type="dc:Point" x="1299" y="106" /> + <di:waypoint xsi:type="dc:Point" x="1042" y="311" /> + <di:waypoint xsi:type="dc:Point" x="1083" y="311" /> + <di:waypoint xsi:type="dc:Point" x="1083" y="311" /> + <di:waypoint xsi:type="dc:Point" x="1118" y="311" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1098" y="311" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_1v8zx4s_di" bpmnElement="CreateNetworkPolicies"> + <dc:Bounds x="142" y="271" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0xqhep5_di" bpmnElement="SequenceFlow_0xqhep5"> + <di:waypoint xsi:type="dc:Point" x="242" y="311" /> + <di:waypoint xsi:type="dc:Point" x="295" y="311" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="269" y="296" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_015ayw5_di" bpmnElement="UpdateVnfIpv4OamAddress"> + <dc:Bounds x="295" y="271" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1yo6mvv_di" bpmnElement="SequenceFlow_1yo6mvv"> + <di:waypoint xsi:type="dc:Point" x="395" y="311" /> + <di:waypoint xsi:type="dc:Point" x="464" y="311" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="430" y="296" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0mlfsc9_di" bpmnElement="UpdateVnfManagementV6Address"> + <dc:Bounds x="464" y="271" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1i03uy2_di" bpmnElement="SequenceFlow_1i03uy2"> + <di:waypoint xsi:type="dc:Point" x="564" y="311" /> + <di:waypoint xsi:type="dc:Point" x="612" y="311" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="588" y="296" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0wctnhw_di" bpmnElement="UpdateVfModuleContrailServiceInstanceFqdn"> + <dc:Bounds x="612" y="271" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_15do1tu_di" bpmnElement="SequenceFlow_15do1tu"> + <di:waypoint xsi:type="dc:Point" x="712" y="311" /> + <di:waypoint xsi:type="dc:Point" x="777" y="311" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1258" y="84" width="0" height="13" /> + <dc:Bounds x="745" y="286" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn index 5cf41b655b..804ae70c58 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn @@ -24,11 +24,15 @@ <camunda:in source="deleteVfModuleRequest" target="deleteVfModuleRequest" /> <camunda:in source="VNFREST_Request" target="VNFREST_Request" /> <camunda:out source="heatStackId" target="heatStackId" /> + <camunda:out source="oamManagementV4Address" target="oamManagementV4Address" /> + <camunda:out source="oamManagementV6Address" target="oamManagementV6Address" /> + <camunda:out source="contrailNetworkPolicyFqdnList" target="contrailNetworkPolicyFqdnList" /> + <camunda:out source="contrailServiceInstanceFqdn" target="contrailServiceInstanceFqdn" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_08tvhtf</bpmn:incoming> <bpmn:outgoing>SequenceFlow_02lpx87</bpmn:outgoing> </bpmn:callActivity> - <bpmn:sequenceFlow id="SequenceFlow_02lpx87" sourceRef="VnfAdapter" targetRef="UpdateVfModuleHeatStackId" /> + <bpmn:sequenceFlow id="SequenceFlow_02lpx87" sourceRef="VnfAdapter" targetRef="DeleteNetworkPolicies" /> <bpmn:subProcess id="SubProcess_11p7mrh" name="Error Handling " triggeredByEvent="true"> <bpmn:startEvent id="StartEvent_1xp6ewt"> <bpmn:outgoing>SequenceFlow_0h607z0</bpmn:outgoing> @@ -41,11 +45,31 @@ <bpmn:sequenceFlow id="SequenceFlow_0h607z0" sourceRef="StartEvent_1xp6ewt" targetRef="EndEvent_0guhjau" /> </bpmn:subProcess> <bpmn:serviceTask id="UpdateVfModuleHeatStackId" name=" AAI Update (vf module) " camunda:expression="${AAIUpdateTasks.updateHeatStackIdVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_02lpx87</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0yuz21z</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01vfwtp</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_01vfwtp" sourceRef="UpdateVfModuleHeatStackId" targetRef="UpdateVfModuleDeleteStatus" /> <bpmn:sequenceFlow id="SequenceFlow_09l7pcg" sourceRef="UpdateVfModuleDeleteStatus" targetRef="DeleteVfModuleBB_End" /> + <bpmn:sequenceFlow id="SequenceFlow_0xyu3pk" sourceRef="DeleteNetworkPolicies" targetRef="UpdateVnfIpv4OamAddress" /> + <bpmn:serviceTask id="DeleteNetworkPolicies" name="AAI Delete (network policies)" camunda:expression="${AAIDeleteTasks.deleteNetworkPolicies(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_02lpx87</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0xyu3pk</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:serviceTask id="UpdateVnfManagementV6Address" name="AAI Update (VNF)" camunda:expression="${AAIUpdateTasks.updateManagementV6AddressVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0jtem3b</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0khqfnc</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0jtem3b" sourceRef="UpdateVnfIpv4OamAddress" targetRef="UpdateVnfManagementV6Address" /> + <bpmn:serviceTask id="UpdateVnfIpv4OamAddress" name="AAI Update (VNF)" camunda:expression="${AAIUpdateTasks.updateIpv4OamAddressVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0xyu3pk</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0jtem3b</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0khqfnc" sourceRef="UpdateVnfManagementV6Address" targetRef="UpdateVfModuleContrailServiceInstanceFqdn" /> + <bpmn:sequenceFlow id="SequenceFlow_0yuz21z" sourceRef="UpdateVfModuleContrailServiceInstanceFqdn" targetRef="UpdateVfModuleHeatStackId" /> + <bpmn:serviceTask id="UpdateVfModuleContrailServiceInstanceFqdn" name="AAI Update (vf module) " camunda:expression="${AAIUpdateTasks.updateContrailServiceInstanceFqdnVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0khqfnc</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0yuz21z</bpmn:outgoing> + </bpmn:serviceTask> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeleteVfModuleBB"> @@ -66,7 +90,7 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0pbhsub_di" bpmnElement="UpdateVfModuleDeleteStatus"> - <dc:Bounds x="762" y="80" width="100" height="80" /> + <dc:Bounds x="758" y="243" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_08tvhtf_di" bpmnElement="SequenceFlow_08tvhtf"> <di:waypoint xsi:type="dc:Point" x="361" y="120" /> @@ -76,9 +100,9 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_1rn6yvh_di" bpmnElement="DeleteVfModuleBB_End"> - <dc:Bounds x="922" y="102" width="36" height="36" /> + <dc:Bounds x="918" y="265" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="940" y="142" width="0" height="0" /> + <dc:Bounds x="936" y="305" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_0whogn3_di" bpmnElement="VnfAdapter"> @@ -86,50 +110,94 @@ </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_02lpx87_di" bpmnElement="SequenceFlow_02lpx87"> <di:waypoint xsi:type="dc:Point" x="527" y="120" /> - <di:waypoint xsi:type="dc:Point" x="604" y="120" /> + <di:waypoint xsi:type="dc:Point" x="591" y="120" /> <bpmndi:BPMNLabel> - <dc:Bounds x="566" y="105" width="0" height="0" /> + <dc:Bounds x="559" y="105" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="SubProcess_11p7mrh_di" bpmnElement="SubProcess_11p7mrh" isExpanded="true"> - <dc:Bounds x="261" y="276" width="231" height="135" /> + <dc:Bounds x="295" y="412" width="231" height="135" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="StartEvent_1xp6ewt_di" bpmnElement="StartEvent_1xp6ewt"> - <dc:Bounds x="304" y="338" width="36" height="36" /> + <dc:Bounds x="338" y="474" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="277" y="374" width="0" height="12" /> + <dc:Bounds x="311" y="510" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_0guhjau_di" bpmnElement="EndEvent_0guhjau"> - <dc:Bounds x="433" y="338" width="36" height="36" /> + <dc:Bounds x="467" y="474" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="406" y="374" width="0" height="12" /> + <dc:Bounds x="440" y="510" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0h607z0_di" bpmnElement="SequenceFlow_0h607z0"> - <di:waypoint xsi:type="dc:Point" x="340" y="356" /> - <di:waypoint xsi:type="dc:Point" x="433" y="356" /> + <di:waypoint xsi:type="dc:Point" x="374" y="492" /> + <di:waypoint xsi:type="dc:Point" x="467" y="492" /> <bpmndi:BPMNLabel> - <dc:Bounds x="386.5" y="335" width="0" height="12" /> + <dc:Bounds x="421" y="471" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0vlgqod_di" bpmnElement="UpdateVfModuleHeatStackId"> - <dc:Bounds x="604" y="80" width="100" height="80" /> + <dc:Bounds x="591" y="243" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_01vfwtp_di" bpmnElement="SequenceFlow_01vfwtp"> - <di:waypoint xsi:type="dc:Point" x="704" y="120" /> - <di:waypoint xsi:type="dc:Point" x="762" y="120" /> + <di:waypoint xsi:type="dc:Point" x="691" y="283" /> + <di:waypoint xsi:type="dc:Point" x="758" y="283" /> <bpmndi:BPMNLabel> - <dc:Bounds x="733" y="95" width="0" height="0" /> + <dc:Bounds x="725" y="268" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_09l7pcg_di" bpmnElement="SequenceFlow_09l7pcg"> - <di:waypoint xsi:type="dc:Point" x="862" y="120" /> - <di:waypoint xsi:type="dc:Point" x="922" y="120" /> + <di:waypoint xsi:type="dc:Point" x="858" y="283" /> + <di:waypoint xsi:type="dc:Point" x="918" y="283" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="888" y="258" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0xyu3pk_di" bpmnElement="SequenceFlow_0xyu3pk"> + <di:waypoint xsi:type="dc:Point" x="691" y="120" /> + <di:waypoint xsi:type="dc:Point" x="751" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="721" y="105" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0tty0ac_di" bpmnElement="DeleteNetworkPolicies"> + <dc:Bounds x="591" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0lrrd16_di" bpmnElement="UpdateVnfManagementV6Address"> + <dc:Bounds x="261" y="243" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0jtem3b_di" bpmnElement="SequenceFlow_0jtem3b"> + <di:waypoint xsi:type="dc:Point" x="851" y="120" /> + <di:waypoint xsi:type="dc:Point" x="941" y="120" /> + <di:waypoint xsi:type="dc:Point" x="941" y="205" /> + <di:waypoint xsi:type="dc:Point" x="182" y="205" /> + <di:waypoint xsi:type="dc:Point" x="182" y="283" /> + <di:waypoint xsi:type="dc:Point" x="261" y="283" /> <bpmndi:BPMNLabel> - <dc:Bounds x="892" y="95" width="0" height="0" /> + <dc:Bounds x="562" y="190" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0w9805b_di" bpmnElement="UpdateVnfIpv4OamAddress"> + <dc:Bounds x="751" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0khqfnc_di" bpmnElement="SequenceFlow_0khqfnc"> + <di:waypoint xsi:type="dc:Point" x="361" y="283" /> + <di:waypoint xsi:type="dc:Point" x="427" y="283" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="394" y="268" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0yuz21z_di" bpmnElement="SequenceFlow_0yuz21z"> + <di:waypoint xsi:type="dc:Point" x="527" y="283" /> + <di:waypoint xsi:type="dc:Point" x="591" y="283" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="559" y="268" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0v8naz9_di" bpmnElement="UpdateVfModuleContrailServiceInstanceFqdn"> + <dc:Bounds x="427" y="243" width="100" height="80" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVfModuleBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVfModuleBBTest.java index 0e4bb5a194..8c44309cca 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVfModuleBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/CreateVfModuleBBTest.java @@ -40,6 +40,10 @@ public class CreateVfModuleBBTest extends BaseBPMNTest{ "QueryVfModule", "CreateVfModule", "VnfAdapter", + "CreateNetworkPolicies", + "UpdateVnfIpv4OamAddress", + "UpdateVnfManagementV6Address", + "UpdateVfModuleContrailServiceInstanceFqdn", "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); @@ -53,7 +57,9 @@ public class CreateVfModuleBBTest extends BaseBPMNTest{ assertThat(pi).isNotNull(); assertThat(pi).isStarted() .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf") - .hasNotPassed("QueryVfModule", "CreateVfModule", "VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); + .hasNotPassed("QueryVfModule", "CreateVfModule", "VnfAdapter", "CreateNetworkPolicies", "UpdateVnfIpv4OamAddress", + "UpdateVnfManagementV6Address","UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId", + "UpdateVfModuleStatus", "CreateVfModuleBB_End"); assertThat(pi).isEnded(); } @@ -64,7 +70,8 @@ public class CreateVfModuleBBTest extends BaseBPMNTest{ assertThat(pi).isNotNull(); assertThat(pi).isStarted() .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule") - .hasNotPassed("CreateVfModule", "VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); + .hasNotPassed("CreateVfModule", "VnfAdapter", "CreateNetworkPolicies", "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address", + "UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); assertThat(pi).isEnded(); } @@ -75,7 +82,8 @@ public class CreateVfModuleBBTest extends BaseBPMNTest{ assertThat(pi).isNotNull(); assertThat(pi).isStarted() .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule") - .hasNotPassed("VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); + .hasNotPassed("VnfAdapter", "CreateNetworkPolicies","UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address", + "UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId", "UpdateVfModuleStatus", "CreateVfModuleBB_End"); assertThat(pi).isEnded(); } @@ -87,7 +95,8 @@ public class CreateVfModuleBBTest extends BaseBPMNTest{ ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables); assertThat(pi).isNotNull(); assertThat(pi).isStarted() - .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule", "VnfAdapter", "UpdateVfModuleHeatStackId") + .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule", "VnfAdapter", "CreateNetworkPolicies", + "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address", "UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId") .hasNotPassed("UpdateVfModuleStatus", "CreateVfModuleBB_End"); assertThat(pi).isEnded(); @@ -100,7 +109,9 @@ public class CreateVfModuleBBTest extends BaseBPMNTest{ ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateVfModuleBB", variables); assertThat(pi).isNotNull(); assertThat(pi).isStarted() - .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule", "VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleStatus") + .hasPassedInOrder("CreateVfModuleBB_Start", "QueryVnf", "QueryVfModule", "CreateVfModule", "VnfAdapter", "CreateNetworkPolicies", + "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address", "UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId", + "UpdateVfModuleStatus") .hasNotPassed("CreateVfModuleBB_End"); assertThat(pi).isEnded(); } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java index d9190b5e12..cedffb77d4 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java @@ -38,6 +38,8 @@ public class DeleteVfModuleBBTest extends BaseBPMNTest{ ProcessInstance pi = runtimeService.startProcessInstanceByKey("DeleteVfModuleBB", variables); assertThat(pi).isNotNull(); assertThat(pi).isStarted().hasPassedInOrder("DeleteVfModuleBB_Start", "DeleteVfModuleVnfAdapter", "VnfAdapter", + "DeleteNetworkPolicies", "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address", + "UpdateVfModuleContrailServiceInstanceFqdn", "UpdateVfModuleHeatStackId", "UpdateVfModuleDeleteStatus", "DeleteVfModuleBB_End"); assertThat(pi).isEnded(); } @@ -49,7 +51,9 @@ public class DeleteVfModuleBBTest extends BaseBPMNTest{ assertThat(pi).isNotNull(); assertThat(pi).isStarted() .hasPassedInOrder("DeleteVfModuleBB_Start", "DeleteVfModuleVnfAdapter") - .hasNotPassed("VnfAdapter", "UpdateVfModuleHeatStackId", "UpdateVfModuleDeleteStatus", "DeleteVfModuleBB_End"); + .hasNotPassed("VnfAdapter", "DeleteNetworkPolicies", "UpdateVnfIpv4OamAddress", "UpdateVnfManagementV6Address", + "UpdateVfModuleContrailServiceInstanceFqdn","UpdateVfModuleHeatStackId", "UpdateVfModuleDeleteStatus", + "DeleteVfModuleBB_End"); assertThat(pi).isEnded(); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java index 55e74339a4..f47781082d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java @@ -21,8 +21,11 @@ package org.onap.so.bpmn.infrastructure.aai.tasks; import java.util.Arrays; -import java.util.Set; +import java.util.List; +import java.util.Optional; import java.util.TreeSet; +import java.util.UUID; +import java.util.stream.Collectors; import org.camunda.bpm.engine.delegate.BpmnError; import org.onap.so.bpmn.common.BuildingBlockExecution; @@ -34,6 +37,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; +import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity; import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; @@ -43,6 +47,9 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.aai.AAIObjectPlurals; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIConfigurationResources; @@ -54,6 +61,8 @@ import org.onap.so.client.orchestration.AAIVolumeGroupResources; import org.onap.so.client.orchestration.AAIVpnBindingResources; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @@ -62,8 +71,13 @@ import org.springframework.stereotype.Component; public class AAICreateTasks { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, AAICreateTasks.class); + private static final Logger logger = LoggerFactory.getLogger(AAICreateTasks.class.getName()); + private static final String networkTypeProvider = "PROVIDER"; private static String NETWORK_COLLECTION_NAME = "networkCollectionName"; + private static String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList"; + private static String HEAT_STACK_ID = "heatStackId"; + private static String NETWORK_POLICY_FQDN_PARAM = "network-policy-fqdn"; @Autowired private AAIServiceInstanceResources aaiSIResources; @Autowired @@ -435,6 +449,38 @@ public class AAICreateTasks { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + + public void createNetworkPolicies(BuildingBlockExecution execution) { + try{ + String fqdns = execution.getVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST); + if (fqdns != null && !fqdns.isEmpty()) { + String fqdnList[] = fqdns.split(","); + int fqdnCount = fqdnList.length; + if (fqdnCount > 0) { + for (int i=0; i < fqdnCount; i++) { + String fqdn = fqdnList[i]; + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY); + uri.queryParam(NETWORK_POLICY_FQDN_PARAM, fqdn); + Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy = aaiNetworkResources.getNetworkPolicy(uri); + if(!oNetPolicy.isPresent()) { + msoLogger.debug("This network policy FQDN is not in AAI yet: " + fqdn); + String networkPolicyId = UUID.randomUUID().toString(); + msoLogger.debug("Adding network-policy with network-policy-id " + networkPolicyId); + NetworkPolicy networkPolicy = new NetworkPolicy(); + networkPolicy.setNetworkPolicyId(networkPolicyId); + networkPolicy.setNetworkPolicyFqdn(fqdn); + networkPolicy.setHeatStackId(execution.getVariable(HEAT_STACK_ID)); + + aaiNetworkResources.createNetworkPolicy(networkPolicy); + } + } + } + } + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + /** * Groups existing vf modules by the model uuid of our new vf module and returns the lowest unused index * @@ -452,23 +498,46 @@ public class AAICreateTasks { if (genericVnf != null && genericVnf.getVfModules() != null && !genericVnf.getVfModules().isEmpty()) { - Set<Integer> moduleIndices = new TreeSet<>(); - for (VfModule vfModule : genericVnf.getVfModules()) { + List<VfModule> modules = genericVnf.getVfModules().stream().filter(item -> !item.getVfModuleId().equals(newVfModule.getVfModuleId())).collect(Collectors.toList()); + TreeSet<Integer> moduleIndices = new TreeSet<>(); + int nullIndexFound = 0; + for (VfModule vfModule : modules) { if (vfModule.getModelInfoVfModule() != null) { if (vfModule.getModelInfoVfModule().getModelInvariantUUID().equals(newVfModuleModelInvariantUUID)) { - moduleIndices.add(vfModule.getModuleIndex()); + if (vfModule.getModuleIndex() != null) { + moduleIndices.add(vfModule.getModuleIndex()); + } else { + nullIndexFound++; + logger.warn("Found null index for vf-module-id {} and model-invariant-uuid {}", vfModule.getVfModuleId(), vfModule.getModelInfoVfModule().getModelInvariantUUID()); + } } } } - Object[] array = moduleIndices.toArray(); - for (int i=0; i < array.length; i++) { - if ((int) array[i] != i) { - return i; - } - } - return array.length; + + return calculateUnusedIndex(moduleIndices, nullIndexFound); } else { return 0; } } + + protected int calculateUnusedIndex(TreeSet<Integer> moduleIndices, int nullIndexFound) { + //pad array with nulls + Integer[] temp = new Integer[moduleIndices.size() + nullIndexFound]; + Integer[] array = moduleIndices.toArray(temp); + int result = 0; + //when a null is found skip that potential value + //effectively creates something like, [0,1,3,null,null] -> [0,1,null(2),3,null(4)] + for (int i=0; i < array.length; i++, result++) { + if (Integer.valueOf(result) != array[i]) { + if (nullIndexFound > 0) { + nullIndexFound--; + i--; + } else { + break; + } + } + } + + return result; + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java index a00806a19c..8f0334e462 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java @@ -21,16 +21,23 @@ package org.onap.so.bpmn.infrastructure.aai.tasks; +import java.util.Optional; +import java.util.UUID; + import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.aai.AAIObjectPlurals; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIConfigurationResources; import org.onap.so.client.orchestration.AAINetworkResources; @@ -38,11 +45,16 @@ import org.onap.so.client.orchestration.AAIServiceInstanceResources; import org.onap.so.client.orchestration.AAIVfModuleResources; import org.onap.so.client.orchestration.AAIVnfResources; import org.onap.so.client.orchestration.AAIVolumeGroupResources; +import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class AAIDeleteTasks { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, AAIDeleteTasks.class); + + private static String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList"; + private static String NETWORK_POLICY_FQDN_PARAM = "network-policy-fqdn"; @Autowired private ExceptionBuilder exceptionUtil; @@ -145,4 +157,30 @@ public class AAIDeleteTasks { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + + public void deleteNetworkPolicies(BuildingBlockExecution execution) { + try{ + String fqdns = execution.getVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST); + if (fqdns != null && !fqdns.isEmpty()) { + String fqdnList[] = fqdns.split(","); + int fqdnCount = fqdnList.length; + if (fqdnCount > 0) { + for (int i=0; i < fqdnCount; i++) { + String fqdn = fqdnList[i]; + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY); + uri.queryParam(NETWORK_POLICY_FQDN_PARAM, fqdn); + Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy = aaiNetworkResources.getNetworkPolicy(uri); + if(oNetPolicy.isPresent()) { + String networkPolicyId = oNetPolicy.get().getNetworkPolicyId(); + msoLogger.debug("Deleting network-policy with network-policy-id " + networkPolicyId); + + aaiNetworkResources.deleteNetworkPolicy(networkPolicyId); + } + } + } + } + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index ed6379a6a4..5176bee0d6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -449,4 +449,53 @@ public class AAIUpdateTasks { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + + public void updateIpv4OamAddressVnf(BuildingBlockExecution execution) { + try { + String ipv4OamAddress = execution.getVariable("oamManagementV4Address"); + if (ipv4OamAddress != null) { + GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + GenericVnf copiedGenericVnf = genericVnf.shallowCopyId(); + + genericVnf.setIpv4OamAddress(ipv4OamAddress); + copiedGenericVnf.setIpv4OamAddress(ipv4OamAddress); + + aaiVnfResources.updateObjectVnf(copiedGenericVnf); + } + } catch(Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + public void updateManagementV6AddressVnf(BuildingBlockExecution execution) { + try { + String managementV6Address = execution.getVariable("oamManagementV6Address"); + if (managementV6Address != null) { + GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + GenericVnf copiedGenericVnf = genericVnf.shallowCopyId(); + + genericVnf.setManagementV6Address(managementV6Address); + copiedGenericVnf.setManagementV6Address(managementV6Address); + + aaiVnfResources.updateObjectVnf(copiedGenericVnf); + } + } catch(Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + public void updateContrailServiceInstanceFqdnVfModule(BuildingBlockExecution execution) { + try { + String contrailServiceInstanceFqdn = execution.getVariable("contrailServiceInstanceFqdn"); + if (contrailServiceInstanceFqdn != null) { + VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + vfModule.setContrailServiceInstanceFqdn(contrailServiceInstanceFqdn); + aaiVfModuleResources.updateContrailServiceInstanceFqdnVfModule(vfModule, vnf); + } + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + }
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java index f1a9e955b6..0851dc9d95 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java @@ -26,6 +26,7 @@ import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse; import org.onap.so.adapters.vnfrest.DeleteVfModuleResponse; import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; @@ -47,10 +48,18 @@ import javax.xml.bind.Unmarshaller; import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.sax.SAXSource; import java.io.StringReader; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; @Component public class VnfAdapterImpl { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VnfAdapterCreateTasks.class); + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VnfAdapterImpl.class); + private static final String CONTRAIL_SERVICE_INSTANCE_FQDN = "contrailServiceInstanceFqdn"; + private static final String OAM_MANAGEMENT_V4_ADDRESS = "oamManagementV4Address"; + private static final String OAM_MANAGEMENT_V6_ADDRESS = "oamManagementV6Address"; + private static final String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList"; @Autowired private ExtractPojosForBB extractPojosForBB; @@ -65,6 +74,10 @@ public class VnfAdapterImpl { execution.setVariable("mso-request-id", gBBInput.getRequestContext().getMsoRequestId()); execution.setVariable("mso-service-instance-id", serviceInstance.getServiceInstanceId()); execution.setVariable("heatStackId", null); + execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, null); + execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, null); + execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, null); + execution.setVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST, null); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -79,15 +92,36 @@ public class VnfAdapterImpl { VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); String heatStackId = ((CreateVfModuleResponse) vnfRestResponse).getVfModuleStackId(); if(!StringUtils.isEmpty(heatStackId)) { - vfModule.setHeatStackId(heatStackId); + vfModule.setHeatStackId(heatStackId); execution.setVariable("heatStackId", heatStackId); } + Map<String,String> vfModuleOutputs = ((CreateVfModuleResponse) vnfRestResponse).getVfModuleOutputs(); + if (vfModuleOutputs != null) { + processVfModuleOutputs(execution, vfModuleOutputs); + } } else if(vnfRestResponse instanceof DeleteVfModuleResponse) { VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); + GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); Boolean vfModuleDelete = ((DeleteVfModuleResponse) vnfRestResponse).getVfModuleDeleted(); if(null!= vfModuleDelete && vfModuleDelete) { vfModule.setHeatStackId(null); execution.setVariable("heatStackId", null); + Map<String,String> vfModuleOutputs = ((DeleteVfModuleResponse) vnfRestResponse).getVfModuleOutputs(); + if (vfModuleOutputs != null) { + processVfModuleOutputs(execution, vfModuleOutputs); + if (execution.getVariable(OAM_MANAGEMENT_V4_ADDRESS) != null) { + genericVnf.setIpv4OamAddress(""); + execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, ""); + } + if (execution.getVariable(OAM_MANAGEMENT_V6_ADDRESS) != null) { + genericVnf.setManagementV6Address(""); + execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, ""); + } + if (execution.getVariable(CONTRAIL_SERVICE_INSTANCE_FQDN) != null) { + vfModule.setContrailServiceInstanceFqdn(""); + execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, ""); + } + } } } else if(vnfRestResponse instanceof CreateVolumeGroupResponse) { VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID, execution.getLookupMap().get(ResourceKey.VOLUME_GROUP_ID)); @@ -108,7 +142,7 @@ public class VnfAdapterImpl { } } } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } @@ -133,4 +167,49 @@ public class VnfAdapterImpl { throw new MarshallerException("Error parsing VNF Adapter response. " + e.getMessage(), MsoLogger.ErrorCode.SchemaError.getValue(), e); } } + + private void processVfModuleOutputs(BuildingBlockExecution execution, Map<String,String> vfModuleOutputs) { + if (vfModuleOutputs == null) { + return; + } + try { + VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); + GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + List<String> contrailNetworkPolicyFqdnList = new ArrayList<String>(); + Iterator<String> keys = vfModuleOutputs.keySet().iterator(); + while (keys.hasNext()) { + String key = keys.next(); + if (key.equals("contrail-service-instance-fqdn")) { + String contrailServiceInstanceFqdn = vfModuleOutputs.get(key); + msoLogger.debug("Obtained contrailServiceInstanceFqdn: " + contrailServiceInstanceFqdn); + vfModule.setContrailServiceInstanceFqdn(contrailServiceInstanceFqdn); + execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, contrailServiceInstanceFqdn); + } + else if (key.endsWith("contrail_network_policy_fqdn")) { + String contrailNetworkPolicyFqdn = vfModuleOutputs.get(key); + msoLogger.debug("Obtained contrailNetworkPolicyFqdn: " + contrailNetworkPolicyFqdn); + contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn); + } + else if (key.equals("oam_management_v4_address")) { + String oamManagementV4Address = vfModuleOutputs.get(key); + msoLogger.debug("Obtained oamManagementV4Address: " + oamManagementV4Address); + genericVnf.setIpv4OamAddress(oamManagementV4Address); + execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, oamManagementV4Address); + } + else if (key.equals("oam_management_v6_address")) { + String oamManagementV6Address = vfModuleOutputs.get(key); + msoLogger.debug("Obtained oamManagementV6Address: " + oamManagementV6Address); + genericVnf.setManagementV6Address(oamManagementV6Address); + execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, oamManagementV6Address); + } + + if (!contrailNetworkPolicyFqdnList.isEmpty()) { + execution.setVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST, String.join(",", contrailNetworkPolicyFqdnList)); + } + } + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java index c895566ca5..c8eeaa7a2b 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java @@ -302,4 +302,8 @@ public class AAIObjectMapper { public org.onap.aai.domain.yang.Subnet mapSubnet (Subnet subnet){ return modelMapper.map(subnet,org.onap.aai.domain.yang.Subnet.class); } + + public org.onap.aai.domain.yang.NetworkPolicy mapNetworkPolicy (NetworkPolicy networkPolicy){ + return modelMapper.map(networkPolicy,org.onap.aai.domain.yang.NetworkPolicy.class); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java index d2bf95a28e..4ca3f2a78d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java @@ -45,6 +45,7 @@ import org.springframework.stereotype.Component; @Component public class AAINetworkResources { + @Autowired private InjectionHelper injectionHelper; @@ -171,6 +172,16 @@ public class AAINetworkResources { AAIResourceUri instanceGroupURI = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId()); injectionHelper.getAaiClient().delete(instanceGroupURI); } - - + + public void createNetworkPolicy(org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy networkPolicy) { + NetworkPolicy aaiNetworkPolicy = aaiObjectMapper.mapNetworkPolicy(networkPolicy); + String networkPolicyId = networkPolicy.getNetworkPolicyId(); + AAIResourceUri netUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId); + injectionHelper.getAaiClient().create(netUri, aaiNetworkPolicy); + } + + public void deleteNetworkPolicy(String networkPolicyId) { + AAIResourceUri networkPolicyURI = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId); + injectionHelper.getAaiClient().delete(networkPolicyURI); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java index a641d43ba3..ef61319eee 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java @@ -76,6 +76,15 @@ public class AAIVfModuleResources { injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule); } + public void updateContrailServiceInstanceFqdnVfModule(VfModule vfModule, GenericVnf vnf) { + AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId()); + VfModule copiedVfModule = vfModule.shallowCopyId(); + + copiedVfModule.setContrailServiceInstanceFqdn(vfModule.getContrailServiceInstanceFqdn()); + org.onap.aai.domain.yang.VfModule aaiVfModule = aaiObjectMapper.mapVfModule(copiedVfModule); + injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule); + } + public void changeAssignVfModule(VfModule vfModule, GenericVnf vnf) { AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId()); org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java index 7375f09240..d8c7ebaff7 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java @@ -45,6 +45,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; +import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity; import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; @@ -708,4 +709,12 @@ public class TestDataSetup{ subnet.setNeutronSubnetId("testNeutronSubnetId"); return subnet; } + + public NetworkPolicy buildNetworkPolicy() { + NetworkPolicy networkPolicy = new NetworkPolicy(); + networkPolicy.setNetworkPolicyId("testNetworkPolicyId"); + networkPolicy.setNetworkPolicyFqdn("testNetworkPolicyFqdn"); + networkPolicy.setHeatStackId("testHeatStackId"); + return networkPolicy; + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java index 8e261cfa8e..c48019af83 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java @@ -30,12 +30,18 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.util.Arrays; +import java.util.Optional; +import java.util.TreeSet; + import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; +import org.mockito.Captor; import org.mockito.InjectMocks; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; @@ -44,6 +50,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; @@ -52,6 +59,7 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.db.catalog.beans.OrchestrationStatus; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; public class AAICreateTasksTest extends BaseTaskTest{ @@ -68,6 +76,9 @@ public class AAICreateTasksTest extends BaseTaskTest{ private Customer customer; private Configuration configuration; + @Captor + ArgumentCaptor<NetworkPolicy> networkPolicyCaptor; + @Rule public final ExpectedException exception = ExpectedException.none(); @@ -457,6 +468,39 @@ public class AAICreateTasksTest extends BaseTaskTest{ verify(aaiVnfResources, times(1)).connectVnfToTenant(genericVnf, gBBInput.getCloudRegion()); } @Test + public void createNetworkPolicyNeedToCreateAllTest() throws Exception { + execution.setVariable("heatStackId", "testHeatStackId"); + execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,ED456"); + Optional<NetworkPolicy> networkPolicy = Optional.empty(); + doReturn(networkPolicy).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class)); + doNothing().when(aaiNetworkResources).createNetworkPolicy(any(NetworkPolicy.class)); + aaiCreateTasks.createNetworkPolicies(execution); + verify(aaiNetworkResources, times(2)).createNetworkPolicy(networkPolicyCaptor.capture()); + assertEquals("ABC123", networkPolicyCaptor.getAllValues().get(0).getNetworkPolicyFqdn()); + assertEquals("ED456", networkPolicyCaptor.getAllValues().get(1).getNetworkPolicyFqdn()); + assertEquals("testHeatStackId", networkPolicyCaptor.getAllValues().get(0).getHeatStackId()); + assertEquals("testHeatStackId", networkPolicyCaptor.getAllValues().get(1).getHeatStackId()); + } + + @Test + public void createNetworkPolicyNeedToCreateNoneTest() throws Exception { + execution.setVariable("heatStackId", "testHeatStackId"); + execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123"); + NetworkPolicy networkPolicy = new NetworkPolicy(); + doReturn(Optional.of(networkPolicy)).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class)); + doNothing().when(aaiNetworkResources).createNetworkPolicy(any(NetworkPolicy.class)); + aaiCreateTasks.createNetworkPolicies(execution); + verify(aaiNetworkResources, times(0)).createNetworkPolicy(any(NetworkPolicy.class)); + } + + @Test + public void createNetworkPolicyNoNetworkPoliciesTest() throws Exception { + execution.setVariable("heatStackId", "testHeatStackId"); + aaiCreateTasks.createNetworkPolicies(execution); + verify(aaiNetworkResources, times(0)).createNetworkPolicy(any(NetworkPolicy.class)); + } + + @Test public void createVfModuleGetLowestIndexTest() throws Exception { GenericVnf vnf = new GenericVnf(); ModelInfoGenericVnf vnfInfo = new ModelInfoGenericVnf(); @@ -472,28 +516,41 @@ public class AAICreateTasksTest extends BaseTaskTest{ infoB.setModelInvariantUUID("B"); ModelInfoVfModule infoC = new ModelInfoVfModule(); - infoB.setIsBaseBoolean(false); - infoB.setModelInvariantUUID("C"); + infoC.setIsBaseBoolean(false); + infoC.setModelInvariantUUID("C"); VfModule newVfModuleA = new VfModule(); + newVfModuleA.setVfModuleId("a"); VfModule newVfModuleB = new VfModule(); + newVfModuleB.setVfModuleId("b"); VfModule newVfModuleC = new VfModule(); + newVfModuleC.setVfModuleId("c"); VfModule vfModule = new VfModule(); vnf.getVfModules().add(vfModule); - + vfModule.setVfModuleId("1"); + VfModule vfModule2 = new VfModule(); vnf.getVfModules().add(vfModule2); - + vfModule2.setVfModuleId("2"); + VfModule vfModule3 = new VfModule(); vnf.getVfModules().add(vfModule3); - + vfModule3.setVfModuleId("3"); + VfModule vfModule4 = new VfModule(); vnf.getVfModules().add(vfModule4); - + vfModule4.setVfModuleId("4"); + VfModule vfModule5 = new VfModule(); vnf.getVfModules().add(vfModule5); + vfModule5.setVfModuleId("5"); + //modules are included in the vnf already + vnf.getVfModules().add(newVfModuleA); + vnf.getVfModules().add(newVfModuleB); + vnf.getVfModules().add(newVfModuleC); + //A newVfModuleA.setModelInfoVfModule(infoA); vfModule.setModelInfoVfModule(infoA); @@ -501,6 +558,7 @@ public class AAICreateTasksTest extends BaseTaskTest{ vfModule3.setModelInfoVfModule(infoA); //B + newVfModuleB.setModelInfoVfModule(infoB); vfModule4.setModelInfoVfModule(infoB); vfModule5.setModelInfoVfModule(infoB); @@ -515,15 +573,32 @@ public class AAICreateTasksTest extends BaseTaskTest{ vfModule3.setModuleIndex(3); //B - vfModule4.setModuleIndex(0); + vfModule4.setModuleIndex(null); vfModule5.setModuleIndex(1); - assertEquals(aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleA), 1); + assertEquals(1, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleA)); - assertEquals(aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleB), 2); + assertEquals(2, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleB)); - assertEquals(aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleC), 0); - + assertEquals(0, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleC)); } + + @Test + public void calculateUnusedIndexTest() { + + TreeSet<Integer> a = new TreeSet<>(Arrays.asList(0,1,3)); + TreeSet<Integer> b = new TreeSet<>(Arrays.asList(0,1,8)); + TreeSet<Integer> c = new TreeSet<>(Arrays.asList(0,2,4)); + assertEquals(2, aaiCreateTasks.calculateUnusedIndex(a, 0)); + assertEquals(5, aaiCreateTasks.calculateUnusedIndex(a, 2)); + + assertEquals(4, aaiCreateTasks.calculateUnusedIndex(b, 2)); + assertEquals(3, aaiCreateTasks.calculateUnusedIndex(b, 1)); + + assertEquals(5, aaiCreateTasks.calculateUnusedIndex(c, 2)); + assertEquals(9, aaiCreateTasks.calculateUnusedIndex(c, 6)); + assertEquals(1, aaiCreateTasks.calculateUnusedIndex(c, 0)); + + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java index 67f5d197de..5cb775180e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java @@ -20,22 +20,26 @@ package org.onap.so.bpmn.infrastructure.aai.tasks; +import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.util.ArrayList; -import java.util.List; +import java.util.Optional; import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Test; +import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; +import org.mockito.Captor; import org.mockito.InjectMocks; +import org.onap.aai.domain.yang.NetworkPolicy; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -46,6 +50,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.exception.BBObjectNotFoundException; @@ -62,6 +67,9 @@ public class AAIDeleteTasksTest extends BaseTaskTest { private CloudRegion cloudRegion; private Configuration configuration; + @Captor + ArgumentCaptor<String> stringCaptor; + @Before public void before() throws BBObjectNotFoundException { serviceInstance = setServiceInstance(); @@ -179,4 +187,34 @@ public class AAIDeleteTasksTest extends BaseTaskTest { aaiDeleteTasks.deleteConfiguration(execution); verify(aaiConfigurationResources, times(1)).deleteConfiguration(configuration); } + + @Test + public void deleteNetworkPolicyNeedToDeleteAllTest() throws Exception { + execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,DEF456"); + NetworkPolicy networkPolicy0 = new NetworkPolicy(); + networkPolicy0.setNetworkPolicyId("testNetworkPolicyId0"); + NetworkPolicy networkPolicy1 = new NetworkPolicy(); + networkPolicy1.setNetworkPolicyId("testNetworkPolicyId1"); + doReturn(Optional.of(networkPolicy0),Optional.of(networkPolicy1)).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class)); + doNothing().when(aaiNetworkResources).deleteNetworkPolicy(any(String.class)); + aaiDeleteTasks.deleteNetworkPolicies(execution); + verify(aaiNetworkResources, times(2)).deleteNetworkPolicy(stringCaptor.capture()); + assertEquals("testNetworkPolicyId0", stringCaptor.getAllValues().get(0)); + assertEquals("testNetworkPolicyId1", stringCaptor.getAllValues().get(1)); + } + + @Test + public void deleteNetworkPolicyNeedToDeleteNoneTest() throws Exception { + execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123"); + Optional<NetworkPolicy> networkPolicy = Optional.empty(); + doReturn(networkPolicy).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class)); + aaiDeleteTasks.deleteNetworkPolicies(execution); + verify(aaiNetworkResources, times(0)).deleteNetworkPolicy(any(String.class)); + } + + @Test + public void deleteNetworkPolicyNoNetworkPoliciesTest() throws Exception { + aaiDeleteTasks.deleteNetworkPolicies(execution); + verify(aaiNetworkResources, times(0)).deleteNetworkPolicy(any(String.class)); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index f97b137fb3..73d7257632 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -586,4 +586,49 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ verify(aaiConfigurationResources, times(1)).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE); } + @Test + public void updateContrailServiceInstanceFqdnVfModuleTest() throws Exception { + execution.setVariable("contrailServiceInstanceFqdn", "newContrailServiceInstanceFqdn"); + doNothing().when(aaiVfModuleResources).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf); + + aaiUpdateTasks.updateContrailServiceInstanceFqdnVfModule(execution); + + verify(aaiVfModuleResources, times(1)).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf); + assertEquals("newContrailServiceInstanceFqdn", vfModule.getContrailServiceInstanceFqdn()); + } + @Test + public void updateContrailServiceInstanceFqdnVfModuleNoUpdateTest() throws Exception { + aaiUpdateTasks.updateContrailServiceInstanceFqdnVfModule(execution); + verify(aaiVfModuleResources, times(0)).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf); + } + @Test + public void updateIpv4OamAddressVnfTest() throws Exception { + execution.setVariable("oamManagementV4Address", "newIpv4OamAddress"); + doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf); + + aaiUpdateTasks.updateIpv4OamAddressVnf(execution); + + verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf); + assertEquals("newIpv4OamAddress", genericVnf.getIpv4OamAddress()); + } + @Test + public void updateIpv4OamAddressVnfNoUpdateTest() throws Exception { + aaiUpdateTasks.updateIpv4OamAddressVnf(execution); + verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf); + } + @Test + public void updateManagementV6AddressVnfTest() throws Exception { + execution.setVariable("oamManagementV6Address", "newManagementV6Address"); + doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf); + + aaiUpdateTasks.updateManagementV6AddressVnf(execution); + + verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf); + assertEquals("newManagementV6Address", genericVnf.getManagementV6Address()); + } + @Test + public void updateManagementV6AddressVnfNoUpdateTest() throws Exception { + aaiUpdateTasks.updateManagementV6AddressVnf(execution); + verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java index 4158f9cfae..33d0dbe130 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java @@ -21,6 +21,7 @@ package org.onap.so.bpmn.infrastructure.adapter.vnf.tasks; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -35,6 +36,7 @@ import org.mockito.InjectMocks; import org.onap.so.FileUtil; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; @@ -50,6 +52,7 @@ public class VnfAdapterImplTest extends BaseTaskTest { private RequestContext requestContext; private ServiceInstance serviceInstance; + private GenericVnf genericVnf; private VfModule vfModule; private VolumeGroup volumeGroup; @@ -58,12 +61,17 @@ public class VnfAdapterImplTest extends BaseTaskTest { private static final String VNF_ADAPTER_VOLUME_CREATE_RESPONSE = FileUtil.readResourceFile("__files/VfModularity/CreateVfModuleVolumeCallbackResponse.xml"); private static final String VNF_ADAPTER_VOLUME_DELETE_RESPONSE = FileUtil.readResourceFile("__files/VfModularity/DeleteVfModuleVolumeCallbackResponse.xml"); private static final String TEST_VFMODULE_HEATSTACK_ID = "slowburn"; - private static final String TEST_VOLUME_HEATSTACK_ID = "testHeatStackId1"; + private static final String TEST_VOLUME_HEATSTACK_ID = "testHeatStackId1"; + private static final String TEST_CONTRAIL_SERVICE_INSTANCE_FQDN = "default-domain:MSOTest:MsoNW-RA"; + private static final String TEST_OAM_MANAGEMENT_V4_ADDRESS = "127.0.0.1"; + private static final String TEST_OAM_MANAGEMENT_V6_ADDRESS = "2000:abc:bce:1111"; + private static final String TEST_CONTRAIL_NETWORK_POLICY_FQDNS = "MSOTest:DefaultPolicyFQDN2,MSOTest:DefaultPolicyFQDN1"; @Before public void before() throws BBObjectNotFoundException { requestContext = setRequestContext(); serviceInstance = setServiceInstance(); + genericVnf = setGenericVnf(); vfModule = setVfModule(); volumeGroup = setVolumeGroup(); vfModule.setHeatStackId(null); @@ -72,6 +80,7 @@ public class VnfAdapterImplTest extends BaseTaskTest { doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class)); when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).thenReturn(serviceInstance); when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID), any())).thenReturn(volumeGroup); + when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID), any())).thenReturn(genericVnf); when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule); } @@ -86,8 +95,15 @@ public class VnfAdapterImplTest extends BaseTaskTest { @Test public void postProcessVnfAdapter_CreateResponseTest() { execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_CREATE_RESPONSE); - vnfAdapterImpl.postProcessVnfAdapter(execution); + vnfAdapterImpl.postProcessVnfAdapter(execution); assertEquals(TEST_VFMODULE_HEATSTACK_ID, vfModule.getHeatStackId()); + assertEquals(TEST_CONTRAIL_SERVICE_INSTANCE_FQDN, vfModule.getContrailServiceInstanceFqdn()); + assertEquals(TEST_CONTRAIL_SERVICE_INSTANCE_FQDN, execution.getVariable("contrailServiceInstanceFqdn")); + assertEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, genericVnf.getIpv4OamAddress()); + assertEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, execution.getVariable("oamManagementV4Address")); + assertEquals(TEST_OAM_MANAGEMENT_V6_ADDRESS, genericVnf.getManagementV6Address()); + assertEquals(TEST_OAM_MANAGEMENT_V6_ADDRESS, execution.getVariable("oamManagementV6Address")); + assertEquals(TEST_CONTRAIL_NETWORK_POLICY_FQDNS, execution.getVariable("contrailNetworkPolicyFqdnList")); } @@ -111,6 +127,20 @@ public class VnfAdapterImplTest extends BaseTaskTest { vnfAdapterImpl.postProcessVnfAdapter(execution); assertNull(vfModule.getHeatStackId()); } + + @Test + public void postProcessVnfAdapter_CreateResponseTest_EmptyVfModuleOutputs() { + execution.setVariable("vnfAdapterRestV1Response", "<createVfModuleResponse><vfModuleOutputs></vfModuleOutputs></createVfModuleResponse>"); + vnfAdapterImpl.postProcessVnfAdapter(execution); + assertNull(vfModule.getHeatStackId()); + assertNull(vfModule.getContrailServiceInstanceFqdn()); + assertNull(execution.getVariable("contrailServiceInstanceFqdn")); + assertNotEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, genericVnf.getIpv4OamAddress()); + assertNull(execution.getVariable("oamManagementV4Address")); + assertNull(genericVnf.getManagementV6Address()); + assertNull(execution.getVariable("oamManagementV6Address")); + assertNull(execution.getVariable("contrailNetworkPolicyFqdnList")); + } @Test public void postProcessVnfAdapter_DeleteResponseTest() { @@ -118,6 +148,25 @@ public class VnfAdapterImplTest extends BaseTaskTest { execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_DELETE_RESPONSE); vnfAdapterImpl.postProcessVnfAdapter(execution); assertNull(vfModule.getHeatStackId()); + assertEquals(vfModule.getContrailServiceInstanceFqdn(), ""); + assertEquals(execution.getVariable("contrailServiceInstanceFqdn"), ""); + assertEquals(genericVnf.getIpv4OamAddress(), ""); + assertEquals(execution.getVariable("oamManagementV4Address"), ""); + assertEquals(genericVnf.getManagementV6Address(), ""); + assertEquals(execution.getVariable("oamManagementV6Address"), ""); + assertEquals(TEST_CONTRAIL_NETWORK_POLICY_FQDNS, execution.getVariable("contrailNetworkPolicyFqdnList")); + } + + @Test + public void postProcessVnfAdapter_DeleteResponseTest_EmptyVfModuleOutputs() { + execution.setVariable("vnfAdapterRestV1Response", "<createVfModuleResponse><vfModuleOutputs></vfModuleOutputs></createVfModuleResponse>"); + vnfAdapterImpl.postProcessVnfAdapter(execution); + assertNull(vfModule.getHeatStackId()); + assertNull(vfModule.getContrailServiceInstanceFqdn()); + assertNull(execution.getVariable("contrailServiceInstanceFqdn")); + assertNull(execution.getVariable("oamManagementV4Address")); + assertNull(execution.getVariable("oamManagementV6Address")); + assertNull(execution.getVariable("contrailNetworkPolicyFqdnList")); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java index db01399b82..a8e9a7e57e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java @@ -41,6 +41,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity; import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget; @@ -672,4 +673,21 @@ public class AAIObjectMapperTest { assertThat(actualSubnet, sameBeanAs(expectedSubnet)); } + + @Test + public void mapNetworkPolicyTest() { + NetworkPolicy networkPolicy = new NetworkPolicy(); + networkPolicy.setNetworkPolicyId("testNetworkPolicyId"); + networkPolicy.setNetworkPolicyFqdn("testNetworkPolicyFqdn"); + networkPolicy.setHeatStackId("testHeatStackId"); + + org.onap.aai.domain.yang.NetworkPolicy expectedNetworkPolicy = new org.onap.aai.domain.yang.NetworkPolicy(); + expectedNetworkPolicy.setNetworkPolicyId("testNetworkPolicyId"); + expectedNetworkPolicy.setNetworkPolicyFqdn("testNetworkPolicyFqdn"); + expectedNetworkPolicy.setHeatStackId("testHeatStackId"); + + org.onap.aai.domain.yang.NetworkPolicy actualNetworkPolicy = aaiObjectMapper.mapNetworkPolicy(networkPolicy); + + assertThat(actualNetworkPolicy, sameBeanAs(expectedNetworkPolicy)); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java index 82ffdf9559..2e2cc5d974 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java @@ -45,7 +45,6 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import org.onap.aai.domain.yang.NetworkPolicy; import org.onap.aai.domain.yang.RouteTableReference; import org.onap.aai.domain.yang.VpnBinding; import org.onap.so.bpmn.common.InjectionHelper; @@ -54,6 +53,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.client.aai.AAIObjectType; @@ -77,6 +77,7 @@ public class AAINetworkResourcesTest extends TestDataSetup{ private ServiceInstance serviceInstance; private CloudRegion cloudRegion; private Subnet subnet; + private NetworkPolicy networkPolicy; @Mock protected AAIResourcesClient MOCK_aaiResourcesClient; @@ -107,6 +108,8 @@ public class AAINetworkResourcesTest extends TestDataSetup{ subnet = buildSubnet(); + networkPolicy = buildNetworkPolicy(); + doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient(); } @@ -175,16 +178,15 @@ public class AAINetworkResourcesTest extends TestDataSetup{ public void getNetworkPolicyTest() throws Exception { final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPolicy.json"))); AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content); - Optional<NetworkPolicy> oNetPolicy = Optional.empty(); + Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy = Optional.empty(); AAIResourceUri netPolicyUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, "ModelInvariantUUID"); doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class)); oNetPolicy = aaiNetworkResources.getNetworkPolicy(netPolicyUri); - verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class)); - + verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class)); if (oNetPolicy.isPresent()) { - NetworkPolicy networkPolicy = oNetPolicy.get(); - assertThat(aaiResultWrapper.asBean(NetworkPolicy.class).get(), sameBeanAs(networkPolicy)); + org.onap.aai.domain.yang.NetworkPolicy networkPolicy = oNetPolicy.get(); + assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.NetworkPolicy.class).get(), sameBeanAs(networkPolicy)); } } @@ -357,4 +359,20 @@ public class AAINetworkResourcesTest extends TestDataSetup{ assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.Subnet.class).get(), sameBeanAs(subnet)); } } + + @Test + public void createNetworkPolicyTest() throws Exception { + doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.NetworkPolicy.class)); + doReturn(new org.onap.aai.domain.yang.NetworkPolicy()).when(MOCK_aaiObjectMapper).mapNetworkPolicy(networkPolicy); + aaiNetworkResources.createNetworkPolicy(networkPolicy); + verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class), isA(org.onap.aai.domain.yang.NetworkPolicy.class)); + } + + @Test + public void deleteNetworkPolicyTest() throws Exception { + doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class)); + aaiNetworkResources.deleteNetworkPolicy(networkPolicy.getNetworkPolicyId()); + verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class)); + } + } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java index 0a8e7ce349..a8200caf79 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java @@ -138,4 +138,17 @@ public class AAIVfModuleResourcesTest extends TestDataSetup{ assertEquals("testHeatStackId", vfModule.getHeatStackId()); } + + @Test + public void updateContrailServiceInstanceFqdnVfModuleTest() throws Exception { + vfModule.setContrailServiceInstanceFqdn("testContrailServiceInstanceFqdn"); + + doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VfModule.class)); + + aaiVfModuleResources.updateContrailServiceInstanceFqdnVfModule(vfModule, vnf); + + verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),ArgumentMatchers.isNull()); + + assertEquals("testContrailServiceInstanceFqdn", vfModule.getContrailServiceInstanceFqdn()); + } } diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java index 03d68f88e8..897e2a5fc8 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java @@ -23,7 +23,7 @@ package org.onap.so.apihandlerinfra; /* * Enum for Status values returned by API Handler to Tail-F */ -public enum Action { +public enum Action implements Actions{ createInstance, updateInstance, deleteInstance, @@ -44,7 +44,7 @@ public enum Action { scaleInstance, deactivateAndCloudDelete, scaleOut, - recreateInstance, + recreateInstance, addMembers, removeMembers } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Actions.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Actions.java index 5dbe44f58b..5dbe44f58b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Actions.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Actions.java diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Constants.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Constants.java index fe105a7637..d824696147 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Constants.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Constants.java @@ -49,4 +49,6 @@ public class Constants { public final static String VNF_REQUEST_SCOPE = "vnf"; public final static String SERVICE_INSTANCE_PATH = "/serviceInstances"; public final static String SERVICE_INSTANTIATION_PATH = "/serviceInstantiation"; + public final static String ORCHESTRATION_REQUESTS_PATH = "/orchestrationRequests"; + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Constants.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Constants.java deleted file mode 100644 index d824696147..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Constants.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.apihandlerinfra; - - -public class Constants { - - private Constants() { - } - - public static final String REQUEST_ID_PATH = "/{request-id}"; - - public static final String STATUS_SUCCESS = "SUCCESS"; - - public static final String MODIFIED_BY_APIHANDLER = "APIH"; - - public static final long PROGRESS_REQUEST_COMPLETED = 100L; - public static final long PROGRESS_REQUEST_RECEIVED = 0L; - public static final long PROGRESS_REQUEST_IN_PROGRESS = 20L; - - public static final String VNF_TYPE_WILDCARD = "*"; - - public static final String VOLUME_GROUP_COMPONENT_TYPE = "VOLUME_GROUP"; - - public static final String VALID_INSTANCE_NAME_FORMAT = "^[a-zA-Z][a-zA-Z0-9._-]*$"; - - public static final String A_LA_CARTE = "aLaCarte"; - - public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; - - public final static String VNF_REQUEST_SCOPE = "vnf"; - public final static String SERVICE_INSTANCE_PATH = "/serviceInstances"; - public final static String SERVICE_INSTANTIATION_PATH = "/serviceInstantiation"; - public final static String ORCHESTRATION_REQUESTS_PATH = "/orchestrationRequests"; - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Messages.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Messages.java deleted file mode 100644 index 555c536efb..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Messages.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.apihandlerinfra; - - -import java.util.HashMap; -import java.util.Map; - -import org.onap.so.apihandler.common.ErrorNumbers; - -public class Messages { - - protected static final Map<String,String> errors = new HashMap<>(); - static { - errors.put(ErrorNumbers.REQUEST_FAILED_SCHEMA_VALIDATION + "_service", "Service request FAILED schema validation. %s"); - errors.put(ErrorNumbers.REQUEST_FAILED_SCHEMA_VALIDATION + "_feature", "Feature request FAILED schema validation. %s"); - errors.put(ErrorNumbers.RECIPE_DOES_NOT_EXIST, "Recipe for %s-type and action specified does not exist in catalog %s"); - errors.put(ErrorNumbers.SERVICE_PARAMETERS_FAILED_SCHEMA_VALIDATION, "Service specific parameters passed in request FAILED schema validation. %s"); - - errors.put(ErrorNumbers.LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS, "%s-name (%s) is locked (status = %s) because already working on a CREATE request with same %s-name."); - errors.put(ErrorNumbers.LOCKED_SAME_ACTION_AND_VNF_ID, "%s-id (%s) is locked (status = %s) because already working on a request with same action (%s) for this %s-id."); - errors.put(ErrorNumbers.REQUEST_TIMED_OUT, "Service request timed out before completing"); - errors.put(ErrorNumbers.ERROR_FROM_BPEL, "BPEL returned an error: %s"); - errors.put(ErrorNumbers.NO_COMMUNICATION_TO_BPEL, "Could not communicate with BPEL %s"); - errors.put(ErrorNumbers.NO_RESPONSE_FROM_BPEL, "No response from BPEL %s"); - errors.put(ErrorNumbers.COULD_NOT_WRITE_TO_REQUESTS_DB, "Could not insert or update record in MSO_REQUESTS DB %s"); - errors.put(ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, "Could not communicate with MSO_REQUESTS DB %s"); - errors.put(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB, "Could not communicate with MSO_CATALOG DB %s"); - errors.put(ErrorNumbers.ERROR_FROM_CATALOG_DB, "Received error from MSO_CATALOG DB %s"); - } - - private Messages(){ - } - - public static Map<String,String> getErrors() { - return errors; - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ModelType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ModelType.java deleted file mode 100644 index 7b3ea3a181..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ModelType.java +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.apihandlerinfra; - -/* - * Enum for Status values returned by API Handler to Tail-F -*/ -public enum ModelType { - service, - vnf, - vfModule, - volumeGroup, - network -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoException.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoException.java deleted file mode 100644 index defc904b05..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoException.java +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.apihandlerinfra; - -public enum MsoException { - ServiceException, - PolicyException, -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Status.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Status.java deleted file mode 100644 index fe9764a2f2..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Status.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.apihandlerinfra; - - -/* - * Enum for Status values returned by API Handler to Tail-F -*/ -public enum Status { - PENDING, - IN_PROGRESS, - COMPLETE, - COMPLETED, - FAILED, - TIMEOUT, - UNLOCKED, - PENDING_MANUAL_TASK -} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogServiceModVerIdLookup.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogServiceModVerIdLookup.java index 77089cbbdc..25f5802413 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogServiceModVerIdLookup.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogServiceModVerIdLookup.java @@ -22,6 +22,8 @@ package org.onap.so.db.request.beans; import java.io.Serializable; import java.util.Date; +import java.util.Objects; +import java.util.Optional; import javax.persistence.Column; import javax.persistence.Entity; @@ -31,7 +33,7 @@ import javax.persistence.PrePersist; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -import java.util.Objects; + import org.apache.commons.lang3.builder.ToStringBuilder; @IdClass(WatchdogServiceModVerIdLookupId.class) @@ -50,6 +52,10 @@ public class WatchdogServiceModVerIdLookup implements Serializable { @Id @Column(name = "SERVICE_MODEL_VERSION_ID", length=45) private String serviceModelVersionId; + @Column(name = "DISTRIBUTION_NOTIFICATION") + private String distributionNotification; + @Column(name = "CONSUMER_ID", length=200) + private String consumerId; @Column(name = "CREATE_TIME", updatable=false) @Temporal(TemporalType.TIMESTAMP) private Date createTime; @@ -57,9 +63,19 @@ public class WatchdogServiceModVerIdLookup implements Serializable { public WatchdogServiceModVerIdLookup() { } - public WatchdogServiceModVerIdLookup(String distributionId, String serviceModelVersionId) { + /** + * + * @param distributionId - Distribution ID + * @param serviceModelVersionId -- service UUID + * @param distributionNotification -- Notification content from ASDC + * @param consumerId -- Consumer ID associated with subscription. + */ + public WatchdogServiceModVerIdLookup(String distributionId, String serviceModelVersionId, + Optional<String> distributionNotification, String consumerId) { this.distributionId = distributionId; this.serviceModelVersionId = serviceModelVersionId; + this.distributionNotification= distributionNotification.orElse(null); + this.consumerId = consumerId; } public String getDistributionId() { @@ -104,8 +120,24 @@ public class WatchdogServiceModVerIdLookup implements Serializable { } @Override public String toString() { - return new ToStringBuilder(this).append("distributionId", getDistributionId()) - .append("serviceModelVersionId", getServiceModelVersionId()).append("createTime", getCreateTime()) + return new ToStringBuilder(this) + .append("distributionId", getDistributionId()) + .append("serviceModelVersionId", getServiceModelVersionId()) + .append("createTime", getCreateTime()) + .append("distributionNotification", getDistributionNotification()) + .append("consumerId", getConsumerId()) .toString(); } + public String getDistributionNotification() { + return distributionNotification; + } + public void setDistributionNotification(String distributionNotification) { + this.distributionNotification = distributionNotification; + } + public String getConsumerId() { + return consumerId; + } + public void setConsumerId(String consumerId) { + this.consumerId = consumerId; + } } |