From 543287367358a1ab6a5730e07f6e647275a8bdc4 Mon Sep 17 00:00:00 2001 From: Prema Bhatt Date: Wed, 7 Nov 2018 13:36:37 -0800 Subject: Removed retry from RainyDay tbl for healthCheckBB Updated rainy_day_handler_macro to remove retry for GenericVnfhealthCheckBB and ConfigurationScaleOutBB. Updated file name to be consistent. Issue-ID: SO-1185 Change-Id: If49e5ec8e5d98c1dfad1fdc678a4a7fc45b2566e Signed-off-by: Prema Bhatt --- .../V4.14__RemoveRetryFromRainyDayHandlingTable.sql | 18 ++++++++++++++++++ ...14___remove_retry_from_rainy_day_handling_table.sql | 18 ------------------ .../V4.15__UpdateRainyDayHandlerMacroForScaleOut.sql | 4 ++++ 3 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.14__RemoveRetryFromRainyDayHandlingTable.sql delete mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.14___remove_retry_from_rainy_day_handling_table.sql create mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.15__UpdateRainyDayHandlerMacroForScaleOut.sql (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.14__RemoveRetryFromRainyDayHandlingTable.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.14__RemoveRetryFromRainyDayHandlingTable.sql new file mode 100644 index 0000000000..e4b599a044 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.14__RemoveRetryFromRainyDayHandlingTable.sql @@ -0,0 +1,18 @@ +use catalogdb; + +UPDATE rainy_day_handler_macro SET POLICY = 'Rollback' WHERE FLOW_NAME = 'CreateNetworkBB'; +UPDATE rainy_day_handler_macro SET POLICY = 'Rollback' WHERE FLOW_NAME = 'CreateNetworkCollectionBB'; +UPDATE rainy_day_handler_macro SET POLICY = 'Rollback' WHERE FLOW_NAME = 'CreateVfModuleBB'; +UPDATE rainy_day_handler_macro SET POLICY = 'Rollback' WHERE FLOW_NAME = 'CreateVolumeGroupBB'; +UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'DeleteNetworkBB'; +UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'DeleteNetworkCollectionBB'; +UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'DeleteVfModuleBB'; +UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'DeleteVolumeGroupBB'; +UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'UnassignNetwork1802BB'; +UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'UnassignNetworkBB'; +UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'UnassignServiceInstanceBB'; +UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'UnassignVfModuleBB'; +UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'UnassignVnfBB'; +UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'UnassignVolumeGroupBB'; +UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'UpdateNetworkBB'; +UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'VnfAdapterBB'; \ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.14___remove_retry_from_rainy_day_handling_table.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.14___remove_retry_from_rainy_day_handling_table.sql deleted file mode 100644 index e4b599a044..0000000000 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.14___remove_retry_from_rainy_day_handling_table.sql +++ /dev/null @@ -1,18 +0,0 @@ -use catalogdb; - -UPDATE rainy_day_handler_macro SET POLICY = 'Rollback' WHERE FLOW_NAME = 'CreateNetworkBB'; -UPDATE rainy_day_handler_macro SET POLICY = 'Rollback' WHERE FLOW_NAME = 'CreateNetworkCollectionBB'; -UPDATE rainy_day_handler_macro SET POLICY = 'Rollback' WHERE FLOW_NAME = 'CreateVfModuleBB'; -UPDATE rainy_day_handler_macro SET POLICY = 'Rollback' WHERE FLOW_NAME = 'CreateVolumeGroupBB'; -UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'DeleteNetworkBB'; -UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'DeleteNetworkCollectionBB'; -UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'DeleteVfModuleBB'; -UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'DeleteVolumeGroupBB'; -UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'UnassignNetwork1802BB'; -UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'UnassignNetworkBB'; -UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'UnassignServiceInstanceBB'; -UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'UnassignVfModuleBB'; -UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'UnassignVnfBB'; -UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'UnassignVolumeGroupBB'; -UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'UpdateNetworkBB'; -UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'VnfAdapterBB'; \ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.15__UpdateRainyDayHandlerMacroForScaleOut.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.15__UpdateRainyDayHandlerMacroForScaleOut.sql new file mode 100644 index 0000000000..75a8c20352 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.15__UpdateRainyDayHandlerMacroForScaleOut.sql @@ -0,0 +1,4 @@ +use catalogdb; + +UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'GenericVnfHealthCheckBB'; +UPDATE rainy_day_handler_macro SET POLICY = 'Abort' WHERE FLOW_NAME = 'ConfigurationScaleOutBB'; \ No newline at end of file -- cgit 1.2.3-korg From 4a4720372672e66775a3102a306721770a0345a4 Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Mon, 12 Nov 2018 17:35:37 +0530 Subject: Fix the retrival of resource recipe Fix the retrival of resource recipe. Change-Id: Iaec1046f487ce61b995d61414dbe4229e8a51115 Issue-ID: SO-1197 Signed-off-by: subhash kumar singh (cherry picked from commit 1c831520f085527c9525d8a757e9c0ccddae0219) --- .../catalogdb/rest/CatalogDbAdapterRest.java | 25 +++++++++++++++++++--- .../onap/so/db/catalog/beans/NetworkRecipe.java | 11 ++++++++++ .../org/onap/so/db/catalog/beans/VnfRecipe.java | 11 ++++++++++ .../data/repository/ArRecipeRepository.java | 1 + .../data/repository/NetworkRecipeRepository.java | 1 + .../data/repository/VnfRecipeRepository.java | 6 ++++-- 6 files changed, 50 insertions(+), 5 deletions(-) (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java index eaf3e125a1..36e00ad599 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java @@ -73,6 +73,7 @@ import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.ToscaCsar; import org.onap.so.db.catalog.beans.VfModule; import org.onap.so.db.catalog.beans.VfModuleCustomization; +import org.onap.so.db.catalog.beans.VnfRecipe; import org.onap.so.db.catalog.beans.VnfResource; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository; @@ -116,6 +117,7 @@ import java.util.List; public class CatalogDbAdapterRest { protected static Logger logger = LoggerFactory.getLogger(CatalogDbAdapterRest.class); private static final boolean IS_ARRAY = true; + private static final String NETWORK_SERVICE = "network service"; @Autowired private VnfCustomizationRepository vnfCustomizationRepo; @@ -563,15 +565,32 @@ public class CatalogDbAdapterRest { if (rmUuid != null && !"".equals(rmUuid)) { logger.debug("Query recipe by resource model uuid: {}", rmUuid); //check vnf and network and ar, the resource could be any resource. + Recipe recipe = null; + VnfResource vnf = vnfResourceRepo.findResourceByModelUUID(rmUuid); - Recipe recipe = vnfRecipeRepo.findFirstVnfRecipeByNfRoleAndAction(vnf.getModelName(), action); + if (vnf != null) { + recipe = vnfRecipeRepo.findFirstVnfRecipeByNfRoleAndActionAndVersionStr(vnf.getModelName(), action, vnf.getModelVersion()); + + // for network service fetch the default recipe + if (recipe == null && vnf.getSubCategory().equalsIgnoreCase(NETWORK_SERVICE)) { + recipe = vnfRecipeRepo.findFirstVnfRecipeByNfRoleAndAction("NS_DEFAULT", action); + } + } + + if (null == recipe) { NetworkResource nResource = networkResourceRepo.findResourceByModelUUID(rmUuid); - recipe = networkRecipeRepo.findFirstByModelNameAndAction(nResource.getModelName(), action); + recipe = networkRecipeRepo.findFirstByModelNameAndActionAndVersionStr(nResource.getModelName(), action, vnf.getModelVersion()); + + // for network fetch the default recipe + if (recipe == null) { + recipe = networkRecipeRepo.findFirstByModelNameAndAction("SDNC_DEFAULT", action); + } } + if (null == recipe) { AllottedResource arResource = arResourceRepo.findResourceByModelUUID(rmUuid); - recipe = arRecipeRepo.findByModelNameAndAction(arResource.getModelName(), action); + recipe = arRecipeRepo.findByModelNameAndActionAndVersion(arResource.getModelName(), action, arResource.getModelVersion()); } if (recipe != null) { QueryResourceRecipe resourceRecipe = new QueryResourceRecipe(recipe); diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkRecipe.java index 73056e2f8c..51bcd54ae1 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkRecipe.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkRecipe.java @@ -59,6 +59,9 @@ public class NetworkRecipe implements Serializable, Recipe { @Column(name = "RECIPE_TIMEOUT") private Integer recipeTimeout; + @Column(name = "VERSION_STR") + private String versionStr; + @BusinessKey @Column(name = "SERVICE_TYPE") private String serviceType; @@ -171,4 +174,12 @@ public class NetworkRecipe implements Serializable, Recipe { sb.append(",networkParamXSD=" + paramXsd); return sb.toString(); } + + public String getVersionStr() { + return versionStr; + } + + public void setVersionStr(String versionStr) { + this.versionStr = versionStr; + } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfRecipe.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfRecipe.java index aef2ac5e74..ab2eb622c1 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfRecipe.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfRecipe.java @@ -71,6 +71,9 @@ public class VnfRecipe implements Serializable, Recipe { @Column(name = "RECIPE_TIMEOUT") private Integer recipeTimeout; + @Column(name = "VERSION_STR") + private String versionStr; + @BusinessKey @Column(name = "SERVICE_TYPE") private String serviceType; @@ -184,4 +187,12 @@ public class VnfRecipe implements Serializable, Recipe { public Date getCreated() { return created; } + + public String getVersionStr() { + return versionStr; + } + + public void setVersionStr(String versionStr) { + this.versionStr = versionStr; + } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ArRecipeRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ArRecipeRepository.java index 1241dac4ee..22f3ccbead 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ArRecipeRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ArRecipeRepository.java @@ -28,4 +28,5 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; public interface ArRecipeRepository extends JpaRepository { ArRecipe findByModelNameAndAction(String modelName, String action); + ArRecipe findByModelNameAndActionAndVersion(String modelName, String action, String version); } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkRecipeRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkRecipeRepository.java index 10290b5877..c74fade8e3 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkRecipeRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkRecipeRepository.java @@ -27,4 +27,5 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(collectionResourceRel = "networkRecipe", path = "networkRecipe") public interface NetworkRecipeRepository extends JpaRepository { NetworkRecipe findFirstByModelNameAndAction(String modelName, String action); + NetworkRecipe findFirstByModelNameAndActionAndVersionStr(String modelName, String action, String versionStr); } \ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfRecipeRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfRecipeRepository.java index dbc86cbb8f..b99e2bd4b6 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfRecipeRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/VnfRecipeRepository.java @@ -7,9 +7,9 @@ * 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. @@ -29,4 +29,6 @@ public interface VnfRecipeRepository extends JpaRepository { VnfRecipe findVnfRecipeByServiceTypeAndAction(String serviceType, String action); VnfRecipe findFirstVnfRecipeByNfRoleAndAction(String nfRole, String action); + + VnfRecipe findFirstVnfRecipeByNfRoleAndActionAndVersionStr(String nfRole, String action, String versionStr); } \ No newline at end of file -- cgit 1.2.3-korg From f74abd14890219b61d9e1ab0b07c263a931cb6be Mon Sep 17 00:00:00 2001 From: "Smokowski, Steve (ss835w)" Date: Wed, 14 Nov 2018 10:36:52 -0500 Subject: Add Ref Data Add Missing reference data for Test cases Issue-ID: SO-1184 Change-Id: Ibf3ed0b802885f64b7d4850b5209932fcf35524a Signed-off-by: Smokowski, Steve (ss835w) --- .../db/migration/V4.13__Add_Default_NeutronNetwork.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.13__Add_Default_NeutronNetwork.sql (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.13__Add_Default_NeutronNetwork.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.13__Add_Default_NeutronNetwork.sql new file mode 100644 index 0000000000..dd821cab78 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.13__Add_Default_NeutronNetwork.sql @@ -0,0 +1,10 @@ +USE catalogdb; + +INSERT INTO `heat_template` (`ARTIFACT_UUID`,`NAME`,`VERSION`,`BODY`,`TIMEOUT_MINUTES`,`DESCRIPTION`,`CREATION_TIMESTAMP`,`ARTIFACT_CHECKSUM`) VALUES +('efee1d84-b8ec-11e7-abc4-cec278b6b50a','Generic NeutronNet','1','heat_template_version: 2013-05-23\n\ndescription:\n HOT template that creates a Generic Neutron Network\n\nparameters:\n network_name:\n type: string\n description: Name of direct network (e.g. core, dmz)\n default: ECOMPNetwork\n network_subnet_name:\n type: string\n description: Name of subnet network (e.g. core, dmz)\n default: ECOMPNetwork\n network_subnet_cidr:\n type: string\n description: CIDR of subnet network (e.g. core, dmz)\n default: 10.0.0.0/16\n\noutputs:\n network_id:\n description: Openstack network identifier\n value: { get_resource: network }\n network_fqdn:\n description: Openstack network identifier\n value: {list_join: [\':\', { get_attr: [network, fq_name] } ] }\n\nresources:\n network:\n type: OS::Neutron::Net\n properties:\n name: {get_param: network_name }\n\n subnet:\n type: OS::Neutron::Subnet\n properties:\n name: { get_param: network_subnet_name }\n network_id: { get_resource: network }\n cidr: { get_param: network_subnet_cidr }\n enable_dhcp: false\n',10,'Generic Neutron Template','2017-10-26 14:44:00', 'MANUAL RECORD'); + + + +INSERT INTO `temp_network_heat_template_lookup` (`NETWORK_RESOURCE_MODEL_NAME`, `HEAT_TEMPLATE_ARTIFACT_UUID`,`AIC_VERSION_MIN` , `AIC_VERSION_MAX` ) +VALUES ('Generic NeutronNet','efee1d84-b8ec-11e7-abc4-cec278b6b50a','2.0','NULL'); + -- cgit 1.2.3-korg From 827edc452055afa431080d04c5668db5e16964fd Mon Sep 17 00:00:00 2001 From: "Smokowski, Steve (ss835w)" Date: Wed, 14 Nov 2018 15:29:20 -0500 Subject: Update Schema Issue-ID: SO-1211 Change-Id: I7a7c6788010c3c3bbaba0d72ec656cebc124d6e6 Signed-off-by: Smokowski, Steve (ss835w) --- .../db/migration/V4.13__Add_Default_NeutronNetwork.sql | 10 ---------- .../db/migration/V4.16__Add_Default_NeutronNetwork.sql | 10 ++++++++++ .../resources/db/migration/V4.17__UpdateCloudSiteColumn.sql | 5 +++++ .../main/resources/db/migration/V4.3__Expand_Column_Size.sql | 4 ++-- 4 files changed, 17 insertions(+), 12 deletions(-) delete mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.13__Add_Default_NeutronNetwork.sql create mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.16__Add_Default_NeutronNetwork.sql create mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.17__UpdateCloudSiteColumn.sql (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.13__Add_Default_NeutronNetwork.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.13__Add_Default_NeutronNetwork.sql deleted file mode 100644 index dd821cab78..0000000000 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.13__Add_Default_NeutronNetwork.sql +++ /dev/null @@ -1,10 +0,0 @@ -USE catalogdb; - -INSERT INTO `heat_template` (`ARTIFACT_UUID`,`NAME`,`VERSION`,`BODY`,`TIMEOUT_MINUTES`,`DESCRIPTION`,`CREATION_TIMESTAMP`,`ARTIFACT_CHECKSUM`) VALUES -('efee1d84-b8ec-11e7-abc4-cec278b6b50a','Generic NeutronNet','1','heat_template_version: 2013-05-23\n\ndescription:\n HOT template that creates a Generic Neutron Network\n\nparameters:\n network_name:\n type: string\n description: Name of direct network (e.g. core, dmz)\n default: ECOMPNetwork\n network_subnet_name:\n type: string\n description: Name of subnet network (e.g. core, dmz)\n default: ECOMPNetwork\n network_subnet_cidr:\n type: string\n description: CIDR of subnet network (e.g. core, dmz)\n default: 10.0.0.0/16\n\noutputs:\n network_id:\n description: Openstack network identifier\n value: { get_resource: network }\n network_fqdn:\n description: Openstack network identifier\n value: {list_join: [\':\', { get_attr: [network, fq_name] } ] }\n\nresources:\n network:\n type: OS::Neutron::Net\n properties:\n name: {get_param: network_name }\n\n subnet:\n type: OS::Neutron::Subnet\n properties:\n name: { get_param: network_subnet_name }\n network_id: { get_resource: network }\n cidr: { get_param: network_subnet_cidr }\n enable_dhcp: false\n',10,'Generic Neutron Template','2017-10-26 14:44:00', 'MANUAL RECORD'); - - - -INSERT INTO `temp_network_heat_template_lookup` (`NETWORK_RESOURCE_MODEL_NAME`, `HEAT_TEMPLATE_ARTIFACT_UUID`,`AIC_VERSION_MIN` , `AIC_VERSION_MAX` ) -VALUES ('Generic NeutronNet','efee1d84-b8ec-11e7-abc4-cec278b6b50a','2.0','NULL'); - diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.16__Add_Default_NeutronNetwork.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.16__Add_Default_NeutronNetwork.sql new file mode 100644 index 0000000000..dd821cab78 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.16__Add_Default_NeutronNetwork.sql @@ -0,0 +1,10 @@ +USE catalogdb; + +INSERT INTO `heat_template` (`ARTIFACT_UUID`,`NAME`,`VERSION`,`BODY`,`TIMEOUT_MINUTES`,`DESCRIPTION`,`CREATION_TIMESTAMP`,`ARTIFACT_CHECKSUM`) VALUES +('efee1d84-b8ec-11e7-abc4-cec278b6b50a','Generic NeutronNet','1','heat_template_version: 2013-05-23\n\ndescription:\n HOT template that creates a Generic Neutron Network\n\nparameters:\n network_name:\n type: string\n description: Name of direct network (e.g. core, dmz)\n default: ECOMPNetwork\n network_subnet_name:\n type: string\n description: Name of subnet network (e.g. core, dmz)\n default: ECOMPNetwork\n network_subnet_cidr:\n type: string\n description: CIDR of subnet network (e.g. core, dmz)\n default: 10.0.0.0/16\n\noutputs:\n network_id:\n description: Openstack network identifier\n value: { get_resource: network }\n network_fqdn:\n description: Openstack network identifier\n value: {list_join: [\':\', { get_attr: [network, fq_name] } ] }\n\nresources:\n network:\n type: OS::Neutron::Net\n properties:\n name: {get_param: network_name }\n\n subnet:\n type: OS::Neutron::Subnet\n properties:\n name: { get_param: network_subnet_name }\n network_id: { get_resource: network }\n cidr: { get_param: network_subnet_cidr }\n enable_dhcp: false\n',10,'Generic Neutron Template','2017-10-26 14:44:00', 'MANUAL RECORD'); + + + +INSERT INTO `temp_network_heat_template_lookup` (`NETWORK_RESOURCE_MODEL_NAME`, `HEAT_TEMPLATE_ARTIFACT_UUID`,`AIC_VERSION_MIN` , `AIC_VERSION_MAX` ) +VALUES ('Generic NeutronNet','efee1d84-b8ec-11e7-abc4-cec278b6b50a','2.0','NULL'); + diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.17__UpdateCloudSiteColumn.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.17__UpdateCloudSiteColumn.sql new file mode 100644 index 0000000000..7077032fca --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.17__UpdateCloudSiteColumn.sql @@ -0,0 +1,5 @@ +use catalogdb; + +ALTER TABLE cloud_sites + MODIFY IF EXISTS REGION_ID varchar(50) NULL, + MODIFY IF EXISTS CLLI varchar(50) NULL; \ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V4.3__Expand_Column_Size.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V4.3__Expand_Column_Size.sql index 96fe5a44e1..87401ade13 100644 --- a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V4.3__Expand_Column_Size.sql +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V4.3__Expand_Column_Size.sql @@ -2,10 +2,10 @@ use requestdb; ALTER TABLE infra_active_requests MODIFY IF EXISTS AIC_CLOUD_REGION varchar(50) NULL, - MODIFY IF EXISTS AIC_NODE_CLLI varchar(45) NULL; + MODIFY IF EXISTS AIC_NODE_CLLI varchar(50) NULL; ALTER TABLE archived_infra_requests MODIFY IF EXISTS AIC_CLOUD_REGION varchar(50) NULL, - MODIFY IF EXISTS AIC_NODE_CLLI varchar(45) NULL; + MODIFY IF EXISTS AIC_NODE_CLLI varchar(50) NULL; -- cgit 1.2.3-korg From d45c2eed969fb9273e67dd6a3a58b83499b05bf8 Mon Sep 17 00:00:00 2001 From: Rob Daugherty Date: Wed, 14 Nov 2018 15:02:31 -0500 Subject: vCPE BRG allottedResourceRole is null In Beijing we used: o.getNfRole() In Casablanca, it was: o.getTargetNetworkRole() I'm changing it to: o.getTargetNetworkRole() != null ? o.getTargetNetworkRole() : o.getNfRole() Change-Id: I874b2f01fd651bb38a361fa9c36f9937b1f02b2f Issue-ID: SO-1200 Signed-off-by: Rob Daugherty --- .../catalogdb/catalogrest/QueryAllottedResourceCustomization.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java index 3dca6a395c..7a215a9458 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java @@ -117,7 +117,7 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { put(valueMap, "MODEL_INSTANCE_NAME", o.getModelInstanceName()); put(valueMap, "TOSCA_NODE_TYPE", arNull ? null : o.getAllottedResource().getToscaNodeType()); put(valueMap, "ALLOTTED_RESOURCE_TYPE", arNull ? null : o.getAllottedResource().getSubcategory()); - put(valueMap, "ALLOTTED_RESOURCE_ROLE", o.getTargetNetworkRole()); + put(valueMap, "ALLOTTED_RESOURCE_ROLE", o.getTargetNetworkRole() != null ? o.getTargetNetworkRole() : o.getNfRole()); put(valueMap, "NF_TYPE", o.getNfType()); put(valueMap, "NF_ROLE", o.getNfRole()); put(valueMap, "NF_FUNCTION", o.getNfFunction()); -- cgit 1.2.3-korg From 70c584bb6b6bb1bb1406c327bb8910e867bc0cab Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Thu, 15 Nov 2018 17:35:55 +0530 Subject: Fix auth for catalog db Fix auth for catalog db. Change-Id: Ic787993f608b7ddf74167f7859a519ca02b794ed Issue-ID: SO-689 Signed-off-by: subhash kumar singh --- .../so/adapters/catalogdb/rest/CatalogDbAdapterRest.java | 16 ++++++++++++---- .../infrastructure/scripts/CreateVFCNSResource.groovy | 2 +- .../scripts/DoCreateVFCNetworkServiceInstance.groovy | 2 +- .../scripts/DoDeleteVFCNetworkServiceInstance.groovy | 4 ++-- .../resources/subprocess/DoDeleteE2EServiceInstance.bpmn | 2 +- common/src/main/java/org/onap/so/client/HttpClient.java | 3 ++- 6 files changed, 19 insertions(+), 10 deletions(-) (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java index 36e00ad599..8a7b7a2e9d 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java @@ -520,13 +520,21 @@ public class CatalogDbAdapterRest { try { if (smUuid != null && !"".equals(smUuid)) { logger.debug("Query Csar by service model uuid: {}",smUuid); - ToscaCsar toscaCsar = toscaCsarRepo.findOne(smUuid); - if (toscaCsar != null) { - QueryServiceCsar serviceCsar = new QueryServiceCsar(toscaCsar); - entity = serviceCsar.JSON2(false, false); + + Service service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(smUuid); + + if (service != null) { + ToscaCsar toscaCsar = service.getCsar(); + if (toscaCsar != null) { + QueryServiceCsar serviceCsar = new QueryServiceCsar(toscaCsar); + entity = serviceCsar.JSON2(false, false); + } else { + respStatus = HttpStatus.SC_NOT_FOUND; + } } else { respStatus = HttpStatus.SC_NOT_FOUND; } + } else { throw (new Exception("Incoming parameter is null or blank")); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy index e3702f1014..dabd3517c3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy @@ -259,7 +259,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER) httpClient.addAdditionalHeader("Accept", "application/json") - httpClient.addAdditionalHeader("Authorization", "Basic QlBFTENsaWVudDpwYXNzd29yZDEk") + httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk") apiResponse = httpClient.post(requestBody) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy index a3c30dcb50..09f159ecd7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy @@ -236,7 +236,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER) httpClient.addAdditionalHeader("Accept", "application/json") - httpClient.addAdditionalHeader("Authorization", "Basic QlBFTENsaWVudDpwYXNzd29yZDEk") + httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk") apiResponse = httpClient.post(requestBody) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy index d855479694..bae1349e3b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy @@ -208,7 +208,7 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER) httpClient.addAdditionalHeader("Accept", "application/json") - httpClient.addAdditionalHeader("Authorization", "Basic QlBFTENsaWVudDpwYXNzd29yZDEk") + httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk") apiResponse = httpClient.post(requestBody) @@ -236,7 +236,7 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces URL Url = new URL(url) HttpClient httpClient = new HttpClient(Url, "application/json", TargetEntity.VNF_ADAPTER) httpClient.addAdditionalHeader("Accept", "application/json") - httpClient.addAdditionalHeader("Authorization", "Basic QlBFTENsaWVudDpwYXNzd29yZDEk") + httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk") r = httpClient.delete(requestBody) msoLogger.trace("Completed Execute VF-C adapter Delete Process ") diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteE2EServiceInstance.bpmn index fd3804c066..8f04b203cb 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteE2EServiceInstance.bpmn @@ -189,7 +189,7 @@ dcsi.postDecomposeService(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateServiceOperStatusRequest} diff --git a/common/src/main/java/org/onap/so/client/HttpClient.java b/common/src/main/java/org/onap/so/client/HttpClient.java index ad13745919..9c4b5731fb 100644 --- a/common/src/main/java/org/onap/so/client/HttpClient.java +++ b/common/src/main/java/org/onap/so/client/HttpClient.java @@ -42,7 +42,8 @@ public class HttpClient extends RestClient { @Override protected void initializeHeaderMap(Map headerMap) { - + headerMap.put("Authorization", "Basic YnBlbDpwYXNzd29yZDEk"); + headerMap.put("content-type", "application/json"); } @Override -- cgit 1.2.3-korg From 383f5f079fd59bfa9399563a83ef8a67981125f3 Mon Sep 17 00:00:00 2001 From: "Brittany Plummer (bp896r)" Date: Fri, 16 Nov 2018 08:15:26 -0500 Subject: Added script with table data Issue-ID: SO-1224 Change-Id: I38dfb86ae866aa510e16b95f2c86619bc663fe2f Signed-off-by: Brittany Plummer (bp896r) --- .../db/migration/V4.18__ControllerSelectionReferenceData.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.18__ControllerSelectionReferenceData.sql (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.18__ControllerSelectionReferenceData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.18__ControllerSelectionReferenceData.sql new file mode 100644 index 0000000000..00f4777c03 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.18__ControllerSelectionReferenceData.sql @@ -0,0 +1,4 @@ +use catalogdb; + +INSERT INTO controller_selection_reference (VNF_TYPE, CONTROLLER_NAME, ACTION_CATEGORY) VALUES ('vLoadBalancerMS/vLoadBalancerMS 0', 'APPC', 'HealthCheck'); +INSERT INTO controller_selection_reference (VNF_TYPE, CONTROLLER_NAME, ACTION_CATEGORY) VALUES ('vLoadBalancerMS/vLoadBalancerMS 0', 'APPC', 'ConfigScaleOut'); \ No newline at end of file -- cgit 1.2.3-korg From 7f4adc268168464dcbc51f8730d570198979b16e Mon Sep 17 00:00:00 2001 From: "Smokowski, Steve (ss835w)" Date: Wed, 21 Nov 2018 09:09:09 -0500 Subject: Fix Default Record Issue-ID: SO-1184 Change-Id: I2708484dce63be8bb043231444aec6eb6438fdae Signed-off-by: Smokowski, Steve (ss835w) --- .../V4.16__Add_Default_NeutronNetwork.sql | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.16__Add_Default_NeutronNetwork.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.16__Add_Default_NeutronNetwork.sql index dd821cab78..b937400f56 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.16__Add_Default_NeutronNetwork.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.16__Add_Default_NeutronNetwork.sql @@ -1,7 +1,28 @@ USE catalogdb; INSERT INTO `heat_template` (`ARTIFACT_UUID`,`NAME`,`VERSION`,`BODY`,`TIMEOUT_MINUTES`,`DESCRIPTION`,`CREATION_TIMESTAMP`,`ARTIFACT_CHECKSUM`) VALUES -('efee1d84-b8ec-11e7-abc4-cec278b6b50a','Generic NeutronNet','1','heat_template_version: 2013-05-23\n\ndescription:\n HOT template that creates a Generic Neutron Network\n\nparameters:\n network_name:\n type: string\n description: Name of direct network (e.g. core, dmz)\n default: ECOMPNetwork\n network_subnet_name:\n type: string\n description: Name of subnet network (e.g. core, dmz)\n default: ECOMPNetwork\n network_subnet_cidr:\n type: string\n description: CIDR of subnet network (e.g. core, dmz)\n default: 10.0.0.0/16\n\noutputs:\n network_id:\n description: Openstack network identifier\n value: { get_resource: network }\n network_fqdn:\n description: Openstack network identifier\n value: {list_join: [\':\', { get_attr: [network, fq_name] } ] }\n\nresources:\n network:\n type: OS::Neutron::Net\n properties:\n name: {get_param: network_name }\n\n subnet:\n type: OS::Neutron::Subnet\n properties:\n name: { get_param: network_subnet_name }\n network_id: { get_resource: network }\n cidr: { get_param: network_subnet_cidr }\n enable_dhcp: false\n',10,'Generic Neutron Template','2017-10-26 14:44:00', 'MANUAL RECORD'); +('efee1d84-b8ec-11e7-abc4-cec278b6b50a','Generic NeutronNet','1',' +heat_template_version: 2013-05-23 +description: A simple Neutron network +parameters: + network_name: + type: string + description: Name of the Neutron Network + default: ONAP-NW1 + shared: + type: boolean + description: Shared amongst tenants + default: False +outputs: + network_id: + description: Openstack network identifier + value: { get_resource: network } +resources: + network: + type: OS::Neutron::Net + properties: + name: { get_param: network_name } + shared: { get_param: shared }',10,'Generic Neutron Template','2017-10-26 14:44:00', 'MANUAL RECORD'); -- cgit 1.2.3-korg From 03fafee16950784d30f1cc2e9c4afd7e971973f4 Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Sat, 24 Nov 2018 19:05:40 +0530 Subject: Fix version string in query Fix version string in query. Change-Id: Idf990d7f58cc93302670fb270735d71f0a834912 Issue-ID: SO-689 Signed-off-by: subhash kumar singh --- .../java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java index 8a7b7a2e9d..9bcbe16af2 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java @@ -588,7 +588,7 @@ public class CatalogDbAdapterRest { if (null == recipe) { NetworkResource nResource = networkResourceRepo.findResourceByModelUUID(rmUuid); - recipe = networkRecipeRepo.findFirstByModelNameAndActionAndVersionStr(nResource.getModelName(), action, vnf.getModelVersion()); + recipe = networkRecipeRepo.findFirstByModelNameAndActionAndVersionStr(nResource.getModelName(), action, nResource.getModelVersion()); // for network fetch the default recipe if (recipe == null) { -- cgit 1.2.3-korg From aaddce96286465f72b659acd4d0a83101089e61d Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Mon, 26 Nov 2018 09:20:28 -0500 Subject: Do not validate certain BBs changed resource type from CUSTOM to NO_VALIDATE when building block detail is CUSTOM skip validation Change-Id: Ie00fad1f96071703a35b96cc5fe83ce5dc2092bb Issue-ID: SO-1243 Signed-off-by: Benjamin, Max (mb388a) --- .../migration/V4.19__RenameCustomToNoValidate.sql | 2 + .../tasks/OrchestrationStatusValidator.java | 4 ++ .../OrchestrationStatusValidatorUnitTest.java | 45 ++++++++++++++++++++++ .../OrchestrationStatusValidationDirective.java | 2 +- .../org/onap/so/db/catalog/beans/ResourceType.java | 2 +- 5 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.19__RenameCustomToNoValidate.sql create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.19__RenameCustomToNoValidate.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.19__RenameCustomToNoValidate.sql new file mode 100644 index 0000000000..bded179395 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.19__RenameCustomToNoValidate.sql @@ -0,0 +1,2 @@ +update building_block_detail set RESOURCE_TYPE = "NO_VALIDATE" where RESOURCE_TYPE = "CUSTOM"; +update orchestration_status_state_transition_directive set RESOURCE_TYPE = "NO_VALIDATE" where RESOURCE_TYPE = "CUSTOM"; \ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java index b0063c1da1..2065dfb71e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java @@ -105,6 +105,10 @@ public class OrchestrationStatusValidator { org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID, execution.getLookupMap().get(ResourceKey.CONFIGURATION_ID)); orchestrationStatus = configuration.getOrchestrationStatus(); break; + case NO_VALIDATE: + //short circuit and exit method + execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, OrchestrationStatusValidationDirective.VALIDATION_SKIPPED); + return; default: // can't currently get here, so not tested. Added in case enum is expanded without a change to this code throw new OrchestrationStatusValidationException(String.format(UNKNOWN_RESOURCE_TYPE, buildingBlockFlowName, buildingBlockDetail.getResourceType(), buildingBlockDetail.getTargetAction())); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java new file mode 100644 index 0000000000..4ace2727be --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java @@ -0,0 +1,45 @@ +package org.onap.so.bpmn.infrastructure.workflow.tasks; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.when; + +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.db.catalog.beans.BuildingBlockDetail; +import org.onap.so.db.catalog.beans.OrchestrationAction; +import org.onap.so.db.catalog.beans.OrchestrationStatusValidationDirective; +import org.onap.so.db.catalog.beans.ResourceType; +import org.onap.so.db.catalog.client.CatalogDbClient; + +@RunWith(MockitoJUnitRunner.class) +public class OrchestrationStatusValidatorUnitTest { + + @Mock + private CatalogDbClient catalogDbClient; + + @InjectMocks + private OrchestrationStatusValidator validator; + @Test + public void skipValidationTest() { + BuildingBlockDetail bbDetail = new BuildingBlockDetail(); + bbDetail.setBuildingBlockName("customBB"); + bbDetail.setResourceType(ResourceType.NO_VALIDATE); + bbDetail.setTargetAction(OrchestrationAction.CUSTOM); + when(catalogDbClient.getBuildingBlockDetail("customBB")).thenReturn(bbDetail); + BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake()); + execution.setVariable("flowToBeCalled", "customBB"); + execution.setVariable("aLaCarte", false); + validator.validateOrchestrationStatus(execution); + + + assertThat(execution.getVariable("orchestrationStatusValidationResult"), equalTo(OrchestrationStatusValidationDirective.VALIDATION_SKIPPED)); + } + +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatusValidationDirective.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatusValidationDirective.java index 544e1cbf08..f92aadf7a7 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatusValidationDirective.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/OrchestrationStatusValidationDirective.java @@ -22,7 +22,7 @@ package org.onap.so.db.catalog.beans; //TODO find this file a new location? public enum OrchestrationStatusValidationDirective { - SILENT_SUCCESS("SilentSuccess"), CONTINUE("Continue"), FAIL("Fail"); + SILENT_SUCCESS("SilentSuccess"), CONTINUE("Continue"), FAIL("Fail"), VALIDATION_SKIPPED("ValidationSkiPped"); private final String name; diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java index 8e1d498e42..64eff56f97 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ResourceType.java @@ -28,7 +28,7 @@ public enum ResourceType { NETWORK("Network"), NETWORK_COLLECTION("NetworkCollection"), CONFIGURATION("Configuration"), - CUSTOM("Custom"); + NO_VALIDATE("NoValidate"); private final String name; -- cgit 1.2.3-korg From 661e097824940625a9cef4547a17d3311c57e1fc Mon Sep 17 00:00:00 2001 From: Elena Kuleshov Date: Sat, 24 Nov 2018 23:20:26 -0500 Subject: Add ActivitiesBBs to building block detail Change-Id: I96524757c4efb93f5ff03f31a4cf8dcb5fa88025 Issue-ID: SO-1243 Signed-off-by: Kuleshov, Elena (ek1439) --- .../db/migration/V4.20__SetActivitiesBBsToNoValidate.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.20__SetActivitiesBBsToNoValidate.sql (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.20__SetActivitiesBBsToNoValidate.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.20__SetActivitiesBBsToNoValidate.sql new file mode 100644 index 0000000000..9f51ed173d --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.20__SetActivitiesBBsToNoValidate.sql @@ -0,0 +1,13 @@ +USE catalogdb; + +INSERT INTO building_block_detail (BUILDING_BLOCK_NAME, RESOURCE_TYPE, TARGET_ACTION) +VALUES +('FlowCompleteActivity', 'NO_VALIDATE', 'CUSTOM'), +('VNFHealthCheckActivity', 'NO_VALIDATE', 'CUSTOM'), +('VNFQuiesceTrafficActivity', 'NO_VALIDATE', 'CUSTOM'), +('VNFResumeTrafficActivity', 'NO_VALIDATE', 'CUSTOM'), +('VNFSetInMaintFlagActivity', 'NO_VALIDATE', 'CUSTOM'), +('VNFUnsetInMaintFlagActivity', 'NO_VALIDATE', 'CUSTOM'), +('VNFUpgradePostCheckActivity', 'NO_VALIDATE', 'CUSTOM'), +('VNFUpgradePreCheckActivity', 'NO_VALIDATE', 'CUSTOM'), +('VNFUpgradeSoftwareActivity', 'NO_VALIDATE', 'CUSTOM'); \ No newline at end of file -- cgit 1.2.3-korg From 17078f031da59e4a3b7a4e18cf5b23daf9ddac56 Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Wed, 28 Nov 2018 12:37:54 -0800 Subject: Fix alacarte homing flows This fix adds homingInstance bean and stores homing info in the database. It then retreves that info when homing ala carte and populates homingSiteId and oofDirectives. SO-1254 Issue-ID: SO-1258 Change-Id: I6f8d5d3aff9ebeb669064a02926c779886dc59dd Signed-off-by: Marcus G K Williams --- .../db/migration/v4.21_AddHomingTables.sql | 7 + .../so/db/catalog/client/CatalogDbClientTest.java | 75 ++++++++++ .../test/resources/db/migration/afterMigrate.sql | 14 +- .../onap/so/bpmn/common/scripts/OofHoming.groovy | 17 ++- .../onap/so/bpmn/common/scripts/OofUtils.groovy | 43 +++--- .../onap/so/bpmn/common/util/OofInfraUtils.java | 103 ++++++++++++++ .../infrastructure/scripts/DoCreateVfModule.groovy | 62 ++++++++- .../bpmn/infrastructure/scripts/DoCreateVnf.groovy | 19 +++ .../onap/so/db/catalog/beans/HomingInstance.java | 152 +++++++++++++++++++++ .../onap/so/db/catalog/client/CatalogDbClient.java | 32 ++++- .../data/repository/HomingInstanceRepository.java | 30 ++++ 11 files changed, 516 insertions(+), 38 deletions(-) create mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/v4.21_AddHomingTables.sql create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java create mode 100644 mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java create mode 100644 mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HomingInstanceRepository.java (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/v4.21_AddHomingTables.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/v4.21_AddHomingTables.sql new file mode 100644 index 0000000000..a2ebe04ed8 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/v4.21_AddHomingTables.sql @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS `homing_instances` ( +`SERVICE_INSTANCE_ID` varchar(50) NOT NULL, +`CLOUD_OWNER` VARCHAR(200) NOT NULL, +`CLOUD_REGION_ID` VARCHAR(200) NOT NULL, +`OOF_DIRECTIVES` longtext NULL DEFAULT NULL, +PRIMARY KEY (`SERVICE_INSTANCE_ID`) +) ; \ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index c85a4c28f5..8c990a1a65 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -33,6 +33,7 @@ import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.CloudifyManager; import org.onap.so.db.catalog.beans.ExternalServiceToInternalService; +import org.onap.so.db.catalog.beans.HomingInstance; import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.ServerType; @@ -414,6 +415,80 @@ public class CatalogDbClientTest { Assert.assertEquals("RANDOMID", getCloudSite.getIdentityServiceId()); } + @Test + public void testGetHomingInstance() { + HomingInstance homingInstance = client.getHomingInstance("5df8b6de-2083-11e7-93ae-92361f232671"); + Assert.assertNotNull(homingInstance); + Assert.assertNotNull(homingInstance.getCloudOwner()); + Assert.assertNotNull(homingInstance.getCloudRegionId()); + Assert.assertNotNull(homingInstance.getOofDirectives()); + } + + @Test + public void testPostHomingInstance() { + CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger("http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort); + HomingInstance homingInstance = new HomingInstance(); + homingInstance.setServiceInstanceId("5df8d6be-2083-11e7-93ae-92361f232671"); + homingInstance.setCloudOwner("CloudOwner-1"); + homingInstance.setCloudRegionId("CloudRegionOne"); + homingInstance.setOofDirectives("{\n" + + "\"directives\": [\n" + + "{\n" + + "\"directives\": [\n" + + "{\n" + + "\"attributes\": [\n" + + "{\n" + + "\"attribute_value\": \"onap.hpa.flavor31\",\n" + + "\"attribute_name\": \"firewall_flavor_name\"\n" + + "}\n" + + "],\n" + + "\"type\": \"flavor_directives\"\n" + + "}\n" + + "],\n" + + "\"type\": \"vnfc\",\n" + + "\"id\": \"vfw\"\n" + + "},\n" + + "{\n" + + "\"directives\": [\n" + + "{\n" + + "\"attributes\": [\n" + + "{\n" + + "\"attribute_value\": \"onap.hpa.flavor32\",\n" + + "\"attribute_name\": \"packetgen_flavor_name\"\n" + + "}\n" + + "],\n" + + "\"type\": \"flavor_directives\"\n" + + "}\n" + + "],\n" + + "\"type\": \"vnfc\",\n" + + "\"id\": \"vgenerator\"\n" + + "},\n" + + "{\n" + + "\"directives\": [\n" + + "{\n" + + "\"attributes\": [\n" + + "{\n" + + "\"attribute_value\": \"onap.hpa.flavor31\",\n" + + "\"attribute_name\": \"sink_flavor_name\"\n" + + "}\n" + + "],\n" + + "\"type\": \"flavor_directives\"\n" + + "}\n" + + "],\n" + + "\"type\": \"vnfc\",\n" + + "\"id\": \"vsink\"\n" + + "}\n" + + "]\n" + + "}"); + localClient.postHomingInstance(homingInstance); + HomingInstance getHomingInstance = this.client.getHomingInstance("5df8d6be-2083-11e7-93ae-92361f232671"); + Assert.assertNotNull(getHomingInstance); + Assert.assertNotNull(getHomingInstance.getCloudRegionId()); + Assert.assertNotNull(getHomingInstance.getCloudOwner()); + Assert.assertEquals("CloudOwner-1", getHomingInstance.getCloudOwner()); + Assert.assertEquals("CloudRegionOne", getHomingInstance.getCloudRegionId()); + } + @Test public void testGetServiceByModelName() { Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service"); diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql index c8475564a4..7ac3c53420 100644 --- a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql +++ b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql @@ -49,6 +49,14 @@ CREATE TABLE IF NOT EXISTS `cloud_sites` ( CONSTRAINT `FK_cloud_sites_identity_services` FOREIGN KEY (`IDENTITY_SERVICE_ID`) REFERENCES `identity_services` (`ID`) ) ; +CREATE TABLE IF NOT EXISTS `homing_instances` ( +`SERVICE_INSTANCE_ID` varchar(50) NOT NULL, +`CLOUD_OWNER` VARCHAR(200) NOT NULL, +`CLOUD_REGION_ID` VARCHAR(200) NOT NULL, +`OOF_DIRECTIVES` longtext NULL DEFAULT NULL, +PRIMARY KEY (`SERVICE_INSTANCE_ID`) +) ; + insert into heat_files(artifact_uuid, name, version, description, body, artifact_checksum, creation_timestamp) values ('00535bdd-0878-4478-b95a-c575c742bfb0', 'nimbus-ethernet-gw', '1', 'created from csar', 'DEVICE=$dev\nBOOTPROTO=none\nNM_CONTROLLED=no\nIPADDR=$ip\nNETMASK=$netmask\nGATEWAY=$gateway\n', 'MANUAL RECORD', '2017-01-21 23:56:43'); @@ -203,4 +211,8 @@ VALUES INSERT INTO vnf_components_recipe (VNF_COMPONENT_TYPE, ACTION, VERSION, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT, VF_MODULE_MODEL_UUID) VALUES -('volumeGroup', 'createInstance', '1', 'Gr api recipe to create volume-group', '/mso/async/services/WorkflowActionBB', 180, '20c4431c-246d-11e7-93ae-92361f002671'); \ No newline at end of file +('volumeGroup', 'createInstance', '1', 'Gr api recipe to create volume-group', '/mso/async/services/WorkflowActionBB', 180, '20c4431c-246d-11e7-93ae-92361f002671'); + +insert into homing_instances (service_instance_id, cloud_owner, cloud_region_id, oof_directives) values +('5df8b6de-2083-11e7-93ae-92361f232671', 'CloudOwner', 'CloudRegionId', '{"directives": [{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "firewall_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vfw"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor33","attribute_name": "packetgen_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vgenerator"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "sink_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vsink"}]}'), +('5df8b6de-2083-11e7-93ae-92361f562672', 'CloudOwner', 'CloudRegionId', '{"directives": [{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "firewall_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vfw"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor33","attribute_name": "packetgen_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vgenerator"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "sink_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vsink"}]}'); \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy index c50ef3530e..df3399f1f0 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy @@ -33,6 +33,7 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.db.catalog.beans.AuthenticationType import org.onap.so.db.catalog.beans.CloudIdentity import org.onap.so.db.catalog.beans.CloudSite +import org.onap.so.db.catalog.beans.HomingInstance import org.onap.so.db.catalog.beans.ServerType import org.onap.so.rest.APIResponse import org.onap.so.rest.RESTClient @@ -293,8 +294,7 @@ class OofHoming extends AbstractServiceTaskProcessor { + " *****", "true") // Set cloudsite in catalog DB here - // TODO Get cloudsite and compare, set if not present - oofUtils.createCloudSiteCatalogDb(cloudSite, execution) + oofUtils.createCloudSite(cloudSite, execution) if (oofDirectives != null && oofDirectives != "") { resource.getHomingSolution().setOofDirectives(oofDirectives) @@ -303,6 +303,19 @@ class OofHoming extends AbstractServiceTaskProcessor { " *****", "true") } + // Set Homing Instance + String serviceInstanceId = decomposition.getServiceInstance().getInstanceId() + HomingInstance homingInstance = new HomingInstance() + homingInstance.setServiceInstanceId(serviceInstanceId) + homingInstance.setCloudOwner(cloudOwner) + homingInstance.setCloudRegionId(cloudRegionId) + if (oofDirectives != null && oofDirectives != "") { + homingInstance.setOofDirectives(oofDirectives)} + else { + homingInstance.setOofDirectives("{}") + } + oofUtils.createHomingInstance(homingInstance, execution) + if (inventoryType.equalsIgnoreCase("service")) { resource.getHomingSolution().setRehome(assignmentMap.get("isRehome").toBoolean()) VnfResource vnf = new VnfResource() diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy index 19d19b8cea..f72fc47aa5 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy @@ -33,24 +33,16 @@ import org.onap.so.bpmn.core.domain.ServiceInstance import org.onap.so.bpmn.core.domain.Subscriber import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.db.catalog.beans.CloudIdentity import org.onap.so.db.catalog.beans.CloudSite -import org.onap.so.db.catalog.client.CatalogDbClient -import org.onap.so.rest.APIResponse -import org.onap.so.rest.RESTClient -import org.onap.so.rest.RESTConfig -import org.springframework.http.HttpEntity -import org.springframework.http.HttpHeaders -import org.springframework.web.util.UriComponentsBuilder - -import javax.ws.rs.core.MediaType +import org.onap.so.db.catalog.beans.HomingInstance import javax.ws.rs.core.UriBuilder - +import org.onap.so.bpmn.common.util.OofInfraUtils import static org.onap.so.bpmn.common.scripts.GenericUtils.* class OofUtils { ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() + OofInfraUtils oofInfraUtils = new OofInfraUtils() private AbstractServiceTaskProcessor utils @@ -491,6 +483,7 @@ class OofUtils { if (candidatesJson != "") {candidatesJson = candidatesJson.substring(0, candidatesJson.length() - 1)} return candidatesJson } + /** * This method creates a cloudsite in catalog database. * @@ -498,23 +491,19 @@ class OofUtils { * * @return void */ - Void createCloudSiteCatalogDb(CloudSite cloudSite, DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution) - String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution) - CloudSite getCloudsite = null + Void createCloudSite(CloudSite cloudSite, DelegateExecution execution) { + oofInfraUtils.createCloudSite(cloudSite, execution) + } - CatalogDbClient catalogDbClient = new CatalogDbClient(endpoint, auth) - try { - getCloudsite = catalogDbClient.getCloudSite(cloudSite.getId().toString()) - } catch (Exception e) { - e = null - utils.log("DEBUG", "Could not find cloudsite : " + cloudSite.getId(), isDebugEnabled) - utils.log("DEBUG", "Creating cloudSite: " + cloudSite.toString(), isDebugEnabled) - } - if (getCloudsite?.getId() != cloudSite.getId()) { - catalogDbClient.postCloudSite(cloudSite) - } + /** + * This method creates a HomingInstance in catalog database. + * + * @param HomingInstance homingInstance + * + * @return void + */ + Void createHomingInstance(HomingInstance homingInstance, DelegateExecution execution) { + oofInfraUtils.createHomingInstance(homingInstance, execution) } String getMsbHost(DelegateExecution execution) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java new file mode 100644 index 0000000000..b62d8be281 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018. Intel Corp. All rights reserved. + * ================================================================================ + * 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.onap.so.bpmn.common.util; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.db.catalog.beans.HomingInstance; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.logger.MsoLogger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Arrays; +import java.util.Optional; + +public class OofInfraUtils { + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, OofInfraUtils.class); + + /** + * This method creates a cloudsite in catalog database. + * + * @param cloudSite + * + * @return void + */ + public void createCloudSite(CloudSite cloudSite, DelegateExecution execution) { + String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution); + String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution); + Optional optCloudsite = Optional.empty(); + + CatalogDbClient client = new CatalogDbClient(endpoint, auth); + try { + optCloudsite = Optional.ofNullable(client.getCloudSite(cloudSite.getId(), endpoint + "/cloudSite/")); + } catch (Exception e) { + LOGGER.debug("Could not find cloudsite : " + cloudSite.getId()); + LOGGER.debug("Creating cloudSite: " + cloudSite.toString()); + } + if (optCloudsite.isPresent() && (cloudSite.getId()) != optCloudsite.get().getId()) { + client.postCloudSite(cloudSite); + } + } + + /** + * This method creates a HomingInstance in catalog database. + * + * @param homingInstance + * + * @return void + */ + public void createHomingInstance(HomingInstance homingInstance, DelegateExecution execution) { + String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution); + String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution); + + CatalogDbClient client = new CatalogDbClient(endpoint, auth); + try { + client.postHomingInstance(homingInstance); + } catch (Exception exception) { + LOGGER.debug("Could not create HomingInstance : " + homingInstance.getServiceInstanceId()); + LOGGER.debug("HomingInstance Creation Error: " + exception); + } + + } + + /** + * This method gets a HomingInstance in catalog database. + * + * @param serviceInstanceId + * + * @return HomingInstance + */ + public HomingInstance getHomingInstance(String serviceInstanceId, DelegateExecution execution) { + String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution); + String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution); + + CatalogDbClient client = new CatalogDbClient(endpoint, auth); + try { + return client.getHomingInstance(serviceInstanceId, endpoint + "/homingInstance/"); + } catch (Exception exception) { + LOGGER.debug("Could not get HomingInstance for serviceInstanceId : " + serviceInstanceId); + LOGGER.debug("Get HomingInstance Error: " + exception); + } + return null; + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy index 58b90a1bf2..74926ce5b7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy @@ -20,6 +20,8 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.db.catalog.beans.HomingInstance + import javax.xml.parsers.DocumentBuilder import javax.xml.parsers.DocumentBuilderFactory @@ -35,6 +37,7 @@ import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.NetworkUtils import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils import org.onap.so.bpmn.common.scripts.VfModuleBase +import org.onap.so.bpmn.common.util.OofInfraUtils import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException @@ -75,6 +78,7 @@ public class DoCreateVfModule extends VfModuleBase { ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + OofInfraUtils oofInfraUtils = new OofInfraUtils() CatalogDbUtils catalog = new CatalogDbUtils() DecomposeJsonUtil decomposeJsonUtils = new DecomposeJsonUtil() @@ -232,12 +236,37 @@ public class DoCreateVfModule extends VfModuleBase { String globalSubscriberId = execution.getVariable("globalSubscriberId") execution.setVariable("DCVFM_globalSubscriberId", globalSubscriberId) msoLogger.debug("globalSubsrciberId: " + globalSubscriberId) - //OofDirectives - String oofDirectives = execution.getVariable("oofDirectives") + + // Set Homing Info + String oofDirectives = null + try { + HomingInstance homingInstance = oofInfraUtils.getHomingInstance(serviceInstanceId, execution) + if (homingInstance != null) { + execution.setVariable("DCVFM_cloudSiteId", homingInstance.getCloudRegionId()) + rollbackData.put("VFMODULE", "aiccloudregion", homingInstance.getCloudRegionId()) + msoLogger.debug("Overwriting cloudSiteId with homing cloudSiteId: " + + homingInstance.getCloudRegionId()) + execution.setVariable("DCVFM_cloudOwner", homingInstance.getCloudOwner()) + rollbackData.put("VFMODULE", "cloudOwner", homingInstance.getCloudOwner()) + msoLogger.debug("Overwriting cloudOwner with homing cloudOwner: " + + homingInstance.getCloudOwner()) + oofDirectives = homingInstance.getOofDirectives() + execution.setVariable("DCVFM_oofDirectives", oofDirectives) + } + } catch (Exception exception) { + msoLogger.debug("Could not find homing information for service instance: " + serviceInstanceId + + "... continuing") + msoLogger.debug("Could not find homing information for service instance error: " + exception) + } + //OofDirectives to Input Params Map vfModuleInputParams = execution.getVariable("vfModuleInputParams") - if (oofDirectives != null) { - vfModuleInputParams.put("oofDirectives", oofDirectives) - logDebug("OofDirectives are: " + oofDirectives, isDebugLogEnabled) + if (oofDirectives != null && vfModuleInputParams != null) { + vfModuleInputParams.put("oof_directives", oofDirectives) + vfModuleInputParams.put("sdnc_directives", "{}") + msoLogger.debug("OofDirectives are: " + oofDirectives) + } else if (vfModuleInputParams != null) { + vfModuleInputParams.put("oof_directives", "{}") + vfModuleInputParams.put("sdnc_directives", "{}") } if (vfModuleInputParams != null) { execution.setVariable("DCVFM_vnfParamsMap", vfModuleInputParams) @@ -464,11 +493,30 @@ public class DoCreateVfModule extends VfModuleBase { } //OofDirectives - String oofDirectives = execution.getVariable("oofDirectives") + String oofDirectives = null + try { + HomingInstance homingInstance = oofInfraUtils.getHomingInstance(serviceInstanceId, execution) + if (homingInstance != null) { + execution.setVariable("DCVFM_cloudSiteId", homingInstance.getCloudRegionId()) + rollbackData.put("VFMODULE", "aiccloudregion", homingInstance.getCloudRegionId()) + msoLogger.debug("Overwriting cloudSiteId with homing cloudSiteId: " + + homingInstance.getCloudRegionId()) + execution.setVariable("DCVFM_cloudOwner", homingInstance.getCloudOwner()) + rollbackData.put("VFMODULE", "cloudOwner", homingInstance.getCloudOwner()) + msoLogger.debug("Overwriting cloudOwner with homing cloudOwner: " + + homingInstance.getCloudOwner()) + oofDirectives = homingInstance.getOofDirectives() + execution.setVariable("DCVFM_oofDirectives", oofDirectives) + } + } catch (Exception exception) { + msoLogger.debug("Could not find homing information for service instance: " + serviceInstanceId + + "... continuing") + msoLogger.debug("Could not find homing information for service instance error: " + exception) + } if (oofDirectives != null) { Map paramsMap = execution.getVariable("DCVFM_vnfParamsMap") paramsMap.put("oofDirectives", oofDirectives) - logDebug("OofDirectives are: " + oofDirectives, isDebugLogEnabled) + msoLogger.debug("OofDirectives are: " + oofDirectives) execution.setVariable("DCVFM_vnfParamsMap", paramsMap) } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy index b35aab1176..deb0bffaf9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy @@ -20,6 +20,8 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.db.catalog.beans.HomingInstance + import static org.apache.commons.lang3.StringUtils.* import org.camunda.bpm.engine.delegate.BpmnError @@ -31,6 +33,7 @@ import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils import org.onap.so.bpmn.common.scripts.VidUtils +import org.onap.so.bpmn.common.util.OofInfraUtils import org.onap.so.bpmn.core.RollbackData import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException @@ -61,6 +64,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { JsonUtils jsonUtil = new JsonUtils() VidUtils vidUtils = new VidUtils(this) SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) + OofInfraUtils oofInfraUtils = new OofInfraUtils() /** * This method gets and validates the incoming @@ -238,6 +242,21 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { execution.setVariable("DoCVNF_nfFunction", nfFunction) msoLogger.debug("NF Function is: " + nfFunction) + // Set Homing Info + try { + HomingInstance homingInstance = oofInfraUtils.getHomingInstance(serviceInstanceId, execution) + if (homingInstance != null) { + execution.setVariable("DoCVNF_cloudSiteId", homingInstance.getCloudRegionId()) + rollbackData.put("VNF", "cloudSiteId", homingInstance.getCloudRegionId()) + msoLogger.debug("Overwriting cloudSiteId with homing cloudSiteId: " + + homingInstance.getCloudRegionId()) + } + } catch (Exception exception) { + msoLogger.debug("Could not find homing information for service instance: " + serviceInstanceId + + "... continuing") + msoLogger.debug("Could not find homing information for service instance error: " + exception) + } + rollbackData.put("VNF", "rollbackSDNCAssign", "false") rollbackData.put("VNF", "rollbackSDNCActivate", "false") rollbackData.put("VNF", "rollbackVnfCreate", "false") diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java new file mode 100644 index 0000000000..ef474be159 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java @@ -0,0 +1,152 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018. Intel Corp. All rights reserved. + * ================================================================================ + * 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.onap.so.db.catalog.beans; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.openpojo.business.annotation.BusinessKey; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; +import uk.co.blackpepper.bowman.annotation.RemoteResource; +import uk.co.blackpepper.bowman.annotation.ResourceId; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Transient; +import java.net.URI; + +/** + * EntityBean class for a HomingInstance. This bean represents a homing instance + * of a service, populated on successful homing + * + */ +@RemoteResource("/homingInstance") +@Entity +@Table(name = "homing_instances") +public class HomingInstance { + @JsonProperty + @BusinessKey + @Id + @Column(name = "SERVICE_INSTANCE_ID") + private String serviceInstanceId; + + @JsonProperty("cloud_region_id") + @BusinessKey + @Column(name = "CLOUD_REGION_ID") + private String cloudRegionId; + + @JsonProperty("cloud_owner") + @BusinessKey + @Column(name = "CLOUD_OWNER") + private String cloudOwner; + + + + @JsonProperty("oof_directives") + @BusinessKey + @Column(name = "OOF_DIRECTIVES", columnDefinition = "LONGTEXT") + private String oofDirectives; + + @Transient + private URI uri; + + public HomingInstance () { + + } + + public HomingInstance (HomingInstance homingInstance) { + this.serviceInstanceId = homingInstance.getServiceInstanceId(); + this.cloudRegionId = homingInstance.getCloudRegionId(); + this.cloudOwner = homingInstance.getCloudOwner(); + this.oofDirectives = homingInstance.getOofDirectives(); + } + + + public String getServiceInstanceId() { + return this.serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + + this.serviceInstanceId = serviceInstanceId; + } + + public String getCloudRegionId() { + + return this.cloudRegionId; + } + + public void setCloudRegionId(String cloudRegionId) { + + this.cloudRegionId = cloudRegionId; + } + + public String getCloudOwner() { + + return this.cloudOwner; + } + + public void setCloudOwner (String cloudOwner) { + + this.cloudOwner = cloudOwner; + } + + public String getOofDirectives() { + return oofDirectives; + } + + public void setOofDirectives(String oofDirectives) { + this.oofDirectives = oofDirectives; + } + + @ResourceId + public URI getUri() { + return this.uri; + } + + public void setUri(URI uri) { + + this.uri = uri; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("serviceInstanceId", serviceInstanceId) + .append("cloudRegionId", cloudRegionId) + .append("cloudOwner", cloudOwner) + .append("oofDirectives", oofDirectives).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof HomingInstance)) { + return false; + } + HomingInstance castOther = (HomingInstance) other; + return new EqualsBuilder().append(serviceInstanceId, castOther.serviceInstanceId).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(serviceInstanceId).toHashCode(); + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java index 8a61102322..98addf90aa 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java @@ -36,6 +36,7 @@ import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.onap.so.db.catalog.beans.CvnfcCustomization; import org.onap.so.db.catalog.beans.ExternalServiceToInternalService; +import org.onap.so.db.catalog.beans.HomingInstance; import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.NetworkRecipe; @@ -125,6 +126,7 @@ public class CatalogDbClient { private static final String WORK_STEP = "workStep"; private static final String CLLI = "clli"; private static final String CLOUD_VERSION = "cloudVersion"; + private static final String HOMING_INSTANCE = "/homingInstance"; private static final String TARGET_ENTITY = "SO:CatalogDB"; @@ -153,6 +155,8 @@ public class CatalogDbClient { private String findOneByActionAndRequestScopeAndIsAlacarte = "/findOneByActionAndRequestScopeAndIsAlacarte"; private String findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep = "/findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep"; private String findByClliAndCloudVersion = "/findByClliAndCloudVersion"; + private String findServiceByServiceInstanceId = "/findServiceByServiceInstanceId"; + private String serviceURI; private String vfModuleURI; @@ -165,6 +169,7 @@ public class CatalogDbClient { private String instanceGroupURI; private String cloudifyManagerURI; private String cloudSiteURI; + private String homingInstanceURI; private final Client serviceClient; @@ -210,6 +215,8 @@ public class CatalogDbClient { private final Client cloudSiteClient; + private final Client homingInstanceClient; + private final Client cloudifyManagerClient; private Client cvnfcCustomizationClient; @@ -262,6 +269,7 @@ public class CatalogDbClient { instanceGroupURI = endpoint + INSTANCE_GROUP + URI_SEPARATOR; cloudifyManagerURI = endpoint + CLOUDIFY_MANAGER + URI_SEPARATOR; cloudSiteURI = endpoint + CLOUD_SITE + URI_SEPARATOR; + homingInstanceURI = endpoint + HOMING_INSTANCE + URI_SEPARATOR; } @@ -300,6 +308,7 @@ public class CatalogDbClient { networkCollectionResourceCustomizationClient = clientFactory.create(NetworkCollectionResourceCustomization.class); collectionNetworkResourceCustomizationClient = clientFactory.create(CollectionNetworkResourceCustomization.class); cloudSiteClient = clientFactory.create(CloudSite.class); + homingInstanceClient = clientFactory.create(HomingInstance.class); cloudifyManagerClient = clientFactory.create(CloudifyManager.class); serviceRecipeClient = clientFactory.create(ServiceRecipe.class); cvnfcCustomizationClient = clientFactory.create(CvnfcCustomization.class); @@ -342,6 +351,7 @@ public class CatalogDbClient { networkCollectionResourceCustomizationClient = clientFactory.create(NetworkCollectionResourceCustomization.class); collectionNetworkResourceCustomizationClient = clientFactory.create(CollectionNetworkResourceCustomization.class); cloudSiteClient = clientFactory.create(CloudSite.class); + homingInstanceClient = clientFactory.create(HomingInstance.class); cloudifyManagerClient = clientFactory.create(CloudifyManager.class); serviceRecipeClient = clientFactory.create(ServiceRecipe.class); cvnfcCustomizationClient = clientFactory.create(CvnfcCustomization.class); @@ -583,7 +593,13 @@ public class CatalogDbClient { } public CloudSite getCloudSite(String id){ - return this.getSingleResource(cloudSiteClient, getUri(cloudSiteURI + id)); + return this.getSingleResource(cloudSiteClient, + getUri(cloudSiteURI + id)); + } + + public CloudSite getCloudSite(String id, String uri){ + return this.getSingleResource(cloudSiteClient, + getUri(uri + id)); } public void postCloudSite(CloudSite cloudSite){ @@ -596,6 +612,20 @@ public class CatalogDbClient { .queryParam(CLLI,clli).queryParam(CLOUD_VERSION,cloudVersion).build().toString())); } + public HomingInstance getHomingInstance (String serviceInstanceId){ + return this.getSingleResource(homingInstanceClient, + getUri(homingInstanceURI + serviceInstanceId)); + } + + public HomingInstance getHomingInstance (String serviceInstanceId, String uri){ + return this.getSingleResource(homingInstanceClient, + getUri(uri + serviceInstanceId)); + } + + public void postHomingInstance(HomingInstance homingInstance){ + this.postSingleResource(homingInstanceClient, homingInstance); + } + public Service getServiceByModelVersionAndModelInvariantUUID(String modelVersion, String modelInvariantUUID) { return this.getSingleResource(serviceClient, getUri(UriBuilder .fromUri(findFirstByModelVersionAndModelInvariantUUIDURI) diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HomingInstanceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HomingInstanceRepository.java new file mode 100644 index 0000000000..aea8d3e537 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HomingInstanceRepository.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018. Intel Corp. All rights reserved. + * ================================================================================ + * 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.onap.so.db.catalog.data.repository; + +import org.onap.so.db.catalog.beans.HomingInstance; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "homingInstance", path = "homingInstance") +public interface HomingInstanceRepository extends JpaRepository { + HomingInstance findServiceByServiceInstanceId(String serviceInstanceId); +} -- cgit 1.2.3-korg From 54b09cb4c75825a2afcfd7020c8c8ab763b64742 Mon Sep 17 00:00:00 2001 From: "Smokowski, Steve (ss835w)" Date: Fri, 30 Nov 2018 09:51:52 -0500 Subject: Fix Cloud Version Issue-ID: SO-1184 Change-Id: I6dcffafa489bb96100d5f67b09cef50a56dddf14 Signed-off-by: Smokowski, Steve (ss835w) --- .../main/resources/db/migration/V4.16__Add_Default_NeutronNetwork.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.16__Add_Default_NeutronNetwork.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.16__Add_Default_NeutronNetwork.sql index dd821cab78..3ad4b314eb 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.16__Add_Default_NeutronNetwork.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.16__Add_Default_NeutronNetwork.sql @@ -6,5 +6,5 @@ INSERT INTO `heat_template` (`ARTIFACT_UUID`,`NAME`,`VERSION`,`BODY`,`TIMEOUT_MI INSERT INTO `temp_network_heat_template_lookup` (`NETWORK_RESOURCE_MODEL_NAME`, `HEAT_TEMPLATE_ARTIFACT_UUID`,`AIC_VERSION_MIN` , `AIC_VERSION_MAX` ) -VALUES ('Generic NeutronNet','efee1d84-b8ec-11e7-abc4-cec278b6b50a','2.0','NULL'); +VALUES ('Generic NeutronNet','efee1d84-b8ec-11e7-abc4-cec278b6b50a','2.0','3.0'); -- cgit 1.2.3-korg From 090cb77be5c347cc764920fea491a149b5380bcf Mon Sep 17 00:00:00 2001 From: Eric Multanen Date: Sat, 8 Dec 2018 00:04:54 -0800 Subject: fix homing_instances table create specify the catalogdb in the script to create the homing_instances table. Renamed file to begin with 'V' instead of 'v' Not sure if that matters or not. Change-Id: I35533ae5e22c23b8c1817fe8c373e40fa434f873 Issue-ID: SO-1306 Signed-off-by: Eric Multanen --- .../src/main/resources/db/migration/V4.21__AddHomingTables.sql | 9 +++++++++ .../src/main/resources/db/migration/v4.21_AddHomingTables.sql | 7 ------- 2 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.21__AddHomingTables.sql delete mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/v4.21_AddHomingTables.sql (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.21__AddHomingTables.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.21__AddHomingTables.sql new file mode 100644 index 0000000000..1725028104 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.21__AddHomingTables.sql @@ -0,0 +1,9 @@ +use catalogdb; + +CREATE TABLE IF NOT EXISTS `homing_instances` ( +`SERVICE_INSTANCE_ID` varchar(50) NOT NULL, +`CLOUD_OWNER` VARCHAR(200) NOT NULL, +`CLOUD_REGION_ID` VARCHAR(200) NOT NULL, +`OOF_DIRECTIVES` longtext NULL DEFAULT NULL, +PRIMARY KEY (`SERVICE_INSTANCE_ID`) +) ; diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/v4.21_AddHomingTables.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/v4.21_AddHomingTables.sql deleted file mode 100644 index a2ebe04ed8..0000000000 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/v4.21_AddHomingTables.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE IF NOT EXISTS `homing_instances` ( -`SERVICE_INSTANCE_ID` varchar(50) NOT NULL, -`CLOUD_OWNER` VARCHAR(200) NOT NULL, -`CLOUD_REGION_ID` VARCHAR(200) NOT NULL, -`OOF_DIRECTIVES` longtext NULL DEFAULT NULL, -PRIMARY KEY (`SERVICE_INSTANCE_ID`) -) ; \ No newline at end of file -- cgit 1.2.3-korg From 6addc71625d4ae32d74908fbeb0ce975f2fded9a Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Fri, 14 Dec 2018 20:02:29 +0530 Subject: update request input and sequence to DB Update request input and sequence to DB. Resource sequence has been added as new column in service table. Resource input has been added as new column in resp resource. Change-Id: I97c8227636f06692190a843a87178517db038bbd Issue-ID: SO-1248 Signed-off-by: subhash kumar singh --- .../QueryAllottedResourceCustomization.java | 4 +- .../catalogrest/QueryServiceMacroHolder.java | 2 + .../catalogrest/QueryServiceNetworks.java | 2 + .../catalogdb/catalogrest/QueryServiceVnfs.java | 2 + .../db/migration/V4.22__AddResourceInput.sql | 13 ++ .../src/test/resources/schema.sql | 4 + .../so/asdc/installer/ToscaResourceStructure.java | 2 +- .../installer/heat/ToscaResourceInstaller.java | 153 ++++++++++++++++++++- .../client/test/rest/ASDCRestInterfaceTest.java | 1 + .../installer/heat/ToscaResourceInputTest.java | 136 ++++++++++++++++++ asdc-controller/src/test/resources/schema.sql | 4 + .../src/test/resources/schema.sql | 4 + .../beans/AllottedResourceCustomization.java | 11 ++ .../beans/NetworkResourceCustomization.java | 11 ++ .../java/org/onap/so/db/catalog/beans/Service.java | 11 ++ .../db/catalog/beans/VnfResourceCustomization.java | 11 ++ mso-catalog-db/src/test/resources/schema.sql | 6 +- 17 files changed, 368 insertions(+), 9 deletions(-) create mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.22__AddResourceInput.sql create mode 100644 asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java index 7a215a9458..859666f446 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java @@ -52,7 +52,8 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { "\t\t\"nfFunction\" : ,\n"+ "\t\t\"nfType\" : ,\n"+ "\t\t\"nfRole\" : ,\n"+ - "\t\t\"nfNamingCode\" : \n"+ + "\t\t\"nfNamingCode\" : ,\n"+ + "\t\t\"resourceInput\" : \n"+ "\t}"; public QueryAllottedResourceCustomization() { @@ -125,6 +126,7 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { put(valueMap, "PROVIDING_SERVICE_MODEL_INVARIANT_UUID", o.getProvidingServiceModelInvariantUUID()); put(valueMap, "PROVIDING_SERVICE_MODEL_UUID", o.getProvidingServiceModelUUID()); put(valueMap, "PROVIDING_SERVICE_MODEL_NAME", o.getProvidingServiceModelName()); + put(valueMap, "RESOURCE_INPUT", o.getResourceInput()); sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap)); sep = ",\n"; diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java index 3b50871a8d..edbf9749c6 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java @@ -45,6 +45,7 @@ public class QueryServiceMacroHolder extends CatalogQuery { "\t\"serviceType\" : ,\n"+ "\t\"serviceRole\" : ,\n"+ "\t\"environmentContext\" : ,\n"+ + "\t\"resourceOrder\" : ,\n"+ "\t\"workloadContext\" : ,\n"+ "<_SERVICEVNFS_>,\n"+ "<_SERVICENETWORKS_>,\n"+ @@ -81,6 +82,7 @@ public class QueryServiceMacroHolder extends CatalogQuery { put(valueMap, "SERVICE_ROLE", service.getServiceRole()); put(valueMap, "ENVIRONMENT_CONTEXT", service.getEnvironmentContext()); put(valueMap, "WORKLOAD_CONTEXT", service.getWorkloadContext()); + put(valueMap, "RESOURCE_ORDER", service.getResourceOrder()); String subitem; subitem = new QueryServiceVnfs(service.getVnfCustomizations()).JSON2(true, true); diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java index a2256f724a..f7457fda4a 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java @@ -50,6 +50,7 @@ public class QueryServiceNetworks extends CatalogQuery { "\t\t\"toscaNodeType\" : ,\n"+ "\t\t\"networkType\" : ,\n"+ "\t\t\"networkTechnology\" : ,\n"+ + "\t\t\"resourceInput\" : ,\n"+ "\t\t\"networkRole\" : ,\n"+ "\t\t\"networkScope\" : \n"+ "\t}"; @@ -116,6 +117,7 @@ public class QueryServiceNetworks extends CatalogQuery { put(valueMap, "NETWORK_ROLE", o.getNetworkRole()); put(valueMap, "NETWORK_SCOPE", o.getNetworkScope()); put(valueMap, "NETWORK_TECHNOLOGY", o.getNetworkTechnology()); + put(valueMap, "RESOURCE_INPUT", o.getResourceInput()); sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap)); sep = ",\n"; diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java index 82b6aa2aeb..4170047e0b 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java @@ -53,6 +53,7 @@ public class QueryServiceVnfs extends CatalogQuery { "\t\"nfRole\" : ,\n"+ "\t\"nfNamingCode\" : ,\n"+ "\t\"multiStageDesign\" : ,\n"+ + "\t\"resourceInput\" : ,\n"+ "<_VFMODULES_>\n" + "\t}"; @@ -119,6 +120,7 @@ public class QueryServiceVnfs extends CatalogQuery { put(valueMap, "NF_ROLE", o.getNfRole()); put(valueMap, "NF_NAMING_CODE", o.getNfNamingCode()); put(valueMap, "MULTI_STEP_DESIGN", o.getMultiStageDesign()); + put(valueMap, "RESOURCE_INPUT", o.getResourceInput()); String subitem = new QueryVfModule(vrNull ? null : o.getVfModuleCustomizations()).JSON2(true, true); valueMap.put("_VFMODULES_", subitem.replaceAll("(?m)^", "\t\t")); diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.22__AddResourceInput.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.22__AddResourceInput.sql new file mode 100644 index 0000000000..10d8789328 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.22__AddResourceInput.sql @@ -0,0 +1,13 @@ +use catalogdb; + +ALTER TABLE service +ADD RESOURCE_ORDER varchar(255); + +ALTER TABLE vnf_resource_customization +ADD RESOURCE_INPUT varchar(2000); + +ALTER TABLE network_resource_customization +ADD RESOURCE_INPUT varchar(2000); + +ALTER TABLE allotted_resource_customization +ADD RESOURCE_INPUT varchar(2000); \ No newline at end of file diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql index a051417cc1..eff5c632fa 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql +++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql @@ -28,6 +28,7 @@ create table `allotted_resource_customization` ( `min_instances` int(11) default null, `max_instances` int(11) default null, `ar_model_uuid` varchar(200) not null, + `resource_input` varchar(2000) default null, `creation_timestamp` datetime not null default current_timestamp, primary key (`model_customization_uuid`), key `fk_allotted_resource_customization__allotted_resource1_idx` (`ar_model_uuid`), @@ -168,6 +169,7 @@ create table `network_resource_customization` ( `network_scope` varchar(45) default null, `creation_timestamp` datetime not null default current_timestamp, `network_resource_model_uuid` varchar(200) not null, + `resource_input` varchar(2000) default null, primary key (`model_customization_uuid`), key `fk_network_resource_customization__network_resource1_idx` (`network_resource_model_uuid`), constraint `fk_network_resource_customization__network_resource1` foreign key (`network_resource_model_uuid`) references `network_resource` (`model_uuid`) on delete cascade on update cascade @@ -203,6 +205,7 @@ create table `service` ( `service_role` varchar(200) default null, `environment_context` varchar(200) default null, `workload_context` varchar(200) default null, + `resource_order` varchar(200) default null, primary key (`model_uuid`), key `fk_service__tosca_csar1_idx` (`tosca_csar_artifact_uuid`), constraint `fk_service__tosca_csar1` foreign key (`tosca_csar_artifact_uuid`) references `tosca_csar` (`artifact_uuid`) on delete cascade on update cascade @@ -381,6 +384,7 @@ create table `vnf_resource_customization` ( `creation_timestamp` datetime not null default current_timestamp, `vnf_resource_model_uuid` varchar(200) not null, `multi_stage_design` varchar(20) default null, + `resource_input` varchar(2000) default null, primary key (`model_customization_uuid`), key `fk_vnf_resource_customization__vnf_resource1_idx` (`vnf_resource_model_uuid`), constraint `fk_vnf_resource_customization__vnf_resource1` foreign key (`vnf_resource_model_uuid`) references `vnf_resource` (`model_uuid`) on delete cascade on update cascade diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java index 030035157d..c7c6ecacc0 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java @@ -134,7 +134,7 @@ public class ToscaResourceStructure { LOGGER.info(MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF, "***PATH", "ASDC", spoolFile.getAbsolutePath()); - sdcCsarHelper = factory.getSdcCsarHelper(spoolFile.getAbsolutePath()); + sdcCsarHelper = factory.getSdcCsarHelper(spoolFile.getAbsolutePath(),false); }catch(Exception e){ System.out.println("System out " + e.getMessage()); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index 529ce30357..c26d4ad0b3 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -25,16 +25,24 @@ package org.onap.so.asdc.installer.heat; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; import org.hibernate.exception.ConstraintViolationException; import org.hibernate.exception.LockAcquisitionException; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.sdc.api.notification.IResourceInstance; import org.onap.sdc.api.notification.IStatusData; +import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; import org.onap.sdc.tosca.parser.impl.SdcPropertyNames; import org.onap.sdc.tosca.parser.impl.SdcTypes; import org.onap.sdc.toscaparser.api.CapabilityAssignment; @@ -42,8 +50,12 @@ import org.onap.sdc.toscaparser.api.CapabilityAssignments; import org.onap.sdc.toscaparser.api.Group; import org.onap.sdc.toscaparser.api.NodeTemplate; import org.onap.sdc.toscaparser.api.Policy; +import org.onap.sdc.toscaparser.api.Property; import org.onap.sdc.toscaparser.api.RequirementAssignment; +import org.onap.sdc.toscaparser.api.RequirementAssignments; import org.onap.sdc.toscaparser.api.elements.Metadata; +import org.onap.sdc.toscaparser.api.functions.GetInput; +import org.onap.sdc.toscaparser.api.parameters.Input; import org.onap.sdc.utils.DistributionStatusEnum; import org.onap.so.asdc.client.ASDCConfiguration; import org.onap.so.asdc.client.exceptions.ArtifactInstallerException; @@ -284,6 +296,7 @@ public class ToscaResourceInstaller { createService(toscaResourceStruct, vfResourceStruct); Service service = toscaResourceStruct.getCatalogService(); + processResourceSequence(toscaResourceStruct, service); processVFResources(toscaResourceStruct, service, vfResourceStructure); processAllottedResources(toscaResourceStruct, service); processNetworks(toscaResourceStruct, service); @@ -332,6 +345,129 @@ public class ToscaResourceInstaller { } } + + List getRequirementList(List resultList, List nodeTemplates, + ISdcCsarHelper iSdcCsarHelper) { + + List nodes = new ArrayList(); + nodes.addAll(nodeTemplates); + + for (NodeTemplate nodeTemplate : nodeTemplates) { + RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate); + List reqAs = requirement.getAll(); + for (RequirementAssignment ra : reqAs) { + String reqNode = ra.getNodeTemplateName(); + for (NodeTemplate rNode : resultList) { + if (rNode.getName().equals(reqNode)) { + if(!resultList.contains(nodeTemplate)) { + resultList.add(nodeTemplate); + } + if(nodes.contains(nodeTemplate)) { + nodes.remove(nodeTemplate); + } + break; + } + } + } + } + + if (!nodes.isEmpty()) { + getRequirementList(resultList, nodes, iSdcCsarHelper); + } + + return resultList; + } + + // This method retrieve resource sequence from csar file + void processResourceSequence(ToscaResourceStructure toscaResourceStructure, Service service) { + List resouceSequence = new ArrayList(); + List resultList = new ArrayList(); + + ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper(); + List nodeTemplates = iSdcCsarHelper.getServiceNodeTemplates(); + List nodes = new ArrayList(); + nodes.addAll(nodeTemplates); + + for (NodeTemplate nodeTemplate : nodeTemplates) { + RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate); + + if (requirement == null || requirement.getAll() == null || requirement.getAll().isEmpty()) { + resultList.add(nodeTemplate); + nodes.remove(nodeTemplate); + } + } + + resultList = getRequirementList(resultList, nodes, iSdcCsarHelper); + + for (NodeTemplate node : resultList) { + String templateName = node.getMetaData().getValue("name"); + if (!resouceSequence.contains(templateName)) { + resouceSequence.add(templateName); + } + } + + String resourceSeqStr = resouceSequence.stream().collect(Collectors.joining(",")); + service.setResourceOrder(resourceSeqStr); + logger.debug(" resourceSeq for service uuid(" + service.getModelUUID() + ") : " + resourceSeqStr); + } + + private static String CUSTOMIZATION_UUID = "customizationUUID"; + + private static String getValue(Object value, List servInputs) { + String output = null; + if(value instanceof Map) { + // currently this logic handles only one level of nesting. + return ((LinkedHashMap) value).values().toArray()[0].toString(); + } else if(value instanceof GetInput) { + String inputName = ((GetInput)value).getInputName(); + + for(Input input : servInputs) { + if(input.getName().equals(inputName)) { + // keep both input name and default value + // if service input does not supplies value the use default value + String defaultValue = input.getDefault() != null ? (String) input.getDefault() : ""; + output = inputName + "|" + defaultValue;// return default value + } + } + + } else { + output = value != null ? value.toString() : ""; + } + return output; // return property value + } + + String getResourceInput(ToscaResourceStructure toscaResourceStructure, String resourceCustomizationUuid) throws ArtifactInstallerException { + Map resouceRequest = new HashMap<>(); + ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper(); + + List serInput = iSdcCsarHelper.getServiceInputs(); + Optional nodeTemplateOpt = iSdcCsarHelper.getServiceNodeTemplates().stream() + .filter(e -> e.getMetaData().getValue(CUSTOMIZATION_UUID).equals(resourceCustomizationUuid)).findFirst(); + if(nodeTemplateOpt.isPresent()) { + NodeTemplate nodeTemplate = nodeTemplateOpt.get(); + LinkedHashMap resourceProperties = nodeTemplate.getProperties(); + + for(String key : resourceProperties.keySet()) { + Property property = resourceProperties.get(key); + + String value = getValue(property.getValue(), serInput); + resouceRequest.put(key, value); + } + } + + try { + ObjectMapper objectMapper = new ObjectMapper(); + String jsonStr = objectMapper.writeValueAsString(resouceRequest); + + logger.debug("resource request for resource customization id (" + resourceCustomizationUuid + ") : " + jsonStr); + return jsonStr; + } catch (JsonProcessingException e) { + logger.error("resource input could not be deserialized for resource customization id (" + + resourceCustomizationUuid + ")"); + throw new ArtifactInstallerException("resource input could not be parsed", e); + } + } + protected void processNetworks (ToscaResourceStructure toscaResourceStruct, Service service) throws ArtifactInstallerException { List nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper ().getServiceVlList (); @@ -366,7 +502,8 @@ public class ToscaResourceInstaller { null, null, service); - service.getNetworkCustomizations().add (networkCustomization); + networkCustomization.setResourceInput(getResourceInput(toscaResourceStruct, networkCustomization.getModelCustomizationUUID())); + service.getNetworkCustomizations().add (networkCustomization); logger.debug ("No NetworkResourceName found in TempNetworkHeatTemplateLookup for " + networkResourceModelName); } @@ -375,13 +512,14 @@ public class ToscaResourceInstaller { } } - protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service) { + protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service) throws ArtifactInstallerException { List allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources(); if (allottedResourceList != null) { - for (NodeTemplate allottedNode : allottedResourceList) { - service.getAllottedCustomizations() - .add(createAllottedResource(allottedNode, toscaResourceStruct, service)); + for (NodeTemplate allottedNode : allottedResourceList) { + AllottedResourceCustomization allottedResource = createAllottedResource(allottedNode, toscaResourceStruct, service); + allottedResource.setResourceInput(getResourceInput(toscaResourceStruct, allottedResource.getModelCustomizationUUID())); + service.getAllottedCustomizations().add(allottedResource); } } } @@ -528,6 +666,7 @@ public class ToscaResourceInstaller { } } + vnfResource.setResourceInput(getResourceInput(toscaResourceStruct, vnfResource.getModelCustomizationUUID())); service.getVnfCustomizations().add(vnfResource); } @@ -1696,7 +1835,7 @@ public class ToscaResourceInstaller { } protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate, - ToscaResourceStructure toscaResourceStructure, Service service) { + ToscaResourceStructure toscaResourceStructure, Service service) throws ArtifactInstallerException { AllottedResourceCustomization allottedResourceCustomization = allottedCustomizationRepo .findOneByModelCustomizationUUID( nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); @@ -1713,6 +1852,8 @@ public class ToscaResourceInstaller { allottedResourceCustomization.setAllottedResource(allottedResource); allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization); } + + allottedResourceCustomization.setResourceInput(getResourceInput(toscaResourceStructure, allottedResourceCustomization.getModelCustomizationUUID())); return allottedResourceCustomization; } diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java index 1944c3af73..e61957d8c2 100644 --- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java +++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java @@ -148,6 +148,7 @@ public class ASDCRestInterfaceTest extends BaseTest { AllottedResourceCustomization arCustomization = new AllottedResourceCustomization(); arCustomization.setModelCustomizationUUID("f62bb612-c5d4-4406-865c-0abec30631ba"); arCustomization.setModelInstanceName("rege1802pnf 0"); + arCustomization.setResourceInput("{}"); arCustomizationSet.add(arCustomization); arCustomization.setAllottedResource(expectedService); diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java new file mode 100644 index 0000000000..cecf70f916 --- /dev/null +++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java @@ -0,0 +1,136 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Huawei Intellectual Property. All rights reserved. + * ================================================================================ + * 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.onap.so.asdc.installer.heat; + +import org.junit.Rule; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnit; +import org.mockito.junit.MockitoRule; +import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; +import org.onap.sdc.toscaparser.api.NodeTemplate; +import org.onap.sdc.toscaparser.api.Property; +import org.onap.sdc.toscaparser.api.elements.Metadata; +import org.onap.sdc.toscaparser.api.functions.GetInput; +import org.onap.sdc.toscaparser.api.parameters.Input; +import org.onap.so.asdc.client.exceptions.ArtifactInstallerException; +import org.onap.so.asdc.installer.ToscaResourceStructure; +import org.onap.so.db.catalog.beans.Service; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedHashMap; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.when; + +public class ToscaResourceInputTest { + @Rule + public MockitoRule rule = MockitoJUnit.rule(); + + @Mock + ISdcCsarHelper sdcCsarHelper; + + @Mock + NodeTemplate nodeTemplate; + + @Mock + Property property; + + @Mock + GetInput getInput; + + @Mock + Input input; + + @Test + public void processResourceSequenceTest() { + ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller(); + ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure(); + toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper); + ArrayList inputs = new ArrayList<>(); + Service service = new Service(); + + HashMap hashMap = new HashMap(); + hashMap.put("name", "node1"); + + Metadata metadata = new Metadata(hashMap); + when(nodeTemplate.getMetaData()).thenReturn(metadata); + when(sdcCsarHelper.getServiceInputs()).thenReturn(inputs); + when(sdcCsarHelper.getServiceNodeTemplates()).thenReturn(Arrays.asList(nodeTemplate)); + when(sdcCsarHelper.getRequirementsOf(any())).thenReturn(null); + + + toscaResourceInstaller.processResourceSequence(toscaResourceStructure, service); + assertEquals(service.getResourceOrder(), "node1"); + } + + @Test + public void resouceInputTest() throws ArtifactInstallerException { + ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller(); + ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure(); + + toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper); + + HashMap hashMap = new HashMap(); + hashMap.put("customizationUUID", "id1"); + Metadata metadata = new Metadata(hashMap); + + LinkedHashMap propertyMap = new LinkedHashMap(); + propertyMap.put("prop1", property); + + when(sdcCsarHelper.getServiceNodeTemplates()).thenReturn(Arrays.asList(nodeTemplate)); + when(nodeTemplate.getMetaData()).thenReturn(metadata); + when(nodeTemplate.getProperties()).thenReturn(propertyMap); + when(property.getValue()).thenReturn("value1"); + + String resourceInput = toscaResourceInstaller.getResourceInput(toscaResourceStructure, "id1"); + assertEquals(resourceInput, "{\"prop1\":\"value1\"}"); + } + + @Test + public void resouceInputGetInputTest() throws ArtifactInstallerException { + ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller(); + ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure(); + + toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper); + + HashMap hashMap = new HashMap(); + hashMap.put("customizationUUID", "id1"); + Metadata metadata = new Metadata(hashMap); + + LinkedHashMap propertyMap = new LinkedHashMap(); + propertyMap.put("prop1", property); + + when(sdcCsarHelper.getServiceNodeTemplates()).thenReturn(Arrays.asList(nodeTemplate)); + when(sdcCsarHelper.getServiceInputs()).thenReturn(Arrays.asList(input)); + when(nodeTemplate.getMetaData()).thenReturn(metadata); + when(nodeTemplate.getProperties()).thenReturn(propertyMap); + when(property.getValue()).thenReturn(getInput); + when(getInput.getInputName()).thenReturn("res_key"); + when(input.getName()).thenReturn("res_key"); + when(input.getDefault()).thenReturn("default_value"); + + String resourceInput = toscaResourceInstaller.getResourceInput(toscaResourceStructure, "id1"); + assertEquals(resourceInput, "{\"prop1\":\"res_key|default_value\"}"); + } +} diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql index 0372887f15..58772c4998 100644 --- a/asdc-controller/src/test/resources/schema.sql +++ b/asdc-controller/src/test/resources/schema.sql @@ -31,6 +31,7 @@ create table `allotted_resource_customization` ( `min_instances` int(11) default null, `max_instances` int(11) default null, `ar_model_uuid` varchar(200) not null, + `resource_input` varchar(2000) default null, `creation_timestamp` datetime not null default current_timestamp, primary key (`model_customization_uuid`), key `fk_allotted_resource_customization__allotted_resource1_idx` (`ar_model_uuid`), @@ -171,6 +172,7 @@ create table `network_resource_customization` ( `network_scope` varchar(45) default null, `creation_timestamp` datetime not null default current_timestamp, `network_resource_model_uuid` varchar(200) not null, + `resource_input` varchar(2000) default null, primary key (`model_customization_uuid`), key `fk_network_resource_customization__network_resource1_idx` (`network_resource_model_uuid`), constraint `fk_network_resource_customization__network_resource1` foreign key (`network_resource_model_uuid`) references `network_resource` (`model_uuid`) on delete cascade on update cascade @@ -207,6 +209,7 @@ create table `service` ( `environment_context` varchar(200) default null, `workload_context` varchar(200) default null, `service_category` varchar(200) default null, + `resource_order` varchar(200) default null, primary key (`model_uuid`), key `fk_service__tosca_csar1_idx` (`tosca_csar_artifact_uuid`), constraint `fk_service__tosca_csar1` foreign key (`tosca_csar_artifact_uuid`) references `tosca_csar` (`artifact_uuid`) on delete cascade on update cascade @@ -396,6 +399,7 @@ create table `vnf_resource_customization` ( `creation_timestamp` datetime not null default current_timestamp, `vnf_resource_model_uuid` varchar(200) not null, `multi_stage_design` varchar(20) default null, + `resource_input` varchar(2000) default null, primary key (`model_customization_uuid`), key `fk_vnf_resource_customization__vnf_resource1_idx` (`vnf_resource_model_uuid`), constraint `fk_vnf_resource_customization__vnf_resource1` foreign key (`vnf_resource_model_uuid`) references `vnf_resource` (`model_uuid`) on delete cascade on update cascade diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql index 381330b928..e1719550b1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql @@ -30,6 +30,7 @@ create table `allotted_resource_customization` ( `min_instances` int(11) default null, `max_instances` int(11) default null, `ar_model_uuid` varchar(200) not null, + `resource_input` varchar(2000) default null, `creation_timestamp` datetime not null default current_timestamp, primary key (`model_customization_uuid`), key `fk_allotted_resource_customization__allotted_resource1_idx` (`ar_model_uuid`), @@ -170,6 +171,7 @@ create table `network_resource_customization` ( `network_scope` varchar(45) default null, `creation_timestamp` datetime not null default current_timestamp, `network_resource_model_uuid` varchar(200) not null, + `resource_input` varchar(2000) default null, primary key (`model_customization_uuid`), key `fk_network_resource_customization__network_resource1_idx` (`network_resource_model_uuid`), constraint `fk_network_resource_customization__network_resource1` foreign key (`network_resource_model_uuid`) references `network_resource` (`model_uuid`) on delete cascade on update cascade @@ -206,6 +208,7 @@ create table `service` ( `environment_context` varchar(200) default null, `workload_context` varchar(200) default null, `service_category` varchar(200) default null, + `resource_order` varchar(200) default null, primary key (`model_uuid`), key `fk_service__tosca_csar1_idx` (`tosca_csar_artifact_uuid`), constraint `fk_service__tosca_csar1` foreign key (`tosca_csar_artifact_uuid`) references `tosca_csar` (`artifact_uuid`) on delete cascade on update cascade @@ -395,6 +398,7 @@ create table `vnf_resource_customization` ( `creation_timestamp` datetime not null default current_timestamp, `vnf_resource_model_uuid` varchar(200) not null, `multi_stage_design` varchar(20) default null, + `resource_input` varchar(2000) default null, primary key (`model_customization_uuid`), key `fk_vnf_resource_customization__vnf_resource1_idx` (`vnf_resource_model_uuid`), constraint `fk_vnf_resource_customization__vnf_resource1` foreign key (`vnf_resource_model_uuid`) references `vnf_resource` (`model_uuid`) on delete cascade on update cascade diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResourceCustomization.java index 00ddf35a5f..04b93c3886 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResourceCustomization.java @@ -93,6 +93,9 @@ public class AllottedResourceCustomization implements Serializable { @Column(name = "MAX_INSTANCES") private Integer maxInstances; + @Column(name = "RESOURCE_INPUT") + private String resourceInput; + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinColumn(name = "AR_MODEL_UUID") private AllottedResource allottedResource; @@ -241,4 +244,12 @@ public class AllottedResourceCustomization implements Serializable { public void setMaxInstances(Integer maxInstances) { this.maxInstances = maxInstances; } + + public String getResourceInput() { + return resourceInput; + } + + public void setResourceInput(String resourceInput) { + this.resourceInput = resourceInput; + } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResourceCustomization.java index 7afeac7710..1e3b6fc220 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResourceCustomization.java @@ -99,6 +99,9 @@ public class NetworkResourceCustomization implements Serializable { @Column(name = "NETWORK_ROLE") private String networkRole; + @Column(name = "RESOURCE_INPUT") + private String resourceInput; + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinColumn(name = "NETWORK_RESOURCE_MODEL_UUID") private NetworkResource networkResource = null; @@ -168,4 +171,12 @@ public class NetworkResourceCustomization implements Serializable { public String getNetworkRole() { return this.networkRole; } + + public String getResourceInput() { + return resourceInput; + } + + public void setResourceInput(String resourceInput) { + this.resourceInput = resourceInput; + } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java index 6eb453805b..28ff778d44 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java @@ -92,6 +92,9 @@ public class Service implements Serializable { @Column(name = "SERVICE_CATEGORY") private String category; + @Column(name = "RESOURCE_ORDER") + private String resourceOrder; + @OneToMany(cascade = CascadeType.ALL) @JoinTable(name = "network_resource_customization_to_service", joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"), inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID")) private List networkCustomizations; @@ -332,4 +335,12 @@ public class Service implements Serializable { public void setWorkloadContext(String workloadContext) { this.workloadContext = workloadContext; } + + public String getResourceOrder() { + return resourceOrder; + } + + public void setResourceOrder(String resourceOrder) { + this.resourceOrder = resourceOrder; + } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java index d286bc0727..53e8c9613e 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java @@ -97,6 +97,9 @@ public class VnfResourceCustomization implements Serializable { @Column(name = "MULTI_STAGE_DESIGN") private String multiStageDesign; + @Column(name = "RESOURCE_INPUT") + private String resourceInput; + @ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name = "VNF_RESOURCE_MODEL_UUID") private VnfResource vnfResources; @@ -283,4 +286,12 @@ public class VnfResourceCustomization implements Serializable { public void setCvnfcCustomization(List cvnfcCustomization) { this.cvnfcCustomization = cvnfcCustomization; } + + public String getResourceInput() { + return resourceInput; + } + + public void setResourceInput(String resourceInput) { + this.resourceInput = resourceInput; + } } diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql index 6eaad260ea..9ee24d78ad 100644 --- a/mso-catalog-db/src/test/resources/schema.sql +++ b/mso-catalog-db/src/test/resources/schema.sql @@ -69,6 +69,7 @@ create table `allotted_resource_customization` ( `min_instances` int(11) default null, `max_instances` int(11) default null, `ar_model_uuid` varchar(200) not null, + `resource_input` varchar(2000) default null, `creation_timestamp` datetime not null default current_timestamp, primary key (`model_customization_uuid`), key `fk_allotted_resource_customization__allotted_resource1_idx` (`ar_model_uuid`), @@ -209,6 +210,7 @@ create table `network_resource_customization` ( `network_scope` varchar(45) default null, `creation_timestamp` datetime not null default current_timestamp, `network_resource_model_uuid` varchar(200) not null, + `resource_input` varchar(2000) default null, primary key (`model_customization_uuid`), key `fk_network_resource_customization__network_resource1_idx` (`network_resource_model_uuid`), constraint `fk_network_resource_customization__network_resource1` foreign key (`network_resource_model_uuid`) references `network_resource` (`model_uuid`) on delete cascade on update cascade @@ -245,6 +247,7 @@ create table `service` ( `environment_context` varchar(200) default null, `workload_context` varchar(200) default null, `service_category` varchar(200) default null, + `resource_order` varchar(200) default null, primary key (`model_uuid`), key `fk_service__tosca_csar1_idx` (`tosca_csar_artifact_uuid`), constraint `fk_service__tosca_csar1` foreign key (`tosca_csar_artifact_uuid`) references `tosca_csar` (`artifact_uuid`) on delete cascade on update cascade @@ -434,6 +437,7 @@ create table `vnf_resource_customization` ( `creation_timestamp` datetime not null default current_timestamp, `vnf_resource_model_uuid` varchar(200) not null, `multi_stage_design` varchar(20) default null, + `resource_input` varchar(2000) default null, primary key (`model_customization_uuid`), key `fk_vnf_resource_customization__vnf_resource1_idx` (`vnf_resource_model_uuid`), constraint `fk_vnf_resource_customization__vnf_resource1` foreign key (`vnf_resource_model_uuid`) references `vnf_resource` (`model_uuid`) on delete cascade on update cascade @@ -744,7 +748,7 @@ create table if not exists `collection_network_resource_customization` ( `network_type` varchar(45) null, `network_role` varchar(200) null, `network_scope` varchar(45) null, -`creation_timestamp` datetime not null default current_timestamp, +`creation_timestamp` datetime not null default current_timestamp, `network_resource_model_uuid` varchar(200) not null, `instance_group_model_uuid` varchar(200) null, `crc_model_customization_uuid` varchar(200) not null, primary key (`model_customization_uuid`, `crc_model_customization_uuid`), -- cgit 1.2.3-korg From 2e5bd7ed14d30437ccd662be63fe117c9702d75f Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Fri, 4 Jan 2019 12:39:08 +0530 Subject: Fix json parsing of resource input Fix json parsing of resource input by adding escape character. Change-Id: Ic19bd5dae5eea25faaeae2df3eb0bcc29482ea7c Issue-ID: SO-1358 Signed-off-by: subhash kumar singh --- .../so/adapters/catalogdb/catalogrest/CatalogQuery.java | 2 +- .../adapters/catalogdb/catalogrest/CatalogDBRestTest.java | 2 ++ .../src/test/resources/db/migration/afterMigrate.sql | 4 ++-- .../so/asdc/installer/heat/ToscaResourceInstaller.java | 1 + .../so/asdc/installer/heat/ToscaResourceInputTest.java | 4 ++-- .../org/onap/so/bpmn/core/domain/AllottedResource.java | 14 ++++++++++++++ .../org/onap/so/bpmn/core/domain/NetworkResource.java | 15 ++++++++++++++- .../org/onap/so/bpmn/core/domain/ServiceInstance.java | 3 +++ .../java/org/onap/so/bpmn/core/domain/VnfResource.java | 13 +++++++++++++ .../onap/so/bpmn/core/domain/AllottedResourceTest.java | 12 ++++++++++++ .../org/onap/so/bpmn/core/domain/NetworkResourceTest.java | 12 ++++++++++++ .../org/onap/so/bpmn/core/domain/ServiceInstanceTest.java | 10 ++++++++++ .../org/onap/so/bpmn/core/domain/VnfResourceTest.java | 11 +++++++++++ 13 files changed, 97 insertions(+), 6 deletions(-) (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java index 63ef8e6dd0..cc1b3ddb17 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java @@ -57,7 +57,7 @@ public abstract class CatalogQuery { while (m.find()) { String key = template.substring(m.start() + 1, m.end() - 1); logger.debug("CatalogQuery key: {} contains key? {}", key , valueMap.containsKey(key)); - m.appendReplacement(result, valueMap.getOrDefault(key, "\"TBD\"")); + m.appendReplacement(result, Matcher.quoteReplacement(valueMap.getOrDefault(key, "\"TBD\""))); } m.appendTail(result); logger.debug("CatalogQuery return: {}", result.toString()); diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java index e15311eb0e..1f51afe143 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java @@ -25,6 +25,8 @@ import static org.junit.Assert.*; import java.io.IOException; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql index 7ac3c53420..663210d6a1 100644 --- a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql +++ b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql @@ -108,8 +108,8 @@ insert into heat_environment(artifact_uuid, name, version, description, body, ar insert into vnf_resource(orchestration_mode, description, creation_timestamp, model_uuid, aic_version_min, aic_version_max, model_invariant_uuid, model_version, model_name, tosca_node_type, heat_template_artifact_uuid) values ('HEAT', '1607 vSAMP10a - inherent network', '2017-04-14 21:46:28', 'ff2ae348-214a-11e7-93ae-92361f002671', '', '', '2fff5b20-214b-11e7-93ae-92361f002671', '1.0', 'vSAMP10a', 'VF', 'ff874603-4222-11e7-9252-005056850d2e'); -insert into vnf_resource_customization(model_customization_uuid, model_instance_name, min_instances, max_instances, availability_zone_max_count, nf_type, nf_role, nf_function, nf_naming_code, creation_timestamp, vnf_resource_model_uuid, multi_stage_design) values -('68dc9a92-214c-11e7-93ae-92361f002671', 'vSAMP10a 1', '0', '0', '0', 'vSAMP', 'vSAMP', 'vSAMP', 'vSAMP', '2017-05-26 15:08:24', 'ff2ae348-214a-11e7-93ae-92361f002671', null); +insert into vnf_resource_customization(model_customization_uuid, model_instance_name, min_instances, max_instances, availability_zone_max_count, nf_type, nf_role, nf_function, nf_naming_code, creation_timestamp, vnf_resource_model_uuid, multi_stage_design, resource_input) values +('68dc9a92-214c-11e7-93ae-92361f002671', 'vSAMP10a 1', '0', '0', '0', 'vSAMP', 'vSAMP', 'vSAMP', 'vSAMP', '2017-05-26 15:08:24', 'ff2ae348-214a-11e7-93ae-92361f002671', null, "{\\\"vf_module_id\\\":\\\"vFirewall\\\",\\\"vfw_private_ip_1\\\":\\\"192.168.20.100\\\",\\\"public_net_id\\\":\\\"PUBLIC NET ID\\\",\\\"vfw_private_ip_0\\\":\\\"192.168.10.100\\\",\\\"onap_private_subnet_id\\\":\\\"PRIVATE NETWORK\\\",\\\"sec_group\\\":\\\"SECURITY GROUP\\\",\\\"vfw_private_ip_2\\\":\\\"10.0.100.1\\\",\\\"vfw_name_0\\\":\\\"zdfw1fwl01fwl01\\\",\\\"nexus_artifact_repo\\\":\\\"https://nexus.onap.org\\\",\\\"onap_private_net_cidr\\\":\\\"10.0.0.0/16\\\",\\\"dcae_collector_ip\\\":\\\"10.0.4.1\\\",\\\"vnf_id\\\":\\\"vFirewall_demo_app\\\",\\\"dcae_collector_port\\\":\\\"8081\\\",\\\"vpg_name_0\\\":\\\"zdfw1fwl01pgn01\\\",\\\"vsn_private_ip_0\\\":\\\"192.168.20.250\\\",\\\"vpg_private_ip_1\\\":\\\"10.0.100.2\\\",\\\"vsn_private_ip_1\\\":\\\"10.0.100.3\\\",\\\"vpg_private_ip_0\\\":\\\"192.168.10.200\\\",\\\"protected_private_net_cidr\\\":\\\"192.168.20.0/24\\\",\\\"unprotected_private_net_cidr\\\":\\\"192.168.10.0/24\\\",\\\"nf_naming\\\":\\\"true\\\",\\\"vsn_name_0\\\":\\\"zdfw1fwl01snk01\\\",\\\"multi_stage_design\\\":\\\"false\\\",\\\"onap_private_net_id\\\":\\\"PRIVATE NETWORK\\\",\\\"unprotected_private_net_id\\\":\\\"zdfw1fwl01_unprotected\\\",\\\"availability_zone_max_count\\\":\\\"1\\\",\\\"vfw_flavor_name\\\":\\\"(m1.medium suggested)\\\",\\\"demo_artifacts_version\\\":\\\"1.3.0-SNAPSHOT\\\",\\\"pub_key\\\":\\\"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQXYJYYi3/OUZXUiCYWdtc7K0m5C0dJKVxPG0eI8EWZrEHYdfYe6WoTSDJCww+1qlBSpA5ac/Ba4Wn9vh+lR1vtUKkyIC/nrYb90ReUd385Glkgzrfh5HdR5y5S2cL/Frh86lAn9r6b3iWTJD8wBwXFyoe1S2nMTOIuG4RPNvfmyCTYVh8XTCCE8HPvh3xv2r4egawG1P4Q4UDwk+hDBXThY2KS8M5/8EMyxHV0ImpLbpYCTBA6KYDIRtqmgS6iKyy8v2D1aSY5mc9J0T5t9S2Gv+VZQNWQDDKNFnxqYaAo1uEoq/i1q63XC5AD3ckXb2VT6dp23BQMdDfbHyUWfJN\\\",\\\"key_name\\\":\\\"vfw_key\\\",\\\"install_script_version\\\":\\\"1.3.0-SNAPSHOT\\\",\\\"vfw_image_name\\\":\\\"(UBUNTU 1404 required)\\\",\\\"protected_private_net_id\\\":\\\"zdfw1fwl01_protected\\\",\\\"cloud_env\\\":\\\"openstack\\\"}"); insert into vf_module(model_uuid, model_invariant_uuid, model_version, model_name, description, is_base, heat_template_artifact_uuid, vol_heat_template_artifact_uuid, creation_timestamp, vnf_resource_model_uuid) values diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java index c26d4ad0b3..51b708d503 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java @@ -459,6 +459,7 @@ public class ToscaResourceInstaller { ObjectMapper objectMapper = new ObjectMapper(); String jsonStr = objectMapper.writeValueAsString(resouceRequest); + jsonStr = jsonStr.replace("\"", "\\\""); logger.debug("resource request for resource customization id (" + resourceCustomizationUuid + ") : " + jsonStr); return jsonStr; } catch (JsonProcessingException e) { diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java index cecf70f916..e738235a0a 100644 --- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java +++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java @@ -104,7 +104,7 @@ public class ToscaResourceInputTest { when(property.getValue()).thenReturn("value1"); String resourceInput = toscaResourceInstaller.getResourceInput(toscaResourceStructure, "id1"); - assertEquals(resourceInput, "{\"prop1\":\"value1\"}"); + assertEquals("{\\\"prop1\\\":\\\"value1\\\"}", resourceInput); } @Test @@ -131,6 +131,6 @@ public class ToscaResourceInputTest { when(input.getDefault()).thenReturn("default_value"); String resourceInput = toscaResourceInstaller.getResourceInput(toscaResourceStructure, "id1"); - assertEquals(resourceInput, "{\"prop1\":\"res_key|default_value\"}"); + assertEquals("{\\\"prop1\\\":\\\"res_key|default_value\\\"}", resourceInput); } } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/AllottedResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/AllottedResource.java index f143346cae..c7c7bba20c 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/AllottedResource.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/AllottedResource.java @@ -22,6 +22,8 @@ package org.onap.so.bpmn.core.domain; import java.util.UUID; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonRootName; /** @@ -55,6 +57,9 @@ public class AllottedResource extends Resource { private String nfNamingCode; private String orchestrationStatus; + @JsonIgnore + private String resourceInput; + /* * GET and SET */ @@ -119,4 +124,13 @@ public class AllottedResource extends Resource { public void setOrchestrationStatus(String orchestrationStatus) { this.orchestrationStatus = orchestrationStatus; } + + + public String getResourceInput() { + return resourceInput; + } + + public void setResourceInput(String resourceInput) { + this.resourceInput = resourceInput; + } } \ No newline at end of file diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/NetworkResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/NetworkResource.java index 20ab3ecc84..f0e97f15ef 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/NetworkResource.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/NetworkResource.java @@ -22,6 +22,8 @@ package org.onap.so.bpmn.core.domain; import java.util.UUID; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonRootName; @@ -47,7 +49,10 @@ public class NetworkResource extends Resource { private String networkRole; private String networkTechnology; private String networkScope; - + + @JsonIgnore + private String resourceInput; + /* * GET and SET */ @@ -75,4 +80,12 @@ public class NetworkResource extends Resource { public void setNetworkScope(String networkScope) { this.networkScope = networkScope; } + + public String getResourceInput() { + return resourceInput; + } + + public void setResourceInput(String resourceInput) { + this.resourceInput = resourceInput; + } } \ No newline at end of file diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceInstance.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceInstance.java index 4295f50a3c..5cdbbcb7c9 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceInstance.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceInstance.java @@ -23,6 +23,8 @@ package org.onap.so.bpmn.core.domain; import java.io.Serializable; import java.util.Map; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonRootName; /** @@ -32,6 +34,7 @@ import com.fasterxml.jackson.annotation.JsonRootName; * @author cb645j * */ +@JsonIgnoreProperties(ignoreUnknown = true) public class ServiceInstance extends JsonWrapper implements Serializable { private static final long serialVersionUID = 1L; diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java index dc76ab0bc7..a7e5389583 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java @@ -25,6 +25,7 @@ import java.util.List; import java.util.UUID; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName; @@ -59,6 +60,9 @@ public class VnfResource extends Resource { private String multiStageDesign; private String orchestrationStatus; + @JsonIgnore + private String resourceInput; + /* * GET and SET */ @@ -123,6 +127,15 @@ public class VnfResource extends Resource { public void setOrchestrationStatus(String orchestrationStatus){ this.orchestrationStatus = orchestrationStatus; } + + public String getResourceInput() { + return resourceInput; + } + + public void setResourceInput(String resourceInput) { + this.resourceInput = resourceInput; + } + /** * Returns a list of all VfModule objects. * Base module is first entry in the list diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/AllottedResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/AllottedResourceTest.java index b1dd8659cd..cca28d411f 100644 --- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/AllottedResourceTest.java +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/AllottedResourceTest.java @@ -21,8 +21,11 @@ package org.onap.so.bpmn.core.domain; import static org.junit.Assert.*; +import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Test; +import java.io.IOException; + public class AllottedResourceTest { private AllottedResource ar = new AllottedResource(); @@ -51,4 +54,13 @@ public class AllottedResourceTest { } + @Test + public void allottedResourceMapperTest() throws IOException { + String jsonStr = "{\"allottedResourceType\": \"code123\", \"resourceInput\": \"sample\"}"; + ObjectMapper objectMapper = new ObjectMapper(); + AllottedResource vnfResource = objectMapper.readValue(jsonStr, AllottedResource.class); + + assertTrue(vnfResource != null); + } + } diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/NetworkResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/NetworkResourceTest.java index 6ca9cef8d2..ee23ebd438 100644 --- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/NetworkResourceTest.java +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/NetworkResourceTest.java @@ -21,8 +21,11 @@ package org.onap.so.bpmn.core.domain; import static org.junit.Assert.*; +import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Test; +import java.io.IOException; + public class NetworkResourceTest { private NetworkResource nr = new NetworkResource(); @@ -39,4 +42,13 @@ public class NetworkResourceTest { } + @Test + public void networkResourceMapperTest() throws IOException { + String jsonStr = "{\"networkScope\": \"code123\", \"resourceInput\": \"sample\"}"; + ObjectMapper objectMapper = new ObjectMapper(); + NetworkResource networkResource = objectMapper.readValue(jsonStr, NetworkResource.class); + + assertTrue(networkResource != null); + } + } diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceInstanceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceInstanceTest.java index 7cacc9da88..c04dc9d601 100644 --- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceInstanceTest.java +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceInstanceTest.java @@ -21,8 +21,10 @@ package org.onap.so.bpmn.core.domain; import static org.junit.Assert.*; +import java.io.IOException; import java.util.Map; +import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Test; public class ServiceInstanceTest { @@ -58,4 +60,12 @@ public class ServiceInstanceTest { } + @Test + public void serviceInstanceMapperTest() throws IOException { + String jsonStr = "{\"workloadContext\": \"code123\", \"resourceOrder\": \"sample\"}"; + ObjectMapper objectMapper = new ObjectMapper(); + ServiceInstance serviceInstance = objectMapper.readValue(jsonStr, ServiceInstance.class); + assertTrue(serviceInstance != null); + } + } diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java index 24947e9a8d..a83337fc5b 100644 --- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java @@ -21,8 +21,10 @@ package org.onap.so.bpmn.core.domain; import static org.junit.Assert.*; +import java.io.IOException; import java.util.List; +import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Test; public class VnfResourceTest { @@ -52,4 +54,13 @@ public class VnfResourceTest { } + @Test + public void vnfResourceMapperTest() throws IOException { + String jsonStr = "{\"vnfHostname\": \"home\", \"resourceInput\": \"sample\"}"; + ObjectMapper objectMapper = new ObjectMapper(); + VnfResource vnfResource = objectMapper.readValue(jsonStr, VnfResource.class); + + assertTrue(vnfResource != null); + } + } -- cgit 1.2.3-korg From f6f326e8fba5d2b208a8530f9ec292b3cd351895 Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Thu, 17 Jan 2019 14:28:43 +0530 Subject: Change size for resource input Change size for resource input. Change-Id: Ic6856e6baa2623867d0ae688c98ed24dbb245036 Issue-ID: SO-1400 Signed-off-by: subhash kumar singh --- .../db/migration/V4.23__ChangeResourceInputLength.sql | 10 ++++++++++ adapters/mso-openstack-adapters/src/test/resources/schema.sql | 6 +++--- asdc-controller/src/test/resources/schema.sql | 6 +++--- .../mso-api-handler-infra/src/test/resources/schema.sql | 6 +++--- mso-catalog-db/src/test/resources/schema.sql | 6 +++--- 5 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.23__ChangeResourceInputLength.sql (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.23__ChangeResourceInputLength.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.23__ChangeResourceInputLength.sql new file mode 100644 index 0000000000..dfb5075674 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.23__ChangeResourceInputLength.sql @@ -0,0 +1,10 @@ +use catalogdb; + +ALTER TABLE vnf_resource_customization + MODIFY IF EXISTS RESOURCE_INPUT varchar(20000); + +ALTER TABLE network_resource_customization + MODIFY IF EXISTS RESOURCE_INPUT varchar(20000); + +ALTER TABLE allotted_resource_customization + MODIFY IF EXISTS RESOURCE_INPUT varchar(20000); \ No newline at end of file diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql index eff5c632fa..58083abba1 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql +++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql @@ -28,7 +28,7 @@ create table `allotted_resource_customization` ( `min_instances` int(11) default null, `max_instances` int(11) default null, `ar_model_uuid` varchar(200) not null, - `resource_input` varchar(2000) default null, + `resource_input` varchar(20000) default null, `creation_timestamp` datetime not null default current_timestamp, primary key (`model_customization_uuid`), key `fk_allotted_resource_customization__allotted_resource1_idx` (`ar_model_uuid`), @@ -169,7 +169,7 @@ create table `network_resource_customization` ( `network_scope` varchar(45) default null, `creation_timestamp` datetime not null default current_timestamp, `network_resource_model_uuid` varchar(200) not null, - `resource_input` varchar(2000) default null, + `resource_input` varchar(20000) default null, primary key (`model_customization_uuid`), key `fk_network_resource_customization__network_resource1_idx` (`network_resource_model_uuid`), constraint `fk_network_resource_customization__network_resource1` foreign key (`network_resource_model_uuid`) references `network_resource` (`model_uuid`) on delete cascade on update cascade @@ -384,7 +384,7 @@ create table `vnf_resource_customization` ( `creation_timestamp` datetime not null default current_timestamp, `vnf_resource_model_uuid` varchar(200) not null, `multi_stage_design` varchar(20) default null, - `resource_input` varchar(2000) default null, + `resource_input` varchar(20000) default null, primary key (`model_customization_uuid`), key `fk_vnf_resource_customization__vnf_resource1_idx` (`vnf_resource_model_uuid`), constraint `fk_vnf_resource_customization__vnf_resource1` foreign key (`vnf_resource_model_uuid`) references `vnf_resource` (`model_uuid`) on delete cascade on update cascade diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql index 58772c4998..020155be65 100644 --- a/asdc-controller/src/test/resources/schema.sql +++ b/asdc-controller/src/test/resources/schema.sql @@ -31,7 +31,7 @@ create table `allotted_resource_customization` ( `min_instances` int(11) default null, `max_instances` int(11) default null, `ar_model_uuid` varchar(200) not null, - `resource_input` varchar(2000) default null, + `resource_input` varchar(20000) default null, `creation_timestamp` datetime not null default current_timestamp, primary key (`model_customization_uuid`), key `fk_allotted_resource_customization__allotted_resource1_idx` (`ar_model_uuid`), @@ -172,7 +172,7 @@ create table `network_resource_customization` ( `network_scope` varchar(45) default null, `creation_timestamp` datetime not null default current_timestamp, `network_resource_model_uuid` varchar(200) not null, - `resource_input` varchar(2000) default null, + `resource_input` varchar(20000) default null, primary key (`model_customization_uuid`), key `fk_network_resource_customization__network_resource1_idx` (`network_resource_model_uuid`), constraint `fk_network_resource_customization__network_resource1` foreign key (`network_resource_model_uuid`) references `network_resource` (`model_uuid`) on delete cascade on update cascade @@ -399,7 +399,7 @@ create table `vnf_resource_customization` ( `creation_timestamp` datetime not null default current_timestamp, `vnf_resource_model_uuid` varchar(200) not null, `multi_stage_design` varchar(20) default null, - `resource_input` varchar(2000) default null, + `resource_input` varchar(20000) default null, primary key (`model_customization_uuid`), key `fk_vnf_resource_customization__vnf_resource1_idx` (`vnf_resource_model_uuid`), constraint `fk_vnf_resource_customization__vnf_resource1` foreign key (`vnf_resource_model_uuid`) references `vnf_resource` (`model_uuid`) on delete cascade on update cascade diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql index e1719550b1..fe81fbcf92 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql @@ -30,7 +30,7 @@ create table `allotted_resource_customization` ( `min_instances` int(11) default null, `max_instances` int(11) default null, `ar_model_uuid` varchar(200) not null, - `resource_input` varchar(2000) default null, + `resource_input` varchar(20000) default null, `creation_timestamp` datetime not null default current_timestamp, primary key (`model_customization_uuid`), key `fk_allotted_resource_customization__allotted_resource1_idx` (`ar_model_uuid`), @@ -171,7 +171,7 @@ create table `network_resource_customization` ( `network_scope` varchar(45) default null, `creation_timestamp` datetime not null default current_timestamp, `network_resource_model_uuid` varchar(200) not null, - `resource_input` varchar(2000) default null, + `resource_input` varchar(20000) default null, primary key (`model_customization_uuid`), key `fk_network_resource_customization__network_resource1_idx` (`network_resource_model_uuid`), constraint `fk_network_resource_customization__network_resource1` foreign key (`network_resource_model_uuid`) references `network_resource` (`model_uuid`) on delete cascade on update cascade @@ -398,7 +398,7 @@ create table `vnf_resource_customization` ( `creation_timestamp` datetime not null default current_timestamp, `vnf_resource_model_uuid` varchar(200) not null, `multi_stage_design` varchar(20) default null, - `resource_input` varchar(2000) default null, + `resource_input` varchar(20000) default null, primary key (`model_customization_uuid`), key `fk_vnf_resource_customization__vnf_resource1_idx` (`vnf_resource_model_uuid`), constraint `fk_vnf_resource_customization__vnf_resource1` foreign key (`vnf_resource_model_uuid`) references `vnf_resource` (`model_uuid`) on delete cascade on update cascade diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql index 9ee24d78ad..bd19c77e44 100644 --- a/mso-catalog-db/src/test/resources/schema.sql +++ b/mso-catalog-db/src/test/resources/schema.sql @@ -69,7 +69,7 @@ create table `allotted_resource_customization` ( `min_instances` int(11) default null, `max_instances` int(11) default null, `ar_model_uuid` varchar(200) not null, - `resource_input` varchar(2000) default null, + `resource_input` varchar(20000) default null, `creation_timestamp` datetime not null default current_timestamp, primary key (`model_customization_uuid`), key `fk_allotted_resource_customization__allotted_resource1_idx` (`ar_model_uuid`), @@ -210,7 +210,7 @@ create table `network_resource_customization` ( `network_scope` varchar(45) default null, `creation_timestamp` datetime not null default current_timestamp, `network_resource_model_uuid` varchar(200) not null, - `resource_input` varchar(2000) default null, + `resource_input` varchar(20000) default null, primary key (`model_customization_uuid`), key `fk_network_resource_customization__network_resource1_idx` (`network_resource_model_uuid`), constraint `fk_network_resource_customization__network_resource1` foreign key (`network_resource_model_uuid`) references `network_resource` (`model_uuid`) on delete cascade on update cascade @@ -437,7 +437,7 @@ create table `vnf_resource_customization` ( `creation_timestamp` datetime not null default current_timestamp, `vnf_resource_model_uuid` varchar(200) not null, `multi_stage_design` varchar(20) default null, - `resource_input` varchar(2000) default null, + `resource_input` varchar(20000) default null, primary key (`model_customization_uuid`), key `fk_vnf_resource_customization__vnf_resource1_idx` (`vnf_resource_model_uuid`), constraint `fk_vnf_resource_customization__vnf_resource1` foreign key (`vnf_resource_model_uuid`) references `vnf_resource` (`model_uuid`) on delete cascade on update cascade -- cgit 1.2.3-korg From d5f5d0d06b7838d14b8776d8273a62ca3eb99355 Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Tue, 22 Jan 2019 12:56:29 +0530 Subject: Fix CSAR distribution on CCVPN service Fix db schema to allow CCVPN service witout heat artifacts. Change-Id: I4f79881a6a04f01f8984835eea88907a61c640db Issue-ID: SO-1407 Signed-off-by: subhash kumar singh --- .../db/migration/V4.24__UpdateHeatRelatedAttribute.sql | 5 +++++ adapters/mso-openstack-adapters/src/test/resources/schema.sql | 7 +++---- asdc-controller/src/test/resources/schema.sql | 7 +++---- .../mso-api-handler-infra/src/test/resources/schema.sql | 7 +++---- mso-catalog-db/src/test/resources/schema.sql | 11 +++++------ 5 files changed, 19 insertions(+), 18 deletions(-) create mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.24__UpdateHeatRelatedAttribute.sql (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.24__UpdateHeatRelatedAttribute.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.24__UpdateHeatRelatedAttribute.sql new file mode 100644 index 0000000000..b1aefaf56c --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.24__UpdateHeatRelatedAttribute.sql @@ -0,0 +1,5 @@ +use catalogdb; + +ALTER TABLE network_resource MODIFY COLUMN AIC_VERSION_MIN varchar(20) NULL; +ALTER TABLE network_resource MODIFY COLUMN HEAT_TEMPLATE_ARTIFACT_UUID varchar(200) NULL; +ALTER TABLE network_resource DROP FOREIGN KEY fk_network_resource__temp_network_heat_template_lookup__mod_nm1; \ No newline at end of file diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql index 58083abba1..f0dfc16bd0 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql +++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql @@ -139,11 +139,11 @@ create table `network_resource` ( `model_name` varchar(200) not null, `model_invariant_uuid` varchar(200) default null, `description` varchar(1200) default null, - `heat_template_artifact_uuid` varchar(200) not null, + `heat_template_artifact_uuid` varchar(200) null, `neutron_network_type` varchar(20) default null, `model_version` varchar(20) default null, `tosca_node_type` varchar(200) default null, - `aic_version_min` varchar(20) not null, + `aic_version_min` varchar(20) null, `aic_version_max` varchar(20) default null, `orchestration_mode` varchar(20) default 'heat', `resource_category` varchar(20) default null, @@ -152,8 +152,7 @@ create table `network_resource` ( primary key (`model_uuid`), key `fk_network_resource__temp_network_heat_template_lookup1_idx` (`model_name`), key `fk_network_resource__heat_template1_idx` (`heat_template_artifact_uuid`), - constraint `fk_network_resource__heat_template1` foreign key (`heat_template_artifact_uuid`) references `heat_template` (`artifact_uuid`) on delete no action on update cascade, - constraint `fk_network_resource__temp_network_heat_template_lookup__mod_nm1` foreign key (`model_name`) references `temp_network_heat_template_lookup` (`network_resource_model_name`) on delete no action on update no action + constraint `fk_network_resource__heat_template1` foreign key (`heat_template_artifact_uuid`) references `heat_template` (`artifact_uuid`) on delete no action on update cascade ) engine=innodb default charset=latin1; diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql index 020155be65..9254780291 100644 --- a/asdc-controller/src/test/resources/schema.sql +++ b/asdc-controller/src/test/resources/schema.sql @@ -142,11 +142,11 @@ create table `network_resource` ( `model_name` varchar(200) not null, `model_invariant_uuid` varchar(200) default null, `description` varchar(1200) default null, - `heat_template_artifact_uuid` varchar(200) not null, + `heat_template_artifact_uuid` varchar(200) null, `neutron_network_type` varchar(20) default null, `model_version` varchar(20) default null, `tosca_node_type` varchar(200) default null, - `aic_version_min` varchar(20) not null, + `aic_version_min` varchar(20) null, `aic_version_max` varchar(20) default null, `orchestration_mode` varchar(20) default 'heat', `resource_category` varchar(20) default null, @@ -155,8 +155,7 @@ create table `network_resource` ( primary key (`model_uuid`), key `fk_network_resource__temp_network_heat_template_lookup1_idx` (`model_name`), key `fk_network_resource__heat_template1_idx` (`heat_template_artifact_uuid`), - constraint `fk_network_resource__heat_template1` foreign key (`heat_template_artifact_uuid`) references `heat_template` (`artifact_uuid`) on delete no action on update cascade, - constraint `fk_network_resource__temp_network_heat_template_lookup__mod_nm1` foreign key (`model_name`) references `temp_network_heat_template_lookup` (`network_resource_model_name`) on delete no action on update no action + constraint `fk_network_resource__heat_template1` foreign key (`heat_template_artifact_uuid`) references `heat_template` (`artifact_uuid`) on delete no action on update cascade ) engine=innodb default charset=latin1; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql index fe81fbcf92..98b26a4be2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql @@ -141,11 +141,11 @@ create table `network_resource` ( `model_name` varchar(200) not null, `model_invariant_uuid` varchar(200) default null, `description` varchar(1200) default null, - `heat_template_artifact_uuid` varchar(200) not null, + `heat_template_artifact_uuid` varchar(200) null, `neutron_network_type` varchar(20) default null, `model_version` varchar(20) default null, `tosca_node_type` varchar(200) default null, - `aic_version_min` varchar(20) not null, + `aic_version_min` varchar(20) null, `aic_version_max` varchar(20) default null, `orchestration_mode` varchar(20) default 'heat', `resource_category` varchar(20) default null, @@ -154,8 +154,7 @@ create table `network_resource` ( primary key (`model_uuid`), key `fk_network_resource__temp_network_heat_template_lookup1_idx` (`model_name`), key `fk_network_resource__heat_template1_idx` (`heat_template_artifact_uuid`), - constraint `fk_network_resource__heat_template1` foreign key (`heat_template_artifact_uuid`) references `heat_template` (`artifact_uuid`) on delete no action on update cascade, - constraint `fk_network_resource__temp_network_heat_template_lookup__mod_nm1` foreign key (`model_name`) references `temp_network_heat_template_lookup` (`network_resource_model_name`) on delete no action on update no action + constraint `fk_network_resource__heat_template1` foreign key (`heat_template_artifact_uuid`) references `heat_template` (`artifact_uuid`) on delete no action on update cascade ) engine=innodb default charset=latin1; diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql index bd19c77e44..221f0d8df6 100644 --- a/mso-catalog-db/src/test/resources/schema.sql +++ b/mso-catalog-db/src/test/resources/schema.sql @@ -165,8 +165,8 @@ create table `network_recipe` ( create table `temp_network_heat_template_lookup` ( `network_resource_model_name` varchar(200) not null, - `heat_template_artifact_uuid` varchar(200) not null, - `aic_version_min` varchar(20) not null, + `heat_template_artifact_uuid` varchar(200) null, + `aic_version_min` varchar(20) null, `aic_version_max` varchar(20) default null, primary key (`network_resource_model_name`), key `fk_temp_network_heat_template_lookup__heat_template1_idx` (`heat_template_artifact_uuid`), @@ -180,11 +180,11 @@ create table `network_resource` ( `model_name` varchar(200) not null, `model_invariant_uuid` varchar(200) default null, `description` varchar(1200) default null, - `heat_template_artifact_uuid` varchar(200) not null, + `heat_template_artifact_uuid` varchar(200) null, `neutron_network_type` varchar(20) default null, `model_version` varchar(20) default null, `tosca_node_type` varchar(200) default null, - `aic_version_min` varchar(20) not null, + `aic_version_min` varchar(20) null, `aic_version_max` varchar(20) default null, `orchestration_mode` varchar(20) default 'heat', `resource_category` varchar(20) default null, @@ -193,8 +193,7 @@ create table `network_resource` ( primary key (`model_uuid`), key `fk_network_resource__temp_network_heat_template_lookup1_idx` (`model_name`), key `fk_network_resource__heat_template1_idx` (`heat_template_artifact_uuid`), - constraint `fk_network_resource__heat_template1` foreign key (`heat_template_artifact_uuid`) references `heat_template` (`artifact_uuid`) on delete no action on update cascade, - constraint `fk_network_resource__temp_network_heat_template_lookup__mod_nm1` foreign key (`model_name`) references `temp_network_heat_template_lookup` (`network_resource_model_name`) on delete no action on update no action + constraint `fk_network_resource__heat_template1` foreign key (`heat_template_artifact_uuid`) references `heat_template` (`artifact_uuid`) on delete no action on update cascade ) engine=innodb default charset=latin1; -- cgit 1.2.3-korg From 402f8dc916e938a55dd54f721b3ce3928a7409a0 Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Wed, 23 Jan 2019 16:42:13 +0530 Subject: Fix get of operationType OperationType should return empty from db request instead of "null". Change-Id: I5df3df5aead6008c4e14961ee385cafe64c37959 Issue-ID: SO-1417 Signed-off-by: subhash kumar singh --- .../catalogdb/catalogrest/QueryResourceRecipe.java | 19 ++++++++++------ .../catalogrest/QueryResourceRecipeTest.java | 25 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-) (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java index 8670b78e15..58a2e852f0 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java @@ -22,6 +22,7 @@ package org.onap.so.adapters.catalogdb.catalogrest; import java.util.HashMap; import java.util.Map; +import org.apache.commons.lang3.StringUtils; import org.onap.so.db.catalog.beans.Recipe; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,12 +57,18 @@ public class QueryResourceRecipe extends CatalogQuery{ @Override public String JSON2(boolean isArray, boolean isEmbed) { Map valueMap = new HashMap<>(); - valueMap.put("id", null == resourceRecipe ? null :String.valueOf(resourceRecipe.getId())); - valueMap.put("action", null == resourceRecipe ? null :resourceRecipe.getAction()); - valueMap.put("orchestrationUri", null == resourceRecipe ? null : resourceRecipe.getOrchestrationUri()); - valueMap.put("recipeTimeout", null == resourceRecipe ? null : String.valueOf(resourceRecipe.getRecipeTimeout())); - valueMap.put("paramXSD", null == resourceRecipe ? null : resourceRecipe.getParamXsd()); - valueMap.put("description", null == resourceRecipe ? null : resourceRecipe.getDescription()); + valueMap.put("id", null == resourceRecipe || null == resourceRecipe.getId() + ? StringUtils.EMPTY :String.valueOf(resourceRecipe.getId())); + valueMap.put("action", null == resourceRecipe || null == resourceRecipe.getAction() + ? StringUtils.EMPTY :resourceRecipe.getAction()); + valueMap.put("orchestrationUri", null == resourceRecipe || null == resourceRecipe.getOrchestrationUri() + ? StringUtils.EMPTY : resourceRecipe.getOrchestrationUri()); + valueMap.put("recipeTimeout", null == resourceRecipe || null == resourceRecipe.getRecipeTimeout() + ? StringUtils.EMPTY : String.valueOf(resourceRecipe.getRecipeTimeout())); + valueMap.put("paramXSD", null == resourceRecipe || null == resourceRecipe.getParamXsd() + ? StringUtils.EMPTY : resourceRecipe.getParamXsd()); + valueMap.put("description", null == resourceRecipe || null == resourceRecipe.getDescription() + ? StringUtils.EMPTY : resourceRecipe.getDescription()); ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); String jsonStr = ""; diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java index 645714cc80..e403867c42 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java @@ -21,11 +21,16 @@ package org.onap.so.adapters.catalogdb.catalogrest; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.onap.so.db.catalog.beans.ArRecipe; +import org.onap.so.db.catalog.beans.NetworkRecipe; import org.onap.so.db.catalog.beans.Recipe; import org.onap.so.db.catalog.beans.ServiceRecipe; +import org.onap.so.db.catalog.beans.VnfRecipe; import org.onap.so.jsonpath.JsonPathUtil; public class QueryResourceRecipeTest { @@ -67,4 +72,24 @@ public class QueryResourceRecipeTest { return recipe; } + @Test + public void convertToJson() { + Recipe recipe = createRecipe(); + QueryResourceRecipe queryResourceRecipe = new QueryResourceRecipe(recipe); + assertEquals("{\"orchestrationUri\":\"uriTest\",\"action\":\"actionTest\",\"description\":\"descrTest\",\"id\":\"123\",\"recipeTimeout\":\"100\",\"paramXSD\":\"paramsXsdTest\"}", + queryResourceRecipe.JSON2(false,false)); + } + + @Test + public void convertToJsonEmptyRecipe() { + QueryResourceRecipe vnfQueryRR = new QueryResourceRecipe(new VnfRecipe()); + QueryResourceRecipe networkQueryRR = new QueryResourceRecipe(new NetworkRecipe()); + QueryResourceRecipe arQueryRR = new QueryResourceRecipe(new ArRecipe()); + + String expected = "{\"orchestrationUri\":\"\",\"action\":\"\",\"description\":\"\",\"id\":\"\",\"recipeTimeout\":\"\",\"paramXSD\":\"\"}"; + assertEquals(expected, vnfQueryRR.JSON2(false, false)); + assertEquals(expected, networkQueryRR.JSON2(false,false)); + assertEquals(expected, arQueryRR.JSON2(false,false)); + } + } -- cgit 1.2.3-korg From 1d602253b5a2a0dde15c672875515619460337bd Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Thu, 24 Jan 2019 17:00:09 +0530 Subject: Fix AR receipe retrival Fix AR receipe retrival. Change-Id: I5675fef17c1ee6375dd6c68a311d5f0568438879 Issue-ID: SO-1422 Signed-off-by: subhash kumar singh --- .../catalogdb/rest/CatalogDbAdapterRest.java | 15 +++++--- .../catalogdb/catalogrest/CatalogDBRestTest.java | 40 ++++++++++++++++++++++ .../test/resources/db/migration/afterMigrate.sql | 10 +++++- 3 files changed, 59 insertions(+), 6 deletions(-) (limited to 'adapters/mso-catalog-db-adapter/src/main') diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java index 9bcbe16af2..dbb168bd15 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java @@ -588,17 +588,22 @@ public class CatalogDbAdapterRest { if (null == recipe) { NetworkResource nResource = networkResourceRepo.findResourceByModelUUID(rmUuid); - recipe = networkRecipeRepo.findFirstByModelNameAndActionAndVersionStr(nResource.getModelName(), action, nResource.getModelVersion()); - // for network fetch the default recipe - if (recipe == null) { - recipe = networkRecipeRepo.findFirstByModelNameAndAction("SDNC_DEFAULT", action); + if(nResource != null) { + recipe = networkRecipeRepo.findFirstByModelNameAndActionAndVersionStr(nResource.getModelName(), action, nResource.getModelVersion()); + + // for network fetch the default recipe + if (recipe == null) { + recipe = networkRecipeRepo.findFirstByModelNameAndAction("SDNC_DEFAULT", action); + } } } if (null == recipe) { AllottedResource arResource = arResourceRepo.findResourceByModelUUID(rmUuid); - recipe = arRecipeRepo.findByModelNameAndActionAndVersion(arResource.getModelName(), action, arResource.getModelVersion()); + if (arResource != null) { + recipe = arRecipeRepo.findByModelNameAndActionAndVersion(arResource.getModelName(), action, arResource.getModelVersion()); + } } if (recipe != null) { QueryResourceRecipe resourceRecipe = new QueryResourceRecipe(recipe); diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java index 1f51afe143..5555a72b36 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java @@ -67,6 +67,8 @@ public class CatalogDBRestTest { private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES = "ecomp/mso/catalog/v2/serviceAllottedResources"; + private static final String ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE = "ecomp/mso/catalog/v2/resourceRecipe"; + private static final String ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS = "ecomp/mso/catalog/v2/serviceNetworks"; private static final String ECOMP_MSO_CATALOG_V2_SERVICE_VNFS = "ecomp/mso/catalog/v2/serviceVnfs"; @@ -96,6 +98,8 @@ public class CatalogDBRestTest { private final String expectedAllottedResponse = "{\r\n\"serviceAllottedResources\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}\r\n]\r\n}"; private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671"; + + private final String arResourceUUID = "25e2d69b-3b22-47b8-b4c9-7b14fd4a80df"; private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671"; @@ -650,6 +654,42 @@ public class CatalogDBRestTest { assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false); } + + @Test + public void testResourceReceipe() throws JSONException { + String expectedResourceRecipe = "{\"orchestrationUri\":\"/mso/async/services/CreateSDNCNetworkResource\",\"action\":\"createInstance\",\"description\":\"sotnvpnattachmentvF\",\"id\":\"1\",\"recipeTimeout\":\"180\",\"paramXSD\":\"\"}"; + + HttpEntity entity = new HttpEntity(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE)) + .queryParam("resourceModelUuid", arResourceUUID) + .queryParam("action", "createInstance"); + + ResponseEntity response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedResourceRecipe, response.getBody().toString(), false); + } + + @Test + public void testResourceReceipeNotMatched() throws JSONException { + + HttpEntity entity = new HttpEntity(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE)) + .queryParam("resourceModelUuid", arResourceUUID) + .queryParam("action", "invalid_action"); + + ResponseEntity response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value()); + } @Test public void testGetServiceAllottedResourcesByServiceModelInvariantUuid() throws JSONException { diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql index 663210d6a1..5b2ba3d11a 100644 --- a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql +++ b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql @@ -215,4 +215,12 @@ VALUES insert into homing_instances (service_instance_id, cloud_owner, cloud_region_id, oof_directives) values ('5df8b6de-2083-11e7-93ae-92361f232671', 'CloudOwner', 'CloudRegionId', '{"directives": [{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "firewall_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vfw"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor33","attribute_name": "packetgen_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vgenerator"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "sink_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vsink"}]}'), -('5df8b6de-2083-11e7-93ae-92361f562672', 'CloudOwner', 'CloudRegionId', '{"directives": [{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "firewall_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vfw"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor33","attribute_name": "packetgen_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vgenerator"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "sink_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vsink"}]}'); \ No newline at end of file +('5df8b6de-2083-11e7-93ae-92361f562672', 'CloudOwner', 'CloudRegionId', '{"directives": [{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "firewall_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vfw"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor33","attribute_name": "packetgen_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vgenerator"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "sink_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vsink"}]}'); + +-- for query resource receipe +INSERT INTO allotted_resource +(MODEL_UUID, MODEL_INVARIANT_UUID, MODEL_VERSION, MODEL_NAME, TOSCA_NODE_TYPE, SUBCATEGORY, DESCRIPTION, CREATION_TIMESTAMP) +VALUES('25e2d69b-3b22-47b8-b4c9-7b14fd4a80df', '8f5fe343-9a3a-4d31-a829-49b27bbfc1c4', '2.0', 'sotnvpnattachmentvF', 'org.openecomp.resource.vf.Sdwanvpnattachmentvf', 'Allotted Resource', 'sdwanvpnattachmentVF', '2019-01-24 09:59:16.000'); + +INSERT INTO ar_recipe(ID, MODEL_NAME, ACTION, VERSION_STR, SERVICE_TYPE, DESCRIPTION, ORCHESTRATION_URI, AR_PARAM_XSD, RECIPE_TIMEOUT, CREATION_TIMESTAMP) +VALUES(1, 'sotnvpnattachmentvF', 'createInstance', '2.0', 'VF', 'sotnvpnattachmentvF', '/mso/async/services/CreateSDNCNetworkResource', '', 180, '2019-01-24 09:59:16.000'); -- cgit 1.2.3-korg