summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-01-24 17:06:39 -0500
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-01-24 17:13:01 -0500
commit7ab8e99936aa0dd72c8b0f54620bbfef8d7ec455 (patch)
tree7018cb258315e327f4817a7f01abe344426f4426 /bpmn/so-bpmn-tasks/src
parent147e9ee814448c8bbec4aa3aeac4b7118b7c1bc7 (diff)
bugfixes jan 24th
Fix null pointer exception when no requestParameters are specified Add configurable timer in ActivateVfModuleBB to delay call to SDNC activate - Use raw slf4j logger - use {} formatting Add configurable timer in ActivateVfModuleBB to delay call to SDNC activate - Use raw slf4j logger Add configurable timer in ActivateVfModuleBB to delay call to SDNC activate - removed unused references in test class Add configurable timer in ActivateVfModuleBB to delay call to SDNC activate Update PortGroup objects separately from the parent VCE object - restore setVariable calls back into vce object - they might be needed later. Update PortGroup objects separately from the parent VCE object - updated test class extra call to get PortGroups Update PortGroup objects separately from the parent VCE object - use PortGroup.getInterfaceRole() getter method instead of accessing field directly. Update PortGroup objects separately from the parent VCE object Added back required headers for tenant isolation. removed workflow exception from outmapping in execute Fix possible null ptr exception, fix to add braces. Default networkTechnology in Update as done in Create Fix failing junits, mapper force upper case nwtech update exception builder to properly throw exception error message supporting assign service instance a la carte as well adding in proper exception handling in network rest v1 add the unassign action to R macro data file Change-Id: Ide420514f81b8083b4c76c762c064de199624cf7 Issue-ID: SO-1424 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks/src')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModule.java35
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java5
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java38
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java24
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java38
6 files changed, 104 insertions, 40 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java
index d821223507..d919c53c9c 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java
@@ -68,8 +68,8 @@ public class NetworkAdapterRestV1 {
throw new Exception("No Network Request was created. networkAdapterRequest was null.");
}
} catch (Exception ex) {
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, ex.getStackTrace().toString());
- }
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
}
public void processCallback (DelegateExecution execution) {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModule.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModule.java
new file mode 100644
index 0000000000..32c852b0e1
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModule.java
@@ -0,0 +1,35 @@
+package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
+
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.client.exception.ExceptionBuilder;
+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;
+
+@Component
+public class ActivateVfModule {
+
+ private static final Logger logger = LoggerFactory.getLogger(ActivateVfModule.class);
+
+ protected static final String VF_MODULE_TIMER_DURATION_PATH = "mso.workflow.vfModuleActivate.timer.duration";
+ protected static final String DEFAULT_TIMER_DURATION = "PT180S";
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+
+ @Autowired
+ private Environment environment;
+
+
+ public void setTimerDuration(BuildingBlockExecution execution) {
+ try {
+ String waitDuration = this.environment.getProperty(VF_MODULE_TIMER_DURATION_PATH, DEFAULT_TIMER_DURATION);
+ logger.debug("Sleeping before proceeding with SDNC activate. Timer duration: {}", waitDuration);
+ execution.setVariable("vfModuleActivateTimerDuration", waitDuration);
+ } catch (Exception e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
+ }
+ }
+}
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 d18fd006f4..bff320a0b6 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
@@ -303,8 +303,9 @@ public class WorkflowAction {
}
}
- // If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is specified, enable it.
- if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
+ // If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is specified, enable it.
+ if (sIRequest.getRequestDetails().getRequestParameters() != null &&
+ sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams();
for (Map<String, Object> params : userParams) {
if (params.containsKey(HOMINGSOLUTION)) {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java
index 794314bf8c..4c84ee4003 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java
@@ -22,6 +22,7 @@ package org.onap.so.client.adapter.network.mapper;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -92,14 +93,19 @@ public class NetworkAdapterObjectMapper {
networkTechnology = l3Network.getNetworkTechnology();
logger.warn("NetworkTechnology was null in CatalogDB. Using field from AAI: " + networkTechnology);
}
- createNetworkRequest.setNetworkTechnology(setNetworkTechnology(networkTechnology));
+ if (networkTechnology != null) {
+ createNetworkRequest.setNetworkTechnology(networkTechnology.toUpperCase());
+ if (createNetworkRequest.getNetworkTechnology().contains("CONTRAIL")) {
+ createNetworkRequest.setContrailRequest(true);
+ }
+ }
//build and set Contrail Network
ContrailNetwork contrailNetwork = buildContrailNetwork(l3Network, customer);
createNetworkRequest.setContrailNetwork(contrailNetwork);
- //set Network Parameters from VID request
- createNetworkRequest.setNetworkParams(userInput);
+ //set Network Parameters from VID request, add "shared" and "external" to this map
+ createNetworkRequest.setNetworkParams(addSharedAndExternal(userInput, l3Network));
createNetworkRequest = setFlowFlags(createNetworkRequest, orchestrationContext);
@@ -112,16 +118,6 @@ public class NetworkAdapterObjectMapper {
return createNetworkRequest;
}
- protected NetworkTechnology setNetworkTechnology(String networkTechnology) {
- if(networkTechnology.equalsIgnoreCase("Contrail")) {
- return NetworkTechnology.CONTRAIL;
- } else if(networkTechnology.equalsIgnoreCase("Neutron")){
- return NetworkTechnology.NEUTRON;
- } else {
- return NetworkTechnology.VMWARE;
- }
- }
-
public DeleteNetworkRequest deleteNetworkRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, ServiceInstance serviceInstance, L3Network l3Network) throws UnsupportedEncodingException {
DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
@@ -182,7 +178,7 @@ public class NetworkAdapterObjectMapper {
updateNetworkRequest.setSubnets(buildOpenstackSubnetList(l3Network));
updateNetworkRequest.setProviderVlanNetwork(buildProviderVlanNetwork(l3Network));
updateNetworkRequest.setContrailNetwork(buildContrailNetwork(l3Network, customer));
- updateNetworkRequest.setNetworkParams(userInput);
+ updateNetworkRequest.setNetworkParams(addSharedAndExternal(userInput, l3Network));
updateNetworkRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance));
setFlowFlags(updateNetworkRequest, orchestrationContext);
@@ -371,4 +367,16 @@ public class NetworkAdapterObjectMapper {
updateNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
//NetworkTechnology(NetworkTechnology.NEUTRON); NOOP - default
}
-} \ No newline at end of file
+
+ private Map<String, String> addSharedAndExternal(Map<String, String> userInput, L3Network l3Network) {
+ if (userInput == null)
+ userInput = new HashMap<String, String>();
+ if (!userInput.containsKey("shared")) {
+ userInput.put("shared", Optional.ofNullable(l3Network.isIsSharedNetwork()).orElse(false).toString());
+ }
+ if (!userInput.containsKey("external")) {
+ userInput.put("external", Optional.ofNullable(l3Network.isIsExternalNetwork()).orElse(false).toString());
+ }
+ return userInput;
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java
new file mode 100644
index 0000000000..57e463c0f8
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ActivateVfModuleTest.java
@@ -0,0 +1,24 @@
+package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.onap.so.bpmn.BaseTaskTest;
+
+public class ActivateVfModuleTest extends BaseTaskTest {
+
+ @InjectMocks
+ private ActivateVfModule activateVfModule = new ActivateVfModule();
+
+ @Test
+ public void setWaitBeforeDurationTest() throws Exception {
+ when(env.getProperty(ActivateVfModule.VF_MODULE_TIMER_DURATION_PATH, ActivateVfModule.DEFAULT_TIMER_DURATION)).thenReturn("PT300S");
+ activateVfModule.setTimerDuration(execution);
+ verify(env, times(1)).getProperty(ActivateVfModule.VF_MODULE_TIMER_DURATION_PATH, ActivateVfModule.DEFAULT_TIMER_DURATION);
+ assertEquals("PT300S", (String) execution.getVariable("vfModuleActivateTimerDuration"));
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java
index 1a86d713a2..0a6310b364 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java
@@ -30,6 +30,7 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -99,24 +100,6 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{
}
@Test
- public void testSetNetworkTechnology() {
- String networkTechnology = "Contrail";
- NetworkTechnology expectedNetworkTechnology = NetworkTechnology.CONTRAIL;
- NetworkTechnology actualNetworkTechnology = SPY_networkAdapterObjectMapper.setNetworkTechnology(networkTechnology);
- assertEquals("NetworkTechnology matches", expectedNetworkTechnology, actualNetworkTechnology);
-
- networkTechnology = "Neutron";
- expectedNetworkTechnology = NetworkTechnology.NEUTRON;
- actualNetworkTechnology = SPY_networkAdapterObjectMapper.setNetworkTechnology(networkTechnology);
- assertEquals("NetworkTechnology matches", expectedNetworkTechnology, actualNetworkTechnology);
-
- networkTechnology = "Vmware";
- expectedNetworkTechnology = NetworkTechnology.VMWARE;
- actualNetworkTechnology = SPY_networkAdapterObjectMapper.setNetworkTechnology(networkTechnology);
- assertEquals("NetworkTechnology matches", expectedNetworkTechnology, actualNetworkTechnology);
-
- }
- @Test
public void buildCreateNetworkRequestFromBbobjectTest() throws Exception {
String cloudRegionPo = "cloudRegionPo";
@@ -129,12 +112,17 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{
expectedCreateNetworkRequest.setNetworkType(l3Network.getNetworkType());
expectedCreateNetworkRequest.setBackout(false);
expectedCreateNetworkRequest.setFailIfExists(true);
- expectedCreateNetworkRequest.setNetworkTechnology(NetworkTechnology.CONTRAIL);
+ expectedCreateNetworkRequest.setNetworkTechnology("CONTRAIL");
MsoRequest msoRequest = new MsoRequest();
msoRequest.setRequestId(requestContext.getMsoRequestId());
msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
expectedCreateNetworkRequest.setMsoRequest(msoRequest);
expectedCreateNetworkRequest.setSkipAAI(true);
+ HashMap<String, String> networkParams = new HashMap<String, String>();
+ networkParams.put("shared", "true");
+ networkParams.put("external", "false");
+ networkParams.put("testUserInputKey", "testUserInputValue");
+ expectedCreateNetworkRequest.setNetworkParams(networkParams);
expectedCreateNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
@@ -148,13 +136,15 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{
subnetList.add(openstackSubnet);
l3Network.getSubnets().add(openstackSubnet);
l3Network.setNetworkTechnology("Contrail");
+ l3Network.setIsSharedNetwork(true);
+ l3Network.setIsExternalNetwork(false);
doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
CreateNetworkRequest createNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
- assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("contrailRequest").ignoring("contrailNetwork").ignoring("providerVlanNetwork").ignoring("subnets").ignoring("networkParams").ignoring("messageId"));
+ assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("contrailRequest").ignoring("contrailNetwork").ignoring("providerVlanNetwork").ignoring("subnets").ignoring("messageId"));
}
@Test
@@ -243,6 +233,12 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{
l3Network.getSubnets().add(actualSubnet);
l3Network.getNetworkPolicies().add(networkPolicy);
l3Network.getContrailNetworkRouteTableReferences().add(routeTableReference);
+ l3Network.setIsSharedNetwork(false);
+ l3Network.setIsExternalNetwork(false);
+ HashMap<String, String> networkParams = new HashMap<String, String>();
+ networkParams.put("shared", "false");
+ networkParams.put("external", "false");
+ networkParams.put("testUserInputKey", "testUserInputValue");
UpdateNetworkRequest expectedUpdateNetworkRequest = new UpdateNetworkRequest();
expectedUpdateNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
@@ -256,7 +252,7 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup{
expectedUpdateNetworkRequest.setSubnets(subnets);
expectedUpdateNetworkRequest.setProviderVlanNetwork(providerVlanNetwork);
expectedUpdateNetworkRequest.setContrailNetwork(contrailNetwork);
- expectedUpdateNetworkRequest.setNetworkParams(userInput);
+ expectedUpdateNetworkRequest.setNetworkParams(networkParams);
expectedUpdateNetworkRequest.setMsoRequest(msoRequest);
expectedUpdateNetworkRequest.setSkipAAI(true);
expectedUpdateNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));