aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2017-11-15 18:25:57 -0500
committerJim Hahn <jrh3@att.com>2017-11-15 18:25:57 -0500
commit98d48a4b34f07ac40fddd2254b78b9ea84f88fa3 (patch)
tree344557a6163b55e072eef8892f986f9d10b5fbe4
parent0900a8bed342b8667052367fe5e24f369f357bb1 (diff)
Modified create-vcpe to filter out "bad" VNFs
Modified create-vcpe to delete the BRG and TXC items from the service VNF list contained within the service decomposition structure. Change-Id: I7624a93b422fa172a2079f70d66a2604ee2229b0 Issue-Id: SO-344 Signed-off-by: Jim Hahn <jrh3@att.com>
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy21
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy81
2 files changed, 85 insertions, 17 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy
index 703ea8be6d..dd6d4514bc 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy
@@ -343,6 +343,9 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor {
// VNFs
List<VnfResource> vnfList = serviceDecomposition.getServiceVnfs()
+ filterVnfs(vnfList)
+ serviceDecomposition.setServiceVnfs(vnfList)
+
execution.setVariable("vnfList", vnfList)
execution.setVariable("vnfListString", vnfList.toString())
@@ -372,6 +375,24 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
}
}
+
+ private void filterVnfs(List<VnfResource> vnfList) {
+ if(vnfList == null) {
+ return
+ }
+
+ // remove BRG & TXC from VNF list
+
+ Iterator<VnfResource> it = vnfList.iterator()
+ while(it.hasNext()) {
+ VnfResource vr = it.next()
+
+ String role = vr.getNfRole()
+ if(role == "BRG" || role == "TunnelXConn") {
+ it.remove()
+ }
+ }
+ }
public void prepareCreateAllottedResourceTXC(Execution execution) {
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy
index f0645b2bc7..70050422ee 100644
--- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy
@@ -370,7 +370,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase {
// @Ignore
public void processDecomposition() {
ExecutionEntity mex = setupMock()
- def svcdecomp = initProcessDecomposition(mex, true, true)
+ def svcdecomp = initProcessDecomposition(mex)
CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
CreateVcpeResCustService.processDecomposition(mex)
@@ -378,8 +378,8 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase {
verify(mex).getVariable(DBGFLAG)
verify(mex).setVariable("vnfList", svcdecomp.getServiceVnfs())
- verify(mex).setVariable("vnfListString", '[myvnf, myvnf2, myvnf3]')
- verify(mex).setVariable(Prefix+"VNFsCount", 3)
+ verify(mex).setVariable("vnfListString", '[myvnf]')
+ verify(mex).setVariable(Prefix+"VNFsCount", 1)
verify(mex).setVariable("vnfModelInfo", "mymodel")
verify(mex).setVariable("vnfModelInfoString", "mymodel")
@@ -389,7 +389,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase {
// @Ignore
public void processDecomposition_EmptyNet_EmptyVnf() {
ExecutionEntity mex = setupMock()
- def svcdecomp = initProcessDecomposition(mex, true, true)
+ def svcdecomp = initProcessDecomposition(mex)
when(svcdecomp.getServiceVnfs()).thenReturn(new LinkedList<VnfResource>())
@@ -410,7 +410,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase {
// @Ignore
public void processDecomposition_Ex() {
ExecutionEntity mex = setupMock()
- def svcdecomp = initProcessDecomposition(mex, true, true)
+ def svcdecomp = initProcessDecomposition(mex)
when(svcdecomp.getServiceVnfs()).thenThrow(new RuntimeException("expected exception"))
@@ -420,6 +420,35 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase {
}
+ // ***** filterVnfs *****
+
+ @Test
+ // @Ignore
+ public void filterVnfs() {
+ ExecutionEntity mex = setupMock()
+ def svcdecomp = initFilterVnfs(mex)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.processDecomposition(mex)
+
+ verify(mex).setVariable("vnfListString", '[myvnf3, myvnf5]')
+ }
+
+ @Test
+ // @Ignore
+ public void filterVnfs_Null() {
+ ExecutionEntity mex = setupMock()
+ def svcdecomp = initFilterVnfs(mex)
+
+ when(svcdecomp.getServiceVnfs()).thenReturn(null)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.processDecomposition(mex)
+
+ // nothing more to check, as long as it didn't throw an exception
+ }
+
+
// ***** prepareCreateAllottedResourceTXC *****
@Test
@@ -1034,13 +1063,30 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase {
when(mex.getVariable("serviceInstanceName")).thenReturn("sin")
}
- private ServiceDecomposition initProcessDecomposition(ExecutionEntity mex, boolean haveNet, boolean haveVnf) {
+ private ServiceDecomposition initProcessDecomposition(ExecutionEntity mex) {
+ List<VnfResource> vnflst = new LinkedList<>()
+ vnflst.add(makeVnf("", ""))
+ vnflst.add(makeVnf("2", "BRG"))
+ vnflst.add(makeVnf("3", "BRG"))
+
+ ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
+ when(svcdecomp.getServiceVnfs()).thenReturn(vnflst)
+
+ when(mex.getVariable(DBGFLAG)).thenReturn("true")
+ when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp)
+ when(mex.getVariable("serviceInstanceId")).thenReturn("sii")
+ when(mex.getVariable("serviceInstanceName")).thenReturn("sin")
+
+ return svcdecomp
+ }
+
+ private ServiceDecomposition initFilterVnfs(ExecutionEntity mex) {
List<VnfResource> vnflst = new LinkedList<>()
- if(haveVnf) {
- vnflst.add(makeVnf(""))
- vnflst.add(makeVnf("2"))
- vnflst.add(makeVnf("3"))
- }
+ vnflst.add(makeVnf("", "BRG"))
+ vnflst.add(makeVnf("2", "TunnelXConn"))
+ vnflst.add(makeVnf("3", ""))
+ vnflst.add(makeVnf("4", "BRG"))
+ vnflst.add(makeVnf("5", "other"))
ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class)
when(svcdecomp.getServiceVnfs()).thenReturn(vnflst)
@@ -1133,10 +1179,10 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase {
List<VnfResource> vnflst = new LinkedList<>()
- vnflst.add(makeVnf("A"))
- vnflst.add(makeVnf("B"))
- vnflst.add(makeVnf("C"))
- vnflst.add(makeVnf("D"))
+ vnflst.add(makeVnf("A", "BRG"))
+ vnflst.add(makeVnf("B", ""))
+ vnflst.add(makeVnf("C", ""))
+ vnflst.add(makeVnf("D", "TunnelXConn"))
when(mex.getVariable(DBGFLAG)).thenReturn("true")
when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request)
@@ -1146,7 +1192,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase {
when(mex.getVariable("sdncVersion")).thenReturn("myvers")
}
- private VnfResource makeVnf(String id) {
+ private VnfResource makeVnf(String id, String role) {
ModelInfo mod = mock(ModelInfo.class)
VnfResource vnf = mock(VnfResource.class)
@@ -1154,8 +1200,9 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase {
when(vnf.toString()).thenReturn("myvnf"+id)
when(vnf.getModelInfo()).thenReturn(mod)
+ when(vnf.getNfRole()).thenReturn(role)
- return vnf
+ return vnf
}
private initValidateVnfCreate(ExecutionEntity mex) {