private static final String MODEL_TYPE = "modelType";
private static final String MODEL_VERSION_ID = "modelVersionId";
private static final String MODEL_CUSTOMIZATION_UUID = "modelCustomizationUuid";
- private static final String VF_MODULE_MODEL_UUID = "vfModuleModelUUId";
+ private static final String VF_MODULE_MODEL_UUID = "vfModuleModelUUId";
+ private static final String NETWORK_SERVICE = "network service";
protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
* @return VnfRecipe object or null if none found
*/
public VnfRecipe getVnfRecipeByNameVersion(String modelName, String modelVersion, String action) {
- StringBuilder hql = new StringBuilder("FROM VnfRecipe WHERE vnfType = :vnfType AND version= :version AND action = :action ");
long startTime = System.currentTimeMillis();
- LOGGER.debug("Catalog database - get VNF recipe with name " + modelName
- + " and action "
- + action);
+ LOGGER.debug("Catalog database - get VNF recipe with name " + modelName + " and action " + action);
- Query query = getSession().createQuery(hql.toString());
+ Query query = getSession().createQuery("FROM VnfRecipe WHERE vnfType = :vnfType AND version= :version AND action = :action ");
query.setParameter(VNF_TYPE, modelName);
query.setParameter(MODEL_VERSION, modelVersion);
query.setParameter(ACTION, action);
/**
* Return a Network recipe that matches a given MODEL_UUID and ACTION
*
- * @param modelName
+ * @param vnfModelUuid
* @param action
* @return NetworkRecipe object or null if none found
*/
return null;
}
- VnfRecipe recipe = this.getVnfRecipeByNameVersion(vnfResource.getModelName(), vnfResource.getModelVersion(), action);
+ VnfRecipe recipe = this.getVnfRecipeByNameVersion(vnfResource.getModelName(), vnfResource.getVersion(), action);
+
+ if (recipe == null && vnfResource.getSubCategory().equalsIgnoreCase(NETWORK_SERVICE)) {
+ recipe = getDefaultVnfRecipe(action);
+ }
return recipe;
}
+ private VnfRecipe getDefaultVnfRecipe(String action) {
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get default VNF recipe with action: " + action);
+
+ Query query = getSession().createQuery("FROM VnfRecipe WHERE vnfType = :vnfType AND action = :action ");
+ query.setParameter(VNF_TYPE, "NS_DEFAULT");
+ query.setParameter(ACTION, action);
+
+ @SuppressWarnings("unchecked")
+ List <VnfRecipe> resultList = query.list();
+
+ if (resultList.isEmpty()) {
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe not found", "CatalogDB", "getVnfRecipe", null);
+ return null;
+ }
+
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfRecipe", null);
+ return resultList.get(0);
+ }
+
/**
* Return a VNF recipe that matches a given VF_MODULE_ID and ACTION
*
}
}
- @Deprecated
- public void saveNestedHeatTemplate (int parentTemplateId, HeatTemplate childTemplate, String yamlFile) {
- /*
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - save nested Heat template with name "
- + childTemplate.getTemplateName ());
- try {
-
- saveHeatTemplate(childTemplate, childTemplate.getParameters());
- if (getNestedHeatTemplate(parentTemplateId,childTemplate.getId()) == null) {
- HeatNestedTemplate nestedTemplate = new HeatNestedTemplate ();
- nestedTemplate.setParentTemplateId (parentTemplateId);
- nestedTemplate.setChildTemplateId (childTemplate.getId ());
- nestedTemplate.setProviderResourceFile (yamlFile);
- session.save (nestedTemplate);
- }
- } finally {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveNestedHeatTemplate", null);
- }
- */
- }
-
// 1707
public void saveNestedHeatTemplate (String parentTemplateId, HeatTemplate childTemplate, String yamlFile) {
long startTime = System.currentTimeMillis ();
}
}
- @Deprecated
- public void saveVfModuleToHeatFiles (int parentVfModuleId, HeatFiles childFile) {
- /*
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - save Heat File to VFmodule link "
- + childFile.getFileName());
- try {
- saveHeatFiles (childFile);
- VfModuleToHeatFiles vfModuleToHeatFile = new VfModuleToHeatFiles ();
- vfModuleToHeatFile.setVfModuleId(parentVfModuleId);
- vfModuleToHeatFile.setHeatFilesId(childFile.getId());
-
- session.save (vfModuleToHeatFile);
-
- } finally {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "saveVfModuleToHeatFiles", null);
- }
- */
- }
-
public void saveVfModuleToHeatFiles (String parentVfModuleId, HeatFiles childFile) {
long startTime = System.currentTimeMillis ();
LOGGER.debug ("Catalog database - save Heat File to VFmodule link "
/**
* Return a Network recipe that matches a given MODEL_UUID and ACTION
*
- * @param modelName
+ * @param networkModelUuid
* @param action
* @return NetworkRecipe object or null if none found
*/
}
NetworkRecipe recipe = getNetworkRecipeByNameVersion(networkResource.getModelName(), networkResource.getModelVersion(), action);
- return recipe;
+
+ if (recipe == null) {
+ recipe = getDefaultNetworkReceipe(action);
+ }
+
+ return recipe;
+ }
+
+ private NetworkRecipe getDefaultNetworkReceipe(String action) {
+ String modelName = "SDNC_DEFAULT";
+ return getNetworkRecipe(modelName, action);
}
/**