aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-02-07 17:25:53 -0500
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-02-07 17:26:07 -0500
commit0f27e7f776cc0d26a4810b76787cf67bc18d03ab (patch)
treeab73600a4f516029c75c4f9c04003b5284d2ec70 /bpmn/so-bpmn-tasks
parentdb2fb3ef8992c12b3be11ab3f6634bf23da1abe9 (diff)
mso is not updating the vip in aai for the vnf
Update JUnits for multiple invocation argument verifications Implement delete mechanism for network policies and vnf adapter params in AAI. Fix a JUnit for getNetworkPolicy(). Implement creation of network policies and setting of openstack-provided params for vf module in AAI CreateNetworkPolicies in AAI functionality update Add the plumbing for create network policy in AAI. Enable VnfAdapterBB to return fqdn and management ip info Change-Id: Id34fe088846a52dbafaf3e7c754bebada05f1bf1 Issue-ID: SO-1478 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java41
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java38
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java49
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java85
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java15
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java9
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java9
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java41
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java42
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java45
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java53
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java18
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java30
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java13
15 files changed, 477 insertions, 15 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
index e2caaf2a67..f47781082d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
@@ -22,7 +22,9 @@ package org.onap.so.bpmn.infrastructure.aai.tasks;
import java.util.Arrays;
import java.util.List;
+import java.util.Optional;
import java.util.TreeSet;
+import java.util.UUID;
import java.util.stream.Collectors;
import org.camunda.bpm.engine.delegate.BpmnError;
@@ -35,6 +37,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
@@ -44,6 +47,9 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.aai.AAIObjectPlurals;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.orchestration.AAIConfigurationResources;
@@ -69,6 +75,9 @@ public class AAICreateTasks {
private static final String networkTypeProvider = "PROVIDER";
private static String NETWORK_COLLECTION_NAME = "networkCollectionName";
+ private static String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList";
+ private static String HEAT_STACK_ID = "heatStackId";
+ private static String NETWORK_POLICY_FQDN_PARAM = "network-policy-fqdn";
@Autowired
private AAIServiceInstanceResources aaiSIResources;
@Autowired
@@ -440,6 +449,38 @@ public class AAICreateTasks {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
+
+ public void createNetworkPolicies(BuildingBlockExecution execution) {
+ try{
+ String fqdns = execution.getVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST);
+ if (fqdns != null && !fqdns.isEmpty()) {
+ String fqdnList[] = fqdns.split(",");
+ int fqdnCount = fqdnList.length;
+ if (fqdnCount > 0) {
+ for (int i=0; i < fqdnCount; i++) {
+ String fqdn = fqdnList[i];
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY);
+ uri.queryParam(NETWORK_POLICY_FQDN_PARAM, fqdn);
+ Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy = aaiNetworkResources.getNetworkPolicy(uri);
+ if(!oNetPolicy.isPresent()) {
+ msoLogger.debug("This network policy FQDN is not in AAI yet: " + fqdn);
+ String networkPolicyId = UUID.randomUUID().toString();
+ msoLogger.debug("Adding network-policy with network-policy-id " + networkPolicyId);
+ NetworkPolicy networkPolicy = new NetworkPolicy();
+ networkPolicy.setNetworkPolicyId(networkPolicyId);
+ networkPolicy.setNetworkPolicyFqdn(fqdn);
+ networkPolicy.setHeatStackId(execution.getVariable(HEAT_STACK_ID));
+
+ aaiNetworkResources.createNetworkPolicy(networkPolicy);
+ }
+ }
+ }
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
/**
* Groups existing vf modules by the model uuid of our new vf module and returns the lowest unused index
*
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java
index a00806a19c..8f0334e462 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java
@@ -21,16 +21,23 @@
package org.onap.so.bpmn.infrastructure.aai.tasks;
+import java.util.Optional;
+import java.util.UUID;
+
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.aai.AAIObjectPlurals;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.orchestration.AAIConfigurationResources;
import org.onap.so.client.orchestration.AAINetworkResources;
@@ -38,11 +45,16 @@ import org.onap.so.client.orchestration.AAIServiceInstanceResources;
import org.onap.so.client.orchestration.AAIVfModuleResources;
import org.onap.so.client.orchestration.AAIVnfResources;
import org.onap.so.client.orchestration.AAIVolumeGroupResources;
+import org.onap.so.logger.MsoLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class AAIDeleteTasks {
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, AAIDeleteTasks.class);
+
+ private static String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList";
+ private static String NETWORK_POLICY_FQDN_PARAM = "network-policy-fqdn";
@Autowired
private ExceptionBuilder exceptionUtil;
@@ -145,4 +157,30 @@ public class AAIDeleteTasks {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
+
+ public void deleteNetworkPolicies(BuildingBlockExecution execution) {
+ try{
+ String fqdns = execution.getVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST);
+ if (fqdns != null && !fqdns.isEmpty()) {
+ String fqdnList[] = fqdns.split(",");
+ int fqdnCount = fqdnList.length;
+ if (fqdnCount > 0) {
+ for (int i=0; i < fqdnCount; i++) {
+ String fqdn = fqdnList[i];
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY);
+ uri.queryParam(NETWORK_POLICY_FQDN_PARAM, fqdn);
+ Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy = aaiNetworkResources.getNetworkPolicy(uri);
+ if(oNetPolicy.isPresent()) {
+ String networkPolicyId = oNetPolicy.get().getNetworkPolicyId();
+ msoLogger.debug("Deleting network-policy with network-policy-id " + networkPolicyId);
+
+ aaiNetworkResources.deleteNetworkPolicy(networkPolicyId);
+ }
+ }
+ }
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java
index ed6379a6a4..5176bee0d6 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java
@@ -449,4 +449,53 @@ public class AAIUpdateTasks {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
+
+ public void updateIpv4OamAddressVnf(BuildingBlockExecution execution) {
+ try {
+ String ipv4OamAddress = execution.getVariable("oamManagementV4Address");
+ if (ipv4OamAddress != null) {
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
+ GenericVnf copiedGenericVnf = genericVnf.shallowCopyId();
+
+ genericVnf.setIpv4OamAddress(ipv4OamAddress);
+ copiedGenericVnf.setIpv4OamAddress(ipv4OamAddress);
+
+ aaiVnfResources.updateObjectVnf(copiedGenericVnf);
+ }
+ } catch(Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateManagementV6AddressVnf(BuildingBlockExecution execution) {
+ try {
+ String managementV6Address = execution.getVariable("oamManagementV6Address");
+ if (managementV6Address != null) {
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
+ GenericVnf copiedGenericVnf = genericVnf.shallowCopyId();
+
+ genericVnf.setManagementV6Address(managementV6Address);
+ copiedGenericVnf.setManagementV6Address(managementV6Address);
+
+ aaiVnfResources.updateObjectVnf(copiedGenericVnf);
+ }
+ } catch(Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ public void updateContrailServiceInstanceFqdnVfModule(BuildingBlockExecution execution) {
+ try {
+ String contrailServiceInstanceFqdn = execution.getVariable("contrailServiceInstanceFqdn");
+ if (contrailServiceInstanceFqdn != null) {
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID));
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
+ vfModule.setContrailServiceInstanceFqdn(contrailServiceInstanceFqdn);
+ aaiVfModuleResources.updateContrailServiceInstanceFqdnVfModule(vfModule, vnf);
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java
index f1a9e955b6..0851dc9d95 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java
@@ -26,6 +26,7 @@ import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse;
import org.onap.so.adapters.vnfrest.DeleteVfModuleResponse;
import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse;
import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
@@ -47,10 +48,18 @@ import javax.xml.bind.Unmarshaller;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.sax.SAXSource;
import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
@Component
public class VnfAdapterImpl {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VnfAdapterCreateTasks.class);
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VnfAdapterImpl.class);
+ private static final String CONTRAIL_SERVICE_INSTANCE_FQDN = "contrailServiceInstanceFqdn";
+ private static final String OAM_MANAGEMENT_V4_ADDRESS = "oamManagementV4Address";
+ private static final String OAM_MANAGEMENT_V6_ADDRESS = "oamManagementV6Address";
+ private static final String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList";
@Autowired
private ExtractPojosForBB extractPojosForBB;
@@ -65,6 +74,10 @@ public class VnfAdapterImpl {
execution.setVariable("mso-request-id", gBBInput.getRequestContext().getMsoRequestId());
execution.setVariable("mso-service-instance-id", serviceInstance.getServiceInstanceId());
execution.setVariable("heatStackId", null);
+ execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, null);
+ execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, null);
+ execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, null);
+ execution.setVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST, null);
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
@@ -79,15 +92,36 @@ public class VnfAdapterImpl {
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID));
String heatStackId = ((CreateVfModuleResponse) vnfRestResponse).getVfModuleStackId();
if(!StringUtils.isEmpty(heatStackId)) {
- vfModule.setHeatStackId(heatStackId);
+ vfModule.setHeatStackId(heatStackId);
execution.setVariable("heatStackId", heatStackId);
}
+ Map<String,String> vfModuleOutputs = ((CreateVfModuleResponse) vnfRestResponse).getVfModuleOutputs();
+ if (vfModuleOutputs != null) {
+ processVfModuleOutputs(execution, vfModuleOutputs);
+ }
} else if(vnfRestResponse instanceof DeleteVfModuleResponse) {
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID));
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
Boolean vfModuleDelete = ((DeleteVfModuleResponse) vnfRestResponse).getVfModuleDeleted();
if(null!= vfModuleDelete && vfModuleDelete) {
vfModule.setHeatStackId(null);
execution.setVariable("heatStackId", null);
+ Map<String,String> vfModuleOutputs = ((DeleteVfModuleResponse) vnfRestResponse).getVfModuleOutputs();
+ if (vfModuleOutputs != null) {
+ processVfModuleOutputs(execution, vfModuleOutputs);
+ if (execution.getVariable(OAM_MANAGEMENT_V4_ADDRESS) != null) {
+ genericVnf.setIpv4OamAddress("");
+ execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, "");
+ }
+ if (execution.getVariable(OAM_MANAGEMENT_V6_ADDRESS) != null) {
+ genericVnf.setManagementV6Address("");
+ execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, "");
+ }
+ if (execution.getVariable(CONTRAIL_SERVICE_INSTANCE_FQDN) != null) {
+ vfModule.setContrailServiceInstanceFqdn("");
+ execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, "");
+ }
+ }
}
} else if(vnfRestResponse instanceof CreateVolumeGroupResponse) {
VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID, execution.getLookupMap().get(ResourceKey.VOLUME_GROUP_ID));
@@ -108,7 +142,7 @@ public class VnfAdapterImpl {
}
}
} catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
@@ -133,4 +167,49 @@ public class VnfAdapterImpl {
throw new MarshallerException("Error parsing VNF Adapter response. " + e.getMessage(), MsoLogger.ErrorCode.SchemaError.getValue(), e);
}
}
+
+ private void processVfModuleOutputs(BuildingBlockExecution execution, Map<String,String> vfModuleOutputs) {
+ if (vfModuleOutputs == null) {
+ return;
+ }
+ try {
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID));
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
+ List<String> contrailNetworkPolicyFqdnList = new ArrayList<String>();
+ Iterator<String> keys = vfModuleOutputs.keySet().iterator();
+ while (keys.hasNext()) {
+ String key = keys.next();
+ if (key.equals("contrail-service-instance-fqdn")) {
+ String contrailServiceInstanceFqdn = vfModuleOutputs.get(key);
+ msoLogger.debug("Obtained contrailServiceInstanceFqdn: " + contrailServiceInstanceFqdn);
+ vfModule.setContrailServiceInstanceFqdn(contrailServiceInstanceFqdn);
+ execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, contrailServiceInstanceFqdn);
+ }
+ else if (key.endsWith("contrail_network_policy_fqdn")) {
+ String contrailNetworkPolicyFqdn = vfModuleOutputs.get(key);
+ msoLogger.debug("Obtained contrailNetworkPolicyFqdn: " + contrailNetworkPolicyFqdn);
+ contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn);
+ }
+ else if (key.equals("oam_management_v4_address")) {
+ String oamManagementV4Address = vfModuleOutputs.get(key);
+ msoLogger.debug("Obtained oamManagementV4Address: " + oamManagementV4Address);
+ genericVnf.setIpv4OamAddress(oamManagementV4Address);
+ execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, oamManagementV4Address);
+ }
+ else if (key.equals("oam_management_v6_address")) {
+ String oamManagementV6Address = vfModuleOutputs.get(key);
+ msoLogger.debug("Obtained oamManagementV6Address: " + oamManagementV6Address);
+ genericVnf.setManagementV6Address(oamManagementV6Address);
+ execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, oamManagementV6Address);
+ }
+
+ if (!contrailNetworkPolicyFqdnList.isEmpty()) {
+ execution.setVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST, String.join(",", contrailNetworkPolicyFqdnList));
+ }
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java
index c895566ca5..c8eeaa7a2b 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java
@@ -302,4 +302,8 @@ public class AAIObjectMapper {
public org.onap.aai.domain.yang.Subnet mapSubnet (Subnet subnet){
return modelMapper.map(subnet,org.onap.aai.domain.yang.Subnet.class);
}
+
+ public org.onap.aai.domain.yang.NetworkPolicy mapNetworkPolicy (NetworkPolicy networkPolicy){
+ return modelMapper.map(networkPolicy,org.onap.aai.domain.yang.NetworkPolicy.class);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java
index d2bf95a28e..4ca3f2a78d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java
@@ -45,6 +45,7 @@ import org.springframework.stereotype.Component;
@Component
public class AAINetworkResources {
+
@Autowired
private InjectionHelper injectionHelper;
@@ -171,6 +172,16 @@ public class AAINetworkResources {
AAIResourceUri instanceGroupURI = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
injectionHelper.getAaiClient().delete(instanceGroupURI);
}
-
-
+
+ public void createNetworkPolicy(org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy networkPolicy) {
+ NetworkPolicy aaiNetworkPolicy = aaiObjectMapper.mapNetworkPolicy(networkPolicy);
+ String networkPolicyId = networkPolicy.getNetworkPolicyId();
+ AAIResourceUri netUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId);
+ injectionHelper.getAaiClient().create(netUri, aaiNetworkPolicy);
+ }
+
+ public void deleteNetworkPolicy(String networkPolicyId) {
+ AAIResourceUri networkPolicyURI = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId);
+ injectionHelper.getAaiClient().delete(networkPolicyURI);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java
index a641d43ba3..ef61319eee 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java
@@ -76,6 +76,15 @@ public class AAIVfModuleResources {
injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule);
}
+ public void updateContrailServiceInstanceFqdnVfModule(VfModule vfModule, GenericVnf vnf) {
+ AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
+ VfModule copiedVfModule = vfModule.shallowCopyId();
+
+ copiedVfModule.setContrailServiceInstanceFqdn(vfModule.getContrailServiceInstanceFqdn());
+ org.onap.aai.domain.yang.VfModule aaiVfModule = aaiObjectMapper.mapVfModule(copiedVfModule);
+ injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule);
+ }
+
public void changeAssignVfModule(VfModule vfModule, GenericVnf vnf) {
AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId());
org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule);
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java
index 7375f09240..d8c7ebaff7 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java
@@ -45,6 +45,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
@@ -708,4 +709,12 @@ public class TestDataSetup{
subnet.setNeutronSubnetId("testNeutronSubnetId");
return subnet;
}
+
+ public NetworkPolicy buildNetworkPolicy() {
+ NetworkPolicy networkPolicy = new NetworkPolicy();
+ networkPolicy.setNetworkPolicyId("testNetworkPolicyId");
+ networkPolicy.setNetworkPolicyFqdn("testNetworkPolicyFqdn");
+ networkPolicy.setHeatStackId("testHeatStackId");
+ return networkPolicy;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
index 4e05d720ea..c48019af83 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
@@ -31,6 +31,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Arrays;
+import java.util.Optional;
import java.util.TreeSet;
import org.camunda.bpm.engine.delegate.BpmnError;
@@ -38,7 +39,9 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatchers;
+import org.mockito.Captor;
import org.mockito.InjectMocks;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.common.BuildingBlockExecution;
@@ -47,6 +50,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
@@ -55,6 +59,7 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
public class AAICreateTasksTest extends BaseTaskTest{
@@ -71,6 +76,9 @@ public class AAICreateTasksTest extends BaseTaskTest{
private Customer customer;
private Configuration configuration;
+ @Captor
+ ArgumentCaptor<NetworkPolicy> networkPolicyCaptor;
+
@Rule
public final ExpectedException exception = ExpectedException.none();
@@ -460,6 +468,39 @@ public class AAICreateTasksTest extends BaseTaskTest{
verify(aaiVnfResources, times(1)).connectVnfToTenant(genericVnf, gBBInput.getCloudRegion());
}
@Test
+ public void createNetworkPolicyNeedToCreateAllTest() throws Exception {
+ execution.setVariable("heatStackId", "testHeatStackId");
+ execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,ED456");
+ Optional<NetworkPolicy> networkPolicy = Optional.empty();
+ doReturn(networkPolicy).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class));
+ doNothing().when(aaiNetworkResources).createNetworkPolicy(any(NetworkPolicy.class));
+ aaiCreateTasks.createNetworkPolicies(execution);
+ verify(aaiNetworkResources, times(2)).createNetworkPolicy(networkPolicyCaptor.capture());
+ assertEquals("ABC123", networkPolicyCaptor.getAllValues().get(0).getNetworkPolicyFqdn());
+ assertEquals("ED456", networkPolicyCaptor.getAllValues().get(1).getNetworkPolicyFqdn());
+ assertEquals("testHeatStackId", networkPolicyCaptor.getAllValues().get(0).getHeatStackId());
+ assertEquals("testHeatStackId", networkPolicyCaptor.getAllValues().get(1).getHeatStackId());
+ }
+
+ @Test
+ public void createNetworkPolicyNeedToCreateNoneTest() throws Exception {
+ execution.setVariable("heatStackId", "testHeatStackId");
+ execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123");
+ NetworkPolicy networkPolicy = new NetworkPolicy();
+ doReturn(Optional.of(networkPolicy)).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class));
+ doNothing().when(aaiNetworkResources).createNetworkPolicy(any(NetworkPolicy.class));
+ aaiCreateTasks.createNetworkPolicies(execution);
+ verify(aaiNetworkResources, times(0)).createNetworkPolicy(any(NetworkPolicy.class));
+ }
+
+ @Test
+ public void createNetworkPolicyNoNetworkPoliciesTest() throws Exception {
+ execution.setVariable("heatStackId", "testHeatStackId");
+ aaiCreateTasks.createNetworkPolicies(execution);
+ verify(aaiNetworkResources, times(0)).createNetworkPolicy(any(NetworkPolicy.class));
+ }
+
+ @Test
public void createVfModuleGetLowestIndexTest() throws Exception {
GenericVnf vnf = new GenericVnf();
ModelInfoGenericVnf vnfInfo = new ModelInfoGenericVnf();
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java
index 67f5d197de..5cb775180e 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasksTest.java
@@ -20,22 +20,26 @@
package org.onap.so.bpmn.infrastructure.aai.tasks;
+import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Optional;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatchers;
+import org.mockito.Captor;
import org.mockito.InjectMocks;
+import org.onap.aai.domain.yang.NetworkPolicy;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
@@ -46,6 +50,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.exception.BBObjectNotFoundException;
@@ -62,6 +67,9 @@ public class AAIDeleteTasksTest extends BaseTaskTest {
private CloudRegion cloudRegion;
private Configuration configuration;
+ @Captor
+ ArgumentCaptor<String> stringCaptor;
+
@Before
public void before() throws BBObjectNotFoundException {
serviceInstance = setServiceInstance();
@@ -179,4 +187,34 @@ public class AAIDeleteTasksTest extends BaseTaskTest {
aaiDeleteTasks.deleteConfiguration(execution);
verify(aaiConfigurationResources, times(1)).deleteConfiguration(configuration);
}
+
+ @Test
+ public void deleteNetworkPolicyNeedToDeleteAllTest() throws Exception {
+ execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,DEF456");
+ NetworkPolicy networkPolicy0 = new NetworkPolicy();
+ networkPolicy0.setNetworkPolicyId("testNetworkPolicyId0");
+ NetworkPolicy networkPolicy1 = new NetworkPolicy();
+ networkPolicy1.setNetworkPolicyId("testNetworkPolicyId1");
+ doReturn(Optional.of(networkPolicy0),Optional.of(networkPolicy1)).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class));
+ doNothing().when(aaiNetworkResources).deleteNetworkPolicy(any(String.class));
+ aaiDeleteTasks.deleteNetworkPolicies(execution);
+ verify(aaiNetworkResources, times(2)).deleteNetworkPolicy(stringCaptor.capture());
+ assertEquals("testNetworkPolicyId0", stringCaptor.getAllValues().get(0));
+ assertEquals("testNetworkPolicyId1", stringCaptor.getAllValues().get(1));
+ }
+
+ @Test
+ public void deleteNetworkPolicyNeedToDeleteNoneTest() throws Exception {
+ execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123");
+ Optional<NetworkPolicy> networkPolicy = Optional.empty();
+ doReturn(networkPolicy).when(aaiNetworkResources).getNetworkPolicy(any(AAIResourceUri.class));
+ aaiDeleteTasks.deleteNetworkPolicies(execution);
+ verify(aaiNetworkResources, times(0)).deleteNetworkPolicy(any(String.class));
+ }
+
+ @Test
+ public void deleteNetworkPolicyNoNetworkPoliciesTest() throws Exception {
+ aaiDeleteTasks.deleteNetworkPolicies(execution);
+ verify(aaiNetworkResources, times(0)).deleteNetworkPolicy(any(String.class));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
index f97b137fb3..73d7257632 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java
@@ -586,4 +586,49 @@ public class AAIUpdateTasksTest extends BaseTaskTest{
verify(aaiConfigurationResources, times(1)).updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE);
}
+ @Test
+ public void updateContrailServiceInstanceFqdnVfModuleTest() throws Exception {
+ execution.setVariable("contrailServiceInstanceFqdn", "newContrailServiceInstanceFqdn");
+ doNothing().when(aaiVfModuleResources).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf);
+
+ aaiUpdateTasks.updateContrailServiceInstanceFqdnVfModule(execution);
+
+ verify(aaiVfModuleResources, times(1)).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf);
+ assertEquals("newContrailServiceInstanceFqdn", vfModule.getContrailServiceInstanceFqdn());
+ }
+ @Test
+ public void updateContrailServiceInstanceFqdnVfModuleNoUpdateTest() throws Exception {
+ aaiUpdateTasks.updateContrailServiceInstanceFqdnVfModule(execution);
+ verify(aaiVfModuleResources, times(0)).updateContrailServiceInstanceFqdnVfModule(vfModule, genericVnf);
+ }
+ @Test
+ public void updateIpv4OamAddressVnfTest() throws Exception {
+ execution.setVariable("oamManagementV4Address", "newIpv4OamAddress");
+ doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf);
+
+ aaiUpdateTasks.updateIpv4OamAddressVnf(execution);
+
+ verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf);
+ assertEquals("newIpv4OamAddress", genericVnf.getIpv4OamAddress());
+ }
+ @Test
+ public void updateIpv4OamAddressVnfNoUpdateTest() throws Exception {
+ aaiUpdateTasks.updateIpv4OamAddressVnf(execution);
+ verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf);
+ }
+ @Test
+ public void updateManagementV6AddressVnfTest() throws Exception {
+ execution.setVariable("oamManagementV6Address", "newManagementV6Address");
+ doNothing().when(aaiVnfResources).updateObjectVnf(genericVnf);
+
+ aaiUpdateTasks.updateManagementV6AddressVnf(execution);
+
+ verify(aaiVnfResources, times(1)).updateObjectVnf(genericVnf);
+ assertEquals("newManagementV6Address", genericVnf.getManagementV6Address());
+ }
+ @Test
+ public void updateManagementV6AddressVnfNoUpdateTest() throws Exception {
+ aaiUpdateTasks.updateManagementV6AddressVnf(execution);
+ verify(aaiVnfResources, times(0)).updateObjectVnf(genericVnf);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java
index 4158f9cfae..33d0dbe130 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImplTest.java
@@ -21,6 +21,7 @@
package org.onap.so.bpmn.infrastructure.adapter.vnf.tasks;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
@@ -35,6 +36,7 @@ import org.mockito.InjectMocks;
import org.onap.so.FileUtil;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
@@ -50,6 +52,7 @@ public class VnfAdapterImplTest extends BaseTaskTest {
private RequestContext requestContext;
private ServiceInstance serviceInstance;
+ private GenericVnf genericVnf;
private VfModule vfModule;
private VolumeGroup volumeGroup;
@@ -58,12 +61,17 @@ public class VnfAdapterImplTest extends BaseTaskTest {
private static final String VNF_ADAPTER_VOLUME_CREATE_RESPONSE = FileUtil.readResourceFile("__files/VfModularity/CreateVfModuleVolumeCallbackResponse.xml");
private static final String VNF_ADAPTER_VOLUME_DELETE_RESPONSE = FileUtil.readResourceFile("__files/VfModularity/DeleteVfModuleVolumeCallbackResponse.xml");
private static final String TEST_VFMODULE_HEATSTACK_ID = "slowburn";
- private static final String TEST_VOLUME_HEATSTACK_ID = "testHeatStackId1";
+ private static final String TEST_VOLUME_HEATSTACK_ID = "testHeatStackId1";
+ private static final String TEST_CONTRAIL_SERVICE_INSTANCE_FQDN = "default-domain:MSOTest:MsoNW-RA";
+ private static final String TEST_OAM_MANAGEMENT_V4_ADDRESS = "127.0.0.1";
+ private static final String TEST_OAM_MANAGEMENT_V6_ADDRESS = "2000:abc:bce:1111";
+ private static final String TEST_CONTRAIL_NETWORK_POLICY_FQDNS = "MSOTest:DefaultPolicyFQDN2,MSOTest:DefaultPolicyFQDN1";
@Before
public void before() throws BBObjectNotFoundException {
requestContext = setRequestContext();
serviceInstance = setServiceInstance();
+ genericVnf = setGenericVnf();
vfModule = setVfModule();
volumeGroup = setVolumeGroup();
vfModule.setHeatStackId(null);
@@ -72,6 +80,7 @@ public class VnfAdapterImplTest extends BaseTaskTest {
doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID), any())).thenReturn(serviceInstance);
when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID), any())).thenReturn(volumeGroup);
+ when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID), any())).thenReturn(genericVnf);
when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(vfModule);
}
@@ -86,8 +95,15 @@ public class VnfAdapterImplTest extends BaseTaskTest {
@Test
public void postProcessVnfAdapter_CreateResponseTest() {
execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_CREATE_RESPONSE);
- vnfAdapterImpl.postProcessVnfAdapter(execution);
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
assertEquals(TEST_VFMODULE_HEATSTACK_ID, vfModule.getHeatStackId());
+ assertEquals(TEST_CONTRAIL_SERVICE_INSTANCE_FQDN, vfModule.getContrailServiceInstanceFqdn());
+ assertEquals(TEST_CONTRAIL_SERVICE_INSTANCE_FQDN, execution.getVariable("contrailServiceInstanceFqdn"));
+ assertEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, genericVnf.getIpv4OamAddress());
+ assertEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, execution.getVariable("oamManagementV4Address"));
+ assertEquals(TEST_OAM_MANAGEMENT_V6_ADDRESS, genericVnf.getManagementV6Address());
+ assertEquals(TEST_OAM_MANAGEMENT_V6_ADDRESS, execution.getVariable("oamManagementV6Address"));
+ assertEquals(TEST_CONTRAIL_NETWORK_POLICY_FQDNS, execution.getVariable("contrailNetworkPolicyFqdnList"));
}
@@ -111,6 +127,20 @@ public class VnfAdapterImplTest extends BaseTaskTest {
vnfAdapterImpl.postProcessVnfAdapter(execution);
assertNull(vfModule.getHeatStackId());
}
+
+ @Test
+ public void postProcessVnfAdapter_CreateResponseTest_EmptyVfModuleOutputs() {
+ execution.setVariable("vnfAdapterRestV1Response", "<createVfModuleResponse><vfModuleOutputs></vfModuleOutputs></createVfModuleResponse>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertNull(vfModule.getHeatStackId());
+ assertNull(vfModule.getContrailServiceInstanceFqdn());
+ assertNull(execution.getVariable("contrailServiceInstanceFqdn"));
+ assertNotEquals(TEST_OAM_MANAGEMENT_V4_ADDRESS, genericVnf.getIpv4OamAddress());
+ assertNull(execution.getVariable("oamManagementV4Address"));
+ assertNull(genericVnf.getManagementV6Address());
+ assertNull(execution.getVariable("oamManagementV6Address"));
+ assertNull(execution.getVariable("contrailNetworkPolicyFqdnList"));
+ }
@Test
public void postProcessVnfAdapter_DeleteResponseTest() {
@@ -118,6 +148,25 @@ public class VnfAdapterImplTest extends BaseTaskTest {
execution.setVariable("vnfAdapterRestV1Response", VNF_ADAPTER_REST_DELETE_RESPONSE);
vnfAdapterImpl.postProcessVnfAdapter(execution);
assertNull(vfModule.getHeatStackId());
+ assertEquals(vfModule.getContrailServiceInstanceFqdn(), "");
+ assertEquals(execution.getVariable("contrailServiceInstanceFqdn"), "");
+ assertEquals(genericVnf.getIpv4OamAddress(), "");
+ assertEquals(execution.getVariable("oamManagementV4Address"), "");
+ assertEquals(genericVnf.getManagementV6Address(), "");
+ assertEquals(execution.getVariable("oamManagementV6Address"), "");
+ assertEquals(TEST_CONTRAIL_NETWORK_POLICY_FQDNS, execution.getVariable("contrailNetworkPolicyFqdnList"));
+ }
+
+ @Test
+ public void postProcessVnfAdapter_DeleteResponseTest_EmptyVfModuleOutputs() {
+ execution.setVariable("vnfAdapterRestV1Response", "<createVfModuleResponse><vfModuleOutputs></vfModuleOutputs></createVfModuleResponse>");
+ vnfAdapterImpl.postProcessVnfAdapter(execution);
+ assertNull(vfModule.getHeatStackId());
+ assertNull(vfModule.getContrailServiceInstanceFqdn());
+ assertNull(execution.getVariable("contrailServiceInstanceFqdn"));
+ assertNull(execution.getVariable("oamManagementV4Address"));
+ assertNull(execution.getVariable("oamManagementV6Address"));
+ assertNull(execution.getVariable("contrailNetworkPolicyFqdnList"));
}
@Test
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java
index db01399b82..a8e9a7e57e 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java
@@ -41,6 +41,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute;
import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget;
@@ -672,4 +673,21 @@ public class AAIObjectMapperTest {
assertThat(actualSubnet, sameBeanAs(expectedSubnet));
}
+
+ @Test
+ public void mapNetworkPolicyTest() {
+ NetworkPolicy networkPolicy = new NetworkPolicy();
+ networkPolicy.setNetworkPolicyId("testNetworkPolicyId");
+ networkPolicy.setNetworkPolicyFqdn("testNetworkPolicyFqdn");
+ networkPolicy.setHeatStackId("testHeatStackId");
+
+ org.onap.aai.domain.yang.NetworkPolicy expectedNetworkPolicy = new org.onap.aai.domain.yang.NetworkPolicy();
+ expectedNetworkPolicy.setNetworkPolicyId("testNetworkPolicyId");
+ expectedNetworkPolicy.setNetworkPolicyFqdn("testNetworkPolicyFqdn");
+ expectedNetworkPolicy.setHeatStackId("testHeatStackId");
+
+ org.onap.aai.domain.yang.NetworkPolicy actualNetworkPolicy = aaiObjectMapper.mapNetworkPolicy(networkPolicy);
+
+ assertThat(actualNetworkPolicy, sameBeanAs(expectedNetworkPolicy));
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java
index 82ffdf9559..2e2cc5d974 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java
@@ -45,7 +45,6 @@ import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.aai.domain.yang.NetworkPolicy;
import org.onap.aai.domain.yang.RouteTableReference;
import org.onap.aai.domain.yang.VpnBinding;
import org.onap.so.bpmn.common.InjectionHelper;
@@ -54,6 +53,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet;
import org.onap.so.client.aai.AAIObjectType;
@@ -77,6 +77,7 @@ public class AAINetworkResourcesTest extends TestDataSetup{
private ServiceInstance serviceInstance;
private CloudRegion cloudRegion;
private Subnet subnet;
+ private NetworkPolicy networkPolicy;
@Mock
protected AAIResourcesClient MOCK_aaiResourcesClient;
@@ -107,6 +108,8 @@ public class AAINetworkResourcesTest extends TestDataSetup{
subnet = buildSubnet();
+ networkPolicy = buildNetworkPolicy();
+
doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
}
@@ -175,16 +178,15 @@ public class AAINetworkResourcesTest extends TestDataSetup{
public void getNetworkPolicyTest() throws Exception {
final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "queryAaiNetworkPolicy.json")));
AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
- Optional<NetworkPolicy> oNetPolicy = Optional.empty();
+ Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy = Optional.empty();
AAIResourceUri netPolicyUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, "ModelInvariantUUID");
doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
oNetPolicy = aaiNetworkResources.getNetworkPolicy(netPolicyUri);
- verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
-
+ verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
if (oNetPolicy.isPresent()) {
- NetworkPolicy networkPolicy = oNetPolicy.get();
- assertThat(aaiResultWrapper.asBean(NetworkPolicy.class).get(), sameBeanAs(networkPolicy));
+ org.onap.aai.domain.yang.NetworkPolicy networkPolicy = oNetPolicy.get();
+ assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.NetworkPolicy.class).get(), sameBeanAs(networkPolicy));
}
}
@@ -357,4 +359,20 @@ public class AAINetworkResourcesTest extends TestDataSetup{
assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.Subnet.class).get(), sameBeanAs(subnet));
}
}
+
+ @Test
+ public void createNetworkPolicyTest() throws Exception {
+ doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.NetworkPolicy.class));
+ doReturn(new org.onap.aai.domain.yang.NetworkPolicy()).when(MOCK_aaiObjectMapper).mapNetworkPolicy(networkPolicy);
+ aaiNetworkResources.createNetworkPolicy(networkPolicy);
+ verify(MOCK_aaiResourcesClient, times(1)).create(any(AAIResourceUri.class), isA(org.onap.aai.domain.yang.NetworkPolicy.class));
+ }
+
+ @Test
+ public void deleteNetworkPolicyTest() throws Exception {
+ doNothing().when(MOCK_aaiResourcesClient).delete(isA(AAIResourceUri.class));
+ aaiNetworkResources.deleteNetworkPolicy(networkPolicy.getNetworkPolicyId());
+ verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java
index 0a8e7ce349..a8200caf79 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java
@@ -138,4 +138,17 @@ public class AAIVfModuleResourcesTest extends TestDataSetup{
assertEquals("testHeatStackId", vfModule.getHeatStackId());
}
+
+ @Test
+ public void updateContrailServiceInstanceFqdnVfModuleTest() throws Exception {
+ vfModule.setContrailServiceInstanceFqdn("testContrailServiceInstanceFqdn");
+
+ doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VfModule.class));
+
+ aaiVfModuleResources.updateContrailServiceInstanceFqdnVfModule(vfModule, vnf);
+
+ verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),ArgumentMatchers.isNull());
+
+ assertEquals("testContrailServiceInstanceFqdn", vfModule.getContrailServiceInstanceFqdn());
+ }
}