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') 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 0f76551ead270d92d9933eab58d088e49b1e766c Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Fri, 9 Nov 2018 15:56:17 -0800 Subject: Fix OOF Directives processing - Various fixes to process OOF directives correctly - Add orchestrator userParam Processing to ala carte and vCPE path to ensure multicloud adapter can be called when homing - Fix JsonUtils to accept json object as well as strings - Adds JsonUtils unit tests to ensure json object code works correctly and didn't break previous func. - Fix OOF Homing codes processing of OOF response to match Casablanca response from OOF (including OOF directives) - Add CloudIdentity get and put to catalogDBClient, along with junit tests - to enable creation of cloudSites - Fix serviceResourceId check Issue-ID: SO-1203 Change-Id: Ice9a9d1da2ce0cd4bd11029e3669b30d658fe359 Signed-off-by: Marcus G K Williams --- .../catalogdb/catalogrest/CloudConfigTest.java | 8 +- .../so/db/catalog/client/CatalogDbClientTest.java | 1 + .../onap/so/bpmn/common/scripts/OofHoming.groovy | 71 +++++++++---- .../onap/so/bpmn/common/scripts/OofUtils.groovy | 46 +++------ .../java/org/onap/so/bpmn/core/json/JsonUtils.java | 4 +- .../org/onap/so/bpmn/core/json/JsonUtilsTest.java | 14 ++- .../test/resources/json-examples/OofExample.json | 110 +++++++++++++++++++++ .../CreateGenericALaCarteServiceInstance.groovy | 8 ++ .../vcpe/scripts/CreateVcpeResCustService.groovy | 4 + .../onap/so/db/catalog/beans/CloudIdentity.java | 1 + .../onap/so/db/catalog/client/CatalogDbClient.java | 1 - 11 files changed, 212 insertions(+), 56 deletions(-) create mode 100644 bpmn/MSOCoreBPMN/src/test/resources/json-examples/OofExample.json (limited to 'adapters') diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java index 0606848b04..eb2d3753d9 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java @@ -63,14 +63,14 @@ public class CloudConfigTest { headers.set("Content-Type",MediaType.APPLICATION_JSON); CloudSite cloudSite = new CloudSite(); - cloudSite.setId("MTN6"); + cloudSite.setId("MTN7"); cloudSite.setClli("TESTCLLI"); cloudSite.setRegionId("regionId"); cloudSite.setCloudVersion("VERSION"); cloudSite.setPlatform("PLATFORM"); CloudIdentity cloudIdentity = new CloudIdentity(); - cloudIdentity.setId("RANDOMID"); + cloudIdentity.setId("RANDOMID-test"); cloudIdentity.setIdentityUrl("URL"); cloudIdentity.setMsoId("MSO_ID"); cloudIdentity.setMsoPass("MSO_PASS"); @@ -81,7 +81,7 @@ public class CloudConfigTest { cloudSite.setIdentityService(cloudIdentity); String uri = "/cloudSite"; UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:"+ port + uri); - HttpEntity request = new HttpEntity(cloudSite, headers); + HttpEntity request = new HttpEntity(cloudSite, headers); ResponseEntity response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, request, String.class); assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusCode().value()); @@ -96,4 +96,6 @@ public class CloudConfigTest { } + + } 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 5e2bd82776..c85a4c28f5 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 @@ -413,6 +413,7 @@ public class CatalogDbClientTest { Assert.assertEquals("regionId", getCloudSite.getRegionId()); Assert.assertEquals("RANDOMID", getCloudSite.getIdentityServiceId()); } + @Test public void testGetServiceByModelName() { Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service"); 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 806a144a48..c50ef3530e 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 @@ -30,8 +30,10 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition 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.AuthenticationType import org.onap.so.db.catalog.beans.CloudIdentity import org.onap.so.db.catalog.beans.CloudSite +import org.onap.so.db.catalog.beans.ServerType import org.onap.so.rest.APIResponse import org.onap.so.rest.RESTClient import org.onap.so.rest.RESTConfig @@ -211,17 +213,12 @@ class OofHoming extends AbstractServiceTaskProcessor { for (int j = 0; j < arrSol.length(); j++) { JSONObject placement = arrSol.getJSONObject(j) utils.log("DEBUG", "****** Placement Solution is: " + placement + " *****", "true") - String jsonServiceResourceId = placement.getString("serviceResourceId") - String jsonResourceModuleName = placement.getString("resourceModuleName") + String jsonServiceResourceId = jsonUtil.getJsonValue( placement.toString(), "serviceResourceId") + utils.log("DEBUG", "****** homing serviceResourceId is: " + jsonServiceResourceId + " *****", "true") for (Resource resource : resourceList) { String serviceResourceId = resource.getResourceId() - String resourceModuleName = "" - if (resource.getResourceType() == ResourceType.ALLOTTED_RESOURCE || - resource.getResourceType() == ResourceType.VNF) { - resourceModuleName = resource.getNfFunction() - } - if (serviceResourceId.equalsIgnoreCase(jsonServiceResourceId) || - resourceModuleName.equalsIgnoreCase(jsonResourceModuleName)) { + utils.log("DEBUG", "****** decomp serviceResourceId is: " + serviceResourceId + " *****", "true") + if (serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)) { JSONObject solution = placement.getJSONObject("solution") String solutionType = solution.getString("identifierType") String inventoryType = "" @@ -230,20 +227,26 @@ class OofHoming extends AbstractServiceTaskProcessor { } else { inventoryType = "cloud" } + utils.log("DEBUG", "****** homing inventoryType is: " + inventoryType + " *****", "true") resource.getHomingSolution().setInventoryType(InventoryType.valueOf(inventoryType)) JSONArray assignmentArr = placement.getJSONArray("assignmentInfo") + utils.log("DEBUG", "****** assignmentInfo is: " + assignmentArr.toString() + " *****", "true") + + Map assignmentMap = jsonUtil.entryArrayToMap(execution, + assignmentArr.toString(), "key", "value") String oofDirectives = null - assignmentArr.each { element -> - JSONObject jsonObject = new JSONObject(element.toString()) - if (jsonUtil.getJsonRawValue(jsonObject.toString(), "key") == "oof_directives") { - oofDirectives = jsonUtil.getJsonRawValue(jsonObject.toString(), "value") + assignmentMap.each { key, value -> + utils.log("DEBUG", "****** element: " + key + " *****", "true") + if (key == "oof_directives") { + oofDirectives = value + utils.log("DEBUG", "****** homing oofDirectives: " + oofDirectives + " *****", "true") } } - Map assignmentMap = jsonUtil.entryArrayToMap(execution, - assignmentArr.toString(), "key", "value") String cloudOwner = assignmentMap.get("cloudOwner") + utils.log("DEBUG", "****** homing cloudOwner: " + cloudOwner + " *****", "true") String cloudRegionId = assignmentMap.get("locationId") + utils.log("DEBUG", "****** homing cloudRegionId: " + cloudRegionId + " *****", "true") resource.getHomingSolution().setCloudOwner(cloudOwner) resource.getHomingSolution().setCloudRegionId(cloudRegionId) @@ -251,12 +254,26 @@ class OofHoming extends AbstractServiceTaskProcessor { cloudSite.setId(cloudRegionId) cloudSite.setRegionId(cloudRegionId) String orchestrator = execution.getVariable("orchestrator") - if ((orchestrator != null) || (orchestrator != "")) { + if ((orchestrator != null) && (orchestrator != "")) { cloudSite.setOrchestrator(orchestrator) + utils.log("DEBUG", "****** orchestrator: " + orchestrator + " *****", "true") + } else { + cloudSite.setOrchestrator("multicloud") } CloudIdentity cloudIdentity = new CloudIdentity() cloudIdentity.setId(cloudRegionId) + cloudIdentity.setIdentityServerType(ServerType."KEYSTONE") + cloudIdentity.setAdminTenant("service") + cloudIdentity.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD) + String msoMulticloudUserName = UrnPropertiesReader + .getVariable("mso.multicloud.api.password", execution, + "apih") + String msoMulticloudPassword = UrnPropertiesReader + .getVariable("mso.multicloud.api.password", execution, + "abc123") + cloudIdentity.setMsoId(msoMulticloudUserName) + cloudIdentity.setMsoPass(msoMulticloudPassword) // Get MSB Url String msbHost = oofUtils.getMsbHost(execution) String multicloudApiEndpoint = UrnPropertiesReader @@ -265,16 +282,24 @@ class OofHoming extends AbstractServiceTaskProcessor { cloudIdentity.setIdentityUrl(msbHost + multicloudApiEndpoint + "/" + cloudOwner + "/" + cloudRegionId + "/infra_workload") - + utils.log("DEBUG", "****** Cloud IdentityUrl: " + msbHost + multicloudApiEndpoint + + "/" + cloudOwner + "/" + + cloudRegionId + "/infra_workload" + + " *****", "true") + utils.log("DEBUG", "****** CloudIdentity: " + cloudIdentity.toString() + + " *****", "true") cloudSite.setIdentityService(cloudIdentity) + utils.log("DEBUG", "****** CloudSite: " + cloudSite.toString() + + " *****", "true") // Set cloudsite in catalog DB here - oofUtils.createCloudSiteCatalogDb(cloudSite) + // TODO Get cloudsite and compare, set if not present + oofUtils.createCloudSiteCatalogDb(cloudSite, execution) if (oofDirectives != null && oofDirectives != "") { resource.getHomingSolution().setOofDirectives(oofDirectives) execution.setVariable("oofDirectives", oofDirectives) - utils.log("DEBUG", "***** OofDirectives is: " + oofDirectives + + utils.log("DEBUG", "***** OofDirectives set to: " + oofDirectives + " *****", "true") } @@ -285,6 +310,12 @@ class OofHoming extends AbstractServiceTaskProcessor { resource.getHomingSolution().setVnf(vnf) resource.getHomingSolution().setServiceInstanceId(solution.getJSONArray("identifiers")[0].toString()) } + } else { + utils.log("DEBUG", "ProcessHomingSolution Exception: no matching serviceResourceIds returned in " + + "homing solution", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - " + + "Occurred in Homing ProcessHomingSolution: no matching serviceResourceIds returned") + } } } @@ -314,8 +345,10 @@ class OofHoming extends AbstractServiceTaskProcessor { utils.log("DEBUG", "*** Completed Homing Process Homing Solution ***", isDebugEnabled) } catch (BpmnError b) { + utils.log("DEBUG", "ProcessHomingSolution Error: " + b, isDebugEnabled) throw b } catch (Exception e) { + utils.log("DEBUG", "ProcessHomingSolution Exception: " + e, isDebugEnabled) msoLogger.error(e); exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occurred in Homing ProcessHomingSolution") } 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 909683adea..19d19b8cea 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,22 +33,18 @@ 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.http.HttpMethod -import org.springframework.http.ResponseEntity -import org.springframework.http.client.BufferingClientHttpRequestFactory -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory -import org.springframework.web.client.RestTemplate import org.springframework.web.util.UriComponentsBuilder import javax.ws.rs.core.MediaType -import javax.ws.rs.core.Response -import javax.xml.ws.http.HTTPException +import javax.ws.rs.core.UriBuilder import static org.onap.so.bpmn.common.scripts.GenericUtils.* @@ -503,36 +499,26 @@ 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) - String uri = "/cloudSite" - - HttpHeaders headers = new HttpHeaders() - - headers.set(HttpHeaders.AUTHORIZATION, auth) - headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON) - headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + CloudSite getCloudsite = null - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(endpoint + uri) - HttpEntity request = new HttpEntity(cloudSite, headers) - RESTConfig config = new RESTConfig(endpoint + uri) - RESTClient client = new RESTClient(config).addAuthorizationHeader(auth). - addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON).addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - APIResponse response = client.httpPost(request.getBody().toString()) - - int responseCode = response.getStatusCode() - logDebug("CatalogDB response code is: " + responseCode, isDebugEnabled) - String syncResponse = response.getResponseBodyAsString() - logDebug("CatalogDB response is: " + syncResponse, isDebugEnabled) - - if(responseCode != 202){ - exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from CatalogDB.") + 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) } } String getMsbHost(DelegateExecution execution) { - msbHost = UrnPropertiesReader.getVariable("mso.msb.host", execution, "msb-iag.onap") + String msbHost = UrnPropertiesReader.getVariable("mso.msb.host", execution, "msb-iag.onap") Integer msbPort = UrnPropertiesReader.getVariable("mso.msb.port", execution, "80").toInteger() diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonUtils.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonUtils.java index ee53148e44..35f76908e3 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonUtils.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/json/JsonUtils.java @@ -927,7 +927,7 @@ public class JsonUtils { for (int i = 0; i < arr.length(); i++){ JSONObject jo = arr.getJSONObject(i); String key = jo.getString(keyNode); - String value = jo.getString(valueNode); + String value = jo.get(valueNode).toString(); map.put(key, value); } msoLogger.debug("Completed Entry Array To Map Util Method"); @@ -954,7 +954,7 @@ public class JsonUtils { for(int i = 0; i < arr.length(); i++){ JSONObject jo = arr.getJSONObject(i); String key = jo.getString(keyNode); - String value = jo.getString(valueNode); + String value = jo.get(valueNode).toString(); map.put(key, value); } msoLogger.debug("Completed Entry Array To Map Util Method"); diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtilsTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtilsTest.java index 6748128f05..067ae9806d 100644 --- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtilsTest.java +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/json/JsonUtilsTest.java @@ -81,7 +81,19 @@ public class JsonUtilsTest { JSONArray assignmentInfo = homingDataJson.getJSONArray("assignmentInfo"); Map map = utils.entryArrayToMap(assignmentInfo.toString(), "variableName", "variableValue"); assertEquals(map.get("cloudOwner"), "CloudOwner"); - } + } + @Test + public void entryArrayToMapStringTestOof() throws IOException { + JsonUtils utils = new JsonUtils(); + String response = this.getJson("OofExample.json"); + String entry = JsonUtils.getJsonValue(response, "solutions.placementSolutions"); + JSONArray arr = new JSONArray(entry); + JSONArray arr2 = arr.getJSONArray(0); + JSONObject homingDataJson = arr2.getJSONObject(0); + JSONArray assignmentInfo = homingDataJson.getJSONArray("assignmentInfo"); + Map map = utils.entryArrayToMap(assignmentInfo.toString(), "key", "value"); + assertEquals(map.get("cloudOwner"), "HPA-cloud"); + } @Test public void getJsonRootPropertyTest() throws IOException { String response = this.getJson("SDNCServiceResponseExample.json"); diff --git a/bpmn/MSOCoreBPMN/src/test/resources/json-examples/OofExample.json b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/OofExample.json new file mode 100644 index 0000000000..127748a5e8 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/OofExample.json @@ -0,0 +1,110 @@ +{ + "requestStatus":"completed", + "statusMessage":"", + "solutions":{ + "placementSolutions":[ + [ + { + "serviceResourceId":"78976677-bca7-446a-8b31-52b83e9aa925", + "resourceModuleName":"7400fd06C75f4a44A68f", + "solution":{ + "identifierType":"cloudRegionId", + "cloudOwner":"HPA-cloud", + "identifiers":[ + "Cloud-region3" + ] + }, + "assignmentInfo":[ + { + "value":"false", + "key":"isRehome" + }, + { + "value":"att_aic", + "key":"locationType" + }, + { + "value":"Cloud-region3", + "key":"locationId" + }, + { + "value":{ + "directives":[ + { + "directives":[ + { + "attributes":[ + { + "attribute_value":"Flavor31", + "attribute_name":"label_1" + } + ], + "type":"flavor_directives" + }, + { + "attributes":[ + { + "attribute_value":"direct", + "attribute_name":"oof_returned_vnic_type_for_firewall_protected" + } + ], + "type":"sriovNICNetwork_directives" + } + ], + "type":"vnfc", + "id":"vfw_1" + }, + { + "directives":[ + { + "attributes":[ + { + "attribute_value":"Flavor32", + "attribute_name":"label_2" + } + ], + "type":"flavor_directives" + } + ], + "type":"vnfc", + "id":"vfw_2" + }, + { + "directives":[ + { + "attributes":[ + { + "attribute_value":"Flavor32", + "attribute_name":"label_3" + } + ], + "type":"flavor_directives" + } + ], + "type":"vnfc", + "id":"vfw_3" + } + ] + }, + "key":"oof_directives" + }, + { + "value":"DLLSTX233", + "key":"cloudClli" + }, + { + "value":"75919", + "key":"aic_version" + }, + { + "value":"HPA-cloud", + "key":"cloudOwner" + } + ] + } + ] + ] + }, + "transactionId":"", + "requestId":"05da4f90-15f7-4128-8ac4-e06dc3cc06f9" +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy index 9763960bfd..848785e5f3 100755 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy @@ -165,6 +165,10 @@ public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskPro msoLogger.debug("User Input Parameter " + userParam.name + ": " + userParam.value.toString()) inputMap.put(userParam.name, userParam.value) } + if ("Orchestrator".equalsIgnoreCase(userParam?.name)) { + execution.setVariable("orchestrator", userParam.value) + inputMap.put("orchestrator", userParam.value) + } } } @@ -344,6 +348,10 @@ public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskPro msoLogger.debug("User Input Parameter " + userParam.name + ": " + userParam.value.toString()) inputMap.put(userParam.name, userParam.value) } + if ("Orchestrator".equalsIgnoreCase(userParam?.name)) { + execution.setVariable("orchestrator", userParam.value) + inputMap.put("orchestrator", userParam.value) + } } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy index 1a47ef88e2..187189c694 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy @@ -250,6 +250,10 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { execution.setVariable("callHoming", true) inputMap.put("Homing_Solution", userParam.value) } + if ("Orchestrator".equalsIgnoreCase(userParam?.name)) { + execution.setVariable("orchestrator", userParam.value) + inputMap.put("orchestrator", userParam.value) + } } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java index b1c81cf8d8..e6d02c6836 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java @@ -23,6 +23,7 @@ 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.HashCodeBuilder; + import java.util.Date; import org.apache.commons.lang3.builder.EqualsBuilder; 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 4f070e71c9..8a61102322 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 @@ -590,7 +590,6 @@ public class CatalogDbClient { this.postSingleResource(cloudSiteClient, cloudSite); } - public CloudSite getCloudSiteByClliAndAicVersion (String clli, String cloudVersion){ return this.getSingleResource(cloudSiteClient, getUri(UriBuilder .fromUri(findByClliAndCloudVersion) -- 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') 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 743c0ec3e756309476dadf2b4067f03edbdbaedf Mon Sep 17 00:00:00 2001 From: Eric Multanen Date: Tue, 13 Nov 2018 08:25:05 -0800 Subject: Fix issues with mulicloud adapter parameters Use the static final string variable for the parameter key values instead of literal string of the variable name. Also, vf_module_id and vnf_id (generic vnf id for multicloud) are already part of the required input list, so they are not needed to be added to the list of inputs. Change-Id: I2b0bbf385e4114f0432673a3d7e8c9d652226f0a Issue-ID: SO-1210 Signed-off-by: Eric Multanen --- .../java/org/onap/so/openstack/utils/MsoMulticloudUtils.java | 10 +++++----- .../java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java | 4 ---- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'adapters') diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java index 8f71af4dfe..d036468808 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java @@ -72,7 +72,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ public static final String OOF_DIRECTIVES = "oof_directives"; public static final String SDNC_DIRECTIVES = "sdnc_directives"; - public static final String GENERIC_VNF_ID = "generic_vnf_id"; + public static final String VNF_ID = "vnf_id"; public static final String VF_MODULE_ID = "vf_module_id"; public static final String TEMPLATE_TYPE = "template_type"; public static final List MULTICLOUD_INPUTS = @@ -173,11 +173,11 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ } } - if (!stackInputs.isEmpty() && stackInputs.containsKey("VF_MODULE_ID")){ - vfModuleId = (String) stackInputs.get("VF_MODULE_ID"); + if (!stackInputs.isEmpty() && stackInputs.containsKey(VF_MODULE_ID)){ + vfModuleId = (String) stackInputs.get(VF_MODULE_ID); } - if (!stackInputs.isEmpty() && stackInputs.containsKey("GENERIC_VNF_ID")){ - genericVnfId = (String) stackInputs.get("GENERIC_VNF_ID"); + if (!stackInputs.isEmpty() && stackInputs.containsKey(VNF_ID)){ + genericVnfId = (String) stackInputs.get(VNF_ID); } // create the multicloud payload diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java index 269acb9d6f..d37342323f 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java @@ -999,10 +999,6 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { } } } - if (multicloudInputs) { - goldenInputs.put(MsoMulticloudUtils.GENERIC_VNF_ID, genericVnfId); - goldenInputs.put(MsoMulticloudUtils.VF_MODULE_ID, vfModuleId); - } LOGGER.debug("Ignoring extra inputs: " + extraInputs); } -- 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') 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 4bea3004b0f7cd0352b8597aa3d6d8ba9b5ad5ba Mon Sep 17 00:00:00 2001 From: "Smokowski, Steve (ss835w)" Date: Wed, 14 Nov 2018 11:58:38 -0500 Subject: Update Schema Issue-ID: SO-1211 Change-Id: I7eb43d47f51790224b84ac6d58b89b9e9d9dfe83 Signed-off-by: Smokowski, Steve (ss835w) --- .../main/resources/db/migration/V4.3__Expand_Column_Size.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 adapters/mso-requests-db-adapter/src/main/resources/db/migration/V4.3__Expand_Column_Size.sql (limited to 'adapters') 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 new file mode 100644 index 0000000000..96fe5a44e1 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V4.3__Expand_Column_Size.sql @@ -0,0 +1,11 @@ +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; + +ALTER TABLE archived_infra_requests + MODIFY IF EXISTS AIC_CLOUD_REGION varchar(50) NULL, + MODIFY IF EXISTS AIC_NODE_CLLI varchar(45) 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') 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 6e3aad261b40427288b18f21b86f109172dbd9c4 Mon Sep 17 00:00:00 2001 From: "Smokowski, Steve (ss835w)" Date: Wed, 14 Nov 2018 16:27:23 -0500 Subject: Up Timer Issue-ID: SO-1209 Change-Id: Icb018e4a178ab13f6d142bdcb1000411c0d0dedf Signed-off-by: Smokowski, Steve (ss835w) --- .../src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'adapters') diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java index 759c116e05..8c5840074f 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java @@ -658,7 +658,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { public boolean isExpired () { // adding arbitrary guard timer of 5 minutes - return expires == null || System.currentTimeMillis() > (expires.getTimeInMillis() - 300000); + return expires == null || System.currentTimeMillis() > (expires.getTimeInMillis() - 1800000); } } -- 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') 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 0578fc4948e8e98e5fe92e63832336f0b7e17e85 Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Thu, 15 Nov 2018 12:27:09 +0530 Subject: Fix auth token for request-db Fix auth token for request-db. Change-Id: I898781b2294392c5cd55df6fccd173f7274bc660 Issue-ID: SO-689 Signed-off-by: subhash kumar singh --- .../adapters/requestsdb/MsoRequestsDbAdapter.java | 11 ++ .../requestsdb/MsoRequestsDbAdapterImpl.java | 32 ++++++ .../scripts/CreateCustomE2EServiceInstance.groovy | 4 +- .../serviceTask/AbstractSdncOperationTask.java | 4 +- .../process/ActivateSDNCNetworkResource.bpmn | 2 +- .../process/Create3rdONAPE2EServiceInstance.bpmn | 8 +- .../process/CreateActivateSDNCResource.bpmn | 6 +- .../process/CreateCustomE2EServiceInstance.bpmn | 116 ++++++++++----------- .../resources/process/CreateDeviceResource.bpmn | 2 +- .../process/CreateSDNCNetworkResource.bpmn | 4 +- .../process/DeActivateSDNCNetworkResource.bpmn | 2 +- .../process/Delete3rdONAPE2EServiceInstance.bpmn | 8 +- .../process/DeleteCustomE2EServiceInstance.bpmn | 2 +- .../resources/process/DeleteDeviceResource.bpmn | 2 +- .../process/DeleteSDNCNetworkResource.bpmn | 4 +- .../process/UpdateCustomE2EServiceInstance.bpmn | 6 +- .../subprocess/DoCreateE2EServiceInstance.bpmn | 2 +- .../subprocess/DoCreateE2EServiceInstanceV2.bpmn | 10 +- .../DoCustomDeleteE2EServiceInstance.bpmn | 2 +- .../DoCustomDeleteE2EServiceInstanceV2.bpmn | 10 +- .../subprocess/DoDeleteE2EServiceInstance.bpmn | 2 +- .../resources/subprocess/DoDeleteResourcesV1.bpmn | 2 +- .../subprocess/DoScaleE2EServiceInstance.bpmn | 2 +- .../subprocess/DoUpdateE2EServiceInstance.bpmn | 2 +- 24 files changed, 144 insertions(+), 101 deletions(-) (limited to 'adapters') diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java index e28bdb2f96..0c2a49ae53 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java @@ -72,6 +72,17 @@ public interface MsoRequestsDbAdapter { @WebParam(name = "progress") @XmlElement(required = false) String progress, @WebParam(name = "reason") @XmlElement(required = false) String reason) throws MsoRequestsDbException; + @WebMethod + public void initServiceOperationStatus( + @WebParam(name = "serviceId") @XmlElement(required = true) String serviceId, + @WebParam(name = "operationId") @XmlElement(required = false) String operationId, + @WebParam(name = "operationType") @XmlElement(required = false) String operationType, + @WebParam(name = "userId") @XmlElement(required = false) String userId, + @WebParam(name = "result") @XmlElement(required = false) String result, + @WebParam(name = "operationContent") @XmlElement(required = false) String operationContent, + @WebParam(name = "progress") @XmlElement(required = false) String progress, + @WebParam(name = "reason") @XmlElement(required = false) String reason) throws MsoRequestsDbException; + @WebMethod public void initResourceOperationStatus(@WebParam(name = "serviceId") @XmlElement(required = true) String serviceId, @WebParam(name = "operationId") @XmlElement(required = true) String operationId, diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java index 33b1028cbb..62e7e2e43c 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java @@ -214,6 +214,38 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { operationStatusRepository.save(operStatus); } + /** + * Init operation status
+ * + * @param serviceId + * @param operationId + * @param operationType + * @param userId + * @param result + * @param operationContent + * @param progress + * @param reason + * @throws MsoRequestsDbException + * @since ONAP Casablanca Release + */ + @Override + @Transactional + public void initServiceOperationStatus(String serviceId, String operationId, String operationType, String userId, + String result, String operationContent, String progress, String reason) throws MsoRequestsDbException { + OperationStatus operStatus = new OperationStatus(); + + operStatus.setOperationId(operationId); + operStatus.setServiceId(serviceId); + operStatus.setUserId(userId); + operStatus.setOperation(operationType); + operStatus.setReason(reason); + operStatus.setProgress(progress); + operStatus.setResult(result); + operStatus.setOperationContent(operationContent); + operStatus.setResult(result); + operationStatusRepository.save(operStatus); + } + /** * init the operation status of all the resources
* diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy index 6ef446b490..02ae6a6f48 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy @@ -302,7 +302,7 @@ public class CreateCustomE2EServiceInstance extends AbstractServiceTaskProcessor xmlns:ns="http://org.onap.so/requestsdb"> - + ${MsoUtils.xmlEscape(serviceId)} ${MsoUtils.xmlEscape(operationId)} ${MsoUtils.xmlEscape(operationType)} @@ -311,7 +311,7 @@ public class CreateCustomE2EServiceInstance extends AbstractServiceTaskProcessor ${MsoUtils.xmlEscape(operationContent)} ${MsoUtils.xmlEscape(progress)} ${MsoUtils.xmlEscape(reason)} - + """ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java index 3c4a35737b..0a00a61f83 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java @@ -93,7 +93,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { logger.info("AbstractSdncOperationTask.updateResOperStatus begin!"); String requestsdbEndPoint = env.getProperty("mso.adapters.openecomp.db.endpoint"); HttpPost httpPost = new HttpPost(requestsdbEndPoint); - httpPost.addHeader("Authorization", "Basic QlBFTENsaWVudDpwYXNzd29yZDEk"); + httpPost.addHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk"); httpPost.addHeader("Content-type", "application/soap+xml"); String postBody = getPostStringBody(resourceOperationStatus); httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML)); @@ -174,7 +174,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { logger.info("AbstractSdncOperationTask.getResourceOperationStatus begin!"); String requestsdbEndPoint = env.getProperty("mso.adapters.openecomp.db.endpoint"); HttpPost httpPost = new HttpPost(requestsdbEndPoint); - httpPost.addHeader("Authorization", "Basic QlBFTENsaWVudDpwYXNzd29yZDEk"); + httpPost.addHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk"); httpPost.addHeader("Content-type", "application/soap+xml"); String getBody = getGetStringBody(serviceId, operationId, resourceTemplateUUID); httpPost.setEntity(new StringEntity(getBody, ContentType.APPLICATION_XML)); diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSDNCNetworkResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSDNCNetworkResource.bpmn index fe2c8928d8..8cde4f6c56 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSDNCNetworkResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSDNCNetworkResource.bpmn @@ -38,7 +38,7 @@ dcsi.prepareUpdateAfterActivateSDNCResource(execution) application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/Create3rdONAPE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/Create3rdONAPE2EServiceInstance.bpmn index 6a7cf8160a..6be6cc9899 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/Create3rdONAPE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/Create3rdONAPE2EServiceInstance.bpmn @@ -46,7 +46,7 @@ dcsi.prepareUpdateProgress(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} @@ -82,7 +82,7 @@ dcsi.doCreateE2ESIin3rdONAP(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} @@ -199,7 +199,7 @@ dcsi.prepareUpdateProgress(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} @@ -311,7 +311,7 @@ dcsi.prepareUpdateProgress(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateActivateSDNCResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateActivateSDNCResource.bpmn index 29d7a11175..5f4f964008 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateActivateSDNCResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateActivateSDNCResource.bpmn @@ -79,7 +79,7 @@ dcsi.prepareUpdateAfterCreateSDNCResource(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} @@ -101,7 +101,7 @@ dcsi.prepareUpdateAfterCreateSDNCResource(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} @@ -147,7 +147,7 @@ dcsi.prepareUpdateAfterActivateSDNCResource(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn index 6f73b46e2e..04ff48d4ed 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateCustomE2EServiceInstance.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_0s2spoq @@ -8,9 +8,9 @@ SequenceFlow_1dsbjjb SequenceFlow_1yay321 - import org.onap.so.bpmn.common.scripts.* ExceptionUtil ex = new ExceptionUtil() -ex.processJavaException(execution)]]> +ex.processJavaException(execution) SequenceFlow_1dsbjjb @@ -54,16 +54,16 @@ ex.processJavaException(execution)]]> SequenceFlow_0s2spoq SequenceFlow_0z4faf9 - import org.onap.so.bpmn.infrastructure.scripts.* def csi= new CreateCustomE2EServiceInstance() -csi.preProcessRequest(execution)]]> +csi.preProcessRequest(execution) SequenceFlow_14zu6wr SequenceFlow_0je30si - import org.onap.so.bpmn.infrastructure.scripts.* def csi = new CreateCustomE2EServiceInstance() -csi.prepareCompletionRequest(execution)]]> +csi.prepareCompletionRequest(execution) @@ -88,9 +88,9 @@ csi.prepareCompletionRequest(execution)]]> SequenceFlow_0n9pexp SequenceFlow_01umodj - import org.onap.so.bpmn.infrastructure.scripts.* def csi = new CreateCustomE2EServiceInstance() -csi.prepareFalloutRequest(execution)]]> +csi.prepareFalloutRequest(execution) @@ -107,9 +107,9 @@ csi.prepareFalloutRequest(execution)]]> SequenceFlow_0e1r62n SequenceFlow_0n9pexp - import org.onap.so.bpmn.infrastructure.scripts.* def csi = new CreateCustomE2EServiceInstance() -csi.sendSyncError(execution)]]> +csi.sendSyncError(execution) @@ -119,9 +119,9 @@ csi.sendSyncError(execution)]]> SequenceFlow_081z8l2 SequenceFlow_19eilro - import org.onap.so.bpmn.infrastructure.scripts.* def csi = new CreateCustomE2EServiceInstance() -csi.sendSyncResponse(execution)]]> +csi.sendSyncResponse(execution) SequenceFlow_0klbpxx @@ -138,19 +138,19 @@ csi.sendSyncResponse(execution)]]> - + #{execution.getVariable("WorkflowException") == null} - + #{execution.getVariable("WorkflowException") != null} SequenceFlow_0z4faf9 SequenceFlow_1euqjsp - import org.onap.so.bpmn.infrastructure.scripts.* def csi= new CreateCustomE2EServiceInstance() -csi.prepareInitServiceOperationStatus(execution)]]> +csi.prepareInitServiceOperationStatus(execution) @@ -160,7 +160,7 @@ csi.prepareInitServiceOperationStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateServiceOperStatusRequest} @@ -225,61 +225,61 @@ csi.prepareInitServiceOperationStatus(execution)]]> - - + + - - + + - - + + - - + + - - + + - - - - + + + + - - + + - - - - + + + + @@ -321,54 +321,54 @@ csi.prepareInitServiceOperationStatus(execution)]]> - - + + - - + + - - - - + + + + - - + + - - - - + + + + - - + + - - + + @@ -380,8 +380,8 @@ csi.prepareInitServiceOperationStatus(execution)]]> - - + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateDeviceResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateDeviceResource.bpmn index 5fd2c69608..29cec8ed1e 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateDeviceResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateDeviceResource.bpmn @@ -93,7 +93,7 @@ dcsi.prepareUpdateProgress(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSDNCNetworkResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSDNCNetworkResource.bpmn index a94569c29b..0bdc6dc0bd 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSDNCNetworkResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSDNCNetworkResource.bpmn @@ -62,7 +62,7 @@ dcsi.prepareUpdateBeforeCreateSDNCResource(execution) application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} @@ -84,7 +84,7 @@ dcsi.prepareUpdateBeforeCreateSDNCResource(execution) application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeActivateSDNCNetworkResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeActivateSDNCNetworkResource.bpmn index eaf37191d5..cfcd259d7c 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeActivateSDNCNetworkResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeActivateSDNCNetworkResource.bpmn @@ -62,7 +62,7 @@ csi.sendSyncResponse(execution) application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/Delete3rdONAPE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/Delete3rdONAPE2EServiceInstance.bpmn index 25fd6af574..f6dcff4435 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/Delete3rdONAPE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/Delete3rdONAPE2EServiceInstance.bpmn @@ -46,7 +46,7 @@ dcsi.prepareUpdateProgress(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} @@ -82,7 +82,7 @@ dcsi.doDeleteE2ESIin3rdONAP(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} @@ -192,7 +192,7 @@ dcsi.prepareUpdateProgress(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} @@ -303,7 +303,7 @@ dcsi.prepareUpdateProgress(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn index 2d68d650c5..7010442b5d 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn @@ -152,7 +152,7 @@ csi.prepareInitServiceOperationStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateServiceOperStatusRequest} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteDeviceResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteDeviceResource.bpmn index 73d38b383c..7d9a9e2b5d 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteDeviceResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteDeviceResource.bpmn @@ -92,7 +92,7 @@ dcsi.prepareUpdateProgress(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSDNCNetworkResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSDNCNetworkResource.bpmn index 80fcc1762e..c2d4de3973 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSDNCNetworkResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeleteSDNCNetworkResource.bpmn @@ -58,7 +58,7 @@ dcsi.prepareUpdateBeforeDeleteSDNCResource(execution) application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} @@ -80,7 +80,7 @@ dcsi.prepareUpdateBeforeDeleteSDNCResource(execution) application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateCustomE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateCustomE2EServiceInstance.bpmn index 1be30d62e4..e2488fda6a 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateCustomE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/UpdateCustomE2EServiceInstance.bpmn @@ -136,7 +136,7 @@ csi.sendSyncError(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateServiceOperStatusRequest} @@ -246,7 +246,7 @@ csi.prepareInitServiceOperationStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateServiceOperStatusRequest} @@ -270,7 +270,7 @@ csi.prepareInitServiceOperationStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateServiceOperStatusRequest} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn index 01040ba914..eccb9486dd 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn @@ -123,7 +123,7 @@ ddsi.preInitResourcesOperStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_initResOperStatusRequest} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn index c699f911d0..31174a0b3e 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateE2EServiceInstanceV2.bpmn @@ -284,7 +284,7 @@ ddsi.preUpdateServiceOperationStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateServiceOperStatusRequest} @@ -317,7 +317,7 @@ ddsi.preUpdateServiceOperationStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateServiceOperStatusRequest} @@ -350,7 +350,7 @@ ddsi.preUpdateServiceOperationStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateServiceOperStatusRequest} @@ -381,7 +381,7 @@ ddsi.preInitResourcesOperStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_initResOperStatusRequest} @@ -404,7 +404,7 @@ ddsi.preInitResourcesOperStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateServiceOperStatusRequest} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstance.bpmn index 2e12dd3b96..1b02fd772d 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstance.bpmn @@ -99,7 +99,7 @@ ddsi.preInitResourcesOperStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_initResOperStatusRequest} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstanceV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstanceV2.bpmn index 2df19abf68..cc927b240b 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstanceV2.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstanceV2.bpmn @@ -245,7 +245,7 @@ ddsi.preUpdateServiceOperationStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateServiceOperStatusRequest} @@ -278,7 +278,7 @@ ddsi.preUpdateServiceOperationStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateServiceOperStatusRequest} @@ -310,7 +310,7 @@ ddsi.preUpdateServiceOperationStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateServiceOperStatusRequest} @@ -349,7 +349,7 @@ ddsi.preUpdateServiceOperationStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateServiceOperStatusRequest} @@ -380,7 +380,7 @@ ddsi.preInitResourcesOperStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_initResOperStatusRequest} 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 17f6c66e4a..fd3804c066 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 @@ -66,7 +66,7 @@ ddsi.preInitResourcesOperStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_initResOperStatusRequest} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteResourcesV1.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteResourcesV1.bpmn index fe5e93cbec..16acb0d7e1 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteResourcesV1.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoDeleteResourcesV1.bpmn @@ -119,7 +119,7 @@ ddrs.preProcessRequest(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_updateResOperStatusRequest} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoScaleE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoScaleE2EServiceInstance.bpmn index fa8a2213b0..dddbe18ba5 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoScaleE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoScaleE2EServiceInstance.bpmn @@ -30,7 +30,7 @@ ddsi.preInitResourcesOperStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_initResOperStatusRequest} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn index 8383ccbd1f..785db75fa1 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoUpdateE2EServiceInstance.bpmn @@ -67,7 +67,7 @@ ddsi.preInitResourcesOperStatus(execution)]]> application/soap+xml - Basic QlBFTENsaWVudDpwYXNzd29yZDEk + Basic YnBlbDpwYXNzd29yZDEk ${CVFMI_initResOperStatusRequest} -- 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') 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') 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 898449a5d41b777ebe271bcae9c0ba511fecdb1f Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Fri, 16 Nov 2018 20:37:57 -0500 Subject: Bug Fixes November 16th fix failing junit when heatID not available provide name if ID is not present on delete op removed logic to skip unassign sdnc in rollback flows Move default settings to CrVfModRequest pojo. Check for null backout and failIfExists params - 1810. Updated exception message and test Added tests for networkCustomization not found Added tests for delete and update network Separated networkResourceCustomization and networkResource lookups Removed version check as not necessary for setting boolean Change-Id: Ia4b409244dc5ebdbb163d4a178713115719366ca Issue-ID: SO-1231 Signed-off-by: Benjamin, Max (mb388a) --- .../so/adapters/vnfrest/CreateVfModuleRequest.java | 4 +- .../adapter/vnf/mapper/VnfAdapterObjectMapper.java | 8 ++- .../vnf/mapper/VnfAdapterVfModuleObjectMapper.java | 22 ++++++-- .../vnf/mapper/VnfAdapterObjectMapperTest.java | 22 ++++++-- .../VnfAdapterVfModuleObjectMapperPayloadTest.java | 2 +- .../mapper/VnfAdapterVfModuleObjectMapperTest.java | 59 +++++++++++++++++++++- .../onap/so/apihandlerinfra/ServiceInstances.java | 20 +++++--- .../validation/RelatedInstancesValidation.java | 2 +- .../so/apihandlerinfra/ServiceInstancesTest.java | 50 +++++++++++++++++- .../ServiceInstanceTest/NetworkInstance.json | 3 +- 10 files changed, 168 insertions(+), 24 deletions(-) (limited to 'adapters') diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/CreateVfModuleRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/CreateVfModuleRequest.java index d0caef33e4..a383aac77f 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/CreateVfModuleRequest.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/CreateVfModuleRequest.java @@ -54,8 +54,8 @@ public class CreateVfModuleRequest extends VfRequestCommon { private String modelCustomizationUuid; private String requestType; - private Boolean failIfExists; - private Boolean backout; + private Boolean failIfExists = false; + private Boolean backout = true; private Boolean enableBridge; private Map vfModuleParams = new HashMap<>(); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java index 93e588f2e1..701817ab58 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapper.java @@ -29,6 +29,7 @@ import java.util.UUID; import javax.annotation.PostConstruct; +import org.apache.commons.lang3.StringUtils; import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleTopology; @@ -92,7 +93,12 @@ public class VnfAdapterObjectMapper { deleteVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId()); deleteVolumeGroupRequest.setTenantId(cloudRegion.getTenantId()); deleteVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId()); - deleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId()); + if (!StringUtils.isEmpty(volumeGroup.getHeatStackId())){ + deleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId()); + } else + { + deleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getVolumeGroupName()); + } deleteVolumeGroupRequest.setSkipAAI(true); deleteVolumeGroupRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance)); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index a36d18c524..1f01772d7a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -23,6 +23,7 @@ package org.onap.so.client.adapter.vnf.mapper; import static java.util.Arrays.asList; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -36,6 +37,7 @@ import java.util.Optional; import javax.annotation.PostConstruct; +import org.apache.commons.lang3.StringUtils; import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; import org.onap.sdnc.northbound.client.model.GenericResourceApiSubInterfaceNetworkData; @@ -781,16 +783,26 @@ public class VnfAdapterVfModuleObjectMapper { deleteVfModuleRequest.setTenantId(cloudRegion.getTenantId()); deleteVfModuleRequest.setVnfId(genericVnf.getVnfId()); deleteVfModuleRequest.setVfModuleId(vfModule.getVfModuleId()); - deleteVfModuleRequest.setVfModuleStackId(vfModule.getHeatStackId());//DoDVfMod_heatStackId - deleteVfModuleRequest.setSkipAAI(true); - String messageId = vnfAdapterObjectMapperUtils.getRandomUuid(); - deleteVfModuleRequest.setMessageId(messageId); - deleteVfModuleRequest.setNotificationUrl(vnfAdapterObjectMapperUtils.createCallbackUrl("VNFAResponse", messageId)); + if (!StringUtils.isEmpty(vfModule.getHeatStackId())){ + deleteVfModuleRequest.setVfModuleStackId(vfModule.getHeatStackId());//DoDVfMod_heatStackId + } else + { + deleteVfModuleRequest.setVfModuleStackId(vfModule.getVfModuleName()); + } + + deleteVfModuleRequest.setSkipAAI(true); + setIdAndUrl(deleteVfModuleRequest); MsoRequest msoRequest = buildMsoRequest(requestContext, serviceInstance); deleteVfModuleRequest.setMsoRequest(msoRequest); return deleteVfModuleRequest; } + protected void setIdAndUrl(DeleteVfModuleRequest deleteVfModuleRequest) throws UnsupportedEncodingException{ + String messageId = vnfAdapterObjectMapperUtils.getRandomUuid(); + deleteVfModuleRequest.setMessageId(messageId); + deleteVfModuleRequest.setNotificationUrl(vnfAdapterObjectMapperUtils.createCallbackUrl("VNFAResponse", messageId)); + } + private String convertToString(Object obj) { String json; try { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java index 8f5c8dfb5e..f176607dfa 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java @@ -230,7 +230,16 @@ public class VnfAdapterObjectMapperTest { } @Test - public void test_deleteVolumeGroupRequestMapper() throws Exception { + public void test_deleteVolumeGroupHeatIdRequestMapper() throws Exception{ + this.test_deleteVolumeGroupRequestMapper("heatStackId"); + } + + @Test + public void test_deleteVolumeGroupNoHeatIdRequestMapper() throws Exception{ + this.test_deleteVolumeGroupRequestMapper(null); + } + + private void test_deleteVolumeGroupRequestMapper(String heatStackId) throws Exception { DeleteVolumeGroupRequest expectedDeleteVolumeGroupRequest = new DeleteVolumeGroupRequest(); CloudRegion cloudRegion = new CloudRegion(); @@ -244,8 +253,13 @@ public class VnfAdapterObjectMapperTest { volumeGroup.setVolumeGroupId("volumeGroupId"); expectedDeleteVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId()); - volumeGroup.setHeatStackId("heatStackId"); - expectedDeleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId()); + if (heatStackId != null){ + volumeGroup.setHeatStackId("heatStackId"); + expectedDeleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId()); + } else { + volumeGroup.setVolumeGroupName("volumeGroupName"); + expectedDeleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getVolumeGroupName()); + } expectedDeleteVolumeGroupRequest.setSkipAAI(true); @@ -269,7 +283,7 @@ public class VnfAdapterObjectMapperTest { assertThat(actualDeleteVolumeGroupRequest, sameBeanAs(expectedDeleteVolumeGroupRequest)); } - + @Test @Ignore public void test_createVolumeGroupParams() throws Exception { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java index 32a495e094..a156c382d1 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java @@ -845,7 +845,7 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { jsonToCompare, DeleteVfModuleRequest.class); - assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl")); + assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl").ignoring("vfModuleStackId")); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java index c8f4a222f3..dac26f728a 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java @@ -20,19 +20,38 @@ package org.onap.so.client.adapter.vnf.mapper; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doNothing; import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import org.junit.Before; import org.junit.Test; +import org.mockito.MockitoAnnotations; +import org.mockito.Spy; +import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.entity.MsoRequest; -public class VnfAdapterVfModuleObjectMapperTest{ +public class VnfAdapterVfModuleObjectMapperTest { + @Spy private VnfAdapterVfModuleObjectMapper mapper = new VnfAdapterVfModuleObjectMapper(); + + @Before + public void before() { + MockitoAnnotations.initMocks(this); + } @Test public void createVnfcSubInterfaceKeyTest() { @@ -64,4 +83,42 @@ public class VnfAdapterVfModuleObjectMapperTest{ } + @Test + public void test_deleteVfModuleNoHeatIdRequestMapper() throws Exception { + DeleteVfModuleRequest expectedDeleteVfModuleRequest = new DeleteVfModuleRequest(); + + CloudRegion cloudRegion = new CloudRegion(); + cloudRegion.setLcpCloudRegionId("lcpCloudRegionId"); + expectedDeleteVfModuleRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId()); + + cloudRegion.setTenantId("tenantId"); + expectedDeleteVfModuleRequest.setTenantId(cloudRegion.getTenantId()); + + GenericVnf genericVnf = new GenericVnf(); + VfModule vfModule = new VfModule(); + vfModule.setHeatStackId("heatStackId"); + expectedDeleteVfModuleRequest.setVfModuleStackId("heatStackId"); + expectedDeleteVfModuleRequest.setSkipAAI(true); + + MsoRequest msoRequest = new MsoRequest(); + RequestContext requestContext = new RequestContext(); + requestContext.setMsoRequestId("msoRequestId"); + msoRequest.setRequestId(requestContext.getMsoRequestId()); + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId()); + expectedDeleteVfModuleRequest.setMsoRequest(msoRequest); + + String messageId = "messageId"; + String endpoint = "endpoint"; + doNothing().when(mapper).setIdAndUrl(any()); + expectedDeleteVfModuleRequest.setMessageId(messageId); + expectedDeleteVfModuleRequest.setNotificationUrl(endpoint + "/VNFAResponse/" + messageId); + + DeleteVfModuleRequest actualDeleteVfModuleRequest = mapper.deleteVfModuleRequestMapper(requestContext, cloudRegion, + serviceInstance, genericVnf, vfModule); + + assertThat(actualDeleteVfModuleRequest, sameBeanAs(expectedDeleteVfModuleRequest).ignoring("messageId").ignoring("notificationUrl")); + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index 8047893bb4..04a707c4ad 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -50,6 +50,7 @@ import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.exceptions.VfModuleNotFoundException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; import org.onap.so.db.catalog.beans.NetworkResource; +import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.Recipe; import org.onap.so.db.catalog.beans.ServiceRecipe; import org.onap.so.db.catalog.beans.VfModule; @@ -1530,14 +1531,19 @@ public class ServiceInstances { Recipe recipe = null; if(modelInfo.getModelCustomizationId()!=null){ - NetworkResource networkResource = catalogDbClient.getNetworkResourceCustomizationByModelCustomizationUUID(modelInfo.getModelCustomizationId()).getNetworkResource(); - if(networkResource!=null){ - if(modelInfo.getModelVersionId() == null) { - modelInfo.setModelVersionId(networkResource.getModelUUID()); + NetworkResourceCustomization networkResourceCustomization = catalogDbClient.getNetworkResourceCustomizationByModelCustomizationUUID(modelInfo.getModelCustomizationId()); + if(networkResourceCustomization != null){ + NetworkResource networkResource = networkResourceCustomization.getNetworkResource(); + if(networkResource!=null){ + if(modelInfo.getModelVersionId() == null) { + modelInfo.setModelVersionId(networkResource.getModelUUID()); + } + recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(networkResource.getModelName(), action.toString()); + }else{ + throw new ValidationException("no catalog entry found"); } - recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(networkResource.getModelName(), action.toString()); - }else{ - throw new ValidationException("no catalog entry found"); + }else if(action != Action.deleteInstance){ + throw new ValidationException("modelCustomizationId for networkResourceCustomization lookup", true); } }else{ //ok for version < 3 and action delete diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java index f22294b33f..9af26af91c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java @@ -128,7 +128,7 @@ public class RelatedInstancesValidation implements ValidationRule{ if(InstanceDirection.source.equals(relatedInstance.getInstanceDirection()) && relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) { isSourceVnfPresent = true; } else if(InstanceDirection.destination.equals(relatedInstance.getInstanceDirection()) && - (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) || (relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) && reqVersion == 6))) { + (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) || (relatedInstanceModelInfo.getModelType().equals(ModelType.pnf)))) { isDestinationVnfPresent = true; } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java index 01b5b38d4f..0ce31a23e3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java @@ -1710,7 +1710,7 @@ public class ServiceInstancesTest extends BaseTest{ stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json")) + .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json")) .withStatus(HttpStatus.SC_OK))); stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" + @@ -2431,4 +2431,52 @@ public class ServiceInstancesTest extends BaseTest{ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } + @Test + public void deleteNetworkInstanceNoCustomizationEntry() throws IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_NOT_FOUND))); + + stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" + + "modelName=VNF-API-DEFAULT&action=deleteInstance")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb"; + ResponseEntity response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void updateNetworkInstanceNoCustomizationEntry() throws IOException { + stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_NOT_FOUND))); + + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb"; + ResponseEntity response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + assertEquals(realResponse.getServiceException().getText(), "No valid modelCustomizationId for networkResourceCustomization lookup is specified"); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/NetworkInstance.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/NetworkInstance.json index a37fe050eb..6e5eb0f533 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/NetworkInstance.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/NetworkInstance.json @@ -1,7 +1,8 @@ { "requestDetails":{ "modelInfo":{ - "modelType":"network" + "modelType":"network", + "modelCustomizationId": "3bdbb104-476c-483e-9f8b-c095b3d308ac" }, "requestInfo":{ "source":"VID", -- cgit 1.2.3-korg From c9bdf8cf227a76d1130c327f6497a455f779955e Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Sat, 17 Nov 2018 12:45:58 +0530 Subject: Fix request resource building Fix request resource building. Change-Id: I64161359ae1b3d36ef3647382fab615d6afd6647 Issue-ID: SO-689 Signed-off-by: subhash kumar singh --- .../org/onap/so/adapters/sdnc/impl/SDNCRestClient.java | 8 ++++++++ .../bpmn/common/resource/ResourceRequestBuilder.java | 18 ++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'adapters') diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java index 71937245bc..f842e78916 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java @@ -84,6 +84,14 @@ public class SDNCRestClient{ msoLogger.debug("BPEL Request:" + bpelRequest.toString()); + // Added delay to allow completion of create request to SDNC + // before executing activate of create request. + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + String action = bpelRequest.getRequestHeader().getSvcAction(); String operation = bpelRequest.getRequestHeader().getSvcOperation(); String bpelReqId = bpelRequest.getRequestHeader().getRequestId(); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java index 1989ca8cf9..b4851ee7a4 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java @@ -233,14 +233,16 @@ public class ResourceRequestBuilder { private static Object getValue(Object value, Map serviceInputs, List servInputs) { if(value instanceof Map) { - Map valueMap = new HashMap<>(); - - Map propertyMap = (Map)value; - - for(String key : propertyMap.keySet()) { - valueMap.put(key, getValue(propertyMap.get(key), serviceInputs, servInputs)); - } - return valueMap; // return if the value is nested hashmap + // currently this logic handles only one level of nesting. +// Map valueMap = new HashMap<>(); +// +// Map propertyMap = (Map)value; +// +// for(String key : propertyMap.keySet()) { +// valueMap.put(key, getValue(propertyMap.get(key), serviceInputs, servInputs)); +// } +// return valueMap; // return if the value is nested hashmap + return ((LinkedHashMap) value).values().toArray()[0]; } else if(value instanceof GetInput) { String inputName = ((GetInput)value).getInputName(); -- cgit 1.2.3-korg From 20b3c6fbb50e339928492c221d5b7352e1ddc59f Mon Sep 17 00:00:00 2001 From: Yulian Han Date: Wed, 21 Nov 2018 15:51:18 +0800 Subject: insert service progress into db if no record Change-Id: Idaa55084f5ecb0dd3636c232cebc14fa5f064409 Issue-ID: SO-1235 Signed-off-by: Yulian Han --- .../requestsdb/MsoRequestsDbAdapterImpl.java | 5 +++- .../requestsdb/adapters/MSORequestDBImplTest.java | 33 +++------------------- 2 files changed, 8 insertions(+), 30 deletions(-) (limited to 'adapters') diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java index 62e7e2e43c..762c76fc77 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java @@ -201,7 +201,10 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { String error = "Entity not found. Unable to retrieve OperationStatus Object ServiceId: " + serviceId + " operationId: " + operationId; logger.error(error); - throw new MsoRequestsDbException(error,MsoLogger.ErrorCode.BusinessProcesssError); +// throw new MsoRequestsDbException(error,MsoLogger.ErrorCode.BusinessProcesssError); + operStatus = new OperationStatus(); + operStatus.setOperationId(operationId); + operStatus.setServiceId(serviceId); } operStatus.setUserId(userId); diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java index 571a2c053f..6504fdaaa5 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java @@ -364,35 +364,10 @@ public class MSORequestDBImplTest { updatedOperationStatus.setReason(reason); updatedOperationStatus.setOperationContent(operationContent); - try { - dbAdapter.updateServiceOperationStatus(serviceId, operationId, operation, userId, - result, operationContent, progress, reason); - fail("Expected MsoRequestsDbException to be thrown"); - } catch (Exception e) { - assertEquals("Entity not found. Unable to retrieve OperationStatus Object ServiceId: " + serviceId + " operationId: " + operationId,e.getMessage()); - for(ILoggingEvent logEvent : TestAppender.events) - if(logEvent.getLoggerName().equals("org.onap.so.logging.cxf.interceptor.SOAPLoggingInInterceptor") && - logEvent.getMarker().getName().equals("ENTRY") - ){ - Map mdc = logEvent.getMDCPropertyMap(); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID)); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID)); - assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME)); - assertEquals("/services/RequestsDbAdapter",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME)); - assertEquals("INPROGRESS",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); - }else if(logEvent.getLoggerName().equals("org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor") && - logEvent.getMarker()!= null && logEvent.getMarker().getName().equals("EXIT")){ - Map mdc = logEvent.getMDCPropertyMap(); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID)); - assertEquals("500",mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE)); - assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME)); - assertEquals("/services/RequestsDbAdapter",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME)); - assertEquals("ERROR",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); - } - } - + dbAdapter.updateServiceOperationStatus(serviceId, operationId, operation, userId, + result, operationContent, progress, reason); + OperationStatus dbOpStatus = operationStatusRepository.findOneByServiceIdAndOperationId(serviceId,operationId); + assertThat(dbOpStatus, sameBeanAs(updatedOperationStatus).ignoring("operateAt").ignoring("finishedAt")); } @Test -- 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') 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 12c81872093919e10734abacf06d24e5e1df3a2c Mon Sep 17 00:00:00 2001 From: Yulian Han Date: Sat, 24 Nov 2018 16:53:35 +0800 Subject: use config value instead hard code of url Change-Id: Idaa55084f5ecb0dd3636c232cebc14fa5f064411 Issue-ID: SO-1249 Signed-off-by: Yulian Han --- .../org/onap/so/adapters/vfc/util/RestfulUtil.java | 19 +++++++------ .../scripts/CreateVFCNSResource.groovy | 31 ++++++++++++++++------ .../scripts/DoCreateResources.groovy | 5 ++-- 3 files changed, 36 insertions(+), 19 deletions(-) (limited to 'adapters') diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java index 0536dd3560..f6bf8b9fbf 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java @@ -82,15 +82,18 @@ public class RestfulUtil { private Environment env; public String getMsbHost() { - // MSB_IP will be set as ONAP_IP environment parameter in install flow. - String msbIp = System.getenv().get(ONAP_IP); - // if ONAP IP is not set. get it from config file. - if(null == msbIp || msbIp.isEmpty()) { - msbIp = env.getProperty("mso.msb-ip", DEFAULT_MSB_IP); - } + // MSB_IP will be set as ONAP_IP environment parameter in install flow. + String msbIp = System.getenv().get(ONAP_IP); + // if ONAP IP is not set. get it from config file. + if (null == msbIp || msbIp.isEmpty()) { + msbIp = env.getProperty("mso.msb-ip", DEFAULT_MSB_IP); + } Integer msbPort = env.getProperty("mso.msb-port", Integer.class, DEFAULT_MSB_PORT); - return UriBuilder.fromPath("").host(msbIp).port(msbPort).scheme("http").build().toString(); + String msbEndpoint = UriBuilder.fromPath("").host(msbIp).port(msbPort).scheme("http").build().toString(); + LOGGER.debug("msbEndpoint in vfc adapter: " + msbEndpoint); + + return msbEndpoint; } private RestfulUtil() { @@ -99,7 +102,7 @@ public class RestfulUtil { public RestfulResponse send(String url, String methodType, String content) { String msbUrl = getMsbHost() + url; - LOGGER.info(MessageEnum.RA_NS_EXC, "Begin to sent message " + methodType +": " + msbUrl, "org.onap.so.adapters.vfc.util.RestfulUtil",VFC_ADAPTER); + LOGGER.debug("Begin to sent message " + methodType +": " + msbUrl); HttpRequestBase method = null; HttpResponse httpResponse = null; 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 dabd3517c3..44ee91885f 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 @@ -31,6 +31,7 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger +import org.onap.so.bpmn.core.UrnPropertiesReader import groovy.json.* import javax.ws.rs.core.Response @@ -43,11 +44,10 @@ import org.onap.so.utils.TargetEntity public class CreateVFCNSResource extends AbstractServiceTaskProcessor { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateVFCNSResource.class); +// String vfcUrl = "/vfc/rest/v1/vfcadapter" - String vfcUrl = "/vfc/rest/v1/vfcadapter" - - String host = "http://mso.mso.testlab.openecomp.org:8080" - +// String host = "http://mso.mso.testlab.openecomp.org:8080" + ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() @@ -116,6 +116,18 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { execution.setVariable("nsParameters", nsParameters) execution.setVariable("nsServiceModelUUID", nsServiceModelUUID); + String vfcAdapterUrl = UrnPropertiesReader.getVariable("mso.adapters.vfc.rest.endpoint", execution) + + if (vfcAdapterUrl == null || vfcAdapterUrl.isEmpty()) { + msg = getProcessKey(execution) + ': mso:adapters:vfcc:rest:endpoint URN mapping is not defined' + msoLogger.debug(msg) + } + + while (vfcAdapterUrl.endsWith('/')) { + vfcAdapterUrl = vfcAdapterUrl.substring(0, vfcAdapterUrl.length()-1) + } + + execution.setVariable("vfcAdapterUrl", vfcAdapterUrl) } catch (BpmnError e) { throw e; @@ -132,6 +144,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { */ public void createNetworkService(DelegateExecution execution) { msoLogger.trace("createNetworkService ") + String vfcAdapterUrl = execution.setVariable("vfcAdapterUrl") String nsOperationKey = execution.getVariable("nsOperationKey"); String nsServiceModelUUID = execution.getVariable("nsServiceModelUUID"); String nsParameters = execution.getVariable("nsParameters"); @@ -149,7 +162,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { "additionalParamForNs":${requestInputs} } }""" - Response apiResponse = postRequest(execution, host + vfcUrl + "/ns", reqBody) + Response apiResponse = postRequest(execution, vfcAdapterUrl + "/ns", reqBody) String returnCode = apiResponse.getStatus() String aaiResponseAsString = apiResponse.readEntity(String.class) String nsInstanceId = ""; @@ -165,6 +178,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { */ public void instantiateNetworkService(DelegateExecution execution) { msoLogger.trace("instantiateNetworkService ") + String vfcAdapterUrl = execution.setVariable("vfcAdapterUrl") String nsOperationKey = execution.getVariable("nsOperationKey"); String nsParameters = execution.getVariable("nsParameters"); String nsServiceName = execution.getVariable("nsServiceName") @@ -176,7 +190,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { "nsParameters":${nsParameters} }""" String nsInstanceId = execution.getVariable("nsInstanceId") - String url = host + vfcUrl + "/ns/" +nsInstanceId + "/instantiate" + String url = vfcAdapterUrl + "/ns/" +nsInstanceId + "/instantiate" Response apiResponse = postRequest(execution, url, reqBody) String returnCode = apiResponse.getStatus() String aaiResponseAsString = apiResponse.readEntity(String.class) @@ -193,9 +207,10 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { */ public void queryNSProgress(DelegateExecution execution) { msoLogger.trace("queryNSProgress ") + String vfcAdapterUrl = execution.setVariable("vfcAdapterUrl") String jobId = execution.getVariable("jobId") String nsOperationKey = execution.getVariable("nsOperationKey"); - String url = host + vfcUrl + "/jobs/" + jobId + String url = vfcAdapterUrl + "/jobs/" + jobId Response apiResponse = postRequest(execution, url, nsOperationKey) String returnCode = apiResponse.getStatus() String aaiResponseAsString = apiResponse.readEntity(String.class) @@ -251,7 +266,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { */ private Response postRequest(DelegateExecution execution, String urlString, String requestBody){ msoLogger.trace("Started Execute VFC adapter Post Process ") - msoLogger.info("url:"+url +"\nrequestBody:"+ requestBody) + msoLogger.info("url:" + urlString +"\nrequestBody:"+ requestBody) Response apiResponse = null try{ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy index 61c88dbb03..f6e4fcc2ba 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy @@ -263,15 +263,14 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ JSONObject resourceRecipe = cutils.getResourceRecipe(execution, resourceModelUUID, requestAction) if (resourceRecipe != null) { - String recipeURL = BPMNProperties.getProperty("bpelURL", "http://bpmn-infra:8081") + resourceRecipe.getString("orchestrationUri") + String recipeURL = BPMNProperties.getProperty("bpelURL", "http://so-bpmn-infra.onap:8081") + resourceRecipe.getString("orchestrationUri") int recipeTimeOut = resourceRecipe.getInt("recipeTimeout") String recipeParamXsd = resourceRecipe.get("paramXSD") BpmnRestClient bpmnRestClient = new BpmnRestClient() HttpResponse resp = bpmnRestClient.post(recipeURL, requestId, recipeTimeOut, requestAction, serviceInstanceId, serviceType, resourceInput, recipeParamXsd) } else { - String exceptionMessage = "Resource receipe is not found for resource modeluuid: " + - resourceInput.getResourceModelInfo().getModelUuid() + String exceptionMessage = "Resource receipe is not found for resource modeluuid: " + resourceModelUUID msoLogger.trace(exceptionMessage) exceptionUtil.buildAndThrowWorkflowException(execution, 500, exceptionMessage) } -- 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') 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 ee8a94ff58552675b37161885ed36fb94caac4e0 Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Sun, 25 Nov 2018 22:49:32 +0530 Subject: Fix intgration issue for E2E service Fix intgration issue for E2E service. Change-Id: I1b701f137ebc79addfb6914c7c68ac8c73f673d4 Issue-ID: SO-1252 Signed-off-by: subhash kumar singh --- .../org/onap/so/adapters/sdnc/impl/SDNCRestClient.java | 2 +- .../scripts/ActivateSDNCNetworkResource.groovy | 15 +++++++-------- .../scripts/CreateSDNCNetworkResource.groovy | 11 ++++------- 3 files changed, 12 insertions(+), 16 deletions(-) (limited to 'adapters') diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java index f842e78916..32769313ed 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java @@ -87,7 +87,7 @@ public class SDNCRestClient{ // Added delay to allow completion of create request to SDNC // before executing activate of create request. try { - Thread.sleep(1000); + Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy index b912b64145..580416ebd2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy @@ -53,7 +53,6 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { MsoUtils msoUtils = new MsoUtils() public void preProcessRequest(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") msoLogger.info(" ***** Started preProcessRequest *****") try { @@ -64,7 +63,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { String resourceInput = execution.getVariable("resourceInput") //Get ResourceInput Object ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class) - execution.setVariable(Prefix + "resourceInput", resourceInputObj) + execution.setVariable(Prefix + "resourceInput", resourceInputObj.toString()) //Deal with recipeParams String recipeParamsFromWf = execution.getVariable("recipeParamXsd") @@ -125,8 +124,8 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception ex){ - msg = "Exception in preProcessRequest " + ex.getMessage() - msoLogger.debug( msg) + String msg = "Exception in preProcessRequest " + ex.getMessage() + msoLogger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } } @@ -398,7 +397,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { } catch (Exception ex) { String exceptionMessage = " Bpmn error encountered in CreateSDNCCNetworkResource flow. prepareSDNCRequest() - " + ex.getMessage() - msoLogger.debug( exceptionMessage) + msoLogger.debug(exceptionMessage) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) } @@ -415,7 +414,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { } public void sendSyncResponse(DelegateExecution execution) { - msoLogger.dubug(" *** sendSyncResponse *** ") + msoLogger.info("started sendsyncResp") try { String operationStatus = "finished" @@ -427,9 +426,9 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { } catch (Exception ex) { String msg = "Exception in sendSyncResponse:" + ex.getMessage() - msoLogger.debug( msg) + msoLogger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - msoLogger.dubug(" ***** Exit sendSyncResponse *****") + msoLogger.info("exited sendsyncResp") } } \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy index a505f3ff5e..8e168a3cf1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy @@ -203,7 +203,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.access-ltp-id", inputParameters.get("local-access-ltp-id")) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.access-node-id", inputParameters.get("local-access-node-id")) resourceInputObj.setResourceParameters(uResourceInput) - execution.setVariable(Prefix + "resourceInput", resourceInputObj) + execution.setVariable(Prefix + "resourceInput", resourceInputObj.toString()) } break @@ -539,10 +539,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { private def getInstnaceId(DelegateExecution execution) { def responce = new XmlSlurper().parseText(execution.getVariable("CRENWKI_createSDNCResponse")) - def data = responce.toString() - data = data.substring(data.indexOf("<")) - def resp = new XmlSlurper().parseText(data) ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(execution.getVariable(Prefix + "resourceInput"), ResourceInput.class) String modelName = resourceInputObj.getResourceModelInfo().getModelName() def val = "" @@ -550,18 +547,18 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { switch (modelName) { case ~/[\w\s\W]*SOTNConnectivity[\w\s\W]*/ : case ~/[\w\s\W]*SDWANConnectivity[\w\s\W]*/ : - val = resp."network-response-information"."instance-id" + val = responce."response-data"."RequestData"."output"."network-response-information"."instance-id" break case ~/[\w\s\W]*deviceVF[\w\s\W]*/ : case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ : case ~/[\w\s\W]*Site[\w\s\W]*/: - val = resp."vnf-response-information"."instance-id" + val = responce."response-data"."RequestData"."output"."vnf-response-information"."instance-id" break case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ : case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/: - val = resp."connection-attachment-response-information"."instance-id" + val = responce."response-data"."RequestData"."output"."connection-attachment-response-information"."instance-id" break } -- 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') 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') 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 89f41fc779523f9234635d3e4e4841d316c2a0cf Mon Sep 17 00:00:00 2001 From: Yulian Han Date: Thu, 29 Nov 2018 17:30:55 +0800 Subject: vfc adapter authentication bug fix Change-Id: Idaa55084f5ecb0dd3636c232cebc14fa5f064414 Issue-ID: SO-1256 Signed-off-by: Yulian Han --- .../org/onap/so/adapters/vfc/CXFConfiguration.java | 4 +- .../so/adapters/vfc/WebSecurityConfigImpl.java | 51 ++++++++++ .../scripts/CreateVFCNSResource.groovy | 100 ++++--------------- .../DoCreateVFCNetworkServiceInstance.groovy | 63 +++++++----- .../DoDeleteVFCNetworkServiceInstance.groovy | 110 +++++++++++++-------- 5 files changed, 177 insertions(+), 151 deletions(-) create mode 100644 adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/WebSecurityConfigImpl.java (limited to 'adapters') diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/CXFConfiguration.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/CXFConfiguration.java index 031bc2edc5..ea1c3805d1 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/CXFConfiguration.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/CXFConfiguration.java @@ -79,11 +79,11 @@ public class CXFConfiguration { public Swagger2Feature createSwaggerFeature() { Swagger2Feature swagger2Feature = new Swagger2Feature(); swagger2Feature.setPrettyPrint(true); - swagger2Feature.setTitle("SO Request Adapter"); + swagger2Feature.setTitle("SO VFC Adapter"); swagger2Feature.setContact("The ONAP SO team"); swagger2Feature.setDescription("This project is the SO Orchestration Engine"); swagger2Feature.setVersion("1.0.0"); - swagger2Feature.setResourcePackage("org.onap.so.adapters.requestdb"); + swagger2Feature.setResourcePackage("org.onap.so.adapters.vfc.rest"); swagger2Feature.setScan(true); return swagger2Feature; } diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/WebSecurityConfigImpl.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/WebSecurityConfigImpl.java new file mode 100644 index 0000000000..37a5633d8d --- /dev/null +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/WebSecurityConfigImpl.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T 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.adapters.vfc; + +import org.onap.so.security.MSOSpringFirewall; +import org.onap.so.security.WebSecurityConfig; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.builders.WebSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.web.firewall.StrictHttpFirewall; +import org.springframework.util.StringUtils; + +@EnableWebSecurity +public class WebSecurityConfigImpl extends WebSecurityConfig { + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.csrf().disable() + .authorizeRequests() + .antMatchers("/manage/health","/manage/info","/services").permitAll() + .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(),",").toString()) + .and() + .httpBasic(); + } + + @Override + public void configure(WebSecurity web) throws Exception { + super.configure(web); + StrictHttpFirewall firewall = new MSOSpringFirewall(); + web.httpFirewall(firewall); + } + +} \ No newline at end of file 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 34f2f0157d..94df0a977a 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 @@ -39,7 +39,7 @@ import org.onap.so.bpmn.core.UrnPropertiesReader import groovy.json.* //import javax.ws.rs.core.Response -import org.onap.so.utils.TargetEntity +//import org.onap.so.utils.TargetEntity /** * This groovy class supports the DoCreateVFCNetworkServiceInstance.bpmn process. @@ -272,96 +272,30 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { msoLogger.trace("Started Execute VFC adapter Post Process ") msoLogger.info("url:" + urlString +"\nrequestBody:"+ requestBody) APIResponse apiResponse = null -// try{ - -// URL url = new URL(urlString); - -// HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER) -// httpClient.addAdditionalHeader("Accept", "application/json") -// httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk") - -// apiResponse = httpClient.post(requestBody) -// msoLogger.info("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class)) - - // Get the Basic Auth credentials for the VFCAdapter (yes... we ARE using the PO adapters credentials) - String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) - - msoLogger.debug("basicAuthValuePO: " + basicAuthValuePO) - if (basicAuthValuePO == null || basicAuthValuePO.isEmpty()) { - msoLogger.debug("mso:adapters:po:auth URN mapping is not defined") - } - - RESTConfig config = new RESTConfig(urlString) - RESTClient client = null; - int statusCode = 0; - try { - client = new RESTClient(config).addHeader("Accept", "application/json").addAuthorizationHeader(basicAuthValuePO) - - apiResponse = client.httpPost(requestBody) + try{ + // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7' + def basicAuthHeaderValue = "" + RESTConfig config = new RESTConfig(urlString) + RESTClient client = null; + int statusCode = 0; - statusCode = apiResponse.getStatusCode() + // user 'bepl' authHeader is the same with mso.db.auth + String basicAuthValuedb = UrnPropertiesReader.getVariable("mso.db.auth", execution) + + client = new RESTClient(config) + client.addHeader("Accept", "application/json") + client.addAuthorizationHeader(basicAuthValuedb) + client.addHeader("Content-Type", "application/json") - if(statusCode == 200 || statusCode == 201) { - return apiResponse - } - }catch(Exception e){ - msoLogger.error("VFC Aatpter Post Call Exception using mso.adapters.po.auth:" + e.getMessage()); - } - - msoLogger.debug("response code:"+ statusCode +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) - - msoLogger.debug("VFC Aatpter Post Call using mso.msoKey") - String basicAuthValue = UrnPropertiesReader.getVariable("mso.msoKey", execution) - msoLogger.debug("basicAuthValue: " + basicAuthValue) - if (basicAuthValue == null || basicAuthValue.isEmpty()) { - msoLogger.debug("mso:msoKey URN mapping is not defined") - } - try { - client = new RESTClient(config).addHeader("Accept", "application/json").addAuthorizationHeader(basicAuthValue) - apiResponse = client.httpPost(requestBody) - statusCode = apiResponse.getStatusCode() - if(statusCode == 200 || statusCode == 201) { - return apiResponse - } - }catch(Exception e){ - msoLogger.error("VFC Aatpter Post Call Exception using mso.msoKey:" + e.getMessage()); - - } - - msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) + msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) - msoLogger.debug("VFC Aatpter Post Call using mso.db.auth") - String basicAuthValuedb = UrnPropertiesReader.getVariable("mso.db.auth", execution) - msoLogger.debug("basicAuthValuedb: " + basicAuthValuedb) - if (basicAuthValuedb == null || basicAuthValuedb.isEmpty()) { - msoLogger.debug("mso:db.auth URN mapping is not defined") - } - try { - client = new RESTClient(config).addHeader("Accept", "application/json").addAuthorizationHeader(basicAuthValuedb) - - apiResponse = client.httpPost(requestBody) - statusCode = apiResponse.getStatusCode() - - if(statusCode == 200 || statusCode == 201) { - return apiResponse - } }catch(Exception e){ - msoLogger.error("VFC Aatpter Post Call Exception using mso.msoKey:" + e.getMessage()); - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "VFC Aatpter Post Call Exception by using mso.msoKey or mso.adapters.po.auth") + msoLogger.error("Exception occured while executing VF-C Post Call. Exception is: \n" + e.getMessage()); + throw new BpmnError("MSOWorkflowException") } - - - msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) - String auth = "Basic QlBFTENsaWVudDpwYXNzd29yZDEk" - msoLogger.debug("auth: " + basicAuthValuedb) - client = new RESTClient(config).addHeader("Accept", "application/json").addAuthorizationHeader(auth) - - apiResponse = client.httpPost(requestBody) - - msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) msoLogger.trace("Completed Execute VF-C adapter Post Process ") 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 f4a542afe9..0502f7949a 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 @@ -28,15 +28,18 @@ import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.client.HttpClient +//import org.onap.so.client.HttpClient import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger +import org.onap.so.rest.APIResponse +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.utils.TargetEntity +//import org.onap.so.utils.TargetEntity import groovy.json.* -import javax.ws.rs.core.Response +//import javax.ws.rs.core.Response /** * This groovy class supports the DoCreateVFCNetworkServiceInstance.bpmn process. @@ -138,7 +141,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces "nsOperationKey":${nsOperationKey}, "nsParameters":${nsParameters} }""" - Response apiResponse = postRequest(execution, vfcAdapterUrl + "/ns", reqBody) + APIResponse apiResponse = postRequest(execution, vfcAdapterUrl + "/ns", reqBody) String returnCode = apiResponse.getStatus() String aaiResponseAsString = apiResponse.readEntity(String.class) String nsInstanceId = ""; @@ -167,7 +170,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces }""" String nsInstanceId = execution.getVariable("nsInstanceId") String url = vfcAdapterUrl + "/ns/" +nsInstanceId + "/instantiate" - Response apiResponse = postRequest(execution, url, reqBody) + APIResponse apiResponse = postRequest(execution, url, reqBody) String returnCode = apiResponse.getStatus() String aaiResponseAsString = apiResponse.readEntity(String.class) String jobId = ""; @@ -187,7 +190,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces String jobId = execution.getVariable("jobId") String nsOperationKey = execution.getVariable("nsOperationKey"); String url = vfcAdapterUrl + "/jobs/" + jobId - Response apiResponse = postRequest(execution, url, nsOperationKey) + APIResponse apiResponse = postRequest(execution, url, nsOperationKey) String returnCode = apiResponse.getStatus() String aaiResponseAsString = apiResponse.readEntity(String.class) String operationStatus = "error" @@ -240,26 +243,38 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces * url: the url of the request * requestBody: the body of the request */ - private Response postRequest(DelegateExecution execution, String urlString, String requestBody){ + private APIResponse postRequest(DelegateExecution execution, String urlString, String requestBody){ msoLogger.trace("Started Execute VFC adapter Post Process") msoLogger.debug("url:"+urlString +"\nrequestBody:"+ requestBody) - Response apiResponse = null - try{ - - URL url = new URL(urlString); - - HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER) - httpClient.addAdditionalHeader("Accept", "application/json") - httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk") - - apiResponse = httpClient.post(requestBody) - - msoLogger.debug("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class)) - msoLogger.trace("Completed Execute VF-C adapter Post Process") - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Post Call", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); - throw new BpmnError("MSOWorkflowException") - } + APIResponse apiResponse = null + try{ + // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7' + def basicAuthHeaderValue = "" + RESTConfig config = new RESTConfig(urlString) + RESTClient client = null; + int statusCode = 0; + + // user 'bepl' authHeader is the same with mso.db.auth + String basicAuthValuedb = UrnPropertiesReader.getVariable("mso.db.auth", execution) + msoLogger.debug("basicAuthValuedb: " + basicAuthValuedb) + + client = new RESTClient(config) + client.addHeader("Accept", "application/json") + client.addAuthorizationHeader(basicAuthValuedb) + client.addHeader("Content-Type", "application/json") + + apiResponse = client.httpPost(requestBody) + statusCode = apiResponse.getStatusCode() + + msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) + + }catch(Exception e){ + msoLogger.error("Exception occured while executing VF-C Post Call. Exception is: \n" + e.getMessage()); + throw new BpmnError("MSOWorkflowException") + } + + msoLogger.trace("Completed Execute VF-C adapter Post Process ") + return apiResponse } } 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 e0586163f1..5ff93363d2 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 @@ -25,16 +25,19 @@ import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.client.HttpClient +//import org.onap.so.client.HttpClient import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger -import org.onap.so.utils.TargetEntity +import org.onap.so.rest.APIResponse +import org.onap.so.rest.RESTClient +import org.onap.so.rest.RESTConfig +//import org.onap.so.utils.TargetEntity import org.onap.so.bpmn.core.UrnPropertiesReader -import javax.ws.rs.core.Response +//import javax.ws.rs.core.Response /** * This groovy class supports the DoDeleteVFCNetworkServiceInstance.bpmn process. * flow for E2E ServiceInstance Delete @@ -136,8 +139,9 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl") String nsOperationKey = execution.getVariable("nsOperationKey"); String url = vfcAdapterUrl + "/ns/" + execution.getVariable("nsInstanceId") - Response apiResponse = deleteRequest(execution, url, nsOperationKey) - String returnCode = apiResponse.getStatus() + APIResponse apiResponse = deleteRequest(execution, url, nsOperationKey) + String returnCode = apiResponse.getStatusCode() + String aaiResponseAsString = apiResponse.getResponseBodyAsString() String operationStatus = "error"; if(returnCode== "200" || returnCode== "202"){ operationStatus = "finished" @@ -148,7 +152,7 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces } /** - * instantiate NS task + * terminate NS task */ public void terminateNetworkService(DelegateExecution execution) { @@ -156,9 +160,9 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl") String nsOperationKey = execution.getVariable("nsOperationKey") String url = vfcAdapterUrl + "/ns/" + execution.getVariable("nsInstanceId") + "/terminate" - Response apiResponse = postRequest(execution, url, nsOperationKey) - String returnCode = apiResponse.getStatus() - String aaiResponseAsString = apiResponse.readEntity(String.class) + APIResponse apiResponse = postRequest(execution, url, nsOperationKey) + String returnCode = apiResponse.getStatusCode() + String aaiResponseAsString = apiResponse.getResponseBodyAsString() String jobId = ""; if(returnCode== "200" || returnCode== "202"){ jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId") @@ -177,9 +181,9 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces String jobId = execution.getVariable("jobId") String nsOperationKey = execution.getVariable("nsOperationKey"); String url = vfcAdapterUrl + "/jobs/" + execution.getVariable("jobId") - Response apiResponse = postRequest(execution, url, nsOperationKey) - String returnCode = apiResponse.getStatus() - String apiResponseAsString = apiResponse.readEntity(String.class) + APIResponse apiResponse = postRequest(execution, url, nsOperationKey) + String returnCode = apiResponse.getStatusCode() + String apiResponseAsString = apiResponse.getResponseBodyAsString() String operationProgress = "100" if(returnCode== "200"){ operationProgress = jsonUtil.getJsonValue(apiResponseAsString, "responseDescriptor.progress") @@ -211,25 +215,34 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces * url: the url of the request * requestBody: the body of the request */ - private Response postRequest(DelegateExecution execution, String urlString, String requestBody){ + private APIResponse postRequest(DelegateExecution execution, String urlString, String requestBody){ msoLogger.trace("Started Execute VFC adapter Post Process ") msoLogger.info("url:"+urlString +"\nrequestBody:"+ requestBody) - Response apiResponse = null + APIResponse apiResponse = null try{ - URL url = new URL(urlString); - - HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER) - httpClient.addAdditionalHeader("Accept", "application/json") - httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk") - - apiResponse = httpClient.post(requestBody) - - msoLogger.debug("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class)) - - msoLogger.trace("Completed Execute VF-C adapter Post Process ") + // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7' + def basicAuthHeaderValue = "" + RESTConfig config = new RESTConfig(urlString) + RESTClient client = null; + int statusCode = 0; + + // user 'bepl' authHeader is the same with mso.db.auth + String basicAuthValuedb = UrnPropertiesReader.getVariable("mso.db.auth", execution) + msoLogger.debug("basicAuthValuedb: " + basicAuthValuedb) + + client = new RESTClient(config) + client.addHeader("Accept", "application/json") + client.addAuthorizationHeader(basicAuthValuedb) + client.addHeader("Content-Type", "application/json") + + apiResponse = client.httpPost(requestBody) + statusCode = apiResponse.getStatusCode() + + msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) + }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing VF-C Post Call. Exception is: \n" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); + msoLogger.error("Exception occured while executing VF-C Post Call. Exception is: \n" + e.getMessage()); throw new BpmnError("MSOWorkflowException") } return apiResponse @@ -239,24 +252,37 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces * url: the url of the request * requestBody: the body of the request */ - private Response deleteRequest(DelegateExecution execution, String url, String requestBody){ + private APIResponse deleteRequest(DelegateExecution execution, String url, String requestBody){ msoLogger.trace("Started Execute VFC adapter Delete Process ") msoLogger.info("url:"+url +"\nrequestBody:"+ requestBody) - Response r - try{ - - URL Url = new URL(url) - HttpClient httpClient = new HttpClient(Url, "application/json", TargetEntity.VNF_ADAPTER) - httpClient.addAdditionalHeader("Accept", "application/json") - httpClient.addAdditionalHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk") - r = httpClient.delete(requestBody) - - msoLogger.trace("Completed Execute VF-C adapter Delete Process ") - }catch(Exception e){ - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing VF-C Post Call. Exception is: \n" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e); - throw new BpmnError("MSOWorkflowException") - } - return r + + APIResponse apiResponse = null + try{ + // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7' + def basicAuthHeaderValue = "" + RESTConfig config = new RESTConfig(url) + RESTClient client = null; + int statusCode = 0; + + // user 'bepl' authHeader is the same with mso.db.auth + String basicAuthValuedb = UrnPropertiesReader.getVariable("mso.db.auth", execution) + msoLogger.debug("basicAuthValuedb: " + basicAuthValuedb) + + client = new RESTClient(config) + client.addHeader("Accept", "application/json") + client.addAuthorizationHeader(basicAuthValuedb) + client.addHeader("Content-Type", "application/json") + + apiResponse = client.httpDelete(requestBody) + statusCode = apiResponse.getStatusCode() + + msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString()) + + }catch(Exception e){ + msoLogger.error("Exception occured while executing VF-C Delete Call. Exception is: \n" + e.getMessage()); + throw new BpmnError("MSOWorkflowException") + } + return apiResponse } } -- cgit 1.2.3-korg From 3ed6ba21356ec2d03e4d42d1f593f6292d05154d Mon Sep 17 00:00:00 2001 From: Yulian Han Date: Thu, 29 Nov 2018 17:55:53 +0800 Subject: update OperationStatus Based On ResourceStatus Change-Id: Idaa55084f5ecb0dd3636c232cebc14fa5f064415 Issue-ID: SO-1256 Signed-off-by: Yulian Han --- .../requestsdb/MsoRequestsDbAdapterImpl.java | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'adapters') diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java index 762c76fc77..a849478907 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java @@ -23,6 +23,8 @@ package org.onap.so.adapters.requestsdb; import java.sql.Timestamp; +import java.util.List; + import javax.jws.WebService; import javax.transaction.Transactional; import org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException; @@ -334,5 +336,65 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { resStatus.setErrorCode(errorCode); resStatus.setStatusDescription(statusDescription); resourceOperationStatusRepository.save(resStatus); + + updateOperationStatusBasedOnResourceStatus(resStatus); } + + /** + * update service operation status when a operation resource status updated + *
+ * + * @param operStatus the resource operation status + * @since ONAP Amsterdam Release + */ + private void updateOperationStatusBasedOnResourceStatus(ResourceOperationStatus operStatus) { + String serviceId = operStatus.getServiceId(); + String operationId = operStatus.getOperationId(); + + logger.debug("Request database - update Operation Status Based On Resource Operation Status with service Id:" + + serviceId + ", operationId:" + operationId); + + List lstResourceStatus = resourceOperationStatusRepository.findByServiceIdAndOperationId(serviceId, operationId); + if (lstResourceStatus == null) { + logger.error("Unable to retrieve resourceOperStatus Object by ServiceId: " + serviceId + " operationId: " + operationId); + return; + } + + // count the total progress + int resourceCount = lstResourceStatus.size(); + int progress = 0; + boolean isFinished = true; + for (ResourceOperationStatus lstResourceStatu : lstResourceStatus) { + progress = progress + Integer.valueOf(lstResourceStatu.getProgress()) / resourceCount; + if (RequestsDbConstant.Status.PROCESSING.equals(lstResourceStatu.getStatus())) { + isFinished = false; + } + } + + OperationStatus serviceOperStatus = operationStatusRepository.findOneByServiceIdAndOperationId(serviceId, operationId); + if (serviceOperStatus == null) { + String error = "Entity not found. Unable to retrieve OperationStatus Object ServiceId: " + serviceId + " operationId: " + + operationId; + logger.error(error); + + serviceOperStatus = new OperationStatus(); + serviceOperStatus.setOperationId(operationId); + serviceOperStatus.setServiceId(serviceId); + } + + progress = progress > 100 ? 100 : progress; + serviceOperStatus.setProgress(String.valueOf(progress)); + serviceOperStatus.setOperationContent(operStatus.getStatusDescription()); + // if current resource failed. service failed. + if(RequestsDbConstant.Status.ERROR.equals(operStatus.getStatus())) { + serviceOperStatus.setResult(RequestsDbConstant.Status.ERROR); + serviceOperStatus.setReason(operStatus.getStatusDescription()); + } else if(isFinished) { + // if finished + serviceOperStatus.setResult(RequestsDbConstant.Status.FINISHED); + serviceOperStatus.setProgress(RequestsDbConstant.Progress.ONE_HUNDRED); + } + + operationStatusRepository.save(serviceOperStatus); + } } -- 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') 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 2daba40082a5ed3ce9111a8ba821b716b90f5a43 Mon Sep 17 00:00:00 2001 From: Eric Multanen Date: Fri, 30 Nov 2018 01:54:59 -0800 Subject: Fix multicloud with no oof or sdnc directives Allow the multicloud adapter to work if no oof or sdnc directives are passed in - use an empty json node - e.g. {}. Change-Id: Ia701051de8a3da314957e4a4085963af6aff16b6 Issue-ID: SO-1247 Signed-off-by: Eric Multanen Signed-off-by: Marcus G K Williams --- .../so/openstack/utils/MsoMulticloudUtils.java | 47 +++++++++++++--------- .../vnf/MsoVnfMulticloudAdapterImplTest.java | 4 +- 2 files changed, 29 insertions(+), 22 deletions(-) (limited to 'adapters') diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java index d036468808..73e0da1cd9 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java @@ -45,6 +45,7 @@ import org.onap.so.adapters.vdu.VduStateType; import org.onap.so.adapters.vdu.VduStatus; import org.onap.so.openstack.beans.HeatStatus; import org.onap.so.openstack.beans.StackInfo; +import org.onap.so.openstack.exceptions.MsoAdapterException; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; import org.onap.so.openstack.exceptions.MsoException; import org.onap.so.openstack.exceptions.MsoOpenstackException; @@ -149,8 +150,8 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ logger.trace("Started MsoMulticloudUtils.createStack"); // Get the directives, if present. - String oofDirectives = ""; - String sdncDirectives = ""; + String oofDirectives = "{}"; + String sdncDirectives = "{}"; String genericVnfId = ""; String vfModuleId = ""; String templateType = ""; @@ -185,26 +186,17 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ MulticloudRequest multicloudRequest= new MulticloudRequest(); - try { - multicloudRequest.setGenericVnfId(genericVnfId); - multicloudRequest.setVfModuleId(vfModuleId); - multicloudRequest.setOofDirectives(JSON_MAPPER.readTree(oofDirectives)); - multicloudRequest.setSdncDirectives(JSON_MAPPER.readTree(sdncDirectives)); - multicloudRequest.setTemplateType(templateType); - if (logger.isDebugEnabled()) { - logger.debug(String.format("Stack Template Data is: %s", stack.toString().substring(16))); - } - multicloudRequest.setTemplateData(stack); - if (logger.isDebugEnabled()) { - logger.debug(String.format("Multicloud Request is: %s", multicloudRequest.toString())); - } - } catch (Exception e) { - logger.debug("ERROR making multicloud JSON body ", e); - } - String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, null); + multicloudRequest.setGenericVnfId(genericVnfId); + multicloudRequest.setVfModuleId(vfModuleId); + multicloudRequest.setTemplateType(templateType); + multicloudRequest.setTemplateData(stack); + multicloudRequest.setOofDirectives(getDirectiveNode(oofDirectives)); + multicloudRequest.setSdncDirectives(getDirectiveNode(sdncDirectives)); if (logger.isDebugEnabled()) { - logger.debug(String.format("Multicloud Endpoint is: %s", multicloudEndpoint)); + logger.debug(String.format("Multicloud Request is: %s", multicloudRequest.toString())); } + + String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, null); RestClient multicloudClient = getMulticloudClient(multicloudEndpoint); Response response = multicloudClient.post(multicloudRequest); @@ -617,6 +609,21 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ return client; } + private JsonNode getDirectiveNode(String directives) throws MsoException { + try { + return JSON_MAPPER.readTree(directives); + } catch (Exception e) { + logger.error(String.format("%d %s %s %s %d %s", + MessageEnum.RA_CREATE_STACK_ERR, + "Create Stack: " + e, "", "", + MsoLogger.ErrorCode.BusinessProcesssError, + "Exception in Create Stack: Invalid JSON format of directives" + directives)); + MsoException me = new MsoAdapterException("Invalid JSON format of directives parameter: " + directives); + me.addContext(CREATE_STACK); + throw me; + } + } + /** * VduPlugin interface for instantiate function. * diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java index b6f1ad1dcd..20c2231032 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java @@ -67,8 +67,8 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils{ public void createVfModule() throws Exception { //expectedException.expect(VnfException.class); Map stackInputs = new HashMap<>(); - stackInputs.put("oof_directives", "{oofDIRECTIVES}"); - stackInputs.put("sdnc_directives", "{sdncDIRECTIVES}"); + stackInputs.put("oof_directives", "{}"); + stackInputs.put("sdnc_directives", "{}"); stackInputs.put("generic_vnf_id", "genVNFID"); stackInputs.put("vf_module_id", "vfMODULEID"); -- 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') 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') 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 8521170839c30e240eac51b0daa5544293dac7b3 Mon Sep 17 00:00:00 2001 From: Eric Multanen Date: Thu, 20 Dec 2018 08:38:23 -0800 Subject: Fixup multicloud log exceptions and error cases Fix log calls which would have an exception. Throw and mso exception when call to multicloud fails to create a stack. Change-Id: Ib103c6f4420e444734bbb715699eb57ffc110925 Issue-ID: SO-1336 Signed-off-by: Eric Multanen --- .../so/openstack/utils/MsoMulticloudUtils.java | 41 +++++++++++++--------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'adapters') diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java index 73e0da1cd9..0e37ce3552 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java @@ -205,17 +205,24 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ createInfo.setName(stackName); MulticloudCreateResponse multicloudResponseBody = null; - if (response.getStatus() == Response.Status.CREATED.getStatusCode() && response.hasEntity()) { + if (response.hasEntity()) { multicloudResponseBody = getCreateBody((java.io.InputStream)response.getEntity()); + } + if (response.getStatus() == Response.Status.CREATED.getStatusCode() && response.hasEntity()) { createInfo.setCanonicalName(stackName + "/" + multicloudResponseBody.getWorkloadId()); if (logger.isDebugEnabled()) { logger.debug("Multicloud Create Response Body: " + multicloudResponseBody); } return getStackStatus(cloudSiteId, tenantId, createInfo.getCanonicalName(), pollForCompletion, timeoutMinutes, backout); } else { - createInfo.setStatus(HeatStatus.FAILED); - createInfo.setStatusMessage(response.getStatusInfo().getReasonPhrase()); - return createInfo; + StringBuilder stackErrorStatusReason = new StringBuilder(response.getStatusInfo().getReasonPhrase()); + if (null != multicloudResponseBody) { + stackErrorStatusReason.append(multicloudResponseBody.toString()); + } + MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString()); + me.addContext(CREATE_STACK); + alarmLogger.sendAlarm(HEAT_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage()); + throw me; } } @@ -383,7 +390,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ if (pollTimeout <= 0) { // Note that this should not occur, since there is a timeout specified // in the Openstack (multicloud?) call. - logger.error(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, instanceId, stackInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError, "Create stack timeout")); + logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId, stackInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError, "Create stack timeout")); createTimedOut = true; break; } @@ -401,7 +408,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ // Cannot query the stack status. Something is wrong. // Try to roll back the stack if (!backout) { - logger.warn(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in Create Stack, stack deletion suppressed")); + logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack error, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in Create Stack, stack deletion suppressed")); } else { try { logger.debug("Create Stack error - unable to query for stack status - attempting to delete stack: " + instanceId + " - This will likely fail and/or we won't be able to query to see if delete worked"); @@ -415,7 +422,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ logger.debug("Deleting " + instanceId + ", status: " + queryInfo.getStatus()); if (HeatStatus.DELETING.equals(queryInfo.getStatus())) { if (deletePollTimeout <= 0) { - logger.error(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, instanceId, + logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId, queryInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError, "Rollback: DELETE stack timeout")); break; @@ -433,12 +440,12 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ } } catch (Exception e3) { // Just log this one. We will report the original exception. - logger.error(String.format("%d %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack: Nested exception rolling back stack: " + e3, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack: Nested exception rolling back stack on error on query")); + logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e3, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack: Nested exception rolling back stack on error on query")); } } } catch (Exception e2) { // Just log this one. We will report the original exception. - logger.error(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack: Nested exception rolling back stack")); + logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack: Nested exception rolling back stack")); } } @@ -449,12 +456,12 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ } if (!HeatStatus.CREATED.equals(stackInfo.getStatus())) { - logger.error(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack error: Polling complete with non-success status: " + logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack error: Polling complete with non-success status: " + stackInfo.getStatus () + ", " + stackInfo.getStatusMessage(), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error")); // Rollback the stack creation, since it is in an indeterminate state. if (!backout) { - logger.warn(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error, stack deletion suppressed")); + logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error, stack deletion suppressed")); } else { @@ -469,7 +476,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ logger.debug("Deleting " + instanceId + ", status: " + queryInfo.getStatus()); if (HeatStatus.DELETING.equals(queryInfo.getStatus())) { if (deletePollTimeout <= 0) { - logger.error(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, instanceId, + logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId, queryInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError, "Rollback: DELETE stack timeout")); break; @@ -483,14 +490,14 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ continue; } else { //got a status other than DELETE_IN_PROGRESS or DELETE_COMPLETE - so break and evaluate - logger.warn(String.format("%d %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, stack deletion FAILED", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error, stack deletion FAILED")); + logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, stack deletion FAILED", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error, stack deletion FAILED")); logger.debug("Stack deletion FAILED on a rollback of a create - " + instanceId + ", status=" + queryInfo.getStatus() + ", reason=" + queryInfo.getStatusMessage()); break; } } catch (MsoException me2) { // Just log this one. We will report the original exception. logger.debug("Exception thrown trying to delete " + instanceId + " on a create->rollback: " + me2.getContextMessage(), me2); - logger.warn(String.format("%d %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, then stack deletion FAILED - exception thrown", "", "", MsoLogger.ErrorCode.BusinessProcesssError, me2.getContextMessage())); + logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, then stack deletion FAILED - exception thrown", "", "", MsoLogger.ErrorCode.BusinessProcesssError, me2.getContextMessage())); } } StringBuilder errorContextMessage; @@ -506,7 +513,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ } } catch (MsoException e2) { // shouldn't happen - but handle - logger.error(String.format("%d %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in Create Stack: rolling back stack")); + logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in Create Stack: rolling back stack")); } } MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString()); @@ -613,8 +620,8 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ try { return JSON_MAPPER.readTree(directives); } catch (Exception e) { - logger.error(String.format("%d %s %s %s %d %s", - MessageEnum.RA_CREATE_STACK_ERR, + logger.error(String.format("%s %s %s %s %d %s", + MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: " + e, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in Create Stack: Invalid JSON format of directives" + directives)); -- cgit 1.2.3-korg From c701db8a45a5fd8be96d064e40422567975fffb3 Mon Sep 17 00:00:00 2001 From: Eric Multanen Date: Fri, 21 Dec 2018 08:13:04 -0800 Subject: Fixup multicloud log exceptions part 2 One more fixup for logging calls which would have an exception. Change-Id: Id29324309400be5e4fdcf25cf8dd29929d10e6c1 Issue-ID: SO-1336 Signed-off-by: Eric Multanen --- .../so/openstack/utils/MsoMulticloudUtils.java | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'adapters') diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java index 0e37ce3552..8d700751a9 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java @@ -390,7 +390,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ if (pollTimeout <= 0) { // Note that this should not occur, since there is a timeout specified // in the Openstack (multicloud?) call. - logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId, stackInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError, "Create stack timeout")); + logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId, stackInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError.getValue(), "Create stack timeout")); createTimedOut = true; break; } @@ -408,7 +408,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ // Cannot query the stack status. Something is wrong. // Try to roll back the stack if (!backout) { - logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack error, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in Create Stack, stack deletion suppressed")); + logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack error, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception in Create Stack, stack deletion suppressed")); } else { try { logger.debug("Create Stack error - unable to query for stack status - attempting to delete stack: " + instanceId + " - This will likely fail and/or we won't be able to query to see if delete worked"); @@ -423,7 +423,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ if (HeatStatus.DELETING.equals(queryInfo.getStatus())) { if (deletePollTimeout <= 0) { logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId, - queryInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError, + queryInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError.getValue(), "Rollback: DELETE stack timeout")); break; } else { @@ -440,12 +440,12 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ } } catch (Exception e3) { // Just log this one. We will report the original exception. - logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e3, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack: Nested exception rolling back stack on error on query")); + logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e3, "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Create Stack: Nested exception rolling back stack on error on query")); } } } catch (Exception e2) { // Just log this one. We will report the original exception. - logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack: Nested exception rolling back stack")); + logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Create Stack: Nested exception rolling back stack")); } } @@ -457,11 +457,11 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ if (!HeatStatus.CREATED.equals(stackInfo.getStatus())) { logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack error: Polling complete with non-success status: " - + stackInfo.getStatus () + ", " + stackInfo.getStatusMessage(), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error")); + + stackInfo.getStatus () + ", " + stackInfo.getStatusMessage(), "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Create Stack error")); // Rollback the stack creation, since it is in an indeterminate state. if (!backout) { - logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error, stack deletion suppressed")); + logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Create Stack error, stack deletion suppressed")); } else { @@ -477,7 +477,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ if (HeatStatus.DELETING.equals(queryInfo.getStatus())) { if (deletePollTimeout <= 0) { logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId, - queryInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError, + queryInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError.getValue(), "Rollback: DELETE stack timeout")); break; } else { @@ -490,14 +490,14 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ continue; } else { //got a status other than DELETE_IN_PROGRESS or DELETE_COMPLETE - so break and evaluate - logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, stack deletion FAILED", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error, stack deletion FAILED")); + logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, stack deletion FAILED", "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Create Stack error, stack deletion FAILED")); logger.debug("Stack deletion FAILED on a rollback of a create - " + instanceId + ", status=" + queryInfo.getStatus() + ", reason=" + queryInfo.getStatusMessage()); break; } } catch (MsoException me2) { // Just log this one. We will report the original exception. logger.debug("Exception thrown trying to delete " + instanceId + " on a create->rollback: " + me2.getContextMessage(), me2); - logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, then stack deletion FAILED - exception thrown", "", "", MsoLogger.ErrorCode.BusinessProcesssError, me2.getContextMessage())); + logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, then stack deletion FAILED - exception thrown", "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), me2.getContextMessage())); } } StringBuilder errorContextMessage; @@ -513,7 +513,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ } } catch (MsoException e2) { // shouldn't happen - but handle - logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in Create Stack: rolling back stack")); + logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception in Create Stack: rolling back stack")); } } MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString()); @@ -623,7 +623,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: " + e, "", "", - MsoLogger.ErrorCode.BusinessProcesssError, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception in Create Stack: Invalid JSON format of directives" + directives)); MsoException me = new MsoAdapterException("Invalid JSON format of directives parameter: " + directives); me.addContext(CREATE_STACK); -- 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') 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') 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') 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') 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') 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') 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