diff options
42 files changed, 456 insertions, 87 deletions
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java index 07d88c9abe..3deabb3ce1 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java @@ -107,7 +107,7 @@ public class ArchiveInfraRequestsScheduler { for (InfraActiveRequests iar : requests) { ArchivedInfraRequests archivedInfra = new ArchivedInfraRequests(); try { - archivedInfra.setAicCloudRegion(iar.getAicCloudRegion()); + archivedInfra.setCloudRegion(iar.getCloudRegion()); archivedInfra.setCallBackUrl(iar.getCallBackUrl()); archivedInfra.setConfigurationId(iar.getConfigurationId()); archivedInfra.setConfigurationName(iar.getConfigurationName()); diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.2__Add_PNF_Column_Infra_Requests_archive_tables.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.2__Add_PNF_Column_Infra_Requests_archive_tables.sql new file mode 100644 index 0000000000..dbdc925dae --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V7.2__Add_PNF_Column_Infra_Requests_archive_tables.sql @@ -0,0 +1,4 @@ +use requestdb; + +ALTER TABLE infra_active_requests ADD COLUMN IF NOT EXISTS PNF_ID varchar(45); +ALTER TABLE archived_infra_requests ADD COLUMN IF NOT EXISTS PNF_ID varchar(45);
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java index 0698023184..a7f21334ed 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomControllerTest.java @@ -111,7 +111,7 @@ public class InfraActiveRequestsRepositoryCustomControllerTest extends RequestsA infraActiveRequests.setNetworkName("networkInstanceNameTest"); infraActiveRequests.setConfigurationId(UUID.randomUUID().toString()); infraActiveRequests.setConfigurationName("configurationInstanceNameTest"); - infraActiveRequests.setAicCloudRegion("1"); + infraActiveRequests.setCloudRegion("1"); infraActiveRequests.setTenantId(UUID.randomUUID().toString()); infraActiveRequests.setRequestScope("operationalEnvironment"); infraActiveRequests.setRequestorId(UUID.randomUUID().toString()); diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java index eacd413df6..fef9dbc22c 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java @@ -98,7 +98,7 @@ public class MSORequestDBImplTest extends RequestsAdapterBase { testRequest.setServiceInstanceId("e3b5744d-2ad1-4cdd-8390-c999a38829bc"); testRequest.setRequestAction("deleteInstance"); testRequest.setRequestScope("vfModule"); - testRequest.setAicCloudRegion("mtn6"); + testRequest.setCloudRegion("mtn6"); testRequest.setLastModifiedBy("BPMN"); testRequest.setVfModuleId("c7d527b1-7a91-49fd-b97d-1c8c0f4a7992"); testRequest.setVfModuleModelName("vSAMP10aDEV::base::module-0"); diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java index 11b6cf4872..09fea0644e 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/client/RequestsDbClientTest.java @@ -76,7 +76,7 @@ public class RequestsDbClientTest extends RequestsAdapterBase { infraActiveRequests.setNetworkName("networkInstanceNameTest"); infraActiveRequests.setConfigurationId(UUID.randomUUID().toString()); infraActiveRequests.setConfigurationName("configurationInstanceNameTest"); - infraActiveRequests.setAicCloudRegion("1"); + infraActiveRequests.setCloudRegion("1"); infraActiveRequests.setTenantId(UUID.randomUUID().toString()); infraActiveRequests.setRequestScope("operationalEnvironment"); infraActiveRequests.setRequestorId(UUID.randomUUID().toString()); @@ -112,7 +112,7 @@ public class RequestsDbClientTest extends RequestsAdapterBase { infraActiveRequests2.setNetworkName("networkInstanceNameTest"); infraActiveRequests2.setConfigurationId(UUID.randomUUID().toString()); infraActiveRequests2.setConfigurationName("configurationInstanceNameTest"); - infraActiveRequests2.setAicCloudRegion("1"); + infraActiveRequests2.setCloudRegion("1"); infraActiveRequests2.setTenantId(UUID.randomUUID().toString()); infraActiveRequests2.setRequestScope("operationalEnvironment"); infraActiveRequests2.setRequestorId(UUID.randomUUID().toString()); diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java index a73958e544..d4063951bd 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java @@ -20,8 +20,8 @@ package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001; import java.util.Optional; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001; /** * Provides methods for invoking REST calls to the ETSI Catalog Manager. @@ -53,4 +53,14 @@ public interface EtsiCatalogServiceProvider { */ Optional<InlineResponse2001> getVnfPackage(final String vnfPkgId); + /** + * GET Package Artifact, from VNF Package. + * + * @param vnfPkgId The ID of the VNF Package from which the artifact will be retrieved. + * @param artifactPath Sequence of one or more path segments representing the path of the artifact within the VNF + * Package, e.g., foo/bar/run.sh + * @return The Package Artifact of a VNF Package ("vnfPkgId", "artifactPath"). + */ + Optional<byte[]> getVnfPackageArtifact(final String vnfPkgId, final String artifactPath); + } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java index 96b01f04e4..11a59c2ec8 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java @@ -23,10 +23,7 @@ package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog; import java.util.Optional; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPkgInfo; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.EtsiCatalogManagerRequestFailureException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfPkgBadRequestException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfPkgConflictException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfPkgNotFoundException; +import org.onap.so.adapters.vnfmadapter.rest.exceptions.*; import org.onap.so.rest.exceptions.HttpResouceNotFoundException; import org.onap.so.rest.exceptions.InvalidRestRequestException; import org.onap.so.rest.exceptions.RestProcessingException; @@ -88,6 +85,31 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide } @Override + public Optional<byte[]> getVnfPackageArtifact(final String vnfPkgId, final String artifactPath) { + try { + final ResponseEntity<byte[]> response = httpServiceProvider.getHttpResponse( + etsiCatalogUrlProvider.getVnfPackageArtifactUrl(vnfPkgId, artifactPath), byte[].class); + logger.info("getVnfPackageArtifact Request to ETSI Catalog Manager Status Code: {}", + response.getStatusCodeValue()); + if (response.getStatusCode() == HttpStatus.OK) { + return Optional.ofNullable(response.getBody()); + } + } catch (final HttpResouceNotFoundException httpResouceNotFoundException) { + logger.error("Caught HttpResouceNotFoundException", httpResouceNotFoundException); + throw new VnfPkgNotFoundException("No Vnf Package Artifact found with vnfPkgId: \"" + vnfPkgId + + "\" and artifactPath: \"" + artifactPath + "\"."); + } catch (final RestProcessingException restProcessingException) { + logger.error("Caught RestProcessingException with Status Code: {}", restProcessingException.getStatusCode(), + restProcessingException); + if (restProcessingException.getStatusCode() == HttpStatus.CONFLICT.value()) { + throw new VnfPkgConflictException("A conflict occurred with the state of the resource,\n" + + "due to the attribute: onboardingState not being set to ONBOARDED."); + } + } + throw new EtsiCatalogManagerRequestFailureException("Internal Server Error Occurred."); + } + + @Override public Optional<InlineResponse2001[]> getVnfPackages() { try { final ResponseEntity<VnfPkgInfo[]> response = diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java index d233c3f0fd..cc2c7a62a4 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java @@ -79,4 +79,16 @@ public class EtsiCatalogUrlProvider { return url; } + /** + * Get the URL for retrieving VNF Package Artifacts + * + * @param vnfPkgId The ID of the VNF Package + * @param artifactPath The path to the Artifact + * @return the URL for the GET operation + */ + public String getVnfPackageArtifactUrl(final String vnfPkgId, final String artifactPath) { + final String url = msbEndpoint + vnfpkgmServiceUrl + "/vnf_packages/" + vnfPkgId + "/artifacts/" + artifactPath; + logger.info("getVnfPackageArtifactUrl: {}", url); + return url; + } } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java index 76ec492bd4..3f975fbc9c 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java @@ -49,7 +49,7 @@ import org.springframework.web.bind.annotation.RequestMapping; public class Sol003PackageManagementController { private final EtsiCatalogServiceProvider etsiCatalogServiceProvider; - private static final String LOG_REQUEST_RECEIVED = "VNF PackageManagement Controller: {} {} {}"; + private static final String LOG_REQUEST_RECEIVED = "VNF PackageManagement Controller: {} {} {} {}"; private static final Logger logger = getLogger(Sol003PackageManagementController.class); @Autowired @@ -64,18 +64,18 @@ public class Sol003PackageManagementController { * @return An Array of all VNF packages. Object: InlineResponse2001[] Response Code: 200 OK */ @GetMapping(value = "/vnf_packages", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public ResponseEntity getVnfPackages() { + public ResponseEntity<?> getVnfPackages() { logger.info(LOG_REQUEST_RECEIVED, "getVnfPackages."); final Optional<InlineResponse2001[]> response = etsiCatalogServiceProvider.getVnfPackages(); if (response.isPresent()) { logger.info(LOG_REQUEST_RECEIVED, "getVnfPackages Response: ", HttpStatus.OK); - return new ResponseEntity(response.get(), HttpStatus.OK); + return ResponseEntity.ok().body(response.get()); } final String errorMessage = "An error occurred, a null response was received by the\n" + " Sol003PackageManagementController from the EtsiCatalogManager using the GET \"vnf_packages\" \n" + "endpoint."; logger.error(errorMessage); - return new ResponseEntity(buildProblemDetails(errorMessage), HttpStatus.INTERNAL_SERVER_ERROR); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(buildProblemDetails(errorMessage)); } /** @@ -86,18 +86,18 @@ public class Sol003PackageManagementController { * @return A VNF package based on vnfPkgId. Object: VnfPkgInfo Response Code: 200 OK */ @GetMapping(value = "/vnf_packages/{vnfPkgId}", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public ResponseEntity getVnfPackage(@PathVariable("vnfPkgId") final String vnfPkgId) { + public ResponseEntity<?> getVnfPackage(@PathVariable("vnfPkgId") final String vnfPkgId) { logger.info(LOG_REQUEST_RECEIVED, "getVnfPackage: ", vnfPkgId); final Optional<InlineResponse2001> response = etsiCatalogServiceProvider.getVnfPackage(vnfPkgId); if (response.isPresent()) { logger.info(LOG_REQUEST_RECEIVED, "getVnfPackage Response: ", HttpStatus.OK); - return new ResponseEntity(response.get(), HttpStatus.OK); + return ResponseEntity.ok().body(response.get()); } final String errorMessage = "An error occurred, a null response was received by the\n" + " Sol003PackageManagementController from the EtsiCatalogManager using the GET \"vnf_packages\" by vnfPkgId: \"" + vnfPkgId + "\" \n" + "endpoint."; logger.error(errorMessage); - return new ResponseEntity(buildProblemDetails(errorMessage), HttpStatus.INTERNAL_SERVER_ERROR); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(buildProblemDetails(errorMessage)); } /** @@ -109,7 +109,7 @@ public class Sol003PackageManagementController { */ @GetMapping(value = "/vnf_packages/{vnfPkgId}/vnfd", produces = {MediaType.TEXT_PLAIN, APPLICATION_ZIP, MediaType.APPLICATION_JSON}) - public ResponseEntity<byte[]> getVnfPackageVnfd(@PathVariable("vnfPkgId") final String vnfPkgId) { + public ResponseEntity<?> getVnfPackageVnfd(@PathVariable("vnfPkgId") final String vnfPkgId) { logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageVnfd: ", vnfPkgId); return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -123,17 +123,18 @@ public class Sol003PackageManagementController { */ @GetMapping(value = "/vnf_packages/{vnfPkgId}/package_content", produces = {MediaType.APPLICATION_JSON, APPLICATION_ZIP, MediaType.APPLICATION_OCTET_STREAM}) - public ResponseEntity getVnfPackageContent(@PathVariable("vnfPkgId") final String vnfPkgId) { + public ResponseEntity<?> getVnfPackageContent(@PathVariable("vnfPkgId") final String vnfPkgId) { logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageContent Endpoint Invoked with VNF Package ID: ", vnfPkgId); final Optional<byte[]> response = etsiCatalogServiceProvider.getVnfPackageContent(vnfPkgId); if (response.isPresent()) { logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageContent Response: ", HttpStatus.OK); - return new ResponseEntity(response.get(), HttpStatus.OK); + return ResponseEntity.ok().body(response.get()); } - logger.error("Null response was received from the EtsiCatalogManager using the GET \"package_content\""); - return new ResponseEntity(buildProblemDetails("An error occurred, a null response was received by the\n" + final String errorMessage = "An error occurred, a null response was received by the\n" + " Sol003PackageManagementController from the EtsiCatalogManager using the GET \"package_content\" \n" - + "endpoint."), HttpStatus.INTERNAL_SERVER_ERROR); + + "endpoint."; + logger.error(errorMessage); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(buildProblemDetails(errorMessage)); } /** @@ -146,10 +147,20 @@ public class Sol003PackageManagementController { */ @GetMapping(value = "/vnf_packages/{vnfPkgId}/artifacts/{artifactPath}", produces = {MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON}) - public ResponseEntity<byte[]> getVnfPackageArtifact(@PathVariable("vnfPkgId") final String vnfPkgId, + public ResponseEntity<?> getVnfPackageArtifact(@PathVariable("vnfPkgId") final String vnfPkgId, @PathVariable("artifactPath") final String artifactPath) { - logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageArtifact: vnfPkgId=", vnfPkgId, " artifactPath=", artifactPath); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageArtifact: vnfPkgId= ", vnfPkgId, " artifactPath=", + artifactPath); + final Optional<byte[]> response = etsiCatalogServiceProvider.getVnfPackageArtifact(vnfPkgId, artifactPath); + if (response.isPresent()) { + logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageArtifact Response: ", HttpStatus.OK); + return ResponseEntity.ok().body(response.get()); + } + final String errorMessage = "An error occurred, a null response was received by the\n" + + " Sol003PackageManagementController from the EtsiCatalogManager using the\n GET \"vnf_packages\" by vnfPkgId: \"" + + vnfPkgId + "\" for artifactPath: \"" + artifactPath + "\"\n" + "endpoint."; + logger.error(errorMessage); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(buildProblemDetails(errorMessage)); } /** diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Sol003PackageManagementControllerExceptionHandler.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java index 2a97bb47e4..a49063a72f 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Sol003PackageManagementControllerExceptionHandler.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter; +package org.onap.so.adapters.vnfmadapter.rest.exceptions; import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails; import org.onap.so.adapters.vnfmadapter.rest.Sol003PackageManagementController; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgConflictException.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgConflictException.java index 0cc9c5bd7e..f9aa2a0e21 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgConflictException.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgConflictException.java @@ -23,7 +23,7 @@ import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; /** - * Exception for a Vnfpkg Conflict failure, due to state of resource. + * Exception for a VnfPkg Conflict failures, due to state of resource. * * @author gareth.roper@est.tech */ diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgNotFoundException.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgNotFoundException.java index 0f9f214643..c15e7052ab 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgNotFoundException.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgNotFoundException.java @@ -23,7 +23,7 @@ import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; /** - * Exception for a Vnfpkg Not Found Failure + * Exception for VnfPkg Not Found Failures * * @author gareth.roper@est.tech */ diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java index 857bd7dc3e..dbc8ef251d 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java @@ -44,11 +44,7 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; +import org.springframework.http.*; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.client.MockRestServiceServer; @@ -207,6 +203,109 @@ public class Sol003PackageManagementControllerTest { } @Test + public void testGetPackageArtifact_ValidArray_Success() { + final byte[] responseArray = buildByteArrayWithRandomData(10); + + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) + .andExpect(method(HttpMethod.GET)) + .andRespond(withSuccess(responseArray, MediaType.APPLICATION_OCTET_STREAM)); + + final String testURL = "http://localhost:" + port + PACKAGE_MANAGEMENT_BASE_URL + "/vnf_packages/" + + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH; + final HttpEntity<?> request = new HttpEntity<>(basicHttpHeadersProvider.getHttpHeaders()); + final ResponseEntity<byte[]> responseEntity = + restTemplate.withBasicAuth("test", "test").exchange(testURL, HttpMethod.GET, request, byte[].class); + + assertEquals(byte[].class, responseEntity.getBody().getClass()); + assertArrayEquals(responseEntity.getBody(), responseArray); + assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); + } + + @Test + public void testOnGetPackageArtifact_Conflict_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.CONFLICT)); + + final ResponseEntity<ProblemDetails> responseEntity = + sendHttpRequest(VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH); + + assertNotNull(responseEntity.getBody()); + assertEquals(HttpStatus.CONFLICT, responseEntity.getStatusCode()); + } + + @Test + public void testOnGetPackageArtifact_NotFound_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.NOT_FOUND)); + + final ResponseEntity<ProblemDetails> responseEntity = + sendHttpRequest(VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH); + + assertNotNull(responseEntity.getBody()); + assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode()); + } + + @Test + public void testOnGetPackageArtifact_UnauthorizedClient_Fail() { + final String testURL = "http://localhost:" + port + PACKAGE_MANAGEMENT_BASE_URL + "/vnf_packages/" + + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH; + final HttpEntity<?> request = new HttpEntity<>(basicHttpHeadersProvider.getHttpHeaders()); + final ResponseEntity<ProblemDetails> responseEntity = + restTemplate.exchange(testURL, HttpMethod.GET, request, ProblemDetails.class); + + assertNotNull(responseEntity.getBody()); + assertEquals(HttpStatus.UNAUTHORIZED, responseEntity.getStatusCode()); + } + + @Test + public void testOnGetPackageArtifact_InternalServerError_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR)); + + final ResponseEntity<ProblemDetails> responseEntity = + sendHttpRequest(VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH); + + assertNotNull(responseEntity.getBody()); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); + } + + @Test + public void testOnGetPackageArtifact_BadRequest_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.BAD_REQUEST)); + + final ResponseEntity<ProblemDetails> responseEntity = + sendHttpRequest(VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH); + + assertNotNull(responseEntity.getBody()); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); + } + + @Test + public void testOnGetPackageArtifact_UnauthorizedServer_InternalError_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.UNAUTHORIZED)); + + final ResponseEntity<ProblemDetails> responseEntity = + sendHttpRequest(VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH); + + assertNotNull(responseEntity.getBody()); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); + } + + @Test + public void testGetPackageArtifact_SuccessResponseFromServerWithNullPackage_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) + .andExpect(method(HttpMethod.GET)).andRespond(withSuccess()); + + final ResponseEntity<ProblemDetails> responseEntity = + sendHttpRequest(VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH); + + assertNotNull(responseEntity.getBody()); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); + } + + @Test public void testVnfPackagesReceivedAsInlineResponse2001ListIfGetVnfPackagesSuccessful() { final VnfPkgInfo[] responses = createVnfPkgArray(); @@ -369,20 +468,13 @@ public class Sol003PackageManagementControllerTest { + VNF_PACKAGE_ID + "\" \n" + "endpoint.", problemDetails.getDetail()); } - // The below 2 test methods are here to improve code coverage and provide a foundation for writing future tests + // The below test method is here to improve code coverage and provide a foundation for writing future tests @Test public void testGetVnfd_Not_Implemented() { final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/vnfd"); assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); } - @Test - public void testGetArtifact_Not_Implemented() { - final ResponseEntity<ProblemDetails> responseEntity = - sendHttpRequest(VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH); - assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); - } - // Simply returns a byte array filled with random data, for use in the tests. private byte[] buildByteArrayWithRandomData(final int sizeInKb) { final Random rnd = new Random(); diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/Client/InfraActiveRequestExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/Client/InfraActiveRequestExpected.json index 361dd9f405..45812c1c45 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/Client/InfraActiveRequestExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/Client/InfraActiveRequestExpected.json @@ -22,7 +22,7 @@ "vfModuleId": "c7d527b1-7a91-49fd-b97d-1c8c0f4a7992", "vfModuleName": null, "vfModuleModelName": "vSAMP10aDEV::base::module-0", - "aicCloudRegion": "mtn6", + "cloudRegion": "mtn6", "callBackUrl": null, "correlator": null, "serviceInstanceId": "e3b5744d-2ad1-4cdd-8390-c999a38829bc", diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/InfraActiveRequestExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/InfraActiveRequestExpected.json index 9c962e9722..b70fd4c42a 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/InfraActiveRequestExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/InfraActiveRequestExpected.json @@ -22,7 +22,7 @@ "vfModuleId": "c7d527b1-7a91-49fd-b97d-1c8c0f4a7992", "vfModuleName": null, "vfModuleModelName": "vSAMP10aDEV::base::module-0", - "aicCloudRegion": "mtn6", + "cloudRegion": "mtn6", "callBackUrl": null, "correlator": null, "serviceInstanceId": "e3b5744d-2ad1-4cdd-8390-c999a38829bc", diff --git a/bpmn/MSOCommonBPMN/src/test/resources/response/infraActiveRequestsResponse.json b/bpmn/MSOCommonBPMN/src/test/resources/response/infraActiveRequestsResponse.json index 3623e888e7..45812c1c45 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/response/infraActiveRequestsResponse.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/response/infraActiveRequestsResponse.json @@ -22,7 +22,7 @@ "vfModuleId": "c7d527b1-7a91-49fd-b97d-1c8c0f4a7992", "vfModuleName": null, "vfModuleModelName": "vSAMP10aDEV::base::module-0", - "aicCloudRegion": "mtn6", + "cloudRegion": "mtn6", "callBackUrl": null, "correlator": null, "serviceInstanceId": "e3b5744d-2ad1-4cdd-8390-c999a38829bc", @@ -37,4 +37,4 @@ "configurationName": null, "operationalEnvId": null, "operationalEnvName": null -}
\ No newline at end of file +} diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequest.java b/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequest.java index 1a0e13587e..5bcdcb181b 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequest.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequest.java @@ -32,6 +32,8 @@ public class ServiceInstancesRequest implements Serializable { private String serviceInstanceId; @JsonProperty("vnfInstanceId") private String vnfInstanceId; + @JsonProperty("pnfId") + private String pnfId; @JsonProperty("networkInstanceId") private String networkInstanceId; @JsonProperty("volumeGroupInstanceId") @@ -67,6 +69,14 @@ public class ServiceInstancesRequest implements Serializable { this.vnfInstanceId = vnfInstanceId; } + public String getPnfId() { + return pnfId; + } + + public void setPnfId(String pnfId) { + this.pnfId = pnfId; + } + public String getNetworkInstanceId() { return networkInstanceId; } @@ -113,6 +123,7 @@ public class ServiceInstancesRequest implements Serializable { sb.append("requestDetails=").append(requestDetails); sb.append(", serviceInstanceId='").append(serviceInstanceId).append('\''); sb.append(", vnfInstanceId='").append(vnfInstanceId).append('\''); + sb.append(", pnfId='").append(pnfId).append('\''); sb.append(", networkInstanceId='").append(networkInstanceId).append('\''); sb.append(", volumeGroupInstanceId='").append(volumeGroupInstanceId).append('\''); sb.append(", vfModuleInstanceId='").append(vfModuleInstanceId).append('\''); diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java index 0653513184..6869a3a213 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java @@ -47,5 +47,6 @@ public enum Action implements Actions { scaleOut, recreateInstance, addMembers, - removeMembers + removeMembers, + forCustomWorkflow } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java index d0302f2e59..88c4bc3b04 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java @@ -45,5 +45,6 @@ public enum Action implements Actions { scaleOut, recreateInstance, addMembers, - removeMembers + removeMembers, + forCustomWorkflow } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java index d3bd769386..dbdc274bc6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java @@ -96,7 +96,7 @@ public class InstanceManagement { @Operation(description = "Execute custom workflow", responses = @ApiResponse( content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) @Transactional - public Response executeCustomWorkflow(String request, @PathParam("version") String version, + public Response executeVNFCustomWorkflow(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, @PathParam("workflowUuid") String workflowUuid, @Context ContainerRequestContext requestContext) throws ApiException { @@ -109,6 +109,26 @@ public class InstanceManagement { requestContext); } + @POST + @Path("/{version:[vV][1]}/serviceInstances/{serviceInstanceId}/pnfs/{pnfId}/workflows/{workflowUuid}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Operation(description = "Execute custom workflow", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + @Transactional + public Response executePNFCustomWorkflow(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("pnfId") String pnfId, + @PathParam("workflowUuid") String workflowUuid, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("pnfId", pnfId); + instanceIdMap.put("workflowUuid", workflowUuid); + return processPNFCustomWorkflowRequest(request, Action.forCustomWorkflow, instanceIdMap, version, requestId, + requestContext); + } + private Response processCustomWorkflowRequest(String requestJSON, Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, ContainerRequestContext requestContext) throws ApiException { @@ -217,6 +237,93 @@ public class InstanceManagement { recipeLookupResult.getOrchestrationURI(), requestScope); } + private Response processPNFCustomWorkflowRequest(String requestJSON, Actions action, + HashMap<String, String> instanceIdMap, String version, String requestId, + ContainerRequestContext requestContext) throws ApiException { + Boolean aLaCarte = false; + ServiceInstancesRequest sir; + String apiVersion = version.substring(1); + + String serviceInstanceId = ""; + String pnfId = ""; + String workflowUuid = ""; + if (instanceIdMap != null) { + serviceInstanceId = instanceIdMap.get("serviceInstanceId"); + pnfId = instanceIdMap.get("pnfId"); + workflowUuid = instanceIdMap.get("workflowUuid"); + } + + String requestUri = requestHandlerUtils.getRequestUri(requestContext, uriPrefix); + sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri); + sir.setServiceInstanceId(serviceInstanceId); + sir.setPnfId(pnfId); + String requestScope = ModelType.pnf.name(); + InfraActiveRequests currentActiveReq = + msoRequest.createRequestObject(sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope); + + try { + requestHandlerUtils.validateHeaders(requestContext); + } catch (ValidationException e) { + logger.error("Exception occurred", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + ValidateException validateException = + new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); + requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); + throw validateException; + } + + requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, + currentActiveReq); + requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap); + + InfraActiveRequests dup = null; + boolean inProgress = false; + + dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, null, requestScope, currentActiveReq); + + if (dup != null) { + inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq); + } + + if (dup != null && inProgress) { + requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, null, requestScope, + dup); + } + + RecipeLookupResult recipeLookupResult = getInstanceManagementWorkflowRecipe(currentActiveReq, workflowUuid); + + try { + infraActiveRequestsClient.save(currentActiveReq); + } catch (Exception e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build(); + } + + RequestClientParameter requestClientParameter = null; + try { + requestClientParameter = new RequestClientParameter.Builder().setRequestId(requestId) + .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.toString()) + .setServiceInstanceId(serviceInstanceId).setPnfCorrelationId(pnfId) + .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, null, aLaCarte, action)) + .setApiVersion(apiVersion).setRequestUri(requestUri).build(); + } catch (IOException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo) + .build(); + } + return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, + recipeLookupResult.getOrchestrationURI(), requestScope); + } + private RecipeLookupResult getInstanceManagementWorkflowRecipe(InfraActiveRequests currentActiveReq, String workflowUuid) throws ApiException { RecipeLookupResult recipeLookupResult = null; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java index 2307a18c1a..e3e840bbcd 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java @@ -301,7 +301,7 @@ public class MsoRequest { if (servInsReq.getRequestDetails().getCloudConfiguration() != null) { CloudConfiguration cloudConfiguration = servInsReq.getRequestDetails().getCloudConfiguration(); if (cloudConfiguration.getLcpCloudRegionId() != null) { - aq.setAicCloudRegion(cloudConfiguration.getLcpCloudRegionId()); + aq.setCloudRegion(cloudConfiguration.getLcpCloudRegionId()); } if (cloudConfiguration.getTenantId() != null) { @@ -318,9 +318,16 @@ public class MsoRequest { aq.setVnfId(servInsReq.getVnfInstanceId()); } + if (servInsReq.getPnfId() != null) { + aq.setRequestScope(requestScope); + aq.setPnfId(servInsReq.getPnfId()); + } + if (ModelType.service.name().equalsIgnoreCase(requestScope)) { - if (servInsReq.getRequestDetails().getRequestInfo().getInstanceName() != null) { - aq.setServiceInstanceName(requestInfo.getInstanceName()); + if (servInsReq.getRequestDetails().getRequestInfo() != null) { + if (servInsReq.getRequestDetails().getRequestInfo().getInstanceName() != null) { + aq.setServiceInstanceName(requestInfo.getInstanceName()); + } } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java index b078aed6ac..0c6ad0ba22 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java @@ -275,12 +275,18 @@ public class RequestHandlerUtils extends AbstractRestHandler { } else if (action == Action.addMembers || action == Action.removeMembers) { return (ModelType.instanceGroup.toString()); } else { - String requestScope; + String requestScope = requestScopeFromUri(requestUri);; + + if (sir.getRequestDetails() == null) { + return requestScope; + } + if (sir.getRequestDetails().getModelInfo() == null) { + return requestScope; + } if (sir.getRequestDetails().getModelInfo().getModelType() == null) { - requestScope = requestScopeFromUri(requestUri); - } else { - requestScope = sir.getRequestDetails().getModelInfo().getModelType().name(); + return requestScope; } + requestScope = sir.getRequestDetails().getModelInfo().getModelType().name(); return requestScope; } } @@ -505,6 +511,9 @@ public class RequestHandlerUtils extends AbstractRestHandler { if (instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID) != null) { currentActiveReq.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID)); } + if (instanceIdMap.get("PnfId") != null) { + currentActiveReq.setPnfId(instanceIdMap.get("PnfId")); + } } } @@ -610,6 +619,8 @@ public class RequestHandlerUtils extends AbstractRestHandler { requestScope = ModelType.configuration.name(); } else if (requestUri.contains(ModelType.vnf.name())) { requestScope = ModelType.vnf.name(); + } else if (requestUri.contains(ModelType.pnf.name())) { + requestScope = ModelType.pnf.name(); } else { requestScope = ModelType.service.name(); } @@ -632,7 +643,7 @@ public class RequestHandlerUtils extends AbstractRestHandler { if (infraActiveRequest != null) { request.setTenantId(infraActiveRequest.getTenantId()); request.setRequestBody(updateRequestorIdInRequestBody(infraActiveRequest, requestorId)); - request.setAicCloudRegion(infraActiveRequest.getAicCloudRegion()); + request.setCloudRegion(infraActiveRequest.getCloudRegion()); request.setRequestScope(infraActiveRequest.getRequestScope()); request.setRequestAction(infraActiveRequest.getRequestAction()); setInstanceIdAndName(infraActiveRequest, request); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index a1779ba0fd..175b212c86 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -1176,7 +1176,7 @@ public class ServiceInstances extends AbstractRestHandler { protected void setCloudConfigurationCurrentActiveRequest(CloudConfiguration cloudConfiguration, InfraActiveRequests currentActiveRequest) { if (cloudConfiguration.getLcpCloudRegionId() != null) { - currentActiveRequest.setAicCloudRegion(cloudConfiguration.getLcpCloudRegionId()); + currentActiveRequest.setCloudRegion(cloudConfiguration.getLcpCloudRegionId()); } if (cloudConfiguration.getTenantId() != null) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java index 01e3de99ec..c05ef98fbb 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java @@ -35,13 +35,13 @@ public class CustomWorkflowValidation implements ValidationRule { CloudConfiguration cloudConfiguration = info.getSir().getRequestDetails().getCloudConfiguration(); if (cloudConfiguration == null) { - throw new ValidationException("cloudConfiguration"); + // throw new ValidationException("cloudConfiguration"); } else if (Strings.isNullOrEmpty((cloudConfiguration.getCloudOwner()))) { - throw new ValidationException("cloudOwner"); + // throw new ValidationException("cloudOwner"); } else if (Strings.isNullOrEmpty((cloudConfiguration.getLcpCloudRegionId()))) { - throw new ValidationException("lcpCloudRegionId"); + // throw new ValidationException("lcpCloudRegionId"); } else if (Strings.isNullOrEmpty((cloudConfiguration.getTenantId()))) { - throw new ValidationException("tenantId"); + // throw new ValidationException("tenantId"); } if (requestParameters == null) { throw new ValidationException("requestParameters"); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java index 0ce8113dcb..979aa8fbb1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java @@ -62,7 +62,7 @@ public class E2EServiceInstancesTest extends BaseTest { wireMockServer.stubFor(post(urlPathEqualTo("/testOrchestrationUri")).willReturn(aResponse() .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK))); wireMockServer.stubFor(post(urlPathEqualTo("/infraActiveRequests/")).withRequestBody(equalToJson( - "{\"requestStatus\":\"FAILED\",\"statusMessage\":\"Error parsing request: No valid requestorId is specified\",\"progress\":100,\"startTime\":1533541051247,\"endTime\":1533541051247,\"source\":null,\"vnfId\":null,\"vnfName\":null,\"vnfType\":null,\"serviceType\":null,\"tenantId\":null,\"vnfParams\":null,\"vnfOutputs\":null,\"requestBody\":\"{\\r\\n \\\"service\\\":{\\r\\n \\\"name\\\":\\\"so_test4\\\",\\r\\n \\\"description\\\":\\\"so_test2\\\",\\r\\n \\\"serviceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561519\\\",\\r\\n \\\"serviceUuid\\\":\\\"592f9437-a9c0-4303-b9f6-c445bb7e9814\\\",\\r\\n \\\"globalSubscriberId\\\":\\\"123457\\\",\\r\\n \\\"serviceType\\\":\\\"voLTE\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"resources\\\":[\\r\\n {\\r\\n \\\"resourceName\\\":\\\"vIMS\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561516\\\",\\r\\n \\\"resourceUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561512\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n {\\r\\n \\\"vnfProfileId\\\":\\\"zte-vBAS-1.0\\\",\\r\\n \\\"locationConstraints\\\":{\\r\\n \\\"vimId\\\":\\\"4050083f-465f-4838-af1e-47a545222ad0\\\"\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"vnfProfileId\\\":\\\"zte-vMME-1.0\\\",\\r\\n \\\"locationConstraints\\\":{\\r\\n \\\"vimId\\\":\\\"4050083f-465f-4838-af1e-47a545222ad0\\\"\\r\\n }\\r\\n }\\r\\n ]\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"resourceName\\\":\\\"vEPC\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"61c3e96e-0970-4871-b6e0-3b6de7561516\\\",\\r\\n \\\"resourceUuid\\\":\\\"62c3e96e-0970-4871-b6e0-3b6de7561512\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n {\\r\\n \\\"vnfProfileId\\\":\\\"zte-CSCF-1.0\\\",\\r\\n \\\"locationConstraints\\\":{\\r\\n \\\"vimId\\\":\\\"4050083f-465f-4838-af1e-47a545222ad1\\\"\\r\\n }\\r\\n }\\r\\n ]\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"resourceName\\\":\\\"underlayvpn\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561513\\\",\\r\\n \\\"resourceUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561514\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n\\r\\n ]\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"resourceName\\\":\\\"overlayvpn\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561517\\\",\\r\\n \\\"resourceUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561518\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n\\r\\n ]\\r\\n }\\r\\n }\\r\\n ],\\r\\n \\\"requestInputs\\\":{\\r\\n \\\"externalDataNetworkName\\\":\\\"Flow_out_net\\\",\\r\\n \\\"m6000_mng_ip\\\":\\\"181.18.20.2\\\",\\r\\n \\\"externalCompanyFtpDataNetworkName\\\":\\\"Flow_out_net\\\",\\r\\n \\\"externalPluginManageNetworkName\\\":\\\"plugin_net_2014\\\",\\r\\n \\\"externalManageNetworkName\\\":\\\"mng_net_2017\\\",\\r\\n \\\"sfc_data_network\\\":\\\"sfc_data_net_2016\\\",\\r\\n \\\"NatIpRange\\\":\\\"210.1.1.10-210.1.1.20\\\",\\r\\n \\\"location\\\":\\\"4050083f-465f-4838-af1e-47a545222ad0\\\",\\r\\n \\\"sdncontroller\\\":\\\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\\\"\\r\\n }\\r\\n }\\r\\n\\r\\n }\\r\\n\\r\\n}\",\"responseBody\":null,\"lastModifiedBy\":\"APIH\",\"modifyTime\":null,\"volumeGroupId\":null,\"volumeGroupName\":null,\"vfModuleId\":null,\"vfModuleName\":null,\"vfModuleModelName\":null,\"aicCloudRegion\":null,\"callBackUrl\":null,\"correlator\":null,\"serviceInstanceId\":null,\"serviceInstanceName\":null,\"requestScope\":\"service\",\"requestAction\":\"createInstance\",\"networkId\":null,\"networkName\":null,\"networkType\":null,\"requestorId\":null,\"configurationId\":null,\"configurationName\":null,\"operationalEnvId\":null,\"operationalEnvName\":null,\"requestURI\":\"d167c9d0-1785-4e93-b319-996ebbcc3272\"}")) + "{\"requestStatus\":\"FAILED\",\"statusMessage\":\"Error parsing request: No valid requestorId is specified\",\"progress\":100,\"startTime\":1533541051247,\"endTime\":1533541051247,\"source\":null,\"vnfId\":null,\"vnfName\":null,\"vnfType\":null,\"serviceType\":null,\"tenantId\":null,\"vnfParams\":null,\"vnfOutputs\":null,\"requestBody\":\"{\\r\\n \\\"service\\\":{\\r\\n \\\"name\\\":\\\"so_test4\\\",\\r\\n \\\"description\\\":\\\"so_test2\\\",\\r\\n \\\"serviceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561519\\\",\\r\\n \\\"serviceUuid\\\":\\\"592f9437-a9c0-4303-b9f6-c445bb7e9814\\\",\\r\\n \\\"globalSubscriberId\\\":\\\"123457\\\",\\r\\n \\\"serviceType\\\":\\\"voLTE\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"resources\\\":[\\r\\n {\\r\\n \\\"resourceName\\\":\\\"vIMS\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561516\\\",\\r\\n \\\"resourceUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561512\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n {\\r\\n \\\"vnfProfileId\\\":\\\"zte-vBAS-1.0\\\",\\r\\n \\\"locationConstraints\\\":{\\r\\n \\\"vimId\\\":\\\"4050083f-465f-4838-af1e-47a545222ad0\\\"\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"vnfProfileId\\\":\\\"zte-vMME-1.0\\\",\\r\\n \\\"locationConstraints\\\":{\\r\\n \\\"vimId\\\":\\\"4050083f-465f-4838-af1e-47a545222ad0\\\"\\r\\n }\\r\\n }\\r\\n ]\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"resourceName\\\":\\\"vEPC\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"61c3e96e-0970-4871-b6e0-3b6de7561516\\\",\\r\\n \\\"resourceUuid\\\":\\\"62c3e96e-0970-4871-b6e0-3b6de7561512\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n {\\r\\n \\\"vnfProfileId\\\":\\\"zte-CSCF-1.0\\\",\\r\\n \\\"locationConstraints\\\":{\\r\\n \\\"vimId\\\":\\\"4050083f-465f-4838-af1e-47a545222ad1\\\"\\r\\n }\\r\\n }\\r\\n ]\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"resourceName\\\":\\\"underlayvpn\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561513\\\",\\r\\n \\\"resourceUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561514\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n\\r\\n ]\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"resourceName\\\":\\\"overlayvpn\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561517\\\",\\r\\n \\\"resourceUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561518\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n\\r\\n ]\\r\\n }\\r\\n }\\r\\n ],\\r\\n \\\"requestInputs\\\":{\\r\\n \\\"externalDataNetworkName\\\":\\\"Flow_out_net\\\",\\r\\n \\\"m6000_mng_ip\\\":\\\"181.18.20.2\\\",\\r\\n \\\"externalCompanyFtpDataNetworkName\\\":\\\"Flow_out_net\\\",\\r\\n \\\"externalPluginManageNetworkName\\\":\\\"plugin_net_2014\\\",\\r\\n \\\"externalManageNetworkName\\\":\\\"mng_net_2017\\\",\\r\\n \\\"sfc_data_network\\\":\\\"sfc_data_net_2016\\\",\\r\\n \\\"NatIpRange\\\":\\\"210.1.1.10-210.1.1.20\\\",\\r\\n \\\"location\\\":\\\"4050083f-465f-4838-af1e-47a545222ad0\\\",\\r\\n \\\"sdncontroller\\\":\\\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\\\"\\r\\n }\\r\\n }\\r\\n\\r\\n }\\r\\n\\r\\n}\",\"responseBody\":null,\"lastModifiedBy\":\"APIH\",\"modifyTime\":null,\"volumeGroupId\":null,\"volumeGroupName\":null,\"vfModuleId\":null,\"vfModuleName\":null,\"vfModuleModelName\":null,\"cloudRegion\":null,\"callBackUrl\":null,\"correlator\":null,\"serviceInstanceId\":null,\"serviceInstanceName\":null,\"requestScope\":\"service\",\"requestAction\":\"createInstance\",\"networkId\":null,\"networkName\":null,\"networkType\":null,\"requestorId\":null,\"configurationId\":null,\"configurationName\":null,\"operationalEnvId\":null,\"operationalEnvName\":null,\"requestURI\":\"d167c9d0-1785-4e93-b319-996ebbcc3272\"}")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withStatus(HttpStatus.SC_OK))); Service defaultService = new Service(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java index 30c1f2a5ce..5c78af3601 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/InstanceManagementTest.java @@ -172,4 +172,32 @@ public class InstanceManagementTest extends BaseTest { ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); } + + @Test + public void executePNFCustomWorkflow() throws IOException { + wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/testingPNFWorkflow")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlMatching( + ".*/workflow/search/findByArtifactUUID[?]artifactUUID=81526781-e55c-4cb7-adb3-97e09d9c76bf")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("workflow_pnf_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + // expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + requestReferences.setRequestSelfLink(createExpectedSelfLink("v1", "32807a28-1a14-4b88-b7b3-2950918aa76d")); + expectedResponse.setRequestReferences(requestReferences); + uri = instanceManagementUri + "v1" + + "/serviceInstances/5df8b6de-2083-11e7-93ae-92361f002676/pnfs/testpnfcId/workflows/81526781-e55c-4cb7-adb3-97e09d9c76bf"; + ResponseEntity<String> response = + sendRequest(inputStream("/ExecutePNFCustomWorkflow.json"), uri, HttpMethod.POST, headers); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java index d0b16cffe6..557771d298 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java @@ -104,7 +104,7 @@ public class RequestHandlerUtilsUnitTest { private void setInfraActiveRequest() throws IOException { infraActiveRequest.setTenantId("tenant-id"); infraActiveRequest.setRequestBody(getRequestBody("/RequestBody.json")); - infraActiveRequest.setAicCloudRegion("cloudRegion"); + infraActiveRequest.setCloudRegion("cloudRegion"); infraActiveRequest.setRequestScope("service"); infraActiveRequest.setServiceInstanceId(SERVICE_INSTANCE_ID); infraActiveRequest.setServiceInstanceName(SERVICE_INSTANCE_NAME); @@ -119,7 +119,7 @@ public class RequestHandlerUtilsUnitTest { currentActiveRequest.setStartTime(startTimeStamp); currentActiveRequest.setTenantId("tenant-id"); currentActiveRequest.setRequestBody(getRequestBody("/RequestBodyNewRequestorId.json")); - currentActiveRequest.setAicCloudRegion("cloudRegion"); + currentActiveRequest.setCloudRegion("cloudRegion"); currentActiveRequest.setRequestScope("service"); currentActiveRequest.setRequestStatus(Status.IN_PROGRESS.toString()); currentActiveRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); @@ -446,7 +446,7 @@ public class RequestHandlerUtilsUnitTest { @Test public void checkForDuplicateRequestsTest() throws ApiException { InfraActiveRequests currentActiveReq = new InfraActiveRequests(); - currentActiveReq.setAicCloudRegion("testRegion"); + currentActiveReq.setCloudRegion("testRegion"); currentActiveReq.setRequestId("792a3158-d9a3-49fd-b3ac-ab09842d6a1a"); Action action = Action.createInstance; String requestScope = ModelType.service.toString(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java index 7f5f0dc931..7191e297ec 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java @@ -149,7 +149,7 @@ public class ResumeOrchestrationRequestTest { private void setInfraActiveRequest() throws IOException { infraActiveRequest.setTenantId("tenant-id"); infraActiveRequest.setRequestBody(getRequestBody("/RequestBody.json")); - infraActiveRequest.setAicCloudRegion("cloudRegion"); + infraActiveRequest.setCloudRegion("cloudRegion"); infraActiveRequest.setRequestScope(SERVICE); infraActiveRequest.setServiceInstanceId(SERVICE_INSTANCE_ID); infraActiveRequest.setServiceInstanceName(SERVICE_INSTANCE_NAME); @@ -173,7 +173,7 @@ public class ResumeOrchestrationRequestTest { currentActiveRequest.setStartTime(startTimeStamp); currentActiveRequest.setTenantId("tenant-id"); currentActiveRequest.setRequestBody(getRequestBody("/RequestBody.json")); - currentActiveRequest.setAicCloudRegion("cloudRegion"); + currentActiveRequest.setCloudRegion("cloudRegion"); currentActiveRequest.setRequestScope(SERVICE); currentActiveRequest.setServiceInstanceId(SERVICE_INSTANCE_ID); currentActiveRequest.setServiceInstanceName(SERVICE_INSTANCE_NAME); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesUnitTest.java index 5c3ac0f461..d399de0b7a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesUnitTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesUnitTest.java @@ -95,6 +95,6 @@ public class ServiceInstancesUnitTest { serviceInstances.setCloudConfigurationCurrentActiveRequest(cloudConfiguration, currentActiveRequest); assertEquals("tenantId", currentActiveRequest.getTenantId()); - assertEquals("lcpCloudRegionId", currentActiveRequest.getAicCloudRegion()); + assertEquals("lcpCloudRegionId", currentActiveRequest.getCloudRegion()); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecutePNFCustomWorkflow.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecutePNFCustomWorkflow.json new file mode 100644 index 0000000000..63021b611f --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ExecutePNFCustomWorkflow.json @@ -0,0 +1,20 @@ +{ + "requestDetails": { + "requestParameters": { + "userParams": [{ + "nrmObj": { + "EUtranGenericCell" : [ + {"cellLocalId":1, "pci":5}, + {"cellLocalId":2, "pci":6} + ], + "ExternalEUtranCell" : [ + {"cellLocalId":3, "eNBId": "x"}, + {"cellLocalId":4, "eNBId": "y"} + ], + "EUtranRelation": [{"scellLocalId":5, "tcellLocalId":6}] + } + }], + "payload": "[{\"GNBDUFunction\":{\"gNBId\":1,\"gNBDUId\":5}}]" + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/InfraActiveRequests/createInfraActiveRequests.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/InfraActiveRequests/createInfraActiveRequests.json index 81b574285c..c79900a15d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/InfraActiveRequests/createInfraActiveRequests.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/InfraActiveRequests/createInfraActiveRequests.json @@ -22,7 +22,7 @@ "vfModuleId":null, "vfModuleName":null, "vfModuleModelName":null, - "aicCloudRegion":"n6", + "cloudRegion":"n6", "callBackUrl":null, "correlator":null, "serviceInstanceId":"9e15a443-af65-4f05-9000-47ae495e937d", @@ -41,4 +41,4 @@ }, "requestURI":"http://localhost:8087/infraActiveRequests/%1$s" -}
\ No newline at end of file +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/InfraActiveRequests/getInfraActiveRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/InfraActiveRequests/getInfraActiveRequest.json index 8d52acbe0d..db33df4d76 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/InfraActiveRequests/getInfraActiveRequest.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/InfraActiveRequests/getInfraActiveRequest.json @@ -21,7 +21,7 @@ "vfModuleId": null, "vfModuleName": null, "vfModuleModelName": null, - "aicCloudRegion": "n6", + "cloudRegion": "n6", "callBackUrl": null, "correlator": null, "serviceInstanceId": "9e15a443-af65-4f05-9000-47ae495e937d", @@ -45,4 +45,4 @@ "href": "http://localhost:8087/infraActiveRequests/%1$s" } } -}
\ No newline at end of file +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/InfraActiveRequests/getInfraActiveRequestNoBody.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/InfraActiveRequests/getInfraActiveRequestNoBody.json index 539851ce57..f36ae0f9da 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/InfraActiveRequests/getInfraActiveRequestNoBody.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/InfraActiveRequests/getInfraActiveRequestNoBody.json @@ -22,7 +22,7 @@ "vfModuleId": null, "vfModuleName": null, "vfModuleModelName": null, - "aicCloudRegion": "n6", + "cloudRegion": "n6", "callBackUrl": null, "correlator": null, "serviceInstanceId": "9e15a443-af65-4f05-9000-47ae495e937d", @@ -46,4 +46,4 @@ "href": "http://localhost:8087/infraActiveRequests/%1$s" } } -}
\ No newline at end of file +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_pnf_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_pnf_Response.json new file mode 100644 index 0000000000..133d8bed9b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_pnf_Response.json @@ -0,0 +1,5 @@ +{ + "artifactUUID": "81526781-e55c-4cb7-adb3-97e09d9c76bf", + "artifactName": "testingPNFWorkflow.bpmn", + "name": "testingPNFWorkflow" +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VnfLookup.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VnfLookup.json index a0a4c14c10..eef0776f5d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VnfLookup.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/infra/VnfLookup.json @@ -16,7 +16,7 @@ "requestBody":"{\"requestDetails\": {\"relatedInstanceList\": [{\"relatedInstance\": {\"instanceId\": \"f5435110-b276-4920-9261-a18a5582d357\", \"modelInfo\": {\"modelVersionId\": \"bad955c3-29b2-4a27-932e-28e942cc6480\", \"modelVersion\": \"1\", \"modelName\": \"Vf zrdm5bpxmc02092017-Service\", \"modelInvariantId\": \"b16a9398-ffa3-4041-b78c-2956b8ad9c7b\", \"modelType\": \"service\"}}}], \"requestParameters\": {\"userParams\": [], \"enforceValidNfValues\": false, \"testApi\": \"GR_API\"}, \"lineOfBusiness\": {\"lineOfBusinessName\": \"vSAMP12_14-2XXX-Aug18-9001 - LOB\"}, \"requestInfo\": {\"source\": \"VID\", \"requestorId\": \"az2016\", \"instanceName\": \"Robot_VNF_For_Volume_Group\", \"suppressRollback\": false, \"productFamilyId\": \"06f76284-8710-11e6-ae22-56b6b6499611\"}, \"platform\": {\"platformName\": \"vSAMP12_14-2XXX-Aug18-9001 - Platform\"}, \"modelInfo\": {\"modelName\": \"Vf zrdm5bpxmc02092017-VF\", \"modelVersion\": \"1\", \"modelInvariantId\": \"23122c9b-dd7f-483f-bf0a-e069303db2f7\", \"modelType\": \"vnf\", \"modelCustomizationName\": \"Vf zrdm5bpxmc02092017-VF 0\", \"modelVersionId\": \"d326f424-2312-4dd6-b7fe-364fadbd1ef5\", \"modelCustomizationId\": \"96c23a4a-6887-4b2c-9cce-1e4ea35eaade\"}, \"cloudConfiguration\": {\"cloudOwner\": \"cloudOwner\", \"tenantId\": \"0422ffb57ba042c0800a29dc85ca70f8\", \"lcpCloudRegionId\": \"regionOne\"}}}", "lastModifiedBy":"CamundaBPMN", "modifyTime":"2019-11-11T19:29:15.000+0000", - "aicCloudRegion":"regionOne", + "cloudRegion":"regionOne", "serviceInstanceId":"f5435110-b276-4920-9261-a18a5582d357", "requestScope":"vnf", "requestAction":"createInstance", diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql index 55db69b9d2..050780c9a2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql @@ -1262,6 +1262,7 @@ CREATE TABLE `infra_active_requests` ( `END_TIME` datetime DEFAULT NULL, `SOURCE` varchar(45) DEFAULT NULL, `VNF_ID` varchar(45) DEFAULT NULL, + `PNF_ID` varchar(45) DEFAULT NULL, `VNF_NAME` varchar(80) DEFAULT NULL, `VNF_TYPE` varchar(200) DEFAULT NULL, `SERVICE_TYPE` varchar(45) DEFAULT NULL, diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java index 445fd6355f..bba0ad4696 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java +++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/InfraActiveRequestsRepositoryImpl.java @@ -245,6 +245,8 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep mapKey = "serviceInstanceName"; } else if ("vnfInstanceId".equalsIgnoreCase(mapKey)) { mapKey = "vnfId"; + } else if ("pnfId".equalsIgnoreCase(mapKey)) { + mapKey = "pnfId"; } else if ("vnfInstanceName".equalsIgnoreCase(mapKey)) { mapKey = "vnfName"; } else if ("vfModuleInstanceId".equalsIgnoreCase(mapKey)) { @@ -264,7 +266,7 @@ public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRep } else if (mapKey.equalsIgnoreCase("configurationInstanceName")) { mapKey = "configurationName"; } else if ("lcpCloudRegionId".equalsIgnoreCase(mapKey)) { - mapKey = "aicCloudRegion"; + mapKey = "cloudRegion"; } else if ("tenantId".equalsIgnoreCase(mapKey)) { mapKey = "tenantId"; } else if ("modelType".equalsIgnoreCase(mapKey)) { diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql index feda0338a6..d2b3a71cad 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql +++ b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql @@ -64,6 +64,7 @@ CREATE TABLE IF NOT EXISTS PUBLIC.INFRA_ACTIVE_REQUESTS( END_TIME VARCHAR, SOURCE VARCHAR SELECTIVITY 2, VNF_ID VARCHAR SELECTIVITY 15, + PNF_ID VARCHAR SELECTIVITY 15, VNF_NAME VARCHAR SELECTIVITY 11, VNF_TYPE VARCHAR SELECTIVITY 5, SERVICE_TYPE VARCHAR SELECTIVITY 1, diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ArchivedInfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ArchivedInfraRequests.java index 2d44eebacd..8c4d0718b1 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ArchivedInfraRequests.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/ArchivedInfraRequests.java @@ -70,7 +70,7 @@ public class ArchivedInfraRequests extends InfraRequests { .append("lastModifiedBy", getLastModifiedBy()).append("modifyTime", getModifyTime()) .append("volumeGroupId", getVolumeGroupId()).append("volumeGroupName", getVolumeGroupName()) .append("vfModuleId", getVfModuleId()).append("vfModuleName", getVfModuleName()) - .append("vfModuleModelName", getVfModuleModelName()).append("aicCloudRegion", getAicCloudRegion()) + .append("vfModuleModelName", getVfModuleModelName()).append("cloudRegion", getCloudRegion()) .append("callBackUrl", getCallBackUrl()).append("correlator", getCorrelator()) .append("serviceInstanceId", getServiceInstanceId()) .append("serviceInstanceName", getServiceInstanceName()).append("requestScope", getRequestScope()) diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java index 9d76e289ab..5848f3b3d9 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java @@ -72,13 +72,13 @@ public class InfraActiveRequests extends InfraRequests { .append("statusMessage", getStatusMessage()).append("progress", getProgress()) .append("startTime", getStartTime()).append("endTime", getEndTime()).append("source", getSource()) .append("vnfId", getVnfId()).append("vnfName", getVnfName()).append("vnfType", getVnfType()) - .append("serviceType", getServiceType()).append("tenantId", getTenantId()) + .append("pnfId", getPnfId()).append("serviceType", getServiceType()).append("tenantId", getTenantId()) .append("vnfParams", getVnfParams()).append("vnfOutputs", getVnfOutputs()) .append("requestBody", getRequestBody()).append("responseBody", getResponseBody()) .append("lastModifiedBy", getLastModifiedBy()).append("modifyTime", getModifyTime()) .append("volumeGroupId", getVolumeGroupId()).append("volumeGroupName", getVolumeGroupName()) .append("vfModuleId", getVfModuleId()).append("vfModuleName", getVfModuleName()) - .append("vfModuleModelName", getVfModuleModelName()).append("aicCloudRegion", getAicCloudRegion()) + .append("vfModuleModelName", getVfModuleModelName()).append("CloudRegion", getCloudRegion()) .append("callBackUrl", getCallBackUrl()).append("correlator", getCorrelator()) .append("serviceInstanceId", getServiceInstanceId()) .append("serviceInstanceName", getServiceInstanceName()).append("requestScope", getRequestScope()) diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java index f36bf9058c..8f798a207c 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java @@ -74,6 +74,8 @@ public abstract class InfraRequests implements java.io.Serializable { private String source; @Column(name = "VNF_ID", length = 45) private String vnfId; + @Column(name = "PNF_ID", length = 45) + private String pnfId; @Column(name = "VNF_NAME", length = 80) private String vnfName; @Column(name = "VNF_TYPE", length = 200) @@ -106,7 +108,7 @@ public abstract class InfraRequests implements java.io.Serializable { @Column(name = "VF_MODULE_MODEL_NAME", length = 200) private String vfModuleModelName; @Column(name = "CLOUD_REGION", length = 11) - private String aicCloudRegion; + private String cloudRegion; @Column(name = "CALLBACK_URL", length = 200) private String callBackUrl; @Column(name = "CORRELATOR", length = 80) @@ -247,6 +249,14 @@ public abstract class InfraRequests implements java.io.Serializable { this.vnfId = vnfId; } + public String getPnfId() { + return this.pnfId; + } + + public void setPnfId(String pnfId) { + this.pnfId = pnfId; + } + public String getVnfName() { return this.vnfName; } @@ -363,12 +373,12 @@ public abstract class InfraRequests implements java.io.Serializable { this.vfModuleModelName = vfModuleModelName; } - public String getAicCloudRegion() { - return this.aicCloudRegion; + public String getCloudRegion() { + return this.cloudRegion; } - public void setAicCloudRegion(String aicCloudRegion) { - this.aicCloudRegion = aicCloudRegion; + public void setCloudRegion(String cloudRegion) { + this.cloudRegion = cloudRegion; } public String getCallBackUrl() { @@ -582,14 +592,14 @@ public abstract class InfraRequests implements java.io.Serializable { .append("flowStatus", getFlowStatus()).append("retryStatusMessage", getRetryStatusMessage()) .append("progress", getProgress()).append("startTime", getStartTime()).append("endTime", getEndTime()) .append("source", getSource()).append("vnfId", getVnfId()).append("vnfName", getVnfName()) - .append("vnfType", getVnfType()).append("serviceType", getServiceType()) + .append("pnfId", getPnfId()).append("vnfType", getVnfType()).append("serviceType", getServiceType()) .append("tenantId", getTenantId()).append("vnfParams", getVnfParams()) .append("vnfOutputs", getVnfOutputs()).append("requestBody", getRequestBody()) .append("responseBody", getResponseBody()).append("lastModifiedBy", getLastModifiedBy()) .append("modifyTime", getModifyTime()).append("volumeGroupId", getVolumeGroupId()) .append("volumeGroupName", getVolumeGroupName()).append("vfModuleId", getVfModuleId()) .append("vfModuleName", getVfModuleName()).append("vfModuleModelName", getVfModuleModelName()) - .append("aicCloudRegion", getAicCloudRegion()).append("callBackUrl", getCallBackUrl()) + .append("cloudRegion", getCloudRegion()).append("callBackUrl", getCallBackUrl()) .append("correlator", getCorrelator()).append("serviceInstanceId", getServiceInstanceId()) .append("serviceInstanceName", getServiceInstanceName()).append("requestScope", getRequestScope()) .append("requestAction", getRequestAction()).append("networkId", getNetworkId()) diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Workflow.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Workflow.java index 6bd0713085..fc1c753e85 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Workflow.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Workflow.java @@ -74,6 +74,9 @@ public class Workflow implements Serializable { private List<VnfResourceWorkflow> vnfResourceWorkflow; @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "workflow") + private List<PnfResourceWorkflow> pnfResourceWorkflow; + + @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "workflow") private List<WorkflowActivitySpecSequence> workflowActivitySpecSequence; @PrePersist @@ -191,6 +194,15 @@ public class Workflow implements Serializable { } @LinkedResource + public List<PnfResourceWorkflow> getPnfResourceWorkflow() { + return pnfResourceWorkflow; + } + + public void setPnfResourceWorkflow(List<PnfResourceWorkflow> pnfResourceWorkflow) { + this.pnfResourceWorkflow = pnfResourceWorkflow; + } + + @LinkedResource public List<WorkflowActivitySpecSequence> getWorkflowActivitySpecSequence() { return workflowActivitySpecSequence; } @@ -207,6 +219,7 @@ public class Workflow implements Serializable { .append("resourceTarget", resourceTarget).append("source", source) .append("timeoutMinutes", timeoutMinutes).append("artifactChecksum", artifactChecksum) .append("created", created).append("vnfResourceWorkflow", vnfResourceWorkflow) + .append("pnfResourceWorkflow", pnfResourceWorkflow) .append("WorkflowActivitySpecSequence", workflowActivitySpecSequence).toString(); } |