aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2017-08-10 06:52:09 +0000
committerGerrit Code Review <gerrit@onap.org>2017-08-10 06:52:09 +0000
commit59a326947cb83a4ac1b7bef7793982b5ed653654 (patch)
tree3b6563439f5cf2d42f732b5e8841be7e7f0ffd9e
parent7255957aa5015de4daae554730ed15158c28abe6 (diff)
parent49f38ff32c2323f5460e18ee300eff015bbd8772 (diff)
Merge "fixed for defect SO-70 - recipe lookup mechanism doesn't allow to define default recipe mapping for any 'source' at level of 'service' and 'network' resources."
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java65
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java13
-rw-r--r--packages/root-pack-extras/config-resources/mariadb/db-sql-scripts/bulkload-files/default/create_mso_db-default.sql3
3 files changed, 55 insertions, 26 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java
index 317859da0e..988d72cc6f 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java
@@ -654,33 +654,35 @@ public class ServiceInstances {
// SERVICE REQUEST
// Construct the default service name
// TODO need to make this a configurable property
- String defaultServiceName = msoRequest.getRequestInfo().getSource() + "_DEFAULT";
+ String sourceDefaultServiceName = msoRequest.getRequestInfo().getSource() + "_DEFAULT";
+ String defaultService = "*";
Service serviceRecord = null;
- if(msoRequest.getALaCarteFlag()){
- serviceRecord = db.getServiceByName(defaultServiceName);
- }else{
- serviceRecord = db.getServiceByVersionAndInvariantId(msoRequest.getModelInfo().getModelInvariantId(), msoRequest.getModelInfo().getModelVersion());
- }
int serviceId;
ServiceRecipe recipe = null;
- if(serviceRecord !=null){
- serviceId = serviceRecord.getId();
- recipe = db.getServiceRecipe(serviceId, action.name());
+
+ //if an aLaCarte flag was Not sent in the request, look first if there is a custom recipe for the specific model version
+ if(!msoRequest.getALaCarteFlag()){
+ serviceRecord = db.getServiceByVersionAndInvariantId(msoRequest.getModelInfo().getModelInvariantId(), msoRequest.getModelInfo().getModelVersion());
+ if(serviceRecord !=null){
+ serviceId = serviceRecord.getId();
+ recipe = db.getServiceRecipe(serviceId, action.name());
+ }
}
- //if an aLaCarte flag was sent in the request, throw an error if the recipe was not found
- RequestParameters reqParam = msoRequest.getServiceInstancesRequest().getRequestDetails().getRequestParameters();
- if(reqParam!=null && reqParam.isALaCarteSet() && recipe==null){
- return null;
- }else if (recipe == null) { //aLaCarte wasn't sent, so we'll try the default
- serviceRecord = db.getServiceByName(defaultServiceName);
- serviceId = serviceRecord.getId();
- recipe = db.getServiceRecipe(serviceId, action.name());
+
+ if (recipe == null) {
+ //find source(initiator) default recipe
+ recipe = db.getServiceRecipeByServiceNameAndAction(sourceDefaultServiceName, action.name());
+ }
+ if (recipe == null) {
+ //find default recipe
+ recipe = db.getServiceRecipeByServiceNameAndAction(defaultService, action.name());
}
if(recipe==null){
return null;
}
return new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ());
+
}
@@ -787,27 +789,38 @@ public class ServiceInstances {
private RecipeLookupResult getNetworkUri (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception {
- String defaultNetworkType = msoRequest.getRequestInfo().getSource() + "_DEFAULT";
+ String sourceDefaultNetworkType = msoRequest.getRequestInfo().getSource() + "_DEFAULT";
+ String defaultNetworkType = "*";
String modelName = msoRequest.getModelInfo().getModelName();
Recipe recipe = null;
- if(msoRequest.getALaCarteFlag()){
- recipe = db.getNetworkRecipe(defaultNetworkType, action.name());
- }else{
+ //if an aLaCarte flag was Not sent in the request, look first if there is a custom recipe for the specific ModelCustomizationId
+ if(!msoRequest.getALaCarteFlag()){
+ String networkType = null;
+
if(msoRequest.getModelInfo().getModelCustomizationId()!=null){
NetworkResource networkResource = db.getNetworkResourceByModelCustUuid(msoRequest.getModelInfo().getModelCustomizationId());
if(networkResource!=null){
- recipe = db.getNetworkRecipe(networkResource.getNetworkType(), action.name());
+ networkType = networkResource.getNetworkType();
}else{
throw new ValidationException("no catalog entry found");
}
}else{
//ok for version < 3
- recipe = db.getNetworkRecipe(modelName, action.name());
- }
- if(recipe == null){
- recipe = db.getNetworkRecipe(defaultNetworkType, action.name());
+ networkType = modelName;
}
+
+ //find latest version Recipe for the given networkType and action
+ recipe = db.getNetworkRecipe(networkType, action.name());
+ }
+
+ if(recipe == null){
+ //find source(initiator) default recipe
+ recipe = db.getNetworkRecipe(sourceDefaultNetworkType, action.name());
+ }
+ if(recipe == null){
+ //find default recipe
+ recipe = db.getNetworkRecipe(defaultNetworkType, action.name());
}
if (recipe == null) {
return null;
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java
index fcdaff7395..7ddaedcd30 100644
--- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java
@@ -514,6 +514,19 @@ public class CatalogDatabase implements Closeable {
return resultList.get (0);
}
+ /**
+ * @param serviceName
+ * @param action
+ * @return ServiceRecipe object or null if none found. returns a newest version of Service recipe that matches a given serviceName, action and for the newest service version
+ */
+ public ServiceRecipe getServiceRecipeByServiceNameAndAction(String serviceName, String action) {
+ Service service = getServiceByName(serviceName);
+ if (service != null ){
+ return getServiceRecipe(service.getId(),action);
+ }
+ return null;
+ }
+
public List<ServiceRecipe> getServiceRecipes (int serviceId) {
StringBuilder hql = null;
diff --git a/packages/root-pack-extras/config-resources/mariadb/db-sql-scripts/bulkload-files/default/create_mso_db-default.sql b/packages/root-pack-extras/config-resources/mariadb/db-sql-scripts/bulkload-files/default/create_mso_db-default.sql
index 2165041f5c..34deb08782 100644
--- a/packages/root-pack-extras/config-resources/mariadb/db-sql-scripts/bulkload-files/default/create_mso_db-default.sql
+++ b/packages/root-pack-extras/config-resources/mariadb/db-sql-scripts/bulkload-files/default/create_mso_db-default.sql
@@ -84,8 +84,11 @@ INSERT INTO `VNF_COMPONENTS_RECIPE`
UNLOCK TABLES;
INSERT INTO service (id, SERVICE_NAME, VERSION_STR, DESCRIPTION, SERVICE_NAME_VERSION_ID) VALUES ('4', 'VID_DEFAULT', '1.0', 'Default service for VID to use for infra APIH orchestration', 'MANUAL_RECORD');
+INSERT INTO service (id, SERVICE_NAME, VERSION_STR, DESCRIPTION, SERVICE_NAME_VERSION_ID) VALUES ('5', '*', '1.0', 'Default service to use for infra APIH orchestration', 'MANUAL_RECORD');
INSERT INTO service_recipe (SERVICE_ID, ACTION, VERSION_STR, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT) VALUES ('4', 'createInstance', '1', 'VID_DEFAULT recipe to create service-instance if no custom BPMN flow is found', '/mso/async/services/CreateGenericALaCarteServiceInstance', '180');
INSERT INTO service_recipe (SERVICE_ID, ACTION, VERSION_STR, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT) VALUES ('4', 'deleteInstance', '1', 'VID_DEFAULT recipe to delete service-instance if no custom BPMN flow is found', '/mso/async/services/DeleteGenericALaCarteServiceInstance', '180');
+INSERT INTO service_recipe (SERVICE_ID, ACTION, VERSION_STR, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT) VALUES ('5', 'createInstance', '1', 'DEFAULT recipe to create service-instance if no custom BPMN flow is found', '/mso/async/services/CreateGenericALaCarteServiceInstance', '180');
+INSERT INTO service_recipe (SERVICE_ID, ACTION, VERSION_STR, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT) VALUES ('5', 'deleteInstance', '1', 'DEFAULT recipe to delete service-instance if no custom BPMN flow is found', '/mso/async/services/DeleteGenericALaCarteServiceInstance', '180');
INSERT INTO vnf_recipe (VNF_TYPE, ACTION, VERSION_STR, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT) VALUES ('VID_DEFAULT', 'createInstance', '1', 'VID_DEFAULT recipe to create VNF if no custom BPMN flow is found', '/mso/async/services/CreateVnfInfra', '180');
INSERT INTO vnf_recipe (VNF_TYPE, ACTION, VERSION_STR, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT) VALUES ('VID_DEFAULT', 'deleteInstance', '1', 'VID_DEFAULT recipe to delete VNF if no custom BPMN flow is found', '/mso/async/services/DeleteVnfInfra', '180');
INSERT INTO vnf_components_recipe (VNF_TYPE, VNF_COMPONENT_TYPE, ACTION, VERSION, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT, VF_MODULE_ID) VALUES (NULL, 'volumeGroup', 'createInstance', '1', 'VID_DEFAULT recipe to create volume-group if no custom BPMN flow is found', '/mso/async/services/CreateVfModuleVolumeInfraV1', '180', 'VID_DEFAULT');