diff options
Diffstat (limited to 'appc-inbound/appc-artifact-handler/provider/src/main/java')
3 files changed, 79 insertions, 53 deletions
diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DBService.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DBService.java index 5afe4e501..9b2d80d3f 100644 --- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DBService.java +++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DBService.java @@ -388,13 +388,19 @@ public class DBService { log.info(fn + "Starting DB operation for Vnfc Reference " + isUpdate); String key = ""; int vm_instance = -1; + String templateId=""; + if (context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE) != null) { vm_instance = Integer.parseInt(context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE)); } int vnfc_instance = -1; if (context.getAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE) != null) { vnfc_instance = Integer.parseInt(context.getAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE)); + } + if (context.getAttribute(SdcArtifactHandlerConstants.TEMPLATE_ID) != null) { + templateId = context.getAttribute(SdcArtifactHandlerConstants.TEMPLATE_ID); } + QueryStatus status = null; if (isUpdate) { key = "update " + SdcArtifactHandlerConstants.DB_VNFC_REFERENCE + " set VM_INSTANCE = " + vm_instance @@ -413,7 +419,8 @@ public class DBService { + " , VM_INSTANCE = $" + SdcArtifactHandlerConstants.VM_INSTANCE + " , VNFC_INSTANCE = $" + SdcArtifactHandlerConstants.VNFC_INSTANCE + " , VNFC_TYPE = $" + SdcArtifactHandlerConstants.VNFC_TYPE + " , VNFC_FUNCTION_CODE = $" - + SdcArtifactHandlerConstants.VNFC_FUNCTION_CODE + " , GROUP_NOTATION_TYPE = $" + + SdcArtifactHandlerConstants.VNFC_FUNCTION_CODE + " , TEMPLATE_ID = $" + + SdcArtifactHandlerConstants.TEMPLATE_ID + " , GROUP_NOTATION_TYPE = $" + SdcArtifactHandlerConstants.GROUP_NOTATION_TYPE + " , IPADDRESS_V4_OAM_VIP = $" + SdcArtifactHandlerConstants.IPADDRESS_V4_OAM_VIP + " , GROUP_NOTATION_VALUE = $" + SdcArtifactHandlerConstants.GROUP_NOTATION_VALUE; diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java index 6a365e4f5..705aa4439 100644 --- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java +++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java @@ -70,6 +70,7 @@ import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.D import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.FILE_CATEGORY; import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.GROUP_NOTATION_TYPE; import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.GROUP_NOTATION_VALUE; +import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.TEMPLATE_ID; import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.IPADDRESS_V4_OAM_VIP; import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.PARAMETER_YANG; import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.PD; @@ -397,26 +398,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { dbservice.isArtifactUpdateRequired(context, DB_SDC_REFERENCE)); } } - if (content.getString(ACTION).equals("Configure") - || content.getString(ACTION).equals("ConfigModify")) { - if (content.has(DOWNLOAD_DG_REFERENCE) - && content.getString(DOWNLOAD_DG_REFERENCE).length() > 0) { - setAttribute(context, content::getString, DOWNLOAD_DG_REFERENCE); - dbservice.processDownloadDgReference(context, - dbservice.isArtifactUpdateRequired(context, DB_DOWNLOAD_DG_REFERENCE)); - } - if (StringUtils.isBlank(context.getAttribute(DOWNLOAD_DG_REFERENCE))) { - context.setAttribute(DOWNLOAD_DG_REFERENCE, - dbservice.getDownLoadDGReference(context)); - } - dbservice.processConfigActionDg(context, dbservice.isArtifactUpdateRequired(context, - DB_CONFIG_ACTION_DG)); - if (content.getString(ACTION).equals("Configure")) { - dbservice.processDeviceInterfaceProtocol(context, dbservice.isArtifactUpdateRequired(context, - DB_DEVICE_INTERFACE_PROTOCOL)); - } - - } + processConfigTypeActions(content,dbservice,context); dbservice.processDeviceAuthentication(context, dbservice.isArtifactUpdateRequired(context, DB_DEVICE_AUTHENTICATION)); @@ -426,38 +408,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { if (content.has(VM) && content.get(VM) instanceof JSONArray) { - JSONArray vmList = (JSONArray) content.get(VM); - dbservice.cleanUpVnfcReferencesForVnf(context); - for (int i = 0; i < vmList.length(); i++) { - JSONObject vmInstance = (JSONObject) vmList.get(i); - setAttribute(context, s -> String.valueOf(vmInstance.getInt(s)), VM_INSTANCE); - log.info("VALUE = " + context.getAttribute(VM_INSTANCE)); - if (vmInstance.get(VNFC) instanceof JSONArray) { - JSONArray vnfcInstanceList = (JSONArray) vmInstance.get(VNFC); - for (int k = 0; k < vnfcInstanceList.length(); k++) { - JSONObject vnfcInstance = (JSONObject) vnfcInstanceList.get(k); - - setAttribute(context, s -> String.valueOf(vnfcInstance.getInt(s)), VNFC_INSTANCE); - setAttribute(context, vnfcInstance::getString, VNFC_TYPE); - setAttribute(context, vnfcInstance::getString, VNFC_FUNCTION_CODE); - - if (vnfcInstance.has(IPADDRESS_V4_OAM_VIP)) { - setAttribute(context, vnfcInstance::getString, IPADDRESS_V4_OAM_VIP); - } - if (vnfcInstance.has(GROUP_NOTATION_TYPE)) { - setAttribute(context, vnfcInstance::getString, GROUP_NOTATION_TYPE); - } - if (vnfcInstance.has(GROUP_NOTATION_VALUE)) { - setAttribute(context, vnfcInstance::getString, GROUP_NOTATION_VALUE); - } - if (content.getString(ACTION).equals("Configure")) { - dbservice.processVnfcReference(context, false); - } - cleanVnfcInstance(context); - } - context.setAttribute(VM_INSTANCE, null); - } - } + processVmList(content, context, dbservice); } @@ -481,6 +432,73 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin { return true; } + public void processConfigTypeActions(JSONObject content, DBService dbservice, SvcLogicContext context)throws Exception { + if (content.getString(ACTION).equals("Configure") + || content.getString(ACTION).equals("ConfigModify") || content.getString(ACTION).equals("ConfigScaleOut")) { + if (content.has(DOWNLOAD_DG_REFERENCE) + && content.getString(DOWNLOAD_DG_REFERENCE).length() > 0) { + setAttribute(context, content::getString, DOWNLOAD_DG_REFERENCE); + dbservice.processDownloadDgReference(context, + dbservice.isArtifactUpdateRequired(context, DB_DOWNLOAD_DG_REFERENCE)); + } + if (StringUtils.isBlank(context.getAttribute(DOWNLOAD_DG_REFERENCE))) { + context.setAttribute(DOWNLOAD_DG_REFERENCE, + dbservice.getDownLoadDGReference(context)); + } + dbservice.processConfigActionDg(context, dbservice.isArtifactUpdateRequired(context, + DB_CONFIG_ACTION_DG)); + if (content.getString(ACTION).equals("Configure") || content.getString(ACTION).equals("ConfigScaleOut")) { + boolean isPresent=dbservice.isArtifactUpdateRequired(context,DB_DEVICE_INTERFACE_PROTOCOL); + if (content.getString(ACTION).equals("Configure") || (content.getString(ACTION).equals("ConfigScaleOut") && !isPresent)) + dbservice.processDeviceInterfaceProtocol(context, isPresent); + } + + } + + } + + public void processVmList(JSONObject content, SvcLogicContext context, DBService dbservice) throws Exception{ + JSONArray vmList = (JSONArray) content.get(VM); + dbservice.cleanUpVnfcReferencesForVnf(context); + for (int i = 0; i < vmList.length(); i++) { + JSONObject vmInstance = (JSONObject) vmList.get(i); + setAttribute(context, s -> String.valueOf(vmInstance.getInt(s)), VM_INSTANCE); + log.info("VALUE = " + context.getAttribute(VM_INSTANCE)); + String templateId = vmInstance.optString(TEMPLATE_ID); + if (StringUtils.isNotBlank(templateId)) { + setAttribute(context, vmInstance::optString, TEMPLATE_ID); + } + if (vmInstance.get(VNFC) instanceof JSONArray) { + JSONArray vnfcInstanceList = (JSONArray) vmInstance.get(VNFC); + for (int k = 0; k < vnfcInstanceList.length(); k++) { + JSONObject vnfcInstance = (JSONObject) vnfcInstanceList.get(k); + + setAttribute(context, s -> String.valueOf(vnfcInstance.getInt(s)), VNFC_INSTANCE); + setAttribute(context, vnfcInstance::getString, VNFC_TYPE); + setAttribute(context, vnfcInstance::getString, VNFC_FUNCTION_CODE); + + if (vnfcInstance.has(IPADDRESS_V4_OAM_VIP)) { + setAttribute(context, vnfcInstance::getString, IPADDRESS_V4_OAM_VIP); + } + if (vnfcInstance.has(GROUP_NOTATION_TYPE)) { + setAttribute(context, vnfcInstance::getString, GROUP_NOTATION_TYPE); + } + if (vnfcInstance.has(GROUP_NOTATION_VALUE)) { + setAttribute(context, vnfcInstance::getString, GROUP_NOTATION_VALUE); + } + if (content.getString(ACTION).equals("Configure") + || content.getString(ACTION).equals("ConfigScaleOut")) { + dbservice.processVnfcReference(context, false); + } + cleanVnfcInstance(context); + } + context.setAttribute(VM_INSTANCE, null); + context.setAttribute(TEMPLATE_ID, null); + } + } + + } + private void cleanArtifactInstanceData(SvcLogicContext context) { context.setAttribute(ARTIFACT_NAME, null); context.setAttribute(FILE_CATEGORY, null); diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/SdcArtifactHandlerConstants.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/SdcArtifactHandlerConstants.java index 4f4525dd1..5051bb136 100644 --- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/SdcArtifactHandlerConstants.java +++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/SdcArtifactHandlerConstants.java @@ -62,6 +62,7 @@ public class SdcArtifactHandlerConstants { public static final String IPADDRESS_V4_OAM_VIP = "ipaddress-v4-oam-vip"; public static final String GROUP_NOTATION_TYPE = "group-notation-type"; public static final String GROUP_NOTATION_VALUE = "group-notation-value"; + public static final String TEMPLATE_ID = "template-id"; public static final String REFERENCE = "reference"; public static final String VNFC_INSTANCE = "vnfc-instance"; public static final String DEVICE_PROTOCOL = "device-protocol"; |