aboutsummaryrefslogtreecommitdiffstats
path: root/appc-outbound/appc-aai-client/provider
diff options
context:
space:
mode:
authorBalaji, Ramya (rb111y) <rb111y@att.com>2018-03-12 21:14:03 -0400
committerTakamune Cho <tc012c@att.com>2018-03-13 17:43:38 +0000
commit51d88e957a81396a26c909dda6ab05d48decc643 (patch)
tree936eede2a29b7962b305101d26ae919b66fa41a2 /appc-outbound/appc-aai-client/provider
parentd6969f09272b77687b24aa333f45de6b33844470 (diff)
Code changes for A&AI add/update
Code and Unit Test updates to updating vnfc records when vf module is provided in request. Issue-ID: APPC-622 Change-Id: I76903eb8bfa6910e3fb2f6e404504d2b9b5fb477 Signed-off-by: Balaji, Ramya (rb111y) <rb111y@att.com>
Diffstat (limited to 'appc-outbound/appc-aai-client/provider')
-rw-r--r--appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiService.java11
-rw-r--r--appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/node/AAIResourceNode.java55
-rw-r--r--appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/TestAaiService.java6
-rw-r--r--appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/node/TestAAIResourceNode.java7
4 files changed, 73 insertions, 6 deletions
diff --git a/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiService.java b/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiService.java
index c1f42a73d..a77aa9cb3 100644
--- a/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiService.java
+++ b/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiService.java
@@ -216,7 +216,7 @@ public class AaiService {
}
- public void insertVnfcs(Map<String, String> params, SvcLogicContext ctx, int vnfcRefLen, int vmCount)
+ public void insertVnfcs(Map<String, String> params, SvcLogicContext ctx, int vnfcRefLen, int vmCount, String vfModuleIdFromRequest)
throws Exception {
log.info("Received insertVnfcs call with params : " + params);
@@ -228,6 +228,15 @@ public class AaiService {
for (int i = 0; i < vmCount; i++) {
String aaiRefKey = prefix + "vm[" + i + "].";
+ //ConfigScaleOut - Do not process vms that are not associated with vfmodule id if vfmodule id is present
+ if (StringUtils.isNotBlank(vfModuleIdFromRequest)){
+ String vmVfModuleId = ctx.getAttribute(aaiRefKey+"vf-module-id");
+ log.info("insertVnfcs():::vfModule for vm is="+vmVfModuleId);
+ if (StringUtils.isBlank(vmVfModuleId) || !StringUtils.equalsIgnoreCase(vmVfModuleId,vfModuleIdFromRequest)) {
+ continue;
+ }
+ }
+
log.info("VNFCNAME IN INSERTVNFCS " + ctx.getAttribute(aaiRefKey + "vnfc-name"));
String vnfcNameAAI = ctx.getAttribute(aaiRefKey + "vnfc-name");
diff --git a/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/node/AAIResourceNode.java b/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/node/AAIResourceNode.java
index ed9b9d074..073ca12f4 100644
--- a/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/node/AAIResourceNode.java
+++ b/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/node/AAIResourceNode.java
@@ -103,7 +103,11 @@ public class AAIResourceNode implements SvcLogicJavaPlugin {
ArrayList<Map<String, String>> vservers = new ArrayList<>();
int vmWithNoVnfcsCount = 0;
+ int vmsWithNoVnfcsForVfModule = 0;
+ int vmCountForVfModule = 0;
String vmCountStr = ctx.getAttribute(responsePrefix + "vm-count");
+ String vfModuleFromRequest = ctx.getAttribute("req-vf-module-id");
+ log.info("getAllVServersVnfcsInfo()::: vfMOdule="+vfModuleFromRequest);
if (vmCountStr == null) {
throw new ResourceNodeInternalException("Unable to get VServers for the VNF");
@@ -145,6 +149,7 @@ public class AAIResourceNode implements SvcLogicJavaPlugin {
}
vserverMap.put("vnfc-count", vnfcCount);
+ String vfModuleForVserver = vmServerCtx.getAttribute(responsePrefix + "vm.vf-module-id");
if (vnfcName != null) {
Map<String, String> paramsVnfc = new HashMap<String, String>();
@@ -166,6 +171,15 @@ public class AAIResourceNode implements SvcLogicJavaPlugin {
} else {
vmWithNoVnfcsCount++;
+ //ConfigScaleOut
+ log.info("getAllVServersVnfcsInfo()::Vf Modules: "+vfModuleForVserver+", "+vfModuleFromRequest);
+ if (StringUtils.isNotBlank(vfModuleFromRequest) && StringUtils.isNotBlank(vfModuleForVserver) && StringUtils.equalsIgnoreCase(vfModuleForVserver,vfModuleFromRequest)) {
+ vmsWithNoVnfcsForVfModule++;
+ }
+ }
+
+ if (StringUtils.isNotBlank(vfModuleFromRequest) && StringUtils.isNotBlank(vfModuleForVserver) && StringUtils.equalsIgnoreCase(vfModuleForVserver,vfModuleFromRequest)){
+ vmCountForVfModule++;
}
vservers.add(vserverMap);
@@ -179,8 +193,12 @@ public class AAIResourceNode implements SvcLogicJavaPlugin {
log.info("VMCOUNT IN GETALLVSERVERS " + vmCount);
log.info("VMSWITHNOVNFCSCOUNT IN GETALLVSERVERS " + vmWithNoVnfcsCount);
+ log.info("VMSWITHNOVNFCSCOUNTFOR VFMODULE IN GETALLVSERVERS " + vmsWithNoVnfcsForVfModule);
+ log.info("VMCOUNT FOR VFMODULE IN GETALLVSERVERS " + vmCountForVfModule);
ctx.setAttribute(responsePrefix + ATTR_VNF_VM_COUNT, String.valueOf(vmCount));
ctx.setAttribute(responsePrefix + "vnf.vm-with-no-vnfcs-count", String.valueOf(vmWithNoVnfcsCount));
+ ctx.setAttribute(responsePrefix + "vnf.vm-with-no-vnfcs-count-vf-module", String.valueOf(vmsWithNoVnfcsForVfModule));
+ ctx.setAttribute(responsePrefix + "vnf.vm-count-for-vf-module", String.valueOf(vmCountForVfModule));
} catch (Exception e) {
@@ -259,17 +277,25 @@ public class AAIResourceNode implements SvcLogicJavaPlugin {
} else {
vmCount = Integer.parseInt(vmCountStr);
}
- if (vmCount < vnfcRefLen) {
+ String vfModuleIdFromRequest = ctx.getAttribute("req-vf-module-id");
+ if ((vmCount < vnfcRefLen) && StringUtils.isBlank(vfModuleIdFromRequest)) {
throw new ResourceNodeInternalException("Vnfc and VM count mismatch");
}
+ //ConfigScaleOut
+ if (StringUtils.isNotBlank(vfModuleIdFromRequest)) {
+ processCheckForVfModule(vfModuleIdFromRequest, ctx, responsePrefix,vnfcRefLen);
+ }
+
log.info("VMCOUNT " + vmCount);
log.info("VNFCREFLEN " + vnfcRefLen);
+
+
if (StringUtils.isBlank(ctx.getAttribute("vnfc-type"))) {
aai.updateVnfStatusWithOAMAddress(inParams, ctx);
}
- aai.insertVnfcs(inParams, ctx, vnfcRefLen, vmCount);
+ aai.insertVnfcs(inParams, ctx, vnfcRefLen, vmCount,vfModuleIdFromRequest);
ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS,
AppcAaiClientConstant.OUTPUT_STATUS_SUCCESS);
@@ -285,6 +311,31 @@ public class AAIResourceNode implements SvcLogicJavaPlugin {
}
}
+ private void processCheckForVfModule(String vfModuleIdFromRequest, SvcLogicContext ctx,
+ String responsePrefix, int vnfcRefLen) throws ResourceNodeInternalException {
+
+ log.info("processCheckForVfModule()::vfModuleId From Request"+vfModuleIdFromRequest+"-"+vnfcRefLen);
+ int vmsWithoutVnfcsForVfModule = 0;
+ String vmsWithoutVnfcsForVfModuleStr = ctx.getAttribute(responsePrefix + "vnf.vm-with-no-vnfcs-count-vf-module");
+ if (StringUtils.isBlank(vmsWithoutVnfcsForVfModuleStr) && StringUtils.isNotBlank(vfModuleIdFromRequest)) {
+ log.info("addVnfcs()::No vmsWithoutVnfcsForVfModule (is null) for vfmodule="+vfModuleIdFromRequest);
+ }
+ else {
+ vmsWithoutVnfcsForVfModule = Integer.parseInt(vmsWithoutVnfcsForVfModuleStr);
+ }
+ log.info("addVnfcs():::Number of VMs without vnfcs for vfmodule: "+vmsWithoutVnfcsForVfModule);
+ String vmsForVfModuleStr = ctx.getAttribute(responsePrefix +"vnf.vm-count-for-vf-module");
+ int vmsForVfModule = 0;
+ if (StringUtils.isNotBlank(vmsForVfModuleStr)) {
+ vmsForVfModule = Integer.parseInt(vmsForVfModuleStr);
+ }
+ if ((vmsForVfModule != vnfcRefLen ) && StringUtils.isNotBlank(vfModuleIdFromRequest)) {
+ throw new ResourceNodeInternalException("Vnfc and VM count mismatch for vfModule in request="+vfModuleIdFromRequest);
+ }
+ log.info("processCheckForVfModule()::vmsForVfModule " + vmsForVfModule);
+
+ }
+
private int trySetVnfcRefLen(String vnfcRefLenStr) throws ResourceNodeInternalException {
if (vnfcRefLenStr == null) {
diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/TestAaiService.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/TestAaiService.java
index 717348584..a68e59af9 100644
--- a/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/TestAaiService.java
+++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/TestAaiService.java
@@ -250,7 +250,7 @@ public class TestAaiService {
mockAai.populateAllVnfInfo1(ctx, "tmp.vnfInfo");
- mockAai.insertVnfcs(inParams, ctx, 2, 2);
+ mockAai.insertVnfcs(inParams, ctx, 2, 2,"vfModuleId1");
}
@@ -269,7 +269,7 @@ public class TestAaiService {
mockAai.populateAllVnfInfo1(ctx, "tmp.vnfInfo");
- mockAai.insertVnfcs(inParams, ctx, 2, 2);
+ mockAai.insertVnfcs(inParams, ctx, 2, 2, null);
assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-name"), "dbjx0001vm001dbj001");
assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-function-code"), "dbj");
@@ -296,7 +296,7 @@ public class TestAaiService {
mockAai.populateAllVnfInfo1(ctx, "tmp.vnfInfo");
- mockAai.insertVnfcs(inParams, ctx, 2, 2);
+ mockAai.insertVnfcs(inParams, ctx, 2, 2,null);
diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/node/TestAAIResourceNode.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/node/TestAAIResourceNode.java
index efb09e0be..e509a3403 100644
--- a/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/node/TestAAIResourceNode.java
+++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/node/TestAAIResourceNode.java
@@ -131,7 +131,14 @@ public class TestAAIResourceNode {
assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-type"), "vnfcType2");
assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-function-code"), "vnfcFuncCode2");
assertEquals(ctx.getAttribute("tmp.vnfInfo.vm[1].group-notation"), "vnfcGrpNot2");
+
+ ctx.setAttribute("tmp.vnfInfo.vm[0].vserver-id","ibcm0001id");
+ ctx.setAttribute("req-vf-module-id","vfModule1");
+ mrn.getAllVServersVnfcsInfo(inParams, ctx);
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vnf.vm-with-no-vnfcs-count-vf-module"),"1");
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.vnf.vm-count-for-vf-module"),"1");
}
+
public void populateAllVServerInfo(SvcLogicContext ctx, String prefix) throws Exception {
ctx.setAttribute("vnf-id", "ibcx0001v");
ctx.setAttribute("vnf-host-ip-address", "000.00.00.00");