aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2020-01-16 17:56:08 +0000
committerGerrit Code Review <gerrit@onap.org>2020-01-16 17:56:08 +0000
commit31e4876968f144b875e21f4499701ba2f16dc94f (patch)
tree94f1001bb4432db0f39384f9de072c2ebc23c41e /bpmn/so-bpmn-tasks/src/main
parente6d05b9359582d2a8bddfeb73527d134586410b7 (diff)
parent833d219c3b6689ea27f46719a3a00cbaf7e649fe (diff)
Merge "1911 create appc adapter micro service"
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIFlagTasks.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java189
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java2
3 files changed, 193 insertions, 2 deletions
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) {