diff options
54 files changed, 1414 insertions, 308 deletions
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 aa039c6ac4..3f1e99c44b 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 @@ -36,6 +36,7 @@ import javax.ws.rs.core.GenericEntity; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpStatus; import org.onap.so.adapters.catalogdb.catalogrest.CatalogQuery; import org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException; @@ -89,6 +90,7 @@ 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"; + private static final String RESOURCE_INPUT_FILTER = "resourceInput"; @Autowired private VnfCustomizationRepository vnfCustomizationRepo; @@ -144,8 +146,8 @@ public class CatalogDbAdapterRest { @Transactional(readOnly = true) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response serviceVnfs(@PathParam("version") String version, - @PathParam("vnfModelCustomizationUuid") String vnfUuid) { - return serviceVnfsImpl(version, !IS_ARRAY, vnfUuid, null, null, null, null); + @PathParam("vnfModelCustomizationUuid") String vnfUuid, @QueryParam("filter") String filter) { + return serviceVnfsImpl(version, !IS_ARRAY, vnfUuid, null, null, null, null, filter); } @GET @@ -155,12 +157,12 @@ public class CatalogDbAdapterRest { public Response serviceVnfs(@PathParam("version") String version, @QueryParam("vnfModelCustomizationUuid") String vnfUuid, @QueryParam("serviceModelUuid") String smUuid, @QueryParam("serviceModelInvariantUuid") String smiUuid, @QueryParam("serviceModelVersion") String smVer, - @QueryParam("serviceModelName") String smName) { - return serviceVnfsImpl(version, IS_ARRAY, vnfUuid, smUuid, smiUuid, smVer, smName); + @QueryParam("serviceModelName") String smName, @QueryParam("filter") String filter) { + return serviceVnfsImpl(version, IS_ARRAY, vnfUuid, smUuid, smiUuid, smVer, smName, filter); } public Response serviceVnfsImpl(String version, boolean isArray, String vnfUuid, String serviceModelUUID, - String smiUuid, String smVer, String smName) { + String smiUuid, String smVer, String smName, String filter) { QueryServiceVnfs qryResp = null; int respStatus = HttpStatus.SC_OK; List<VnfResourceCustomization> ret = new ArrayList<>(); @@ -188,9 +190,16 @@ public class CatalogDbAdapterRest { respStatus = HttpStatus.SC_NOT_FOUND; qryResp = new QueryServiceVnfs(); } else if (service == null && !ret.isEmpty()) { + if (StringUtils.isNotEmpty(filter) && RESOURCE_INPUT_FILTER.equalsIgnoreCase(filter)) { + ret.forEach(vnfCustomization -> vnfCustomization.setResourceInput(null)); + } qryResp = new QueryServiceVnfs(ret); } else if (service != null) { - qryResp = new QueryServiceVnfs(service.getVnfCustomizations()); + ret = service.getVnfCustomizations(); + if (StringUtils.isNotEmpty(filter) && RESOURCE_INPUT_FILTER.equalsIgnoreCase(filter)) { + ret.forEach(vnfCustomization -> vnfCustomization.setResourceInput(null)); + } + qryResp = new QueryServiceVnfs(ret); } logger.debug("serviceVnfs qryResp= {}", qryResp); return respond(version, respStatus, isArray, qryResp); @@ -290,7 +299,7 @@ public class CatalogDbAdapterRest { public Response serviceResources(@PathParam("version") String version, @QueryParam("serviceModelUuid") String modelUUID, @QueryParam("serviceModelInvariantUuid") String modelInvariantUUID, - @QueryParam("serviceModelVersion") String modelVersion) { + @QueryParam("serviceModelVersion") String modelVersion, @QueryParam("filter") String filter) { QueryServiceMacroHolder qryResp; int respStatus = HttpStatus.SC_OK; @@ -305,6 +314,10 @@ public class CatalogDbAdapterRest { if (serv != null) { ret.setNetworkResourceCustomizations(new ArrayList(serv.getNetworkCustomizations())); + if (StringUtils.isNotEmpty(filter) && RESOURCE_INPUT_FILTER.equalsIgnoreCase(filter)) { + serv.getVnfCustomizations() + .forEach(vnfCustomization -> vnfCustomization.setResourceInput(null)); + } ret.setVnfResourceCustomizations(new ArrayList(serv.getVnfCustomizations())); ret.setAllottedResourceCustomizations(new ArrayList(serv.getAllottedCustomizations())); } 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 3906229c2c..48ef1329b0 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 @@ -23,10 +23,13 @@ package org.onap.so.adapters.catalogdb.catalogrest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.List; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.json.JSONException; +import org.json.simple.parser.ParseException; import org.junit.Test; import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest; import org.onap.so.db.catalog.beans.ProcessingFlags; @@ -66,13 +69,9 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { HttpHeaders headers = new HttpHeaders(); - private final String expectedServiceResourceResponse = - "{\r\n\"serviceResources\": {\r\n\"modelInfo\": {\r\n\"modelName\": \"MSOTADevInfra_vSAMP10a_Service\",\r\n\"modelUuid\": \"5df8b6de-2083-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"9647dfc4-2083-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\"\r\n},\r\n\"serviceType\": \"NA\",\r\n\"serviceRole\": \"NA\",\r\n\"environmentContext\": \"Luna\",\r\n\"workloadContext\": \"Oxygen\",\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002671\",\r\n\"modelInstanceName\": \"vSAMP10a 1\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n],\r\n\"serviceNetworks\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"CONTRAIL30_GNDIRECT\",\r\n\"modelUuid\": \"10b36f65-f4e6-4be6-ae49-9596dc1c47fc\",\r\n\"modelInvariantUuid\": \"ce4ff476-9641-4e60-b4d5-b4abbec1271d\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"3bdbb104-476c-483e-9f8b-c095b3d308ac\",\r\n\"modelInstanceName\": \"CONTRAIL30_GNDIRECT 9\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"networkType\": \"\",\r\n\"networkTechnology\": \"\",\r\n\"networkRole\": \"\",\r\n\"networkScope\": \"\"\r\n}\r\n],\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}\r\n}"; - private final String expectedServiceResourceResponsev2 = "{\r\n\"serviceResources\": {\r\n\"modelInfo\": {\r\n\"modelName\": \"MSOTADevInfra_vSAMP10a_Service\",\r\n\"modelUuid\": \"5df8b6de-2083-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"9647dfc4-2083-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2.0\"\r\n},\r\n\"serviceType\": \"NA\",\r\n\"serviceRole\": \"NA\",\r\n\"environmentContext\": \"Luna\",\r\n\"workloadContext\": \"Oxygen\",\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002672\",\r\n\"modelInstanceName\": \"vSAMP10a 2\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n],\r\n\"serviceNetworks\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"CONTRAIL30_GNDIRECT\",\r\n\"modelUuid\": \"10b36f65-f4e6-4be6-ae49-9596dc1c47fc\",\r\n\"modelInvariantUuid\": \"ce4ff476-9641-4e60-b4d5-b4abbec1271d\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"3bdbb104-476c-483e-9f8b-c095b3d308ac\",\r\n\"modelInstanceName\": \"CONTRAIL30_GNDIRECT 9\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"networkType\": \"\",\r\n\"networkTechnology\": \"\",\r\n\"networkRole\": \"\",\r\n\"networkScope\": \"\"\r\n}\r\n],\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}\r\n}"; - private final String expectedServiceVnfResponse = "{\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002671\",\r\n\"modelInstanceName\": \"vSAMP10a 1\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n]\r\n}"; @@ -88,6 +87,9 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { 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 expectedFilteredServiceResourceResponse = + "{\r\n\"serviceResources\": {\r\n\"modelInfo\": {\r\n\"modelName\": \"MSOTADevInfra_vSAMP10a_Service\",\r\n\"modelUuid\": \"5df8b6de-2083-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"9647dfc4-2083-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\"\r\n},\r\n\"serviceType\": \"NA\",\r\n\"serviceRole\": \"NA\",\r\n\"environmentContext\": \"Luna\",\r\n\"workloadContext\": \"Oxygen\",\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002671\",\r\n\"modelInstanceName\": \"vSAMP10a 1\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n],\r\n\"serviceNetworks\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"CONTRAIL30_GNDIRECT\",\r\n\"modelUuid\": \"10b36f65-f4e6-4be6-ae49-9596dc1c47fc\",\r\n\"modelInvariantUuid\": \"ce4ff476-9641-4e60-b4d5-b4abbec1271d\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"3bdbb104-476c-483e-9f8b-c095b3d308ac\",\r\n\"modelInstanceName\": \"CONTRAIL30_GNDIRECT 9\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"networkType\": \"\",\r\n\"networkTechnology\": \"\",\r\n\"networkRole\": \"\",\r\n\"networkScope\": \"\"\r\n}\r\n],\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}\r\n}"; + private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671"; private final String arResourceUUID = "25e2d69b-3b22-47b8-b4c9-7b14fd4a80df"; @@ -110,7 +112,7 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { /* Service Resources Endpoint */ @Test - public void testGetServiceModelUUID() throws JSONException { + public void testGetServiceModelUUID() throws JSONException, IOException, ParseException { HttpEntity<String> entity = new HttpEntity<String>(null, headers); headers.set("Accept", MediaType.APPLICATION_JSON); @@ -122,24 +124,42 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), + JSONAssert.assertEquals(getJson("ExpectedServiceResourceEscaped.json"), response.getBody().toString(), JSONCompareMode.LENIENT); } @Test - public void testGetServiceInvariantUUIDAndVersion() throws JSONException { + public void testGetFilteredVnfResourceInputServiceModelUUID() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = + UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES)) + .queryParam("serviceModelUuid", serviceUUID).queryParam("filter", "resourceInput"); + + ResponseEntity<String> response = + restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + JSONAssert.assertEquals(expectedFilteredServiceResourceResponse, response.getBody().toString(), + JSONCompareMode.LENIENT); + } + + @Test + public void testGetServiceInvariantUUIDAndVersion() throws JSONException, IOException { HttpEntity<String> entity = new HttpEntity<String>(null, headers); headers.set("Accept", MediaType.APPLICATION_JSON); UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES)) .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671") - .queryParam("serviceModelVersion", "1.0"); + .queryParam("serviceModelVersion", "1.0").queryParam("filter", "resourceInput"); ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), false); + JSONAssert.assertEquals(expectedFilteredServiceResourceResponse, response.getBody().toString(), + JSONCompareMode.LENIENT); } @Test @@ -212,8 +232,10 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { headers.set("Accept", MediaType.APPLICATION_JSON); String expectedResponse = "{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002671\",\r\n\"modelInstanceName\": \"vSAMP10a 1\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}"; - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl( - createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc9a92-214c-11e7-93ae-92361f002671")); + UriComponentsBuilder builder = UriComponentsBuilder + .fromHttpUrl( + createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc9a92-214c-11e7-93ae-92361f002671")) + .queryParam("filter", "resourceInput"); ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); @@ -246,7 +268,8 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS)) - .queryParam("vnfModelCustomizationUuid", "68dc9a92-214c-11e7-93ae-92361f002671"); + .queryParam("vnfModelCustomizationUuid", "68dc9a92-214c-11e7-93ae-92361f002671") + .queryParam("filter", "resourceInput"); ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); @@ -262,7 +285,7 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS)) - .queryParam("serviceModelUuid", serviceUUID); + .queryParam("serviceModelUuid", serviceUUID).queryParam("filter", "resourceInput"); ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); @@ -279,7 +302,7 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS)) .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671") - .queryParam("serviceModelVersion", "1.0"); + .queryParam("serviceModelVersion", "1.0").queryParam("filter", "resourceInput"); ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); @@ -362,7 +385,7 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS)) .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service") - .queryParam("serviceModelVersion", "1.0"); + .queryParam("serviceModelVersion", "1.0").queryParam("filter", "resourceInput"); ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); @@ -881,4 +904,8 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { private String createURLWithPort(String uri) { return "http://localhost:" + port + uri; } + + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get("src/test/resources/" + filename))); + } } diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedServiceResourceEscaped.json b/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedServiceResourceEscaped.json new file mode 100644 index 0000000000..20f4adb972 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedServiceResourceEscaped.json @@ -0,0 +1,103 @@ +{ "serviceResources" : { + "modelInfo" : { + "modelName" : "MSOTADevInfra_vSAMP10a_Service", + "modelUuid" : "5df8b6de-2083-11e7-93ae-92361f002671", + "modelInvariantUuid" : "9647dfc4-2083-11e7-93ae-92361f002671", + "modelVersion" : "1.0" + }, + "serviceType" : "NA", + "serviceRole" : "NA", + "environmentContext" : "Luna", + "resourceOrder" : null, + "workloadContext" : "Oxygen", + "serviceVnfs": [ + + { "modelInfo" : { + "modelName" : "vSAMP10a", + "modelUuid" : "ff2ae348-214a-11e7-93ae-92361f002671", + "modelInvariantUuid" : "2fff5b20-214b-11e7-93ae-92361f002671", + "modelVersion" : "1.0", + "modelCustomizationUuid" : "68dc9a92-214c-11e7-93ae-92361f002671", + "modelInstanceName" : "vSAMP10a 1" + }, + "toscaNodeType" : "VF", + "nfFunction" : "vSAMP", + "nfType" : "vSAMP", + "nfRole" : "vSAMP", + "nfNamingCode" : "vSAMP", + "multiStageDesign" : null, + "vnfcInstGroupOrder" : null, + "resourceInput" : "{\"resource_input\":\"test\"}", + "vfModules": [ + { + "modelInfo" : { + "modelName" : "vSAMP10aDEV::base::module-0", + "modelUuid" : "20c4431c-246d-11e7-93ae-92361f002671", + "modelInvariantUuid" : "78ca26d0-246d-11e7-93ae-92361f002671", + "modelVersion" : "2", + "modelCustomizationUuid" : "cb82ffd8-252a-11e7-93ae-92361f002671" + }, "isBase" : true, + "vfModuleLabel" : "base", + "initialCount" : 1, + "hasVolumeGroup" : false + }, + { + "modelInfo" : { + "modelName" : "vSAMP10aDEV::PCM::module-1", + "modelUuid" : "066de97e-253e-11e7-93ae-92361f002671", + "modelInvariantUuid" : "64efd51a-2544-11e7-93ae-92361f002671", + "modelVersion" : "2", + "modelCustomizationUuid" : "b4ea86b4-253f-11e7-93ae-92361f002671" + }, "isBase" : false, + "vfModuleLabel" : "PCM", + "initialCount" : 0, + "hasVolumeGroup" : false + } + ], + "groups": [] + } + ], + "serviceNetworks": [ + { + "modelInfo" : { + "modelName" : "CONTRAIL30_GNDIRECT", + "modelUuid" : "10b36f65-f4e6-4be6-ae49-9596dc1c47fc", + "modelInvariantUuid" : "ce4ff476-9641-4e60-b4d5-b4abbec1271d", + "modelVersion" : "1.0", + "modelCustomizationUuid" : "3bdbb104-476c-483e-9f8b-c095b3d308ac", + "modelInstanceName" : "CONTRAIL30_GNDIRECT 9" + }, + "toscaNodeType" : "", + "networkType" : "", + "networkTechnology" : "", + "resourceInput" : "TBD", + "networkRole" : "", + "networkScope" : "" + } + ], + "serviceInfo": null, + "serviceProxy": [], + "serviceAllottedResources": [ + { + "modelInfo" : { + "modelName" : "Tunnel_Xconn", + "modelUuid" : "f6b7d4c6-e8a4-46e2-81bc-31cad5072842", + "modelInvariantUuid" : "b7a1b78e-6b6b-4b36-9698-8c9530da14af", + "modelVersion" : "1.0", + "modelCustomizationUuid" : "367a8ba9-057a-4506-b106-fbae818597c6", + "modelInstanceName" : "Sec_Tunnel_Xconn 11" + }, + "toscaNodeType" : "", + "allottedResourceType" : "", + "allottedResourceRole" : null, + "providingServiceModelName" : null, + "providingServiceModelInvariantUuid" : null, + "providingServiceModelUuid" : null, + "nfFunction" : null, + "nfType" : null, + "nfRole" : null, + "nfNamingCode" : null, + "resourceInput" : "TBD" + } + ] + }}
\ No newline at end of file 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 31a4f126e8..53a457dadf 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 @@ -64,9 +64,9 @@ insert into vnf_resource(orchestration_mode, description, creation_timestamp, mo ('HEAT', '1607 vSAMP10a - inherent network', '2017-04-14 21:46:28', 'ff2ae348-214a-11e7-93ae-92361f002672', '', '', '2fff5b20-214b-11e7-93ae-92361f002671', '2.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,service_model_uuid) 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,'5df8b6de-2083-11e7-93ae-92361f002671'), -('68dc9a92-214c-11e7-93ae-92361f002672', 'vSAMP10a 2', '0', '0', '0', 'vSAMP', 'vSAMP', 'vSAMP', 'vSAMP', '2017-05-26 15:08:24', 'ff2ae348-214a-11e7-93ae-92361f002672', null,'5df8b6de-2083-11e7-93ae-92361f002672'); +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,service_model_uuid,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,'5df8b6de-2083-11e7-93ae-92361f002671', '{\\\"resource_input\\\":\\\"test\\\"}'), +('68dc9a92-214c-11e7-93ae-92361f002672', 'vSAMP10a 2', '0', '0', '0', 'vSAMP', 'vSAMP', 'vSAMP', 'vSAMP', '2017-05-26 15:08:24', 'ff2ae348-214a-11e7-93ae-92361f002672', null,'5df8b6de-2083-11e7-93ae-92361f002672', null); diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java index fb880a91e3..0456c90fae 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java @@ -173,8 +173,6 @@ public abstract class BaseNssmfManager implements NssmfManager { logger.info("Query operations: nsiId = [{}], jobId = [{}], serviceUuid = [{}]", nsiId, jobId, serviceUuid); - ResourceOperationStatus status = new ResourceOperationStatus(nsiId, jobId, serviceUuid); - List<ResourceOperationStatus> resourceOperationStatuses = repository.findByServiceIdAndOperationId(nsiId, jobId); diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java index 4b0e98e8ec..7ec6c0f9e1 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java @@ -235,6 +235,8 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { status.setOperType(actionType.toString()); status.setProgress("0"); + response.setStatus(STARTED.toString()); + restResponse.setResponseContent(marshal(response)); updateDbStatus(status, restResponse.getStatus(), STARTED, NssmfAdapterUtil.getStatusDesc(actionType)); } } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java index e89160c4ae..64ab199bc1 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java @@ -66,19 +66,20 @@ public abstract class InternalNssmfManager extends BaseNssmfManager { } private RestResponse responseDBStatus(ResourceOperationStatus status) throws ApplicationException { + JobStatusResponse statusResponse = new JobStatusResponse(); ResponseDescriptor descriptor = new ResponseDescriptor(); if (status == null) { descriptor.setProgress(0); descriptor.setStatus(PROCESSING.name()); descriptor.setStatusDescription("Initiating Nssi Instance"); - return restUtil.createResponse(200, marshal(descriptor)); + } else { + descriptor.setStatus(status.getStatus()); + descriptor.setStatusDescription(status.getStatusDescription()); + descriptor.setProgress(Integer.parseInt(status.getProgress())); + descriptor.setNssiId(status.getResourceInstanceID()); } - descriptor.setStatus(status.getStatus()); - descriptor.setStatusDescription(status.getStatusDescription()); - descriptor.setProgress(Integer.parseInt(status.getProgress())); - descriptor.setNssiId(status.getResourceInstanceID()); - // descriptor.setResponseId(status.getOperationId()); - return restUtil.createResponse(200, marshal(descriptor)); + statusResponse.setResponseDescriptor(descriptor); + return restUtil.createResponse(200, marshal(statusResponse)); } @Override diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java index c51b72d61e..3d0d0926fd 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java @@ -27,6 +27,7 @@ import org.onap.so.adapters.nssmf.enums.SelectionType; import org.onap.so.adapters.nssmf.exceptions.ApplicationException; import org.onap.so.adapters.nssmf.manager.impl.ExternalNssmfManager; import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil; +import org.onap.so.beans.nsmf.AnSliceProfile; import org.onap.so.beans.nsmf.DeAllocateNssi; import org.onap.so.beans.nsmf.NssiResponse; import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest; @@ -47,7 +48,21 @@ public class ExternalAnNssmfManager extends ExternalNssmfManager { @Override protected String doWrapExtAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException { Map<String, Object> request = new HashMap<>(); - request.put("attributeListIn", nbiRequest.getAllocateAnNssi().getSliceProfile()); + + AnSliceProfile anSliceProfile = nbiRequest.getAllocateAnNssi().getSliceProfile(); + + RanSliceProfile ranSliceProfile = new RanSliceProfile(); + ranSliceProfile.setSliceProfileId(anSliceProfile.getSliceProfileId()); + ranSliceProfile.setSNSSAIList(anSliceProfile.getSNSSAIList()); + ranSliceProfile.setPLMNIdList(anSliceProfile.getPLMNIdList()); + ranSliceProfile.setPerfReq(anSliceProfile.getPerfReq()); + ranSliceProfile.setMaxNumberofUEs(anSliceProfile.getMaxNumberOfUEs()); + ranSliceProfile.setCoverageAreaTAList(anSliceProfile.getCoverageAreaTAList()); + ranSliceProfile.setLatency(anSliceProfile.getLatency()); + ranSliceProfile.setUEMobilityLevel(anSliceProfile.getUeMobilityLevel()); + ranSliceProfile.setResourceSharingLevel(anSliceProfile.getResourceSharingLevel()); + + request.put("attributeListIn", ranSliceProfile); return marshal(request); } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/RanSliceProfile.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/RanSliceProfile.java new file mode 100644 index 0000000000..7035456d75 --- /dev/null +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/RanSliceProfile.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.nssmf.manager.impl.external; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import java.io.Serializable; +import java.util.List; +import org.onap.so.beans.nsmf.PerfReq; +import org.onap.so.beans.nsmf.UeMobilityLevel; +import org.onap.so.beans.nsmf.ResourceSharingLevel; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@Data +public class RanSliceProfile implements Serializable { + /* + * Reference 3GPP TS 28.541 V16.5.0, Section 6.3.4. + */ + + private static final long serialVersionUID = 172447042469370448L; + + @JsonProperty(value = "sliceProfileId", required = true) + private String sliceProfileId; + + @JsonProperty(value = "sNSSAIList", required = true) + private List<String> sNSSAIList; + + @JsonProperty(value = "pLMNIdList", required = true) + private List<String> pLMNIdList; + + @JsonProperty(value = "perfReq", required = true) + private PerfReq perfReq; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + @JsonProperty(value = "maxNumberofUEs") + private long maxNumberofUEs; + + @JsonProperty(value = "coverageAreaTAList") + private List<Integer> coverageAreaTAList; + + @JsonInclude(JsonInclude.Include.NON_DEFAULT) + @JsonProperty(value = "latency") + private int latency; + + @JsonProperty(value = "uEMobilityLevel") + private UeMobilityLevel uEMobilityLevel; + + @JsonProperty(value = "resourceSharingLevel") + private ResourceSharingLevel resourceSharingLevel; + +} diff --git a/adapters/mso-nssmf-adapter/src/main/resources/subnetCapability.json b/adapters/mso-nssmf-adapter/src/main/resources/subnetCapability.json index 8db52168ae..8753e85ea2 100644 --- a/adapters/mso-nssmf-adapter/src/main/resources/subnetCapability.json +++ b/adapters/mso-nssmf-adapter/src/main/resources/subnetCapability.json @@ -1,19 +1,10 @@ { "AN": { - "latency": "5", + "latency": 5, "maxNumberofUEs": "100" }, "CN": { - "latency": "10", + "latency": 5, "maxNumberofConns": "100" - }, - "TN_FH": { - "latency": "10" - }, - "TN_MH": { - "latency": "5" - }, - "TN_BH": { - "latency": "10" } } diff --git a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java index f150f47f4f..f78bfd297a 100644 --- a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java +++ b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/NssmfAdapterRestTest.java @@ -78,6 +78,7 @@ public class NssmfAdapterRestTest { + " \"networkType\" : \"cn\"\n" + " },\n" + " \"allocateCnNssi\" : {\n" + " \"nssiId\" : \"NSST-C-001-HDBNJ-NSSMF-01-A-ZX\",\n" + " \"nssiName\" : \"eMBB-001\",\n" + " \"sliceProfile\" : {\n" + " \"snssaiList\" : [ \"001-100001\" ],\n" + + " \"maxNumberofPDUSession\" : 10,\n" + " \"sliceProfileId\" : \"ab9af40f13f721b5f13539d87484098\",\n" + " \"plmnIdList\" : [ \"460-00\", \"460-01\" ],\n" + " \"perfReq\" : {\n" + " \"perfReqEmbbList\" : [ {\n" + " \"activityFactor\" : 50\n" + " } ]\n" @@ -315,12 +316,13 @@ public class NssmfAdapterRestTest { taList.add("3"); sP.setSnssaiList(sns); sP.setSliceProfileId("ab9af40f13f721b5f13539d87484098"); - sP.setPlmnIdList(plmn); + sP.setPLMNIdList(plmn); sP.setPerfReq(perfReq); - sP.setMaxNumberofUEs(200); + sP.setMaxNumberOfUEs(200); sP.setCoverageAreaTAList(taList); sP.setLatency(6); sP.setResourceSharingLevel(NON_SHARED); + sP.setMaxNumberOfPDUSession(10); NsiInfo nsiInfo = new NsiInfo(); nsiInfo.setNsiId("NSI-M-001-HDBNJ-NSMF-01-A-ZX"); nsiInfo.setNsiName("eMBB-001"); diff --git a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java index 68adf8073b..d7b3b03333 100644 --- a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java +++ b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java @@ -204,9 +204,9 @@ public class NssmfManagerServiceImplTest { taList.add("3"); sP.setSnssaiList(sns); sP.setSliceProfileId("ab9af40f13f721b5f13539d87484098"); - sP.setPlmnIdList(plmn); + sP.setPLMNIdList(plmn); sP.setPerfReq(perfReq); - sP.setMaxNumberofUEs(200); + sP.setMaxNumberOfUEs(200); sP.setCoverageAreaTAList(taList); sP.setLatency(6); sP.setResourceSharingLevel(NON_SHARED); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/AaiClientPropertiesImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/AaiClientPropertiesImpl.java index b7e214f9fc..cd32cc208a 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/AaiClientPropertiesImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/AaiClientPropertiesImpl.java @@ -24,6 +24,7 @@ import java.net.MalformedURLException; import java.net.URL; import org.onap.aaiclient.client.aai.AAIProperties; import org.onap.aaiclient.client.aai.AAIVersion; +import org.onap.so.client.CacheProperties; import org.onap.so.spring.SpringContextHelper; import org.springframework.context.ApplicationContext; @@ -33,6 +34,8 @@ public class AaiClientPropertiesImpl implements AAIProperties { private String auth; private String key; private Long readTimeout; + private boolean enableCaching; + private Long cacheMaxAge; private static final String SYSTEM_NAME = "MSO"; public AaiClientPropertiesImpl() { @@ -41,6 +44,8 @@ public class AaiClientPropertiesImpl implements AAIProperties { this.auth = context.getEnvironment().getProperty("aai.auth"); this.key = context.getEnvironment().getProperty("mso.msoKey"); this.readTimeout = context.getEnvironment().getProperty("aai.readTimeout", Long.class, new Long(60000)); + this.enableCaching = context.getEnvironment().getProperty("aai.caching.enabled", Boolean.class, false); + this.cacheMaxAge = context.getEnvironment().getProperty("aai.caching.maxAge", Long.class, 60000L); } @Override @@ -72,4 +77,19 @@ public class AaiClientPropertiesImpl implements AAIProperties { public Long getReadTimeout() { return this.readTimeout; } + + @Override + public boolean isCachingEnabled() { + return this.enableCaching; + } + + @Override + public CacheProperties getCacheProperties() { + return new AAICacheProperties() { + @Override + public Long getMaxAge() { + return cacheMaxAge; + } + }; + } } 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 d57b305902..7efc397e30 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 @@ -2227,28 +2227,6 @@ public class ToscaResourceInstaller { .setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)); cvnfcConfigurationCustomization.setModelInstanceName(fabricEntity.getName()); - List<IEntityDetails> policyList = - getEntityDetails(toscaResourceStruct, EntityQuery.newBuilder("org.openecomp.policies.External"), - TopologyTemplateQuery.newBuilder(SdcTypes.VF), true); - - - if (policyList != null) { - for (IEntityDetails policyEntity : policyList) { - - for (String policyCvfcTarget : policyEntity.getTargets()) { - - if (policyCvfcTarget.equalsIgnoreCase(vfModuleMemberName)) { - - String policyType = getLeafPropertyValue(policyEntity, "type"); - - if (policyType != null && policyType.equalsIgnoreCase("Fabric Policy")) { - cvnfcConfigurationCustomization.setPolicyName(getLeafPropertyValue(policyEntity, "name")); - } - } - } - } - } - cvnfcConfigurationCustomization.setConfigurationFunction(getLeafPropertyValue(fabricEntity, "function")); cvnfcConfigurationCustomization.setConfigurationRole(getLeafPropertyValue(fabricEntity, "role")); cvnfcConfigurationCustomization.setConfigurationType(getLeafPropertyValue(fabricEntity, "type")); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImpl.java index 7b89af0910..ace0ff1f57 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImpl.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImpl.java @@ -24,6 +24,7 @@ import java.net.MalformedURLException; import java.net.URL; import org.onap.aaiclient.client.aai.AAIProperties; import org.onap.aaiclient.client.aai.AAIVersion; +import org.onap.so.client.CacheProperties; import org.onap.so.spring.SpringContextHelper; import org.springframework.context.ApplicationContext; @@ -33,6 +34,8 @@ public class AaiClientPropertiesImpl implements AAIProperties { private String auth; private String key; private Long readTimeout; + private boolean enableCaching; + private Long cacheMaxAge; private static final String SYSTEM_NAME = "MSO"; public AaiClientPropertiesImpl() { @@ -41,6 +44,8 @@ public class AaiClientPropertiesImpl implements AAIProperties { this.auth = context.getEnvironment().getProperty("aai.auth"); this.key = context.getEnvironment().getProperty("mso.msoKey"); this.readTimeout = context.getEnvironment().getProperty("aai.readTimeout", Long.class, new Long(60000)); + this.enableCaching = context.getEnvironment().getProperty("aai.caching.enabled", Boolean.class, false); + this.cacheMaxAge = context.getEnvironment().getProperty("aai.caching.maxAge", Long.class, 60000L); } @Override @@ -74,4 +79,19 @@ public class AaiClientPropertiesImpl implements AAIProperties { public Long getReadTimeout() { return this.readTimeout; } + + @Override + public boolean isCachingEnabled() { + return this.enableCaching; + } + + @Override + public CacheProperties getCacheProperties() { + return new AAICacheProperties() { + @Override + public Long getMaxAge() { + return cacheMaxAge; + } + }; + } } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy index 23dfdce753..4e8be5d6e5 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy @@ -144,7 +144,7 @@ class RequestDBUtil { <ns:initResourceOperationStatus xmlns:ns="http://org.onap.so/requestsdb"> <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId> <operationId>${MsoUtils.xmlEscape(operationId)}</operationId> - <operationType>${MsoUtils.xmlEscape(operType)}</operationType> + <operType>${MsoUtils.xmlEscape(operType)}</operType> <resourceTemplateUUIDs>${MsoUtils.xmlEscape(resourceTemplateUUID)}</resourceTemplateUUIDs> </ns:initResourceOperationStatus> </soapenv:Body> @@ -192,8 +192,9 @@ class RequestDBUtil { <ns:updateResourceOperationStatus xmlns:ns="http://org.onap.so/requestsdb"> <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId> <operationId>${MsoUtils.xmlEscape(operationId)}</operationId> - <resourceTemplateUUIDs>${MsoUtils.xmlEscape(resourceTemplateUUID)}</resourceTemplateUUIDs> - <operationType>${MsoUtils.xmlEscape(operType)}</operationType> + <resourceTemplateUUID>${MsoUtils.xmlEscape(resourceTemplateUUID)}</resourceTemplateUUID> + <operType>${MsoUtils.xmlEscape(operType)}</operType> + <resourceInstanceID>${MsoUtils.xmlEscape(resourceInstanceID)}</resourceInstanceID> <jobId>${MsoUtils.xmlEscape(jobId)}</jobId> <status>${MsoUtils.xmlEscape(status)}</status> <progress>${MsoUtils.xmlEscape(progress)}</progress> diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java index afd7f6433c..24f1e055e2 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java @@ -269,10 +269,10 @@ public class BBInputSetupUtils { String cloudRegionId = cloudConfiguration.getLcpCloudRegionId(); String cloudOwner = cloudConfiguration.getCloudOwner(); if (cloudRegionId != null && cloudOwner != null && !cloudRegionId.isEmpty() && !cloudOwner.isEmpty()) { - return injectionHelper.getAaiClient() - .get(CloudRegion.class, AAIUriFactory.createResourceUri( + return injectionHelper.getAaiClient().get(CloudRegion.class, + AAIUriFactory.createResourceUri( AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId)) - .depth(Depth.TWO)) + .depth(Depth.ONE).nodesOnly(true)) .orElse(null); } else { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java index f67af20ef1..98a14fc0e5 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java @@ -25,6 +25,7 @@ import java.net.URL; import org.onap.aaiclient.client.aai.AAIProperties; import org.onap.aaiclient.client.aai.AAIVersion; import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.client.CacheProperties; import org.springframework.stereotype.Component; @Component @@ -34,6 +35,9 @@ public class AAIPropertiesImpl implements AAIProperties { public static final String AAI_AUTH = "aai.auth"; public static final String AAI_ENDPOINT = "aai.endpoint"; public static final String AAI_READ_TIMEOUT = "aai.readTimeout"; + public static final String AAI_ENABLE_CACHING = "aai.caching.enable"; + public static final String AAI_CACHE_MAX_AGE = "aai.caching.maxAge"; + private UrnPropertiesReader reader; @Override @@ -66,4 +70,19 @@ public class AAIPropertiesImpl implements AAIProperties { return Long.valueOf(reader.getVariable(AAI_READ_TIMEOUT, "60000")); } + @Override + public boolean isCachingEnabled() { + return Boolean.parseBoolean(reader.getVariable(AAI_ENABLE_CACHING, "false")); + } + + @Override + public CacheProperties getCacheProperties() { + return new AAICacheProperties() { + @Override + public Long getMaxAge() { + return Long.valueOf(reader.getVariable(AAI_CACHE_MAX_AGE, "60000")); + } + }; + } + } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java index 85774ec23c..188f853a14 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java @@ -184,7 +184,7 @@ public class BBInputSetupUtilsTest { AAIUriFactory .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() .cloudRegion(cloudConfig.getCloudOwner(), cloudConfig.getLcpCloudRegionId())) - .depth(Depth.TWO)); + .depth(Depth.ONE).nodesOnly(true)); assertThat(bbInputSetupUtils.getCloudRegion(cloudConfig), sameBeanAs(expected.get())); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy index 9100f2773b..e2d9c16328 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy @@ -149,16 +149,17 @@ class AllocateSliceSubnet extends AbstractServiceTaskProcessor { def prepareInitOperationStatus = { DelegateExecution execution -> logger.debug(Prefix + "prepareInitOperationStatus Start") - String serviceId = execution.getVariable("dummyServiceId") + String modelUuid = execution.getVariable("modelUuid") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") - logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) + logger.debug("Generated new job for Service Instance serviceId:" + modelUuid + " jobId:" + jobId) ResourceOperationStatus initStatus = new ResourceOperationStatus() - initStatus.setServiceId(serviceId) - initStatus.setOperationId(jobId) - initStatus.setResourceTemplateUUID(nsiId) - initStatus.setOperType("Allocate") + initStatus.setServiceId(nsiId) // set nsiId to this field + initStatus.setOperationId(jobId) // set jobId to this field + initStatus.setResourceTemplateUUID(modelUuid) // set modelUuid to this field + initStatus.setOperType("ALLOCATE") + //initStatus.setResourceInstanceID() // set nssiId to this field requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) logger.debug(Prefix + "prepareInitOperationStatus Exit") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy index fac8871b52..1f3cf6ed52 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy @@ -20,8 +20,11 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.beans.nsmf.ConnectionLink +import org.onap.so.beans.nsmf.EndPoint import org.onap.so.beans.nsmf.NsiInfo import org.onap.so.beans.nsmf.SliceProfileAdapter +import org.onap.so.beans.nsmf.TransportSliceNetwork import org.onap.so.beans.nsmf.oof.SubnetType import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import javax.ws.rs.NotFoundException @@ -328,6 +331,12 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ NsiInfo nsiInfo = new NsiInfo() nsiInfo.nsiId = sliceParams.suggestNsiId allocateAnNssi.nsiInfo = nsiInfo + //endPoint + EndPoint endPoint = new EndPoint() + endPoint.setIpAddress(sliceTaskInfo.sliceProfile.ipAddress) + endPoint.setLogicInterfaceId(sliceTaskInfo.sliceProfile.logicInterfaceId) + endPoint.setNextHopInfo(sliceTaskInfo.sliceProfile.nextHopInfo) + allocateAnNssi.setEndPoint(endPoint) EsrInfo esrInfo = new EsrInfo() //todo: vendor and network @@ -442,6 +451,12 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ NsiInfo nsiInfo = new NsiInfo() nsiInfo.nsiId = sliceParams.suggestNsiId allocateCnNssi.nsiInfo = nsiInfo + // endPoint + EndPoint endPoint = new EndPoint() + endPoint.setIpAddress(sliceTaskInfo.sliceProfile.ipAddress) + endPoint.setLogicInterfaceId(sliceTaskInfo.sliceProfile.logicInterfaceId) + endPoint.setNextHopInfo(sliceTaskInfo.sliceProfile.nextHopInfo) + allocateCnNssi.setEndPoint(endPoint) EsrInfo esrInfo = new EsrInfo() //todo: vendor and network @@ -552,8 +567,18 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ AllocateTnNssi allocateTnNssi = new AllocateTnNssi() //todo: AllocateTnNssi - //todo: endpointId -> set into tn - allocateTnNssi.setTransportSliceNetworks() + //todo: endPointId -> set into tn + List<TransportSliceNetwork> transportSliceNetworks = new ArrayList<>() + TransportSliceNetwork transportSliceNetwork = new TransportSliceNetwork() + List<ConnectionLink> connectionLinks = new ArrayList<>() + ConnectionLink connectionLink = new ConnectionLink() + connectionLink.setTransportEndpointA(sliceParams.anSliceTaskInfo.endPointId) + connectionLink.setTransportEndpointB(sliceParams.cnSliceTaskInfo.endPointId) + connectionLinks.add(connectionLink) + transportSliceNetwork.setConnectionLinks(connectionLinks) + transportSliceNetworks.add(transportSliceNetwork) + allocateTnNssi.setTransportSliceNetworks(transportSliceNetworks) + allocateTnNssi.setNetworkSliceInfos() allocateTnNssi.setSliceProfile(sliceTaskInfo.sliceProfile.trans2TnProfile()) NsiInfo nsiInfo = new NsiInfo() @@ -607,7 +632,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ String sliceProfileInstanceId = sliceParams.anSliceTaskInfo.sliceInstanceId String serviceProfileInstanceId = sliceParams.serviceId //nsi id - //todo: aai -> nssi -> relationship -> endpointId -> set into tn + //todo: aai -> nssi -> relationship -> endPointId -> set into tn String endPointId = getEndpointIdFromAAI(execution, nssiId) execution.setVariable("endPointIdAn", endPointId) @@ -641,7 +666,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ String sliceProfileInstanceId = sliceParams.cnSliceTaskInfo.sliceInstanceId String serviceProfileInstanceId = sliceParams.serviceId //nsi id - //todo: aai -> nssi -> relationship -> endpointId -> set into tn + //todo: aai -> nssi -> relationship -> endPointId -> set into tn String endPointId = getEndpointIdFromAAI(execution, nssiId) execution.setVariable("endPointIdCn", endPointId) @@ -685,7 +710,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } else { ServiceInstance nssiInstance = si.get() - //todo: handle relationship and return endpointId + //todo: handle relationship and return endPointId if (nssiInstance.relationshipList == null) { String msg = "relationshipList of " + nssiId + " is null" logger.debug(msg) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy index 896d7ff4b1..e5c1b56d55 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy @@ -99,8 +99,12 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { if (response != null) { JobStatusResponse jobStatusResponse = objectMapper.readValue(response, JobStatusResponse.class) - execution.setVariable("nssiAllocateStatus", jobStatusResponse) + if (StringUtils.isBlank(nssiId)) { + nssiAllocateResult.setNssiId(jobStatusResponse.getResponseDescriptor().getNssiId()) + execution.setVariable("nssiAllocateResult", nssiAllocateResult) + } + execution.setVariable("nssiAllocateStatus", jobStatusResponse) if (jobStatusResponse.getResponseDescriptor().getProgress() == 100) { execution.setVariable("jobFinished", true) } @@ -119,8 +123,9 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { SliceTaskInfo sliceTaskInfo = execution.getVariable("sliceTaskInfo") as SliceTaskInfo sliceTaskInfo.progress = response.getProgress() - sliceTaskInfo.status = response.getStatus() + sliceTaskInfo.status = response.getStatus().toLowerCase() sliceTaskInfo.statusDescription = response.getStatusDescription() + sliceTaskInfo.endPointId = response.getEndPointId() updateNssiResult(sliceParams, subnetType, sliceTaskInfo) String paramJson = sliceParams.convertToJson() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy index 8a276ed330..88db2161f7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/TnAllocateNssi.groovy @@ -321,17 +321,17 @@ class TnAllocateNssi extends AbstractServiceTaskProcessor { String status, String progress, String statusDescription) { - String serviceId = execution.getVariable("dummyServiceId") + String modelUuid = execution.getVariable("modelUuid") String ssInstanceId = execution.getVariable("sliceServiceInstanceId") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") ResourceOperationStatus roStatus = new ResourceOperationStatus() - roStatus.setServiceId(serviceId) + roStatus.setServiceId(nsiId) roStatus.setOperationId(jobId) - roStatus.setResourceTemplateUUID(nsiId) + roStatus.setResourceTemplateUUID(modelUuid) roStatus.setResourceInstanceID(ssInstanceId) - roStatus.setOperType("Allocate") + roStatus.setOperType("ALLOCATE") roStatus.setProgress(progress) roStatus.setStatus(status) roStatus.setStatusDescription(statusDescription) diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 5e281cff87..554385d043 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -450,14 +450,18 @@ public class WorkflowActionBBTasks { if (requestAction.equalsIgnoreCase("replaceInstance") || requestAction.equalsIgnoreCase("replaceInstanceRetainAssignments")) { List<ExecuteBuildingBlock> configBBs = flowsToExecute.stream() - .filter(item -> !item.getBuildingBlock().getBpmnFlowName().matches(CONFIGURATION_PATTERN)) + .filter(item -> item.getBuildingBlock().getBpmnFlowName().matches(CONFIGURATION_PATTERN)) .collect(Collectors.toList()); - for (ExecuteBuildingBlock bb : configBBs) { - bb.getConfigurationResourceKeys().setCvnfcCustomizationUUID(modelCustomizationId); - bb.getConfigurationResourceKeys().setVnfcName(vnfc.getVnfcName()); + if (configBBs != null && configBBs.size() > 0) { + for (ExecuteBuildingBlock bb : configBBs) { + if (bb.getConfigurationResourceKeys() != null) { + bb.getConfigurationResourceKeys().setCvnfcCustomizationUUID(modelCustomizationId); + bb.getConfigurationResourceKeys().setVnfcName(vnfc.getVnfcName()); + } + } + execution.setVariable("flowsToExecute", flowsToExecute); + execution.setVariable(COMPLETED, false); } - execution.setVariable("flowsToExecute", flowsToExecute); - execution.setVariable(COMPLETED, false); } else { CvnfcConfigurationCustomization fabricConfig = catalogDbClient.getCvnfcCustomization( serviceModelUUID, vnfCustomizationUUID, vfModuleCustomizationUUID, modelCustomizationId); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index 0384a28cdc..b7529bdeb8 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -613,7 +613,73 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test - public void postProcessingExecuteBBActivateVfModuleTest() throws CloneNotSupportedException { + public void postProcessingExecuteBBActivateVfModuleNotReplaceInstanceTest() throws CloneNotSupportedException { + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("1"); + workflowResourceIds.setVnfId("1"); + + BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule); + ebbActivateVfModule.setWorkflowResourceIds(workflowResourceIds); + ebbActivateVfModule.setResourceId("1"); + + ServiceInstance service = new ServiceInstance(); + service.setServiceInstanceName("name"); + service.setModelVersionId("1"); + doReturn(service).when(bbSetupUtils).getAAIServiceInstanceById("1"); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfName("name"); + vnf.setModelCustomizationId("1"); + doReturn(vnf).when(bbSetupUtils).getAAIGenericVnf("1"); + + VfModule vfModule = new VfModule(); + vfModule.setVfModuleName("name"); + vfModule.setModelCustomizationId("1"); + doReturn(vfModule).when(bbSetupUtils).getAAIVfModule("1", "1"); + + List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>(); + org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc(); + vnfc.setModelInvariantId("1"); + vnfc.setVnfcName("name"); + vnfc.setModelCustomizationId("2"); + vnfcs.add(vnfc); + doReturn(vnfcs).when(workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any()); + + CvnfcConfigurationCustomization vfModuleCustomization = new CvnfcConfigurationCustomization(); + ConfigurationResource configuration = new ConfigurationResource(); + configuration.setToscaNodeType("FabricConfiguration"); + configuration.setModelUUID("1"); + vfModuleCustomization.setConfigurationResource(configuration); + + doReturn(vfModuleCustomization).when(catalogDbClient).getCvnfcCustomization("1", "1", "1", "2"); + + prepareDelegateExecution(); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + flowsToExecute.add(ebbActivateVfModule); + + execution.setVariable("requestAction", "createInstance"); + execution.setVariable("completed", true); + + ArgumentCaptor<DelegateExecution> executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class); + ArgumentCaptor<ExecuteBuildingBlock> bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class); + ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class); + workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbActivateVfModule, flowsToExecute); + verify(workflowActionBBTasks, times(1)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(), + bbCaptor.capture(), listCaptor.capture()); + assertEquals(false, executionCaptor.getAllValues().get(0).getVariable("completed")); + assertEquals(2, ((ArrayList) executionCaptor.getAllValues().get(0).getVariable("flowsToExecute")).size()); + assertEquals("2", + ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues().get(0) + .getVariable("flowsToExecute")).get(1)).getConfigurationResourceKeys() + .getCvnfcCustomizationUUID()); + assertEquals("AddFabricConfigurationBB", ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues() + .get(0).getVariable("flowsToExecute")).get(1)).getBuildingBlock().getBpmnFlowName()); + } + + @Test + public void postProcessingExecuteBBActivateVfModuleReplaceInstanceHasConfigurationTest() + throws CloneNotSupportedException { BuildingBlock bbAddFabric = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB"); ExecuteBuildingBlock ebbAddFabric = new ExecuteBuildingBlock().setBuildingBlock(bbAddFabric); @@ -628,7 +694,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { ebbActivateVfModule.setWorkflowResourceIds(workflowResourceIds); ebbActivateVfModule.setResourceId("1"); ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys(); - ebbActivateVfModule.setConfigurationResourceKeys(configurationResourceKeys); + ebbAddFabric.setConfigurationResourceKeys(configurationResourceKeys); ServiceInstance service = new ServiceInstance(); service.setServiceInstanceName("name"); @@ -664,35 +730,88 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { prepareDelegateExecution(); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); flowsToExecute.add(ebbActivateVfModule); + flowsToExecute.add(ebbAddFabric); ArgumentCaptor<DelegateExecution> executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class); ArgumentCaptor<ExecuteBuildingBlock> bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class); ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class); - workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbAddFabric, flowsToExecute); + + execution.setVariable("requestAction", "replaceInstance"); + execution.setVariable("completed", true); + workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbActivateVfModule, flowsToExecute); verify(workflowActionBBTasks, times(1)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(), bbCaptor.capture(), listCaptor.capture()); assertEquals(false, executionCaptor.getAllValues().get(0).getVariable("completed")); assertEquals(2, ((ArrayList) executionCaptor.getAllValues().get(0).getVariable("flowsToExecute")).size()); - assertEquals(null, + assertEquals("2", ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues().get(0) - .getVariable("flowsToExecute")).get(0)).getConfigurationResourceKeys() + .getVariable("flowsToExecute")).get(1)).getConfigurationResourceKeys() .getCvnfcCustomizationUUID()); + } + @Test + public void postProcessingExecuteBBActivateVfModuleReplaceInstanceHasNoConfigurationTest() + throws CloneNotSupportedException { - execution.setVariable("requestAction", "replaceInstance"); - flowsToExecute = new ArrayList<>(); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("1"); + workflowResourceIds.setVnfId("1"); + + BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); + ExecuteBuildingBlock ebbActivateVfModule = new ExecuteBuildingBlock().setBuildingBlock(bbActivateVfModule); + ebbActivateVfModule.setWorkflowResourceIds(workflowResourceIds); + ebbActivateVfModule.setResourceId("1"); + + ServiceInstance service = new ServiceInstance(); + service.setServiceInstanceName("name"); + service.setModelVersionId("1"); + doReturn(service).when(bbSetupUtils).getAAIServiceInstanceById("1"); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfName("name"); + vnf.setModelCustomizationId("1"); + doReturn(vnf).when(bbSetupUtils).getAAIGenericVnf("1"); + + VfModule vfModule = new VfModule(); + vfModule.setVfModuleName("name"); + vfModule.setModelCustomizationId("1"); + doReturn(vfModule).when(bbSetupUtils).getAAIVfModule("1", "1"); + + List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>(); + org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc(); + vnfc.setModelInvariantId("1"); + vnfc.setVnfcName("name"); + vnfc.setModelCustomizationId("2"); + vnfcs.add(vnfc); + doReturn(vnfcs).when(workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any()); + + CvnfcConfigurationCustomization vfModuleCustomization = new CvnfcConfigurationCustomization(); + ConfigurationResource configuration = new ConfigurationResource(); + configuration.setToscaNodeType("FabricConfiguration"); + configuration.setModelUUID("1"); + vfModuleCustomization.setConfigurationResource(configuration); + + doReturn(vfModuleCustomization).when(catalogDbClient).getCvnfcCustomization("1", "1", "1", "2"); + + prepareDelegateExecution(); + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); flowsToExecute.add(ebbActivateVfModule); + + ArgumentCaptor<DelegateExecution> executionCaptor = ArgumentCaptor.forClass(DelegateExecution.class); + ArgumentCaptor<ExecuteBuildingBlock> bbCaptor = ArgumentCaptor.forClass(ExecuteBuildingBlock.class); + ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class); + + execution.setVariable("requestAction", "replaceInstance"); + execution.setVariable("completed", true); + workflowActionBBTasks.postProcessingExecuteBBActivateVfModule(execution, ebbActivateVfModule, flowsToExecute); - verify(workflowActionBBTasks, times(2)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(), + verify(workflowActionBBTasks, times(1)).postProcessingExecuteBBActivateVfModule(executionCaptor.capture(), bbCaptor.capture(), listCaptor.capture()); - assertEquals(false, executionCaptor.getAllValues().get(0).getVariable("completed")); - assertEquals(1, ((ArrayList) executionCaptor.getAllValues().get(0).getVariable("flowsToExecute")).size()); - assertEquals("2", - ((ExecuteBuildingBlock) ((ArrayList) executionCaptor.getAllValues().get(0) - .getVariable("flowsToExecute")).get(0)).getConfigurationResourceKeys() - .getCvnfcCustomizationUUID()); + assertEquals(true, executionCaptor.getAllValues().get(0).getVariable("completed")); } + + @Test public void getExecuteBBForConfigTest() throws CloneNotSupportedException { BuildingBlock bbActivateVfModule = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB"); diff --git a/common/pom.xml b/common/pom.xml index 74e51805ad..6e265925c3 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -293,6 +293,16 @@ <artifactId>jaxb-impl</artifactId> <version>2.3.0</version> </dependency> + <dependency> + <groupId>javax.cache</groupId> + <artifactId>cache-api</artifactId> + <version>1.0.0</version> + </dependency> + <dependency> + <groupId>org.ehcache</groupId> + <artifactId>ehcache</artifactId> + <version>3.8.1</version> + </dependency> </dependencies> <dependencyManagement> <dependencies> @@ -366,4 +376,4 @@ </plugin> </plugins> </build> -</project>
\ No newline at end of file +</project> diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java index dc8e69121e..f966098b18 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateAnNssi.java @@ -47,5 +47,5 @@ public class AllocateAnNssi implements Serializable { private NsiInfo nsiInfo; - private Map<String, Object> endPoint; + private EndPoint endPoint; } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java b/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java index f5b926f627..fdbff2fd42 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AllocateCnNssi.java @@ -49,5 +49,5 @@ public class AllocateCnNssi implements Serializable { private NsiInfo nsiInfo; - private Map<String, Object> endPoint; + private EndPoint endPoint; } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java index 14918c7873..3d0f70805c 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java @@ -32,7 +32,7 @@ import java.util.List; @ToString public class AnSliceProfile implements Serializable { /* - * Reference 3GPP TS 28.541 V16.5.0, Section 6.3.4. + * Reference 3GPP TS 28.541 V16.5.0. */ private static final long serialVersionUID = -3057342171549542794L; @@ -40,10 +40,10 @@ public class AnSliceProfile implements Serializable { @JsonProperty(value = "sliceProfileId", required = true) private String sliceProfileId; - @JsonProperty(value = "sNSSAIList", required = true) + @JsonProperty(value = "snssaiList", required = true) private List<String> sNSSAIList; - @JsonProperty(value = "pLMNIdList", required = true) + @JsonProperty(value = "plmnIdList", required = true) private List<String> pLMNIdList; @JsonProperty(value = "perfReq", required = true) @@ -51,7 +51,7 @@ public class AnSliceProfile implements Serializable { @JsonInclude(JsonInclude.Include.NON_DEFAULT) @JsonProperty(value = "maxNumberofUEs") - private long maxNumberofUEs; + private int maxNumberOfUEs; @JsonProperty(value = "coverageAreaTAList") private List<Integer> coverageAreaTAList; @@ -61,7 +61,7 @@ public class AnSliceProfile implements Serializable { private int latency; @JsonProperty(value = "uEMobilityLevel") - private UeMobilityLevel uEMobilityLevel; + private UeMobilityLevel ueMobilityLevel; @JsonProperty(value = "resourceSharingLevel") private ResourceSharingLevel resourceSharingLevel; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java index 3a45119195..efb447bc00 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/CnSliceProfile.java @@ -38,13 +38,13 @@ public class CnSliceProfile implements Serializable { private String sliceProfileId; @JsonProperty(value = "plmnIdList", required = true) - private List<String> plmnIdList; + private List<String> pLMNIdList; @JsonProperty(value = "perfReq", required = true) private PerfReq perfReq; @JsonProperty(value = "maxNumberofUEs") - private int maxNumberofUEs; + private int maxNumberOfUEs; @JsonProperty(value = "coverageAreaTAList") private List<String> coverageAreaTAList; @@ -57,4 +57,8 @@ public class CnSliceProfile implements Serializable { @JsonProperty(value = "resourceSharingLevel") private ResourceSharingLevel resourceSharingLevel; + + @JsonProperty(value = "maxNumberofPDUSession") + private int maxNumberOfPDUSession; + } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/EndPoint.java b/common/src/main/java/org/onap/so/beans/nsmf/EndPoint.java index dab9b3a990..90bfc0eae0 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/EndPoint.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/EndPoint.java @@ -20,17 +20,28 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; import java.io.Serializable; -import java.util.Map; @JsonInclude(JsonInclude.Include.NON_NULL) @Data +@ToString +@NoArgsConstructor +@AllArgsConstructor public class EndPoint implements Serializable { private static final long serialVersionUID = 2479795890807020491L; - private String nodeId; + @JsonProperty(value = "ipAddress") + private String ipAddress; - private Map<String, Object> additionalInfo; + @JsonProperty(value = "logicInterfaceId") + private String logicInterfaceId; + + @JsonProperty(value = "nextHopInfo") + private String nextHopInfo; } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/NssiResponse.java b/common/src/main/java/org/onap/so/beans/nsmf/NssiResponse.java index 92acdaa90d..270a55e349 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/NssiResponse.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/NssiResponse.java @@ -21,9 +21,11 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) +@Data public class NssiResponse implements Serializable { private static final long serialVersionUID = 2723440188640857903L; @@ -32,19 +34,5 @@ public class NssiResponse implements Serializable { private String jobId; - public String getNssiId() { - return nssiId; - } - - public void setNssiId(String nssiId) { - this.nssiId = nssiId; - } - - public String getJobId() { - return jobId; - } - - public void setJobId(String jobId) { - this.jobId = jobId; - } + private String status; } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java index 9e4b4edce3..06f97a8484 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/PerfReqUrllc.java @@ -21,118 +21,31 @@ package org.onap.so.beans.nsmf; import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; import java.io.Serializable; @JsonInclude(JsonInclude.Include.NON_NULL) +@Data public class PerfReqUrllc implements Serializable { private static final long serialVersionUID = 3133479142915485943L; @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private int e2eLatency; + private String survivalTime; @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private int jitter; - - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private int survivalTime; - - @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private float csAvailability; + private int expDataRate; @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private float reliability; + private String transferIntervalTarget; @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private int expDataRate; - - private String payloadSize; + private String msgSizeByte; @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private int trafficDensity; + private String csReliabilityMeanTime; @JsonInclude(JsonInclude.Include.NON_DEFAULT) - private int connDensity; - - private String serviceAreaDimension; - - public int getE2eLatency() { - return e2eLatency; - } - - public void setE2eLatency(int e2eLatency) { - this.e2eLatency = e2eLatency; - } - - public int getJitter() { - return jitter; - } - - public void setJitter(int jitter) { - this.jitter = jitter; - } - - public int getSurvivalTime() { - return survivalTime; - } - - public void setSurvivalTime(int survivalTime) { - this.survivalTime = survivalTime; - } - - public float getReliability() { - return reliability; - } - - public void setReliability(float reliability) { - this.reliability = reliability; - } - - public int getExpDataRate() { - return expDataRate; - } - - public void setExpDataRate(int expDataRate) { - this.expDataRate = expDataRate; - } - - public String getPayloadSize() { - return payloadSize; - } - - public void setPayloadSize(String payloadSize) { - this.payloadSize = payloadSize; - } - - public int getTrafficDensity() { - return trafficDensity; - } - - public void setTrafficDensity(int trafficDensity) { - this.trafficDensity = trafficDensity; - } - - public int getConnDensity() { - return connDensity; - } - - public void setConnDensity(int connDensity) { - this.connDensity = connDensity; - } - - public String getServiceAreaDimension() { - return serviceAreaDimension; - } - - public void setServiceAreaDimension(String serviceAreaDimension) { - this.serviceAreaDimension = serviceAreaDimension; - } - - public float getCsAvailability() { - return csAvailability; - } + private float csAvailabilityTarget; - public void setCsAvailability(float csAvailability) { - this.csAvailability = csAvailability; - } } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/ResponseDescriptor.java b/common/src/main/java/org/onap/so/beans/nsmf/ResponseDescriptor.java index 2456d540ce..17ef210c4e 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/ResponseDescriptor.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/ResponseDescriptor.java @@ -31,7 +31,6 @@ public class ResponseDescriptor implements Serializable { private static final long serialVersionUID = 6330527958947215910L; - @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int progress; private String status; diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java index ad6eec1c01..90cee2794a 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceProfileAdapter.java @@ -25,7 +25,9 @@ import lombok.Data; import lombok.ToString; import org.springframework.beans.BeanUtils; import java.io.Serializable; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; @Data @ToString @@ -43,7 +45,7 @@ public class SliceProfileAdapter implements Serializable { private String pLMNIdList = ""; @JsonProperty(value = "maxNumberofUEs") - private long maxNumberofUEs; + private int maxNumberOfUEs; @JsonProperty(value = "coverageAreaTAList") private String coverageAreaTAList = ""; @@ -52,23 +54,68 @@ public class SliceProfileAdapter implements Serializable { private int latency; @JsonProperty(value = "uEMobilityLevel") - private String uEMobilityLevel; + private String ueMobilityLevel; @JsonProperty(value = "resourceSharingLevel") private String resourceSharingLevel; @JsonProperty(value = "maxBandwidth") - private String bandwidth; + private int maxBandwidth; @JsonProperty(value = "sST") private String sST; @JsonProperty(value = "activityFactor") - private String activityFactor; + private int activityFactor; @JsonProperty(value = "survivalTime") private String survivalTime; + @JsonProperty(value = "expDataRateUL") + private int expDataRateUL; + + @JsonProperty(value = "expDataRateDL") + private int expDataRateDL; + + @JsonProperty(value = "areaTrafficCapUL") + private int areaTrafficCapUL; + + @JsonProperty(value = "areaTrafficCapDL") + private int areaTrafficCapDL; + + @JsonProperty(value = "jitter") + private int jitter; + + @JsonProperty(value = "csAvailabilityTarget") + private float csAvailabilityTarget; + + @JsonProperty(value = "expDataRate") + private int expDataRate; + + @JsonProperty(value = "maxNumberofPDUSession") + private int maxNumberOfPDUSession; + + @JsonProperty(value = "overallUserDensity") + private int overallUserDensity; + + @JsonProperty(value = "cSReliabilityMeanTime") + private String csReliabilityMeanTime; + + @JsonProperty(value = "msgSizeByte") + private String msgSizeByte; + + @JsonProperty(value = "transferIntervalTarget") + private String transferIntervalTarget; + + @JsonProperty(value = "ipAddress") + private String ipAddress; + + @JsonProperty(value = "logicInterfaceId") + private String logicInterfaceId; + + @JsonProperty(value = "nextHopInfo") + private String nextHopInfo; + public AnSliceProfile trans2AnProfile() { AnSliceProfile anSliceProfile = new AnSliceProfile(); BeanUtils.copyProperties(this, anSliceProfile); @@ -81,16 +128,16 @@ public class SliceProfileAdapter implements Serializable { areasRes[i] = str2Code(areas[i]); } anSliceProfile.setCoverageAreaTAList(Arrays.asList(areasRes)); - anSliceProfile.setUEMobilityLevel(UeMobilityLevel.fromString(this.uEMobilityLevel)); + + anSliceProfile.setUeMobilityLevel(UeMobilityLevel.fromString(this.ueMobilityLevel)); anSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(this.resourceSharingLevel)); - PerfReq perfReq = new PerfReq(); - // todo - anSliceProfile.setPerfReq(perfReq); + anSliceProfile.setPerfReq(generatePerfReq()); + return anSliceProfile; } private Integer str2Code(String area) { - return Math.abs(area.hashCode() >> 16); + return area.hashCode() >> 16; } public CnSliceProfile trans2CnProfile() { @@ -98,15 +145,31 @@ public class SliceProfileAdapter implements Serializable { BeanUtils.copyProperties(this, cnSliceProfile); cnSliceProfile.setSnssaiList(Arrays.asList(this.sNSSAIList.split("\\|"))); cnSliceProfile.setCoverageAreaTAList(Arrays.asList(this.coverageAreaTAList.split("\\|"))); - cnSliceProfile.setPlmnIdList(Arrays.asList(this.pLMNIdList.split("\\|"))); + cnSliceProfile.setPLMNIdList(Arrays.asList(this.pLMNIdList.split("\\|"))); cnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(this.resourceSharingLevel)); - cnSliceProfile.setUeMobilityLevel(UeMobilityLevel.fromString(this.uEMobilityLevel)); - PerfReq perfReq = new PerfReq(); - // todo - cnSliceProfile.setPerfReq(perfReq); + + cnSliceProfile.setPerfReq(generatePerfReq()); return cnSliceProfile; } + private PerfReq generatePerfReq() { + PerfReq perfReq = new PerfReq(); + if ("embb".equalsIgnoreCase(sST)) { + List<PerfReqEmbb> perfReqEmbbs = new ArrayList<>(); + PerfReqEmbb perfReqEmbb = new PerfReqEmbb(); + BeanUtils.copyProperties(this, perfReqEmbb); + perfReqEmbbs.add(perfReqEmbb); + perfReq.setPerfReqEmbbList(perfReqEmbbs); + } else if ("ullc".equalsIgnoreCase(sST)) { + List<PerfReqUrllc> perfReqUrllcs = new ArrayList<>(); + PerfReqUrllc perfReqUrllc = new PerfReqUrllc(); + BeanUtils.copyProperties(this, perfReqUrllc); + perfReqUrllcs.add(perfReqUrllc); + perfReq.setPerfReqUrllcList(perfReqUrllcs); + } + return perfReq; + } + public TnSliceProfile trans2TnProfile() { TnSliceProfile tnSliceProfile = new TnSliceProfile(); BeanUtils.copyProperties(this, tnSliceProfile); diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskInfo.java index 9b6406d57f..18d6007176 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskInfo.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskInfo.java @@ -52,4 +52,6 @@ public class SliceTaskInfo<T> implements Serializable { private SubnetType subnetType; + private String endPointId; + } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java index 3f0da1bf21..f904e1c466 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java @@ -35,14 +35,17 @@ public class TnSliceProfile implements Serializable { private String sliceProfileId; @JsonProperty(value = "maxBandwidth") - private String bandwidth; + private int maxBandwidth; @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int latency; - @JsonProperty(value = "sNSSAIList", required = true) + @JsonProperty(value = "snssaiList", required = true) private List<String> sNSSAIList; - @JsonProperty(value = "pLMNIdList", required = true) + @JsonProperty(value = "plmnIdList", required = true) private List<String> pLMNIdList; + + @JsonProperty(value = "jitter") + private int jitter; } diff --git a/common/src/main/java/org/onap/so/client/AddCacheHeaders.java b/common/src/main/java/org/onap/so/client/AddCacheHeaders.java new file mode 100644 index 0000000000..1a41be1233 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/AddCacheHeaders.java @@ -0,0 +1,28 @@ +package org.onap.so.client; + +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Priority; +import javax.ws.rs.client.ClientRequestContext; +import javax.ws.rs.client.ClientResponseContext; +import javax.ws.rs.client.ClientResponseFilter; +import javax.ws.rs.ext.Provider; + +@Provider +@Priority(1) +public class AddCacheHeaders implements ClientResponseFilter { + + private final CacheProperties props; + + public AddCacheHeaders(CacheProperties props) { + this.props = props; + } + + public void filter(ClientRequestContext request, ClientResponseContext response) throws IOException { + if (request.getMethod().equalsIgnoreCase("GET")) { + response.getHeaders().putIfAbsent("Cache-Control", + Collections.singletonList("public, max-age=" + (props.getMaxAge() / 1000))); + } + + } +} diff --git a/common/src/main/java/org/onap/so/client/CacheFactory.java b/common/src/main/java/org/onap/so/client/CacheFactory.java new file mode 100644 index 0000000000..6bc4858463 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/CacheFactory.java @@ -0,0 +1,25 @@ +package org.onap.so.client; + + +import java.util.concurrent.TimeUnit; +import javax.cache.configuration.Factory; +import javax.cache.expiry.Duration; +import javax.cache.expiry.ExpiryPolicy; +import javax.cache.expiry.TouchedExpiryPolicy; + +public class CacheFactory implements Factory<ExpiryPolicy> { + + private static final long serialVersionUID = 8948728679233836929L; + + private final CacheProperties props; + + public CacheFactory(CacheProperties props) { + this.props = props; + } + + @Override + public ExpiryPolicy create() { + return TouchedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS, props.getMaxAge())).create(); + } + +} diff --git a/common/src/main/java/org/onap/so/client/CacheProperties.java b/common/src/main/java/org/onap/so/client/CacheProperties.java new file mode 100644 index 0000000000..4fb2a87a5b --- /dev/null +++ b/common/src/main/java/org/onap/so/client/CacheProperties.java @@ -0,0 +1,13 @@ +package org.onap.so.client; + +public interface CacheProperties { + + + default Long getMaxAge() { + return 60000L; + } + + default String getCacheName() { + return "default-http-cache"; + } +} diff --git a/common/src/main/java/org/onap/so/client/RestClient.java b/common/src/main/java/org/onap/so/client/RestClient.java index 9fce328b1d..be0a0f3f9e 100644 --- a/common/src/main/java/org/onap/so/client/RestClient.java +++ b/common/src/main/java/org/onap/so/client/RestClient.java @@ -188,8 +188,20 @@ public abstract class RestClient { return APPLICATION_MERGE_PATCH_JSON; } + protected ClientBuilder getClientBuilder() { + ClientBuilder builder = ClientBuilder.newBuilder(); + if (props.isCachingEnabled()) { + enableCaching(builder); + } + return builder.readTimeout(props.getReadTimeout(), TimeUnit.MILLISECONDS); + } + + protected ClientBuilder enableCaching(ClientBuilder builder) { + return builder; + } + protected Client getClient() { - return ClientBuilder.newBuilder().readTimeout(props.getReadTimeout(), TimeUnit.MILLISECONDS).build(); + return getClientBuilder().build(); } protected abstract ONAPComponentsList getTargetEntity(); diff --git a/common/src/main/java/org/onap/so/client/RestClientSSL.java b/common/src/main/java/org/onap/so/client/RestClientSSL.java index 8956e20a5a..c6252e4652 100644 --- a/common/src/main/java/org/onap/so/client/RestClientSSL.java +++ b/common/src/main/java/org/onap/so/client/RestClientSSL.java @@ -24,7 +24,6 @@ import java.net.URI; import java.security.KeyStore; import java.security.NoSuchAlgorithmException; import java.util.Optional; -import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLContext; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; @@ -57,8 +56,7 @@ public abstract class RestClientSSL extends RestClient { } } // Use default SSL context - client = ClientBuilder.newBuilder().sslContext(SSLContext.getDefault()) - .readTimeout(props.getReadTimeout(), TimeUnit.MILLISECONDS).build(); + client = getClientBuilder().sslContext(SSLContext.getDefault()).build(); logger.info("RestClientSSL using default SSL context!"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); diff --git a/common/src/main/java/org/onap/so/client/RestProperties.java b/common/src/main/java/org/onap/so/client/RestProperties.java index 36da424f93..a7a0ef614c 100644 --- a/common/src/main/java/org/onap/so/client/RestProperties.java +++ b/common/src/main/java/org/onap/so/client/RestProperties.java @@ -49,4 +49,12 @@ public interface RestProperties { public default Long getReadTimeout() { return Long.valueOf(60000); } + + public default boolean isCachingEnabled() { + return false; + } + + public default CacheProperties getCacheProperties() { + return new CacheProperties() {}; + } } diff --git a/common/src/test/java/org/onap/so/client/RestClientTest.java b/common/src/test/java/org/onap/so/client/RestClientTest.java index c6e282c14a..d40576b69f 100644 --- a/common/src/test/java/org/onap/so/client/RestClientTest.java +++ b/common/src/test/java/org/onap/so/client/RestClientTest.java @@ -49,6 +49,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.logging.filter.base.ONAPComponents; import org.onap.logging.filter.base.ONAPComponentsList; import com.github.tomakehurst.wiremock.core.WireMockConfiguration; +import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer; import com.github.tomakehurst.wiremock.junit.WireMockRule; @RunWith(MockitoJUnitRunner.class) @@ -61,7 +62,8 @@ public class RestClientTest { public ExpectedException thrown = ExpectedException.none(); @Rule - public WireMockRule wireMockRule = new WireMockRule(WireMockConfiguration.options().dynamicPort()); + public WireMockRule wireMockRule = new WireMockRule( + WireMockConfiguration.options().dynamicPort().extensions(new ResponseTemplateTransformer(false))); @Test public void retries() throws Exception { diff --git a/common/src/test/resources/logback-test.xml b/common/src/test/resources/logback-test.xml index b52e6be022..3c5f259817 100644 --- a/common/src/test/resources/logback-test.xml +++ b/common/src/test/resources/logback-test.xml @@ -19,61 +19,60 @@ --> <configuration> - <property name="p_tim" value="%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", UTC}"/> - <property name="p_lvl" value="%level"/> - <property name="p_log" value="%logger"/> - <property name="p_mdc" value="%replace(%replace(%mdc){'\t','\\\\t'}){'\n', '\\\\n'}"/> - <property name="p_msg" value="%replace(%replace(%msg){'\t', '\\\\t'}){'\n','\\\\n'}"/> - <property name="p_exc" value="%replace(%replace(%rootException){'\t', '\\\\t'}){'\n','\\\\n'}"/> - <property name="p_mak" value="%replace(%replace(%marker){'\t', '\\\\t'}){'\n','\\\\n'}"/> - <property name="p_thr" value="%thread"/> - <property name="pattern" value="%nopexception${p_tim}\t${p_thr}\t${p_lvl}\t${p_log}\t${p_mdc}\t${p_msg}\t${p_exc}\t${p_mak}\t%n"/> + <property name="p_tim" value="%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", UTC}" /> + <property name="p_lvl" value="%level" /> + <property name="p_log" value="%logger" /> + <property name="p_mdc" value="%replace(%replace(%mdc){'\t','\\\\t'}){'\n', '\\\\n'}" /> + <property name="p_msg" value="%replace(%replace(%msg){'\t', '\\\\t'}){'\n','\\\\n'}" /> + <property name="p_exc" value="%replace(%replace(%rootException){'\t', '\\\\t'}){'\n','\\\\n'}" /> + <property name="p_mak" value="%replace(%replace(%marker){'\t', '\\\\t'}){'\n','\\\\n'}" /> + <property name="p_thr" value="%thread" /> + <property name="pattern" + value="%nopexception${p_tim}\t${p_thr}\t${p_lvl}\t${p_log}\t${p_mdc}\t${p_msg}\t${p_exc}\t${p_mak}\t%n" /> - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder> - <pattern>${pattern}</pattern> - </encoder> - </appender> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>${pattern}</pattern> + </encoder> + </appender> - <appender name="test" - class="org.onap.so.utils.TestAppender" /> + <appender name="test" class="org.onap.so.utils.TestAppender" /> - <logger name="com.att.ecomp.audit" level="info" additivity="false"> - <appender-ref ref="STDOUT" /> - </logger> + <logger name="com.att.ecomp.audit" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> - <logger name="com.att.eelf.metrics" level="info" additivity="false"> - <appender-ref ref="STDOUT" /> - </logger> + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> - <logger name="com.att.eelf.error" level="WARN" additivity="false"> - <appender-ref ref="STDOUT" /> - </logger> + <logger name="com.att.eelf.error" level="WARN" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> - <logger name="org.onap" level="${so.log.level:-DEBUG}" additivity="false"> - <appender-ref ref="STDOUT" /> - <appender-ref ref="test" /> - </logger> - - <logger name="org.flywaydb" level="DEBUG" additivity="false"> - <appender-ref ref="STDOUT" /> - </logger> - + <logger name="org.onap" level="${so.log.level:-DEBUG}" additivity="false"> + <appender-ref ref="STDOUT" /> + <appender-ref ref="test" /> + </logger> - <logger name="ch.vorburger" level="WARN" additivity="false"> - <appender-ref ref="STDOUT" /> - </logger> - - <logger name="org.reflections" level="ERROR" additivity="false"> - <appender-ref ref="STDOUT" /> - </logger> - + <logger name="org.flywaydb" level="DEBUG" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> - <root level="WARN"> - <appender-ref ref="STDOUT" /> - <appender-ref ref="test" /> - </root> + + <logger name="ch.vorburger" level="WARN" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="org.reflections" level="ERROR" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <root level="WARN"> + <appender-ref ref="STDOUT" /> + <appender-ref ref="test" /> + </root> </configuration>
\ No newline at end of file diff --git a/docs/release-notes.rst b/docs/release-notes.rst index ed8c7de674..b43997af12 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -10,6 +10,201 @@ Service Orchestrator Release Notes The SO provides the highest level of service orchestration in the ONAP architecture. +============= +Release Notes +============= + +Version: 1.7.10 +============== + +:Release Date: 2020-11-19 + +SO Release Image Versions +-------------------------- + - so-bpmn-infra + + :Version: 1.7.10 + + - so-catalog-db-adapter + + :Version: 1.7.10 + + - so-monitoring + + :Version: 1.7.10 + + - so/nssmf-adapter + + :Version: 1.7.10 + + - so/openstack-adapter + + :Version: 1.7.10 + + - so/request-db-adapter + + :Version: 1.7.10 + + - so/sdc-controller + + :Version: 1.7.10 + + - so/sdnc-adapter + + :Version: 1.7.10 + + - so/vnfm-adapter + + :Version: 1.7.10 + + - so/api-handler-infra + + :Version: 1.7.10 + + - so/api-handler-infra + + :Version: 1.7.10 + + - so/so-etsi-nfvo-ns-lcm + + :Version: 1.7.7 + + - so/so-oof-adapter + + :Version: 1.7.6 + + - so/cnf-adapter + + :Version: 1.7.10 + +Release Purpose +---------------- +SO Guilin Release + +**Epics** + +* `SO-3167 <https://jira.onap.org/browse/SO-3167>`_ - Design ETSI SOL007 compliant Network Service Descriptor packages +* `SO-3208 <https://jira.onap.org/browse/SO-3208>`_ - SOL003 Adapter maintenance Enhancements +* `SO-3036 <https://jira.onap.org/browse/SO-3036>`_ - SO impacts for E2E Network Slicing use case in Guilin +* `SO-2936 <https://jira.onap.org/browse/SO-2936>`_ - PNF PnP: SO macro flow - use existing PNF instance in a Service Instance +* `SO-2843 <https://jira.onap.org/browse/SO-2843>`_ - Support NS LCM and Workflows Management +* `SO-2842 <https://jira.onap.org/browse/SO-2842>`_ - Support for SOL005 NBI API Handler +* `SO-2841 <https://jira.onap.org/browse/SO-2841>`_ - Support SO NFVO Microservice Plugin Capabilities +* `SO-2840 <https://jira.onap.org/browse/SO-2840>`_ - Support for ETSI NFV NFVO Orchestrator in ONAP SO (ONAP SO ETSI-Aligned Hierarchical Orchestration) +* `SO-2841 <https://jira.onap.org/browse/SO-2681>`_ - SO direct Catalog Management Support - Guilin +* `SO-2046 <https://jira.onap.org/browse/SO-2046>`_ - support Java 11 upgrade + + +**Stories** + +The full list of implemented tasks is available on `JIRA GUILIN STORY <https://jira.onap.org/issues/?jql=project%20%3D%20%22Service%20Orchestrator%22%20%20AND%20issuetype%20%3D%20story%20AND%20fixVersion%20%3D%20%22Guilin%20Release%22>`_ +Listed below are key functional jira stories handled in the Guilin release: + +* `SO-2950 <https://jira.onap.org/browse/SO-2950>`_ - Asynchronous service activation response handling support in MDONS +* `SO-3028 <https://jira.onap.org/browse/SO-3028>`_ - SO supports the OVP 2.0 test platform +* `SO-2930 <https://jira.onap.org/browse/SO-2930>`_ - Service level workflow execution API +* `SO-2929 <https://jira.onap.org/browse/SO-2929>`_ - Service level workflow retrieving API +* `SO-2928 <https://jira.onap.org/browse/SO-2928>`_ - Service model retrieving API +* `SO-2927 <https://jira.onap.org/browse/SO-2927>`_ - Generic service level upgrade workflow +* `SO-2926 <https://jira.onap.org/browse/SO-2926>`_ - New Service Level postCheck building block +* `SO-2925 <https://jira.onap.org/browse/SO-2925>`_ - New Service Level Upgrade building block +* `SO-2924 <https://jira.onap.org/browse/SO-2924>`_ - New Service Level Preparation building block +* `SO-2981 <https://jira.onap.org/browse/SO-2981>`_ - PNF Plug & Play in R7 - SO Building Block Work +* `SO-3026 <https://jira.onap.org/browse/SO-3026>`_ - Adapter for the SO to interact with the K8S plugin +* `SO-3025 <https://jira.onap.org/browse/SO-3025>`_ - SO should support CNFO +* `SO-3039 <https://jira.onap.org/browse/SO-3039>`_ - Containers must crash properly when a failure occurs +* `SO-3040 <https://jira.onap.org/browse/SO-3040>`_ - ONAP container repository (nexus) must not contain upstream docker images +* `SO-3029 <https://jira.onap.org/browse/SO-3029>`_ - SO support Multi Tenancy +* `SO-3077 <https://jira.onap.org/browse/SO-3077>`_ - ONAP shall use STDOUT for logs collection - REQ-374 + +**Tasks** + +The full list of implemented tasks is available on `JIRA GUILIN TASKS <https://jira.onap.org/issues/?jql=project%20%3D%20%22Service%20Orchestrator%22%20%20AND%20issuetype%20%3D%20Task%20AND%20fixVersion%20%3D%20%22Guilin%20Release%22>`_ +Listed below are highest and high piority jira tasks handled in the Guilin release: + +* `SO-3205 <https://jira.onap.org/browse/SO-3205>`_ - E2E Network Slicing: Improvements for NST/NSI Selection callback +* `SO-3120 <https://jira.onap.org/browse/SO-3120>`_ - Create swagger api for software upgrade in SO +* `SO-2915 <https://jira.onap.org/browse/SO-2915>`_ - Upgrade Vulnerable Direct Dependencies + + +**Bug Fixes** + +The full list of fixed bugs is available on `JIRA GUILIN BUGS +<https://jira.onap.org/issues/?jql=project%20%3D%20%22Service%20Orchestrator%22%20%20AND%20issuetype%20%3D%20Bug%20AND%20fixVersion%20%3D%20%22Guilin%20Release%22>`_ +Listed below are highest and high piority jira tasks handled in the Guilin release: + +* `SO-3375 <https://jira.onap.org/browse/SO-3375>`_ - FlowManipulatorListenerRunner does not invoke for controller execution config-deploy +* `SO-3369 <https://jira.onap.org/browse/SO-3369>`_ - Fix basic vm test case in onap +* `SO-3364 <https://jira.onap.org/browse/SO-3364>`_ - SO sends rest request to cds twice per one operation +* `SO-3360 <https://jira.onap.org/browse/SO-3360>`_ - SO-OpenStack-Adapter attempts to create wrong vserver-to-vnfc relation in AAI +* `SO-3357 <https://jira.onap.org/browse/SO-3357>`_ - ControllerExecutionBB is triggered, when running a`la carte DeleteVFModule +* `SO-3352 <https://jira.onap.org/browse/SO-3352>`_ - Exception in org.onap.so.bpmn.infrastructure.workflow.tasks.OrchestrationStatusValidator.validateOrchestrationStatus Orchestration Status Validation failed +* `SO-3351 <https://jira.onap.org/browse/SO-3351>`_ - Staging image is present in OOM master branch +* `SO-3346 <https://jira.onap.org/browse/SO-3346>`_ - vFW CNF AssignVfModuleBB has failed +* `SO-3342 <https://jira.onap.org/browse/SO-3342>`_ - VnfAdapter is configured by default to v1 version whereas v2 version is more complete +* `SO-3341 <https://jira.onap.org/browse/SO-3341>`_ - Exception of Writing NSSI to AAI for ExternalNssmfManager +* `SO-3339 <https://jira.onap.org/browse/SO-3339>`_ - Transport Slicing integration: network-policy is missing under allotted-resource +* `SO-3326 <https://jira.onap.org/browse/SO-3326>`_ - Transport Slicing integration: AAI Exception in DeAllocate TN NSSI WF +* `SO-3322 <https://jira.onap.org/browse/SO-3322>`_ - PNF service instantiation using building blocks fails during ActivateServiceInstanceBB building block execution +* `SO-3321 <https://jira.onap.org/browse/SO-3321>`_ - Transport Slicing integration: SO sets wrong subscription-service-type in SDNC payload +* `SO-3313 <https://jira.onap.org/browse/SO-3313>`_ - SO getting disto error while SDC distribution +* `SO-3310 <https://jira.onap.org/browse/SO-3310>`_ - Transport Slicing Integration: null pointer exception in saving SDNC rollback data +* `SO-3309 <https://jira.onap.org/browse/SO-3309>`_ - Transport Slicing integration: unable to get prefix environment variable from execution in TnNssmfUntils +* `SO-3308 <https://jira.onap.org/browse/SO-3308>`_ - Transport Slicing integration: MSOWorkflowException: mso-request-id not provided +* `SO-3304 <https://jira.onap.org/browse/SO-3304>`_ - Exception in org.onap.so.bpmn.infrastructure.aai.tasks.AAICreateTasks.createServiceInstance ModelMapper configuration errors +* `SO-3296 <https://jira.onap.org/browse/SO-3296>`_ - SO has python 2.7 pods +* `SO-3294 <https://jira.onap.org/browse/SO-3294>`_ - Parameters exception of Deallocating NSSI +* `SO-3293 <https://jira.onap.org/browse/SO-3293>`_ - Allocate TN NSSI fails to create relationship between allotted-resource and logical-links +* `SO-3290 <https://jira.onap.org/browse/SO-3290>`_ - SO-VNFM certificates expired +* `SO-3284 <https://jira.onap.org/browse/SO-3284>`_ - Exceptions in Allocate TN NSSI work flow +* `SO-3275 <https://jira.onap.org/browse/SO-3275>`_ - Fix 3gppservices URI path in API-Handler +* `SO-3274 <https://jira.onap.org/browse/SO-3274>`_ - Parameters exception of Allocating NSSI +* `SO-3271 <https://jira.onap.org/browse/SO-3271>`_ - SO/BB PNF - skip_post_instantiation_configuration is not processed properly. +* `SO-3270 <https://jira.onap.org/browse/SO-3270>`_ - BB workflow failing sporadically during post instantiation +* `SO-3266 <https://jira.onap.org/browse/SO-3266>`_ - BPMN config assign bb - NullPointerException in ControllerExecution +* `SO-3261 <https://jira.onap.org/browse/SO-3261>`_ - Encountering NullPointerException, WorkFlow failure after Java 11 upgrade Code refactorig on SO-bpmn-infra code base. +* `SO-3243 <https://jira.onap.org/browse/SO-3243>`_ - SO-bpmn-infra Container after Java 11 upgrade encountering SunCertPathBuilder Exception: unable to find valid certification path to requested target in CSIT +* `SO-3236 <https://jira.onap.org/browse/SO-3236>`_ - SO has java 8 pods +* `SO-3216 <https://jira.onap.org/browse/SO-3216>`_ - Integration E2E VNF test fails due to missing EdgeRule in AAI call +* `SO-3196 <https://jira.onap.org/browse/SO-3196>`_ - [SO] so-sdc-controller fails to connect to aai due to cert issue +* `SO-3193 <https://jira.onap.org/browse/SO-3193>`_ - Macro Workflow fails in AssignVnfBB in step HomingBB +* `SO-2941 <https://jira.onap.org/browse/SO-2941>`_ - Docker are not built anymore +* `SO-2939 <https://jira.onap.org/browse/SO-2939>`_ - Master branch uses SNAPSHOT version that are not available anymore +* `SO-2809 <https://jira.onap.org/browse/SO-2809>`_ - SO build is failing due to unable to download org.onap.appc.client:client-lib:jar:1.7.1-SNAPSHOT +* `SO-2797 <https://jira.onap.org/browse/SO-2797>`_ - BB workflow with post instantiation is not working + + +Security Notes +-------------- + +*Fixed Security Issues* + +*Known Security Issues* + +*Known Vulnerabilities in Used Modules* + +Quick Links: + +- `SO project page <https://wiki.onap.org/display/DW/Service+Orchestrator+Project>`__ +- `Passing Badge information for SDC <https://bestpractices.coreinfrastructure.org/en/projects/1702>`__ + +**Known Issues** + + N/A + +**Upgrade Notes** + + N/A + +**Deprecation Notes** + + SO modules Ve-Vnfm-adapter and appc-orchestrator are deprectaed for the Guilin release. + +**Other** + + N/A +*************************************************************************************** + Version: 1.6.4 ----------------------- diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/CacheControlFeature.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/CacheControlFeature.java new file mode 100644 index 0000000000..1e7c3e7f71 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/CacheControlFeature.java @@ -0,0 +1,137 @@ +package org.onap.aaiclient.client; + +import java.io.Closeable; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Arrays; +import java.util.Map; +import java.util.Properties; +import javax.annotation.PreDestroy; +import javax.cache.Cache; +import javax.cache.CacheManager; +import javax.cache.Caching; +import javax.cache.configuration.Factory; +import javax.cache.configuration.FactoryBuilder; +import javax.cache.configuration.MutableCacheEntryListenerConfiguration; +import javax.cache.configuration.MutableConfiguration; +import javax.cache.expiry.ExpiryPolicy; +import javax.cache.integration.CacheLoader; +import javax.cache.integration.CacheWriter; +import javax.cache.spi.CachingProvider; +import javax.ws.rs.core.Feature; +import javax.ws.rs.core.FeatureContext; +import javax.ws.rs.ext.Provider; +import org.apache.cxf.jaxrs.client.cache.CacheControlClientReaderInterceptor; +import org.apache.cxf.jaxrs.client.cache.CacheControlClientRequestFilter; +import org.apache.cxf.jaxrs.client.cache.Entry; +import org.apache.cxf.jaxrs.client.cache.Key; + + +@Provider +public class CacheControlFeature implements Feature, Closeable { + private CachingProvider provider; + private CacheManager manager; + private Cache<Key, Entry> cache; + private boolean cacheResponseInputStream; + private Factory<ExpiryPolicy> expiryPolicy; + + @Override + public boolean configure(final FeatureContext context) { + // TODO: read context properties to exclude some patterns? + final Cache<Key, Entry> entryCache = createCache(context.getConfiguration().getProperties()); + context.register(new CacheControlClientRequestFilter(entryCache)); + CacheControlClientReaderInterceptor reader = new CacheControlClientReaderInterceptor(entryCache); + reader.setCacheResponseInputStream(cacheResponseInputStream); + context.register(reader); + return true; + } + + @PreDestroy // TODO: check it is called + public void close() { + for (final Closeable c : Arrays.asList(cache, manager, provider)) { + try { + if (c != null) { + c.close(); + } + } catch (final Exception e) { + // no-op + } + } + } + + private Cache<Key, Entry> createCache(final Map<String, Object> properties) { + final Properties props = new Properties(); + props.putAll(properties); + + final String prefix = this.getClass().getName() + "."; + final String uri = props.getProperty(prefix + "config-uri"); + final String name = props.getProperty(prefix + "name", this.getClass().getName()); + + final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); + + provider = Caching.getCachingProvider(); + try { + synchronized (contextClassLoader) { + manager = provider.getCacheManager(uri == null ? provider.getDefaultURI() : new URI(uri), + contextClassLoader, props); + if (manager.getCache(name) == null) { + final MutableConfiguration<Key, Entry> configuration = new MutableConfiguration<Key, Entry>() + .setReadThrough("true".equalsIgnoreCase(props.getProperty(prefix + "readThrough", "false"))) + .setWriteThrough( + "true".equalsIgnoreCase(props.getProperty(prefix + "writeThrough", "false"))) + .setManagementEnabled( + "true".equalsIgnoreCase(props.getProperty(prefix + "managementEnabled", "false"))) + .setStatisticsEnabled( + "true".equalsIgnoreCase(props.getProperty(prefix + "statisticsEnabled", "false"))) + .setStoreByValue( + "true".equalsIgnoreCase(props.getProperty(prefix + "storeByValue", "false"))); + + final String loader = props.getProperty(prefix + "loaderFactory"); + if (loader != null) { + @SuppressWarnings("unchecked") + Factory<? extends CacheLoader<Key, Entry>> f = + newInstance(contextClassLoader, loader, Factory.class); + configuration.setCacheLoaderFactory(f); + } + final String writer = props.getProperty(prefix + "writerFactory"); + if (writer != null) { + @SuppressWarnings("unchecked") + Factory<? extends CacheWriter<Key, Entry>> f = + newInstance(contextClassLoader, writer, Factory.class); + configuration.setCacheWriterFactory(f); + } + if (expiryPolicy != null) { + + configuration.setExpiryPolicyFactory(expiryPolicy); + } + configuration.addCacheEntryListenerConfiguration(new MutableCacheEntryListenerConfiguration( + FactoryBuilder.factoryOf(new CacheLogger()), null, true, true)); + + cache = manager.createCache(name, configuration); + } else { + cache = manager.getCache(name); + } + return cache; + } + } catch (final URISyntaxException e) { + throw new IllegalArgumentException(e); + } + } + + @SuppressWarnings("unchecked") + private static <T> T newInstance(final ClassLoader contextClassLoader, final String clazz, final Class<T> cast) { + try { + return (T) contextClassLoader.loadClass(clazz).newInstance(); + } catch (final Exception e) { + throw new IllegalArgumentException(e); + } + } + + public void setCacheResponseInputStream(boolean cacheStream) { + this.cacheResponseInputStream = cacheStream; + } + + public void setExpiryPolicyFactory(Factory<ExpiryPolicy> f) { + this.expiryPolicy = f; + } +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/CacheLogger.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/CacheLogger.java new file mode 100644 index 0000000000..f3dc610125 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/CacheLogger.java @@ -0,0 +1,53 @@ +package org.onap.aaiclient.client; + +import java.io.Serializable; +import javax.cache.event.CacheEntryCreatedListener; +import javax.cache.event.CacheEntryEvent; +import javax.cache.event.CacheEntryExpiredListener; +import javax.cache.event.CacheEntryListenerException; +import javax.cache.event.CacheEntryRemovedListener; +import javax.cache.event.CacheEntryUpdatedListener; +import org.apache.cxf.jaxrs.client.cache.Entry; +import org.apache.cxf.jaxrs.client.cache.Key; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CacheLogger implements CacheEntryExpiredListener<Key, Entry>, CacheEntryCreatedListener<Key, Entry>, + CacheEntryUpdatedListener<Key, Entry>, CacheEntryRemovedListener<Key, Entry>, Serializable { + + private static final long serialVersionUID = 1L; + private static final Logger logger = LoggerFactory.getLogger(CacheLogger.class); + + @Override + public void onExpired(Iterable<CacheEntryEvent<? extends Key, ? extends Entry>> events) + throws CacheEntryListenerException { + for (CacheEntryEvent<? extends Key, ? extends Entry> event : events) { + logger.debug("{} expired key: {}", event.getSource().getName(), event.getKey().getUri()); + } + } + + @Override + public void onRemoved(Iterable<CacheEntryEvent<? extends Key, ? extends Entry>> events) + throws CacheEntryListenerException { + for (CacheEntryEvent<? extends Key, ? extends Entry> event : events) { + logger.debug("{} removed key: {}", event.getSource().getName(), event.getKey().getUri()); + } + } + + @Override + public void onUpdated(Iterable<CacheEntryEvent<? extends Key, ? extends Entry>> events) + throws CacheEntryListenerException { + for (CacheEntryEvent<? extends Key, ? extends Entry> event : events) { + logger.debug("{} updated key: {}", event.getSource().getName(), event.getKey().getUri()); + } + } + + @Override + public void onCreated(Iterable<CacheEntryEvent<? extends Key, ? extends Entry>> events) + throws CacheEntryListenerException { + for (CacheEntryEvent<? extends Key, ? extends Entry> event : events) { + logger.debug("{} created key: {}", event.getSource().getName(), event.getKey().getUri()); + } + } + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/FlushCache.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/FlushCache.java new file mode 100644 index 0000000000..0f290ff620 --- /dev/null +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/FlushCache.java @@ -0,0 +1,41 @@ +package org.onap.aaiclient.client; + +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; +import javax.cache.CacheManager; +import javax.cache.Caching; +import javax.ws.rs.HttpMethod; +import javax.ws.rs.client.ClientRequestContext; +import javax.ws.rs.client.ClientResponseContext; +import javax.ws.rs.client.ClientResponseFilter; +import org.apache.cxf.jaxrs.client.cache.Key; +import org.onap.so.client.CacheProperties; + +public class FlushCache implements ClientResponseFilter { + + private static final Set<String> modifyMethods = + new HashSet<>(Arrays.asList(HttpMethod.DELETE, HttpMethod.PATCH, HttpMethod.PUT, HttpMethod.POST)); + + private final CacheProperties props; + + public FlushCache(CacheProperties props) { + this.props = props; + } + + @Override + public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException { + + if (responseContext.getStatus() >= 200 && responseContext.getStatus() <= 299) { + if (FlushCache.modifyMethods.contains(requestContext.getMethod())) { + + CacheManager cacheManager = Caching.getCachingProvider().getCacheManager( + Caching.getCachingProvider().getDefaultURI(), Thread.currentThread().getContextClassLoader()); + cacheManager.getCache(props.getCacheName()).remove( + new Key(requestContext.getUri(), requestContext.getAcceptableMediaTypes().get(0).toString())); + } + } + } + +} diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIProperties.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIProperties.java index ac8a6e6e52..9c7798f4c5 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIProperties.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIProperties.java @@ -20,6 +20,7 @@ package org.onap.aaiclient.client.aai; +import org.onap.so.client.CacheProperties; import org.onap.so.client.RestProperties; public interface AAIProperties extends RestProperties { @@ -34,4 +35,15 @@ public interface AAIProperties extends RestProperties { public default boolean mapNotFoundToEmpty() { return true; } + + default CacheProperties getCacheProperties() { + return new AAICacheProperties() {}; + } + + public interface AAICacheProperties extends CacheProperties { + + default String getCacheName() { + return "aai-http-cache"; + } + } } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java index c2422085aa..c22f2f5f8e 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java @@ -23,8 +23,13 @@ package org.onap.aaiclient.client.graphinventory; import java.net.URI; import java.util.Map; import java.util.Optional; +import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.Response; +import org.onap.aaiclient.client.CacheControlFeature; +import org.onap.aaiclient.client.FlushCache; import org.onap.logging.filter.base.ONAPComponentsList; +import org.onap.so.client.AddCacheHeaders; +import org.onap.so.client.CacheFactory; import org.onap.so.client.ResponseExceptionMapper; import org.onap.so.client.RestClientSSL; import org.onap.so.client.RestProperties; @@ -41,6 +46,21 @@ public abstract class GraphInventoryRestClient extends RestClientSSL { super(props, Optional.of(uri)); } + + protected ClientBuilder enableCaching(ClientBuilder builder) { + builder.register(new AddCacheHeaders(props.getCacheProperties())); + builder.register(new FlushCache(props.getCacheProperties())); + CacheControlFeature cacheControlFeature = new CacheControlFeature(); + cacheControlFeature.setCacheResponseInputStream(true); + cacheControlFeature.setExpiryPolicyFactory(new CacheFactory(props.getCacheProperties())); + builder.property("org.onap.aaiclient.client.CacheControlFeature.name", + props.getCacheProperties().getCacheName()); + + builder.register(cacheControlFeature); + + return builder; + } + @Override public abstract ONAPComponentsList getTargetEntity(); diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java index b73454fe67..d0f7847726 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java @@ -25,7 +25,11 @@ import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor; import static com.github.tomakehurst.wiremock.client.WireMock.matching; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; +import static com.github.tomakehurst.wiremock.client.WireMock.verify; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; import static org.hamcrest.CoreMatchers.containsString; import static org.mockito.ArgumentMatchers.any; @@ -35,8 +39,10 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; +import java.net.URL; import java.util.HashMap; import javax.ws.rs.core.Response; import org.junit.Rule; @@ -48,6 +54,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.aaiclient.client.defaultproperties.DefaultAAIPropertiesImpl; import org.onap.aaiclient.client.graphinventory.GraphInventoryPatchConverter; import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryPatchDepthExceededException; +import org.onap.so.client.RestClient; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.junit.WireMockRule; import com.google.common.collect.ImmutableMap; @@ -96,4 +103,113 @@ public class AAIRestClientTest { wireMockRule.verify(getRequestedFor(urlPathEqualTo("/test")).withHeader("X-FromAppId", equalTo("MSO")) .withHeader("X-TransactionId", matching(".*")).withHeader("test", equalTo("value"))); } + + + @Test + public void cacheGetTest() throws URISyntaxException, InterruptedException { + + wireMockRule.stubFor(get(urlPathMatching("/cached")) + .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/plain").withBody("value"))); + + AAIProperties props = new AAIProperties() { + + @Override + public URL getEndpoint() throws MalformedURLException { + return new URL(String.format("http://localhost:%s", wireMockRule.port())); + } + + @Override + public String getSystemName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isCachingEnabled() { + return true; + } + + @Override + public AAIVersion getDefaultVersion() { + return AAIVersion.LATEST; + } + + @Override + public String getAuth() { + return null; + } + + @Override + public String getKey() { + return null; + } + + }; + RestClient client = new AAIRestClient(props, new URI("/cached"), new HashMap<String, String>()); + + Response response = client.get(); + + response.readEntity(String.class); + response = client.get(); + response.readEntity(String.class); + verify(1, getRequestedFor(urlEqualTo("/cached"))); + + } + + @Test + public void cachePutTest() throws URISyntaxException, InterruptedException { + + wireMockRule.stubFor(put(urlPathMatching("/cached/1")).willReturn(aResponse().withStatus(200))); + + wireMockRule.stubFor(get(urlPathMatching("/cached/1")) + .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody("{}"))); + + AAIProperties props = new AAIProperties() { + + @Override + public URL getEndpoint() throws MalformedURLException { + return new URL(String.format("http://localhost:%s", wireMockRule.port())); + } + + @Override + public String getSystemName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean isCachingEnabled() { + return true; + } + + @Override + public AAIVersion getDefaultVersion() { + return AAIVersion.LATEST; + } + + @Override + public String getAuth() { + return null; + } + + @Override + public String getKey() { + return null; + } + + }; + + RestClient client = new AAIRestClient(props, new URI("/cached/1"), new HashMap<String, String>()); + + + Response response = client.get(); + + response.readEntity(String.class); + client.put("wow"); + + client.get(); + response.readEntity(String.class); + verify(2, getRequestedFor(urlEqualTo("/cached/1"))); + + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java index 6e6a9d2b07..1492baf1cd 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java @@ -24,6 +24,7 @@ import java.net.MalformedURLException; import java.net.URL; import org.onap.aaiclient.client.aai.AAIProperties; import org.onap.aaiclient.client.aai.AAIVersion; +import org.onap.so.client.CacheProperties; import org.onap.so.spring.SpringContextHelper; import org.springframework.context.ApplicationContext; @@ -33,6 +34,8 @@ public class AaiClientPropertiesImpl implements AAIProperties { private String auth; private String key; private Long readTimeout; + private boolean enableCaching; + private Long cacheMaxAge; public AaiClientPropertiesImpl() { @@ -41,6 +44,8 @@ public class AaiClientPropertiesImpl implements AAIProperties { this.auth = context.getEnvironment().getProperty("aai.auth"); this.key = context.getEnvironment().getProperty("mso.msoKey"); this.readTimeout = context.getEnvironment().getProperty("aai.readTimeout", Long.class, new Long(60000)); + this.enableCaching = context.getEnvironment().getProperty("aai.caching.enabled", Boolean.class, false); + this.cacheMaxAge = context.getEnvironment().getProperty("aai.caching.maxAge", Long.class, 60000L); } @Override @@ -72,4 +77,19 @@ public class AaiClientPropertiesImpl implements AAIProperties { public Long getReadTimeout() { return this.readTimeout; } + + @Override + public boolean isCachingEnabled() { + return this.enableCaching; + } + + @Override + public CacheProperties getCacheProperties() { + return new AAICacheProperties() { + @Override + public Long getMaxAge() { + return cacheMaxAge; + } + }; + } } diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiPropertiesImpl.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiPropertiesImpl.java index 910d5fa75c..0aa14c711f 100644 --- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiPropertiesImpl.java +++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiPropertiesImpl.java @@ -22,6 +22,7 @@ package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.aai; import org.onap.aaiclient.client.aai.AAIProperties; import org.onap.aaiclient.client.aai.AAIVersion; +import org.onap.so.client.CacheProperties; import org.onap.so.spring.SpringContextHelper; import org.springframework.context.ApplicationContext; import java.net.MalformedURLException; @@ -34,6 +35,8 @@ public class AaiPropertiesImpl implements AAIProperties { private final String encryptionKey; private final String aaiVersion; private final Long readTimeout; + private final boolean enableCaching; + private final Long cacheMaxAge; public AaiPropertiesImpl() { final ApplicationContext context = SpringContextHelper.getAppContext(); @@ -42,6 +45,8 @@ public class AaiPropertiesImpl implements AAIProperties { this.encryptionKey = context.getEnvironment().getProperty("mso.key"); this.aaiVersion = context.getEnvironment().getProperty("aai.version"); this.readTimeout = context.getEnvironment().getProperty("aai.readTimeout", Long.class, new Long(60000)); + this.enableCaching = context.getEnvironment().getProperty("aai.caching.enabled", Boolean.class, false); + this.cacheMaxAge = context.getEnvironment().getProperty("aai.caching.maxAge", Long.class, 60000L); } @Override @@ -79,4 +84,19 @@ public class AaiPropertiesImpl implements AAIProperties { public Long getReadTimeout() { return this.readTimeout; } + + @Override + public boolean isCachingEnabled() { + return this.enableCaching; + } + + @Override + public CacheProperties getCacheProperties() { + return new AAICacheProperties() { + @Override + public Long getMaxAge() { + return cacheMaxAge; + } + }; + } } |