diff options
Diffstat (limited to 'adapters/mso-openstack-adapters/src/main')
2 files changed, 130 insertions, 149 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java index f1b6f838a0..a141f59153 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java @@ -117,16 +117,19 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { private static final String FAIL_REQUESTS_ON_VALET_FAILURE = "org.onap.so.adapters.vnf.fail_requests_on_valet_failure"; private static final String OPENSTACK = "OpenStack"; - - + private static final String DELETE_VNF = "DeleteVNF"; + private static final String QUERY_STACK = "QueryStack"; + private static final String CREATE_VFM_MODULE = "CreateVFModule"; + private static final String CREATE_VF_STACK = "Create VF: Stack"; + private static final String STACK = "Stack"; + private static final String USER_ERROR = "USER ERROR"; + private static final String VERSION_MIN = "VersionMin"; + private static final String VERSION_MAX = "VersionMax"; @Autowired private VFModuleCustomizationRepository vfModuleCustomRepo; - - @Autowired private VnfResourceRepository vnfResourceRepo; - @Autowired private MsoHeatUtilsWithUpdate heatU; @Autowired @@ -269,7 +272,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String error = "Query VNF: " + vnfName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + me; logger.error(LoggingAnchor.EIGHT, MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfName, cloudSiteId, tenantId, - OPENSTACK, "QueryVNF", ErrorCode.DataError.getValue(), "Exception - queryStack", me); + OPENSTACK, "QueryVNF", ErrorCode.DataError.getValue(), "Exception - " + QUERY_STACK, me); logger.debug(error); throw new VnfException(me); } @@ -316,13 +319,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { try { heat.deleteStack(tenantId, cloudOwner, cloudSiteId, vnfName, true); } catch (MsoException me) { - me.addContext("DeleteVNF"); + me.addContext(DELETE_VNF); // Failed to query the Stack due to an openstack exception. // Convert to a generic VnfException String error = "Delete VNF: " + vnfName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + me; logger.error(LoggingAnchor.NINE, MessageEnum.RA_DELETE_VNF_ERR.toString(), vnfName, cloudOwner, cloudSiteId, - tenantId, OPENSTACK, "DeleteVNF", ErrorCode.DataError.getValue(), "Exception - DeleteVNF", me); + tenantId, OPENSTACK, DELETE_VNF, ErrorCode.DataError.getValue(), "Exception - " + DELETE_VNF, me); logger.debug(error); throw new VnfException(me); } @@ -642,12 +645,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String error = "Create VF Module: Query " + vfModuleName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + me; logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, OPENSTACK, "queryStack", ErrorCode.DataError.getValue(), - "Exception - queryStack", me); + cloudSiteId, tenantId, OPENSTACK, QUERY_STACK, ErrorCode.DataError.getValue(), + "Exception - " + QUERY_STACK, me); logger.debug(error); // Failed to query the Stack due to an openstack exception. // Convert to a generic VnfException - me.addContext("CreateVFModule"); + me.addContext(CREATE_VFM_MODULE); throw new VnfException(me); } // more precise handling/messaging if the stack already exists @@ -657,35 +660,35 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (status == HeatStatus.INIT || status == HeatStatus.BUILDING || status == HeatStatus.DELETING || status == HeatStatus.UPDATING) { // fail - it's in progress - return meaningful error - String error = "Create VF: Stack " + vfModuleName + " already exists and has status " + String error = CREATE_VF_STACK + " " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + "; please wait for it to complete, or fix manually."; logger.error(LoggingAnchor.NINE, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, OPENSTACK, "queryStack", ErrorCode.DataError.getValue(), - "Stack " + vfModuleName + " already exists"); + cloudSiteId, tenantId, OPENSTACK, QUERY_STACK, ErrorCode.DataError.getValue(), + STACK + " " + vfModuleName + " already exists"); logger.debug(error); throw new VnfAlreadyExists(vfModuleName, cloudOwner, cloudSiteId, tenantId, heatStack.getCanonicalName()); } if (status == HeatStatus.FAILED) { // fail - it exists and is in a FAILED state - String error = "Create VF: Stack " + vfModuleName + " already exists and is in FAILED state in " + String error = CREATE_VF_STACK + " " + vfModuleName + " already exists and is in FAILED state in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + "; requires manual intervention."; logger.error(LoggingAnchor.NINE, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, OPENSTACK, "queryStack", ErrorCode.DataError.getValue(), - "Stack " + vfModuleName + " already exists and is " + "in FAILED state"); + cloudSiteId, tenantId, OPENSTACK, QUERY_STACK, ErrorCode.DataError.getValue(), + STACK + " " + vfModuleName + " already exists and is " + "in FAILED state"); logger.debug(error); throw new VnfAlreadyExists(vfModuleName, cloudOwner, cloudSiteId, tenantId, heatStack.getCanonicalName()); } if (status == HeatStatus.UNKNOWN || status == HeatStatus.UPDATED) { // fail - it exists and is in a FAILED state - String error = "Create VF: Stack " + vfModuleName + " already exists and has status " + String error = CREATE_VF_STACK + " " + vfModuleName + " already exists and has status " + status.toString() + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + "; requires manual intervention."; logger.error(LoggingAnchor.NINE, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, OPENSTACK, "queryStack", ErrorCode.DataError.getValue(), - "Stack " + vfModuleName + " already exists and is " + "in UPDATED or UNKNOWN state"); + cloudSiteId, tenantId, OPENSTACK, QUERY_STACK, ErrorCode.DataError.getValue(), + STACK + " " + vfModuleName + " already exists and is " + "in UPDATED or UNKNOWN state"); logger.debug(error); throw new VnfAlreadyExists(vfModuleName, cloudOwner, cloudSiteId, tenantId, heatStack.getCanonicalName()); @@ -693,11 +696,11 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (status == HeatStatus.CREATED) { // fail - it exists if (failIfExists != null && failIfExists) { - String error = "Create VF: Stack " + vfModuleName + " already exists in " + cloudOwner + "/" + String error = CREATE_VF_STACK + " " + vfModuleName + " already exists in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId; logger.error(LoggingAnchor.NINE, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, - cloudOwner, cloudSiteId, tenantId, OPENSTACK, "queryStack", ErrorCode.DataError.getValue(), - "Stack " + vfModuleName + " already exists"); + cloudOwner, cloudSiteId, tenantId, OPENSTACK, QUERY_STACK, ErrorCode.DataError.getValue(), + STACK + " " + vfModuleName + " already exists"); logger.debug(error); throw new VnfAlreadyExists(vfModuleName, cloudOwner, cloudSiteId, tenantId, heatStack.getCanonicalName()); @@ -724,20 +727,20 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } catch (MsoException me) { // Failed to query the Stack due to an openstack exception. // Convert to a generic VnfException - me.addContext("CreateVFModule"); + me.addContext(CREATE_VFM_MODULE); String error = "Create VFModule: Attached heatStack ID Query " + nestedStackId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + me; logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, OPENSTACK, "queryStack", ErrorCode.BusinessProcesssError.getValue(), + cloudSiteId, tenantId, OPENSTACK, QUERY_STACK, ErrorCode.BusinessProcesssError.getValue(), "MsoException trying to query nested stack", me); logger.debug("ERROR trying to query nested stack= {}", error); throw new VnfException(me); } if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) { String error = "Create VFModule: Attached heatStack ID DOES NOT EXIST " + nestedStackId + " in " - + cloudOwner + "/" + cloudSiteId + "/" + tenantId + " USER ERROR"; + + cloudOwner + "/" + cloudSiteId + "/" + tenantId + " " + USER_ERROR; logger.error(LoggingAnchor.TEN, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, error, OPENSTACK, "queryStack", + cloudSiteId, tenantId, error, OPENSTACK, QUERY_STACK, ErrorCode.BusinessProcesssError.getValue(), "Create VFModule: Attached heatStack ID " + "DOES NOT EXIST"); logger.debug(error); @@ -758,20 +761,20 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } catch (MsoException me) { // Failed to query the Stack due to an openstack exception. // Convert to a generic VnfException - me.addContext("CreateVFModule"); + me.addContext(CREATE_VFM_MODULE); String error = "Create VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + me; logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, OPENSTACK, "QueryStack", ErrorCode.BusinessProcesssError.getValue(), + cloudSiteId, tenantId, OPENSTACK, QUERY_STACK, ErrorCode.BusinessProcesssError.getValue(), "MsoException trying to query nested base stack", me); logger.debug("ERROR trying to query nested base stack= {}", error); throw new VnfException(me); } if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) { String error = "Create VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId - + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + " USER ERROR"; + + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + " " + USER_ERROR; logger.error(LoggingAnchor.TEN, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, error, OPENSTACK, "QueryStack", + cloudSiteId, tenantId, error, OPENSTACK, QUERY_STACK, ErrorCode.BusinessProcesssError.getValue(), "Create VFModule: Attached base heatStack ID DOES NOT EXIST"); logger.debug("Exception occurred", error); @@ -893,14 +896,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if ((moreThanMin || equalToMin) // aic >= min && (equalToMax || !(moreThanMax))) { // aic <= max logger.debug("VNF Resource " + vnfResource.getModelName() + ", ModelUuid=" - + vnfResource.getModelUUID() + " VersionMin=" + minVersionVnf + " VersionMax:" - + maxVersionVnf + " supported on Cloud: " + cloudSiteId + " with AIC_Version:" - + cloudSiteOpt.get().getCloudVersion()); + + vnfResource.getModelUUID() + " " + VERSION_MIN + " =" + minVersionVnf + " " + + VERSION_MAX + " :" + maxVersionVnf + " supported on Cloud: " + cloudSiteId + + " with AIC_Version:" + cloudSiteOpt.get().getCloudVersion()); } else { // ERROR String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" - + vnfResource.getModelUUID() + " VersionMin=" + minVersionVnf + " VersionMax:" - + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteId + + vnfResource.getModelUUID() + " " + VERSION_MIN + " =" + minVersionVnf + " " + + VERSION_MAX + " :" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSiteOpt.get().getCloudVersion(); logger.error(LoggingAnchor.FIVE, MessageEnum.RA_CONFIG_EXC.toString(), error, OPENSTACK, ErrorCode.BusinessProcesssError.getValue(), "Exception - setVersion"); @@ -936,8 +939,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (heatTemplate == null) { String error = "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType - + ", modelCustomizationUuid=" + mcu + ", vfModuleUuid=" + vf.getModelUUID() - + ", vnfResourceModelUuid=" + vnfResource.getModelUUID() + ", reqType=" + requestTypeString; + + ", modelCustomizationUuid=" + mcu + ", vfModuleUuid=" + + (vf != null ? vf.getModelUUID() : "null") + ", vnfResourceModelUuid=" + + vnfResource.getModelUUID() + ", reqType=" + requestTypeString; logger.error(LoggingAnchor.SIX, MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "Heat Template " + "ID", vfModuleType, OPENSTACK, ErrorCode.DataError.getValue(), error); logger.debug(error); @@ -952,8 +956,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { if (heatEnvironment == null) { String error = "Update VNF: undefined Heat Environment. VF=" + vfModuleType - + ", modelCustomizationUuid=" + mcu + ", vfModuleUuid=" + vf.getModelUUID() - + ", vnfResourceModelUuid=" + vnfResource.getModelUUID() + ", reqType=" + requestTypeString; + + ", modelCustomizationUuid=" + mcu + ", vfModuleUuid=" + + (vf != null ? vf.getModelUUID() : "null") + ", vnfResourceModelUuid=" + + vnfResource.getModelUUID() + ", reqType=" + requestTypeString; logger.error(LoggingAnchor.FIVE, MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "Heat " + "Environment ID", OPENSTACK, ErrorCode.DataError.getValue(), error); logger.debug(error); @@ -1188,7 +1193,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { throw new MsoHeatNotFoundException(); } } catch (MsoException me) { - me.addContext("CreateVFModule"); + me.addContext(CREATE_VFM_MODULE); logger.error("Error creating Stack", me); if (isValetEnabled && sendResponseToValet) { logger.debug("valet is enabled, the orchestration failed - now sending rollback to valet"); @@ -1246,7 +1251,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // 1702 capture the output parameters on a delete // so we'll need to query first - Map<String, Object> stackOutputs = null; + Map<String, Object> stackOutputs; try { stackOutputs = heat.queryStackForOutputs(cloudSiteId, cloudOwner, tenantId, vnfName); } catch (MsoException me) { @@ -1256,7 +1261,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String error = "Delete VFModule: Query to get outputs: " + vnfName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + me; logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfName, cloudOwner, cloudSiteId, - tenantId, OPENSTACK, "QueryStack", ErrorCode.DataError.getValue(), "Exception - QueryStack", me); + tenantId, OPENSTACK, QUERY_STACK, ErrorCode.DataError.getValue(), "Exception - " + QUERY_STACK, me); logger.debug(error); throw new VnfException(me); } @@ -1277,7 +1282,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { try { heat.deleteStack(tenantId, cloudOwner, cloudSiteId, vnfName, true); } catch (MsoException me) { - me.addContext("DeleteVNF"); + me.addContext(DELETE_VNF); // Failed to query the Stack due to an openstack exception. // Convert to a generic VnfException String error = @@ -1390,9 +1395,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { logger.debug("requestTypeString = " + requestTypeString + ", nestedVolumeStackId = " + nestedStackId + ", nestedBaseStackId = " + nestedBaseStackId); - // Will capture execution time for metrics - long startTime = System.currentTimeMillis(); - // Build a default rollback object (no actions performed) VnfRollback vfRollback = new VnfRollback(); vfRollback.setCloudSiteId(cloudSiteId); @@ -1406,8 +1408,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { vfRollback.setVfModuleStackId(vfModuleStackId); vfRollback.setModelCustomizationUuid(mcu); - StackInfo heatStack = null; - long queryStackStarttime = System.currentTimeMillis(); + StackInfo heatStack; logger.debug("UpdateVfModule - querying for {}", vfModuleName); try { heatStack = heat.queryStack(cloudSiteId, cloudOwner, tenantId, vfModuleName); @@ -1418,8 +1419,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String error = "Update VFModule: Query " + vfModuleName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + me; logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, OPENSTACK, "QueryStack", ErrorCode.DataError.getValue(), - "Exception - QueryStack", me); + cloudSiteId, tenantId, OPENSTACK, QUERY_STACK, ErrorCode.DataError.getValue(), + "Exception - " + QUERY_STACK, me); logger.debug(error); throw new VnfException(me); } @@ -1430,7 +1431,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String error = "Update VF: Stack " + vfModuleName + " does not exist in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId; logger.error(LoggingAnchor.NINE, MessageEnum.RA_VNF_NOT_EXIST.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, OPENSTACK, "QueryStack", ErrorCode.DataError.getValue(), error); + cloudSiteId, tenantId, OPENSTACK, QUERY_STACK, ErrorCode.DataError.getValue(), error); throw new VnfNotFound(cloudSiteId, cloudOwner, tenantId, vfModuleName); } else { logger.debug("Found Existing stack, status={}", heatStack.getStatus()); @@ -1441,7 +1442,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // 1604 Cinder Volume support - handle a nestedStackId if sent (volumeGroupHeatStackId): StackInfo nestedHeatStack = null; - long queryStackStarttime2 = System.currentTimeMillis(); Map<String, Object> nestedVolumeOutputs = null; if (nestedStackId != null) { try { @@ -1454,16 +1454,16 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String error = "Update VF: Attached heatStack ID Query " + nestedStackId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + me; logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfName, cloudOwner, - cloudSiteId, tenantId, OPENSTACK, "QueryStack", ErrorCode.DataError.getValue(), + cloudSiteId, tenantId, OPENSTACK, QUERY_STACK, ErrorCode.DataError.getValue(), "Exception - " + error, me); logger.debug("ERROR trying to query nested stack= {}", error); throw new VnfException(me); } if (nestedHeatStack == null || nestedHeatStack.getStatus() == HeatStatus.NOTFOUND) { String error = "Update VFModule: Attached volume heatStack ID DOES NOT EXIST " + nestedStackId + " in " - + cloudOwner + "/" + cloudSiteId + "/" + tenantId + " USER ERROR"; + + cloudOwner + "/" + cloudSiteId + "/" + tenantId + " " + USER_ERROR; logger.error(LoggingAnchor.TEN, MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfName, cloudOwner, - cloudSiteId, tenantId, error, OPENSTACK, "QueryStack", ErrorCode.DataError.getValue(), error); + cloudSiteId, tenantId, error, OPENSTACK, QUERY_STACK, ErrorCode.DataError.getValue(), error); logger.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } else { @@ -1476,7 +1476,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { StackInfo nestedBaseHeatStack = null; Map<String, Object> baseStackOutputs = null; if (nestedBaseStackId != null) { - long queryStackStarttime3 = System.currentTimeMillis(); try { logger.debug("Querying for nestedBaseStackId = {}", nestedBaseStackId); nestedBaseHeatStack = heat.queryStack(cloudSiteId, cloudOwner, tenantId, nestedBaseStackId); @@ -1487,16 +1486,16 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String error = "Update VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + me; logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, OPENSTACK, "QueryStack", ErrorCode.DataError.getValue(), + cloudSiteId, tenantId, OPENSTACK, QUERY_STACK, ErrorCode.DataError.getValue(), "Exception - " + error, me); logger.debug("ERROR trying to query nested base stack= {}", error); throw new VnfException(me); } if (nestedBaseHeatStack == null || nestedBaseHeatStack.getStatus() == HeatStatus.NOTFOUND) { String error = "Update VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId - + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + " USER ERROR"; + + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + " " + USER_ERROR; logger.error(LoggingAnchor.TEN, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, error, OPENSTACK, "QueryStack", ErrorCode.DataError.getValue(), error); + cloudSiteId, tenantId, error, OPENSTACK, QUERY_STACK, ErrorCode.DataError.getValue(), error); logger.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } else { @@ -1598,14 +1597,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (!doNotTest) { if ((moreThanMin || equalToMin) // aic >= min && ((equalToMax) || !(moreThanMax))) { // aic <= max - logger.debug("VNF Resource " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf - + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSiteId - + " with AIC_Version:" + aicV); + logger.debug("VNF Resource " + vnfResource.getModelName() + " " + VERSION_MIN + " =" + + minVersionVnf + " " + VERSION_MAX + " :" + maxVersionVnf + " supported on Cloud: " + + cloudSiteId + " with AIC_Version:" + aicV); } else { // ERROR - String error = "VNF Resource type: " + vnfResource.getModelName() + " VersionMin=" - + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " - + cloudSiteId + " with AIC_Version:" + aicV; + String error = "VNF Resource type: " + vnfResource.getModelName() + " " + VERSION_MIN + " =" + + minVersionVnf + " " + VERSION_MAX + " :" + maxVersionVnf + + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + aicV; logger.error(LoggingAnchor.FIVE, MessageEnum.RA_CONFIG_EXC.toString(), error, OPENSTACK, ErrorCode.BusinessProcesssError.getValue(), "Exception - setVersion"); logger.debug(error); @@ -1930,7 +1929,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Have the tenant. Now deploy the stack itself // Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions // because we already checked for those. - long updateStackStarttime = System.currentTimeMillis(); try { heatStack = heatU.updateStack(cloudSiteId, cloudOwner, tenantId, vfModuleName, template, goldenInputs, true, heatTemplate.getTimeoutMinutes(), newEnvironmentString, @@ -2023,7 +2021,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { Map<String, Object> nestedTemplates) { boolean haveGetFiles = true; boolean haveNestedTemplates = true; - Map<String, Object> files = new HashMap<String, Object>(); + Map<String, Object> files = new HashMap<>(); if (getFiles == null || getFiles.isEmpty()) { haveGetFiles = false; } @@ -2079,7 +2077,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (newInputs != null) { Map<String, Object> oldGold = goldenInputs; logger.debug("parameters before being modified by valet:{}", oldGold.toString()); - goldenInputs = new HashMap<String, Object>(); + goldenInputs = new HashMap<>(); for (String key : newInputs.keySet()) { goldenInputs.put(key, newInputs.get(key)); } @@ -2215,7 +2213,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { valetDeleteRequestSucceeded = false; valetErrorMessage = e.getMessage(); } - if (valetDeleteRequestSucceeded == false && failRequestOnValetFailure == true) { + if (!valetDeleteRequestSucceeded && failRequestOnValetFailure) { logger.error("ValetDeleteRequestFailed - del req still will be sent to openstack", new VnfException("ValetDeleteRequestFailedError")); } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java index 98cfa9d410..96e5db7ce7 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java @@ -176,10 +176,6 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { Holder<Map<String, String>> outputs) throws VnfException { logger.debug("Querying VNF {} in {}", vnfName, cloudSiteId + "/" + tenantId); - // Will capture execution time for metrics - long startTime = System.currentTimeMillis(); - long subStartTime = System.currentTimeMillis(); - DeploymentInfo deployment = null; try { @@ -190,6 +186,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { deployment = null; } catch (MsoException me) { // Failed to query the Deployment due to a cloudify exception. + logger.debug("Failed to query the Deployment due to a cloudify exception"); // Convert to a generic VnfException me.addContext("QueryVNF"); String error = "Query VNF (Cloudify): " + vnfName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId @@ -215,7 +212,6 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { logger.debug("VNF {} not found", vnfName); } - return; } @@ -241,7 +237,6 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { */ @Override public void rollbackVnf(VnfRollback rollback) throws VnfException { - long startTime = System.currentTimeMillis(); // rollback may be null (e.g. if stack already existed when Create was called) if (rollback == null) { logger.info(LoggingAnchor.THREE, MessageEnum.RA_ROLLBACK_NULL.toString(), OPENSTACK, "rollbackVnf"); @@ -267,7 +262,6 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { // The possible outcomes of deleteStack are a StackInfo object with status // of NOTFOUND (on success) or FAILED (on error). Also, MsoOpenstackException // could be thrown. - long subStartTime = System.currentTimeMillis(); try { // KLUDGE - Cloudify requires Tenant Name for Openstack. We have the ID. // Go directly to Keystone until APIs could be updated to supply the name. @@ -290,7 +284,6 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { logger.debug(error); throw new VnfException(me); } - return; } @@ -318,37 +311,38 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { } private Map<String, String> copyStringOutputs(Map<String, Object> stackOutputs) { - Map<String, String> stringOutputs = new HashMap<String, String>(); - for (String key : stackOutputs.keySet()) { - if (stackOutputs.get(key) instanceof String) { - stringOutputs.put(key, (String) stackOutputs.get(key)); - } else if (stackOutputs.get(key) instanceof Integer) { + Map<String, String> stringOutputs = new HashMap<>(); + for (Map.Entry<String, Object> entry : stackOutputs.entrySet()) { + if (entry.getValue() instanceof String) { + stringOutputs.put(entry.getKey(), (String) entry.getValue()); + } else if (entry.getValue() instanceof Integer) { try { - String str = "" + stackOutputs.get(key); - stringOutputs.put(key, str); + String str = "" + entry.getValue(); + stringOutputs.put(entry.getKey(), str); } catch (Exception e) { - logger.debug("Unable to add " + key + " to outputs"); + logger.error("Unable to add " + entry.getKey() + " to outputs", e); } - } else if (stackOutputs.get(key) instanceof JsonNode) { + } else if (entry.getValue() instanceof JsonNode) { try { - String str = this.convertNode((JsonNode) stackOutputs.get(key)); - stringOutputs.put(key, str); + String str = this.convertNode((JsonNode) entry.getValue()); + stringOutputs.put(entry.getKey(), str); } catch (Exception e) { - logger.debug("Unable to add " + key + " to outputs - exception converting JsonNode"); + logger.error("Unable to add " + entry.getKey() + " to outputs - exception converting JsonNode", e); } - } else if (stackOutputs.get(key) instanceof java.util.LinkedHashMap) { + } else if (entry.getValue() instanceof java.util.LinkedHashMap) { try { - String str = JSON_MAPPER.writeValueAsString(stackOutputs.get(key)); - stringOutputs.put(key, str); + String str = JSON_MAPPER.writeValueAsString(entry.getValue()); + stringOutputs.put(entry.getKey(), str); } catch (Exception e) { - logger.debug("Unable to add " + key + " to outputs - exception converting LinkedHashMap"); + logger.error("Unable to add " + entry.getKey() + " to outputs - exception converting LinkedHashMap", + e); } } else { try { - String str = stackOutputs.get(key).toString(); - stringOutputs.put(key, str); + String str = entry.getValue().toString(); + stringOutputs.put(entry.getKey(), str); } catch (Exception e) { - logger.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage()); + logger.error("Unable to add " + entry.getKey() + " to outputs - unable to call .toString() ", e); } } } @@ -364,18 +358,17 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { } else if (inputs.size() < 1) { sb.append("\tEMPTY"); } else { - for (String str : inputs.keySet()) { + for (Map.Entry<String, Object> entry : inputs.entrySet()) { String outputString; try { - outputString = inputs.get(str).toString(); + outputString = entry.getValue().toString(); } catch (Exception e) { - outputString = "Unable to call toString() on the value for " + str; + outputString = "Unable to call toString() on the value for " + entry.getKey(); } - sb.append("\t\nitem " + i++ + ": '" + str + "'='" + outputString + "'"); + sb.append("\t\nitem " + i++ + ": '" + entry.getKey() + "'='" + outputString + "'"); } } logger.debug(sb.toString()); - return; } private void sendMapToDebug(Map<String, Object> inputs) { @@ -386,12 +379,11 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { } else if (inputs.size() < 1) { sb.append("\tEMPTY"); } else { - for (String str : inputs.keySet()) { - sb.append("\titem " + i++ + ": " + str + "=" + inputs.get(str)); + for (Map.Entry<String, Object> entry : inputs.entrySet()) { + sb.append("\titem " + i++ + ": " + entry.getKey() + "=" + entry.getValue()); } } logger.debug(sb.toString()); - return; } private String convertNode(final JsonNode node) { @@ -400,9 +392,9 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { final String json = JSON_MAPPER.writeValueAsString(obj); return json; } catch (JsonParseException jpe) { - logger.debug("Error converting json to string " + jpe.getMessage()); + logger.error("Error converting json to string ", jpe); } catch (Exception e) { - logger.debug("Error converting json to string " + e.getMessage()); + logger.error("Error converting json to string ", e); } return "[Error converting json to string]"; } @@ -411,44 +403,44 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { if (objectMap == null) { return null; } - Map<String, String> stringMap = new HashMap<String, String>(); - for (String key : objectMap.keySet()) { - if (!stringMap.containsKey(key)) { - Object obj = objectMap.get(key); + Map<String, String> stringMap = new HashMap<>(); + for (Map.Entry<String, Object> entry : objectMap.entrySet()) { + if (!stringMap.containsKey(entry.getKey())) { + Object obj = entry.getValue(); if (obj instanceof String) { - stringMap.put(key, (String) objectMap.get(key)); + stringMap.put(entry.getKey(), (String) entry.getValue()); } else if (obj instanceof JsonNode) { // This is a bit of mess - but I think it's the least impacting // let's convert it BACK to a string - then it will get converted back later try { String str = this.convertNode((JsonNode) obj); - stringMap.put(key, str); + stringMap.put(entry.getKey(), str); } catch (Exception e) { - logger.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode " + key); + logger.error("DANGER WILL ROBINSON: unable to convert value for JsonNode " + entry.getKey(), e); // okay in this instance - only string values (fqdn) are expected to be needed } } else if (obj instanceof java.util.LinkedHashMap) { logger.debug("LinkedHashMap - this is showing up as a LinkedHashMap instead of JsonNode"); try { String str = JSON_MAPPER.writeValueAsString(obj); - stringMap.put(key, str); + stringMap.put(entry.getKey(), str); } catch (Exception e) { - logger.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap " + key); + logger.error( + "DANGER WILL ROBINSON: unable to convert value for LinkedHashMap " + entry.getKey(), e); } } else if (obj instanceof Integer) { try { String str = "" + obj; - stringMap.put(key, str); + stringMap.put(entry.getKey(), str); } catch (Exception e) { - logger.debug("DANGER WILL ROBINSON: unable to convert value for Integer " + key); + logger.error("DANGER WILL ROBINSON: unable to convert value for Integer " + entry.getKey(), e); } } else { try { String str = obj.toString(); - stringMap.put(key, str); + stringMap.put(entry.getKey(), str); } catch (Exception e) { - logger.debug( - "DANGER WILL ROBINSON: unable to convert value " + key + " (" + e.getMessage() + ")"); + logger.error("DANGER WILL ROBINSON: unable to convert value " + entry.getKey(), e); } } } @@ -504,8 +496,6 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { String volumeGroupId, String baseVfModuleId, String modelCustomizationUuid, Map<String, Object> inputs, Boolean failIfExists, Boolean backout, Boolean enableBridge, MsoRequest msoRequest, Holder<String> vnfId, Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback) throws VnfException { - // Will capture execution time for metrics - long startTime = System.currentTimeMillis(); // Require a model customization ID. Every VF Module definition must have one. if (modelCustomizationUuid == null || modelCustomizationUuid.isEmpty()) { @@ -587,7 +577,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { vnfResource = vfmc.getVfModule().getVnfResources(); } catch (Exception e) { - logger.debug("unhandled exception in create VF - [Query]" + e.getMessage()); + logger.error("unhandled exception in create VF - [Query]", e); throw new VnfException("Exception during create VF " + e.getMessage()); } @@ -622,7 +612,6 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { // First, look up to see if the VF already exists. - long subStartTime1 = System.currentTimeMillis(); try { cloudifyDeployment = cloudifyUtils.queryDeployment(cloudSiteId, tenantId, vfModuleName); } catch (MsoException me) { @@ -716,7 +705,6 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { // If a Volume Group was provided, query its outputs for inclusion in Module input parameters if (volumeGroupId != null) { - long subStartTime2 = System.currentTimeMillis(); DeploymentInfo volumeDeployment = null; try { volumeDeployment = cloudifyUtils.queryDeployment(cloudSiteId, tenantId, volumeGroupId); @@ -765,7 +753,6 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { } if (baseVfModuleId != null) { - long subStartTime2 = System.currentTimeMillis(); DeploymentInfo baseDeployment = null; try { baseDeployment = cloudifyUtils.queryDeployment(cloudSiteId, tenantId, baseVfModuleId); @@ -843,21 +830,21 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { try { // All variables converted to their native object types - HashMap<String, Object> goldenInputs = new HashMap<String, Object>(); - List<String> extraInputs = new ArrayList<String>(); + HashMap<String, Object> goldenInputs = new HashMap<>(); + List<String> extraInputs = new ArrayList<>(); // NOTE: SKIP THIS FOR CLOUDIFY for now. Just use what was passed in. // This whole section needs to be rewritten. Boolean skipInputChecks = false; if (skipInputChecks) { - goldenInputs = new HashMap<String, Object>(); - for (String key : inputs.keySet()) { - goldenInputs.put(key, inputs.get(key)); + goldenInputs = new HashMap<>(); + for (Map.Entry<String, Object> entry : inputs.entrySet()) { + goldenInputs.put(entry.getKey(), entry.getValue()); } } else { // Build maps for the parameters (including aliases) to simplify checks - HashMap<String, HeatTemplateParam> params = new HashMap<String, HeatTemplateParam>(); + HashMap<String, HeatTemplateParam> params = new HashMap<>(); Set<HeatTemplateParam> paramSet = heatTemplate.getParameters(); logger.debug("paramSet has {} entries", paramSet.size()); @@ -893,18 +880,18 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { // Next add in Volume Group Outputs if there are any. Copy directly without conversions. if (volumeGroupOutputs != null && !volumeGroupOutputs.isEmpty()) { - for (String key : volumeGroupOutputs.keySet()) { - if (params.containsKey(key) && !goldenInputs.containsKey(key)) { - goldenInputs.put(key, volumeGroupOutputs.get(key)); + for (Map.Entry<String, Object> entry : volumeGroupOutputs.entrySet()) { + if (params.containsKey(entry.getKey()) && !goldenInputs.containsKey(entry.getKey())) { + goldenInputs.put(entry.getKey(), entry.getValue()); } } } // Next add in Base Module Outputs if there are any. Copy directly without conversions. if (baseModuleOutputs != null && !baseModuleOutputs.isEmpty()) { - for (String key : baseModuleOutputs.keySet()) { - if (params.containsKey(key) && !goldenInputs.containsKey(key)) { - goldenInputs.put(key, baseModuleOutputs.get(key)); + for (Map.Entry<String, Object> entry : baseModuleOutputs.entrySet()) { + if (params.containsKey(entry.getKey()) && !goldenInputs.containsKey(entry.getKey())) { + goldenInputs.put(entry.getKey(), entry.getValue()); } } } @@ -948,7 +935,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { } } catch (Exception e) { // No problem - default is true - logger.debug("An exception occured trying to get property {}", + logger.error("An exception occured trying to get property {}", MsoVnfCloudifyAdapterImpl.CHECK_REQD_PARAMS, e); } @@ -996,7 +983,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { if (!cloudifyUtils.isBlueprintLoaded(cloudSiteId, blueprintId)) { logger.debug("Blueprint " + blueprintId + " is not loaded. Will upload it now."); - Map<String, byte[]> blueprintFiles = new HashMap<String, byte[]>(); + Map<String, byte[]> blueprintFiles = new HashMap<>(); blueprintFiles.put(blueprintName, blueprint.getBytes()); @@ -1039,7 +1026,6 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { // Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions // because we already checked for those. - long createDeploymentStarttime = System.currentTimeMillis(); try { // KLUDGE - Cloudify requires Tenant Name for Openstack. We have the ID. // Go directly to Keystone until APIs could be updated to supply the name. @@ -1073,11 +1059,11 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { // npe.addContext ("CreateVNF"); throw new VnfException("NullPointerException during cloudify.createAndInstallDeployment"); } catch (Exception e) { - logger.debug("unhandled exception at cloudify.createAndInstallDeployment"); + logger.error("unhandled exception at cloudify.createAndInstallDeployment", e); throw new VnfException("Exception during cloudify.createAndInstallDeployment! " + e.getMessage()); } } catch (Exception e) { - logger.debug("unhandled exception in create VF"); + logger.error("unhandled exception in create VF", e); throw new VnfException("Exception during create VF " + e.getMessage()); } @@ -1091,15 +1077,13 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { rollback.value = vfRollback; - logger.debug("VF Module successfully created", vfModuleName); - return; + logger.debug("VF Module successfully created {}", vfModuleName); + } public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException { logger.debug("Deleting VF " + vnfName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId); - // Will capture execution time for metrics - long startTime = System.currentTimeMillis(); // 1702 capture the output parameters on a delete // so we'll need to query first @@ -1124,7 +1108,6 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { // The possible outcomes of deleteStack are a StackInfo object with status // of NOTFOUND (on success) or FAILED (on error). Also, MsoOpenstackException // could be thrown. - long subStartTime = System.currentTimeMillis(); try { cloudifyUtils.uninstallAndDeleteDeployment(cloudSiteId, tenantId, vnfName, 5); } catch (MsoException me) { |