diff options
80 files changed, 3069 insertions, 198 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql index 9527986f52..f5c7cd65c2 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql @@ -29,7 +29,8 @@ INSERT INTO northbound_request_ref_lookup(MACRO_ACTION, ACTION, REQUEST_SCOPE, I ('VFModule-Replace-Retain-Assignments', 'replaceInstanceRetainAssignments', 'VfModule', true,true, '7','7', 'DEFAULT', '*'), ('NetworkCollection-Macro-Create', 'createInstance', 'NetworkCollection', false,true, '7','7', 'DEFAULT', '*'), ('NetworkCollection-Macro-Delete', 'deleteInstance', 'NetworkCollection', false,true, '7','7', 'DEFAULT', '*'), -('VFModule-ScaleOut', 'scaleOut', 'VfModule', true, true, '7','7', 'DEFAULT', '*'); +('VFModule-ScaleOut', 'scaleOut', 'VfModule', true, true, '7','7', 'DEFAULT', '*'), +('VNF-InPlaceUpdate', 'inPlaceSoftwareUpdate', 'Vnf', true, true, '7','7', 'DEFAULT', '*'); INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID) VALUES @@ -176,7 +177,26 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FL ('VFModule-Replace-Retain-Assignments', '10', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), ('VFModule-Replace-Retain-Assignments', '11', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), ('VFModule-Replace-Retain-Assignments', '12', 'ChangeModelVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), -('VFModule-Replace-Retain-Assignments', '13', 'ChangeModelServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')); +('VFModule-Replace-Retain-Assignments', '13', 'ChangeModelServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '1', 'VNFCheckPserversLockedFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '2', 'VNFCheckInMaintFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '3', 'VNFSetInMaintFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '4', 'VNFCheckClosedLoopDisabledFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '5', 'VNFSetClosedLoopDisabledFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '6', 'VNFLockActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '7', 'VNFUpgradePreCheckActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '8', 'VNFQuiesceTrafficActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '9', 'VNFStopActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '10', 'VNFSnapShotActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '11', 'VNFStartActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '12', 'VNFUpgradeBackupActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '13', 'VNFUpgradeSoftwareActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '14', 'VNFUpgradePostCheckActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '15', 'VNFResumeTrafficActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '16', 'VNFUnlockActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '17', 'VNFUnsetInMaintFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '18', 'VNFUnsetClosedLoopDisabledFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')); + INSERT INTO rainy_day_handler_macro (FLOW_NAME, SERVICE_TYPE, VNF_TYPE, ERROR_CODE, WORK_STEP, POLICY) @@ -849,3 +869,7 @@ UPDATE rainy_day_handler_macro SET SERVICE_ROLE = '*' WHERE SERVICE_ROLE IS null INSERT INTO vnf_components_recipe (VNF_TYPE, VNF_COMPONENT_TYPE, ACTION, VERSION, ORCHESTRATION_URI, RECIPE_TIMEOUT) VALUES (NULL, 'vfModule', 'replaceInstanceRetainAssignments', '1', '/mso/async/services/WorkflowActionBB', 180); + +UPDATE vnf_recipe +SET ORCHESTRATION_URI = '/mso/async/services/WorkflowActionBB' +WHERE NF_ROLE = 'GR-API-DEFAULT' AND ACTION = 'inPlaceSoftwareUpdate'; diff --git a/adapters/pom.xml b/adapters/pom.xml index 14498c5eff..b96c3744c3 100644 --- a/adapters/pom.xml +++ b/adapters/pom.xml @@ -23,6 +23,7 @@ <module>mso-openstack-adapters</module> <module>mso-vnfm-adapter</module> <module>mso-ve-vnfm-adapter</module> + <module>so-appc-orchestrator</module> </modules> <dependencies> diff --git a/adapters/so-appc-orchestrator/pom.xml b/adapters/so-appc-orchestrator/pom.xml new file mode 100644 index 0000000000..717bcee3fc --- /dev/null +++ b/adapters/so-appc-orchestrator/pom.xml @@ -0,0 +1,221 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.so</groupId> + <artifactId>adapters</artifactId> + <version>1.4.0-SNAPSHOT</version> + </parent> + + <groupId>org.onap.so.adapters</groupId> + <artifactId>so-appc-orchestrator</artifactId> + <packaging>jar</packaging> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <java.version>1.8</java.version> + <appc.client.version>1.6.0-SNAPSHOT</appc.client.version> + </properties> + <name>so-appc-orchestrator</name> + <description>MSO APPC-C Orchestrator</description> + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <version>${springboot.version}</version> + <configuration> + <mainClass>org.onap.so.adapters.appc.orchestrator.AppcOrchestratorApplication</mainClass> + </configuration> + <executions> + <execution> + <goals> + <goal>repackage</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>extract-docker-file</id> + </execution> + </executions> + </plugin> + <plugin> + <groupId>io.fabric8</groupId> + <artifactId>fabric8-maven-plugin</artifactId> + <executions> + <execution> + <id>start</id> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.3</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + <fork>true</fork> + <compilerArgs> + <arg>-parameters</arg> + </compilerArgs> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <executions> + <execution> + <id>default-test</id> + <goals> + <goal>test</goal> + </goals> + <configuration> + <includes> + <include>**/AllTestsTestSuite.java</include> + </includes> + <parallel>suites</parallel> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + <pluginManagement> + <plugins> + <!--This plugin's configuration is used to store Eclipse m2e settings + only. It has no influence on the Maven build itself. --> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId> + org.jvnet.jax-ws-commons + </groupId> + <artifactId> + jaxws-maven-plugin + </artifactId> + <versionRange> + [2.3,) + </versionRange> + <goals> + <goal>wsgen</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore> + </ignore> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + </plugin> + </plugins> + </pluginManagement> + <finalName>${project.artifactId}-${project.version}</finalName> + </build> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.micrometer</groupId> + <artifactId>micrometer-core</artifactId> + </dependency> + <dependency> + <groupId>io.micrometer</groupId> + <artifactId>micrometer-registry-prometheus</artifactId> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>common</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.camunda.bpm</groupId> + <artifactId>camunda-external-task-client</artifactId> + <version>1.1.1</version> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>MSOCommonBPMN</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.appc.client</groupId> + <artifactId>client-lib</artifactId> + <version>${appc.client.version}</version> + <exclusions> + <exclusion> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </exclusion> + <exclusion> + <groupId>org.powermock</groupId> + <artifactId>powermock-module-junit4</artifactId> + </exclusion> + <exclusion> + <groupId>org.powermock</groupId> + <artifactId>powermock-api-mockito</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.onap.so.adapters</groupId> + <artifactId>mso-adapter-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.appc.client</groupId> + <artifactId>client-kit</artifactId> + <version>${appc.client.version}</version> + <exclusions> + <exclusion> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </exclusion> + </exclusions> + </dependency> + <!-- Test Dependencies --> + <dependency> + <groupId>pl.pragmatists</groupId> + <artifactId>JUnitParams</artifactId> + <version>1.0.5</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> +</project> diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/AppcOrchestratorApplication.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/AppcOrchestratorApplication.java new file mode 100644 index 0000000000..258c95ac89 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/AppcOrchestratorApplication.java @@ -0,0 +1,46 @@ +/*- + * ============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.adapters.appc.orchestrator; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @since Version 1.0 + * + */ + +@SpringBootApplication(scanBasePackages = {"org.onap"}) +public class AppcOrchestratorApplication { + + private static final String LOGS_DIR = "logs_dir"; + + private static void setLogsDir() { + if (System.getProperty(LOGS_DIR) == null) { + System.getProperties().setProperty(LOGS_DIR, "./logs/appcorch/"); + } + } + + public static void main(String... args) { + SpringApplication.run(AppcOrchestratorApplication.class, args); + setLogsDir(); + } +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerCallback.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerCallback.java new file mode 100644 index 0000000000..1f73000299 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerCallback.java @@ -0,0 +1,84 @@ +/*- + * ============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.adapters.appc.orchestrator.client; + +import org.camunda.bpm.client.task.ExternalTask; +import org.camunda.bpm.client.task.ExternalTaskService; +import org.onap.appc.client.lcm.api.ResponseHandler; +import org.onap.appc.client.lcm.exceptions.AppcClientException; +import org.onap.appc.client.lcm.model.Status; +import org.onap.so.adapters.appc.orchestrator.client.StatusCategory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ApplicationControllerCallback<T> implements ResponseHandler<T> { + + private static final Logger logger = LoggerFactory.getLogger(ApplicationControllerCallback.class); + + private final ExternalTask externalTask; + private final ExternalTaskService externalTaskService; + private final ApplicationControllerSupport appCSupport; + + public ApplicationControllerCallback(ExternalTask externalTask, ExternalTaskService externalTaskService, + ApplicationControllerSupport appCSupport) { + this.externalTask = externalTask; + this.externalTaskService = externalTaskService; + this.appCSupport = appCSupport; + } + + @Override + public void onResponse(T response) { + logger.info("ON RESPONSE IN CALLBACK"); + + Status status = appCSupport.getStatusFromGenericResponse(response); + + logger.info("Status code is: " + status.getCode()); + logger.info("Status message is: " + status.getMessage()); + + if (appCSupport.getFinalityOf(status)) { + logger.debug("Obtained final status, complete the task"); + completeExternalTask(externalTask, externalTaskService, status); + } else { + logger.debug("Intermediate status, continue the task"); + } + } + + @Override + public void onException(AppcClientException exception) { + + logger.info("ON EXCEPTION IN CALLBACK"); + logger.info("Exception from APPC: " + exception.getMessage()); + Status exceptionStatus = appCSupport.buildStatusFromAppcException(exception); + completeExternalTask(externalTask, externalTaskService, exceptionStatus); + } + + private void completeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService, + Status status) { + + if (appCSupport.getCategoryOf(status).equals(StatusCategory.NORMAL)) { + externalTaskService.complete(externalTask); + logger.debug("The External Task Id: {} Successful", externalTask.getId()); + } else { + logger.debug("The External Task Id: {} Failed", externalTask.getId()); + externalTaskService.handleBpmnError(externalTask, "MSOWorkflowException", status.getMessage()); + } + } +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java new file mode 100644 index 0000000000..20093be6a4 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java @@ -0,0 +1,244 @@ +/*- + * ============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.adapters.appc.orchestrator.client; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.time.Instant; +import java.util.Optional; +import java.util.Properties; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +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; +import org.onap.appc.client.lcm.api.AppcClientServiceFactoryProvider; +import org.onap.appc.client.lcm.api.AppcLifeCycleManagerServiceFactory; +import org.onap.appc.client.lcm.api.ApplicationContext; +import org.onap.appc.client.lcm.api.LifeCycleManagerStateful; +import org.onap.appc.client.lcm.exceptions.AppcClientException; +import org.onap.appc.client.lcm.model.Action; +import org.onap.appc.client.lcm.model.ActionIdentifiers; +import org.onap.appc.client.lcm.model.CommonHeader; +import org.onap.appc.client.lcm.model.Flags; +import org.onap.appc.client.lcm.model.Flags.Force; +import org.onap.appc.client.lcm.model.Flags.Mode; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerOrchestratorException; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerSupport; +import org.onap.so.adapters.appc.orchestrator.client.StatusCategory; +import org.onap.appc.client.lcm.model.Payload; +import org.onap.appc.client.lcm.model.Status; +import org.onap.appc.client.lcm.model.ZULU; + +@Component +public class ApplicationControllerClient { + + @Autowired + public Environment env; + + public static final String DEFAULT_CONTROLLER_TYPE = "APPC"; + + private static final String CLIENT_NAME = "MSO"; + + private static final String API_VER = "2.00"; + private static final String ORIGINATOR_ID = "MSO"; + private static final int FLAGS_TTL = 65000; + private static Logger logger = LoggerFactory.getLogger(ApplicationControllerClient.class); + + @Autowired + private ApplicationControllerSupport appCSupport; + + // APPC gave us an API where the controllerType is configured in the + // client object, which is not what we asked for. We asked for an API + // in which the client would have additional methods that could take + // the controllerType as a parameter, so that we would not need to + // maintain multiple client objects. This map should be removed when + // the (hopefully short-term) controllerType becomes obsolete. + + private String controllerType = DEFAULT_CONTROLLER_TYPE; + + private static ConcurrentHashMap<String, LifeCycleManagerStateful> appCClients = new ConcurrentHashMap<>(); + + /** + * Creates an ApplicationControllerClient for the specified controller type. + * + * @param controllerType the controller type: "appc" or "sdnc". + */ + public void setControllerType(String controllerType) { + if (controllerType == null) { + controllerType = DEFAULT_CONTROLLER_TYPE; + } + this.controllerType = controllerType.toUpperCase(); + } + + /** + * Gets the controller type. + * + * @return the controllertype + */ + public String getControllerType() { + return controllerType; + } + + /** + * Returns the AppC client object associated with this ApplicationControllerClient. AppC client objects are shared + * objects. One is created if it does not exist. + * + * @return the client object, or null if creation failed + */ + public LifeCycleManagerStateful getAppCClient() { + return appCClients.computeIfAbsent(controllerType, k -> createAppCClient(k)); + } + + protected LifeCycleManagerStateful createAppCClient(String controllerType) { + + try { + if (controllerType == null) { + controllerType = DEFAULT_CONTROLLER_TYPE; + } + controllerType = controllerType.toUpperCase(); + return AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class) + .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties(controllerType)); + } catch (AppcClientException e) { + logger.error("Error in getting LifeCycleManagerStateful: {}", e.getMessage(), e); + // This null value will cause NullPointerException when used later. + // Error handling could certainly be improved here. + return null; + } + } + + public Status vnfCommand(Action action, String requestId, String vnfId, Optional<String> vserverId, + Optional<String> request, String controllerType, ApplicationControllerCallback listener) + throws ApplicationControllerOrchestratorException { + this.setControllerType(controllerType); + Status status; + ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); + actionIdentifiers.setVnfId(vnfId); + if (vserverId.isPresent()) { + actionIdentifiers.setVserverId(vserverId.get()); + } + Payload payload = null; + if (request.isPresent()) { + payload = new Payload(request.get()); + + } + status = runCommand(action, actionIdentifiers, payload, requestId, listener); + if (appCSupport.getCategoryOf(status).equals(StatusCategory.ERROR)) { + throw new ApplicationControllerOrchestratorException(status.getMessage(), status.getCode()); + } else { + return status; + } + } + + + public Status runCommand(Action action, org.onap.appc.client.lcm.model.ActionIdentifiers actionIdentifiers, + org.onap.appc.client.lcm.model.Payload payload, String requestID, ApplicationControllerCallback listener) + throws ApplicationControllerOrchestratorException { + Status status; + Object requestObject; + requestObject = createRequest(action, actionIdentifiers, payload, requestID); + appCSupport.logLCMMessage(requestObject); + LifeCycleManagerStateful client = getAppCClient(); + Method lcmMethod = appCSupport.getAPIMethod(action.name(), client, true); + try { + Object response = lcmMethod.invoke(client, requestObject, listener); + if (response != null) { + return appCSupport.getStatusFromGenericResponse(response); + } else { + return new Status(); + } + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + throw new RuntimeException(String.format("%s : %s", "Unable to invoke action", action.toString()), e); + } + } + + protected Properties getLCMProperties() { + return getLCMProperties("appc"); + } + + protected Properties getLCMProperties(String controllerType) { + Properties properties = new Properties(); + + properties.put("topic.read", this.env.getProperty("appc.client.topic.read.name")); + properties.put("topic.write", this.env.getProperty("appc.client.topic.write")); + properties.put("SDNC-topic.read", this.env.getProperty("appc.client.topic.sdnc.read")); + properties.put("SDNC-topic.write", this.env.getProperty("appc.client.topic.sdnc.write")); + properties.put("topic.read.timeout", this.env.getProperty("appc.client.topic.read.timeout")); + properties.put("client.response.timeout", this.env.getProperty("appc.client.response.timeout")); + properties.put("poolMembers", this.env.getProperty("appc.client.poolMembers")); + properties.put("controllerType", controllerType); + properties.put("client.key", this.env.getProperty("appc.client.key")); + properties.put("client.secret", this.env.getProperty("appc.client.secret")); + properties.put("client.name", CLIENT_NAME); + properties.put("service", this.env.getProperty("appc.client.service")); + return properties; + } + + public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId) { + Object requestObject = appCSupport.getInput(action.name()); + + + try { + CommonHeader commonHeader = buildCommonHeader(requestId); + requestObject.getClass().getDeclaredMethod("setCommonHeader", CommonHeader.class).invoke(requestObject, + commonHeader); + requestObject.getClass().getDeclaredMethod("setAction", Action.class).invoke(requestObject, action); + requestObject.getClass().getDeclaredMethod("setActionIdentifiers", ActionIdentifiers.class) + .invoke(requestObject, identifier); + if (payload != null) { + logger.info("payload in RunCommand: " + payload.getValue()); + requestObject.getClass().getDeclaredMethod("setPayload", Payload.class).invoke(requestObject, payload); + } + } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { + logger.error("Error building Appc request", e); + } + return requestObject; + } + + private CommonHeader buildCommonHeader(String requestId) { + CommonHeader commonHeader = new CommonHeader(); + commonHeader.setApiVer(API_VER); + commonHeader.setOriginatorId(ORIGINATOR_ID); + commonHeader.setRequestId(requestId == null ? UUID.randomUUID().toString() : requestId); + commonHeader.setSubRequestId(UUID.randomUUID().toString()); + Flags flags = new Flags(); + String flagsMode = "NORMAL"; + Mode mode = Mode.valueOf(flagsMode); + flags.setMode(mode); + String flagsForce = "FALSE"; + Force force = Force.valueOf(flagsForce); + flags.setForce(force); + flags.setTtl(FLAGS_TTL); + commonHeader.setFlags(flags); + Instant timestamp = Instant.now(); + ZULU zulu = new ZULU(timestamp.toString()); + commonHeader.setTimestamp(zulu); + return commonHeader; + } + + public Flags createRequestFlags() { + Flags flags = new Flags(); + flags.setTtl(6000); + return flags; + } +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerOrchestratorException.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerOrchestratorException.java new file mode 100644 index 0000000000..cc980a489d --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerOrchestratorException.java @@ -0,0 +1,37 @@ +/*- + * ============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.adapters.appc.orchestrator.client; + + +public class ApplicationControllerOrchestratorException extends Exception { + + private static final long serialVersionUID = 2594894543585595494L; + private final int appcCode; + + public ApplicationControllerOrchestratorException(String message, int code) { + super(message); + appcCode = code; + } + + public int getAppcCode() { + return appcCode; + } +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupport.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupport.java new file mode 100644 index 0000000000..90ab24cb86 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupport.java @@ -0,0 +1,207 @@ +/*- + * ============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.adapters.appc.orchestrator.client; + +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import org.onap.appc.client.lcm.api.LifeCycleManagerStateful; +import org.onap.appc.client.lcm.api.ResponseHandler; +import org.onap.appc.client.lcm.exceptions.AppcClientException; +import org.onap.appc.client.lcm.model.Status; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectWriter; + + +@Component +public class ApplicationControllerSupport { + + private static final int ACCEPT_SERIES = 100; + private static final int ERROR_SERIES = 200; + private static final int REJECT_SERIES = 300; + private static final int SUCCESS_SERIES = 400; + private static final int SUCCESS_STATUS = SUCCESS_SERIES; + private static final int PARTIAL_SERIES = 500; + private static final int PARTIAL_SUCCESS_STATUS = PARTIAL_SERIES; + private static final int PARTIAL_FAILURE_STATUS = PARTIAL_SERIES + 1; + + private static Logger logger = LoggerFactory.getLogger(ApplicationControllerSupport.class); + private String lcmModelPackage = "org.onap.appc.client.lcm.model"; + + /** + * @param action + * @return + * @throws ClassNotFoundException + * @throws InstantiationException + * @throws IllegalAccessException + */ + public Object getInput(String action) { + try { + return getInputClass(action).newInstance(); + } catch (IllegalAccessException | InstantiationException e) { + throw new RuntimeException( + String.format("%s : %s", "Unable to instantiate viable LCM Kit input class for action", action), e); + } + } + + /** + * @param action + * @return + * @throws ClassNotFoundException + */ + public Method getAPIMethod(String action, LifeCycleManagerStateful lcmStateful, boolean async) { + Method[] methods = lcmStateful.getClass().getMethods(); + for (Method method : methods) { + if (method.getName().equalsIgnoreCase(action)) { + Class<?>[] methodParameterTypes = method.getParameterTypes(); + if (methodParameterTypes.length > 0) { + if (getInputClass(action).equals(methodParameterTypes[0])) { + if (async) { + if (methodParameterTypes.length == 2 + && ResponseHandler.class.isAssignableFrom(methodParameterTypes[1])) { + return method; + } + } else if (methodParameterTypes.length == 1) { + return method; + } + } + } + } + } + throw new RuntimeException(String.format("%s : %s, async=%b", + "Unable to derive viable LCM Kit API method for action", action, async)); + } + + public Status getStatusFromGenericResponse(Object response) { + Method statusReader = getBeanPropertyMethodFor(response.getClass(), "status", false); + if (statusReader != null) { + try { + return (Status) statusReader.invoke(response); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + logger.error("Unable to obtain status from LCM Kit response", e); + } + } + return new Status(); + } + + public StatusCategory getCategoryOf(Status status) { + int codeSeries = status.getCode() - (status.getCode() % 100); + switch (codeSeries) { + case ACCEPT_SERIES: + return StatusCategory.NORMAL; + case ERROR_SERIES: + case REJECT_SERIES: + return StatusCategory.ERROR; + case SUCCESS_SERIES: + return status.getCode() == SUCCESS_STATUS ? StatusCategory.NORMAL : StatusCategory.ERROR; + case PARTIAL_SERIES: + switch (status.getCode()) { + case PARTIAL_SUCCESS_STATUS: + return StatusCategory.NORMAL; + case PARTIAL_FAILURE_STATUS: + return StatusCategory.ERROR; + default: + return StatusCategory.WARNING; + } + default: + return StatusCategory.WARNING; + } + } + + public boolean getFinalityOf(Status status) { + int codeSeries = status.getCode() - (status.getCode() % 100); + switch (codeSeries) { + case ACCEPT_SERIES: + case PARTIAL_SERIES: + return false; + case ERROR_SERIES: + case REJECT_SERIES: + case SUCCESS_SERIES: + return true; + default: + return true; + } + } + + private Method getBeanPropertyMethodFor(Class<?> clazz, String propertyName, boolean isWriter) { + BeanInfo beanInfo; + try { + beanInfo = Introspector.getBeanInfo(clazz, Object.class); + } catch (IntrospectionException e) { + throw new RuntimeException( + String.format("Unable to produce bean property method for class : %s, property : %s, writer=%b", + clazz.getName(), propertyName, isWriter), + e); + } + PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); + for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { + if (propertyDescriptor.getName().equals(propertyName)) { + return isWriter ? propertyDescriptor.getWriteMethod() : propertyDescriptor.getReadMethod(); + } + } + throw new RuntimeException( + String.format("Unable to produce bean property method for class : %s, property : %s, writer=%b", + clazz.getName(), propertyName, isWriter)); + } + + /** + * @param action + * @return + * @throws ClassNotFoundException + */ + private Class<?> getInputClass(String action) { + try { + return Class.forName(lcmModelPackage + '.' + action + "Input"); + } catch (ClassNotFoundException e) { + throw new RuntimeException(String.format("%s : %s using package : %s", + "Unable to identify viable LCM Kit input class for action", action, lcmModelPackage), e); + } + } + + + public void logLCMMessage(Object message) { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.setSerializationInclusion(Include.NON_NULL); + ObjectWriter writer = objectMapper.writerWithDefaultPrettyPrinter(); + String inputAsJSON; + try { + inputAsJSON = writer.writeValueAsString(message); + logger.info("LCM Kit input message follows: {}", inputAsJSON); + } catch (JsonProcessingException e) { + logger.error("Error in logging LCM Message", e); + } + } + + public Status buildStatusFromAppcException(AppcClientException exception) { + Status exceptionStatus = new Status(); + exceptionStatus.setCode(200); + exceptionStatus.setMessage("Exception on APPC request: " + exception.getMessage()); + return exceptionStatus; + } +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/StatusCategory.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/StatusCategory.java new file mode 100644 index 0000000000..27160ef981 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/StatusCategory.java @@ -0,0 +1,16 @@ +package org.onap.so.adapters.appc.orchestrator.client; + +public enum StatusCategory { + NORMAL("normal"), WARNING("warning"), ERROR("error"); + + private final String category; + + private StatusCategory(final String category) { + this.category = category; + } + + @Override + public String toString() { + return category; + } +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/ConfigurationParameters.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/ConfigurationParameters.java new file mode 100644 index 0000000000..b065e9a0c3 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/ConfigurationParameters.java @@ -0,0 +1,53 @@ +package org.onap.so.adapters.appc.orchestrator.client.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ConfigurationParameters { + + @JsonProperty("vnf_name") + private String vnfName; + @JsonProperty("book_name") + private String bookName; + @JsonProperty("node_list") + private String nodeList; + @JsonProperty("file_parameter_content") + private String fileParameterContent; + + + @JsonProperty("vnf_name") + public String getVnfName() { + return vnfName; + } + + @JsonProperty("vnf_name") + public void setVnfName(String vnfName) { + this.vnfName = vnfName; + } + + public String getBookName() { + return bookName; + } + + public void setBookName(String bookName) { + this.bookName = bookName; + } + + public String getNodeList() { + return nodeList; + } + + public void setNodeList(String nodeList) { + this.nodeList = nodeList; + } + + public String getFileParameterContent() { + return fileParameterContent; + } + + public void setFileParameterContent(String fileParameterContent) { + this.fileParameterContent = fileParameterContent; + } + +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/Identity.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/Identity.java new file mode 100644 index 0000000000..912441ad9a --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/Identity.java @@ -0,0 +1,24 @@ +package org.onap.so.adapters.appc.orchestrator.client.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"identity-url"}) +public class Identity { + + @JsonProperty("identity-url") + private String identityUrl; + + @JsonProperty("identity-url") + public String getIdentityUrl() { + return identityUrl; + } + + @JsonProperty("identity-url") + public void setIdentityUrl(String identityUrl) { + this.identityUrl = identityUrl; + } + +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/Parameters.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/Parameters.java new file mode 100644 index 0000000000..9b0385bd7a --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/Parameters.java @@ -0,0 +1,99 @@ +package org.onap.so.adapters.appc.orchestrator.client.beans; + + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"vm-id", "identity-url", "old_software_version", "new_software_version", "operations_timeout", + "request-parameters", "configuration-parameters"}) +public class Parameters { + + @JsonProperty("vm-id") + private String vmId; + @JsonProperty("identity-url") + private String identityUrl; + @JsonProperty("operations_timeout") + private String operationsTimeout; + @JsonProperty("existing_software_version") + private String existingSoftwareVersion; + @JsonProperty("new_software_version") + private String newSoftwareVersion; + @JsonProperty("request-parameters") + private RequestParameters requestParameters; + @JsonProperty("configuration-parameters") + private ConfigurationParameters configurationParameters; + + @JsonProperty("request-parameters") + public RequestParameters getRequestParameters() { + return requestParameters; + } + + @JsonProperty("request-parameters") + public void setRequestParameters(RequestParameters requestParameters) { + this.requestParameters = requestParameters; + } + + @JsonProperty("configuration-parameters") + public ConfigurationParameters getConfigurationParameters() { + return configurationParameters; + } + + @JsonProperty("configuration-parameters") + public void setConfigurationParameters(ConfigurationParameters configurationParameters) { + this.configurationParameters = configurationParameters; + } + + @JsonProperty("vm-id") + public String getVmId() { + return vmId; + } + + @JsonProperty("vm-id") + public void setVmId(String vmId) { + this.vmId = vmId; + } + + @JsonProperty("identity-url") + public String getIdentityUrl() { + return identityUrl; + } + + @JsonProperty("identity-url") + public void setIdentityUrl(String identityUrl) { + this.identityUrl = identityUrl; + } + + @JsonProperty("operations_timeout") + public String getOperationsTimeout() { + return operationsTimeout; + } + + @JsonProperty("operations_timeout") + public void setOperationsTimeout(String operationsTimeout) { + this.operationsTimeout = operationsTimeout; + } + + @JsonProperty("existing_software_version") + public String getExistingSoftwareVersion() { + return existingSoftwareVersion; + } + + @JsonProperty("existing_software_version") + public void setExistingSoftwareVersion(String existingSoftwareVersion) { + this.existingSoftwareVersion = existingSoftwareVersion; + } + + @JsonProperty("new_software_version") + public String getNewSoftwareVersion() { + return newSoftwareVersion; + } + + @JsonProperty("new_software_version") + public void setNewSoftwareVersion(String newSoftwareVersion) { + this.newSoftwareVersion = newSoftwareVersion; + } + + +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/RequestParameters.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/RequestParameters.java new file mode 100644 index 0000000000..ddc0a0ea3d --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/RequestParameters.java @@ -0,0 +1,59 @@ +package org.onap.so.adapters.appc.orchestrator.client.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class RequestParameters { + + @JsonProperty("vnf-host-ip-address") + private String vnfHostIpAddress; + @JsonProperty("vf-module-id") + private String vfModuleId; + @JsonProperty("vnf-name") + private String vnfName; + @JsonProperty("host-ip-address") + private String hostIpAddress; + + public String getVnfHostIpAddress() { + return vnfHostIpAddress; + } + + public void setVnfHostIpAddress(String vnfHostIpAddress) { + this.vnfHostIpAddress = vnfHostIpAddress; + } + + public String getVfModuleId() { + return vfModuleId; + } + + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + + public String getVnfName() { + return vnfName; + } + + public void setVnfName(String vnfName) { + this.vnfName = vnfName; + } + + public String getHostIpAddress() { + return hostIpAddress; + } + + public void setHostIpAddress(String hostIpAddress) { + this.hostIpAddress = hostIpAddress; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("RequestParametersConfigScaleOut{"); + sb.append("vnf-host-ip-address=").append(vnfHostIpAddress); + sb.append(", vf-module-id='").append(vfModuleId); + sb.append('}'); + return sb.toString(); + } + +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTask.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTask.java new file mode 100644 index 0000000000..181d114cc0 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTask.java @@ -0,0 +1,50 @@ +package org.onap.so.adapters.appc.orchestrator.service; + +import org.camunda.bpm.client.task.ExternalTask; +import org.camunda.bpm.client.task.ExternalTaskService; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerSupport; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; +import org.onap.so.externaltasks.logging.AuditMDCSetup; +import org.onap.so.utils.ExternalTaskUtils; +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; +import org.onap.appc.client.lcm.model.Status; + +@Component +public class ApplicationControllerTask extends ExternalTaskUtils { + + private static final Logger logger = LoggerFactory.getLogger(ApplicationControllerTask.class); + + @Autowired + public Environment env; + + @Autowired + public ApplicationControllerTaskImpl applicationControllerTaskImpl; + + @Autowired + public ApplicationControllerSupport applicationControllerSupport; + + @Autowired + private AuditMDCSetup mdcSetup; + + protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { + mdcSetup.setupMDC(externalTask); + ApplicationControllerTaskRequest request = externalTask.getVariable("appcOrchestratorRequest"); + String msoRequestId = externalTask.getVariable("mso-request-id"); + logger.debug("Starting External Task for RequestId: {} ", msoRequestId); + Status status = null; + ApplicationControllerCallback listener = + new ApplicationControllerCallback(externalTask, externalTaskService, applicationControllerSupport); + + try { + status = applicationControllerTaskImpl.execute(msoRequestId, request, listener); + } catch (Exception e) { + logger.error("Error while calling appc", e.getMessage()); + } + } + +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java new file mode 100644 index 0000000000..a174ccb05a --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java @@ -0,0 +1,112 @@ +package org.onap.so.adapters.appc.orchestrator.service; + +import java.util.Optional; +import org.onap.appc.client.lcm.model.Status; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerClient; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerOrchestratorException; +import org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters; +import org.onap.so.adapters.appc.orchestrator.client.beans.Identity; +import org.onap.so.adapters.appc.orchestrator.client.beans.Parameters; +import org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVm; +import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.JsonProcessingException; + +@Component +public class ApplicationControllerTaskImpl { + + @Autowired + private ApplicationControllerClient appcClient; + + public Status execute(String msoRequestId, ApplicationControllerTaskRequest request, + ApplicationControllerCallback listener) + throws JsonProcessingException, ApplicationControllerOrchestratorException { + Status status = null; + GraphInventoryCommonObjectMapperProvider mapper = new GraphInventoryCommonObjectMapperProvider(); + Optional<String> payload = Optional.empty(); + String vmId = null; + Optional<String> vserverId = Optional.empty(); + Parameters parameters = new Parameters(); + ConfigurationParameters configParams = new ConfigurationParameters(); + + switch (request.getAction()) { + case HealthCheck: + RequestParameters requestParams = new RequestParameters(); + requestParams.setHostIpAddress(request.getApplicationControllerVnf().getVnfHostIpAddress()); + parameters.setRequestParameters(requestParams); + payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + break; + case ResumeTraffic: + configParams.setVnfName(request.getApplicationControllerVnf().getVnfName()); + parameters.setConfigurationParameters(configParams); + payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + break; + case Start: + case Stop: + Identity identity = new Identity(); + identity.setIdentityUrl(request.getIdentityUrl()); + payload = Optional.of((mapper.getMapper().writeValueAsString(identity))); + break; + case Unlock: + case Lock: + break; + case QuiesceTraffic: + parameters.setOperationsTimeout(request.getOperationsTimeout()); + payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + break; + case DistributeTraffic: + configParams.setBookName(request.getBookName()); + configParams.setNodeList(request.getNodeList()); + configParams.setFileParameterContent(request.getFileParameters()); + configParams.setVnfName(request.getApplicationControllerVnf().getVnfName()); + parameters.setConfigurationParameters(configParams); + payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + break; + case DistributeTrafficCheck: + configParams.setBookName(request.getBookName()); + configParams.setNodeList(request.getNodeList()); + configParams.setFileParameterContent(request.getFileParameters()); + configParams.setVnfName(request.getApplicationControllerVnf().getVnfName()); + parameters.setConfigurationParameters(configParams); + payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + break; + case ConfigModify: + case ConfigScaleOut: + break; + case UpgradePreCheck: + case UpgradePostCheck: + case UpgradeSoftware: + case UpgradeBackup: + parameters.setExistingSoftwareVersion(request.getExistingSoftwareVersion()); + parameters.setNewSoftwareVersion(request.getNewSoftwareVersion()); + payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + break; + case ActionStatus: + break; + case Snapshot: + ApplicationControllerVm applicationControllerVm = + request.getApplicationControllerVnf().getApplicationControllerVm(); + if (applicationControllerVm != null) { + vmId = request.getApplicationControllerVnf().getApplicationControllerVm().getVmId(); + parameters.setVmId(vmId); + payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + vserverId = Optional + .of(request.getApplicationControllerVnf().getApplicationControllerVm().getVserverId()); + } + default: + // errorMessage = "Unable to idenify Action request for AppCClient"; + break; + } + + status = appcClient.vnfCommand(request.getAction(), msoRequestId, + request.getApplicationControllerVnf().getVnfId(), vserverId, payload, request.getControllerType(), + listener); + + return status; + } + +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskService.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskService.java new file mode 100644 index 0000000000..2a33124eac --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskService.java @@ -0,0 +1,31 @@ +package org.onap.so.adapters.appc.orchestrator.service; + +import javax.annotation.PostConstruct; +import org.onap.so.utils.ExternalTaskServiceUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Profile; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +@Component +@Profile("!test") +public class ApplicationControllerTaskService { + + @Autowired + public Environment env; + + @Autowired + private ApplicationControllerTask appcOrchestrator; + + @Autowired + private ExternalTaskServiceUtils externalTaskServiceUtils; + + @PostConstruct + public void appcOrchestrator() throws Exception { + for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { + externalTaskServiceUtils.createExternalTaskClient().subscribe("AppcService").lockDuration(604800000) + .handler(appcOrchestrator::executeExternalTask).open(); + } + } + +} diff --git a/adapters/so-appc-orchestrator/src/main/resources/application.yaml b/adapters/so-appc-orchestrator/src/main/resources/application.yaml new file mode 100644 index 0000000000..c0c5962ea2 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/resources/application.yaml @@ -0,0 +1,18 @@ +server: + port: 8080 + tomcat: + max-threads: 50 + +#Actuator +management: + endpoints: + web: + base-path: /manage + exposure: + include: "*" + metrics: + se-global-registry: false + export: + prometheus: + enabled: true # Whether exporting of metrics to Prometheus is enabled. + step: 1m # Step size (i.e. reporting frequency) to use.
\ No newline at end of file diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/TestApplication.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/TestApplication.java new file mode 100644 index 0000000000..fe965b4444 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/TestApplication.java @@ -0,0 +1,43 @@ +package org.onap.so; +/*- + * ============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========================================================= + */ + + + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.ComponentScan.Filter; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Profile; + +@SpringBootApplication +@Profile("test") +@ComponentScan(basePackages = {"org.onap.so"}, + excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)}) +public class TestApplication { + public static void main(String... args) { + SpringApplication.run(TestApplication.class, args); + System.getProperties().setProperty("mso.db", "MARIADB"); + System.getProperties().setProperty("server.name", "Springboot"); + + + } +} diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerCallbackTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerCallbackTest.java new file mode 100644 index 0000000000..90f5a44752 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerCallbackTest.java @@ -0,0 +1,113 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017-2019 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.adapters.appc.orchestrator.client; + +import static org.hamcrest.CoreMatchers.any; +import static org.mockito.Mockito.doReturn; +import org.camunda.bpm.client.task.ExternalTask; +import org.camunda.bpm.client.task.ExternalTaskService; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerSupport; +import org.onap.appc.client.lcm.model.Status; +import org.onap.appc.client.lcm.exceptions.AppcClientException; +import org.onap.appc.client.lcm.model.ResumeTrafficOutput; + +public class ApplicationControllerCallbackTest { + + @InjectMocks + ApplicationControllerCallback appcTaskCallback; + + @Mock + ApplicationControllerSupport applicationControllerSupport; + + @Mock + ExternalTask mockExternalTask; + + @Mock + ExternalTaskService mockExternalTaskService; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + appcTaskCallback = new ApplicationControllerCallback(mockExternalTask, mockExternalTaskService, + applicationControllerSupport); + } + + @Test + public void onResponse_appcCallback_success_Test() throws Exception { + Status status = new Status(); + status.setCode(400); + ResumeTrafficOutput response = new ResumeTrafficOutput(); + response.setStatus(status); + doReturn(status).when(applicationControllerSupport).getStatusFromGenericResponse(response); + doReturn(true).when(applicationControllerSupport).getFinalityOf(status); + doReturn(StatusCategory.NORMAL).when(applicationControllerSupport).getCategoryOf(status); + appcTaskCallback.onResponse(response); + Mockito.verify(mockExternalTaskService).complete(mockExternalTask); + } + + @Test + public void onResponse_appcCallback_intermediateResponse_Test() throws Exception { + Status status = new Status(); + status.setCode(100); + ResumeTrafficOutput response = new ResumeTrafficOutput(); + response.setStatus(status); + doReturn(status).when(applicationControllerSupport).getStatusFromGenericResponse(response); + appcTaskCallback.onResponse(response); + Mockito.verifyZeroInteractions(mockExternalTaskService); + } + + @Test + public void onResponse_appcCallback_failure_Test() throws Exception { + String testFailure = "test failure"; + Status status = new Status(); + status.setCode(200); + status.setMessage(testFailure); + ResumeTrafficOutput response = new ResumeTrafficOutput(); + response.setStatus(status); + doReturn(status).when(applicationControllerSupport).getStatusFromGenericResponse(response); + doReturn(true).when(applicationControllerSupport).getFinalityOf(status); + doReturn(StatusCategory.ERROR).when(applicationControllerSupport).getCategoryOf(status); + appcTaskCallback.onResponse(response); + Mockito.verify(mockExternalTaskService).handleBpmnError(mockExternalTask, "MSOWorkflowException", testFailure); + } + + @Test + public void onException_appcCallback_failure_Test() throws Exception { + String testFailure = "test failure"; + AppcClientException appcException = new AppcClientException(testFailure); + Status status = new Status(); + status.setCode(200); + String exceptionMessage = "Exception on APPC request: " + testFailure; + status.setMessage(exceptionMessage); + doReturn(status).when(applicationControllerSupport).buildStatusFromAppcException(appcException); + doReturn(StatusCategory.ERROR).when(applicationControllerSupport).getCategoryOf(status); + appcTaskCallback.onException(appcException); + Mockito.verify(mockExternalTaskService).handleBpmnError(mockExternalTask, "MSOWorkflowException", + exceptionMessage); + } +} diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupportTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupportTest.java new file mode 100644 index 0000000000..2dd2fd7ac8 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupportTest.java @@ -0,0 +1,79 @@ +/*- + * ============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.adapters.appc.orchestrator.client; + +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.appc.client.lcm.exceptions.AppcClientException; +import org.onap.appc.client.lcm.model.Status; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerSupport; +import org.onap.so.adapters.appc.orchestrator.client.StatusCategory; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +@RunWith(JUnitParamsRunner.class) +public class ApplicationControllerSupportTest { + private ApplicationControllerSupport applicationControllerSupport = new ApplicationControllerSupport(); + + public static Object[][] statusesAndCategories() { + return new Object[][] {{100, StatusCategory.NORMAL}, {200, StatusCategory.ERROR}, {300, StatusCategory.ERROR}, + {400, StatusCategory.NORMAL}, {401, StatusCategory.ERROR}, {500, StatusCategory.NORMAL}, + {501, StatusCategory.ERROR}, {502, StatusCategory.WARNING}, {800, StatusCategory.WARNING},}; + } + + public static Object[][] statusesAndFinalities() { + return new Object[][] {{100, false}, {200, true}, {300, true}, {400, true}, {500, false}, {800, true},}; + } + + @Test + @Parameters(method = "statusesAndCategories") + public void shouldReturnCategoryForCode(int code, StatusCategory category) throws Exception { + // when + StatusCategory detectedCategory = applicationControllerSupport.getCategoryOf(createStatus(code)); + // then + assertThat(detectedCategory).isEqualTo(category); + } + + @Test + @Parameters(method = "statusesAndFinalities") + public void shouldReturnFinalityForCode(int code, boolean expectedFinality) throws Exception { + // when + boolean finality = applicationControllerSupport.getFinalityOf(createStatus(code)); + // then + assertThat(finality).isEqualTo(expectedFinality); + } + + @Test + public void buildStatusFromAppcException_Test() { + String errorMessage = "errormessage"; + AppcClientException exception = new AppcClientException(errorMessage); + Status status = applicationControllerSupport.buildStatusFromAppcException(exception); + assertThat(status.getCode() == 200); + assertThat((status.getMessage()).equals(("Exception on APPC request: " + errorMessage))); + } + + private Status createStatus(int code) { + Status status = new Status(); + status.setCode(code); + return status; + } +} diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/beans/BeansTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/beans/BeansTest.java new file mode 100644 index 0000000000..76b5efacb3 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/beans/BeansTest.java @@ -0,0 +1,20 @@ +package org.onap.so.adapters.appc.orchestrator.client.beans; + +import org.junit.Test; +import com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; + +public class BeansTest { + + @Test + public void validateGettersAndSetters() { + Validator validator = ValidatorBuilder.create().with(new SetterMustExistRule(), new GetterMustExistRule()) + .with(new SetterTester(), new GetterTester()).build(); + validator.validate("org.onap.so.adapters.appc.orchestrator.client.beans", new FilterPackageInfo()); + } +} diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java new file mode 100644 index 0000000000..3eac851f13 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java @@ -0,0 +1,88 @@ +package org.onap.so.adapters.appc.orchestrator.service; + +import java.util.List; +import java.util.Optional; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.appc.client.lcm.model.Status; +import org.onap.so.TestApplication; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerClient; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerOrchestratorException; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerSupport; +import org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters; +import org.onap.so.adapters.appc.orchestrator.client.beans.Identity; +import org.onap.so.adapters.appc.orchestrator.client.beans.Parameters; +import org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters; +import org.onap.so.adapters.appc.orchestrator.service.ApplicationControllerTaskImpl; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf; +import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; +import org.camunda.bpm.client.task.ExternalTask; +import org.camunda.bpm.client.task.ExternalTaskService; +import com.fasterxml.jackson.core.JsonProcessingException; +import org.onap.appc.client.lcm.model.Action; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +@ContextConfiguration +@AutoConfigureWireMock(port = 0) +public class ApplicationControllerTaskImplITTest { + + @Autowired + private ApplicationControllerTaskImpl applicationControllerTaskImpl; + + @Mock + ExternalTask externalTask; + + @Mock + ExternalTaskService externalTaskService; + + @Mock + ApplicationControllerSupport appCSupport; + + ApplicationControllerTaskRequest request; + + ApplicationControllerCallback listener; + + GraphInventoryCommonObjectMapperProvider mapper = new GraphInventoryCommonObjectMapperProvider(); + + @Before + public void setup() { + request = new ApplicationControllerTaskRequest(); + request.setBookName("testBookName"); + request.setControllerType("testControllerType"); + request.setFileParameters("testFileParams"); + request.setIdentityUrl("testIdentityUrl"); + request.setNewSoftwareVersion("2.0"); + request.setExistingSoftwareVersion("1.0"); + request.setOperationsTimeout("30"); + ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf(); + applicationControllerVnf.setVnfHostIpAddress("100.100"); + applicationControllerVnf.setVnfId("testVnfId"); + applicationControllerVnf.setVnfName("testVnfName"); + request.setApplicationControllerVnf(applicationControllerVnf); + listener = new ApplicationControllerCallback(null, externalTaskService, appCSupport); + } + + + @Test + public void testListener() throws Exception { + request.setAction(Action.QuiesceTraffic); + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + } + +} diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java new file mode 100644 index 0000000000..640e2dbd6e --- /dev/null +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java @@ -0,0 +1,236 @@ +package org.onap.so.adapters.appc.orchestrator.service; + +import java.util.Optional; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.appc.client.lcm.model.Status; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerClient; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerOrchestratorException; +import org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters; +import org.onap.so.adapters.appc.orchestrator.client.beans.Identity; +import org.onap.so.adapters.appc.orchestrator.client.beans.Parameters; +import org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters; +import org.onap.so.adapters.appc.orchestrator.service.ApplicationControllerTaskImpl; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf; +import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider; +import com.fasterxml.jackson.core.JsonProcessingException; +import org.onap.appc.client.lcm.model.Action; + +@RunWith(MockitoJUnitRunner.class) +public class ApplicationControllerTaskImplTest { + + @Mock + ApplicationControllerClient applicationControllerClient; + + @InjectMocks + @Spy + ApplicationControllerTaskImpl applicationControllerTaskImpl; + + ApplicationControllerTaskRequest request; + + ApplicationControllerCallback listener; + + GraphInventoryCommonObjectMapperProvider mapper = new GraphInventoryCommonObjectMapperProvider(); + + @Before + public void setup() { + request = new ApplicationControllerTaskRequest(); + request.setBookName("testBookName"); + request.setControllerType("testControllerType"); + request.setFileParameters("testFileParams"); + request.setIdentityUrl("testIdentityUrl"); + request.setNewSoftwareVersion("2.0"); + request.setExistingSoftwareVersion("1.0"); + request.setOperationsTimeout("30"); + ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf(); + applicationControllerVnf.setVnfHostIpAddress("100.100"); + applicationControllerVnf.setVnfId("testVnfId"); + applicationControllerVnf.setVnfName("testVnfName"); + request.setApplicationControllerVnf(applicationControllerVnf); + listener = new ApplicationControllerCallback(null, null, null); + + } + + @Test + public void testExcute_healthCheck() throws JsonProcessingException, ApplicationControllerOrchestratorException { + request.setAction(Action.HealthCheck); + + Parameters parameters = new Parameters(); + RequestParameters requestParams = new RequestParameters(); + requestParams.setHostIpAddress(request.getApplicationControllerVnf().getVnfHostIpAddress()); + parameters.setRequestParameters(requestParams); + Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + + Mockito.when(applicationControllerClient.vnfCommand(Action.HealthCheck, "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener)).thenReturn(new Status()); + + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + + Mockito.verify(applicationControllerClient).vnfCommand(Action.HealthCheck, "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener); + + } + + @Test + public void testExcute_resumeTraffic() throws JsonProcessingException, ApplicationControllerOrchestratorException { + request.setAction(Action.ResumeTraffic); + + Parameters parameters = new Parameters(); + ConfigurationParameters configParams = new ConfigurationParameters(); + configParams.setVnfName(request.getApplicationControllerVnf().getVnfName()); + parameters.setConfigurationParameters(configParams); + Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + + Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener)).thenReturn(new Status()); + + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + + Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener); + } + + @Test + public void testExcute_stop() throws JsonProcessingException, ApplicationControllerOrchestratorException { + request.setAction(Action.Stop); + + Identity identity = new Identity(); + identity.setIdentityUrl(request.getIdentityUrl()); + Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(identity))); + + Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener)).thenReturn(new Status()); + + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + + Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener); + } + + @Test + public void testExcute_lock() throws JsonProcessingException, ApplicationControllerOrchestratorException { + request.setAction(Action.Lock); + + Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), Optional.empty(), + "testControllerType", listener)).thenReturn(new Status()); + + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + + Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), Optional.empty(), + "testControllerType", listener); + } + + @Test + public void testExcute_quiesceTraffic() throws JsonProcessingException, ApplicationControllerOrchestratorException { + request.setAction(Action.QuiesceTraffic); + + + Parameters parameters = new Parameters(); + parameters.setOperationsTimeout(request.getOperationsTimeout()); + Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + System.out.println("PAYLOAD is: " + payload.get()); + + Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener)).thenReturn(new Status()); + + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + + Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener); + } + + @Test + public void testExcute_distributeTraffic() + throws JsonProcessingException, ApplicationControllerOrchestratorException { + request.setAction(Action.DistributeTraffic); + + Parameters parameters = new Parameters(); + ConfigurationParameters configParams = new ConfigurationParameters(); + configParams.setBookName(request.getBookName()); + configParams.setNodeList(request.getNodeList()); + configParams.setFileParameterContent(request.getFileParameters()); + configParams.setVnfName(request.getApplicationControllerVnf().getVnfName()); + parameters.setConfigurationParameters(configParams); + Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + + Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener)).thenReturn(new Status()); + + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + + Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener); + } + + @Test + public void testExcute_distributeTrafficCheck() + throws JsonProcessingException, ApplicationControllerOrchestratorException { + request.setAction(Action.DistributeTrafficCheck); + + Parameters parameters = new Parameters(); + ConfigurationParameters configParams = new ConfigurationParameters(); + configParams.setBookName(request.getBookName()); + configParams.setNodeList(request.getNodeList()); + configParams.setFileParameterContent(request.getFileParameters()); + configParams.setVnfName(request.getApplicationControllerVnf().getVnfName()); + parameters.setConfigurationParameters(configParams); + Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + + Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener)).thenReturn(new Status()); + + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + + Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener); + } + + @Test + public void testExcute_upgradeBackup() throws JsonProcessingException, ApplicationControllerOrchestratorException { + request.setAction(Action.UpgradeBackup); + + Parameters parameters = new Parameters(); + parameters.setExistingSoftwareVersion(request.getExistingSoftwareVersion()); + parameters.setNewSoftwareVersion(request.getNewSoftwareVersion()); + Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + + Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener)).thenReturn(new Status()); + + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + + Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener); + } + + @Test + public void testListener() throws Exception { + request.setAction(Action.QuiesceTraffic); + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + } + +} diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskTest.java new file mode 100644 index 0000000000..228ee90107 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskTest.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017-2019 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.adapters.appc.orchestrator.service; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import org.camunda.bpm.client.task.ExternalTask; +import org.camunda.bpm.client.task.ExternalTaskService; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.so.externaltasks.logging.AuditMDCSetup; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; +import org.onap.appc.client.lcm.model.Status; + +public class ApplicationControllerTaskTest extends ApplicationControllerTask { + + @InjectMocks + ApplicationControllerTask appcTaskService = new ApplicationControllerTask(); + + @Mock + ApplicationControllerTaskImpl applicationControllerTaskImpl; + + @Mock + ExternalTask mockExternalTask; + + @Mock + ExternalTaskService mockExternalTaskService; + + @Mock + private AuditMDCSetup mdcSetup; + + private ApplicationControllerTaskRequest request = new ApplicationControllerTaskRequest(); + private String msoRequestId = "testRequestId"; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + doNothing().when(mdcSetup).setupMDC(mockExternalTask); + doReturn(request).when(mockExternalTask).getVariable("appcOrchestratorRequest"); + doReturn(msoRequestId).when(mockExternalTask).getVariable("mso-request-id"); + } + + @Test + public void executeExternalTask_appc_success_Test() throws Exception { + Status status = new Status(); + doReturn(status).when(applicationControllerTaskImpl).execute(any(String.class), + any(ApplicationControllerTaskRequest.class), any(ApplicationControllerCallback.class)); + appcTaskService.executeExternalTask(mockExternalTask, mockExternalTaskService); + Mockito.verify(applicationControllerTaskImpl).execute(any(String.class), + any(ApplicationControllerTaskRequest.class), any(ApplicationControllerCallback.class)); + } +} diff --git a/adapters/so-appc-orchestrator/src/test/resources/application-test.yaml b/adapters/so-appc-orchestrator/src/test/resources/application-test.yaml new file mode 100644 index 0000000000..eb693a263e --- /dev/null +++ b/adapters/so-appc-orchestrator/src/test/resources/application-test.yaml @@ -0,0 +1,17 @@ + +appc: + client: + key: LSl8QKolmKcC0yJR + response: + timeout: '60000' + secret: lgjXraD1HutKxv8jEN6tVouu + poolMembers: localhost:3904,localhost:3904 + service: ueb + topic: + read: + name: APPC-1902-SHDEV-WRITE + timeout: '120000' + write: APPC-1902-SHDEV-READ + sdnc: + read: SDNC-LCM-READ + write: SDNC-LCM-WRITE
\ No newline at end of file diff --git a/adapters/so-appc-orchestrator/src/test/resources/logback-test.xml b/adapters/so-appc-orchestrator/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8a9e705ca6 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/test/resources/logback-test.xml @@ -0,0 +1,31 @@ +<configuration> + + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n</pattern> + </encoder> + </appender> + + + <logger name="com.att.ecomp.audit" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.error" level="trace" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="org.onap" level="${so.log.level:-WARN}" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <root level="WARN"> + <appender-ref ref="STDOUT" /> + </root> + +</configuration>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index bc8b54e444..6afceac78f 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -247,7 +247,8 @@ public class BBInputSetup implements JavaDelegate { if (serviceInstanceId != null) { aaiServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId); if (aaiServiceInstance != null) { - if (requestAction.equalsIgnoreCase("replaceInstance")) { + if (requestAction.equalsIgnoreCase("replaceInstance") + || requestAction.equalsIgnoreCase("replaceInstanceRetainAssignments")) { RelatedInstanceList[] relatedInstanceList = requestDetails.getRelatedInstanceList(); if (relatedInstanceList != null) { for (RelatedInstanceList relatedInstList : relatedInstanceList) { @@ -300,7 +301,7 @@ public class BBInputSetup implements JavaDelegate { } String instanceGroupId = lookupKeyMap.get(ResourceKey.INSTANCE_GROUP_ID); - if (instanceGroupId != null) { + if (instanceGroupId != null && !instanceGroupId.isEmpty()) { org.onap.aai.domain.yang.InstanceGroup aaiInstancegroup = bbInputSetupUtils.getAAIInstanceGroup(instanceGroupId); InstanceGroup instanceGroup = this.mapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstancegroup); @@ -363,7 +364,8 @@ public class BBInputSetup implements JavaDelegate { } else if (modelType.equals(ModelType.vnf)) { lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, resourceId); this.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, - lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId, applicationId); + lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId, applicationId, + isReplace); } else if (modelType.equals(ModelType.volumeGroup) || (modelType.equals(ModelType.vfModule) && (bbName.equalsIgnoreCase(AssignFlows.VOLUME_GROUP.toString()) || bbName.startsWith(CREATEVOLUME)))) { lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, resourceId); @@ -555,7 +557,8 @@ public class BBInputSetup implements JavaDelegate { .getModelCustomizationId(); ModelInfo modelInfoVfModule = new ModelInfo(); modelInfoVfModule.setModelCustomizationId(vfModuleCustId); - if (isReplace) { + if (isReplace && lookupKeyMap.get(ResourceKey.VF_MODULE_ID) != null + && vfModuleTemp.getVfModuleId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.VF_MODULE_ID))) { mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, service, replaceVnfModelCustomizationUUID); } else { mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, service, vnfModelCustomizationUUID); @@ -738,11 +741,12 @@ public class BBInputSetup implements JavaDelegate { org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness, Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, RelatedInstanceList[] relatedInstanceList, String resourceId, String vnfType, - List<Map<String, String>> instanceParams, String productFamilyId, String applicationId) { + List<Map<String, String>> instanceParams, String productFamilyId, String applicationId, boolean isReplace) { GenericVnf vnf = null; ModelInfo instanceGroupModelInfo = null; String instanceGroupId = null; String generatedVnfType = vnfType; + String replaceVnfModelCustomizationUUID = null; if (generatedVnfType == null || generatedVnfType.isEmpty()) { generatedVnfType = service.getModelName() + "/" + modelInfo.getModelCustomizationName(); } @@ -753,6 +757,9 @@ public class BBInputSetup implements JavaDelegate { instanceGroupModelInfo = relatedInstance.getModelInfo(); instanceGroupId = relatedInstance.getInstanceId(); } + if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf) && isReplace) { + replaceVnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId(); + } } } for (GenericVnf vnfTemp : serviceInstance.getVnfs()) { @@ -760,6 +767,12 @@ public class BBInputSetup implements JavaDelegate { && vnfTemp.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { String vnfModelCustId = bbInputSetupUtils.getAAIGenericVnf(vnfTemp.getVnfId()).getModelCustomizationId(); + if (isReplace && replaceVnfModelCustomizationUUID != null + && vnfTemp.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { + modelInfo.setModelCustomizationUuid(replaceVnfModelCustomizationUUID); + } else { + modelInfo.setModelCustomizationUuid(vnfModelCustId); + } modelInfo.setModelCustomizationUuid(vnfModelCustId); vnf = vnfTemp; break; @@ -1431,9 +1444,12 @@ public class BBInputSetup implements JavaDelegate { } String productFamilyId = requestDetails.getRequestInfo().getProductFamilyId(); String applicationId = ""; + if (vnfs.getApplicationId() != null) { + applicationId = vnfs.getApplicationId(); + } this.populateGenericVnf(vnfs.getModelInfo(), vnfs.getInstanceName(), vnfs.getPlatform(), vnfs.getLineOfBusiness(), service, bbName, serviceInstance, lookupKeyMap, null, vnfId, vnfType, - vnfs.getInstanceParams(), productFamilyId, applicationId); + vnfs.getInstanceParams(), productFamilyId, applicationId, false); } else if (bbName.contains(PNF)) { String pnfId = lookupKeyMap.get(ResourceKey.PNF); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index e4b1153f4b..517bdfffb8 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -855,13 +855,13 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, - productFamilyId, applicationId); + productFamilyId, applicationId, false); SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false); verify(SPY_bbInputSetup, times(1)).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, - productFamilyId, applicationId); + productFamilyId, applicationId, false); assertEquals("VnfId populated", true, lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID).equalsIgnoreCase(resourceId)); @@ -1433,13 +1433,13 @@ public class BBInputSetupTest { SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, - requestDetails.getRequestInfo().getProductFamilyId(), applicationId); + requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, - requestDetails.getRequestInfo().getProductFamilyId(), applicationId); + requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false); verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service); instanceName = "vnfName2"; @@ -1454,7 +1454,7 @@ public class BBInputSetupTest { SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, - requestDetails.getRequestInfo().getProductFamilyId(), applicationId); + requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false); verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service); verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}"); verify(SPY_bbInputSetup, times(2)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service); @@ -1531,13 +1531,13 @@ public class BBInputSetupTest { SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, - requestDetails.getRequestInfo().getProductFamilyId(), applicationId); + requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, - requestDetails.getRequestInfo().getProductFamilyId(), applicationId); + requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false); verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service); instanceName = "vnfName2"; @@ -1551,7 +1551,7 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}"); SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, - requestDetails.getRequestInfo().getProductFamilyId(), applicationId); + requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false); verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service); verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}"); verify(SPY_bbInputSetup, times(1)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service); @@ -2015,7 +2015,7 @@ public class BBInputSetupTest { isA(org.onap.so.serviceinstancebeans.Platform.class), isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any(), - any(String.class), any(String.class)); + any(String.class), any(String.class), Mockito.anyBoolean()); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString()); @@ -2298,7 +2298,7 @@ public class BBInputSetupTest { isA(org.onap.so.serviceinstancebeans.Platform.class), isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), ArgumentMatchers.isNull(), any(String.class), - ArgumentMatchers.isNull(), any(), any(String.class), any()); + ArgumentMatchers.isNull(), any(), any(String.class), any(), Mockito.anyBoolean()); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString()); @@ -2363,7 +2363,7 @@ public class BBInputSetupTest { isA(org.onap.so.serviceinstancebeans.Platform.class), isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any(), - any(String.class), any(String.class)); + any(String.class), any(String.class), Mockito.anyBoolean()); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString()); @@ -2995,6 +2995,78 @@ public class BBInputSetupTest { } @Test + public void testPopulateVfModuleIsReplaceCorrectPopulationOfVfs() throws Exception { + String vnfId = "vnfId"; + String vfModuleId = "vfModuleId"; + String volumeGroupId = "volumeGroupId"; + String vfModuleCustomizationId = "vfModuleCustomizationId"; + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelCustomizationId(vfModuleCustomizationId); + Service service = new Service(); + String bbName = "ActivateVfModuleBB"; + ServiceInstance serviceInstance = new ServiceInstance(); + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId(vnfId); + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupId(volumeGroupId); + vnf.getVolumeGroups().add(volumeGroup); + serviceInstance.getVnfs().add(vnf); + VfModule vfModule1 = new VfModule(); + vfModule1.setVfModuleId("vfModuleId1"); + VfModule vfModule2 = new VfModule(); + vfModule2.setVfModuleId("vfModuleId2"); + vnf.getVfModules().add(vfModule1); + vnf.getVfModules().add(vfModule2); + Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); + lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnfId); + lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId1"); + String resourceId = vfModuleId; + RelatedInstanceList[] relatedInstanceList = new RelatedInstanceList[1]; + RelatedInstanceList relatedInstanceListObj = new RelatedInstanceList(); + RelatedInstance relatedInstance = new RelatedInstance(); + relatedInstance.setInstanceId(vnfId); + + ModelInfo vnfModelInfo = new ModelInfo(); + vnfModelInfo.setModelCustomizationId("vnfCustomizationId"); + vnfModelInfo.setModelType(ModelType.vnf); + relatedInstance.setModelInfo(vnfModelInfo); + relatedInstanceListObj.setRelatedInstance(relatedInstance); + relatedInstanceList[0] = relatedInstanceListObj; + + String instanceName = "vfModuleName"; + List<Map<String, String>> instanceParams = null; + CloudConfiguration cloudConfiguration = new CloudConfiguration(); + + org.onap.aai.domain.yang.GenericVnf vnfAAI = new org.onap.aai.domain.yang.GenericVnf(); + vnfAAI.setModelCustomizationId("vnfModelCustId"); + org.onap.aai.domain.yang.VolumeGroup volumeGroupAAI = new org.onap.aai.domain.yang.VolumeGroup(); + volumeGroupAAI.setModelCustomizationId(vfModuleCustomizationId); + org.onap.aai.domain.yang.VfModule vfModuleAAI = new org.onap.aai.domain.yang.VfModule(); + vfModuleAAI.setModelCustomizationId(vfModuleCustomizationId); + + doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId()); + doReturn(volumeGroupAAI).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(CLOUD_OWNER, + cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()); + doReturn(vfModuleAAI).when(SPY_bbInputSetupUtils).getAAIVfModule(isA(String.class), isA(String.class)); + doNothing().when(SPY_bbInputSetup).mapCatalogVnf(isA(GenericVnf.class), isA(ModelInfo.class), + isA(Service.class)); + doNothing().when(SPY_bbInputSetup).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), + isA(Service.class), isA(String.class)); + + SPY_bbInputSetup.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + relatedInstanceList, instanceName, instanceParams, cloudConfiguration, true); + + verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), + isA(Service.class), eq("vnfModelCustId")); + verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), + isA(Service.class), eq("vnfCustomizationId")); + assertEquals("Lookup Key Map populated with VfModule Id", "vfModuleId1", + lookupKeyMap.get(ResourceKey.VF_MODULE_ID)); + assertEquals("Lookup Key Map populated with VolumeGroup Id", volumeGroupId, + lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID)); + } + + @Test public void testPopulateVfModuleIsReplace() throws Exception { String vnfId = "vnfId"; String vfModuleId = "vfModuleId"; diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/DistributeTrafficActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/DistributeTrafficActivity.bpmn index 4ea6bb10b1..496fcb1784 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/DistributeTrafficActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/DistributeTrafficActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="DistributeTrafficActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskDistributeTraffic" targetRef="DistributeTrafficActivity_End" /> - <bpmn:serviceTask id="TaskDistributeTraffic" name="Distribute Traffic" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionDistributeTraffic"))}"> + <bpmn:serviceTask id="TaskDistributeTraffic" name="Distribute Traffic" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskDistributeTraffic" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"DistributeTraffic")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/DistributeTrafficCheckActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/DistributeTrafficCheckActivity.bpmn index 19a4972187..a5bde79237 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/DistributeTrafficCheckActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/DistributeTrafficCheckActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="DistributeTrafficCheckActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskDistributeTrafficCheck" targetRef="DistributeTrafficCheckActivity_End" /> - <bpmn:serviceTask id="TaskDistributeTrafficCheck" name="Distribute Traffic Check" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionDistributeTrafficCheck"))}"> + <bpmn:serviceTask id="TaskDistributeTrafficCheck" name="Distribute Traffic Check" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskDistributeTrafficCheck" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"DistributeTrafficCheck")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckClosedLoopDisabledFlagActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckClosedLoopDisabledFlagActivity.bpmn index 9ac0f38835..50fc40f450 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckClosedLoopDisabledFlagActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckClosedLoopDisabledFlagActivity.bpmn @@ -1,6 +1,6 @@ <?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.9.0"> - <bpmn:process id="VNFCheckClosedLoopDisabledFlagActivity" name="VNFCheckClosedLoopDisabledFlagActivity " isExecutable="true"> +<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="VNFCheckClosedLoopDisabledFlagActivity" name="VNFCheckClosedLoopDisabledFlagActivity" isExecutable="true"> <bpmn:startEvent id="VNFCheckClosedLoopDisabledFlagActivity_Start"> <bpmn:outgoing>SequenceFlow_01c8z5u</bpmn:outgoing> </bpmn:startEvent> @@ -47,4 +47,4 @@ </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckInMaintFlagActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckInMaintFlagActivity.bpmn index 8709f399a5..ed6b10feed 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckInMaintFlagActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckInMaintFlagActivity.bpmn @@ -1,6 +1,6 @@ <?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.9.0"> - <bpmn:process id="VNFCheckInMaintFlagActivity" name="VNFCheckInMaintFlagActivity " isExecutable="true"> + <bpmn:process id="VNFCheckInMaintFlagActivity" name="VNFCheckInMaintFlagActivity" isExecutable="true"> <bpmn:startEvent id="VNFCheckInMaintFlagActivity_Start"> <bpmn:outgoing>SequenceFlow_0h1gkvd</bpmn:outgoing> </bpmn:startEvent> @@ -47,4 +47,4 @@ </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckPserversLockedFlagActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckPserversLockedFlagActivity.bpmn index 9c327a4da9..49777daa02 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckPserversLockedFlagActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckPserversLockedFlagActivity.bpmn @@ -1,6 +1,6 @@ <?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.9.0"> - <bpmn:process id="VNFCheckPserversLockedFlagActivity" name="VNFCheckInMaintFlagActivity " isExecutable="true"> + <bpmn:process id="VNFCheckPserversLockedFlagActivity" name="VNFCheckPserversLockedFlagActivity" isExecutable="true"> <bpmn:startEvent id="VNFCheckPserversLockedFlagActivity_Start"> <bpmn:outgoing>SequenceFlow_0a56huh</bpmn:outgoing> </bpmn:startEvent> @@ -47,4 +47,4 @@ </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFHealthCheckActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFHealthCheckActivity.bpmn index 2e97206867..2e66f6c948 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFHealthCheckActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFHealthCheckActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFHealthCheckActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskHealthCheck" targetRef="VNFHealthCheckActivity_End" /> - <bpmn:serviceTask id="TaskHealthCheck" name="VNF Health Check" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionHealthCheck"))}"> + <bpmn:serviceTask id="TaskHealthCheck" name="VNF Health Check" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskHealthCheck" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"HealthCheck")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFLockActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFLockActivity.bpmn index 1aaa920ef8..43f2f4d6d3 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFLockActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFLockActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFLockActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskLock" targetRef="VNFLockActivity_End" /> - <bpmn:serviceTask id="TaskLock" name="VNF Lock" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionLock"))}"> + <bpmn:serviceTask id="TaskLock" name="VNF Lock" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskLock" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"Lock")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFQuiesceTrafficActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFQuiesceTrafficActivity.bpmn index ac09674884..d0073803e9 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFQuiesceTrafficActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFQuiesceTrafficActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFQuiesceTrafficActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskQuiesceTraffic" targetRef="VNFQuiesceTrafficActivity_End" /> - <bpmn:serviceTask id="TaskQuiesceTraffic" name="VNF Quiesce Traffic" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionQuiesceTraffic"))}"> + <bpmn:serviceTask id="TaskQuiesceTraffic" name="VNF Quiesce Traffic" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskQuiesceTraffic" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"QuiesceTraffic")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFResumeTrafficActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFResumeTrafficActivity.bpmn index c21072a32a..888ce18467 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFResumeTrafficActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFResumeTrafficActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFResumeTrafficActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskResumeTraffic" targetRef="VNFResumeTrafficActivity_End" /> - <bpmn:serviceTask id="TaskResumeTraffic" name="VNF Resume Traffic" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionResumeTraffic"))}"> + <bpmn:serviceTask id="TaskResumeTraffic" name="VNF Resume Traffic" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskResumeTraffic" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"ResumeTraffic")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSetClosedLoopDisabledFlagActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSetClosedLoopDisabledFlagActivity.bpmn index f356634106..c02161eb61 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSetClosedLoopDisabledFlagActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSetClosedLoopDisabledFlagActivity.bpmn @@ -1,6 +1,6 @@ <?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.9.0"> - <bpmn:process id="VNFSetClosedLoopDisabledFlagActivity" name="VNFSetClosedLoopDisabledFlagActivity " isExecutable="true"> + <bpmn:process id="VNFSetClosedLoopDisabledFlagActivity" name="VNFSetClosedLoopDisabledFlagActivity" isExecutable="true"> <bpmn:startEvent id="VNFSetClosedLoopDisabledFlagActivity_Start"> <bpmn:outgoing>SequenceFlow_0pp6ze7</bpmn:outgoing> </bpmn:startEvent> @@ -47,4 +47,4 @@ </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSetInMaintFlagActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSetInMaintFlagActivity.bpmn index 2bdb1d7533..a0d0cbd5d7 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSetInMaintFlagActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSetInMaintFlagActivity.bpmn @@ -1,6 +1,6 @@ <?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.4.0"> - <bpmn:process id="VNFSetInMaintFlagActivity" name="VNFSetInMaintFlagActivity " isExecutable="true"> + <bpmn:process id="VNFSetInMaintFlagActivity" name="VNFSetInMaintFlagActivity" isExecutable="true"> <bpmn:startEvent id="VNFSetInMaintFlagActivity_Start"> <bpmn:outgoing>SequenceFlow_0zaz9o2</bpmn:outgoing> </bpmn:startEvent> @@ -47,4 +47,4 @@ </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSnapShotActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSnapShotActivity.bpmn index 8115f694c2..f7bf835bd9 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSnapShotActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSnapShotActivity.bpmn @@ -5,19 +5,44 @@ <bpmn:outgoing>SequenceFlow_06vhbci</bpmn:outgoing> </bpmn:startEvent> <bpmn:endEvent id="VNFSnapShotActivity_End"> - <bpmn:incoming>SequenceFlow_01312aj</bpmn:incoming> + <bpmn:incoming>SequenceFlow_048qlth</bpmn:incoming> + <bpmn:incoming>SequenceFlow_17zvrl5</bpmn:incoming> </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFSnapShotActivity_Start" targetRef="TaskPreProcessActivity" /> - <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskSnapShot" targetRef="VNFSnapShotActivity_End" /> - <bpmn:serviceTask id="TaskSnapShot" name="VNF SnapShot" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionSnapshot"))}"> - <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> + <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskSnapShot" targetRef="ExclusiveGateway_0u10l8w" /> + <bpmn:serviceTask id="TaskSnapShot" name="VM SnapShot" camunda:type="external" camunda:topic="AppcService"> + <bpmn:incoming>SequenceFlow_041lqrr</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"Snapshot")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskSnapShot" /> + <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="ExclusiveGateway_0ivqnoj" /> + <bpmn:sequenceFlow id="SequenceFlow_041lqrr" sourceRef="TaskPreProcessVM" targetRef="TaskSnapShot" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_0ivqnoj" name="Are there VMs?" default="SequenceFlow_048qlth"> + <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0aachpx</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_048qlth</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_0aachpx" name="yes" sourceRef="ExclusiveGateway_0ivqnoj" targetRef="TaskPreProcessVM"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{execution.getVariable("vmIdListSize") > 0}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_048qlth" name="no" sourceRef="ExclusiveGateway_0ivqnoj" targetRef="VNFSnapShotActivity_End" /> + <bpmn:serviceTask id="TaskPreProcessVM" name="PreProcess VM" camunda:expression="${AppcOrchestratorPreProcessor.addVmInfoToAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0aachpx</bpmn:incoming> + <bpmn:incoming>SequenceFlow_12eenwu</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_041lqrr</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:exclusiveGateway id="ExclusiveGateway_0u10l8w" name="Any more VMs?" default="SequenceFlow_17zvrl5"> + <bpmn:incoming>SequenceFlow_01312aj</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_17zvrl5</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_12eenwu</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_17zvrl5" name="no" sourceRef="ExclusiveGateway_0u10l8w" targetRef="VNFSnapShotActivity_End" /> + <bpmn:sequenceFlow id="SequenceFlow_12eenwu" name="yes" sourceRef="ExclusiveGateway_0u10l8w" targetRef="TaskPreProcessVM"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{execution.getVariable("vmIndex") < execution.getVariable("vmIdListSize")}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="VNFSnapShotActivity"> @@ -25,9 +50,9 @@ <dc:Bounds x="173" y="102" width="36" height="36" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_102xlzi_di" bpmnElement="VNFSnapShotActivity_End"> - <dc:Bounds x="561" y="102" width="36" height="36" /> + <dc:Bounds x="1047" y="102" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="579" y="138" width="0" height="0" /> + <dc:Bounds x="1065" y="138" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_06vhbci_di" bpmnElement="SequenceFlow_06vhbci"> @@ -38,25 +63,79 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_01312aj_di" bpmnElement="SequenceFlow_01312aj"> - <di:waypoint xsi:type="dc:Point" x="497" y="120" /> - <di:waypoint xsi:type="dc:Point" x="561" y="120" /> + <di:waypoint xsi:type="dc:Point" x="850" y="120" /> + <di:waypoint xsi:type="dc:Point" x="911" y="120" /> <bpmndi:BPMNLabel> - <dc:Bounds x="529" y="105" width="0" height="0" /> + <dc:Bounds x="881" y="105" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_066idx4_di" bpmnElement="TaskSnapShot"> - <dc:Bounds x="397" y="80" width="100" height="80" /> + <dc:Bounds x="750" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0fti66x_di" bpmnElement="TaskPreProcessActivity"> <dc:Bounds x="255" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0cf0riu_di" bpmnElement="SequenceFlow_0cf0riu"> <di:waypoint xsi:type="dc:Point" x="355" y="120" /> - <di:waypoint xsi:type="dc:Point" x="397" y="120" /> + <di:waypoint xsi:type="dc:Point" x="430" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="393" y="105" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_041lqrr_di" bpmnElement="SequenceFlow_041lqrr"> + <di:waypoint xsi:type="dc:Point" x="667" y="120" /> + <di:waypoint xsi:type="dc:Point" x="750" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="709" y="105" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_0ivqnoj_di" bpmnElement="ExclusiveGateway_0ivqnoj" isMarkerVisible="true"> + <dc:Bounds x="430" y="95" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="417" y="59" width="76" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0aachpx_di" bpmnElement="SequenceFlow_0aachpx"> + <di:waypoint xsi:type="dc:Point" x="480" y="120" /> + <di:waypoint xsi:type="dc:Point" x="567" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="515" y="105" width="18" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_048qlth_di" bpmnElement="SequenceFlow_048qlth"> + <di:waypoint xsi:type="dc:Point" x="455" y="145" /> + <di:waypoint xsi:type="dc:Point" x="455" y="243" /> + <di:waypoint xsi:type="dc:Point" x="1065" y="243" /> + <di:waypoint xsi:type="dc:Point" x="1065" y="138" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="754" y="228" width="12" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_12efz54_di" bpmnElement="TaskPreProcessVM"> + <dc:Bounds x="567" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_0u10l8w_di" bpmnElement="ExclusiveGateway_0u10l8w" isMarkerVisible="true"> + <dc:Bounds x="911" y="95" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="897" y="145" width="78" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_17zvrl5_di" bpmnElement="SequenceFlow_17zvrl5"> + <di:waypoint xsi:type="dc:Point" x="961" y="120" /> + <di:waypoint xsi:type="dc:Point" x="1047" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="998" y="95" width="12" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_12eenwu_di" bpmnElement="SequenceFlow_12eenwu"> + <di:waypoint xsi:type="dc:Point" x="936" y="95" /> + <di:waypoint xsi:type="dc:Point" x="936" y="-10" /> + <di:waypoint xsi:type="dc:Point" x="617" y="-10" /> + <di:waypoint xsi:type="dc:Point" x="617" y="80" /> <bpmndi:BPMNLabel> - <dc:Bounds x="376" y="105" width="0" height="0" /> + <dc:Bounds x="768" y="-25" width="18" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFStartActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFStartActivity.bpmn index f0490a9b61..da1e4a3630 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFStartActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFStartActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFStartActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskStart" targetRef="VNFStartActivity_End" /> - <bpmn:serviceTask id="TaskStart" name="VNF Start" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionStart"))}"> + <bpmn:serviceTask id="TaskStart" name="VNF Start" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskStart" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"Start")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFStopActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFStopActivity.bpmn index 0e02295631..93d442eaa5 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFStopActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFStopActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFStopActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskStop" targetRef="VNFStopActivity_End" /> - <bpmn:serviceTask id="TaskStop" name="VNF Stop" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionStop"))}"> + <bpmn:serviceTask id="TaskStop" name="VNF Stop" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskStop" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"Stop")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnlockActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnlockActivity.bpmn index 6d1b68cb7b..ef4162c60e 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnlockActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnlockActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFUnlockActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskUnlock" targetRef="VNFUnlockActivity_End" /> - <bpmn:serviceTask id="TaskUnlock" name="VNF Unlock" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionUnlock"))}"> + <bpmn:serviceTask id="TaskUnlock" name="VNF Unlock" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskUnlock" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"Unlock")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnsetClosedLoopDisabledFlagActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnsetClosedLoopDisabledFlagActivity.bpmn index d70e103009..575e3124fa 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnsetClosedLoopDisabledFlagActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnsetClosedLoopDisabledFlagActivity.bpmn @@ -44,4 +44,4 @@ </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnsetInMaintFlagActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnsetInMaintFlagActivity.bpmn index 05d3fcfa27..59eb80c16e 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnsetInMaintFlagActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnsetInMaintFlagActivity.bpmn @@ -1,6 +1,6 @@ <?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.4.0"> - <bpmn:process id="VNFUnsetInMaintFlagActivity" name="VNFUnsetInMaintFlagActivity " isExecutable="true"> + <bpmn:process id="VNFUnsetInMaintFlagActivity" name="VNFUnsetInMaintFlagActivity" isExecutable="true"> <bpmn:startEvent id="VNFUnsetInMaintFlagActivity_Start"> <bpmn:outgoing>SequenceFlow_0zaz9o2</bpmn:outgoing> </bpmn:startEvent> @@ -47,4 +47,4 @@ </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradeBackupActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradeBackupActivity.bpmn index dfcf9974ee..1b37867ecf 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradeBackupActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradeBackupActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFUpgradeBackupActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskUpgradeBackup" targetRef="VNFUpgradeBackupActivity_End" /> - <bpmn:serviceTask id="TaskUpgradeBackup" name="VNF UpgradeBackup" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionUpgradeBackup"))}"> + <bpmn:serviceTask id="TaskUpgradeBackup" name="VNF UpgradeBackup" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskUpgradeBackup" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"UpgradeBackup")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradePostCheckActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradePostCheckActivity.bpmn index 56c24dabc9..b9c4d89be9 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradePostCheckActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradePostCheckActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFUpgradePostCheckActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskUpgradePostCheck" targetRef="VNFUpgradePostCheckActivity_End" /> - <bpmn:serviceTask id="TaskUpgradePostCheck" name="VNF Upgrade PostCheck " camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionUpgradePostCheck"))}"> + <bpmn:serviceTask id="TaskUpgradePostCheck" name="VNF Upgrade PostCheck " camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskUpgradePostCheck" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"UpgradePostCheck")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradePreCheckActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradePreCheckActivity.bpmn index 1ec0a18dd5..33886e358d 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradePreCheckActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradePreCheckActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFUpgradePreCheckActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskUpgradePreCheck" targetRef="VNFUpgradePreCheckActivity_End" /> - <bpmn:serviceTask id="TaskUpgradePreCheck" name="VNF Upgrade PreCheck " camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionUpgradePreCheck"))}"> + <bpmn:serviceTask id="TaskUpgradePreCheck" name="VNF Upgrade PreCheck " camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskUpgradePreCheck" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"UpgradePreCheck")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradeSoftwareActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradeSoftwareActivity.bpmn index 89481a5640..16df667f6a 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradeSoftwareActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradeSoftwareActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFUpgradeSoftwareActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskUpgradeSoftware" targetRef="VNFUpgradeSoftwareActivity_End" /> - <bpmn:serviceTask id="TaskUpgradeSoftware" name="VNF Upgrade Software" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionUpgradeSoftware"))}"> + <bpmn:serviceTask id="TaskUpgradeSoftware" name="VNF Upgrade Software" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskUpgradeSoftware" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"UpgradeSoftware")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java index ff987b75d4..5b7fe66f54 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java @@ -19,6 +19,7 @@ */ package org.onap.so.bpmn; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -26,6 +27,8 @@ import java.util.Map; import org.camunda.bpm.engine.ExternalTaskService; import org.camunda.bpm.engine.RepositoryService; import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; +import org.camunda.bpm.engine.runtime.ProcessInstance; import org.camunda.bpm.extension.mockito.mock.FluentJavaDelegateMock; import org.camunda.bpm.model.bpmn.Bpmn; import org.camunda.bpm.model.bpmn.BpmnModelInstance; @@ -49,6 +52,7 @@ import org.onap.so.bpmn.infrastructure.adapter.network.tasks.NetworkAdapterUpdat import org.onap.so.bpmn.infrastructure.adapter.vnf.tasks.VnfAdapterCreateTasks; import org.onap.so.bpmn.infrastructure.adapter.vnf.tasks.VnfAdapterDeleteTasks; import org.onap.so.bpmn.infrastructure.adapter.vnf.tasks.VnfAdapterImpl; +import org.onap.so.bpmn.infrastructure.appc.tasks.AppcOrchestratorPreProcessor; import org.onap.so.bpmn.infrastructure.appc.tasks.AppcRunTasks; import org.onap.so.bpmn.infrastructure.audit.AuditTasks; import org.onap.so.bpmn.infrastructure.flowspecific.tasks.ActivateVfModule; @@ -131,6 +135,9 @@ public abstract class BaseBPMNTest { protected AppcRunTasks appcRunTasks; @MockBean + protected AppcOrchestratorPreProcessor appcOrchestratorPreProcessor; + + @MockBean protected SDNCActivateTasks sdncActivateTasks; @MockBean @@ -299,4 +306,17 @@ public abstract class BaseBPMNTest { mockedSubprocessList.add(repositoryService.createDeployment() .addModelInstance(fileName + ".bpmn", modelInstance).deploy().getId()); } + + protected void processExternalTasks(ProcessInstance pi, String taskName) { + assertThat(pi).isWaitingAt(taskName); + List<LockedExternalTask> tasks = + externalTaskService.fetchAndLock(100, "externalWorkerId").topic("AppcService", 60L * 1000L).execute(); + while (!tasks.isEmpty()) { + for (LockedExternalTask task : tasks) { + externalTaskService.complete(task.getId(), "externalWorkerId"); + } + tasks = externalTaskService.fetchAndLock(100, "externalWorkerId").topic("AppcService", 60L * 1000L) + .execute(); + } + } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DistributeTrafficActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DistributeTrafficActivityTest.java index 8306de4794..dae430e400 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DistributeTrafficActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DistributeTrafficActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class DistributeTrafficActivityTest extends BaseBPMNTest { @Test public void sunnyDayDistributeTrafficActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("DistributeTrafficActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskDistributeTraffic"); assertThat(pi).isStarted().hasPassedInOrder("DistributeTrafficActivity_Start", "TaskPreProcessActivity", "TaskDistributeTraffic", "DistributeTrafficActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,12 @@ public class DistributeTrafficActivityTest extends BaseBPMNTest { @Test public void rainyDayDistributeTrafficActivity_Test() throws Exception { - variables.put("actionDistributeTraffic", Action.DistributeTraffic); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("DistributeTrafficActivity", variables); assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("DistributeTrafficActivity_Start", "TaskPreProcessActivity", "TaskDistributeTraffic") - .hasNotPassed("DistributeTrafficActivity_End"); + .hasPassedInOrder("DistributeTrafficActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskDistributeTraffic", "DistributeTrafficActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DistributeTrafficCheckActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DistributeTrafficCheckActivityTest.java index 195a1ed809..7c18a20604 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DistributeTrafficCheckActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DistributeTrafficCheckActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class DistributeTrafficCheckActivityTest extends BaseBPMNTest { @Test public void sunnyDayDistributeTrafficCheckActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("DistributeTrafficCheckActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskDistributeTrafficCheck"); assertThat(pi).isStarted().hasPassedInOrder("DistributeTrafficCheckActivity_Start", "TaskPreProcessActivity", "TaskDistributeTrafficCheck", "DistributeTrafficCheckActivity_End"); assertThat(pi).isEnded(); @@ -42,14 +44,12 @@ public class DistributeTrafficCheckActivityTest extends BaseBPMNTest { @Test public void rainyDayDistributeTrafficActivity_Test() throws Exception { - variables.put("actionDistributeTrafficCheck", Action.DistributeTrafficCheck); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("DistributeTrafficCheckActivity", variables); - assertThat(pi) - .isNotNull().isStarted().hasPassedInOrder("DistributeTrafficCheckActivity_Start", - "TaskPreProcessActivity", "TaskDistributeTrafficCheck") - .hasNotPassed("DistributeTrafficCheckActivity_End"); + assertThat(pi).isNotNull().isStarted() + .hasPassedInOrder("DistributeTrafficCheckActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskDistributeTrafficCheck", "DistributeTrafficCheckActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java index c0b0094f20..48104017a5 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java @@ -29,7 +29,6 @@ import org.camunda.bpm.engine.TaskService; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.runtime.Job; import org.camunda.bpm.engine.runtime.ProcessInstance; -import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.task.Task; import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions; import org.junit.Test; diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFHealthCheckActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFHealthCheckActivityTest.java index 0b17e3e099..10040b813c 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFHealthCheckActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFHealthCheckActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFHealthCheckActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFHealthCheckActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFHealthCheckActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskHealthCheck"); assertThat(pi).isStarted().hasPassedInOrder("VNFHealthCheckActivity_Start", "TaskPreProcessActivity", "TaskHealthCheck", "VNFHealthCheckActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,12 @@ public class VNFHealthCheckActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFHealthCheckActivity_Test() throws Exception { - variables.put("actionHealthCheck", Action.HealthCheck); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFHealthCheckActivity", variables); assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFHealthCheckActivity_Start", "TaskPreProcessActivity", "TaskHealthCheck") - .hasNotPassed("VNFHealthCheckActivity_End"); + .hasPassedInOrder("VNFHealthCheckActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskHealthCheck", "VNFHealthCheckActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFLockActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFLockActivityTest.java index 45cf44848f..a174bbb90c 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFLockActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFLockActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFLockActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFLockActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFLockActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskLock"); assertThat(pi).isStarted().hasPassedInOrder("VNFLockActivity_Start", "TaskPreProcessActivity", "TaskLock", "VNFLockActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,11 @@ public class VNFLockActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFLockActivity_Test() throws Exception { - variables.put("actionLock", Action.Lock); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFLockActivity", variables); - assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFLockActivity_Start", "TaskPreProcessActivity", "TaskLock") - .hasNotPassed("VNFLockActivity_End"); + assertThat(pi).isNotNull().isStarted().hasPassedInOrder("VNFLockActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskLock", "VNFLockActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFQuiesceTrafficActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFQuiesceTrafficActivityTest.java index fb462bc02f..b1229cdfdf 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFQuiesceTrafficActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFQuiesceTrafficActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFQuiesceTrafficActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFQuiesceTrafficActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFQuiesceTrafficActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskQuiesceTraffic"); assertThat(pi).isStarted().hasPassedInOrder("VNFQuiesceTrafficActivity_Start", "TaskPreProcessActivity", "TaskQuiesceTraffic", "VNFQuiesceTrafficActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,12 @@ public class VNFQuiesceTrafficActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFQuiesceTrafficActivity_Test() throws Exception { - variables.put("actionQuiesceTraffic", Action.QuiesceTraffic); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFQuiesceTrafficActivity", variables); assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFQuiesceTrafficActivity_Start", "TaskPreProcessActivity", "TaskQuiesceTraffic") - .hasNotPassed("VNFQuiesceTrafficActivity_End"); + .hasPassedInOrder("VNFQuiesceTrafficActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskQuiesceTraffic", "VNFQuiesceTrafficActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFResumeTrafficActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFResumeTrafficActivityTest.java index 61d88a5770..ae61f3c46e 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFResumeTrafficActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFResumeTrafficActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFResumeTrafficActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFResumeTrafficActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFResumeTrafficActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskResumeTraffic"); assertThat(pi).isStarted().hasPassedInOrder("VNFResumeTrafficActivity_Start", "TaskPreProcessActivity", "TaskResumeTraffic", "VNFResumeTrafficActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,12 @@ public class VNFResumeTrafficActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFResumeTrafficActivity_Test() throws Exception { - variables.put("actionResumeTraffic", Action.ResumeTraffic); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFResumeTrafficActivity", variables); assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFResumeTrafficActivity_Start", "TaskPreProcessActivity", "TaskResumeTraffic") - .hasNotPassed("VNFResumeTrafficActivity_End"); + .hasPassedInOrder("VNFResumeTrafficActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskResumeTraffic", "VNFResumeTrafficActivity_End"); } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFSetClosedLoopDisabledFlagActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFSetClosedLoopDisabledFlagActivityTest.java index 001dc70b54..513afd35e5 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFSetClosedLoopDisabledFlagActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFSetClosedLoopDisabledFlagActivityTest.java @@ -21,7 +21,6 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; -import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Mockito.doThrow; import org.camunda.bpm.engine.delegate.BpmnError; diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFSnapShotActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFSnapShotActivityTest.java index 6f1e076c02..b883f1cb28 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFSnapShotActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFSnapShotActivityTest.java @@ -28,27 +28,27 @@ import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFSnapShotActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFSnapShotActivity_Test() throws InterruptedException { + variables.put("vmIdListSize", 0); + variables.put("vmIdList", null); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFSnapShotActivity", variables); assertThat(pi).isNotNull(); - assertThat(pi).isStarted().hasPassedInOrder("VNFSnapShotActivity_Start", "TaskPreProcessActivity", - "TaskSnapShot", "VNFSnapShotActivity_End"); + assertThat(pi).isStarted() + .hasPassedInOrder("VNFSnapShotActivity_Start", "TaskPreProcessActivity", "VNFSnapShotActivity_End") + .hasNotPassed("TaskSnapShot"); assertThat(pi).isEnded(); } @Test public void rainyDayVNFSnapShotActivity_Test() throws Exception { - variables.put("actionSnapshot", Action.Snapshot); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFSnapShotActivity", variables); - assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFSnapShotActivity_Start", "TaskPreProcessActivity", "TaskSnapShot") - .hasNotPassed("VNFSnapShotActivity_End"); + assertThat(pi).isNotNull().isStarted().hasPassedInOrder("VNFSnapShotActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskSnapShot", "VNFSnapShotActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStartActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStartActivityTest.java index 2163e0b7a8..0a700c5fa1 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStartActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStartActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFStartActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFStartActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFStartActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskStart"); assertThat(pi).isStarted().hasPassedInOrder("VNFStartActivity_Start", "TaskPreProcessActivity", "TaskStart", "VNFStartActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,11 @@ public class VNFStartActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFStartActivity_Test() throws Exception { - variables.put("actionStart", Action.Start); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFStartActivity", variables); - assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFStartActivity_Start", "TaskPreProcessActivity", "TaskStart") - .hasNotPassed("VNFStartActivity_End"); + assertThat(pi).isNotNull().isStarted().hasPassedInOrder("VNFStartActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskStart", "VNFStartActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStopActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStopActivityTest.java index 58dfff8bd7..89cc13f0f0 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStopActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStopActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFStopActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFStopActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFStopActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskStop"); assertThat(pi).isStarted().hasPassedInOrder("VNFStopActivity_Start", "TaskPreProcessActivity", "TaskStop", "VNFStopActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,11 @@ public class VNFStopActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFStopActivity_Test() throws Exception { - variables.put("actionStop", Action.Stop); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFStopActivity", variables); - assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFStopActivity_Start", "TaskPreProcessActivity", "TaskStop") - .hasNotPassed("VNFStopActivity_End"); + assertThat(pi).isNotNull().isStarted().hasPassedInOrder("VNFStopActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskStop", "VNFStopActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUnlockActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUnlockActivityTest.java index c5ddd56880..0dbde4b62c 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUnlockActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUnlockActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFUnlockActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFUnlockActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUnlockActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskUnlock"); assertThat(pi).isStarted().hasPassedInOrder("VNFUnlockActivity_Start", "TaskPreProcessActivity", "TaskUnlock", "VNFUnlockActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,11 @@ public class VNFUnlockActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFUnlockActivity_Test() throws Exception { - variables.put("actionUnlock", Action.Unlock); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUnlockActivity", variables); - assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFUnlockActivity_Start", "TaskPreProcessActivity", "TaskUnlock") - .hasNotPassed("VNFUnlockActivity_End"); + assertThat(pi).isNotNull().isStarted().hasPassedInOrder("VNFUnlockActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskUnlock", "VNFUnlockActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradeBackupActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradeBackupActivityTest.java index 4d99147761..2d4a11c17e 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradeBackupActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradeBackupActivityTest.java @@ -23,18 +23,20 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFUpgradeBackupActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFUpgradeBackupActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUpgradeBackupActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskUpgradeBackup"); assertThat(pi).isStarted().hasPassedInOrder("VNFUpgradeBackupActivity_Start", "TaskPreProcessActivity", "TaskUpgradeBackup", "VNFUpgradeBackupActivity_End"); assertThat(pi).isEnded(); @@ -42,14 +44,12 @@ public class VNFUpgradeBackupActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFUpgradeBackupActivity_Test() throws Exception { - variables.put("actionUpgradeBackup", Action.UpgradeBackup); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUpgradeBackupActivity", variables); assertThat(pi).isNotNull(); - assertThat(pi).isStarted() - .hasPassedInOrder("VNFUpgradeBackupActivity_Start", "TaskPreProcessActivity", "TaskUpgradeBackup") - .hasNotPassed("VNFUpgradeBackupActivity_End"); + assertThat(pi).isStarted().hasPassedInOrder("VNFUpgradeBackupActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskUpgradeBackup", "VNFUpgradeBackupActivity_End"); assertThat(pi).isEnded(); } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradePostCheckActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradePostCheckActivityTest.java index c87cc44f29..dfb6bc1d9c 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradePostCheckActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradePostCheckActivityTest.java @@ -20,20 +20,22 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFUpgradePostCheckActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFUpgradePostCheckActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUpgradePostCheckActivity", variables); + processExternalTasks(pi, "TaskUpgradePostCheck"); assertThat(pi).isNotNull().isStarted().hasPassedInOrder("VNFUpgradePostCheckActivity_Start", "TaskPreProcessActivity", "TaskUpgradePostCheck", "VNFUpgradePostCheckActivity_End"); @@ -41,14 +43,12 @@ public class VNFUpgradePostCheckActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFUpgradePostCheckActivity_Test() throws Exception { - variables.put("actionUpgradePostCheck", Action.UpgradePostCheck); - - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUpgradePostCheckActivity", variables); assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFUpgradePostCheckActivity_Start", "TaskPreProcessActivity", "TaskUpgradePostCheck") - .hasNotPassed("VNFUpgradePostCheckActivity_End"); + .hasPassedInOrder("VNFUpgradePostCheckActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskUpgradePostCheck", "VNFUpgradePostCheckActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradePreCheckActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradePreCheckActivityTest.java index 79fc43396d..9854bd8860 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradePreCheckActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradePreCheckActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFUpgradePreCheckActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFUpgradePreCheckActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUpgradePreCheckActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskUpgradePreCheck"); assertThat(pi).isStarted().hasPassedInOrder("VNFUpgradePreCheckActivity_Start", "TaskPreProcessActivity", "TaskUpgradePreCheck", "VNFUpgradePreCheckActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,12 @@ public class VNFUpgradePreCheckActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFUpgradePreCheckActivity_Test() throws Exception { - variables.put("actionUpgradePreCheck", Action.UpgradePreCheck); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUpgradePreCheckActivity", variables); assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFUpgradePreCheckActivity_Start", "TaskPreProcessActivity", "TaskUpgradePreCheck") - .hasNotPassed("VNFUpgradePreCheckActivity_End"); + .hasPassedInOrder("VNFUpgradePreCheckActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskUpgradePreCheck", "VNFUpgradePreCheckActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradeSoftwareActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradeSoftwareActivityTest.java index b550185702..de999e1074 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradeSoftwareActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradeSoftwareActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFUpgradeSoftwareActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFUpgradeSoftwareActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUpgradeSoftwareActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskUpgradeSoftware"); assertThat(pi).isStarted().hasPassedInOrder("VNFUpgradeSoftwareActivity_Start", "TaskPreProcessActivity", "TaskUpgradeSoftware", "VNFUpgradeSoftwareActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,12 @@ public class VNFUpgradeSoftwareActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFUpgradeSoftwareActivity_Test() throws Exception { - variables.put("actionUpgradeSoftware", Action.UpgradeSoftware); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUpgradeSoftwareActivity", variables); assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFUpgradeSoftwareActivity_Start", "TaskPreProcessActivity", "TaskUpgradeSoftware") - .hasNotPassed("VNFUpgradeSoftwareActivity_End"); + .hasPassedInOrder("VNFUpgradeSoftwareActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskUpgradeSoftware", "VNFUpgradeSoftwareActivity_End"); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIFlagTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIFlagTasks.java index 1add5e6d24..997d20036f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIFlagTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIFlagTasks.java @@ -35,6 +35,8 @@ import org.springframework.stereotype.Component; @Component public class AAIFlagTasks { + private static final Logger logger = LoggerFactory.getLogger(AAIFlagTasks.class); + @Autowired private AAIVnfResources aaiVnfResources; @@ -107,7 +109,7 @@ public class AAIFlagTasks { String vnfId = vnf.getVnfId(); inPserversLocked = aaiVnfResources.checkVnfPserversLockedFlag(vnfId); } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + logger.warn("Exception on checking pservers: " + ex.getMessage()); } if (inPserversLocked) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "VNF PServers in Locked in A&AI"); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java new file mode 100644 index 0000000000..4b967c7bc4 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java @@ -0,0 +1,189 @@ +package org.onap.so.bpmn.infrastructure.appc.tasks; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import org.onap.aai.domain.yang.Vserver; +import org.onap.appc.client.lcm.model.Action; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVm; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +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.AAIObjectType; +import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.Relationships; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.exception.BBObjectNotFoundException; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.AAIVnfResources; +import org.onap.so.db.catalog.beans.ControllerSelectionReference; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class AppcOrchestratorPreProcessor { + private static final Logger logger = LoggerFactory.getLogger(AppcOrchestratorPreProcessor.class); + public static final String CONTROLLER_TYPE_DEFAULT = "APPC"; + + @Autowired + private ExceptionBuilder exceptionUtil; + @Autowired + private ExtractPojosForBB extractPojosForBB; + @Autowired + private CatalogDbClient catalogDbClient; + @Autowired + private AAIVnfResources aaiVnfResources; + + public void buildAppcTaskRequest(BuildingBlockExecution execution, String actionName) { + try { + Action action = Action.valueOf(actionName); + ApplicationControllerTaskRequest appcTaskRequest = new ApplicationControllerTaskRequest(); + appcTaskRequest.setAction(action); + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + GenericVnf vnf = null; + try { + vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + } catch (BBObjectNotFoundException e) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "No valid VNF exists"); + } + String vnfId = null; + String vnfName = null; + String vnfType = null; + String vnfHostIpAddress = null; + + if (vnf != null) { + vnfId = vnf.getVnfId(); + vnfName = vnf.getVnfName(); + vnfType = vnf.getVnfType(); + vnfHostIpAddress = vnf.getIpv4OamAddress(); + } + String msoRequestId = gBBInput.getRequestContext().getMsoRequestId(); + + String aicIdentity = execution.getVariable("aicIdentity"); + String identityUrl = execution.getVariable("identityUrl"); + appcTaskRequest.setIdentityUrl(identityUrl); + + if (gBBInput.getRequestContext().getRequestParameters() != null) { + String payload = gBBInput.getRequestContext().getRequestParameters().getPayload(); + if (payload == null) { + payload = ""; + } + String existingSoftwareVersion = JsonUtils.getJsonValue(payload, "existing-software-version"); + appcTaskRequest.setExistingSoftwareVersion(existingSoftwareVersion); + String newSoftwareVersion = JsonUtils.getJsonValue(payload, "new-software-version"); + appcTaskRequest.setNewSoftwareVersion(newSoftwareVersion); + String operationsTimeout = JsonUtils.getJsonValue(payload, "operations-timeout"); + appcTaskRequest.setOperationsTimeout(operationsTimeout); + } + + ControllerSelectionReference controllerSelectionReference = catalogDbClient + .getControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, action.toString()); + String controllerType = null; + if (controllerSelectionReference != null) { + controllerType = controllerSelectionReference.getControllerName(); + } else { + controllerType = CONTROLLER_TYPE_DEFAULT; + } + appcTaskRequest.setControllerType(controllerType); + + execution.setVariable("vmIdList", null); + execution.setVariable("vserverIdList", null); + execution.setVariable("vmIndex", 0); + execution.setVariable("vmIdListSize", 0); + + String vfModuleId = null; + VfModule vfModule = null; + try { + vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); + } catch (BBObjectNotFoundException e) { + } + if (vfModule != null) { + vfModuleId = vfModule.getVfModuleId(); + } + if (action.equals(Action.Snapshot)) { + try { + getVserversForAppc(execution, vnf); + } catch (Exception e) { + logger.warn("Unable to retrieve vservers for vnf: " + vnfId); + } + } + + ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf(); + applicationControllerVnf.setVnfHostIpAddress(vnfHostIpAddress); + applicationControllerVnf.setVnfId(vnfId); + applicationControllerVnf.setVnfName(vnfName); + appcTaskRequest.setApplicationControllerVnf(applicationControllerVnf); + + execution.setVariable("appcOrchestratorRequest", appcTaskRequest); + } catch (Exception e) { + logger.error("Error building ApplicationControllerTaskRequest Object", e); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e); + } + } + + public void addVmInfoToAppcTaskRequest(BuildingBlockExecution execution) { + try { + ApplicationControllerTaskRequest appcTaskRequest = + (ApplicationControllerTaskRequest) execution.getVariable("appcOrchestratorRequest"); + ArrayList<String> vmIdList = execution.getVariable("vmIdList"); + ArrayList<String> vserverIdList = execution.getVariable("vserverIdList"); + Integer vmIndex = (Integer) execution.getVariable("vmIndex"); + + if (vmIdList != null && !vmIdList.isEmpty() && vserverIdList != null && !vserverIdList.isEmpty()) { + execution.setVariable("vmIdListSize", vmIdList.size()); + if (vmIndex < vmIdList.size()) { + ApplicationControllerVm applicationControllerVm = new ApplicationControllerVm(); + applicationControllerVm.setVmId(vmIdList.get(vmIndex)); + applicationControllerVm.setVserverId(vserverIdList.get(vmIndex)); + if (appcTaskRequest.getApplicationControllerVnf() == null) { + ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf(); + appcTaskRequest.setApplicationControllerVnf(applicationControllerVnf); + } + appcTaskRequest.getApplicationControllerVnf().setApplicationControllerVm(applicationControllerVm); + execution.setVariable("appcOrchestratorRequest", appcTaskRequest); + vmIndex++; + execution.setVariable("vmIndex", vmIndex); + } + } + } catch (Exception e) { + logger.error("Error adding VM info to ApplicationControllerTaskRequest Object", e); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e); + } + } + + protected void getVserversForAppc(BuildingBlockExecution execution, GenericVnf vnf) throws Exception { + AAIResultWrapper aaiRW = aaiVnfResources.queryVnfWrapperById(vnf); + + if (aaiRW != null && aaiRW.getRelationships().isPresent()) { + Relationships relationships = aaiRW.getRelationships().get(); + if (relationships != null) { + List<AAIResourceUri> vserverUris = relationships.getRelatedAAIUris(AAIObjectType.VSERVER); + ArrayList<String> vserverIds = new ArrayList<String>(); + ArrayList<String> vserverSelfLinks = new ArrayList<String>(); + for (AAIResourceUri j : vserverUris) { + String vserverId = j.getURIKeys().get("vserver-id"); + vserverIds.add(vserverId); + Optional<Vserver> oVserver = aaiVnfResources.getVserver(j); + if (oVserver.isPresent()) { + Vserver vserver = oVserver.get(); + String vserverSelfLink = vserver.getVserverSelflink(); + vserverSelfLinks.add(vserverSelfLink); + } + } + logger.debug("vmIdsArray is: {}", vserverSelfLinks); + logger.debug("vserverIdsArray is: {}", vserverIds); + execution.setVariable("vmIdList", vserverSelfLinks); + execution.setVariable("vserverIdList", vserverIds); + } + } + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 99ba35232c..356fe8d9a2 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -1555,7 +1555,7 @@ public class WorkflowAction { if (flows == null) flows = new ArrayList<>(); for (OrchestrationFlow flow : flows) { - if (!flow.getFlowName().contains("BB")) { + if (!flow.getFlowName().contains("BB") && !flow.getFlowName().contains("Activity")) { List<OrchestrationFlow> macroQueryFlows = catalogDbClient.getOrchestrationFlowByAction(flow.getFlowName()); for (OrchestrationFlow macroFlow : macroQueryFlows) { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java new file mode 100644 index 0000000000..c78b652bd0 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java @@ -0,0 +1,166 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ + * 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.appc.tasks; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Optional; +import org.junit.Test; +import org.mockito.ArgumentMatchers; +import org.mockito.InjectMocks; +import org.onap.aai.domain.yang.Vserver; +import org.onap.appc.client.lcm.model.Action; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf; +import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.policy.JettisonStyleMapperProvider; +import org.onap.so.db.catalog.beans.ControllerSelectionReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class AppcOrchestratorPreProcessorTest extends BaseTaskTest { + + private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/"; + + @InjectMocks + private AppcOrchestratorPreProcessor appcOrchestratorPreProcessor = new AppcOrchestratorPreProcessor(); + + private ObjectMapper mapper = new JettisonStyleMapperProvider().getMapper(); + + @Test + public void buildAppcTaskRequestTest() throws Exception { + final String expectedRequestJson = + new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "appcTaskRequest.json"))); + ApplicationControllerTaskRequest expectedTaskRequest = + mapper.readValue(expectedRequestJson, ApplicationControllerTaskRequest.class); + execution.getLookupMap().put(ResourceKey.GENERIC_VNF_ID, "-TEST"); + fillRequiredAppcExecutionFields(); + GenericVnf genericVnf = getTestGenericVnf(); + when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf); + mockReferenceResponse(); + execution.getLookupMap().put(ResourceKey.VF_MODULE_ID, "VF-MODULE-ID-TEST"); + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("VF-MODULE-ID"); + when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); + appcOrchestratorPreProcessor.buildAppcTaskRequest(execution, "Lock"); + ApplicationControllerTaskRequest actualTaskRequest = execution.getVariable("appcOrchestratorRequest"); + assertThat(actualTaskRequest, sameBeanAs(expectedTaskRequest)); + } + + @Test + public void getVserversForAppcTest() throws Exception { + + GenericVnf genericVnf = getTestGenericVnf(); + + final String aaiVnfJson = + new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiGenericVnfWithVservers.json"))); + final String aaiVserverJson = + new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVserverQueryResponse.json"))); + AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiVnfJson); + ObjectMapper mapper = new ObjectMapper(); + Vserver vserver = mapper.readValue(aaiVserverJson, Vserver.class); + doReturn(aaiResultWrapper).when(aaiVnfResources).queryVnfWrapperById(genericVnf); + doReturn(Optional.of(vserver)).when(aaiVnfResources).getVserver(ArgumentMatchers.any(AAIResourceUri.class)); + appcOrchestratorPreProcessor.getVserversForAppc(execution, genericVnf); + ArrayList<String> vserverIdList = execution.getVariable("vserverIdList"); + ArrayList<String> expectedVserverIdList = new ArrayList<String>(); + expectedVserverIdList.add("1b3f44e5-d96d-4aac-bd9a-310e8cfb0af5"); + expectedVserverIdList.add("14551849-1e70-45cd-bc5d-a256d49548a2"); + expectedVserverIdList.add("48bd7f11-408f-417c-b834-b41c1b98f7d7"); + ArrayList<String> vmIdList = execution.getVariable("vmIdList"); + ArrayList<String> expectedVmIdList = new ArrayList<String>(); + expectedVmIdList.add("http://VSERVER-link.com"); + expectedVmIdList.add("http://VSERVER-link.com"); + expectedVmIdList.add("http://VSERVER-link.com"); + assertEquals(vserverIdList, expectedVserverIdList); + assertEquals(vmIdList, expectedVmIdList); + } + + @Test + public void addVmInfoToAppcTaskRequestTest() throws Exception { + ApplicationControllerTaskRequest appcTaskRequest = new ApplicationControllerTaskRequest(); + ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf(); + appcTaskRequest.setApplicationControllerVnf(applicationControllerVnf); + execution.setVariable("appcOrchestratorRequest", appcTaskRequest); + ArrayList<String> vmIdList = new ArrayList<String>(); + vmIdList.add("http://VSERVER-link.com"); + vmIdList.add("http://VSERVER-link.com"); + vmIdList.add("http://VSERVER-link.com"); + execution.setVariable("vmIdList", vmIdList); + ArrayList<String> vserverIdList = new ArrayList<String>(); + vserverIdList.add("1b3f44e5-d96d-4aac-bd9a-310e8cfb0af5"); + vserverIdList.add("14551849-1e70-45cd-bc5d-a256d49548a2"); + vserverIdList.add("48bd7f11-408f-417c-b834-b41c1b98f7d7"); + execution.setVariable("vserverIdList", vserverIdList); + execution.setVariable("vmIndex", 1); + appcOrchestratorPreProcessor.addVmInfoToAppcTaskRequest(execution); + Integer nextVmIndex = execution.getVariable("vmIndex"); + assertThat(nextVmIndex == 2); + Integer vmIdListSize = execution.getVariable("vmIdListSize"); + assertThat(vmIdListSize == 3); + appcTaskRequest = execution.getVariable("appcOrchestratorRequest"); + assertEquals(appcTaskRequest.getApplicationControllerVnf().getApplicationControllerVm().getVserverId(), + "14551849-1e70-45cd-bc5d-a256d49548a2"); + assertEquals(appcTaskRequest.getApplicationControllerVnf().getApplicationControllerVm().getVmId(), + "http://VSERVER-link.com"); + } + + private void mockReferenceResponse() { + ControllerSelectionReference reference = new ControllerSelectionReference(); + reference.setControllerName("TEST-CONTROLLER-NAME"); + when(catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(eq("TEST-VNF-TYPE"), + eq(Action.Lock.toString()))).thenReturn(reference); + } + + private void fillRequiredAppcExecutionFields() { + RequestContext context = new RequestContext(); + context.setMsoRequestId("TEST-MSO-ID"); + execution.setVariable("aicIdentity", "AIC-TEST"); + execution.setVariable("vmIdList", "VM-ID-LIST-TEST"); + execution.setVariable("vserverIdList", "VSERVER-ID-LIST"); + execution.setVariable("identityUrl", "IDENTITY-URL-TEST"); + execution.getGeneralBuildingBlock().setRequestContext(context); + } + + private GenericVnf getTestGenericVnf() { + GenericVnf genericVnf = new GenericVnf(); + genericVnf.setVnfId("TEST-VNF-ID"); + genericVnf.setVnfType("TEST-VNF-TYPE"); + genericVnf.setVnfName("TEST-VNF-NAME"); + genericVnf.setIpv4OamAddress("127.0.0.1"); + return genericVnf; + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json new file mode 100644 index 0000000000..957c603dc9 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json @@ -0,0 +1,12 @@ +{ + "ApplicationControllerTaskRequest": { + "controllerType": "TEST-CONTROLLER-NAME", + "action": "Lock", + "identityUrl": "IDENTITY-URL-TEST", + "applicationControllerVnf": { + "vnfId": "TEST-VNF-ID", + "vnfName": "TEST-VNF-NAME", + "vnfHostIpAddress": "127.0.0.1" + } + } +}
\ No newline at end of file diff --git a/common/pom.xml b/common/pom.xml index 94b28e91bd..cdd5df950a 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -16,6 +16,7 @@ <protobuf.version>3.6.1</protobuf.version> <grpc.netty.version>4.1.30.Final</grpc.netty.version> <ccsdk.version>0.4.2</ccsdk.version> + <appc.client.version>1.6.0-SNAPSHOT</appc.client.version> </properties> <dependencies> @@ -202,6 +203,66 @@ <artifactId>camunda-external-task-client</artifactId> <version>1.1.1</version> </dependency> + <dependency> + <groupId>org.onap.appc.client</groupId> + <artifactId>client-lib</artifactId> + <version>${appc.client.version}</version> + <exclusions> + <exclusion> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </exclusion> + <exclusion> + <groupId>org.powermock</groupId> + <artifactId>powermock-module-junit4</artifactId> + </exclusion> + <exclusion> + <groupId>org.powermock</groupId> + <artifactId>powermock-api-mockito</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.onap.appc.client</groupId> + <artifactId>client-kit</artifactId> + <version>${appc.client.version}</version> + <exclusions> + <exclusion> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.onap.appc.client</groupId> + <artifactId>client-lib</artifactId> + <version>${appc.client.version}</version> + <exclusions> + <exclusion> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </exclusion> + <exclusion> + <groupId>org.powermock</groupId> + <artifactId>powermock-module-junit4</artifactId> + </exclusion> + <exclusion> + <groupId>org.powermock</groupId> + <artifactId>powermock-api-mockito</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.onap.appc.client</groupId> + <artifactId>client-kit</artifactId> + <version>${appc.client.version}</version> + <exclusions> + <exclusion> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </exclusion> + </exclusions> + </dependency> </dependencies> <dependencyManagement> <dependencies> diff --git a/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java new file mode 100644 index 0000000000..3811b52551 --- /dev/null +++ b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java @@ -0,0 +1,104 @@ +package org.onap.so.appc.orchestrator.service.beans; + +import java.io.Serializable; +import org.onap.appc.client.lcm.model.Action; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf; + +public class ApplicationControllerTaskRequest implements Serializable { + + private static final long serialVersionUID = -3150320542857627682L; + + private Action action; + private String controllerType; + private String identityUrl; + private String operationsTimeout; + private String bookName; + private String nodeList; + private String fileParameters; + private String existingSoftwareVersion; + private String newSoftwareVersion; + private ApplicationControllerVnf applicationControllerVnf; + + public Action getAction() { + return action; + } + + public void setAction(Action action) { + this.action = action; + } + + public String getControllerType() { + return controllerType; + } + + public void setControllerType(String controllerType) { + this.controllerType = controllerType; + } + + public ApplicationControllerVnf getApplicationControllerVnf() { + return applicationControllerVnf; + } + + public void setApplicationControllerVnf(ApplicationControllerVnf applicationControllerVnf) { + this.applicationControllerVnf = applicationControllerVnf; + } + + public String getIdentityUrl() { + return identityUrl; + } + + public void setIdentityUrl(String identityUrl) { + this.identityUrl = identityUrl; + } + + public String getOperationsTimeout() { + return operationsTimeout; + } + + public void setOperationsTimeout(String operationsTimeout) { + this.operationsTimeout = operationsTimeout; + } + + public String getBookName() { + return bookName; + } + + public void setBookName(String bookName) { + this.bookName = bookName; + } + + public String getNodeList() { + return nodeList; + } + + public void setNodeList(String nodeList) { + this.nodeList = nodeList; + } + + public String getFileParameters() { + return fileParameters; + } + + public void setFileParameters(String fileParameters) { + this.fileParameters = fileParameters; + } + + public String getExistingSoftwareVersion() { + return existingSoftwareVersion; + } + + public void setExistingSoftwareVersion(String existingSoftwareVersion) { + this.existingSoftwareVersion = existingSoftwareVersion; + } + + public String getNewSoftwareVersion() { + return newSoftwareVersion; + } + + public void setNewSoftwareVersion(String newSoftwareVersion) { + this.newSoftwareVersion = newSoftwareVersion; + } + + + +} diff --git a/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerVm.java b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerVm.java new file mode 100644 index 0000000000..75e2053077 --- /dev/null +++ b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerVm.java @@ -0,0 +1,30 @@ +package org.onap.so.appc.orchestrator.service.beans; + +import java.io.Serializable; +import java.util.List; + +public class ApplicationControllerVm implements Serializable { + + private static final long serialVersionUID = 2786675508024214638L; + + private String vserverId; + private String vmId; + + public String getVserverId() { + return vserverId; + } + + public void setVserverId(String vserverId) { + this.vserverId = vserverId; + } + + public String getVmId() { + return vmId; + } + + public void setVmId(String vmId) { + this.vmId = vmId; + } + + +} diff --git a/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerVnf.java b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerVnf.java new file mode 100644 index 0000000000..526941dc39 --- /dev/null +++ b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerVnf.java @@ -0,0 +1,49 @@ +package org.onap.so.appc.orchestrator.service.beans; + +import java.io.Serializable; +import java.util.List; + +public class ApplicationControllerVnf implements Serializable { + + private static final long serialVersionUID = 2786675508024214637L; + + private String vnfId; + private String vnfName; + private String vnfHostIpAddress; + private ApplicationControllerVm applicationControllerVm; + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getVnfName() { + return vnfName; + } + + public void setVnfName(String vnfName) { + this.vnfName = vnfName; + } + + public String getVnfHostIpAddress() { + return vnfHostIpAddress; + } + + public void setVnfHostIpAddress(String vnfHostIpAddress) { + this.vnfHostIpAddress = vnfHostIpAddress; + } + + public ApplicationControllerVm getApplicationControllerVm() { + return applicationControllerVm; + } + + public void setApplicationControllerVm(ApplicationControllerVm applicationControllerVm) { + this.applicationControllerVm = applicationControllerVm; + } + + + +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/Vnfs.java b/common/src/main/java/org/onap/so/serviceinstancebeans/Vnfs.java index a2eb35464b..ca67f566b1 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/Vnfs.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/Vnfs.java @@ -51,7 +51,8 @@ public class Vnfs implements Serializable { private List<Map<String, String>> instanceParams = new ArrayList<>(); @JsonProperty("vfModules") private List<VfModules> vfModules = new ArrayList<>(); - + @JsonProperty("applicationId") + protected String applicationId; public ModelInfo getModelInfo() { return modelInfo; @@ -117,12 +118,20 @@ public class Vnfs implements Serializable { this.vfModules = vfModules; } + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + @Override public String toString() { return "Vnfs [modelInfo=" + modelInfo + ", cloudConfiguration=" + cloudConfiguration + ", instanceName=" + instanceName + ", platform=" + platform + ", " + "lineOfBusiness=" + lineOfBusiness + ", productFamilyId=" + productFamilyId + ", instanceParams=" + instanceParams + ", vfModules=" - + vfModules + "]"; + + vfModules + ", applicaionId=" + applicationId + " ]"; } } diff --git a/common/src/test/java/org/onap/so/BeansTest.java b/common/src/test/java/org/onap/so/BeansTest.java index 8bde3c4eb7..9e8a0184ab 100644 --- a/common/src/test/java/org/onap/so/BeansTest.java +++ b/common/src/test/java/org/onap/so/BeansTest.java @@ -60,6 +60,7 @@ public class BeansTest { @Test public void pojoStructure() { + test("org.onap.so.appc.orchestrator.service.beans"); test("org.onap.so.client.policy.entities"); test("org.onap.so.client.grm.beans"); test("org.onap.so.client.ruby.beans"); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SoSubsystems.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SoSubsystems.java index 5842531dc3..b76cd42bb3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SoSubsystems.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SoSubsystems.java @@ -26,7 +26,8 @@ public enum SoSubsystems implements Subsystem { CATALOGDB("CatalogDb Adapter"), OPENSTACK("Openstack Adapter"), REQUESTDB("RequestDB Adapter"), - SDNC("SDNC Adapter"); + SDNC("SDNC Adapter"), + SOAPPCORCHESTRATOR("SO APPC Orchestrator"); private String subsystem; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml b/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml index 27e1ae90d2..1d6722278c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml @@ -23,6 +23,8 @@ mso: uri: http://localhost:${wiremock.server.port} - subsystem: sdnc uri: http://localhost:${wiremock.server.port} + - subsystem: soappcorchestrator + uri: http://localhost:${wiremock.server.port} infra-requests: archived: period: 180 diff --git a/packages/docker/pom.xml b/packages/docker/pom.xml index f1d5b53ace..5d09ffb0d6 100644 --- a/packages/docker/pom.xml +++ b/packages/docker/pom.xml @@ -231,6 +231,31 @@ </assembly> </build> </image> + <image> + <name>${docker.image.prefix}/so-appc-orchestrator</name> + <build> + <cleanup>try</cleanup> + <dockerFileDir>docker-files</dockerFileDir> + <dockerFile>Dockerfile.so-app</dockerFile> + <tags> + <tag>${project.version}</tag> + <tag>${project.version}-${maven.build.timestamp}</tag> + <tag>${project.docker.latesttag.version}</tag> + </tags> + <assembly> + <inline> + <dependencySets> + <dependencySet> + <includes> + <include>org.onap.so.adapters:so-appc-orchestrator</include> + </includes> + <outputFileNameMapping>app.jar</outputFileNameMapping> + </dependencySet> + </dependencySets> + </inline> + </assembly> + </build> + </image> <image> <name>${docker.image.prefix}/sdc-controller</name> <build> |