X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=appc-outbound%2Fappc-aai-client%2Fprovider%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fappc%2Faai%2Fclient%2Fnode%2FAAIResourceNode.java;fp=appc-outbound%2Fappc-aai-client%2Fprovider%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fappc%2Faai%2Fclient%2Fnode%2FAAIResourceNode.java;h=073ca12f4293b5b402bea7739d12f80a5e6294a1;hb=51d88e957a81396a26c909dda6ab05d48decc643;hp=ed9b9d07406390dafabd3723ce2cc65fa440c8e0;hpb=d6969f09272b77687b24aa333f45de6b33844470;p=appc.git 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> 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 paramsVnfc = new HashMap(); @@ -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) {