diff options
Diffstat (limited to 'bpmn')
16 files changed, 342 insertions, 104 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy index e4bc5f8fa2..c337a21987 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy @@ -137,7 +137,7 @@ class AllottedResourceUtils { try { AAIResourcesClient client = new AAIResourcesClient() AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId) - AaiUtil aaiUtil = new AaiUtil() + AaiUtil aaiUtil = new AaiUtil(taskProcessor) arLink = aaiUtil.createAaiUri(uri) } catch (NotFoundException e) { msoLogger.debug("GET AR received a Not Found (404) Response") @@ -323,5 +323,25 @@ class AllottedResourceUtils { msoLogger.trace("Exit BuildAAIErrorResponse Process") throw new BpmnError("MSOWorkflowException") } + + public String createARUrl(DelegateExecution execution, AAIResourceUri uri, String allottedResourceId) { + AaiUtil aaiUriUtil = new AaiUtil(taskProcessor) + AAIResourceUri siResourceLink= uri + + String siUri = "" + + if(siResourceLink != null) { + msoLogger.debug("Incoming PSI Resource Link is: " + siResourceLink.build().toString()) + } + else + { + String msg = "Parent Service Link in AAI is null" + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } + AAIResourceUri arUri = AAIUriFactory.createResourceFromParentURI(siResourceLink, AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId) + + return aaiUriUtil.createAaiUri(arUri) + } } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy index 533df72285..c8736b8f0e 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy @@ -250,7 +250,7 @@ class OofHoming extends AbstractServiceTaskProcessor { resource.getHomingSolution().setCloudOwner(cloudOwner) resource.getHomingSolution().setCloudRegionId(cloudRegionId) - CloudSite cloudSite = new CloudSite(); + CloudSite cloudSite = new CloudSite() cloudSite.setId(cloudRegionId) cloudSite.setRegionId(cloudRegionId) String orchestrator = execution.getVariable("orchestrator") @@ -258,10 +258,18 @@ class OofHoming extends AbstractServiceTaskProcessor { cloudSite.setOrchestrator(orchestrator) } - CloudIdentity cloudIdentity = new CloudIdentity(); - cloudIdentity.setId(cloudRegionId); - cloudIdentity.setIdentityUrl("/api/multicloud /v1/" + cloudOwner + "/" + cloudRegionId + "/infra_workload") - cloudSite.setIdentityService(cloudIdentity); + CloudIdentity cloudIdentity = new CloudIdentity() + cloudIdentity.setId(cloudRegionId) + // Get MSB Url + String msbHost = oofUtils.getMsbHost(execution) + String multicloudApiEndpoint = UrnPropertiesReader + .getVariable("mso.multicloud.api.endpoint", execution, + "/api/multicloud-titaniumcloud/v1") + cloudIdentity.setIdentityUrl(msbHost + multicloudApiEndpoint + + "/" + cloudOwner + "/" + + cloudRegionId + "/infra_workload") + + cloudSite.setIdentityService(cloudIdentity) // Set cloudsite in catalog DB here oofUtils.createCloudSiteCatalogDb(cloudSite) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy index c7312c453c..909683adea 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy @@ -530,4 +530,12 @@ class OofUtils { exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from CatalogDB.") } } + + String getMsbHost(DelegateExecution execution) { + msbHost = UrnPropertiesReader.getVariable("mso.msb.host", execution, "msb-iag.onap") + + Integer msbPort = UrnPropertiesReader.getVariable("mso.msb.port", execution, "80").toInteger() + + return UriBuilder.fromPath("").host(msbHost).port(msbPort).scheme("http").build().toString() + } } diff --git a/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml b/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml deleted file mode 100644 index 33c8cb1ac0..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!-- - ============LICENSE_START======================================================= - ONAP SO - ================================================================================ - 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========================================================= - --> - -<process-application - xmlns="http://www.camunda.org/schema/1.0/ProcessApplication" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - - <process-archive name="MSOCommonBPMN"> - <properties> - <property name="isDeleteUponUndeploy">false</property> - <property name="isScanForProcessDefinitions">true</property> - </properties> - </process-archive> - -</process-application> diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtilsTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtilsTest.groovy new file mode 100644 index 0000000000..5058961992 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtilsTest.groovy @@ -0,0 +1,39 @@ +package org.onap.so.bpmn.common.scripts + +import static org.junit.Assert.assertEquals +import static org.mockito.Matchers.eq +import static org.mockito.Mockito.mock +import static org.mockito.Mockito.when + +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake +import org.junit.Test +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.springframework.core.env.Environment + +class AllottedResourceUtilsTest { + + + @Test + public void createARUrlTest() { + AllottedResourceUtils utils = new AllottedResourceUtils(mock(AbstractServiceTaskProcessor.class)) + DelegateExecution execution = new DelegateExecutionFake() + String allottedResourceId = "my-id" + UrnPropertiesReader reader = new UrnPropertiesReader() + Environment env = mock(Environment.class); + + when(env.getProperty(eq("mso.workflow.global.default.aai.version"))).thenReturn("14") + when(env.getProperty(eq("aai.endpoint"))).thenReturn("http://localhost:8080") + + + reader.setEnvironment(env) + + + AAIResourceUri uri = mock(AAIResourceUri.class) + when(uri.build()).thenReturn(new URI("/business/customers/customer/1/service-subscriptions/service-subscription/2/service-instances/service-instance/3")) + String actual = utils.createARUrl(execution, uri, allottedResourceId) + + assertEquals("http://localhost:8080/aai/v14/business/customers/customer/1/service-subscriptions/service-subscription/2/service-instances/service-instance/3/allotted-resources/allotted-resource/my-id", actual) + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/UrnPropertiesReader.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/UrnPropertiesReader.java index 968c8c1590..750cd241e8 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/UrnPropertiesReader.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/UrnPropertiesReader.java @@ -69,6 +69,10 @@ public class UrnPropertiesReader { return variableValue; } + public static String getVariable(String variableName, DelegateExecution execution, String defaultValue) { + return Optional.ofNullable(getVariable(variableName, execution)).orElse(defaultValue); + } + /** * Return the URN property value from the environment object * @param variableName URN property name diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn index 8cda1d7c7b..3b24ba390b 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.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.8.2"> +<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="WorkflowActionBB" name="WorkflowActionBB" isExecutable="true"> <bpmn:startEvent id="Start_WorkflowActionBB" name="start"> <bpmn:outgoing>SequenceFlow_15s0okp</bpmn:outgoing> @@ -17,6 +17,9 @@ <camunda:in source="mso-request-id" target="mso-request-id" /> <camunda:in source="retryCount" target="retryCount" /> <camunda:out source="WorkflowExceptionErrorMessage" target="WorkflowExceptionErrorMessage" /> + <camunda:in source="aLaCarte" target="aLaCarte" /> + <camunda:in source="orchestrationStatusValidationResult" target="orchestrationStatusValidationResult" /> + <camunda:out source="orchestrationStatusValidationResult" target="orchestrationStatusValidationResult" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_0mew9im</bpmn:incoming> <bpmn:outgoing>SequenceFlow_07h9d4y</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/BuildingBlockValidatorRunnerTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/BuildingBlockValidatorRunnerTest.java new file mode 100644 index 0000000000..ea0fb95702 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/BuildingBlockValidatorRunnerTest.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.bpmn.subprocess; + +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.job; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.execute; +import org.camunda.bpm.engine.runtime.Job; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.task.Task; +import org.junit.Test; +import org.onap.so.bpmn.BaseBPMNTest; + +public class BuildingBlockValidatorRunnerTest extends BaseBPMNTest{ + @Test + public void sunnyDayActivateNetwork_Test() throws InterruptedException { + variables.put("flowToBeCalled","CreateVolumeGroupBB"); + ProcessInstance pi = runtimeService.startProcessInstanceByKey("BuildingBlockValidatorRunnerTest", variables); + assertThat(pi).isNotNull(); + + execute(job()); + execute(job()); + assertThat(pi).isStarted().hasPassedInOrder("ServiceTask_1","ServiceTask_2","ServiceTask_3"); + assertThat(pi).isEnded(); + } +} diff --git a/bpmn/so-bpmn-building-blocks/src/test/resources/META-INF/processes.xml b/bpmn/so-bpmn-building-blocks/src/test/resources/META-INF/processes.xml new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/test/resources/META-INF/processes.xml diff --git a/bpmn/so-bpmn-building-blocks/src/test/resources/subprocess/BuildingBlock/BuildingBlockValidatorRunnerTest.bpmn b/bpmn/so-bpmn-building-blocks/src/test/resources/subprocess/BuildingBlock/BuildingBlockValidatorRunnerTest.bpmn new file mode 100644 index 0000000000..446dfe3104 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/test/resources/subprocess/BuildingBlock/BuildingBlockValidatorRunnerTest.bpmn @@ -0,0 +1,122 @@ +<?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.8.2"> + <bpmn:process id="BuildingBlockValidatorRunnerTest" name="BuildingBlockValidatorRunnerTest" isExecutable="true"> + <bpmn:startEvent id="StartEvent_1"> + <bpmn:outgoing>SequenceFlow_0vof4nz</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:serviceTask id="ServiceTask_1" name="PreValidate" camunda:expression="${BuildingBlockValidatorRunner.preValidate(flowToBeCalled, InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0vof4nz</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_14nr57b</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:serviceTask id="ServiceTask_2" name="PreValidate" camunda:expression="${BuildingBlockValidatorRunner.preValidate(flowToBeCalled, InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_1vsqhv8</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_04xg7yh</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0vof4nz" sourceRef="StartEvent_1" targetRef="ServiceTask_1" /> + <bpmn:endEvent id="EndEvent_1wyjfsw"> + <bpmn:incoming>SequenceFlow_06wt67a</bpmn:incoming> + </bpmn:endEvent> + <bpmn:intermediateCatchEvent id="IntermediateCatchEvent_1" name="RetryTimer"> + <bpmn:incoming>SequenceFlow_14nr57b</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1vsqhv8</bpmn:outgoing> + <bpmn:timerEventDefinition> + <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT10S</bpmn:timeDuration> + </bpmn:timerEventDefinition> + </bpmn:intermediateCatchEvent> + <bpmn:sequenceFlow id="SequenceFlow_14nr57b" sourceRef="ServiceTask_1" targetRef="IntermediateCatchEvent_1" /> + <bpmn:sequenceFlow id="SequenceFlow_1vsqhv8" sourceRef="IntermediateCatchEvent_1" targetRef="ServiceTask_2" /> + <bpmn:intermediateCatchEvent id="IntermediateCatchEvent_2" name="RetryTimer"> + <bpmn:incoming>SequenceFlow_04xg7yh</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0w8ajcb</bpmn:outgoing> + <bpmn:timerEventDefinition> + <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT10S</bpmn:timeDuration> + </bpmn:timerEventDefinition> + </bpmn:intermediateCatchEvent> + <bpmn:serviceTask id="ServiceTask_3" name="PreValidate" camunda:expression="${BuildingBlockValidatorRunner.preValidate(flowToBeCalled, InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0w8ajcb</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_06wt67a</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_04xg7yh" sourceRef="ServiceTask_2" targetRef="IntermediateCatchEvent_2" /> + <bpmn:sequenceFlow id="SequenceFlow_0w8ajcb" sourceRef="IntermediateCatchEvent_2" targetRef="ServiceTask_3" /> + <bpmn:sequenceFlow id="SequenceFlow_06wt67a" sourceRef="ServiceTask_3" targetRef="EndEvent_1wyjfsw" /> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="BuildingBlockValidatorRunnerTest"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> + <dc:Bounds x="320" y="131" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="293" y="167" width="90" height="20" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0k9j83h_di" bpmnElement="ServiceTask_1"> + <dc:Bounds x="435" y="109" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_06izmow_di" bpmnElement="ServiceTask_2"> + <dc:Bounds x="685" y="109" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0vof4nz_di" bpmnElement="SequenceFlow_0vof4nz"> + <di:waypoint xsi:type="dc:Point" x="356" y="149" /> + <di:waypoint xsi:type="dc:Point" x="435" y="149" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="395.5" y="128" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_1wyjfsw_di" bpmnElement="EndEvent_1wyjfsw"> + <dc:Bounds x="1106" y="131" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1079" y="171" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_1xxf97p_di" bpmnElement="IntermediateCatchEvent_1"> + <dc:Bounds x="596" y="131" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="587" y="106" width="55" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_14nr57b_di" bpmnElement="SequenceFlow_14nr57b"> + <di:waypoint xsi:type="dc:Point" x="535" y="149" /> + <di:waypoint xsi:type="dc:Point" x="596" y="149" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="565.5" y="128" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1vsqhv8_di" bpmnElement="SequenceFlow_1vsqhv8"> + <di:waypoint xsi:type="dc:Point" x="632" y="149" /> + <di:waypoint xsi:type="dc:Point" x="685" y="149" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="658.5" y="128" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="IntermediateCatchEvent_1hx48zh_di" bpmnElement="IntermediateCatchEvent_2"> + <dc:Bounds x="853" y="131" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="844" y="106" width="55" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_059dhj6_di" bpmnElement="ServiceTask_3"> + <dc:Bounds x="943" y="109" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_04xg7yh_di" bpmnElement="SequenceFlow_04xg7yh"> + <di:waypoint xsi:type="dc:Point" x="785" y="149" /> + <di:waypoint xsi:type="dc:Point" x="853" y="149" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="819" y="128" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0w8ajcb_di" bpmnElement="SequenceFlow_0w8ajcb"> + <di:waypoint xsi:type="dc:Point" x="889" y="149" /> + <di:waypoint xsi:type="dc:Point" x="943" y="149" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="916" y="128" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_06wt67a_di" bpmnElement="SequenceFlow_06wt67a"> + <di:waypoint xsi:type="dc:Point" x="1043" y="149" /> + <di:waypoint xsi:type="dc:Point" x="1106" y="149" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1074.5" y="128" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy index 3c08779513..1be4989490 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy @@ -240,11 +240,9 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ if(obj.has("result-data")){ JSONObject ob = obj.getJSONArray("result-data").getJSONObject(0) String resourceLink = ob.getString("resource-link") + AAIResourceUri siUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, new URI(resourceLink)) - String[] split = resourceLink.split("/aai/") - String siRelatedLink = "/aai/" + split[1] - - execution.setVariable("PSI_resourceLink", resourceLink) + execution.setVariable("PSI_resourceLink", siUri) }else{ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai") } @@ -277,26 +275,9 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ //AAI PUT AaiUtil aaiUriUtil = new AaiUtil(this) - String aaiEndpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - String siResourceLink= execution.getVariable("PSI_resourceLink") - - String siUri = "" - msoLogger.debug("PSI_resourceLink:" + siResourceLink) - - if(!isBlank(siResourceLink)) { - msoLogger.debug("Incoming PSI Resource Link is: " + siResourceLink) - String[] split = siResourceLink.split("/aai/") - siUri = "/aai/" + split[1] - } - else - { - msg = "Parent Service Link in AAI is null" - msoLogger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") - execution.setVariable("aaiARPath", arUrl) + AAIResourceUri siResourceLink= execution.getVariable("PSI_resourceLink") + AllottedResourceUtils arUtils = new AllottedResourceUtils(this) + execution.setVariable("aaiARPath", arUtils.createARUrl(execution, siResourceLink, allottedResourceId)) msoLogger.debug("GET AllottedResource AAI URL is:\n" + arUrl) String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy index 5f9b4b8ecd..48eb1c85f9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy @@ -20,23 +20,22 @@ package org.onap.so.bpmn.vcpe.scripts; +import static org.apache.commons.lang3.StringUtils.* + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.*; -import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.core.RollbackData -import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.rest.APIResponse - -import java.util.UUID; -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.springframework.web.util.UriUtils; -import static org.apache.commons.lang3.StringUtils.* - +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse /** * This groovy class supports the <class>DoCreateAllottedResourceTXC.bpmn</class> process. @@ -204,26 +203,9 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ //AAI PUT AaiUtil aaiUriUtil = new AaiUtil(this) - String aaiEndpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) - String siResourceLink= execution.getVariable("PSI_resourceLink") - - String siUri = "" - msoLogger.debug("PSI_resourceLink:" + siResourceLink) - - if(!isBlank(siResourceLink)) { - msoLogger.debug("Incoming PSI Resource Link is: " + siResourceLink) - String[] split = siResourceLink.split("/aai/") - siUri = "/aai/" + split[1] - } - else - { - msg = "Parent Service Link in AAI is null" - msoLogger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") - execution.setVariable("aaiARPath", arUrl) + AAIResourceUri siResourceLink= execution.getVariable("PSI_resourceLink") + AllottedResourceUtils arUtils = new AllottedResourceUtils(this) + execution.setVariable("aaiARPath", arUtils.createARUrl(execution, siResourceLink, allottedResourceId)) msoLogger.debug("GET AllottedResource AAI URL is:\n" + arUrl) String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl) 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 87c04d7ecc..38261c0f1a 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 @@ -54,6 +54,7 @@ import org.springframework.stereotype.Component; @Component public class AAIUpdateTasks { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, AAIUpdateTasks.class); + private static final String ALACARTE = "aLaCarte"; private static final String MULTI_STAGE_DESIGN_OFF = "false"; private static final String MULTI_STAGE_DESIGN_ON = "true"; @Autowired @@ -196,7 +197,8 @@ public class AAIUpdateTasks { if (vnf.getModelInfoGenericVnf() != null) { multiStageDesign = vnf.getModelInfoGenericVnf().getMultiStageDesign(); } - if (multiStageDesign != null && multiStageDesign.equalsIgnoreCase(MULTI_STAGE_DESIGN_ON)) { + boolean aLaCarte = (boolean) execution.getVariable(ALACARTE); + if (aLaCarte && multiStageDesign != null && multiStageDesign.equalsIgnoreCase(MULTI_STAGE_DESIGN_ON)) { aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule,vnf,OrchestrationStatus.PENDING_ACTIVATION); } else { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java index 88ae3746ab..b0063c1da1 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java @@ -45,6 +45,7 @@ public class OrchestrationStatusValidator { private static final String UNKNOWN_RESOURCE_TYPE = "Building Block (%s) not set up correctly in Orchestration_Status_Validation table in CatalogDB. ResourceType=(%s), TargetAction=(%s)"; private static final String ORCHESTRATION_VALIDATION_FAIL = "Orchestration Status Validation failed. ResourceType=(%s), TargetAction=(%s), OrchestrationStatus=(%s)"; private static final String ORCHESTRATION_STATUS_VALIDATION_RESULT = "orchestrationStatusValidationResult"; + private static final String ALACARTE = "aLaCarte"; private static final String MULTI_STAGE_DESIGN_OFF = "false"; private static final String MULTI_STAGE_DESIGN_ON = "true"; @@ -62,8 +63,10 @@ public class OrchestrationStatusValidator { execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, null); - String buildingBlockFlowName = execution.getFlowToBeCalled(); + boolean aLaCarte = (boolean) execution.getVariable(ALACARTE); + String buildingBlockFlowName = execution.getFlowToBeCalled(); + BuildingBlockDetail buildingBlockDetail = catalogDbClient.getBuildingBlockDetail(buildingBlockFlowName); if (buildingBlockDetail == null) { @@ -112,7 +115,7 @@ public class OrchestrationStatusValidator { } OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = catalogDbClient.getOrchestrationStatusStateTransitionDirective(buildingBlockDetail.getResourceType(), orchestrationStatus, buildingBlockDetail.getTargetAction()); - if(ResourceType.VF_MODULE.equals(buildingBlockDetail.getResourceType()) && OrchestrationAction.CREATE.equals(buildingBlockDetail.getTargetAction()) && + if(aLaCarte && ResourceType.VF_MODULE.equals(buildingBlockDetail.getResourceType()) && OrchestrationAction.CREATE.equals(buildingBlockDetail.getTargetAction()) && OrchestrationStatus.PENDING_ACTIVATION.equals(orchestrationStatus)) { org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); orchestrationStatusStateTransitionDirective = processPossibleSecondStageofVfModuleCreate(execution, previousOrchestrationStatusValidationResult, @@ -138,11 +141,11 @@ public class OrchestrationStatusValidator { private OrchestrationStatusStateTransitionDirective processPossibleSecondStageofVfModuleCreate(BuildingBlockExecution execution, OrchestrationStatusValidationDirective previousOrchestrationStatusValidationResult, org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf genericVnf, OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective) { if (previousOrchestrationStatusValidationResult != null && previousOrchestrationStatusValidationResult.equals(OrchestrationStatusValidationDirective.SILENT_SUCCESS)) { - String multiStageDesign = "false"; + String multiStageDesign = MULTI_STAGE_DESIGN_OFF; if (genericVnf.getModelInfoGenericVnf() != null) { multiStageDesign = genericVnf.getModelInfoGenericVnf().getMultiStageDesign(); } - if (multiStageDesign != null && multiStageDesign.equalsIgnoreCase("true")) { + if (multiStageDesign != null && multiStageDesign.equalsIgnoreCase(MULTI_STAGE_DESIGN_ON)) { orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.CONTINUE); } } 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 560f2a91bf..1a302c29a7 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 @@ -169,6 +169,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ @Test public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleNoMultiStageTest() throws Exception { + execution.setVariable("aLaCarte", true); ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); modelInfoGenericVnf.setMultiStageDesign("false"); genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf); @@ -179,7 +180,20 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ } @Test + public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleMultiStageButNotAlacarteTest() throws Exception { + execution.setVariable("aLaCarte", false); + ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); + modelInfoGenericVnf.setMultiStageDesign("true"); + genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf); + doNothing().when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED); + aaiUpdateTasks.updateOrchestrationStatusAssignedOrPendingActivationVfModule(execution); + verify(aaiVfModuleResources, times(1)).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED); + assertEquals("", vfModule.getHeatStackId()); + } + + @Test public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleWithMultiStageTest() throws Exception { + execution.setVariable("aLaCarte", true); ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); modelInfoGenericVnf.setMultiStageDesign("true"); genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf); @@ -191,6 +205,7 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ @Test public void updateOrchestrationStatusAssignedOrPendingActivationVfModuleExceptionTest() throws Exception { + execution.setVariable("aLaCarte", true); doThrow(Exception.class).when(aaiVfModuleResources).updateOrchestrationStatusVfModule(vfModule, genericVnf, OrchestrationStatus.ASSIGNED); expectedException.expect(BpmnError.class); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java index fa5081da2f..5ef020d6ed 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorTest.java @@ -51,7 +51,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { public void test_validateOrchestrationStatus() throws Exception { String flowToBeCalled = "AssignServiceInstanceBB"; setServiceInstance().setOrchestrationStatus(OrchestrationStatus.PRECREATED); - + execution.setVariable("aLaCarte", true); execution.setVariable("flowToBeCalled", flowToBeCalled); BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); @@ -91,6 +91,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { si.setConfigurations(configurations); execution.setVariable("flowToBeCalled", flowToBeCalled); + execution.setVariable("aLaCarte", true); BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); buildingBlockDetail.setBuildingBlockName("UnassignFabricConfigurationBB"); @@ -188,6 +189,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { String flowToBeCalled = "UnassignServiceInstanceBB"; execution.setVariable("flowToBeCalled", flowToBeCalled); + execution.setVariable("aLaCarte", true); BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); buildingBlockDetail.setBuildingBlockName("UnassignServiceInstanceBB"); @@ -209,7 +211,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { String flowToBeCalled = "CreateVfModuleBB"; execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS); - + execution.setVariable("aLaCarte", true); execution.setVariable("flowToBeCalled", flowToBeCalled); GenericVnf genericVnf = buildGenericVnf(); @@ -246,7 +248,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { String flowToBeCalled = "CreateVfModuleBB"; execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.CONTINUE); - + execution.setVariable("aLaCarte", true); execution.setVariable("flowToBeCalled", flowToBeCalled); GenericVnf genericVnf = buildGenericVnf(); @@ -282,7 +284,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { String flowToBeCalled = "CreateVfModuleBB"; execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS); - + execution.setVariable("aLaCarte", true); execution.setVariable("flowToBeCalled", flowToBeCalled); GenericVnf genericVnf = buildGenericVnf(); @@ -318,7 +320,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { String flowToBeCalled = "CreateVfModuleBB"; execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS); - + execution.setVariable("aLaCarte", true); execution.setVariable("flowToBeCalled", flowToBeCalled); GenericVnf genericVnf = buildGenericVnf(); @@ -354,7 +356,7 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { String flowToBeCalled = "CreateVfModuleBB"; execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS); - + execution.setVariable("aLaCarte", true); execution.setVariable("flowToBeCalled", flowToBeCalled); GenericVnf genericVnf = buildGenericVnf(); @@ -384,4 +386,40 @@ public class OrchestrationStatusValidatorTest extends BaseTaskTest { assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult")); } + + @Test + public void test_validateOrchestrationStatusSecondStageOfMultiStageWrongAlacarteValueVfModule() throws Exception { + String flowToBeCalled = "CreateVfModuleBB"; + + execution.setVariable("orchestrationStatusValidationResult", OrchestrationStatusValidationDirective.SILENT_SUCCESS); + execution.setVariable("aLaCarte", false); + execution.setVariable("flowToBeCalled", flowToBeCalled); + + GenericVnf genericVnf = buildGenericVnf(); + ModelInfoGenericVnf modelInfoGenericVnf = genericVnf.getModelInfoGenericVnf(); + modelInfoGenericVnf.setMultiStageDesign("true"); + setGenericVnf().setModelInfoGenericVnf(modelInfoGenericVnf); + setVfModule().setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + + BuildingBlockDetail buildingBlockDetail = new BuildingBlockDetail(); + buildingBlockDetail.setBuildingBlockName("CreateVfModuleBB"); + buildingBlockDetail.setId(1); + buildingBlockDetail.setResourceType(ResourceType.VF_MODULE); + buildingBlockDetail.setTargetAction(OrchestrationAction.CREATE); + + doReturn(buildingBlockDetail).when(catalogDbClient).getBuildingBlockDetail(flowToBeCalled); + + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = new OrchestrationStatusStateTransitionDirective(); + orchestrationStatusStateTransitionDirective.setFlowDirective(OrchestrationStatusValidationDirective.SILENT_SUCCESS); + orchestrationStatusStateTransitionDirective.setId(1); + orchestrationStatusStateTransitionDirective.setOrchestrationStatus(OrchestrationStatus.PENDING_ACTIVATION); + orchestrationStatusStateTransitionDirective.setResourceType(ResourceType.VF_MODULE); + orchestrationStatusStateTransitionDirective.setTargetAction(OrchestrationAction.ACTIVATE); + + doReturn(orchestrationStatusStateTransitionDirective).when(catalogDbClient).getOrchestrationStatusStateTransitionDirective(ResourceType.VF_MODULE, OrchestrationStatus.PENDING_ACTIVATION, OrchestrationAction.CREATE); + + orchestrationStatusValidator.validateOrchestrationStatus(execution); + + assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, execution.getVariable("orchestrationStatusValidationResult")); + } } |