diff options
Diffstat (limited to 'adapters/mso-vnf-adapter/src')
11 files changed, 497 insertions, 329 deletions
diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java index 4842580d85..5c654298fb 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterAsyncImpl.java @@ -371,8 +371,9 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { * @param cloudSiteId CLLI code of the cloud site in which to delete * @param tenantId Openstack tenant identifier * @param vnfName VNF Name or Openstack ID + * @param messageId * @param msoRequest Request tracking information for logs - * @param notificationURL the target URL for asynchronous response + * @param notificationUrl the target URL for asynchronous response */ @Override public void deleteVnfA (String cloudSiteId, diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java index 95e62a0e2d..9022c26ccd 100644 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImpl.java @@ -295,7 +295,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { vnfExists.value = Boolean.FALSE; status.value = VnfStatus.NOTFOUND; vnfId.value = null; - outputs.value = new HashMap <String, String> (); // Return as an empty map + outputs.value = new HashMap<>(); // Return as an empty map LOGGER.debug ("VNF " + vnfName + " not found"); } else { @@ -536,8 +536,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { final Object obj = JSON_MAPPER.treeToValue(node, Object.class); final String json = JSON_MAPPER.writeValueAsString(obj); return json; - } catch (JsonParseException jpe) { - LOGGER.debug("Error converting json to string " + jpe.getMessage(),jpe); } catch (Exception e) { LOGGER.debug("Error converting json to string " + e.getMessage(),e); } @@ -548,7 +546,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (objectMap == null) { return null; } - Map<String, String> stringMap = new HashMap<String, String>(); + Map<String, String> stringMap = new HashMap<>(); for (String key : objectMap.keySet()) { if (!stringMap.containsKey(key)) { Object obj = objectMap.get(key); @@ -823,9 +821,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Ready to deploy the new VNF - CatalogDatabase db = CatalogDatabase.getInstance(); - - try { + try (CatalogDatabase db = CatalogDatabase.getInstance()) { // Retrieve the VF VfModule vf = null; VnfResource vnfResource = null; @@ -839,10 +835,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { //vf = db.getVfModuleByModelCustomizationUuid(mcu); if (vf == null) { LOGGER.debug("Unable to find vfModuleCust with modelCustomizationUuid=" + mcu); - String error = "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" + mcu; + String error = + "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" + mcu; LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, - "VF Module ModelCustomizationUuid", modelCustomizationUuid, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VF Module: Unable to find vfModule with modelCustomizationUuid=" + mcu); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + "VF Module ModelCustomizationUuid", modelCustomizationUuid, "OpenStack", "", + MsoLogger.ErrorCode.DataError, + "Create VF Module: Unable to find vfModule with modelCustomizationUuid=" + mcu); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, + error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } else { LOGGER.debug("Found vfModuleCust entry " + vfmc.toString()); @@ -853,7 +853,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { LOGGER.debug("This is *not* a BASE VF request!"); if (!isVolumeRequest && nestedBaseStackId == null) { - LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request"); + LOGGER.debug( + "DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request"); } } } @@ -912,12 +913,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (vnfResource == null) { String error = "Create VNF: Unknown VNF Type: " + vnfType; LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "VNF Type", - vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VNF: Unknown VNF Type"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VNF: Unknown VNF Type"); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, + error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } LOGGER.debug("Got VNF module definition from Catalog: " - + vnfResource.toString()); + + vnfResource.toString()); } // By here - we have either a vf or vnfResource @@ -930,7 +932,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { //vnfResource = db.getVnfResourceById(vnfResourceId); vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid); if (vnfResource == null) { - LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now..."); + LOGGER.debug( + "Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now..."); } } } @@ -941,7 +944,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { minVersionVnf = vnfResource.getAicVersionMin(); maxVersionVnf = vnfResource.getAicVersionMax(); } catch (Exception e) { - LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",e); + LOGGER.debug("Unable to pull min/max version for this VNF Resource entry", e); minVersionVnf = null; maxVersionVnf = null; } @@ -974,17 +977,26 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { moreThanMax = aicV.isMoreRecentThan(maxVersionVnf); equalToMax = aicV.isTheSameVersion(maxVersionVnf); } catch (Exception e) { - LOGGER.debug("An exception occured while trying to test AIC Version " + e.getMessage() + " - will default to not check",e); + LOGGER.debug("An exception occured while trying to test AIC Version " + e.getMessage() + + " - will default to not check", e); doNotTest = true; } if (!doNotTest) { 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: " + cloudSiteOpt.get().getId() + " with AIC_Version:" + cloudSiteOpt.get().getAic_version()); + && (equalToMax || !(moreThanMax))) { //aic <= max + LOGGER.debug("VNF Resource " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource + .getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + + " supported on Cloud: " + cloudSiteOpt.get().getId() + " with AIC_Version:" + + cloudSiteOpt.get().getAic_version()); } else { // ERROR - String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteOpt.get().getId() + " with AIC_Version:" + cloudSiteOpt.get().getAic_version(); - LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); + String error = + "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource + .getModelUuid() + " VersionMin=" + minVersionVnf + " VersionMax:" + + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteOpt.get().getId() + + " with AIC_Version:" + cloudSiteOpt.get().getAic_version(); + LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", + MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); LOGGER.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } @@ -996,7 +1008,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { LOGGER.debug("cloudConfig is NULL - cannot check cloud site version"); } } else { - LOGGER.debug("AIC Version not set in VNF_Resource - this is expected thru 1607 - do not error here - not checked."); + LOGGER.debug( + "AIC Version not set in VNF_Resource - this is expected thru 1607 - do not error here - not checked."); } // End Version check 1607 @@ -1018,7 +1031,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } } else { if (isVolumeRequest) { - LOGGER.debug("DANGER WILL ROBINSON! This should never apply - a VNF Request (gamma only now) *and* a volume request?"); + LOGGER.debug( + "DANGER WILL ROBINSON! This should never apply - a VNF Request (gamma only now) *and* a volume request?"); /* VnfComponent vnfComponent = null; vnfComponent = db.getVnfComponent(vnfResource.getId(), "VOLUME"); @@ -1040,11 +1054,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // By the time we get here - heatTemplateId and heatEnvtId should be populated (or null) HeatTemplate heatTemplate = null; if (heatTemplateArtifactUuid == null || "".equals(heatTemplateArtifactUuid)) { - String error = "Create: No Heat Template ID defined in catalog database for " + vnfType + ", reqType=" + requestTypeString; - LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vnfType, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create: No Heat Template ID defined in catalog database"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + String error = "Create: No Heat Template ID defined in catalog database for " + vnfType + ", reqType=" + + requestTypeString; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vnfType, "OpenStack", "", + MsoLogger.ErrorCode.DataError, "Create: No Heat Template ID defined in catalog database"); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, + error); alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, - MsoAlarmLogger.CRITICAL, error); + MsoAlarmLogger.CRITICAL, error); throw new VnfException(error, MsoExceptionCategory.INTERNAL); } else { heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid); @@ -1052,11 +1069,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (heatTemplate == null) { String error = "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid; LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, - "Heat Template ID", - String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + "Heat Template ID", + String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", + MsoLogger.ErrorCode.BusinessProcesssError, + "Create VF/VNF: no entry found for heat template ID = " + heatTemplateArtifactUuid); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, + error); alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, - MsoAlarmLogger.CRITICAL, error); + MsoAlarmLogger.CRITICAL, error); throw new VnfException(error, MsoExceptionCategory.INTERNAL); } LOGGER.debug("Got HEAT Template from DB"); @@ -1065,45 +1085,49 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String heatEnvironmentString = null; if (heatEnvironmentArtifactUuid != null && !"".equals(heatEnvironmentArtifactUuid)) { - LOGGER.debug ("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":"); + LOGGER.debug("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":"); heatEnvironment = db.getHeatEnvironmentByArtifactUuid(heatEnvironmentArtifactUuid); if (heatEnvironment == null) { String error = "Create VFModule: undefined Heat Environment. VFModule=" + vfModuleType - + ", Environment ID=" - + heatEnvironmentArtifactUuid; - LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", String.valueOf(heatEnvironmentArtifactUuid), "OpenStack", "getHeatEnvironment", MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: undefined Heat Environment"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + + ", Environment ID=" + + heatEnvironmentArtifactUuid; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", + String.valueOf(heatEnvironmentArtifactUuid), "OpenStack", "getHeatEnvironment", + MsoLogger.ErrorCode.BusinessProcesssError, "Create VFModule: undefined Heat Environment"); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, + error); // Alarm on this error, configuration must be fixed - alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); - throw new VnfException (error, MsoExceptionCategory.INTERNAL); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); } else { - LOGGER.debug ("Got Heat Environment from DB: " + heatEnvironment.toString ()); - heatEnvironmentString = heatEnvironment.getEnvironment (); //this.parseEnvironment (heatEnvironment.getEnvironment ()); - LOGGER.debug ("after parsing: " + heatEnvironmentString); + LOGGER.debug("Got Heat Environment from DB: " + heatEnvironment.toString()); + heatEnvironmentString = heatEnvironment + .getEnvironment(); //this.parseEnvironment (heatEnvironment.getEnvironment ()); + LOGGER.debug("after parsing: " + heatEnvironmentString); } } else { - LOGGER.debug ("no environment parameter found for this Type " + vfModuleType); + LOGGER.debug("no environment parameter found for this Type " + vfModuleType); } // 1510 - Add the files: for nested templates *if* there are any - LOGGER.debug ("In MsoVnfAdapterImpl, createVfModule about to call db.getNestedTemplates avec templateId=" - + heatTemplate.getArtifactUuid()); - Map <String, Object> nestedTemplates = db.getNestedTemplates (heatTemplate.getArtifactUuid()); - Map <String, Object> nestedTemplatesChecked = new HashMap <> (); + LOGGER.debug("In MsoVnfAdapterImpl, createVfModule about to call db.getNestedTemplates avec templateId=" + + heatTemplate.getArtifactUuid()); + Map<String, Object> nestedTemplates = db.getNestedTemplates(heatTemplate.getArtifactUuid()); + Map<String, Object> nestedTemplatesChecked = new HashMap<>(); if (nestedTemplates != null) { // for debugging print them out - LOGGER.debug ("Contents of nestedTemplates - to be added to files: on stack:"); - for (Map.Entry<String, Object> entry : nestedTemplates.entrySet ()) { + LOGGER.debug("Contents of nestedTemplates - to be added to files: on stack:"); + for (Map.Entry<String, Object> entry : nestedTemplates.entrySet()) { String providerResourceFile = entry.getKey(); Object value = entry.getValue(); String providerResourceFileChecked = providerResourceFile; //this.enforceFilePrefix (providerResourceFile); String childTemplateBody = (String) value; - LOGGER.debug (providerResourceFileChecked + " -> " + childTemplateBody); - nestedTemplatesChecked.put (providerResourceFileChecked, childTemplateBody); + LOGGER.debug(providerResourceFileChecked + " -> " + childTemplateBody); + nestedTemplatesChecked.put(providerResourceFileChecked, childTemplateBody); } } else { - LOGGER.debug ("No nested templates found - nothing to do here"); + LOGGER.debug("No nested templates found - nothing to do here"); nestedTemplatesChecked = null; // just to make sure } @@ -1115,25 +1139,29 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Add ability to turn on adding get_files with volume requests (by property). boolean addGetFilesOnVolumeReq = false; try { - String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER).getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null); + String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER) + .getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null); if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) { addGetFilesOnVolumeReq = true; LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString); } } catch (Exception e) { - LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + " - default to false", e); + LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + + " - default to false", e); } if (!isVolumeRequest || addGetFilesOnVolumeReq) { if (oldWay) { - LOGGER.debug("In MsoVnfAdapterImpl createVfModule, this should not happen - old way is gamma only - no heat files!"); + LOGGER.debug( + "In MsoVnfAdapterImpl createVfModule, this should not happen - old way is gamma only - no heat files!"); //heatFiles = db.getHeatFiles(vnfResource.getId()); } else { // 1607 - now use VF_MODULE_TO_HEAT_FILES table - LOGGER.debug("In MsoVnfAdapterImpl createVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId=" + LOGGER.debug( + "In MsoVnfAdapterImpl createVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId=" + vf.getModelUUID()); heatFiles = db - .getHeatFilesForVfModule(vf.getModelUUID()); + .getHeatFilesForVfModule(vf.getModelUUID()); } if (heatFiles != null) { // add these to stack - to be done in createStack @@ -1147,19 +1175,24 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { HeatFiles value = entry.getValue(); if (heatFileName.startsWith("_ERROR|")) { // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found. - String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1); - String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + " at HEAT_FILES index=" + heatFileId; + String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|") + 1); + String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + + " at HEAT_FILES index=" + heatFileId; LOGGER.debug(error); - LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "HEAT_FILES entry not found"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + LOGGER + .error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, + vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, + "HEAT_FILES entry not found"); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.DataNotFound, error); // Alarm on this error, configuration must be fixed - alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); - throw new VnfException (error, MsoExceptionCategory.INTERNAL); + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); } String heatFileBody = value.getFileBody(); String heatFileNameChecked = heatFileName; LOGGER.debug(heatFileNameChecked + " -> " - + heatFileBody); + + heatFileBody); heatFilesObjects.put(heatFileNameChecked, heatFileBody); } } else { @@ -1167,12 +1200,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { heatFilesObjects = null; } } else { - LOGGER.debug("Volume request - DO NOT CHECK for HEAT_FILES"); + LOGGER.debug("Volume request - DO NOT CHECK for HEAT_FILES"); } // Check that required parameters have been supplied StringBuilder missingParams = null; - List <String> paramList = new ArrayList <> (); + List<String> paramList = new ArrayList<>(); // New for 1510 - consult the PARAM_ALIAS field to see if we've been // supplied an alias. Only check if we don't find it initially. @@ -1181,23 +1214,23 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // shouldn't boolean checkRequiredParameters = true; try { - String propertyString = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_VNF_ADAPTER) - .getProperty (MsoVnfAdapterImpl.CHECK_REQD_PARAMS,null); - if ("false".equalsIgnoreCase (propertyString) || "n".equalsIgnoreCase (propertyString)) { + String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER) + .getProperty(MsoVnfAdapterImpl.CHECK_REQD_PARAMS, null); + if ("false".equalsIgnoreCase(propertyString) || "n".equalsIgnoreCase(propertyString)) { checkRequiredParameters = false; - LOGGER.debug ("CheckRequiredParameters is FALSE. Will still check but then skip blocking..." - + MsoVnfAdapterImpl.CHECK_REQD_PARAMS); + LOGGER.debug("CheckRequiredParameters is FALSE. Will still check but then skip blocking..." + + MsoVnfAdapterImpl.CHECK_REQD_PARAMS); } } catch (Exception e) { // No problem - default is true - LOGGER.debug ("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e); + LOGGER.debug("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e); } // 1604 - Add enhanced environment & parameter checking // Part 1: parse envt entries to see if reqd parameter is there (before used a simple grep // Part 2: only submit to openstack the parameters in the envt that are in the heat template // Note this also removes any comments MsoHeatEnvironmentEntry mhee = null; - if (heatEnvironmentString != null && heatEnvironmentString.contains ("parameters:")) { + if (heatEnvironmentString != null && heatEnvironmentString.contains("parameters:")) { //LOGGER.debug ("Have an Environment argument with a parameters: section - will bypass checking for valid params - but will still check for aliases"); LOGGER.debug("Enhanced environment checking enabled - 1604"); mhee = MsoHeatEnvironmentEntry.create(heatEnvironmentString); @@ -1235,7 +1268,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } LOGGER.debug(sb.toString()); } catch (Exception e) { - LOGGER.debug("??An exception occurred trying to go through Parameter Names " + e.getMessage(),e); + LOGGER.debug("??An exception occurred trying to go through Parameter Names " + e.getMessage(), e); } // Step 1 - convert what we got as inputs (Map<String, String>) to a // Map<String, Object> - where the object matches the param type identified in the template @@ -1249,21 +1282,22 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { heat.copyBaseOutputsToInputs(goldenInputs, nestedVolumeOutputs, parameterNames, aliasToParam); this.sendMapToDebug(goldenInputs, "Final inputs sent to openstack"); - for (HeatTemplateParam parm : heatTemplate.getParameters ()) { - LOGGER.debug ("Parameter:'" + parm.getParamName () - + "', isRequired=" - + parm.isRequired () - + ", alias=" - + parm.getParamAlias ()); + for (HeatTemplateParam parm : heatTemplate.getParameters()) { + LOGGER.debug("Parameter:'" + parm.getParamName() + + "', isRequired=" + + parm.isRequired() + + ", alias=" + + parm.getParamAlias()); - if (parm.isRequired () && (goldenInputs == null || !goldenInputs.containsKey (parm.getParamName ()))) { + if (parm.isRequired() && (goldenInputs == null || !goldenInputs.containsKey(parm.getParamName()))) { // The check for an alias was moved to the method in MsoHeatUtils - when we converted the Map<String, String> to Map<String, Object> - LOGGER.debug("**Parameter " + parm.getParamName() + " is required and not in the inputs...check environment"); + LOGGER.debug("**Parameter " + parm.getParamName() + + " is required and not in the inputs...check environment"); if (mhee != null && mhee.containsParameter(parm.getParamName())) { - LOGGER.debug ("Required parameter " + parm.getParamName () - + " appears to be in environment - do not count as missing"); + LOGGER.debug("Required parameter " + parm.getParamName() + + " appears to be in environment - do not count as missing"); } else { - LOGGER.debug ("adding to missing parameters list: " + parm.getParamName ()); + LOGGER.debug("adding to missing parameters list: " + parm.getParamName()); if (missingParams == null) { missingParams = new StringBuilder(parm.getParamName()); } else { @@ -1271,20 +1305,22 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } } } - paramList.add (parm.getParamName ()); + paramList.add(parm.getParamName()); } if (missingParams != null) { if (checkRequiredParameters) { // Problem - missing one or more required parameters String error = "Create VFModule: Missing Required inputs: " + missingParams; - LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams.toString(), "OpenStack", "", MsoLogger.ErrorCode.DataError, "Create VFModule: Missing Required inputs"); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); - throw new VnfException (error, MsoExceptionCategory.USERDATA); + LOGGER.error(MessageEnum.RA_MISSING_PARAM, missingParams.toString(), "OpenStack", "", + MsoLogger.ErrorCode.DataError, "Create VFModule: Missing Required inputs"); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, + error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); } else { - LOGGER.debug ("found missing parameters - but checkRequiredParameters is false - will not block"); + LOGGER.debug("found missing parameters - but checkRequiredParameters is false - will not block"); } } else { - LOGGER.debug ("No missing parameters found - ok to proceed"); + LOGGER.debug("No missing parameters found - ok to proceed"); } // We can now remove the recreating of the ENV with only legit params - that check is done for us, // and it causes problems with json that has arrays @@ -1294,13 +1330,13 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } // "Fix" the template if it has CR/LF (getting this from Oracle) - String template = heatTemplate.getHeatTemplate (); - template = template.replaceAll ("\r\n", "\n"); + String template = heatTemplate.getHeatTemplate(); + template = template.replaceAll("\r\n", "\n"); // Have the tenant. Now deploy the stack itself // Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions // because we already checked for those. - long createStackStarttime = System.currentTimeMillis (); + long createStackStarttime = System.currentTimeMillis(); try { // heatStack = heat.createStack(cloudSiteId, tenantId, vnfName, template, inputs, true, // heatTemplate.getTimeoutMinutes()); @@ -1310,47 +1346,59 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (heat != null) { LOGGER.debug("heat is not null!!"); } - heatStack = heat.createStack (cloudSiteId, - tenantId, - vfModuleName, - template, - goldenInputs, - true, - heatTemplate.getTimeoutMinutes (), - newEnvironmentString, - nestedTemplatesChecked, - heatFilesObjects, - backout.booleanValue()); - LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack", "CreateStack", vfModuleName); + heatStack = heat.createStack(cloudSiteId, + tenantId, + vfModuleName, + template, + goldenInputs, + true, + heatTemplate.getTimeoutMinutes(), + newEnvironmentString, + nestedTemplatesChecked, + heatFilesObjects, + backout.booleanValue()); + LOGGER + .recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, + "Successfully received response from Open Stack", "OpenStack", "CreateStack", vfModuleName); } catch (MsoException me) { - me.addContext ("CreateVFModule"); + me.addContext("CreateVFModule"); String error = "Create VF Module " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName); - LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "MsoException - createStack", me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new VnfException (me); + LOGGER.recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName); + LOGGER.error(MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", + MsoLogger.ErrorCode.DataError, "MsoException - createStack", me); + LOGGER + .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + error); + throw new VnfException(me); } catch (NullPointerException npe) { String error = "Create VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + npe; - LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName); - LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "NullPointerException - createStack", npe); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); + LOGGER.recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "CreateStack", vfModuleName); + LOGGER.error(MessageEnum.RA_CREATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", + MsoLogger.ErrorCode.DataError, "NullPointerException - createStack", npe); + LOGGER + .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + error); LOGGER.debug("NULL POINTER EXCEPTION at heat.createStack"); //npe.addContext ("CreateVNF"); - throw new VnfException ("NullPointerException during heat.createStack"); + throw new VnfException("NullPointerException during heat.createStack"); } catch (Exception e) { - LOGGER.recordMetricEvent (createStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating stack with OpenStack", "OpenStack", "CreateStack", vfModuleName); - LOGGER.debug("unhandled exception at heat.createStack",e); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating stack with OpenStack"); + LOGGER.recordMetricEvent(createStackStarttime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, "Exception while creating stack with OpenStack", + "OpenStack", "CreateStack", vfModuleName); + LOGGER.debug("unhandled exception at heat.createStack", e); + LOGGER + .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + "Exception while creating stack with OpenStack"); throw new VnfException("Exception during heat.createStack! " + e.getMessage()); } } catch (Exception e) { - LOGGER.debug("unhandled exception in create VF",e); + LOGGER.debug("unhandled exception in create VF", e); throw new VnfException("Exception during create VF " + e.getMessage()); - } finally { - // Make sure DB session is closed - db.close (); } + // Make sure DB session is closed // Reach this point if createStack is successful. // Populate remaining rollback info and response parameters. @@ -1442,19 +1490,17 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String serviceName = VNF_ADAPTER_SERVICE_NAME + methodName; MsoLogger.setServiceName (serviceName); - StringBuilder sbInit = new StringBuilder(); - sbInit.append("updateVfModule: \n"); - sbInit.append("cloudSiteId=").append(cloudSiteId).append("\n"); - sbInit.append("tenantId=").append(tenantId).append("\n"); - sbInit.append("vnfType=").append(vnfType).append("\n"); - sbInit.append("vnfVersion=").append(vnfVersion).append("\n"); - sbInit.append("vnfName=").append(vnfName).append("\n"); - sbInit.append("requestType=").append(requestType).append("\n"); - sbInit.append("volumeGroupHeatStackId=").append(volumeGroupHeatStackId).append("\n"); - sbInit.append("baseVfHeatStackId=").append(baseVfHeatStackId).append("\n"); - sbInit.append("vfModuleStackId=").append(vfModuleStackId).append("\n"); - sbInit.append("modelCustomizationUuid=").append(modelCustomizationUuid).append("\n"); - LOGGER.debug(sbInit.toString()); + String strInit = "updateVfModule: cloudSiteId=" + cloudSiteId + + ",tenantId=" + tenantId + + ",vnfType=" + vnfType + + ",vnfVersion=" + vnfVersion + + ",vnfName=" + vnfName + + ",requestType=" + requestType + + ",volumeGroupHeatStackId=" + volumeGroupHeatStackId + + ",baseVfHeatStackId=" + baseVfHeatStackId + + ",vfModuleStackId=" + vfModuleStackId + + ",modelCustomizationUuid=" + modelCustomizationUuid; + LOGGER.debug(strInit); String mcu = modelCustomizationUuid; boolean useMCUuid = false; @@ -1635,10 +1681,9 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Ready to deploy the new VNF // Get a handle to the Catalog Database - CatalogDatabase db = CatalogDatabase.getInstance(); // Make sure DB session is closed - try { + try (CatalogDatabase db = CatalogDatabase.getInstance()) { // Retrieve the VF definition VnfResource vnfResource = null; VfModule vf = null; @@ -1653,20 +1698,22 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else { LOGGER.debug("1707 and later - MUST PROVIDE Model Customization UUID!"); } - if (vf == null) { + if (vf == null) { String error = "Update VfModule: unable to find vfModule with modelCustomizationUuid=" + mcu; - LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "VF Module Type", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); - throw new VnfException (error, MsoExceptionCategory.USERDATA); + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "VF Module Type", vfModuleType, "OpenStack", "", + MsoLogger.ErrorCode.DataError, error); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); } - LOGGER.debug ("Got VF module definition from Catalog: " + vf.toString ()); + LOGGER.debug("Got VF module definition from Catalog: " + vf.toString()); if (vf.isBase()) { isBaseRequest = true; LOGGER.debug("This a BASE update request"); } else { LOGGER.debug("This is *not* a BASE VF update request"); if (!isVolumeRequest && nestedBaseStackId == null) { - LOGGER.debug("DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request"); + LOGGER.debug( + "DANGER WILL ROBINSON! This is unexpected - no nestedBaseStackId with this non-base request"); } } @@ -1678,7 +1725,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { //vnfResource = db.getVnfResourceById(vnfResourceId); vnfResource = db.getVnfResourceByModelUuid(vnfResourceModelUuid); if (vnfResource == null) { - LOGGER.debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now..."); + LOGGER + .debug("Unable to find vnfResource at " + vnfResourceModelUuid + " will not error for now..."); } } String minVersionVnf = null; @@ -1688,35 +1736,42 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { minVersionVnf = vnfResource.getAicVersionMin(); maxVersionVnf = vnfResource.getAicVersionMax(); } catch (Exception e) { - LOGGER.debug("Unable to pull min/max version for this VNF Resource entry",e); + LOGGER.debug("Unable to pull min/max version for this VNF Resource entry", e); minVersionVnf = null; maxVersionVnf = null; - } + } if (minVersionVnf != null && "".equals(minVersionVnf)) { minVersionVnf = null; } if (maxVersionVnf != null && "".equals(maxVersionVnf)) { maxVersionVnf = null; - } } + } if (minVersionVnf != null && maxVersionVnf != null) { MavenLikeVersioning aicV = new MavenLikeVersioning(); //String aicVersion = ""; if (this.cloudConfig == null) { this.cloudConfig = this.cloudConfigFactory.getCloudConfig(); - } + } // double check if (this.cloudConfig != null) { Optional<CloudSite> cloudSiteOpt = this.cloudConfig.getCloudSite(cloudSiteId); if (cloudSiteOpt.isPresent()) { aicV.setVersion(cloudSiteOpt.get().getAic_version()); if ((aicV.isMoreRecentThan(minVersionVnf) || aicV.isTheSameVersion(minVersionVnf)) // aic >= min - && (aicV.isTheSameVersion(maxVersionVnf) || !(aicV.isMoreRecentThan(maxVersionVnf)))) { //aic <= max - LOGGER.debug("VNF Resource " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSiteOpt.get().getId() + " with AIC_Version:" + cloudSiteOpt.get().getAic_version()); + && (aicV.isTheSameVersion(maxVersionVnf) || !(aicV + .isMoreRecentThan(maxVersionVnf)))) { //aic <= max + LOGGER.debug("VNF Resource " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSiteOpt.get().getId() + + " with AIC_Version:" + cloudSiteOpt.get().getAic_version()); } else { // ERROR - String error = "VNF Resource type: " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteOpt.get().getId() + " with AIC_Version:" + cloudSiteOpt.get().getAic_version(); - LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); + String error = + "VNF Resource type: " + vnfResource.getModelName() + " VersionMin=" + minVersionVnf + + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteOpt.get() + .getId() + " with AIC_Version:" + cloudSiteOpt.get().getAic_version(); + LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", + MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); LOGGER.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } @@ -1742,11 +1797,15 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { heatEnvironmentArtifactUuid = vfmc.getHeatEnvironmentArtifactUuid(); } if (heatTemplateArtifactUuid == null) { - String error = "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType + ", reqType=" + requestTypeString; - LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + String error = + "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType + ", reqType=" + + requestTypeString; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Template ID", vfModuleType, "OpenStack", "", + MsoLogger.ErrorCode.DataError, error); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, + error); alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, - MsoAlarmLogger.CRITICAL, error); + MsoAlarmLogger.CRITICAL, error); throw new VnfException(error, MsoExceptionCategory.INTERNAL); } else { heatTemplate = db.getHeatTemplateByArtifactUuidRegularQuery(heatTemplateArtifactUuid); @@ -1754,90 +1813,97 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (heatTemplate == null) { String error = "Update VNF: undefined Heat Template. VF=" - + vfModuleType + ", heat template id = " + heatTemplateArtifactUuid; + + vfModuleType + ", heat template id = " + heatTemplateArtifactUuid; LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, - "Heat Template ID", - String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + "Heat Template ID", + String.valueOf(heatTemplateArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError, error); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, + error); // Alarm on this error, configuration must be fixed alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, - MsoAlarmLogger.CRITICAL, error); + MsoAlarmLogger.CRITICAL, error); throw new VnfException(error, MsoExceptionCategory.INTERNAL); } - LOGGER.debug ("Got HEAT Template from DB: " + heatTemplate.toString ()); + LOGGER.debug("Got HEAT Template from DB: " + heatTemplate.toString()); // Add check for any Environment variable HeatEnvironment heatEnvironment = null; String heatEnvironmentString = null; if (heatEnvironmentArtifactUuid != null) { - LOGGER.debug ("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":"); + LOGGER.debug("about to call getHeatEnvironment with :" + heatEnvironmentArtifactUuid + ":"); heatEnvironment = db.getHeatEnvironmentByArtifactUuid(heatEnvironmentArtifactUuid); if (heatEnvironment == null) { String error = "Update VNF: undefined Heat Environment. VF=" + vfModuleType - + ", Environment ID=" - + heatEnvironmentArtifactUuid; - LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", String.valueOf(heatEnvironmentArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + + ", Environment ID=" + + heatEnvironmentArtifactUuid; + LOGGER.error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "Heat Environment ID", + String.valueOf(heatEnvironmentArtifactUuid), "OpenStack", "", MsoLogger.ErrorCode.DataError, + error); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, + error); // Alarm on this error, configuration must be fixed - alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); - throw new VnfException (error, MsoExceptionCategory.INTERNAL); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); } else { - LOGGER.debug ("Got Heat Environment from DB: " + heatEnvironment.toString ()); - heatEnvironmentString = heatEnvironment.getEnvironment (); //this.parseEnvironment (heatEnvironment.getEnvironment ()); - LOGGER.debug ("After parsing: " + heatEnvironmentString); + LOGGER.debug("Got Heat Environment from DB: " + heatEnvironment.toString()); + heatEnvironmentString = heatEnvironment + .getEnvironment(); //this.parseEnvironment (heatEnvironment.getEnvironment ()); + LOGGER.debug("After parsing: " + heatEnvironmentString); } } else { - LOGGER.debug ("no environment parameter for this VFModuleType " + vfModuleType); + LOGGER.debug("no environment parameter for this VFModuleType " + vfModuleType); } - - LOGGER.debug ("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId=" - + heatTemplate.getArtifactUuid ()); - Map <String, Object> nestedTemplates = db.getNestedTemplates (heatTemplate.getArtifactUuid ()); - Map <String, Object> nestedTemplatesChecked = new HashMap <> (); + LOGGER.debug("In MsoVnfAdapterImpl, about to call db.getNestedTemplates avec templateId=" + + heatTemplate.getArtifactUuid()); + Map<String, Object> nestedTemplates = db.getNestedTemplates(heatTemplate.getArtifactUuid()); + Map<String, Object> nestedTemplatesChecked = new HashMap<>(); if (nestedTemplates != null) { // for debugging print them out - LOGGER.debug ("Contents of nestedTemplates - to be added to files: on stack:"); - for (Map.Entry<String, Object> entry : nestedTemplates.entrySet ()) { + LOGGER.debug("Contents of nestedTemplates - to be added to files: on stack:"); + for (Map.Entry<String, Object> entry : nestedTemplates.entrySet()) { String providerResourceFile = entry.getKey(); Object value = entry.getValue(); String providerResourceFileChecked = providerResourceFile; //this.enforceFilePrefix (providerResourceFile); String childTemplateBody = (String) value; - nestedTemplatesChecked.put (providerResourceFileChecked, childTemplateBody); - LOGGER.debug (providerResourceFileChecked + " -> " + childTemplateBody); + nestedTemplatesChecked.put(providerResourceFileChecked, childTemplateBody); + LOGGER.debug(providerResourceFileChecked + " -> " + childTemplateBody); } } else { - LOGGER.debug ("No nested templates found - nothing to do here"); + LOGGER.debug("No nested templates found - nothing to do here"); nestedTemplatesChecked = null; } // Also add the files: for any get_files associated with this VfModule // *if* there are any - LOGGER.debug ("In MsoVnfAdapterImpl.updateVfModule, about to call db.getHeatFiles avec vfModuleId=" - + vf.getModelUUID()); + LOGGER.debug("In MsoVnfAdapterImpl.updateVfModule, about to call db.getHeatFiles avec vfModuleId=" + + vf.getModelUUID()); - Map <String, HeatFiles> heatFiles = null; + Map<String, HeatFiles> heatFiles = null; // Map <String, HeatFiles> heatFiles = db.getHeatFiles (vnf.getId ()); - Map <String, Object> heatFilesObjects = new HashMap <> (); + Map<String, Object> heatFilesObjects = new HashMap<>(); // Add ability to turn on adding get_files with volume requests (by property). boolean addGetFilesOnVolumeReq = false; try { - String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER).getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null); + String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER) + .getProperty(MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ, null); if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) { addGetFilesOnVolumeReq = true; LOGGER.debug("AddGetFilesOnVolumeReq - setting to true! " + propertyString); } } catch (Exception e) { - LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + " - default to false", e); + LOGGER.debug("An error occured trying to get property " + MsoVnfAdapterImpl.ADD_GET_FILES_ON_VOLUME_REQ + + " - default to false", e); } if (!isVolumeRequest || addGetFilesOnVolumeReq) { - LOGGER.debug("In MsoVnfAdapterImpl updateVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId=" + LOGGER.debug( + "In MsoVnfAdapterImpl updateVfModule, about to call db.getHeatFilesForVfModule avec vfModuleId=" + vf.getModelUUID()); heatFiles = db.getHeatFilesForVfModule(vf.getModelUUID()); @@ -1845,35 +1911,39 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // add these to stack - to be done in createStack // here, we will map them to Map<String, Object> from Map<String, HeatFiles> // this will match the nested templates format - LOGGER.debug ("Contents of heatFiles - to be added to files: on stack:"); + LOGGER.debug("Contents of heatFiles - to be added to files: on stack:"); - for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet ()) { + for (Map.Entry<String, HeatFiles> entry : heatFiles.entrySet()) { String heatFileName = entry.getKey(); HeatFiles value = entry.getValue(); if (heatFileName.startsWith("_ERROR|")) { // This means there was an invalid entry in VF_MODULE_TO_HEAT_FILES table - the heat file it pointed to could not be found. - String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|")+1); - String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + " at HEAT_FILES index=" + heatFileId; + String heatFileId = heatFileName.substring(heatFileName.lastIndexOf("|") + 1); + String error = "Create: No HEAT_FILES entry in catalog database for " + vfModuleType + + " at HEAT_FILES index=" + heatFileId; LOGGER.debug(error); - LOGGER.error (MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error); + LOGGER + .error(MessageEnum.RA_VNF_UNKNOWN_PARAM, "HEAT_FILES entry not found at " + heatFileId, + vfModuleType, "OpenStack", "", MsoLogger.ErrorCode.DataError, error); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.DataNotFound, error); // Alarm on this error, configuration must be fixed - alarmLogger.sendAlarm (MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); - throw new VnfException (error, MsoExceptionCategory.INTERNAL); + alarmLogger.sendAlarm(MSO_CONFIGURATION_ERROR, MsoAlarmLogger.CRITICAL, error); + throw new VnfException(error, MsoExceptionCategory.INTERNAL); } - String heatFileBody = value.getFileBody (); - LOGGER.debug (heatFileName + " -> " + heatFileBody); - heatFilesObjects.put (heatFileName, heatFileBody); + String heatFileBody = value.getFileBody(); + LOGGER.debug(heatFileName + " -> " + heatFileBody); + heatFilesObjects.put(heatFileName, heatFileBody); } } else { - LOGGER.debug ("No heat files found -nothing to do here"); + LOGGER.debug("No heat files found -nothing to do here"); heatFilesObjects = null; } } // Check that required parameters have been supplied StringBuilder missingParams = null; - List <String> paramList = new ArrayList <> (); + List<String> paramList = new ArrayList<>(); // New for 1510 - consult the PARAM_ALIAS field to see if we've been // supplied an alias. Only check if we don't find it initially. @@ -1883,23 +1953,23 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { boolean haveEnvironmentParameters = false; boolean checkRequiredParameters = true; try { - String propertyString = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_VNF_ADAPTER) - .getProperty (MsoVnfAdapterImpl.CHECK_REQD_PARAMS,null); - if ("false".equalsIgnoreCase (propertyString) || "n".equalsIgnoreCase (propertyString)) { + String propertyString = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_VNF_ADAPTER) + .getProperty(MsoVnfAdapterImpl.CHECK_REQD_PARAMS, null); + if ("false".equalsIgnoreCase(propertyString) || "n".equalsIgnoreCase(propertyString)) { checkRequiredParameters = false; - LOGGER.debug ("CheckRequiredParameters is FALSE. Will still check but then skip blocking..." - + MsoVnfAdapterImpl.CHECK_REQD_PARAMS); + LOGGER.debug("CheckRequiredParameters is FALSE. Will still check but then skip blocking..." + + MsoVnfAdapterImpl.CHECK_REQD_PARAMS); } } catch (Exception e) { // No problem - default is true - LOGGER.debug ("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e); + LOGGER.debug("An exception occured trying to get property " + MsoVnfAdapterImpl.CHECK_REQD_PARAMS, e); } // 1604 - Add enhanced environment & parameter checking // Part 1: parse envt entries to see if reqd parameter is there (before used a simple grep // Part 2: only submit to openstack the parameters in the envt that are in the heat template // Note this also removes any comments MsoHeatEnvironmentEntry mhee = null; - if (heatEnvironmentString != null && heatEnvironmentString.toLowerCase ().contains ("parameters:")) { + if (heatEnvironmentString != null && heatEnvironmentString.toLowerCase().contains("parameters:")) { LOGGER.debug("Enhanced environment checking enabled - 1604"); mhee = MsoHeatEnvironmentEntry.create(heatEnvironmentString); StringBuilder sb2 = new StringBuilder("\nHeat Template Parameters:\n"); @@ -1921,12 +1991,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { HashMap<String, JsonNode> jsonParams = new HashMap<>(); boolean hasJson = false; - for (HeatTemplateParam parm : heatTemplate.getParameters ()) { - LOGGER.debug ("Parameter:'" + parm.getParamName () - + "', isRequired=" - + parm.isRequired () - + ", alias=" - + parm.getParamAlias ()); + for (HeatTemplateParam parm : heatTemplate.getParameters()) { + LOGGER.debug("Parameter:'" + parm.getParamName() + + "', isRequired=" + + parm.isRequired() + + ", alias=" + + parm.getParamAlias()); // handle json String parameterType = parm.getParamType(); if (parameterType == null || "".equals(parameterType.trim())) { @@ -1934,7 +2004,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } JsonNode jsonNode = null; if ("json".equalsIgnoreCase(parameterType) && inputs != null) { - if (inputs.containsKey(parm.getParamName()) ) { + if (inputs.containsKey(parm.getParamName())) { hasJson = true; String jsonString = null; try { @@ -1944,12 +2014,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { //TODO - what to do here? //for now - send the error to debug, but just leave it as a String String errorMessage = jpe.getMessage(); - LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage,jpe); + LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage, jpe); hasJson = false; jsonNode = null; } catch (Exception e) { // or here? - LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(),e); + LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(), e); hasJson = false; jsonNode = null; } @@ -1959,56 +2029,55 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } else if (inputs.containsKey(parm.getParamAlias())) { hasJson = true; String jsonString = null; - try { + try { jsonString = inputs.get(parm.getParamAlias()); jsonNode = new ObjectMapper().readTree(jsonString); } catch (JsonParseException jpe) { //TODO - what to do here? //for now - send the error to debug, but just leave it as a String String errorMessage = jpe.getMessage(); - LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage,jpe); + LOGGER.debug("Json Error Converting " + parm.getParamName() + " - " + errorMessage, jpe); hasJson = false; jsonNode = null; } catch (Exception e) { // or here? - LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(),e); + LOGGER.debug("Json Error Converting " + parm.getParamName() + " " + e.getMessage(), e); hasJson = false; jsonNode = null; } - if (jsonNode != null) { - // Notice here - we add it to the jsonParams hashMap with the actual name - - // then manipulate the inputs so when we check for aliases below - it will not - // get flagged. - jsonParams.put(parm.getParamName(), jsonNode); - inputs.remove(parm.getParamAlias()); - inputs.put(parm.getParamName(), jsonString); - } + if (jsonNode != null) { + // Notice here - we add it to the jsonParams hashMap with the actual name - + // then manipulate the inputs so when we check for aliases below - it will not + // get flagged. + jsonParams.put(parm.getParamName(), jsonNode); + inputs.remove(parm.getParamAlias()); + inputs.put(parm.getParamName(), jsonString); + } } //TODO add a check for the parameter in the env file } - if (parm.isRequired () && (inputs == null || !inputs.containsKey (parm.getParamName ()))) { - if (inputs.containsKey (parm.getParamAlias ())) { + if (parm.isRequired() && (inputs == null || !inputs.containsKey(parm.getParamName()))) { + if (inputs.containsKey(parm.getParamAlias())) { // They've submitted using an alias name. Remove that from inputs, and add back using real name. - String realParamName = parm.getParamName (); - String alias = parm.getParamAlias (); - String value = inputs.get (alias); - LOGGER.debug ("*Found an Alias: paramName=" + realParamName - + ",alias=" - + alias - + ",value=" - + value); - inputs.remove (alias); - inputs.put (realParamName, value); - LOGGER.debug (alias + " entry removed from inputs, added back using " + realParamName); + String realParamName = parm.getParamName(); + String alias = parm.getParamAlias(); + String value = inputs.get(alias); + LOGGER.debug("*Found an Alias: paramName=" + realParamName + + ",alias=" + + alias + + ",value=" + + value); + inputs.remove(alias); + inputs.put(realParamName, value); + LOGGER.debug(alias + " entry removed from inputs, added back using " + realParamName); } // enhanced - check if it's in the Environment (note: that method else if (mhee != null && mhee.containsParameter(parm.getParamName())) { - LOGGER.debug ("Required parameter " + parm.getParamName () - + " appears to be in environment - do not count as missing"); - } - else { - LOGGER.debug ("adding to missing parameters list: " + parm.getParamName ()); + LOGGER.debug("Required parameter " + parm.getParamName() + + " appears to be in environment - do not count as missing"); + } else { + LOGGER.debug("adding to missing parameters list: " + parm.getParamName()); if (missingParams == null) { missingParams = new StringBuilder(parm.getParamName()); } else { @@ -2016,20 +2085,22 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } } } - paramList.add (parm.getParamName ()); + paramList.add(parm.getParamName()); } if (missingParams != null) { // Problem - missing one or more required parameters if (checkRequiredParameters) { - String error = "Update VNF: Missing Required inputs: " + missingParams; - LOGGER.error (MessageEnum.RA_MISSING_PARAM, missingParams.toString(), "OpenStack", "", MsoLogger.ErrorCode.DataError, error); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, error); - throw new VnfException (error, MsoExceptionCategory.USERDATA); + String error = "Update VNF: Missing Required inputs: " + missingParams; + LOGGER.error(MessageEnum.RA_MISSING_PARAM, missingParams.toString(), "OpenStack", "", + MsoLogger.ErrorCode.DataError, error); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, + error); + throw new VnfException(error, MsoExceptionCategory.USERDATA); } else { - LOGGER.debug ("found missing parameters - but checkRequiredParameters is false - will not block"); + LOGGER.debug("found missing parameters - but checkRequiredParameters is false - will not block"); } } else { - LOGGER.debug ("No missing parameters found - ok to proceed"); + LOGGER.debug("No missing parameters found - ok to proceed"); } // Just submit the envt entry as received from the database @@ -2040,13 +2111,14 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // Remove any extraneous parameters (don't throw an error) if (inputs != null) { - List <String> extraParams = new ArrayList <> (); - extraParams.addAll (inputs.keySet ()); + List<String> extraParams = new ArrayList<>(); + extraParams.addAll(inputs.keySet()); // This is not a valid parameter for this template - extraParams.removeAll (paramList); - if (!extraParams.isEmpty ()) { - LOGGER.warn (MessageEnum.RA_VNF_EXTRA_PARAM, vnfType, extraParams.toString(), "OpenStack", "", MsoLogger.ErrorCode.DataError, "Extra params"); - inputs.keySet ().removeAll (extraParams); + extraParams.removeAll(paramList); + if (!extraParams.isEmpty()) { + LOGGER.warn(MessageEnum.RA_VNF_EXTRA_PARAM, vnfType, extraParams.toString(), "OpenStack", "", + MsoLogger.ErrorCode.DataError, "Extra params"); + inputs.keySet().removeAll(extraParams); } } // 1607 - when we get here - we have clean inputs. Create inputsTwo in case we have json @@ -2065,54 +2137,60 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } // "Fix" the template if it has CR/LF (getting this from Oracle) - String template = heatTemplate.getHeatTemplate (); - template = template.replaceAll ("\r\n", "\n"); + String template = heatTemplate.getHeatTemplate(); + template = template.replaceAll("\r\n", "\n"); // Have the tenant. Now deploy the stack itself // Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions // because we already checked for those. - long updateStackStarttime = System.currentTimeMillis (); + long updateStackStarttime = System.currentTimeMillis(); try { if (!hasJson) { - heatStack = heatU.updateStack (cloudSiteId, - tenantId, - vfModuleName, - template, - copyStringInputs (inputs), - true, - heatTemplate.getTimeoutMinutes (), - newEnvironmentString, - //heatEnvironmentString, - nestedTemplatesChecked, - heatFilesObjects); - LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "UpdateStack", null); + heatStack = heatU.updateStack(cloudSiteId, + tenantId, + vfModuleName, + template, + copyStringInputs(inputs), + true, + heatTemplate.getTimeoutMinutes(), + newEnvironmentString, + //heatEnvironmentString, + nestedTemplatesChecked, + heatFilesObjects); + LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", + "UpdateStack", null); } else { - heatStack = heatU.updateStack (cloudSiteId, - tenantId, - vfModuleName, - template, - inputsTwo, - true, - heatTemplate.getTimeoutMinutes (), - newEnvironmentString, - //heatEnvironmentString, - nestedTemplatesChecked, - heatFilesObjects); - LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", "UpdateStack", null); + heatStack = heatU.updateStack(cloudSiteId, + tenantId, + vfModuleName, + template, + inputsTwo, + true, + heatTemplate.getTimeoutMinutes(), + newEnvironmentString, + //heatEnvironmentString, + nestedTemplatesChecked, + heatFilesObjects); + LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.COMPLETE, + MsoLogger.ResponseCode.Suc, "Successfully receive response from Open Stack", "OpenStack", + "UpdateStack", null); } } catch (MsoException me) { - me.addContext ("UpdateVFModule"); + me.addContext("UpdateVFModule"); String error = "Update VFModule " + vfModuleType + " in " + cloudSiteId + "/" + tenantId + ": " + me; - LOGGER.recordMetricEvent (updateStackStarttime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null); - LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception - " + error, me); - LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error); - throw new VnfException (me); + LOGGER.recordMetricEvent(updateStackStarttime, MsoLogger.StatusCode.ERROR, + MsoLogger.ResponseCode.CommunicationError, error, "OpenStack", "UpdateStack", null); + LOGGER.error(MessageEnum.RA_UPDATE_VNF_ERR, vfModuleType, cloudSiteId, tenantId, "OpenStack", "", + MsoLogger.ErrorCode.DataError, "Exception - " + error, me); + LOGGER + .recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, + error); + throw new VnfException(me); } - } finally { - // Make sure DB session is closed - db.close (); } + // Make sure DB session is closed // Reach this point if updateStack is successful. // Populate remaining rollback info and response parameters. diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduInfo.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduInfo.java index 53300c9453..3646b292c5 100755 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduInfo.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduInfo.java @@ -35,8 +35,8 @@ public class VduInfo { private String vduInstanceId = ""; private String vduInstanceName = ""; private VduStatus status = VduStatus.NOTFOUND; - private Map<String,Object> outputs = new HashMap<String,Object>(); - private Map<String,Object> inputs = new HashMap<String,Object>(); + private Map<String,Object> outputs = new HashMap<>(); + private Map<String,Object> inputs = new HashMap<>(); private String lastAction; private String actionStatus; private String errorMessage; diff --git a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduPlugin.java b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduPlugin.java index 3452a10db9..2118eec0a5 100755 --- a/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduPlugin.java +++ b/adapters/mso-vnf-adapter/src/main/java/org/openecomp/mso/vdu/utils/VduPlugin.java @@ -88,7 +88,7 @@ public interface VduPlugin { String tenantId, String vduInstanceName, VduBlueprint vduBlueprint, - Map <String, ? extends Object> inputs, + Map <String, ?> inputs, String environmentFile, int timeoutMinutes, boolean suppressBackout) @@ -145,7 +145,7 @@ public interface VduPlugin { * @param tenantId The cloud tenant in which to delete the VDU. * @param vduInstanceId The unique id of the deployment to delete. * @param timeoutMinutes Timeout after which the delete action will be cancelled - * @param deleteBlueprint Flag to also delete the blueprint + * @param keepBlueprintLoaded Flag to also delete the blueprint * * @return A VduInfo object, representing the state of the instance just prior to deletion. * @@ -198,7 +198,7 @@ public interface VduPlugin { String tenantId, String vduInstanceId, VduBlueprint vduBlueprint, - Map <String, ? extends Object> inputs, + Map <String, ?> inputs, String environmentFile, int timeoutMinutes) throws MsoException; diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java index a045b00699..acde3153ab 100644 --- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java @@ -44,7 +44,7 @@ public class MsoVnfAdapterAsyncImplTest { try {
instance.createVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
- "volumeGroupHeatStackId|1", new HashMap<String, String>(), Boolean.FALSE, Boolean.TRUE, "messageId",
+ "volumeGroupHeatStackId|1", new HashMap<>(), Boolean.FALSE, Boolean.TRUE, "messageId",
null, "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest");
} catch (Exception e) {
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java index 6f01954db3..eec2257c7f 100644 --- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java @@ -48,8 +48,8 @@ public class MsoVnfAdapterImplTest { try {
instance.createVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
"volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map,
- Boolean.FALSE, Boolean.TRUE, msoRequest, new Holder<>(), new Holder<Map<String, String>>(),
- new Holder<VnfRollback>());
+ Boolean.FALSE, Boolean.TRUE, msoRequest, new Holder<>(), new Holder<>(),
+ new Holder<>());
} catch (Exception e) {
}
@@ -67,8 +67,8 @@ public class MsoVnfAdapterImplTest { try {
instance.updateVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
"volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
- "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<Map<String, String>>(),
- new Holder<VnfRollback>());
+ "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
+ new Holder<>());
} catch (Exception e) {
}
@@ -82,7 +82,7 @@ public class MsoVnfAdapterImplTest { msoRequest.setServiceInstanceId("12345");
try {
instance.deleteVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest,
- new Holder<Map<String, String>>());
+ new Holder<>());
} catch (Exception e) {
}
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java index f6e79e12a0..d898a6547e 100644 --- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/QueryTest.java @@ -55,10 +55,10 @@ public class QueryTest { String cloudId = "MT"; String tenantId = "MSO_Test"; String vnfName = "VNF_TEST1"; - Holder<Boolean> vnfExists = new Holder<Boolean>(); - Holder<String> vnfId = new Holder<String>(); - Holder<VnfStatus> status = new Holder<VnfStatus>(); - Holder<Map<String, String>> outputs = new Holder<Map<String, String>>(); + Holder<Boolean> vnfExists = new Holder<>(); + Holder<String> vnfId = new Holder<>(); + Holder<VnfStatus> status = new Holder<>(); + Holder<Map<String, String>> outputs = new Holder<>(); vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, vnfExists, vnfId, status, outputs); @@ -82,10 +82,10 @@ public class QueryTest { String cloudId = "MT"; String tenantId = "MSO_Test"; String vnfName = "VNF_TEST1"; - Holder<Boolean> vnfExists = new Holder<Boolean>(); - Holder<String> vnfId = new Holder<String>(); - Holder<VnfStatus> status = new Holder<VnfStatus>(); - Holder<Map<String, String>> outputs = new Holder<Map<String, String>>(); + Holder<Boolean> vnfExists = new Holder<>(); + Holder<String> vnfId = new Holder<>(); + Holder<VnfStatus> status = new Holder<>(); + Holder<Map<String, String>> outputs = new Holder<>(); vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, vnfExists, vnfId, status, outputs); @@ -101,10 +101,10 @@ public class QueryTest { String cloudId = "MT"; String tenantId = "MSO_Test"; String vnfName = "VNF_TEST1"; - Holder<Boolean> vnfExists = new Holder<Boolean>(); - Holder<String> vnfId = new Holder<String>(); - Holder<VnfStatus> status = new Holder<VnfStatus>(); - Holder<Map<String, String>> outputs = new Holder<Map<String, String>>(); + Holder<Boolean> vnfExists = new Holder<>(); + Holder<String> vnfId = new Holder<>(); + Holder<VnfStatus> status = new Holder<>(); + Holder<Map<String, String>> outputs = new Holder<>(); vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, vnfExists, vnfId, status, outputs); diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java index 52e1797531..000ed8aef3 100644 --- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfCreateTest.java @@ -42,16 +42,16 @@ public class VnfCreateTest { String tenantName = "John_Test"; String vnfType = "ApacheDemo"; String vnfName = "AdapterTest"; - Map<String,String> inputs = new HashMap<String,String>(); + Map<String,String> inputs = new HashMap<>(); inputs.put("vnf_id", "abc"); inputs.put("extra", "whocares"); inputs.put("private_subnet_gateway", "10.4.1.1"); inputs.put("private_subnet_cidr", "10.4.1.0/29"); // Web Service Outputs - Holder<String> vnfId = new Holder<String>(); - Holder<Map<String,String>> outputs = new Holder<Map<String,String>>(); - Holder<VnfRollback> vnfRollback = new Holder<VnfRollback>(); + Holder<String> vnfId = new Holder<>(); + Holder<Map<String,String>> outputs = new Holder<>(); + Holder<VnfRollback> vnfRollback = new Holder<>(); try { vnfAdapter.createVnf(cloudId, tenantName, vnfType,null, vnfName, null, null, inputs, false, true, null, diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java index 84f2f2ff57..bbffddfd15 100644 --- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/VnfQueryTest.java @@ -39,10 +39,10 @@ public class VnfQueryTest { String cloudId = "MT"; String tenantId = "MSO_Test"; String vnfName = "VNF_TEST1"; - Holder<Boolean> vnfExists = new Holder<Boolean>(); - Holder<String> vnfId = new Holder<String>(); - Holder<VnfStatus> status = new Holder<VnfStatus>(); - Holder<Map<String,String>> outputs = new Holder<Map<String,String>>(); + Holder<Boolean> vnfExists = new Holder<>(); + Holder<String> vnfId = new Holder<>(); + Holder<VnfStatus> status = new Holder<>(); + Holder<Map<String,String>> outputs = new Holder<>(); try { vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduBlueprintTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduBlueprintTest.java index 21a71ccf61..019ae1e3f9 100644 --- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduBlueprintTest.java +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduBlueprintTest.java @@ -60,7 +60,7 @@ public class VduBlueprintTest { @Test public void testGetTemplateFiles() { byte[] templateFileData = "some template file data".getBytes(); - templateFiles = new HashMap<String, byte[]>(); + templateFiles = new HashMap<>(); templateFiles.put("templateKey1", templateFileData); vduBlueprint.setTemplateFiles(templateFiles); Assert.assertNotNull(vduBlueprint.getTemplateFiles()); @@ -71,7 +71,7 @@ public class VduBlueprintTest { @Test public void testGetAttachedFiles() { byte[] attachedFileData = "some file data".getBytes(); - attachedFiles = new HashMap<String, byte[]>(); + attachedFiles = new HashMap<>(); attachedFiles.put("attachedKey1", attachedFileData); vduBlueprint.setAttachedFiles(attachedFiles); Assert.assertNotNull(vduBlueprint.getAttachedFiles()); diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduInfoTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduInfoTest.java new file mode 100644 index 0000000000..98a00033f7 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/vdu/utils/VduInfoTest.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 TechMahindra + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.vdu.utils; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class VduInfoTest { + + private VduInfo vduInfo; + private VduStatus status = VduStatus.NOTFOUND; + private Map<String, Object> outputs; + private Map<String, Object> inputs; + + @Before + public void setUp() { + vduInfo = new VduInfo(); + } + + @Test + public void testGetVnfInstanceId() { + String vnfInstanceId = "vnfInstanceId"; + vduInfo.setVnfInstanceId(vnfInstanceId); + Assert.assertNotNull(vduInfo.getVnfInstanceId()); + Assert.assertEquals(vduInfo.getVnfInstanceId(), "vnfInstanceId"); + } + + @Test + public void testGetVnfInstanceName() { + String vnfInstanceName = "vnfInstanceName"; + vduInfo.setVnfInstanceName(vnfInstanceName); + Assert.assertNotNull(vduInfo.getVnfInstanceName()); + Assert.assertEquals(vduInfo.getVnfInstanceName(), "vnfInstanceName"); + } + + @Test + public void testGetStatus() { + vduInfo.setStatus(status); + Assert.assertNotNull(vduInfo.getStatus()); + Assert.assertEquals(status, vduInfo.getStatus()); + } + + @Test + public void testGetOutputs() { + Object obj = new Object(); + String str = "some text"; + outputs = new HashMap<>(); + outputs.put(str, obj); + vduInfo.setOutputs(outputs); + Assert.assertNotNull(vduInfo.getOutputs()); + Assert.assertTrue(vduInfo.getOutputs().containsKey(str)); + Assert.assertTrue(vduInfo.getOutputs().containsValue(obj)); + } + + @Test + public void testGetInputs() { + Object obj = new Object(); + String str = "some text"; + inputs = new HashMap<>(); + inputs.put(str, obj); + vduInfo.setInputs(inputs); + Assert.assertNotNull(vduInfo.getInputs()); + Assert.assertTrue(vduInfo.getInputs().containsKey(str)); + Assert.assertTrue(vduInfo.getInputs().containsValue(obj)); + } + +} |