diff options
Diffstat (limited to 'adapters')
66 files changed, 5086 insertions, 410 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java index d7bc22aa7c..9042095e84 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java @@ -258,7 +258,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin { // The workflow completed with errors. Must try to back it out. if (!backout) { logger.warn("{} Deployment installation failed, backout deletion suppressed {} {}", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(), + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue(), "Exception in Deployment Installation, backout suppressed"); } else { // Poll on delete if we rollback - use same values for now @@ -278,13 +278,13 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin { // Didn't uninstall successfully. Log this error logger.error("{} Create Deployment: Cloudify error rolling back deployment install: {} {}", MessageEnum.RA_CREATE_STACK_ERR, installWorkflow.getError(), - ErrorCode.BusinessProcesssError.getValue()); + ErrorCode.BusinessProcessError.getValue()); } } catch (Exception e) { // Catch-all for backout errors trying to uninstall/delete // Log this error, and return the original exception logger.error("{} Create Stack: Nested exception rolling back deployment install: {}", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(), e); + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue(), e); } } @@ -299,7 +299,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin { if (!backout) { logger.warn("{} Deployment installation failed, backout deletion suppressed {}", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue()); + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue()); } else { // Poll on delete if we rollback - use same values for now int deletePollInterval = createPollInterval; @@ -318,7 +318,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin { // Catch-all for backout errors trying to uninstall/delete // Log this error, and return the original exception logger.error("{} Create Stack: Nested exception rolling back deployment install: {} ", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(), e); + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue(), e); } } @@ -350,7 +350,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin { } catch (CloudifyConnectException ce) { // Couldn't connect to Cloudify logger.error("{} QueryDeploymentOutputs: Cloudify connection failure: {} ", MessageEnum.RA_CREATE_STACK_ERR, - ErrorCode.BusinessProcesssError.getValue(), ce); + ErrorCode.BusinessProcessError.getValue(), ce); throw new MsoIOException(ce.getMessage(), ce); } catch (CloudifyResponseException re) { if (re.getStatus() == 404) { @@ -435,32 +435,32 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin { // Workflow failed. Log it and return the execution object (don't throw exception here) logger.error("{} Cloudify workflow failure: {} {} Execute Workflow: Failed: {}", MessageEnum.RA_CREATE_STACK_ERR, execution.getError(), - ErrorCode.BusinessProcesssError.getValue(), execution.getError()); + ErrorCode.BusinessProcessError.getValue(), execution.getError()); return execution; } else if (status.equals(CANCELLED)) { // Workflow was cancelled, leaving the deployment in an indeterminate state. Log it and return the // execution object (don't throw exception here) logger.error("{} Cloudify workflow cancelled. Deployment is in an indeterminate state {} {} {}", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(), + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue(), "Execute Workflow cancelled: ", workflowId); return execution; } else { // Can only get here after a timeout logger.error("{} Cloudify workflow timeout {} Execute Workflow: Timed Out", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue()); + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue()); } } catch (CloudifyConnectException ce) { logger.error("{} {} Execute Workflow ({} {}): Cloudify connection failure {} ", - MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(), command, ce); + MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcessError.getValue(), command, ce); savedException = ce; } catch (CloudifyResponseException re) { logger.error("{} {} Execute Workflow ({}): Cloudify response error {} ", MessageEnum.RA_CREATE_STACK_ERR, - ErrorCode.BusinessProcesssError.getValue(), command, re.getMessage(), re); + ErrorCode.BusinessProcessError.getValue(), command, re.getMessage(), re); savedException = re; } catch (RuntimeException e) { // Catch-all logger.error("{} {} Execute Workflow ({}): Internal error {}", MessageEnum.RA_CREATE_STACK_ERR, - ErrorCode.BusinessProcesssError.getValue(), command, e.getMessage(), e); + ErrorCode.BusinessProcessError.getValue(), command, e.getMessage(), e); savedException = e; } @@ -578,7 +578,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin { } catch (CloudifyConnectException ce) { // Couldn't connect to Cloudify logger.error("{} QueryDeployment: Cloudify connection failure: {} ", MessageEnum.RA_CREATE_STACK_ERR, - ErrorCode.BusinessProcesssError.getValue(), ce); + ErrorCode.BusinessProcessError.getValue(), ce); throw new MsoIOException(ce.getMessage(), ce); } catch (CloudifyResponseException re) { if (re.getStatus() == 404) { diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java index c648cc2137..ca0180ae4b 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java @@ -578,7 +578,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { if (!backout) { logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack error, stack deletion suppressed", "", "", - ErrorCode.BusinessProcesssError.getValue(), + ErrorCode.BusinessProcessError.getValue(), "Exception in Create Stack, stack deletion suppressed")); } else { try { @@ -621,7 +621,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e3, "", "", - ErrorCode.BusinessProcesssError.getValue(), + ErrorCode.BusinessProcessError.getValue(), "Create Stack: Nested exception rolling back stack on error on query")); } } @@ -629,7 +629,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { // Just log this one. We will report the original exception. logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e2, "", "", - ErrorCode.BusinessProcesssError.getValue(), + ErrorCode.BusinessProcessError.getValue(), "Create Stack: Nested exception rolling back stack")); } } @@ -644,13 +644,13 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack error: Polling complete with non-success status: " + stackInfo.getStatus() + ", " + stackInfo.getStatusMessage(), - "", "", ErrorCode.BusinessProcesssError.getValue(), "Create Stack error")); + "", "", ErrorCode.BusinessProcessError.getValue(), "Create Stack error")); // Rollback the stack creation, since it is in an indeterminate state. if (!backout) { logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, stack deletion suppressed", "", "", - ErrorCode.BusinessProcesssError.getValue(), + ErrorCode.BusinessProcessError.getValue(), "Create Stack error, stack deletion suppressed")); } else { try { @@ -685,7 +685,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, stack deletion FAILED", "", "", - ErrorCode.BusinessProcesssError.getValue(), + ErrorCode.BusinessProcessError.getValue(), "Create Stack error, stack deletion FAILED")); logger.debug("Stack deletion FAILED on a rollback of a create - " + instanceId + ", status=" + queryInfo.getStatus() + ", reason=" @@ -699,7 +699,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, then stack deletion FAILED - exception thrown", "", "", - ErrorCode.BusinessProcesssError.getValue(), me2.getContextMessage())); + ErrorCode.BusinessProcessError.getValue(), me2.getContextMessage())); } } StringBuilder errorContextMessage; @@ -717,7 +717,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { // shouldn't happen - but handle logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e2, "", "", - ErrorCode.BusinessProcesssError.getValue(), + ErrorCode.BusinessProcessError.getValue(), "Exception in Create Stack: rolling back stack")); } } @@ -840,7 +840,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { return JSON_MAPPER.readTree(directives); } catch (Exception e) { logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), - "Create Stack: " + e, "", "", ErrorCode.BusinessProcesssError.getValue(), + "Create Stack: " + e, "", "", ErrorCode.BusinessProcessError.getValue(), "Exception in Create Stack: Invalid JSON format of directives" + directives)); MsoException me = new MsoAdapterException("Invalid JSON format of directives parameter: " + directives); me.addContext(CREATE_STACK); diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql index 13d736e747..9527986f52 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql @@ -25,6 +25,8 @@ INSERT INTO northbound_request_ref_lookup(MACRO_ACTION, ACTION, REQUEST_SCOPE, I ('VolumeGroup-Delete', 'deleteInstance', 'VolumeGroup', true,true, '7','7', 'DEFAULT', '*'), ('VFModule-Create', 'createInstance', 'VfModule', true,true, '7','7', 'DEFAULT', '*'), ('VFModule-Delete', 'deleteInstance', 'VfModule', true,true, '7','7', 'DEFAULT', '*'), +('VFModule-Replace', 'replaceInstance', 'VfModule', true,true, '7','7', 'DEFAULT', '*'), +('VFModule-Replace-Retain-Assignments', 'replaceInstanceRetainAssignments', 'VfModule', true,true, '7','7', 'DEFAULT', '*'), ('NetworkCollection-Macro-Create', 'createInstance', 'NetworkCollection', false,true, '7','7', 'DEFAULT', '*'), ('NetworkCollection-Macro-Delete', 'deleteInstance', 'NetworkCollection', false,true, '7','7', 'DEFAULT', '*'), ('VFModule-ScaleOut', 'scaleOut', 'VfModule', true, true, '7','7', 'DEFAULT', '*'); @@ -147,7 +149,35 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FL ('VFModule-ScaleOut', '3', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-ScaleOut' and CLOUD_OWNER = 'DEFAULT')), ('VFModule-ScaleOut', '4', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-ScaleOut' and CLOUD_OWNER = 'DEFAULT')), ('VFModule-ScaleOut', '5', 'ConfigurationScaleOutBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-ScaleOut' and CLOUD_OWNER = 'DEFAULT')), -('VFModule-ScaleOut', '6', 'GenericVnfHealthCheckBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-ScaleOut' and CLOUD_OWNER = 'DEFAULT')); +('VFModule-ScaleOut', '6', 'GenericVnfHealthCheckBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-ScaleOut' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace', '1', 'DeactivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace', '2', 'DeleteVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace', '3', 'DeactivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace', '4', 'DeleteVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace', '5', 'UnassignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace', '6', 'UnassignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace', '7', 'AssignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace', '8', 'AssignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace', '9', 'CreateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace', '10', 'ActivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace', '11', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace', '12', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace', '13', 'ChangeModelVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace', '14', 'ChangeModelServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace-Retain-Assignments', '1', 'DeactivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace-Retain-Assignments', '2', 'DeleteVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace-Retain-Assignments', '3', 'DeactivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace-Retain-Assignments', '4', 'DeleteVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace-Retain-Assignments', '5', 'UnassignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace-Retain-Assignments', '6', 'AssignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace-Retain-Assignments', '7', 'ChangeModelVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace-Retain-Assignments', '8', 'CreateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace-Retain-Assignments', '9', 'ActivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace-Retain-Assignments', '10', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace-Retain-Assignments', '11', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace-Retain-Assignments', '12', 'ChangeModelVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), +('VFModule-Replace-Retain-Assignments', '13', 'ChangeModelServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')); + INSERT INTO rainy_day_handler_macro (FLOW_NAME, SERVICE_TYPE, VNF_TYPE, ERROR_CODE, WORK_STEP, POLICY) VALUES @@ -815,3 +845,7 @@ VALUES UPDATE rainy_day_handler_macro SET reg_ex_error_message = '*' WHERE reg_ex_error_message IS null; UPDATE rainy_day_handler_macro SET SERVICE_ROLE = '*' WHERE SERVICE_ROLE IS null; + +INSERT INTO vnf_components_recipe (VNF_TYPE, VNF_COMPONENT_TYPE, ACTION, VERSION, ORCHESTRATION_URI, RECIPE_TIMEOUT) +VALUES +(NULL, 'vfModule', 'replaceInstanceRetainAssignments', '1', '/mso/async/services/WorkflowActionBB', 180); diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.7.1__WorkFlowDesignerTables.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.7.1__WorkFlowDesignerTables.sql index e44a6b97ba..8641e51862 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.7.1__WorkFlowDesignerTables.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.7.1__WorkFlowDesignerTables.sql @@ -40,6 +40,27 @@ CREATE TABLE IF NOT EXISTS `catalogdb`.`vnf_resource_to_workflow` ( ENGINE = InnoDB DEFAULT CHARACTER SET = latin1; +CREATE TABLE IF NOT EXISTS `catalogdb`.`pnf_resource_to_workflow` ( + `ID` INT(11) NOT NULL AUTO_INCREMENT, + `PNF_RESOURCE_MODEL_UUID` VARCHAR(200) NOT NULL, + `WORKFLOW_ID` INT(11) NOT NULL, + PRIMARY KEY (`ID`), + UNIQUE INDEX `UK_pnf_resource_to_workflow` (`PNF_RESOURCE_MODEL_UUID` ASC, `WORKFLOW_ID` ASC), + INDEX `fk_pnf_resource_to_workflow__workflow1_idx` (`WORKFLOW_ID` ASC), + INDEX `fk_pnf_resource_to_workflow__pnf_res_mod_uuid_idx` (`PNF_RESOURCE_MODEL_UUID` ASC), + CONSTRAINT `fk_pnf_resource_to_workflow__pnf_resource1` + FOREIGN KEY (`PNF_RESOURCE_MODEL_UUID`) + REFERENCES `catalogdb`.`pnf_resource` (`MODEL_UUID`) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT `fk_pnf_resource_to_workflow__workflow1` + FOREIGN KEY (`WORKFLOW_ID`) + REFERENCES `catalogdb`.`workflow` (`ID`) + ON DELETE CASCADE + ON UPDATE CASCADE) +ENGINE = InnoDB +DEFAULT CHARACTER SET = latin1; + CREATE TABLE IF NOT EXISTS `catalogdb`.`activity_spec` ( `ID` INT(11) NOT NULL AUTO_INCREMENT, `NAME` VARCHAR(200) NOT NULL, diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.1__AddControllerActorAndBlueprint.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.1__AddControllerActorAndBlueprint.sql new file mode 100644 index 0000000000..5560dcc0de --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.1__AddControllerActorAndBlueprint.sql @@ -0,0 +1,23 @@ +use catalogdb; + +ALTER TABLE service +ADD CONTROLLER_ACTOR varchar(200) null; + +ALTER TABLE service +ADD CDS_BLUEPRINT_NAME varchar(200) null; + +ALTER TABLE service +ADD CDS_BLUEPRINT_VERSION varchar(20) null; + +ALTER TABLE service +ADD SKIP_POST_INSTANTIATION_CONFIGURATION boolean default true; + +ALTER TABLE vnf_resource_customization +ADD CONTROLLER_ACTOR varchar(200) null; + +ALTER TABLE pnf_resource_customization +ADD CONTROLLER_ACTOR varchar(200) null; + +ALTER TABLE vf_module_customization +ADD SKIP_POST_INSTANTIATION_CONFIGURATION boolean default true; + diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.2__AddScopeAndActionColumnsInOrchestrationFlowReference.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.2__AddScopeAndActionColumnsInOrchestrationFlowReference.sql new file mode 100644 index 0000000000..19bfb0f1e1 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.2__AddScopeAndActionColumnsInOrchestrationFlowReference.sql @@ -0,0 +1,5 @@ +use catalogdb; + +ALTER TABLE orchestration_flow_reference +ADD SCOPE VARCHAR (200) DEFAULT NULL, +ADD ACTION VARCHAR (200) DEFAULT NULL;
\ No newline at end of file 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 347bce5b17..69a23a0eba 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 @@ -21,21 +21,11 @@ package org.onap.so.adapters.catalogdb.catalogrest; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.INVOCATION_ID; -import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.LOG_TIMESTAMP; -import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.PARTNER_NAME; -import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.RESPONSE_CODE; -import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION; -import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE; -import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.SERVICE_NAME; import java.io.IOException; -import java.util.Map; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.json.JSONException; import org.junit.Test; -import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest; import org.onap.so.db.catalog.beans.ServiceRecipe; import org.skyscreamer.jsonassert.JSONAssert; @@ -46,7 +36,6 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.util.UriComponentsBuilder; -import ch.qos.logback.classic.spi.ILoggingEvent; public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { @@ -109,26 +98,6 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { restTemplate.exchange(createURLWithPort("/manage/health"), HttpMethod.GET, entity, String.class); assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - for (ILoggingEvent logEvent : TestAppender.events) - if (logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") - && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) { - Map<String, String> mdc = logEvent.getMDCPropertyMap(); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID)); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID)); - assertEquals("", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME)); - assertEquals("/manage/health", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME)); - assertEquals("INPROGRESS", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); - } else if (logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") - && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")) { - Map<String, String> mdc = logEvent.getMDCPropertyMap(); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID)); - assertEquals("200", mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE)); - assertEquals("", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME)); - assertEquals("/manage/health", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME)); - assertEquals("COMPLETED", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); - } } /* Service Resources Endpoint */ @@ -815,31 +784,6 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false); - - - for (ILoggingEvent logEvent : TestAppender.events) - if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.SOAuditLogContainerFilter") - && logEvent.getMarker().getName().equals("ENTRY")) { - Map<String, String> mdc = logEvent.getMDCPropertyMap(); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); - assertNotNull(mdc.get(INVOCATION_ID)); - assertEquals("UNKNOWN", mdc.get(PARTNER_NAME)); - assertEquals("v2/vfModules", mdc.get(SERVICE_NAME)); - assertEquals("INPROGRESS", mdc.get(RESPONSE_STATUS_CODE)); - } else if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.SOAuditLogContainerFilter") - && logEvent.getMarker().getName().equals("EXIT")) { - Map<String, String> mdc = logEvent.getMDCPropertyMap(); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); - assertNotNull(mdc.get(LOG_TIMESTAMP)); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); - assertNotNull(mdc.get(INVOCATION_ID)); - assertEquals("500", mdc.get(RESPONSE_CODE)); - assertEquals("UNKNOWN", mdc.get(PARTNER_NAME)); - assertEquals("v2/vfModules", mdc.get(SERVICE_NAME)); - assertEquals("ERROR", mdc.get(RESPONSE_STATUS_CODE)); - assertNotNull(mdc.get(RESPONSE_DESCRIPTION)); - } } @Test diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java index 5641186eca..97c715b44e 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java @@ -231,7 +231,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } catch (MsoException me) { logger.error( "{} {} Exception while querying network {} for CloudSite {} from Tenant {} from OpenStack ", - MessageEnum.RA_QUERY_NETWORK_EXC, ErrorCode.BusinessProcesssError.getValue(), networkName, + MessageEnum.RA_QUERY_NETWORK_EXC, ErrorCode.BusinessProcessError.getValue(), networkName, cloudSiteId, tenantId, me); me.addContext(CREATE_NETWORK_CONTEXT); throw new NetworkException(me); @@ -568,7 +568,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } catch (MsoException me) { me.addContext(UPDATE_NETWORK_CONTEXT); logger.error("{} {} Exception - queryNetwork query {} in {}/{} ", MessageEnum.RA_QUERY_NETWORK_EXC, - ErrorCode.BusinessProcesssError.getValue(), networkId, cloudSiteId, tenantId, me); + ErrorCode.BusinessProcessError.getValue(), networkId, cloudSiteId, tenantId, me); throw new NetworkException(me); } @@ -576,7 +576,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String error = String.format("Update Nework: Network %s does not exist in %s/%s", networkId, cloudSiteId, tenantId); logger.error(LoggingAnchor.THREE, MessageEnum.RA_NETWORK_NOT_FOUND, - ErrorCode.BusinessProcesssError.getValue(), error); + ErrorCode.BusinessProcessError.getValue(), error); // Does not exist. Throw an exception (can't update a non-existent network) throw new NetworkException(error, MsoExceptionCategory.USERDATA); } @@ -1105,7 +1105,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } catch (MsoException me) { me.addContext("RollbackNetwork"); logger.error("{} {} Exception - Rollback Network (neutron): {} in {}/{} ", - MessageEnum.RA_DELETE_NETWORK_EXC, ErrorCode.BusinessProcesssError.getValue(), networkId, + MessageEnum.RA_DELETE_NETWORK_EXC, ErrorCode.BusinessProcessError.getValue(), networkId, cloudSiteId, tenantId, me); throw new NetworkException(me); } @@ -1115,7 +1115,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } catch (MsoException me) { me.addContext("RollbackNetwork"); logger.error("{} {} Exception - Rollback Network (heat): {} in {}/{} ", - MessageEnum.RA_DELETE_NETWORK_EXC, ErrorCode.BusinessProcesssError.getValue(), networkId, + MessageEnum.RA_DELETE_NETWORK_EXC, ErrorCode.BusinessProcessError.getValue(), networkId, cloudSiteId, tenantId, me); throw new NetworkException(me); } @@ -1263,7 +1263,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } } else { String error = "Null pFqdns at start of mergePolicyRefs"; - logger.error(LoggingAnchor.THREE, MessageEnum.RA_MARSHING_ERROR, ErrorCode.BusinessProcesssError.getValue(), + logger.error(LoggingAnchor.THREE, MessageEnum.RA_MARSHING_ERROR, ErrorCode.BusinessProcessError.getValue(), error); throw new MsoAdapterException(error); } @@ -1276,7 +1276,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { logger.debug("Json PolicyRefs Data:{}", jsonString); } catch (Exception e) { String error = "Error creating JsonNode for policyRefs Data"; - logger.error(LoggingAnchor.THREE, MessageEnum.RA_MARSHING_ERROR, ErrorCode.BusinessProcesssError.getValue(), + logger.error(LoggingAnchor.THREE, MessageEnum.RA_MARSHING_ERROR, ErrorCode.BusinessProcessError.getValue(), error, e); throw new MsoAdapterException(error); } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java index 4eb5d5637f..0c37837880 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java @@ -124,7 +124,7 @@ public class NetworkAdapterRest { } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller logger.error("{} {} Exception while create network ", MessageEnum.RA_CREATE_NETWORK_EXC, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -286,7 +286,7 @@ public class NetworkAdapterRest { } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller logger.error("{} {} Exception while delete network ", MessageEnum.RA_DELETE_NETWORK_EXC, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -403,7 +403,7 @@ public class NetworkAdapterRest { return Response.status(respStatus).entity(new GenericEntity<QueryNetworkResponse>(resp) {}).build(); } catch (NetworkException e) { logger.error("{} {} Exception when query VNF ", MessageEnum.RA_QUERY_VNF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); QueryNetworkError err = new QueryNetworkError(); err.setMessage(e.getMessage()); err.setCategory(MsoExceptionCategory.INTERNAL); @@ -436,7 +436,7 @@ public class NetworkAdapterRest { } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller logger.error("{} {} Exception in rollbackNetwork ", MessageEnum.RA_ROLLBACK_NULL, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -529,7 +529,7 @@ public class NetworkAdapterRest { } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller logger.error("{} {} Exception in updateNetwork ", MessageEnum.RA_UPDATE_NETWORK_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java index 62e9d562a6..662ce33022 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/BpelRestClient.java @@ -216,7 +216,7 @@ public class BpelRestClient { if (totalretries >= retryCount) { debug("Retried " + totalretries + " times, giving up."); logger.error("{} {} Could not deliver response to BPEL after {} tries: {}", - MessageEnum.RA_SEND_VNF_NOTIF_ERR, ErrorCode.BusinessProcesssError.getValue(), totalretries, + MessageEnum.RA_SEND_VNF_NOTIF_ERR, ErrorCode.BusinessProcessError.getValue(), totalretries, toBpelStr); return false; } @@ -273,7 +273,7 @@ public class BpelRestClient { } } catch (Exception e) { logger.error("{} {} Exception - Error sending Bpel notification: {} ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, - ErrorCode.BusinessProcesssError.getValue(), toBpelStr, e); + ErrorCode.BusinessProcessError.getValue(), toBpelStr, e); lastResponseCode = 900; lastResponse = ""; } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java index f6ea2261d7..39a380d2cf 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java @@ -121,6 +121,8 @@ public interface MsoVnfAdapter { @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner, @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId, @WebParam(name = "vfName") @XmlElement(required = true) String vfName, + @WebParam(name = "vnfId") @XmlElement(required = true) String vnfId, + @WebParam(name = "vfModuleId") @XmlElement(required = true) String vfModuleId, @WebParam(name = "request") MsoRequest msoRequest, @WebParam(name = "vfModuleOutputs", mode = Mode.OUT) Holder<Map<String, String>> vfModuleOutputs) throws VnfException; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java index 6713c2d069..e925e6037c 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java @@ -135,7 +135,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { vnfRollback); } catch (VnfException e) { logger.error("{} {} VnfException in createVnfA ", MessageEnum.RA_CREATE_VNF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null; String eMsg = null; try { @@ -144,7 +144,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { .fromValue(e.getFaultInfo().getCategory().name()); } catch (Exception e1) { logger.error("{} {} Exception - Fault info ", MessageEnum.RA_FAULT_INFO_EXC, - ErrorCode.BusinessProcesssError.getValue(), e1); + ErrorCode.BusinessProcessError.getValue(), e1); } // Build and send Asynchronous error response try { @@ -152,7 +152,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { notifyPort.createVnfNotification(messageId, false, exCat, eMsg, null, null, null); } catch (Exception e1) { logger.error("{} {} Exception sending createVnf notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e1); + ErrorCode.BusinessProcessError.getValue(), e1); } logger.info(LoggingAnchor.ONE, MessageEnum.RA_ASYNC_CREATE_VNF_COMPLETE); return; @@ -165,7 +165,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { copyVrb(vnfRollback)); } catch (Exception e) { logger.error("{} {} Exception sending createVnf notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); } logger.info("{} createVnfA", MessageEnum.RA_ASYNC_CREATE_VNF_COMPLETE); return; @@ -191,7 +191,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { volumeGroupHeatStackId, inputs, msoRequest, outputs, vnfRollback); } catch (VnfException e) { logger.error(EXCEPTION_UPDATEVNF_NOTIFICATION, MessageEnum.RA_UPDATE_VNF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null; String eMsg = null; try { @@ -200,7 +200,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { .fromValue(e.getFaultInfo().getCategory().name()); } catch (Exception e1) { logger.error("{} {} Exception - fault info ", MessageEnum.RA_FAULT_INFO_EXC, - ErrorCode.BusinessProcesssError.getValue(), e1); + ErrorCode.BusinessProcessError.getValue(), e1); } // Build and send Asynchronous error response try { @@ -208,7 +208,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { notifyPort.updateVnfNotification(messageId, false, exCat, eMsg, null, null); } catch (Exception e1) { logger.error(EXCEPTION_UPDATEVNF_NOTIFICATION, MessageEnum.RA_SEND_VNF_NOTIF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e1); + ErrorCode.BusinessProcessError.getValue(), e1); } logger.info(UPDATE_VNFA, MessageEnum.RA_ASYNC_UPDATE_VNF_COMPLETE); return; @@ -221,7 +221,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { copyVrb(vnfRollback)); } catch (Exception e) { logger.error(EXCEPTION_UPDATEVNF_NOTIFICATION, MessageEnum.RA_SEND_VNF_NOTIF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); } logger.info(UPDATE_VNFA, MessageEnum.RA_ASYNC_UPDATE_VNF_COMPLETE); return; @@ -261,7 +261,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { outputs); } catch (VnfException e) { logger.error("{} {} Exception sending queryVnfA notification ", MessageEnum.RA_QUERY_VNF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null; String eMsg = null; try { @@ -270,7 +270,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { .fromValue(e.getFaultInfo().getCategory().name()); } catch (Exception e1) { logger.error("{} {} Exception - fault info ", MessageEnum.RA_FAULT_INFO_EXC, - ErrorCode.BusinessProcesssError.getValue(), e1); + ErrorCode.BusinessProcessError.getValue(), e1); } // Build and send Asynchronous error response try { @@ -278,7 +278,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { notifyPort.queryVnfNotification(messageId, false, exCat, eMsg, null, null, null, null); } catch (Exception e1) { logger.error("{} {} Exception sending queryVnf notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e1); + ErrorCode.BusinessProcessError.getValue(), e1); } logger.info("{} queryVnfA", MessageEnum.RA_ASYNC_QUERY_VNF_COMPLETE); return; @@ -298,7 +298,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { copyQueryOutputs(outputs)); } catch (Exception e) { logger.error("{} {} Exception sending queryVnf notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); } logger.info("{} queryVnfA", MessageEnum.RA_ASYNC_QUERY_VNF_COMPLETE); @@ -331,7 +331,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { vnfAdapter.deleteVnf(cloudSiteId, cloudOwner, tenantId, vnfName, msoRequest); } catch (VnfException e) { logger.error("{} {} Exception sending deleteVnfA notification ", MessageEnum.RA_DELETE_VNF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null; String eMsg = null; try { @@ -340,7 +340,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { .fromValue(e.getFaultInfo().getCategory().name()); } catch (Exception e1) { logger.error("{} {} Exception - fault info ", MessageEnum.RA_FAULT_INFO_EXC, - ErrorCode.BusinessProcesssError.getValue(), e1); + ErrorCode.BusinessProcessError.getValue(), e1); } // Build and send Asynchronous error response try { @@ -348,7 +348,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { notifyPort.deleteVnfNotification(messageId, false, exCat, eMsg); } catch (Exception e1) { logger.error("{} {} Exception sending deleteVnfA notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e1); + ErrorCode.BusinessProcessError.getValue(), e1); } logger.info("{} deleteVnfA", MessageEnum.RA_ASYNC_DELETE_VNF_COMPLETE); return; @@ -362,7 +362,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { } catch (Exception e) { logger.error("{} {} Exception sending deleteVnfA notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); } logger.info("{} deleteVnfA", MessageEnum.RA_ASYNC_DELETE_VNF_COMPLETE); @@ -391,7 +391,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { vnfAdapter.rollbackVnf(rollback); } catch (VnfException e) { logger.error("{} {} Exception sending rollbackVnfA notification ", MessageEnum.RA_ROLLBACK_VNF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null; String eMsg = null; try { @@ -400,7 +400,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { .fromValue(e.getFaultInfo().getCategory().name()); } catch (Exception e1) { logger.error("{} {} Exception - fault info ", MessageEnum.RA_FAULT_INFO_EXC, - ErrorCode.BusinessProcesssError.getValue(), e1); + ErrorCode.BusinessProcessError.getValue(), e1); } // Build and send Asynchronous error response try { @@ -408,7 +408,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { notifyPort.rollbackVnfNotification(messageId, false, exCat, eMsg); } catch (Exception e1) { logger.error("{} {} Exception sending rollbackVnfA notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e1); + ErrorCode.BusinessProcessError.getValue(), e1); } logger.info("{} rollbackVnfA", MessageEnum.RA_ASYNC_ROLLBACK_VNF_COMPLETE); return; @@ -421,7 +421,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { notifyPort.rollbackVnfNotification(messageId, true, null, null); } catch (Exception e) { logger.error("{} {} Exception sending rollbackVnfA notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); } logger.info("{} rollbackVnfA", MessageEnum.RA_ASYNC_ROLLBACK_VNF_COMPLETE); @@ -519,17 +519,17 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { warWsdlLoc = Thread.currentThread().getContextClassLoader().getResource("VnfAdapterNotify.wsdl"); } catch (Exception e) { logger.error("{} {} Exception - WSDL not found ", MessageEnum.RA_WSDL_NOT_FOUND, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); } if (warWsdlLoc == null) { logger.error("{} {} WSDL not found", MessageEnum.RA_WSDL_NOT_FOUND, - ErrorCode.BusinessProcesssError.getValue()); + ErrorCode.BusinessProcessError.getValue()); } else { try { logger.debug("VnfAdpaterNotify.wsdl location:{}", warWsdlLoc.toURI().toString()); } catch (Exception e) { logger.error("{} {} Exception - WSDL URL convention ", MessageEnum.RA_WSDL_URL_CONVENTION_EXC, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); } } @@ -545,7 +545,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { epUrl = new URL(notificationUrl); } catch (MalformedURLException e1) { logger.error("{} {} MalformedURLException ", MessageEnum.RA_INIT_NOTIF_EXC, - ErrorCode.BusinessProcesssError.getValue(), e1); + ErrorCode.BusinessProcessError.getValue(), e1); } if (null != epUrl) { @@ -567,7 +567,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { headers.put("Authorization", Collections.singletonList(basicAuth)); } catch (Exception e) { logger.error("{} {} Exception - Unable to set authorization in callback request ", - MessageEnum.RA_SET_CALLBACK_AUTH_EXC, ErrorCode.BusinessProcesssError.getValue(), e); + MessageEnum.RA_SET_CALLBACK_AUTH_EXC, ErrorCode.BusinessProcessError.getValue(), e); } return notifyPort; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java index 0d1d690024..fcb2d7c2bb 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java @@ -25,15 +25,11 @@ package org.onap.so.adapters.vnf; -import java.io.File; -import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.concurrent.TimeUnit; import javax.jws.WebService; import javax.xml.ws.Holder; import org.apache.commons.collections.CollectionUtils; @@ -63,6 +59,7 @@ import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository; import org.onap.so.db.catalog.data.repository.VnfResourceRepository; import org.onap.so.db.catalog.utils.MavenLikeVersioning; import org.onap.so.entity.MsoRequest; +import org.onap.so.heatbridge.HeatBridgeException; import org.onap.so.heatbridge.HeatBridgeApi; import org.onap.so.heatbridge.HeatBridgeImpl; import org.onap.so.logger.ErrorCode; @@ -424,8 +421,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { List<String> oobMgtNetNames = new ArrayList<>(); - HeatBridgeApi heatBridgeClient = - new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, cloudOwner, cloudSiteId, tenantId); + HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, cloudOwner, + cloudSiteId, cloudSite.getRegionId(), tenantId); + + heatBridgeClient.authenticate(); List<Resource> stackResources = heatBridgeClient.queryNestedHeatStackResources(heatStackId); @@ -620,7 +619,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String error = "Create VFModule: Attached heatStack ID Query " + nestedStackId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + me; logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, OPENSTACK, QUERY_STACK, ErrorCode.BusinessProcesssError.getValue(), + cloudSiteId, tenantId, OPENSTACK, QUERY_STACK, ErrorCode.BusinessProcessError.getValue(), "MsoException trying to query nested stack", me); logger.debug("ERROR trying to query nested stack= {}", error); throw new VnfException(me); @@ -629,8 +628,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String error = "Create VFModule: Attached heatStack ID DOES NOT EXIST " + nestedStackId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + " " + USER_ERROR; logger.error(LoggingAnchor.TEN, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, error, OPENSTACK, QUERY_STACK, - ErrorCode.BusinessProcesssError.getValue(), + cloudSiteId, tenantId, error, OPENSTACK, QUERY_STACK, ErrorCode.BusinessProcessError.getValue(), "Create VFModule: Attached heatStack ID " + "DOES NOT EXIST"); logger.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); @@ -654,7 +652,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String error = "Create VFModule: Attached baseHeatStack ID Query " + nestedBaseStackId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + me; logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, OPENSTACK, QUERY_STACK, ErrorCode.BusinessProcesssError.getValue(), + cloudSiteId, tenantId, OPENSTACK, QUERY_STACK, ErrorCode.BusinessProcessError.getValue(), "MsoException trying to query nested base stack", me); logger.debug("ERROR trying to query nested base stack= {}", error); throw new VnfException(me); @@ -663,8 +661,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { String error = "Create VFModule: Attached base heatStack ID DOES NOT EXIST " + nestedBaseStackId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + " " + USER_ERROR; logger.error(LoggingAnchor.TEN, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, error, OPENSTACK, QUERY_STACK, - ErrorCode.BusinessProcesssError.getValue(), + cloudSiteId, tenantId, error, OPENSTACK, QUERY_STACK, ErrorCode.BusinessProcessError.getValue(), "Create VFModule: Attached base heatStack ID DOES NOT EXIST"); logger.debug("Exception occurred", error); throw new VnfException(error, MsoExceptionCategory.USERDATA); @@ -796,7 +793,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { + VERSION_MAX + " :" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSiteOpt.get().getCloudVersion(); logger.error(LoggingAnchor.FIVE, MessageEnum.RA_CONFIG_EXC.toString(), error, OPENSTACK, - ErrorCode.BusinessProcesssError.getValue(), "Exception - setVersion"); + ErrorCode.BusinessProcessError.getValue(), "Exception - setVersion"); logger.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } @@ -1139,8 +1136,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } @Override - public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, - MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException { + public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, String vnfId, + String vfModuleId, MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException { Map<String, Object> stackOutputs; try { stackOutputs = msoHeatUtils.queryStackForOutputs(cloudSiteId, cloudOwner, tenantId, vnfName); @@ -1205,6 +1202,12 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { logger.error("Exception encountered while sending Confirm to Valet ", e); } } + // call heatbridge delete + try { + new HeatBridgeImpl().deleteVfModuleData(vnfId, vfModuleId); + } catch (HeatBridgeException e) { + logger.error("Heatbridge failed to delete AAI data for vf-module: " + vfModuleId, e); + } } @Override @@ -1489,7 +1492,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { + minVersionVnf + " " + VERSION_MAX + " :" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + aicV; logger.error(LoggingAnchor.FIVE, MessageEnum.RA_CONFIG_EXC.toString(), error, OPENSTACK, - ErrorCode.BusinessProcesssError.getValue(), "Exception - setVersion"); + ErrorCode.BusinessProcessError.getValue(), "Exception - setVersion"); logger.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java index f09fa34cb9..d35c34a937 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java @@ -601,7 +601,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { + vnfResource.getModelUUID() + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSite.getCloudVersion(); logger.error(LoggingAnchor.FIVE, MessageEnum.RA_CONFIG_EXC.toString(), error, OPENSTACK, - ErrorCode.BusinessProcesssError.getValue(), "Exception - setVersion"); + ErrorCode.BusinessProcessError.getValue(), "Exception - setVersion"); logger.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } @@ -725,7 +725,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { String error = "Create VFModule: Attached Volume Group DOES NOT EXIST " + volumeGroupId + " in " + cloudSiteId + "/" + tenantId + " USER ERROR"; logger.error(BRACKETS, MessageEnum.RA_QUERY_VNF_ERR.toString(), volumeGroupId, cloudSiteId, tenantId, - error, CLOUDIFY, "queryDeployment(volume)", ErrorCode.BusinessProcesssError.getValue(), + error, CLOUDIFY, "queryDeployment(volume)", ErrorCode.BusinessProcessError.getValue(), "Create VFModule: Attached Volume Group DOES NOT EXIST"); logger.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); @@ -774,7 +774,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { + cloudSiteId + "/" + tenantId + " USER ERROR"; logger.error(BRACKETS, MessageEnum.RA_QUERY_VNF_ERR.toString(), baseVfModuleId, cloudSiteId, tenantId, error, CLOUDIFY, "queryDeployment(Base)", - ErrorCode.BusinessProcesssError.getValue(), + ErrorCode.BusinessProcessError.getValue(), "Create VFModule: Base " + "Module DOES NOT EXIST"); logger.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); @@ -1081,8 +1081,8 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { } - public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, - MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException { + public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, String vnfId, + String vfModuleId, MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException { logger.debug("Deleting VF " + vnfName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId); // 1702 capture the output parameters on a delete diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java index 41bcc8c481..561b21250f 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java @@ -643,7 +643,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSite.getCloudVersion(); logger.error(LoggingAnchor.FIVE, MessageEnum.RA_CONFIG_EXC.toString(), error, "OpenStack", - ErrorCode.BusinessProcesssError.getValue(), "Exception - setVersion"); + ErrorCode.BusinessProcessError.getValue(), "Exception - setVersion"); logger.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } @@ -773,7 +773,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { + cloudOwner + "/" + cloudSiteId + "/" + tenantId + " USER ERROR"; logger.error(LoggingAnchor.TEN, MessageEnum.RA_QUERY_VNF_ERR.toString(), volumeGroupId, cloudOwner, cloudSiteId, tenantId, error, "VDU", "queryVdu(volume)", - ErrorCode.BusinessProcesssError.getValue(), + ErrorCode.BusinessProcessError.getValue(), "Create VFModule: Attached Volume Group " + "DOES NOT EXIST"); logger.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); @@ -822,7 +822,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { + "/" + cloudSiteId + "/" + tenantId + " USER ERROR"; logger.error(LoggingAnchor.TEN, MessageEnum.RA_QUERY_VNF_ERR.toString(), baseVfModuleId, cloudOwner, cloudSiteId, tenantId, error, "VDU", "queryVdu(Base)", - ErrorCode.BusinessProcesssError.getValue(), "Create VFModule: Base Module DOES NOT EXIST"); + ErrorCode.BusinessProcessError.getValue(), "Create VFModule: Base Module DOES NOT EXIST"); logger.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); } else { @@ -1072,8 +1072,8 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { } - public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vfModuleId, - MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException { + public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vfModuleId, String vnfId, + String aaiVfModuleId, MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException { logger.debug("Deleting VF Module " + vfModuleId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java index 8c871c742e..58899b7f48 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java @@ -130,7 +130,7 @@ public class VnfAdapterRest { } catch (Exception e) { // problem handling delete, send generic failure as sync resp to caller logger.error("", MessageEnum.RA_DELETE_VNF_ERR.toString(), "deleteVfModule", - ErrorCode.BusinessProcesssError.getValue(), "Exception in deleteVfModule", e); + ErrorCode.BusinessProcessError.getValue(), "Exception in deleteVfModule", e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -179,13 +179,14 @@ public class VnfAdapterRest { Holder<Map<String, String>> outputs = new Holder<>(); if (cloudsite != null && !cloudsite.equals(TESTING_KEYWORD)) { vnfAdapter.deleteVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(), - req.getVfModuleStackId(), req.getMsoRequest(), outputs); + req.getVfModuleStackId(), req.getVnfId(), req.getVfModuleId(), req.getMsoRequest(), + outputs); } response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE, req.getMessageId(), outputs.value); } catch (VnfException e) { logger.error(LoggingAnchor.THREE, MessageEnum.RA_DELETE_VNF_ERR.toString(), - ErrorCode.BusinessProcesssError.getValue(), "VnfException - Delete VNF Module", e); + ErrorCode.BusinessProcessError.getValue(), "VnfException - Delete VNF Module", e); eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId()); } @@ -243,7 +244,7 @@ public class VnfAdapterRest { return Response.status(respStatus).entity(new GenericEntity<QueryVfModuleResponse>(qryResp) {}).build(); } catch (VnfException e) { logger.error(LoggingAnchor.FIVE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, "queryVfModule", - ErrorCode.BusinessProcesssError.getValue(), "VnfException - queryVfModule", e); + ErrorCode.BusinessProcessError.getValue(), "VnfException - queryVfModule", e); VfModuleExceptionResponse excResp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null); return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR) @@ -290,7 +291,7 @@ public class VnfAdapterRest { } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller logger.error(LoggingAnchor.FOUR, MessageEnum.RA_CREATE_VNF_ERR, "createVfModule", - ErrorCode.BusinessProcesssError, "Exception - createVfModule", e); + ErrorCode.BusinessProcessError, "Exception - createVfModule", e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -405,7 +406,7 @@ public class VnfAdapterRest { } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller logger.error(LoggingAnchor.FOUR, MessageEnum.RA_UPDATE_VNF_ERR.toString(), "updateVfModule", - ErrorCode.BusinessProcesssError.getValue(), "Exception - updateVfModule", e); + ErrorCode.BusinessProcessError.getValue(), "Exception - updateVfModule", e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -509,7 +510,7 @@ public class VnfAdapterRest { } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller logger.error(LoggingAnchor.FOUR, MessageEnum.RA_ROLLBACK_VNF_ERR.toString(), "rollbackVfModule", - ErrorCode.BusinessProcesssError.getValue(), "Exception - rollbackVfModule", e); + ErrorCode.BusinessProcessError.getValue(), "Exception - rollbackVfModule", e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -560,7 +561,7 @@ public class VnfAdapterRest { vnfAdapter.rollbackVnf(vrb); response = new RollbackVfModuleResponse(Boolean.TRUE, req.getMessageId()); } catch (VnfException e) { - logger.error(LoggingAnchor.THREE, MessageEnum.RA_ROLLBACK_VNF_ERR, ErrorCode.BusinessProcesssError, + logger.error(LoggingAnchor.THREE, MessageEnum.RA_ROLLBACK_VNF_ERR, ErrorCode.BusinessProcessError, "Exception" + " - " + "rollbackVfModule", e); eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, false, req.getMessageId()); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java index 9a7354c40c..0e70c6be53 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java @@ -140,7 +140,7 @@ public class VnfAdapterRestV2 { } catch (Exception e) { // problem handling delete, send generic failure as sync resp to caller logger.error(BRACKETS, MessageEnum.RA_DELETE_VNF_ERR.toString(), "deleteVfModule", - ErrorCode.BusinessProcesssError.getValue(), "Exception in deleteVfModule", e); + ErrorCode.BusinessProcessError.getValue(), "Exception in deleteVfModule", e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -195,13 +195,14 @@ public class VnfAdapterRestV2 { // Support different Adapter Implementations MsoVnfAdapter adapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudsite); adapter.deleteVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(), - req.getVfModuleStackId(), req.getMsoRequest(), outputs); + req.getVfModuleStackId(), req.getVnfId(), req.getVfModuleId(), req.getMsoRequest(), + outputs); } response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE, req.getMessageId(), outputs.value); } catch (VnfException e) { logger.error(LoggingAnchor.THREE, MessageEnum.RA_DELETE_VNF_ERR.toString(), - ErrorCode.BusinessProcesssError.getValue(), "VnfException - " + "Delete VNF Module", e); + ErrorCode.BusinessProcessError.getValue(), "VnfException - " + "Delete VNF Module", e); eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, req.getMessageId()); } @@ -271,7 +272,7 @@ public class VnfAdapterRestV2 { return Response.status(respStatus).entity(new GenericEntity<QueryVfModuleResponse>(qryResp) {}).build(); } catch (VnfException e) { logger.error(LoggingAnchor.FIVE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, "queryVfModule", - ErrorCode.BusinessProcesssError.getValue(), "VnfException - queryVfModule", e); + ErrorCode.BusinessProcessError.getValue(), "VnfException - queryVfModule", e); VfModuleExceptionResponse excResp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null); return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR) @@ -320,7 +321,7 @@ public class VnfAdapterRestV2 { } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller logger.error(BRACKETS, MessageEnum.RA_CREATE_VNF_ERR.toString(), "createVfModule", - ErrorCode.BusinessProcesssError.getValue(), "Exception - createVfModule", e); + ErrorCode.BusinessProcessError.getValue(), "Exception - createVfModule", e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -440,7 +441,7 @@ public class VnfAdapterRestV2 { } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller logger.error(BRACKETS, MessageEnum.RA_UPDATE_VNF_ERR.toString(), "updateVfModule", - ErrorCode.BusinessProcesssError.getValue(), "Exception - updateVfModule", e); + ErrorCode.BusinessProcessError.getValue(), "Exception - updateVfModule", e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -555,7 +556,7 @@ public class VnfAdapterRestV2 { } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller logger.error(BRACKETS, MessageEnum.RA_ROLLBACK_VNF_ERR.toString(), "rollbackVfModule", - ErrorCode.BusinessProcesssError.getValue(), "Exception - rollbackVfModule", e); + ErrorCode.BusinessProcessError.getValue(), "Exception - rollbackVfModule", e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -612,7 +613,7 @@ public class VnfAdapterRestV2 { response = new RollbackVfModuleResponse(Boolean.TRUE, req.getMessageId()); } catch (VnfException e) { logger.error(LoggingAnchor.THREE, MessageEnum.RA_ROLLBACK_VNF_ERR.toString(), - ErrorCode.BusinessProcesssError.getValue(), "Exception - rollbackVfModule", e); + ErrorCode.BusinessProcessError.getValue(), "Exception - rollbackVfModule", e); eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, false, req.getMessageId()); } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java index 87df7fdc37..c9e046ca43 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java @@ -118,7 +118,7 @@ public class VolumeAdapterRest { } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller logger.error("{} {} Exception - createVNFVolumes: ", MessageEnum.RA_CREATE_VNF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -270,7 +270,7 @@ public class VolumeAdapterRest { } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller logger.error("{} {} Exception - deleteVNFVolumes: ", MessageEnum.RA_DELETE_VNF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -367,7 +367,7 @@ public class VolumeAdapterRest { } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller logger.error("{} {} Exception - rollbackVNFVolumes: ", MessageEnum.RA_ROLLBACK_VNF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -463,7 +463,7 @@ public class VolumeAdapterRest { } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller logger.error("{} {} Exception - updateVNFVolumes: ", MessageEnum.RA_UPDATE_VNF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -607,7 +607,7 @@ public class VolumeAdapterRest { return Response.status(respStatus).entity(new GenericEntity<QueryVolumeGroupResponse>(qryResp) {}).build(); } catch (VnfException e) { logger.error("{} {} AaiVolumeGroupId: {} VnfException - queryVNFVolumes", MessageEnum.RA_QUERY_VNF_ERR, - ErrorCode.BusinessProcesssError.getValue(), aaiVolumeGroupId, e); + ErrorCode.BusinessProcessError.getValue(), aaiVolumeGroupId, e); VolumeGroupExceptionResponse excResp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null); logger.debug("Query queryVNFVolumes exit"); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java index 89eb6a161d..2b7234aca6 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java @@ -118,7 +118,7 @@ public class VolumeAdapterRestV2 { } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller logger.error("{} {} Exception - createVNFVolumes: ", MessageEnum.RA_CREATE_VNF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -253,7 +253,7 @@ public class VolumeAdapterRestV2 { } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller logger.error("{} {} Exception - deleteVNFVolumes: ", MessageEnum.RA_DELETE_VNF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -355,7 +355,7 @@ public class VolumeAdapterRestV2 { } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller logger.error("{} {} Exception - rollbackVNFVolumes: ", MessageEnum.RA_ROLLBACK_VNF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -455,7 +455,7 @@ public class VolumeAdapterRestV2 { } catch (Exception e) { // problem handling create, send generic failure as sync resp to caller logger.error("{} {} Exception - updateVNFVolumes: ", MessageEnum.RA_UPDATE_VNF_ERR, - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcessError.getValue(), e); return Response.serverError().build(); } // send sync response (ACK) to caller @@ -594,7 +594,7 @@ public class VolumeAdapterRestV2 { return Response.status(respStatus).entity(new GenericEntity<QueryVolumeGroupResponse>(qryResp) {}).build(); } catch (VnfException e) { logger.error("{} {} AaiVolumeGroupId: {} VnfException - queryVNFVolumes: ", MessageEnum.RA_QUERY_VNF_ERR, - ErrorCode.BusinessProcesssError.getValue(), aaiVolumeGroupId, e); + ErrorCode.BusinessProcessError.getValue(), aaiVolumeGroupId, e); VolumeGroupExceptionResponse excResp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null); logger.debug("Query queryVNFVolumes exit"); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java index d568bc2807..7eff09b692 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java @@ -150,4 +150,11 @@ public interface HeatBridgeApi { * @throws HeatBridgeException when failing to add openstack resource PoJos to AAI */ void submitToAai() throws HeatBridgeException; + + /** + * Delete heatbridge data for a given vf-module + * + * @throws HeatBridgeException when failing to remove heatbridge data from AAI for a given vf-module + */ + void deleteVfModuleData(String vnfId, String vfModuleId) throws HeatBridgeException; } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java index a1b33056da..e2022c9a6e 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java @@ -58,9 +58,12 @@ import org.onap.aai.domain.yang.SriovVfs; import org.onap.aai.domain.yang.Vlan; import org.onap.aai.domain.yang.Vlans; import org.onap.aai.domain.yang.Vserver; +import org.onap.aai.domain.yang.VfModule; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.AAISingleTransactionClient; +import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.Relationships; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.graphinventory.entities.uri.Depth; @@ -102,33 +105,39 @@ public class HeatBridgeImpl implements HeatBridgeApi { private AAISingleTransactionClient transaction; private String cloudOwner; private String cloudRegionId; + private String regionId; private String tenantId; private AaiHelper aaiHelper = new AaiHelper(); private CloudIdentity cloudIdentity; - public HeatBridgeImpl(AAIResourcesClient resourcesClient, final CloudIdentity cloudIdentity, - @Nonnull final String cloudOwner, @Nonnull final String cloudRegionId, @Nonnull final String tenantId) { + @Nonnull final String cloudOwner, @Nonnull final String cloudRegionId, @Nonnull final String regionId, + @Nonnull final String tenantId) { Objects.requireNonNull(cloudOwner, "Null cloud-owner value!"); Objects.requireNonNull(cloudRegionId, "Null cloud-region identifier!"); Objects.requireNonNull(tenantId, "Null tenant identifier!"); - Objects.requireNonNull(tenantId, "Null AAI actions list!"); + Objects.requireNonNull(regionId, "Null regionId identifier!"); this.cloudIdentity = cloudIdentity; this.cloudOwner = cloudOwner; this.cloudRegionId = cloudRegionId; + this.regionId = regionId; this.tenantId = tenantId; this.resourcesClient = resourcesClient; this.transaction = resourcesClient.beginSingleTransaction(); } + public HeatBridgeImpl() { + this.resourcesClient = new AAIResourcesClient(); + this.transaction = resourcesClient.beginSingleTransaction(); + } + @Override public OpenstackClient authenticate() throws HeatBridgeException { this.osClient = new MsoCloudClientFactoryImpl(new OpenstackClientFactoryImpl()).getOpenstackClient( - cloudIdentity.getIdentityUrl(), cloudIdentity.getMsoId(), cloudIdentity.getMsoPass(), cloudRegionId, + cloudIdentity.getIdentityUrl(), cloudIdentity.getMsoId(), cloudIdentity.getMsoPass(), regionId, tenantId); - logger.debug("Successfully authenticated with keystone for tenant: " + tenantId + " and cloud " + "region: " - + cloudRegionId); + logger.debug("Successfully authenticated with keystone for tenant: " + tenantId + " and region: " + regionId); return osClient; } @@ -418,6 +427,78 @@ public class HeatBridgeImpl implements HeatBridgeApi { } } + @Override + public void deleteVfModuleData(@Nonnull final String vnfId, @Nonnull final String vfModuleId) + throws HeatBridgeException { + Objects.requireNonNull(vnfId, "Null vnf-id!"); + Objects.requireNonNull(vfModuleId, "Null vf-module-id!"); + try { + Optional<VfModule> vfModule = resourcesClient.get(VfModule.class, + AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId).depth(Depth.ONE)); + if (vfModule.isPresent()) { + + AAIResultWrapper resultWrapper = new AAIResultWrapper(vfModule); + Optional<Relationships> relationships = resultWrapper.getRelationships(); + if (relationships.isPresent()) { + List<AAIResourceUri> vserverUris = relationships.get().getRelatedUris(AAIObjectType.VSERVER); + createTransactionToDeleteSriovPfFromPserver(vserverUris); + if (!vserverUris.isEmpty()) { + for (AAIResourceUri vserverUri : vserverUris) { + resourcesClient.delete(vserverUri); + } + } + } + } + } catch (Exception e) { + String msg = "Failed to commit delete heatbridge data transaction"; + logger.debug(msg + " with error: " + e); + throw new HeatBridgeException(msg, e); + } + } + + private void createTransactionToDeleteSriovPfFromPserver(List<AAIResourceUri> vserverUris) { + Map<String, List<String>> pserverToPciIdMap = getPserverToPciIdMap(vserverUris); + for (Map.Entry<String, List<String>> entry : pserverToPciIdMap.entrySet()) { + String pserverName = entry.getKey(); + List<String> pciIds = entry.getValue(); + Optional<Pserver> pserver = resourcesClient.get(Pserver.class, + AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, pserverName).depth(Depth.TWO)); + if (pserver.isPresent()) { + // For each pserver/p-interface match sriov-vfs by pic-id and delete them. + pserver.get().getPInterfaces().getPInterface().stream().filter( + pIf -> pIf.getSriovPfs() != null && CollectionUtils.isNotEmpty(pIf.getSriovPfs().getSriovPf())) + .forEach(pIf -> pIf.getSriovPfs().getSriovPf().forEach(sriovPf -> { + if (pciIds.contains(sriovPf.getPfPciId())) { + logger.debug("creating transaction to delete SR-IOV PF: " + pIf.getInterfaceName() + + " from PServer: " + pserverName); + resourcesClient.delete(AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, + pserverName, pIf.getInterfaceName(), sriovPf.getPfPciId())); + } + })); + } + } + } + + private Map<String, List<String>> getPserverToPciIdMap(List<AAIResourceUri> vserverUris) { + Map<String, List<String>> pserverToPciIdMap = new HashMap<>(); + for (AAIResourceUri vserverUri : vserverUris) { + AAIResultWrapper vserverWrapper = resourcesClient.get(vserverUri.depth(Depth.TWO)); + Optional<Relationships> vserverRelationships = vserverWrapper.getRelationships(); + if (vserverRelationships.isPresent() + && CollectionUtils.isNotEmpty(vserverRelationships.get().getRelatedLinks(AAIObjectType.PSERVER))) { + Vserver vserver = vserverWrapper.asBean(Vserver.class).get(); + List<String> pciIds = HeatBridgeUtils.extractPciIdsFromVServer(vserver); + if (CollectionUtils.isNotEmpty(pciIds)) { + List<String> matchingPservers = vserverRelationships.get().getRelatedLinks(AAIObjectType.PSERVER); + if (matchingPservers != null && matchingPservers.size() == 1) { + pserverToPciIdMap.put(matchingPservers.get(0), pciIds); + } + } + } + } + return pserverToPciIdMap; + } + private <T> Predicate<T> distinctByProperty(Function<? super T, Object> keyExtractor) { Map<Object, Boolean> map = new ConcurrentHashMap<>(); return t -> map.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java index 018a4eac8d..e1f363ca05 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java @@ -47,13 +47,13 @@ public interface MsoCloudClientFactory { * @param url openstack url * @param msoId openstack user for mso * @param msoPass openstack password for mso user - * @param cloudRegionId cloud-region identifier + * @param regionId region identifier * @param tenantId tenant identifier * @return Openstack Client for the keystone version requested * @throws HeatBridgeException if any errors when reading cloud configuration or getting openstack client */ - OpenstackClient getOpenstackClient(String url, String msoId, String msoPass, String cloudRegionId, String tenantId) + OpenstackClient getOpenstackClient(String url, String msoId, String msoPass, String regionId, String tenantId) throws HeatBridgeException; } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java index f0c5a0b434..04245899aa 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java @@ -61,17 +61,17 @@ public class MsoCloudClientFactoryImpl implements MsoCloudClientFactory { @Override public OpenstackClient getOpenstackClient(@Nonnull String url, @Nonnull String msoId, @Nonnull String msoPass, - @Nonnull String cloudRegionId, @Nonnull String tenantId) throws HeatBridgeException { + @Nonnull String regionId, @Nonnull String tenantId) throws HeatBridgeException { Objects.requireNonNull(url, "Null openstack url!"); Objects.requireNonNull(msoId, "Null openstack user id!"); Objects.requireNonNull(msoPass, "Null openstack password!"); - Objects.requireNonNull(cloudRegionId, "Null cloud-region ID!"); + Objects.requireNonNull(regionId, "Null regionId ID!"); Objects.requireNonNull(tenantId, "Null tenant ID!"); try { final OpenstackAccess osAccess = new OpenstackAccessBuilder().setBaseUrl(url) // keystone URL .setUser(msoId) // keystone username .setPassword(CryptoUtils.decryptCloudConfigPassword(msoPass)) // keystone decrypted password - .setRegion(cloudRegionId) // openstack region + .setRegion(regionId) // openstack region .setDomainName(HeatBridgeConstants.OS_DEFAULT_DOMAIN_NAME) // hardcode to "default" .setTenantId(tenantId) // tenantId .build(); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java index be086677db..1667f980e1 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java @@ -35,10 +35,15 @@ package org.onap.so.heatbridge.utils; import com.google.common.base.Preconditions; import com.google.common.base.Strings; +import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; import javax.annotation.Nonnull; +import org.apache.commons.collections.CollectionUtils; +import org.onap.aai.domain.yang.SriovVf; +import org.onap.aai.domain.yang.Vserver; -public class HeatBridgeUtils { +public final class HeatBridgeUtils { /** * IaaS naming convention for compute/p-interface to openstack/physical-network name mapping @@ -64,4 +69,13 @@ public class HeatBridgeUtils { } return Optional.empty(); } + + public static List<String> extractPciIdsFromVServer(Vserver vserver) { + return vserver.getLInterfaces().getLInterface().stream() + .filter(lInterface -> lInterface.getSriovVfs() != null + && CollectionUtils.isNotEmpty(lInterface.getSriovVfs().getSriovVf())) + .flatMap(lInterface -> lInterface.getSriovVfs().getSriovVf().stream()).map(SriovVf::getPciId) + .collect(Collectors.toList()); + } + } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java index f3cad76c9d..01726acd54 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java @@ -484,7 +484,8 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl(); MsoRequest msoRequest = getMsoRequest(); try { - instance.deleteVfModule("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest, + instance.deleteVfModule("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", + "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest, new Holder<Map<String, String>>()); } catch (Exception e) { diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java index 16cc2c34de..e7ef9d9348 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java @@ -101,7 +101,8 @@ public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils { msoRequest.setRequestId("12345"); msoRequest.setServiceInstanceId("12345"); - instance.deleteVfModule("mtn13", "CloudOwner", "1234", "vfname", msoRequest, new Holder<>()); + instance.deleteVfModule("mtn13", "CloudOwner", "1234", "vfname", "5aae1e49-805c-4f9f-bd78-055bf7451157", + "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest, new Holder<>()); } @Test @@ -124,7 +125,8 @@ public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils { wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/tokens")) .willReturn(aResponse().withBodyFile("OpenstackResponse_Access.json").withStatus(HttpStatus.SC_OK))); - instance.deleteVfModule("mtn13", "CloudOwner", "1234", "vfname", msoRequest, new Holder<>()); + instance.deleteVfModule("mtn13", "CloudOwner", "1234", "vfname", "5aae1e49-805c-4f9f-bd78-055bf7451157", + "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest, new Holder<>()); } @Test diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java index 48ca0fd79c..0ac30cb75c 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java @@ -210,7 +210,8 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils { wireMockServer.stubFor(delete(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id")) .willReturn(aResponse().withStatus(HttpStatus.SC_NO_CONTENT))); - instance.deleteVfModule("MTN13", "CloudOwner", "123", "workload-id", msoRequest, new Holder<>()); + instance.deleteVfModule("MTN13", "CloudOwner", "123", "workload-id", "5aae1e49-805c-4f9f-bd78-055bf7451157", + "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest, new Holder<>()); } @Test diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java index 7ec8e51892..ede25c5dbe 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java @@ -134,7 +134,8 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils { expectedException.expect(VnfException.class); MsoRequest msoRequest = getMsoRequest(); msoVnfPluginAdapter.deleteVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", - msoRequest, new Holder<Map<String, String>>()); + "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest, + new Holder<Map<String, String>>()); } @Test @@ -151,7 +152,8 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils { .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR))); MsoRequest msoRequest = getMsoRequest(); msoVnfPluginAdapter.deleteVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", - msoRequest, new Holder<Map<String, String>>()); + "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest, + new Holder<Map<String, String>>()); } private MsoRequest getMsoRequest() { diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java index d611322c02..e2f5531280 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java @@ -112,7 +112,7 @@ public class HeatBridgeImplTest { public void setUp() throws HeatBridgeException, OpenstackClientException, BulkProcessFailed { when(resourcesClient.beginSingleTransaction()).thenReturn(transaction); - heatbridge = new HeatBridgeImpl(resourcesClient, cloudIdentity, CLOUD_OWNER, REGION_ID, TENANT_ID); + heatbridge = new HeatBridgeImpl(resourcesClient, cloudIdentity, CLOUD_OWNER, REGION_ID, REGION_ID, TENANT_ID); } @Ignore diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java index 701ed65d19..4eeb1c03a3 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java @@ -38,7 +38,7 @@ public class MsoCloudClientFactoryImplTest { private static final String MSO_ID = "testMsoId"; private static final String ENCRYPTED_PASSWORD = CryptoUtils.encryptCloudConfigPassword("testPassword"); - private static final String CLOUD_REGION_ID = "testCloudRegionId"; + private static final String REGION_ID = "testCloudRegionId"; private static final String TENANT_ID = "testTenantId"; private MsoCloudClientFactoryImpl testedObject; @@ -52,20 +52,19 @@ public class MsoCloudClientFactoryImplTest { @Test public void getOpenstackClientWithVersion2() throws Exception { - testedObject.getOpenstackClient(URL_V2, MSO_ID, ENCRYPTED_PASSWORD, CLOUD_REGION_ID, TENANT_ID); + testedObject.getOpenstackClient(URL_V2, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID); verify(openstackClientFactoryMock).createOpenstackV2Client(any(OpenstackAccess.class)); } @Test public void getOpenstackClientWithVersion3() throws Exception { - testedObject.getOpenstackClient(URL_V3, MSO_ID, ENCRYPTED_PASSWORD, CLOUD_REGION_ID, TENANT_ID); + testedObject.getOpenstackClient(URL_V3, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID); verify(openstackClientFactoryMock).createOpenstackV3Client(any(OpenstackAccess.class)); } @Test(expected = HeatBridgeException.class) public void getOpenstackClient_unsupportedVersion() throws Exception { - testedObject.getOpenstackClient(URL_WITH_UNSUPPORTED_VERSION, MSO_ID, ENCRYPTED_PASSWORD, CLOUD_REGION_ID, - TENANT_ID); + testedObject.getOpenstackClient(URL_WITH_UNSUPPORTED_VERSION, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID); } } diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql index 9406bc445d..6b791e789c 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql +++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql @@ -735,6 +735,8 @@ CREATE TABLE `orchestration_flow_reference` ( `SEQ_NO` int(11) NOT NULL, `FLOW_NAME` varchar(200) NOT NULL, `FLOW_VERSION` double NOT NULL, + `SCOPE` varchar(200) DEFAULT NULL, + `ACTION` varchar(200) DEFAULT NULL, `NB_REQ_REF_LOOKUP_ID` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `UK_orchestration_flow_reference` (`COMPOSITE_ACTION`,`FLOW_NAME`,`SEQ_NO`,`NB_REQ_REF_LOOKUP_ID`), @@ -806,6 +808,10 @@ CREATE TABLE `service` ( `OVERALL_DISTRIBUTION_STATUS` varchar(45), `ONAP_GENERATED_NAMING` TINYINT(1) DEFAULT NULL, `NAMING_POLICY` varchar(200) DEFAULT NULL, + `CDS_BLUEPRINT_NAME` varchar(200) DEFAULT NULL, + `CDS_BLUEPRINT_VERSION` varchar(20) DEFAULT NULL, + `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL, + `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true, PRIMARY KEY (`MODEL_UUID`), KEY `fk_service__tosca_csar1_idx` (`TOSCA_CSAR_ARTIFACT_UUID`), CONSTRAINT `fk_service__tosca_csar1` FOREIGN KEY (`TOSCA_CSAR_ARTIFACT_UUID`) REFERENCES `tosca_csar` (`ARTIFACT_UUID`) ON DELETE CASCADE ON UPDATE CASCADE @@ -960,6 +966,7 @@ CREATE TABLE `vf_module_customization` ( `CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `VF_MODULE_MODEL_UUID` varchar(200) NOT NULL, `VNF_RESOURCE_CUSTOMIZATION_ID` int(13) DEFAULT NULL, + `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true, PRIMARY KEY (`ID`), KEY `fk_vf_module_customization__vf_module1_idx` (`VF_MODULE_MODEL_UUID`), KEY `fk_vf_module_customization__heat_env__heat_environment1_idx` (`HEAT_ENVIRONMENT_ARTIFACT_UUID`), @@ -1111,6 +1118,7 @@ CREATE TABLE `vnf_resource_customization` ( `SERVICE_MODEL_UUID` varchar(200) NOT NULL, `NF_DATA_VALID` tinyint(1) DEFAULT '0', `VNFCINSTANCEGROUP_ORDER` varchar(200) default NULL, + `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL, PRIMARY KEY (`ID`), UNIQUE KEY `UK_vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`,`SERVICE_MODEL_UUID`), KEY `fk_vnf_resource_customization__vnf_resource1_idx` (`VNF_RESOURCE_MODEL_UUID`), @@ -1192,6 +1200,7 @@ CREATE TABLE IF NOT EXISTS `pnf_resource_customization` ( `CDS_BLUEPRINT_NAME` varchar(200) DEFAULT NULL, `CDS_BLUEPRINT_VERSION` varchar(20) DEFAULT NULL, `SKIP_POST_INSTANTIATION_CONFIGURATION` boolean default true, + `CONTROLLER_ACTOR` varchar(200) DEFAULT NULL, PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`), KEY `fk_pnf_resource_customization__pnf_resource1_idx` (`PNF_RESOURCE_MODEL_UUID`), CONSTRAINT `fk_pnf_resource_customization__pnf_resource1` FOREIGN KEY (`PNF_RESOURCE_MODEL_UUID`) REFERENCES `pnf_resource` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java index f4a9f711fd..110fc6c03e 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapter.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,6 +31,7 @@ import org.onap.so.db.request.beans.ResourceOperationStatus; /** * MSO Request DB Adapter Web Service */ +@Deprecated @WebService(name = "RequestsDbAdapter", targetNamespace = "http://org.onap.so/requestsdb") public interface MsoRequestsDbAdapter { diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java index 6ecf5dc3f0..085a255948 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java @@ -10,9 +10,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -45,6 +45,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; +@Deprecated @WebService(serviceName = "RequestsDbAdapter", endpointInterface = "org.onap.so.adapters.requestsdb.MsoRequestsDbAdapter", targetNamespace = "http://org.onap.so/requestsdb") @@ -129,7 +130,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { } catch (Exception e) { String error = "Error retrieving MSO Infra Requests DB for Request ID " + requestId; logger.error(error, e); - throw new MsoRequestsDbException(error, ErrorCode.BusinessProcesssError, e); + throw new MsoRequestsDbException(error, ErrorCode.BusinessProcessError, e); } } @@ -155,7 +156,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { } catch (Exception e) { String error = "Error retrieving MSO Infra Requests DB for Request ID " + requestId; logger.error(error, e); - throw new MsoRequestsDbException(error, ErrorCode.BusinessProcesssError, e); + throw new MsoRequestsDbException(error, ErrorCode.BusinessProcessError, e); } return request; } @@ -183,7 +184,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { /** * update operation status <br> - * + * * @param serviceId * @param operationId * @param operationType @@ -253,7 +254,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { /** * init the operation status of all the resources <br> - * + * * @param serviceId the service Id * @param operationId the operation Id * @param operationType the operationType @@ -284,7 +285,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { /** * get resource operation status <br> - * + * * @param serviceId * @param operationId * @param resourceTemplateUUID @@ -304,7 +305,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { /** * update resource operation status <br> - * + * * @param serviceId * @param operationId * @param resourceTemplateUUID @@ -340,7 +341,7 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter { /** * update service operation status when a operation resource status updated <br> - * + * * @param operStatus the resource operation status * @since ONAP Amsterdam Release */ diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java index 3a14b2ff84..0272bab1a1 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java @@ -22,7 +22,6 @@ package org.onap.so.adapters.requestsdb.application; -import java.time.Duration; import javax.sql.DataSource; import org.onap.logging.filter.base.Constants; import org.onap.logging.filter.base.ONAPComponents; @@ -34,8 +33,7 @@ import org.springframework.jmx.support.RegistrationPolicy; import org.springframework.scheduling.annotation.EnableScheduling; import net.javacrumbs.shedlock.core.LockProvider; import net.javacrumbs.shedlock.provider.jdbctemplate.JdbcTemplateLockProvider; -import net.javacrumbs.shedlock.spring.ScheduledLockConfiguration; -import net.javacrumbs.shedlock.spring.ScheduledLockConfigurationBuilder; +import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock; /** * @since Version 1.0 @@ -43,6 +41,7 @@ import net.javacrumbs.shedlock.spring.ScheduledLockConfigurationBuilder; */ @SpringBootApplication(scanBasePackages = {"org.onap.so", "org.onap.logging.filter"}) @EnableScheduling +@EnableSchedulerLock(defaultLockAtMostFor = "120s") @EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING) public class MSORequestDBApplication { @@ -66,10 +65,5 @@ public class MSORequestDBApplication { return new JdbcTemplateLockProvider(dataSource); } - @Bean - public ScheduledLockConfiguration taskScheduler(LockProvider lockProvider) { - return ScheduledLockConfigurationBuilder.withLockProvider(lockProvider).withPoolSize(10) - .withDefaultLockAtMostFor(Duration.ofMinutes(10)).build(); - } } diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.6__UpdateRequestProcessingData.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.6__UpdateRequestProcessingData.sql new file mode 100644 index 0000000000..70d1d3fd46 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.6__UpdateRequestProcessingData.sql @@ -0,0 +1,9 @@ +use requestdb; + +UPDATE request_processing_data +SET IS_DATA_INTERNAL = 1 +WHERE TAG = 'BPMNExecutionData'; + +UPDATE request_processing_data +SET IS_DATA_INTERNAL = 0 +WHERE TAG = 'StackInformation' OR TAG = 'pincFabricConfigRequest';
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestdb/rest/RequestProcessingDataRequestDbQueryTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestdb/rest/RequestProcessingDataRequestDbQueryTest.java index abc70ed6bf..9641cb8004 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestdb/rest/RequestProcessingDataRequestDbQueryTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestdb/rest/RequestProcessingDataRequestDbQueryTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -86,4 +86,28 @@ public class RequestProcessingDataRequestDbQueryTest { assertEquals(dataFound.get(1).getValue(), secondEntry.getValue()); assertEquals(dataFound.get(1).getTag(), secondEntry.getTag()); } + + @Test + @Transactional + public void testGetRequestProcessingDataBySoRequestIdAndIsInternalData() { + String soRequestId = "00032ab7-na18-42e5-965d-8ea592502018"; + String tag = "pincFabricConfigRequest"; + RequestProcessingData firstEntry = new RequestProcessingData(); + List<RequestProcessingData> expectedList = new ArrayList<>(); + firstEntry.setSoRequestId(soRequestId); + firstEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca715"); + firstEntry.setName("configurationId"); + firstEntry.setValue("52234bc0-d6a6-41d4-a901-79015e4877e2"); + firstEntry.setTag(tag); + expectedList.add(firstEntry); + + List<RequestProcessingData> dataFound = client.getExternalRequestProcessingDataBySoRequestId(soRequestId); + + assertEquals(1, dataFound.size()); + assertEquals(dataFound.get(0).getSoRequestId(), firstEntry.getSoRequestId()); + assertEquals(dataFound.get(0).getGroupingId(), firstEntry.getGroupingId()); + assertEquals(dataFound.get(0).getName(), firstEntry.getName()); + assertEquals(dataFound.get(0).getValue(), firstEntry.getValue()); + assertEquals(dataFound.get(0).getTag(), firstEntry.getTag()); + } } 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 92d3114ebe..eacd413df6 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 @@ -23,17 +23,14 @@ package org.onap.so.adapters.requestsdb.adapters; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import java.util.ArrayList; import java.util.List; -import java.util.Map; import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.adapters.requestsdb.MsoRequestsDbAdapter; import org.onap.so.adapters.requestsdb.RequestStatusType; import org.onap.so.adapters.requestsdb.RequestsAdapterBase; @@ -47,7 +44,6 @@ import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; import org.onap.so.requestsdb.RequestsDbConstant; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.server.LocalServerPort; -import ch.qos.logback.classic.spi.ILoggingEvent; public class MSORequestDBImplTest extends RequestsAdapterBase { @@ -423,28 +419,5 @@ public class MSORequestDBImplTest extends RequestsAdapterBase { ResourceOperationStatus actualResource = dbAdapter.getResourceOperationStatus(serviceId, operationId, "template1"); assertThat(actualResource, sameBeanAs(expectedResource)); - - for (ILoggingEvent logEvent : TestAppender.events) - if (logEvent.getLoggerName().equals("org.onap.so.logging.cxf.interceptor.SOAPLoggingInInterceptor") - && logEvent.getMarker().getName().equals("ENTRY")) { - Map<String, String> mdc = logEvent.getMDCPropertyMap(); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID)); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID)); - assertEquals("UNKNOWN", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME)); - assertEquals("/services/RequestsDbAdapter", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME)); - assertEquals("INPROGRESS", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); - } else if (logEvent.getLoggerName().equals("org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor") - && logEvent.getMarker().getName().equals("EXIT")) { - Map<String, String> mdc = logEvent.getMDCPropertyMap(); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID)); - assertEquals(null, mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE)); - assertEquals("UNKNOWN", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME)); - assertEquals("/services/RequestsDbAdapter", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME)); - assertEquals("COMPLETE", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); - } } - - } diff --git a/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql index a86065d76c..b34b272b51 100644 --- a/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql +++ b/adapters/mso-requests-db-adapter/src/test/resources/db/migration/afterMigrate.sql @@ -31,11 +31,11 @@ insert into watchdog_service_mod_ver_id_lookup(distribution_id, service_model_ve insert into site_status(site_name, status, creation_timestamp) values ('testsite', 0, '2017-11-30 15:48:09'); -INSERT INTO requestdb.request_processing_data (ID, SO_REQUEST_ID, GROUPING_ID, NAME, VALUE, TAG) +INSERT INTO requestdb.request_processing_data (ID, SO_REQUEST_ID, GROUPING_ID, NAME, VALUE, TAG, IS_DATA_INTERNAL) VALUES -(1, '00032ab7-na18-42e5-965d-8ea592502018', '7d2e8c07-4d10-456d-bddc-37abf38ca714', 'requestAction', 'assign', 'pincFabricConfigRequest'), -(2, '00032ab7-na18-42e5-965d-8ea592502018', '7d2e8c07-4d10-456d-bddc-37abf38ca715', 'configurationId', '52234bc0-d6a6-41d4-a901-79015e4877e2', 'pincFabricConfigRequest'), -(3, '5ffbabd6-b793-4377-a1ab-082670fbc7ac', '5ffbabd6-b793-4377-a1ab-082670fbc7ac', 'configId', '52234bc0-d6a6-41d4-a901-79015e4877e2', 'pincFabricConfig'); +(1, '00032ab7-na18-42e5-965d-8ea592502018', '7d2e8c07-4d10-456d-bddc-37abf38ca714', 'requestAction', 'assign', 'pincFabricConfigRequest', 1), +(2, '00032ab7-na18-42e5-965d-8ea592502018', '7d2e8c07-4d10-456d-bddc-37abf38ca715', 'configurationId', '52234bc0-d6a6-41d4-a901-79015e4877e2', 'pincFabricConfigRequest', 0), +(3, '5ffbabd6-b793-4377-a1ab-082670fbc7ac', '5ffbabd6-b793-4377-a1ab-082670fbc7ac', 'configId', '52234bc0-d6a6-41d4-a901-79015e4877e2', 'pincFabricConfig', 1); INSERT INTO activate_operational_env_service_model_distribution_status (OPERATIONAL_ENV_ID, SERVICE_MODEL_VERSION_ID, REQUEST_ID,SERVICE_MOD_VER_FINAL_DISTR_STATUS,RECOVERY_ACTION,RETRY_COUNT_LEFT,WORKLOAD_CONTEXT, CREATE_TIME, MODIFY_TIME, VNF_OPERATIONAL_ENV_ID) VALUES diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterApplication.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterApplication.java index fc6d0a6fc9..55a05436f0 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterApplication.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterApplication.java @@ -23,7 +23,9 @@ package org.onap.so.adapters.sdnc; import java.util.concurrent.Executor; +import org.onap.logging.filter.base.Constants; import org.onap.logging.filter.spring.MDCTaskDecorator; +import org.onap.so.utils.Components; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -52,6 +54,7 @@ public class SDNCAdapterApplication { } public static void main(String[] args) { + System.setProperty(Constants.Property.PARTNER_NAME, Components.SDNC_ADAPTER.toString()); SpringApplication.run(SDNCAdapterApplication.class, args); System.getProperties().setProperty("server.name", "Springboot"); setLogsDir(); diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java index 012a19f1a9..a8418ea901 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java @@ -178,7 +178,7 @@ public class SDNCRestClient { return (sdncResp); } catch (Exception e) { logger.error(LoggingAnchor.FOUR, MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC.toString(), "SDNC", - ErrorCode.BusinessProcesssError.getValue(), "Exception processing request to SDNC", e); + ErrorCode.BusinessProcessError.getValue(), "Exception processing request to SDNC", e); // default sdncResp.setRespCode(HttpURLConnection.HTTP_INTERNAL_ERROR); String respMsg = "Error processing request to SDNC. "; @@ -246,7 +246,7 @@ public class SDNCRestClient { } // is != null } catch (Exception e1) { logger.error(LoggingAnchor.FOUR, MessageEnum.RA_ERROR_GET_RESPONSE_SDNC.toString(), "SDNC", - ErrorCode.BusinessProcesssError.getValue(), "Exception while get SDNC response", e1); + ErrorCode.BusinessProcessError.getValue(), "Exception while get SDNC response", e1); } } // con != null @@ -312,7 +312,7 @@ public class SDNCRestClient { headers.put("Authorization", Collections.singletonList(basicAuth)); } catch (Exception e2) { logger.error(LoggingAnchor.FOUR, MessageEnum.RA_SET_CALLBACK_AUTH_EXC.toString(), CAMUNDA, - ErrorCode.BusinessProcesssError.getValue(), + ErrorCode.BusinessProcessError.getValue(), "Exception - Unable to set authorization in callback request", e2); } @@ -322,7 +322,7 @@ public class SDNCRestClient { } catch (Exception e) { error = "Error sending BpelCallback request" + e.getMessage(); - logger.error("Error {} - {} - {}", ErrorCode.BusinessProcesssError.getValue(), + logger.error("Error {} - {} - {}", ErrorCode.BusinessProcessError.getValue(), MessageEnum.RA_CALLBACK_BPEL_EXC.toString(), error, e); } logger.info(MessageEnum.RA_CALLBACK_BPEL_COMPLETE.name(), CAMUNDA); diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java index 1c47a2d6b0..f710988886 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java @@ -99,7 +99,7 @@ public class Utils { } catch (Exception e) { logger.error(LoggingAnchor.FOUR, MessageEnum.RA_ERROR_CREATE_SDNC_REQUEST.toString(), "SDNC", - ErrorCode.BusinessProcesssError.getValue(), "Exception in genSdncReq", e); + ErrorCode.BusinessProcessError.getValue(), "Exception in genSdncReq", e); } return null; } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java index b50662a832..631be2f9ff 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java @@ -24,27 +24,30 @@ package org.onap.so.adapters.sdnc.sdncrest; +import java.net.URI; import javax.xml.bind.DatatypeConverter; -import org.onap.so.logger.LoggingAnchor; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.util.EntityUtils; -import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.onap.logging.filter.spring.SpringClientPayloadFilter; import org.onap.so.adapters.sdnc.impl.Constants; import org.onap.so.logger.ErrorCode; +import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; +import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; +import org.onap.so.utils.CryptoUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.onap.so.utils.CryptoUtils; -import org.slf4j.MDC; import org.springframework.core.env.Environment; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.http.client.BufferingClientHttpRequestFactory; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.stereotype.Component; +import org.springframework.web.client.HttpStatusCodeException; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponentsBuilder; /** * Sends asynchronous messages to the BPMN WorkflowMessage service. @@ -95,81 +98,72 @@ public class BPRestCallback { logger.info(LoggingAnchor.THREE, MessageEnum.RA_CALLBACK_BPEL.toString(), message == null ? "[no content]" : message, CAMUNDA); - - HttpPost method = null; - HttpResponse httpResponse = null; - try { int timeout = 60 * 1000; + RestTemplate restTemplate = setRestTemplate(timeout); - RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(timeout).setConnectTimeout(timeout) - .setConnectionRequestTimeout(timeout).build(); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); - HttpClient client = HttpClientBuilder.create().build(); - method = new HttpPost(url); - method.setConfig(requestConfig); - - if (message != null) { - method.setEntity(new StringEntity(message, ContentType.APPLICATION_JSON)); - } - - boolean error = false; - - try { - String userCredentials = CryptoUtils.decrypt(env.getProperty(Constants.BPEL_AUTH_PROP), - env.getProperty(Constants.ENCRYPTION_KEY_PROP)); - String authorization = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); - method.setHeader("Authorization", authorization); - method.setHeader(ONAPLogConstants.Headers.REQUEST_ID, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID)); - method.setHeader(ONAPLogConstants.Headers.INVOCATION_ID, MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID)); - method.setHeader(ONAPLogConstants.Headers.PARTNER_NAME, "SO-SDNCAdapter"); - } catch (Exception e) { - logger.error(LoggingAnchor.FOUR, MessageEnum.RA_SET_CALLBACK_AUTH_EXC.toString(), CAMUNDA, - ErrorCode.BusinessProcesssError.getValue(), "Unable to set authorization in callback request", - e); - error = true; - } + boolean error = setAuthorizationHeader(headers); + HttpEntity<String> requestEntity = new HttpEntity<>(message, headers); if (!error) { - httpResponse = client.execute(method); - - @SuppressWarnings("unused") - String responseContent = null; - - if (httpResponse.getEntity() != null) { - responseContent = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); - } - - if (httpResponse.getStatusLine().getStatusCode() >= 300) { - String msg = "Received error response to callback request: " + httpResponse.getStatusLine(); - logger.error(LoggingAnchor.FOUR, MessageEnum.RA_CALLBACK_BPEL_EXC.toString(), CAMUNDA, - ErrorCode.BusinessProcesssError.getValue(), msg); - - } + postRequest(restTemplate, url, requestEntity); } + logger.info(LoggingAnchor.TWO, MessageEnum.RA_CALLBACK_BPEL_COMPLETE.toString(), CAMUNDA); return true; } catch (Exception e) { logger.error(LoggingAnchor.FOUR, MessageEnum.RA_CALLBACK_BPEL_EXC.toString(), CAMUNDA, - ErrorCode.BusinessProcesssError.getValue(), "Error sending callback request", e); + ErrorCode.BusinessProcessError.getValue(), "Error sending callback request", e); return false; - } finally { - if (httpResponse != null) { - try { - EntityUtils.consume(httpResponse.getEntity()); - httpResponse = null; - } catch (Exception e) { - logger.debug("Exception:", e); - } - } + } + } - if (method != null) { - try { - method.reset(); - } catch (Exception e) { - logger.debug("Exception:", e); - } - } - logger.info(LoggingAnchor.TWO, MessageEnum.RA_CALLBACK_BPEL_COMPLETE.toString(), CAMUNDA); + protected boolean setAuthorizationHeader(HttpHeaders headers) { + boolean error = false; + try { + String userCredentials = CryptoUtils.decrypt(env.getProperty(Constants.BPEL_AUTH_PROP), + env.getProperty(Constants.ENCRYPTION_KEY_PROP)); + String authorization = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); + headers.set("Authorization", authorization); + } catch (Exception e) { + logger.error(LoggingAnchor.FOUR, MessageEnum.RA_SET_CALLBACK_AUTH_EXC.toString(), CAMUNDA, + ErrorCode.BusinessProcessError.getValue(), "Unable to set authorization in callback request", e); + error = true; + } + return error; + } + + private void postRequest(RestTemplate restTemplate, String url, HttpEntity<String> requestEntity) { + ResponseEntity<String> response = null; + try { + UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(url); + URI uri = builder.build(true).toUri(); + response = restTemplate.postForEntity(uri, requestEntity, String.class); + } catch (HttpStatusCodeException e) { + logResponseError(e.getStatusCode()); + } + if (response != null && response.getStatusCode().is3xxRedirection()) { + logResponseError(response.getStatusCode()); } } + + private void logResponseError(HttpStatus statusCode) { + String msg = "Received error response to callback request: " + statusCode; + logger.error(LoggingAnchor.FOUR, MessageEnum.RA_CALLBACK_BPEL_EXC.toString(), CAMUNDA, + ErrorCode.BusinessProcessError.getValue(), msg); + } + + protected RestTemplate setRestTemplate(int timeout) { + RestTemplate restTemplate = new RestTemplate(); + HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(); + factory.setConnectionRequestTimeout(timeout); + factory.setReadTimeout(timeout); + factory.setConnectTimeout(timeout); + restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(factory)); + restTemplate.getInterceptors().add(new SOSpringClientFilter()); + restTemplate.getInterceptors().add((new SpringClientPayloadFilter())); + return restTemplate; + } } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java index 5697ed56a5..50c8a089df 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java @@ -185,7 +185,7 @@ public class SDNCServiceRequestTask { addTextChild(agnosticServiceInformation, "anydata", anydata); } catch (Exception e) { logger.error(LoggingAnchor.FOUR, MessageEnum.RA_ERROR_CREATE_SDNC_REQUEST.toString(), "SDNC", - ErrorCode.BusinessProcesssError.getValue(), "Exception in genSdncReq", e); + ErrorCode.BusinessProcessError.getValue(), "Exception in genSdncReq", e); return null; } diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackUnitTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackUnitTest.java new file mode 100644 index 0000000000..09089890ab --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallbackUnitTest.java @@ -0,0 +1,142 @@ +package org.onap.so.adapters.sdnc.sdncrest; + + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; +import java.io.IOException; +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Paths; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.adapters.sdnc.impl.Constants; +import org.springframework.core.env.Environment; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.HttpServerErrorException; +import org.springframework.web.client.ResourceAccessException; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponentsBuilder; + +@RunWith(MockitoJUnitRunner.class) +public class BPRestCallbackUnitTest { + @Mock + private Environment env; + + @Mock + private RestTemplate restTemplate; + + @Spy + @InjectMocks + private BPRestCallback bpRestCallback; + + private HttpEntity<String> requestEntity; + private String message; + private HttpHeaders headers; + private URI uri; + + @Before + public void setUp() throws IOException { + headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + message = input("BPRestCallbackRequest.json"); + requestEntity = new HttpEntity<>(message, headers); + UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("http://localhost:8000/sdnc"); + uri = builder.build(true).toUri(); + } + + public String input(String JsonInput) throws IOException { + JsonInput = "src/test/resources/" + JsonInput; + return new String(Files.readAllBytes(Paths.get(JsonInput))); + } + + @Test + public void sendTest() throws IOException { + ResponseEntity<String> postResponse = new ResponseEntity<String>("response", HttpStatus.OK); + doReturn(restTemplate).when(bpRestCallback).setRestTemplate(60000); + doReturn(false).when(bpRestCallback).setAuthorizationHeader(headers); + when(restTemplate.postForEntity(uri, requestEntity, String.class)).thenReturn(postResponse); + boolean response = bpRestCallback.send("http://localhost:8000/sdnc", message); + assertTrue(response); + } + + @Test + public void sendNoAuthHeaderTest() throws IOException { + doReturn(true).when(bpRestCallback).setAuthorizationHeader(headers); + doReturn(restTemplate).when(bpRestCallback).setRestTemplate(60000); + boolean response = bpRestCallback.send("http://localhost:8000/sdnc", message); + assertTrue(response); + } + + @Test + public void sendErrorTest() throws IOException { + doReturn(false).when(bpRestCallback).setAuthorizationHeader(headers); + doReturn(restTemplate).when(bpRestCallback).setRestTemplate(60000); + when(restTemplate.postForEntity(uri, requestEntity, String.class)) + .thenThrow(new HttpServerErrorException(HttpStatus.INTERNAL_SERVER_ERROR, null, null, null)); + boolean response = bpRestCallback.send("http://localhost:8000/sdnc", message); + assertTrue(response); + } + + @Test + public void sendResponse3xxTest() throws IOException { + ResponseEntity<String> postResponse = new ResponseEntity<String>("response", HttpStatus.MULTIPLE_CHOICES); + doReturn(false).when(bpRestCallback).setAuthorizationHeader(headers); + doReturn(restTemplate).when(bpRestCallback).setRestTemplate(60000); + when(restTemplate.postForEntity(uri, requestEntity, String.class)).thenReturn(postResponse); + boolean response = bpRestCallback.send("http://localhost:8000/sdnc", message); + assertTrue(response); + } + + @Test + public void sendResponseNullMessageTest() throws IOException { + HttpHeaders httpHeaders = new HttpHeaders(); + httpHeaders.setContentType(MediaType.APPLICATION_JSON); + HttpEntity<String> requestEntityNoMessage = new HttpEntity<>(null, httpHeaders); + ResponseEntity<String> postResponse = new ResponseEntity<String>("response", HttpStatus.OK); + doReturn(false).when(bpRestCallback).setAuthorizationHeader(httpHeaders); + doReturn(restTemplate).when(bpRestCallback).setRestTemplate(60000); + when(restTemplate.postForEntity(uri, requestEntityNoMessage, String.class)).thenReturn(postResponse); + boolean response = bpRestCallback.send("http://localhost:8000/sdnc", null); + assertTrue(response); + } + + @Test + public void postThrowsExceptionTest() throws IOException { + doReturn(false).when(bpRestCallback).setAuthorizationHeader(headers); + doReturn(restTemplate).when(bpRestCallback).setRestTemplate(60000); + when(restTemplate.postForEntity(uri, requestEntity, String.class)) + .thenThrow(new ResourceAccessException("ResourceAccessException")); + boolean response = bpRestCallback.send("http://localhost:8000/sdnc", message); + assertFalse(response); + } + + @Test + public void setAuthorizationHeaderTest() { + HttpHeaders authHeaders = new HttpHeaders(); + when(env.getProperty(Constants.BPEL_AUTH_PROP)) + .thenReturn("5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C"); + when(env.getProperty(Constants.ENCRYPTION_KEY_PROP)).thenReturn("07a7159d3bf51a0e53be7a8f89699be7"); + boolean result = bpRestCallback.setAuthorizationHeader(authHeaders); + assertFalse(result); + } + + @Test + public void setAuthorizationHeaderErrorTest() { + HttpHeaders authHeaders = new HttpHeaders(); + when(env.getProperty(Constants.BPEL_AUTH_PROP)).thenReturn("test"); + when(env.getProperty(Constants.ENCRYPTION_KEY_PROP)).thenReturn("test"); + boolean result = bpRestCallback.setAuthorizationHeader(authHeaders); + assertTrue(result); + } +} diff --git a/adapters/mso-sdnc-adapter/src/test/resources/BPRestCallbackRequest.json b/adapters/mso-sdnc-adapter/src/test/resources/BPRestCallbackRequest.json new file mode 100644 index 0000000000..21f3dab7e0 --- /dev/null +++ b/adapters/mso-sdnc-adapter/src/test/resources/BPRestCallbackRequest.json @@ -0,0 +1 @@ +{"SDNCServiceResponse":{"sdncRequestId":"b5b763aa-0d8a-4438-b900-83af45d21d10","responseCode":"200","ackFinalIndicator":"N"}}
\ No newline at end of file diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java index e8b4cfd997..5b50f776cc 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/JsonUtil.java @@ -85,7 +85,7 @@ public class JsonUtil { return MAPPER.readValue(jsonstr, type); } catch (IOException e) { logger.error(LoggingAnchor.THREE, MessageEnum.RA_NS_EXC.toString(), - ErrorCode.BusinessProcesssError.getValue(), UNMARSHAL_FAIL_MSG, e); + ErrorCode.BusinessProcessError.getValue(), UNMARSHAL_FAIL_MSG, e); throw new ApplicationException(HttpCode.BAD_REQUEST, UNMARSHAL_FAIL_MSG); } } @@ -103,7 +103,7 @@ public class JsonUtil { return MAPPER.readValue(jsonstr, type); } catch (IOException e) { logger.error(LoggingAnchor.THREE, MessageEnum.RA_NS_EXC.toString(), - ErrorCode.BusinessProcesssError.getValue(), UNMARSHAL_FAIL_MSG, e); + ErrorCode.BusinessProcessError.getValue(), UNMARSHAL_FAIL_MSG, e); throw new ApplicationException(HttpCode.BAD_REQUEST, UNMARSHAL_FAIL_MSG); } } @@ -120,7 +120,7 @@ public class JsonUtil { return MAPPER.writeValueAsString(srcObj); } catch (IOException e) { logger.error(LoggingAnchor.THREE, MessageEnum.RA_NS_EXC.toString(), - ErrorCode.BusinessProcesssError.getValue(), "fail to marshal json", e); + ErrorCode.BusinessProcessError.getValue(), "fail to marshal json", e); throw new ApplicationException(HttpCode.BAD_REQUEST, "srcObj marshal failed!"); } } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml index 9d9e33a524..f828a12c8b 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml +++ b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml @@ -105,5 +105,9 @@ <artifactId>okio</artifactId> <version>1.13.0</version> </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> </dependencies> </project> diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml index 784c39c906..8e2cfd2be4 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml +++ b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml @@ -110,6 +110,26 @@ </configOptions> </configuration> </execution> + <execution> + <id>etsicatalog-api</id> + <goals> + <goal>generate</goal> + </goals> + <configuration> + <inputSpec>${basedir}/src/main/resources/ETSI-Catalog-API.json</inputSpec> + <language>java</language> + <library>okhttp-gson</library> + <output>${project.build.directory}/generated-sources/etsicatalog</output> + <apiPackage>org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.api</apiPackage> + <modelPackage>org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model</modelPackage> + <configOptions> + <sourceFolder>src/gen/java/main</sourceFolder> + <withXml>true</withXml> + <useRxJava2>true</useRxJava2> + <serializableModel>true</serializableModel> + </configOptions> + </configuration> + </execution> </executions> </plugin> </plugins> diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/ETSI-Catalog-API.json b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/ETSI-Catalog-API.json new file mode 100644 index 0000000000..514029bab8 --- /dev/null +++ b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/ETSI-Catalog-API.json @@ -0,0 +1,3102 @@ +{ + "swagger": "2.0", + "info": { + "title": "Modeling etsicatalog API", + "description": "\n\nThe `swagger-ui` view can be found [here](/api/catalog/v1/swagger).\nThe `ReDoc` view can be found [here](/api/catalog/v1/redoc).\nThe swagger YAML document can be found [here](/api/catalog/v1/swagger.yaml).\nThe swagger JSON document can be found [here](/api/catalog/v1/swagger.json).", + "version": "v1" + }, + "host": "127.0.0.1:8000", + "schemes": ["http"], + "basePath": "/", + "consumes": ["application/json"], + "produces": ["application/json"], + "securityDefinitions": { + "Basic": { + "type": "basic" + } + }, + "security": [{ + "Basic": [] + }], + "paths": { + "/api/catalog/v1/callback_sample": { + "get": { + "operationId": "api_catalog_v1_callback_sample_list", + "description": "Callback Sample.", + "parameters": [], + "responses": { + "200": { + "description": "" + } + }, + "tags": ["Sample interface"] + }, + "parameters": [] + }, + "/api/catalog/v1/health_check": { + "get": { + "operationId": "api_catalog_v1_health_check_list", + "description": "", + "parameters": [], + "responses": { + "200": { + "description": "Active" + } + }, + "tags": ["Health Check interface"] + }, + "parameters": [] + }, + "/api/catalog/v1/jobs/{job_id}": { + "get": { + "operationId": "api_catalog_v1_jobs_read", + "description": "Get job status", + "parameters": [{ + "name": "job_id", + "in": "query", + "description": "job id", + "type": "string" + }, { + "name": "responseId", + "in": "query", + "description": "response id", + "type": "string" + }], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/GetJobResponse" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/PostJobResponseResult" + } + } + }, + "tags": ["Catalog interface"] + }, + "post": { + "operationId": "api_catalog_v1_jobs_create", + "description": "Update job status", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PostJobRequest" + } + }, { + "name": "job_id", + "in": "query", + "description": "job id", + "type": "string" + }], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/PostJobResponseResult" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/PostJobResponseResult" + } + } + }, + "tags": ["Catalog interface"] + }, + "parameters": [{ + "name": "job_id", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/catalog/v1/mandb/{modelName}": { + "get": { + "operationId": "api_catalog_v1_mandb_read", + "description": "", + "parameters": [], + "responses": { + "200": { + "description": "" + } + }, + "tags": ["Sample interface"] + }, + "delete": { + "operationId": "api_catalog_v1_mandb_delete", + "description": "", + "parameters": [], + "responses": { + "204": { + "description": "" + } + }, + "tags": ["Sample interface"] + }, + "parameters": [{ + "name": "modelName", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/catalog/v1/nspackages": { + "get": { + "operationId": "api_catalog_v1_nspackages_list", + "description": "Query NS packages", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/NsPackage" + } + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "tags": ["Catalog interface"] + }, + "post": { + "operationId": "api_catalog_v1_nspackages_create", + "description": "On distribute NS package", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/NsPackageDistributeRequest" + } + }], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/NsPackageDistributeResponse" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "tags": ["Catalog interface"] + }, + "parameters": [] + }, + "/api/catalog/v1/nspackages/{csarId}": { + "get": { + "operationId": "api_catalog_v1_nspackages_read", + "description": "Query one NS package", + "parameters": [{ + "name": "csarId", + "in": "query", + "description": "csarId", + "type": "string" + }], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/NsPackage" + } + }, + "500": { + "description": "error message", + "schema": { + "type": "string" + } + } + }, + "tags": ["Catalog interface"] + }, + "delete": { + "operationId": "api_catalog_v1_nspackages_delete", + "description": "Delete one NS package", + "parameters": [{ + "name": "csarId", + "in": "query", + "description": "csarId", + "type": "string" + }], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/NsPackageDistributeResponse" + } + }, + "500": { + "description": "error message", + "schema": { + "type": "string" + } + } + }, + "tags": ["Catalog interface"] + }, + "parameters": [{ + "name": "csarId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/catalog/v1/service_packages": { + "get": { + "operationId": "api_catalog_v1_service_packages_list", + "description": "Query Service packages", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/ServicePackage" + } + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "tags": ["Catalog interface"] + }, + "post": { + "operationId": "api_catalog_v1_service_packages_create", + "description": "On distribute Service package", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ServicePackageDistributeRequest" + } + }], + "responses": { + "202": { + "description": "" + }, + "400": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "tags": ["Catalog interface"] + }, + "parameters": [] + }, + "/api/catalog/v1/service_packages/{csarId}": { + "get": { + "operationId": "api_catalog_v1_service_packages_read", + "description": "Query one Service package", + "parameters": [{ + "name": "csarId", + "in": "query", + "description": "csarId", + "type": "string" + }], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/ServicePackage" + } + }, + "404": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "tags": ["Catalog interface"] + }, + "delete": { + "operationId": "api_catalog_v1_service_packages_delete", + "description": "Delete one Service package", + "parameters": [{ + "name": "csarId", + "in": "query", + "description": "csarId", + "type": "string" + }], + "responses": { + "204": { + "description": "" + }, + "404": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "tags": ["Catalog interface"] + }, + "parameters": [{ + "name": "csarId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/catalog/v1/vnfpackages": { + "get": { + "operationId": "api_catalog_v1_vnfpackages_list", + "description": "Query Nf packages", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/NfPackage" + } + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "tags": ["Catalog interface"] + }, + "post": { + "operationId": "api_catalog_v1_vnfpackages_create", + "description": "On distribute Nf package", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/NfPackageDistributeRequest" + } + }], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/PostJobResponse" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "tags": ["Catalog interface"] + }, + "parameters": [] + }, + "/api/catalog/v1/vnfpackages/{csarId}": { + "get": { + "operationId": "api_catalog_v1_vnfpackages_read", + "description": "Query one Nf package", + "parameters": [{ + "name": "csarId", + "in": "query", + "description": "csarId", + "type": "string" + }], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/NfPackage" + } + }, + "500": { + "description": "error message", + "schema": { + "type": "string" + } + } + }, + "tags": ["Catalog interface"] + }, + "delete": { + "operationId": "api_catalog_v1_vnfpackages_delete", + "description": "Delete one Nf package", + "parameters": [{ + "name": "csarId", + "in": "query", + "description": "csarId", + "type": "string" + }], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/PostJobResponse" + } + }, + "500": { + "description": "error message", + "schema": { + "type": "string" + } + } + }, + "tags": ["Catalog interface"] + }, + "parameters": [{ + "name": "csarId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/nsd/v1/health_check": { + "get": { + "operationId": "api_nsd_v1_health_check_list", + "description": "", + "parameters": [], + "responses": { + "200": { + "description": "Active" + } + }, + "tags": ["Health Check interface"] + }, + "parameters": [] + }, + "/api/nsd/v1/ns_descriptors": { + "get": { + "operationId": "api_nsd_v1_ns_descriptors_list", + "description": "Query multiple NSDs", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/NsdInfo" + } + } + }, + "500": { + "description": "Internal error" + } + }, + "tags": ["NSD Management interface"] + }, + "post": { + "operationId": "api_nsd_v1_ns_descriptors_create", + "description": "Create a NSD", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateNsdInfoRequest" + } + }], + "responses": { + "201": { + "description": "", + "schema": { + "$ref": "#/definitions/NsdInfo" + } + }, + "500": { + "description": "Internal error" + } + }, + "tags": ["NSD Management interface"] + }, + "parameters": [] + }, + "/api/nsd/v1/ns_descriptors/{nsdInfoId}": { + "get": { + "operationId": "api_nsd_v1_ns_descriptors_read", + "description": "Query a NSD", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/NsdInfo" + } + }, + "404": { + "description": "NSDs do not exist" + }, + "500": { + "description": "Internal error" + } + }, + "tags": ["NSD Management interface"] + }, + "delete": { + "operationId": "api_nsd_v1_ns_descriptors_delete", + "description": "Delete a NSD", + "parameters": [], + "responses": { + "204": { + "description": "No content" + }, + "500": { + "description": "Internal error" + } + }, + "tags": ["NSD Management interface"] + }, + "parameters": [{ + "name": "nsdInfoId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/nsd/v1/ns_descriptors/{nsdInfoId}/nsd_content": { + "get": { + "operationId": "api_nsd_v1_ns_descriptors_nsd_content_list", + "description": "Download NSD content", + "parameters": [], + "responses": { + "204": { + "description": "No content" + }, + "404": { + "description": "NSD does not exist." + }, + "500": { + "description": "Internal error" + } + }, + "tags": ["NSD Management interface"] + }, + "put": { + "operationId": "api_nsd_v1_ns_descriptors_nsd_content_update", + "description": "Upload NSD content", + "parameters": [], + "responses": { + "204": { + "description": "PNFD file" + }, + "500": { + "description": "Internal error" + } + }, + "tags": ["NSD Management interface"] + }, + "parameters": [{ + "name": "nsdInfoId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/nsd/v1/pnf_descriptors": { + "get": { + "operationId": "api_nsd_v1_pnf_descriptors_list", + "description": "Query multiple PNFDs", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/PnfdInfo" + } + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + } + }, + "tags": ["NSD Management interface"] + }, + "post": { + "operationId": "api_nsd_v1_pnf_descriptors_create", + "description": "Create a PNFD", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreatePnfdInfoRequest" + } + }], + "responses": { + "201": { + "description": "", + "schema": { + "$ref": "#/definitions/PnfdInfo" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + } + }, + "tags": ["NSD Management interface"] + }, + "parameters": [] + }, + "/api/nsd/v1/pnf_descriptors/{pnfdInfoId}": { + "get": { + "operationId": "api_nsd_v1_pnf_descriptors_read", + "description": "Query a PNFD", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/PnfdInfo" + } + }, + "404": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + } + }, + "tags": ["NSD Management interface"] + }, + "delete": { + "operationId": "api_nsd_v1_pnf_descriptors_delete", + "description": "Delete a PNFD", + "parameters": [], + "responses": { + "204": { + "description": "No content" + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + } + }, + "tags": ["NSD Management interface"] + }, + "parameters": [{ + "name": "pnfdInfoId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/nsd/v1/pnf_descriptors/{pnfdInfoId}/pnfd_content": { + "get": { + "operationId": "Fetch PNFD content", + "description": "Fetch PNFD content", + "parameters": [], + "responses": { + "200": { + "description": "PNFD file", + "schema": { + "type": "string", + "format": "binary" + } + }, + "404": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + } + }, + "tags": ["NSD Management interface"] + }, + "put": { + "operationId": "api_nsd_v1_pnf_descriptors_pnfd_content_update", + "description": "Upload PNFD content", + "parameters": [], + "responses": { + "204": { + "description": "No content" + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + } + }, + "tags": ["NSD Management interface"] + }, + "parameters": [{ + "name": "pnfdInfoId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/nsd/v1/subscriptions": { + "get": { + "operationId": "api_nsd_v1_subscriptions_list", + "description": "Query subscriptions for Nsd Management", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/NsdmSubscription" + } + } + }, + "400": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + }, + "404": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + } + }, + "tags": ["NSD Management interface"] + }, + "post": { + "operationId": "api_nsd_v1_subscriptions_create", + "description": "Create Subscription for NSD Management", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/NsdmSubscriptionRequest" + } + }], + "responses": { + "201": { + "description": "", + "schema": { + "$ref": "#/definitions/NsdmSubscription" + } + }, + "303": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + }, + "400": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + } + }, + "tags": ["NSD Management interface"] + }, + "parameters": [] + }, + "/api/nsd/v1/subscriptions/{subscriptionId}": { + "get": { + "operationId": "api_nsd_v1_subscriptions_read", + "description": "Query subscriptions for Nsd Management", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/NsdmSubscription" + } + }, + "400": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + }, + "404": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + } + }, + "tags": ["NSD Management interface"] + }, + "delete": { + "operationId": "api_nsd_v1_subscriptions_delete", + "description": "Delete subscription for Nsd Management", + "parameters": [], + "responses": { + "204": { + "description": "No_Content" + }, + "400": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + }, + "404": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + } + }, + "tags": ["NSD Management interface"] + }, + "parameters": [{ + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/parser/v1/health_check": { + "get": { + "operationId": "api_parser_v1_health_check_list", + "description": "", + "parameters": [], + "responses": { + "200": { + "description": "Active" + } + }, + "tags": ["Health Check interface"] + }, + "parameters": [] + }, + "/api/parser/v1/parser": { + "post": { + "operationId": "api_parser_v1_parser_create", + "description": "Parse model(NS, Service, VNF, PNF)", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ParseModelRequest" + } + }], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/ParseModelResponse" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "tags": ["Parser interface"] + }, + "parameters": [] + }, + "/api/parser/v1/parsernsd": { + "post": { + "operationId": "api_parser_v1_parsernsd_create", + "description": "Parse NS model", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ParseModelRequest" + } + }], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/ParseModelResponse" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "tags": ["Parser interface"] + }, + "parameters": [] + }, + "/api/parser/v1/parserpnfd": { + "post": { + "operationId": "api_parser_v1_parserpnfd_create", + "description": "Parse PNF model", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ParseModelRequest" + } + }], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/ParseModelResponse" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "tags": ["Parser interface"] + }, + "parameters": [] + }, + "/api/parser/v1/parservnfd": { + "post": { + "operationId": "api_parser_v1_parservnfd_create", + "description": "Parse NF model", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ParseModelRequest" + } + }], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/ParseModelResponse" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "tags": ["Parser interface"] + }, + "parameters": [] + }, + "/api/vnfpkgm/v1/health_check": { + "get": { + "operationId": "api_vnfpkgm_v1_health_check_list", + "description": "", + "parameters": [], + "responses": { + "200": { + "description": "Active" + } + }, + "tags": ["Health Check interface"] + }, + "parameters": [] + }, + "/api/vnfpkgm/v1/subscriptions": { + "get": { + "operationId": "api_vnfpkgm_v1_subscriptions_list", + "description": "", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/PkgmSubscription" + } + }, + "400": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + } + }, + "tags": ["VNF Package Management interface"] + }, + "post": { + "operationId": "api_vnfpkgm_v1_subscriptions_create", + "description": "", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PkgmSubscriptionRequest" + } + }], + "responses": { + "201": { + "description": "", + "schema": { + "$ref": "#/definitions/PkgmSubscription" + } + }, + "500": { + "description": "Internal error" + } + }, + "tags": ["VNF Package Management interface"] + }, + "parameters": [] + }, + "/api/vnfpkgm/v1/subscriptions/{subscriptionId}": { + "get": { + "operationId": "api_vnfpkgm_v1_subscriptions_read", + "description": "", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/PkgmSubscription" + } + }, + "404": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + } + }, + "tags": ["VNF Package Management interface"] + }, + "delete": { + "operationId": "api_vnfpkgm_v1_subscriptions_delete", + "description": "", + "parameters": [], + "responses": { + "204": { + "description": "" + }, + "404": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/SUBSCRIPTION_ProblemDetailsSerializer" + } + } + }, + "tags": ["VNF Package Management interface"] + }, + "parameters": [{ + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/vnfpkgm/v1/vnf_packages": { + "get": { + "operationId": "api_vnfpkgm_v1_vnf_packages_list", + "description": "Query multiple VNF package resource", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/VnfPkgInfo" + } + } + }, + "500": { + "description": "Internal error", + "schema": { + "type": "string" + } + } + }, + "tags": ["VNF Package Management interface"] + }, + "post": { + "operationId": "api_vnfpkgm_v1_vnf_packages_create", + "description": "Create an individual VNF package resource", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateVnfPkgInfoRequest" + } + }], + "responses": { + "201": { + "description": "", + "schema": { + "$ref": "#/definitions/VnfPkgInfo" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "string" + } + }, + "500": { + "description": "Internal error", + "schema": { + "type": "string" + } + } + }, + "tags": ["VNF Package Management interface"] + }, + "parameters": [] + }, + "/api/vnfpkgm/v1/vnf_packages/{vnfPkgId}": { + "get": { + "operationId": "api_vnfpkgm_v1_vnf_packages_read", + "description": "Query an individual VNF package resource", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/VnfPkgInfo" + } + }, + "404": { + "description": "VNF package does not exist", + "schema": { + "type": "string" + } + }, + "500": { + "description": "Internal error", + "schema": { + "type": "string" + } + } + }, + "tags": ["VNF Package Management interface"] + }, + "delete": { + "operationId": "api_vnfpkgm_v1_vnf_packages_delete", + "description": "Delete an individual VNF package resource", + "parameters": [], + "responses": { + "204": { + "description": "No content" + }, + "500": { + "description": "Internal error", + "schema": { + "type": "string" + } + } + }, + "tags": ["VNF Package Management interface"] + }, + "parameters": [{ + "name": "vnfPkgId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/vnfpkgm/v1/vnf_packages/{vnfPkgId}/artifacts/{artifactPath}": { + "get": { + "operationId": "api_vnfpkgm_v1_vnf_packages_artifacts_read", + "description": "", + "parameters": [], + "responses": { + "200": { + "description": "Return the artifact file", + "schema": { + "type": "string", + "format": "binary" + } + }, + "404": { + "description": "Artifact not found", + "schema": { + "type": "string" + } + }, + "500": { + "description": "Internal error", + "schema": { + "type": "string" + } + } + }, + "tags": ["VNF Package Management interface"] + }, + "parameters": [{ + "name": "artifactPath", + "in": "path", + "required": true, + "type": "string" + }, { + "name": "vnfPkgId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/vnfpkgm/v1/vnf_packages/{vnfPkgId}/package_content": { + "get": { + "operationId": "api_vnfpkgm_v1_vnf_packages_package_content_list", + "description": "Fetch VNF package content", + "parameters": [], + "responses": { + "200": { + "description": "VNF package file", + "schema": { + "type": "string", + "format": "binary" + } + }, + "404": { + "description": "VNF package does not exist", + "schema": { + "type": "string" + } + }, + "500": { + "description": "Internal error", + "schema": { + "type": "string" + } + } + }, + "tags": ["VNF Package Management interface"] + }, + "put": { + "operationId": "api_vnfpkgm_v1_vnf_packages_package_content_update", + "description": "Upload VNF package content", + "parameters": [], + "responses": { + "202": { + "description": "Successfully" + }, + "500": { + "description": "Internal error", + "schema": { + "type": "string" + } + } + }, + "tags": ["VNF Package Management interface"] + }, + "parameters": [{ + "name": "vnfPkgId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/vnfpkgm/v1/vnf_packages/{vnfPkgId}/package_content/upload_from_uri": { + "post": { + "operationId": "api_vnfpkgm_v1_vnf_packages_package_content_upload_from_uri_create", + "description": "Upload VNF package content from uri", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UploadVnfPackageFromUriRequest" + } + }], + "responses": { + "202": { + "description": "Successfully" + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "string" + } + }, + "500": { + "description": "Internal error", + "schema": { + "type": "string" + } + } + }, + "tags": ["VNF Package Management interface"] + }, + "parameters": [{ + "name": "vnfPkgId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/vnfpkgm/v1/vnf_packages/{vnfPkgId}/vnfd": { + "get": { + "operationId": "VNFD of an on-boarded VNF package", + "description": "Read VNFD of an on-boarded VNF package", + "parameters": [], + "responses": { + "200": { + "description": "VNFD of an on-boarded VNF package", + "schema": { + "type": "string", + "format": "binary" + } + }, + "404": { + "description": "VNF package does not exist", + "schema": { + "type": "string" + } + }, + "500": { + "description": "Internal error", + "schema": { + "type": "string" + } + } + }, + "tags": ["VNF Package Management interface"] + }, + "parameters": [{ + "name": "vnfPkgId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/samples/": { + "get": { + "operationId": "samples_list", + "description": "List all samples.", + "parameters": [], + "responses": { + "200": { + "description": "" + } + }, + "tags": ["Sample interface"] + }, + "parameters": [] + } + }, + "definitions": { + "JobResponseHistoryList": { + "description": "Response History List", + "type": "object", + "properties": { + "status": { + "title": "Status", + "description": "Status", + "type": "string", + "minLength": 1 + }, + "progress": { + "title": "Progress", + "description": "Job Progress", + "type": "string", + "minLength": 1 + }, + "statusDescription": { + "title": "Statusdescription", + "description": "Status Description", + "type": "string", + "minLength": 1 + }, + "errorCode": { + "title": "Errorcode", + "description": "Error Code", + "type": "string", + "minLength": 1, + "x-nullable": true + }, + "responseId": { + "title": "Responseid", + "description": "Response Id", + "type": "string", + "minLength": 1 + } + } + }, + "JobResponseDescriptor": { + "title": "Responsedescriptor", + "description": "Job Response Descriptor", + "type": "object", + "properties": { + "status": { + "title": "Status", + "description": "Status", + "type": "string", + "minLength": 1 + }, + "progress": { + "title": "Progress", + "description": "Job Progress", + "type": "string", + "minLength": 1 + }, + "statusDescription": { + "title": "Statusdescription", + "description": "Status Description", + "type": "string", + "minLength": 1 + }, + "errorCode": { + "title": "Errorcode", + "description": "Error Code", + "type": "string", + "minLength": 1, + "x-nullable": true + }, + "responseId": { + "title": "Responseid", + "description": "Response Id", + "type": "string", + "minLength": 1 + }, + "responseHistoryList": { + "description": "Response History List", + "type": "array", + "items": { + "$ref": "#/definitions/JobResponseHistoryList" + } + } + } + }, + "GetJobResponse": { + "type": "object", + "properties": { + "jobId": { + "title": "Jobid", + "description": "Job Id", + "type": "string", + "minLength": 1 + }, + "responseDescriptor": { + "$ref": "#/definitions/JobResponseDescriptor" + } + } + }, + "PostJobResponseResult": { + "required": ["result"], + "type": "object", + "properties": { + "result": { + "title": "Result", + "description": "Result", + "type": "string", + "minLength": 1 + }, + "msg": { + "title": "Msg", + "description": "Message", + "type": "string", + "minLength": 1 + } + } + }, + "PostJobRequest": { + "type": "object", + "properties": { + "progress": { + "title": "Progress", + "description": "Job Progress", + "type": "string", + "minLength": 1 + }, + "desc": { + "title": "Desc", + "description": "Description", + "type": "string", + "minLength": 1 + }, + "errcode": { + "title": "Errcode", + "description": "Error Code", + "type": "string", + "minLength": 1 + } + } + }, + "NsPackageInfo": { + "title": "Packageinfo", + "description": "NS Package Info", + "type": "object", + "properties": { + "nsdId": { + "title": "Nsdid", + "description": "NSD ID", + "type": "string", + "minLength": 1, + "x-nullable": true + }, + "nsPackageId": { + "title": "Nspackageid", + "description": "NS Package ID", + "type": "string", + "x-nullable": true + }, + "nsdProvider": { + "title": "Nsdprovider", + "description": "NSD Provider", + "type": "string", + "x-nullable": true + }, + "nsdVersion": { + "title": "Nsdversion", + "description": "NSD Version", + "type": "string", + "x-nullable": true + }, + "csarName": { + "title": "Csarname", + "description": "CSAR name", + "type": "string", + "x-nullable": true + }, + "nsdModel": { + "title": "Nsdmodel", + "description": "NSD Model", + "type": "string", + "x-nullable": true + }, + "downloadUrl": { + "title": "Downloadurl", + "description": "URL to download NSD Model", + "type": "string", + "minLength": 1, + "x-nullable": true + } + }, + "x-nullable": true + }, + "NsPackage": { + "type": "object", + "properties": { + "csarId": { + "title": "Csarid", + "description": "CSAR ID", + "type": "string", + "minLength": 1, + "x-nullable": true + }, + "packageInfo": { + "$ref": "#/definitions/NsPackageInfo" + } + } + }, + "InternalErrorRequest": { + "required": ["error"], + "type": "object", + "properties": { + "error": { + "title": "Error", + "description": "Error", + "type": "string", + "minLength": 1 + }, + "errorMessage": { + "title": "Errormessage", + "description": "Error Message", + "type": "string", + "minLength": 1 + } + } + }, + "NsPackageDistributeRequest": { + "required": ["csarId"], + "type": "object", + "properties": { + "csarId": { + "title": "Csarid", + "description": "csarId", + "type": "string", + "minLength": 1 + } + } + }, + "NsPackageDistributeResponse": { + "required": ["status", "statusDescription", "errorCode"], + "type": "object", + "properties": { + "status": { + "title": "Status", + "description": "status", + "type": "string", + "minLength": 1 + }, + "statusDescription": { + "title": "Statusdescription", + "description": "statusDescription", + "type": "string", + "minLength": 1 + }, + "errorCode": { + "title": "Errorcode", + "description": "errorCode", + "type": "string", + "minLength": 1 + } + } + }, + "ServicePackageInfo": { + "title": "Packageinfo", + "description": "Service Package Info", + "type": "object", + "properties": { + "servicedId": { + "title": "Servicedid", + "description": "ServiceD ID", + "type": "string", + "minLength": 1, + "x-nullable": true + }, + "servicePackageId": { + "title": "Servicepackageid", + "description": "Service Package ID", + "type": "string", + "x-nullable": true + }, + "servicedProvider": { + "title": "Servicedprovider", + "description": "ServiceD Provider", + "type": "string", + "x-nullable": true + }, + "servicedVersion": { + "title": "Servicedversion", + "description": "ServiceD Version", + "type": "string", + "x-nullable": true + }, + "csarName": { + "title": "Csarname", + "description": "CSAR name", + "type": "string", + "x-nullable": true + }, + "servicedModel": { + "title": "Servicedmodel", + "description": "ServiceD Model", + "type": "string", + "x-nullable": true + }, + "downloadUrl": { + "title": "Downloadurl", + "description": "URL to download ServiceD Model", + "type": "string", + "minLength": 1, + "x-nullable": true + } + }, + "x-nullable": true + }, + "ServicePackage": { + "type": "object", + "properties": { + "csarId": { + "title": "Csarid", + "description": "CSAR ID", + "type": "string", + "minLength": 1, + "x-nullable": true + }, + "packageInfo": { + "$ref": "#/definitions/ServicePackageInfo" + } + } + }, + "ServicePackageDistributeRequest": { + "required": ["csarId"], + "type": "object", + "properties": { + "csarId": { + "title": "Csarid", + "description": "csarId", + "type": "string", + "minLength": 1 + } + } + }, + "NfPackageInfo": { + "title": "Packageinfo", + "description": "VNF Package Info", + "required": ["vnfPackageId"], + "type": "object", + "properties": { + "vnfdId": { + "title": "Vnfdid", + "description": "VNFD ID", + "type": "string", + "x-nullable": true + }, + "vnfPackageId": { + "title": "Vnfpackageid", + "description": "VNF Package ID", + "type": "string", + "minLength": 1 + }, + "vnfdProvider": { + "title": "Vnfdprovider", + "description": "VNFD Provider", + "type": "string", + "x-nullable": true + }, + "vnfdVersion": { + "title": "Vnfdversion", + "description": "VNFD Version", + "type": "string", + "x-nullable": true + }, + "vnfVersion": { + "title": "Vnfversion", + "description": "VNF Version", + "type": "string", + "x-nullable": true + }, + "csarName": { + "title": "Csarname", + "description": "CSAR Name", + "type": "string", + "x-nullable": true + }, + "vnfdModel": { + "title": "Vnfdmodel", + "description": "VNFD Model", + "type": "string", + "x-nullable": true + }, + "downloadUrl": { + "title": "Downloadurl", + "description": "URL to download VNFD Model", + "type": "string", + "x-nullable": true + } + } + }, + "NfImageInfo": { + "description": "Image Info", + "required": ["index", "fileName", "imageId", "vimId", "vimUser", "tenant", "status"], + "type": "object", + "properties": { + "index": { + "title": "Index", + "description": "Index of VNF Image", + "type": "string", + "minLength": 1 + }, + "fileName": { + "title": "Filename", + "description": "Image file name", + "type": "string", + "minLength": 1 + }, + "imageId": { + "title": "Imageid", + "description": "Image ID", + "type": "string", + "minLength": 1 + }, + "vimId": { + "title": "Vimid", + "description": "VIM ID", + "type": "string", + "minLength": 1 + }, + "vimUser": { + "title": "Vimuser", + "description": "User of VIM", + "type": "string", + "minLength": 1 + }, + "tenant": { + "title": "Tenant", + "description": "Tenant", + "type": "string", + "minLength": 1 + }, + "status": { + "title": "Status", + "description": "Status", + "type": "string", + "minLength": 1 + } + } + }, + "NfPackage": { + "required": ["csarId", "packageInfo"], + "type": "object", + "properties": { + "csarId": { + "title": "Csarid", + "description": "CSAR ID", + "type": "string", + "minLength": 1 + }, + "packageInfo": { + "$ref": "#/definitions/NfPackageInfo" + }, + "imageInfo": { + "description": "Image Info", + "type": "array", + "items": { + "$ref": "#/definitions/NfImageInfo" + }, + "x-nullable": true + } + } + }, + "NfPackageDistributeRequest": { + "required": ["csarId"], + "type": "object", + "properties": { + "csarId": { + "title": "Csarid", + "description": "CSAR ID", + "type": "string", + "minLength": 1 + }, + "vimIds": { + "description": "A string for vimIds", + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + }, + "labVimId": { + "title": "Labvimid", + "description": "A list of VIM IDs.", + "type": "string" + } + } + }, + "PostJobResponse": { + "required": ["jobId"], + "type": "object", + "properties": { + "jobId": { + "title": "Jobid", + "description": "jobId", + "type": "string", + "minLength": 1 + } + } + }, + "ProblemDetails": { + "title": "Onboardingfailuredetails", + "description": "Failure details of current onboarding procedure.It shall be present when the nsdOnboardingState attribute is CREATED and the uploading or processing fails in NFVO.", + "required": ["title", "detail"], + "type": "object", + "properties": { + "type": { + "title": "Type", + "description": "A URI reference according to IETF RFC 3986 [10] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".", + "type": "string", + "x-nullable": true + }, + "title": { + "title": "Title", + "description": "The HTTP status code for this occurrence of the problem.", + "type": "integer" + }, + "detail": { + "title": "Detail", + "description": "A human-readable explanation specific to this occurrence of the problem.", + "type": "string", + "minLength": 1 + }, + "instance": { + "title": "Instance", + "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.", + "type": "string", + "x-nullable": true + }, + "additional_attributes": { + "title": "Additional attributes", + "description": "Any number of additional attributes, as defined in a specification or by an implementation.", + "type": "object", + "additionalProperties": { + "description": "Additional attribute", + "type": "string" + }, + "x-nullable": true + } + } + }, + "UriLink": { + "title": "Self", + "description": "URI of this resource.", + "required": ["href"], + "type": "object", + "properties": { + "href": { + "title": "Href", + "description": "URI of the referenced resource", + "type": "string", + "minLength": 1 + } + } + }, + "NSD_LinkSerializer": { + "title": " links", + "description": "Links to resources related to this resource.", + "required": ["self", "nsd_content"], + "type": "object", + "properties": { + "self": { + "$ref": "#/definitions/UriLink" + }, + "nsd_content": { + "$ref": "#/definitions/UriLink" + } + } + }, + "NsdInfo": { + "required": ["id", "nsdOnboardingState", "nsdOperationalState", "nsdUsageState", "_links"], + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "Identifier of the onboarded individual NS descriptor resource.This identifier is allocated by the NFVO.", + "type": "string", + "minLength": 1 + }, + "nsdId": { + "title": "Nsdid", + "description": "This identifier, which is allocated by the NSD designer,identifies the NSD in a globally unique way.It is copied from the NSD content and shall be present after the NSD content is on-boarded.", + "type": "string", + "x-nullable": true + }, + "nsdName": { + "title": "Nsdname", + "description": "Name of the onboarded NSD.This information is copied from the NSD content and shall be present after the NSD content is on-boarded.", + "type": "string", + "x-nullable": true + }, + "nsdVersion": { + "title": "Nsdversion", + "description": "Version of the on-boarded NSD.This information is copied from the NSD content and shall be present after the NSD content is on-boarded.", + "type": "string", + "x-nullable": true + }, + "nsdDesigner": { + "title": "Nsddesigner", + "description": "Designer of the on-boarded NSD.This information is copied from the NSD content and shall be present after the NSD content is on-boarded.", + "type": "string", + "x-nullable": true + }, + "nsdInvariantId": { + "title": "Nsdinvariantid", + "description": "This identifier, which is allocated by the NSD designer,identifies an NSD in a version independent manner.This information is copied from the NSD content and shall be present after the NSD content is on-boarded.", + "type": "string", + "x-nullable": true + }, + "vnfPkgIds": { + "description": "Identifies the VNF package for the VNFD referenced by the on-boarded NS descriptor resource.", + "type": "array", + "items": { + "description": "Identifier of the VNF package", + "type": "string" + }, + "x-nullable": true + }, + "pnfdInfoIds": { + "description": "Identifies the PnfdInfo element for the PNFD referenced by the on-boarded NS descriptor resource.", + "type": "array", + "items": { + "description": "Identifier of the PnfdInfo element", + "type": "string" + }, + "x-nullable": true + }, + "nestedNsdInfoIds": { + "description": "Identifies the NsdInfo element for the nested NSD referenced by the on-boarded NS descriptor resource.", + "type": "array", + "items": { + "description": "Identifier of the NsdInfo element", + "type": "string" + }, + "x-nullable": true + }, + "nsdOnboardingState": { + "title": "Nsdonboardingstate", + "description": "Onboarding state of the individual NS descriptor resource.", + "type": "string", + "enum": ["CREATED", "UPLOADING", "PROCESSING", "ONBOARDED"] + }, + "onboardingFailureDetails": { + "$ref": "#/definitions/ProblemDetails" + }, + "nsdOperationalState": { + "title": "Nsdoperationalstate", + "description": "Operational state of the individual NS descriptor resource.This attribute can be modified with the PATCH method.", + "type": "string", + "enum": ["ENABLED", "DISABLED"] + }, + "nsdUsageState": { + "title": "Nsdusagestate", + "description": "Usage state of the individual NS descriptor resource.", + "type": "string", + "enum": ["IN_USE", "NOT_IN_USE"] + }, + "userDefinedData": { + "title": "Userdefineddata", + "description": "User defined data for the individual NS descriptor resource.This attribute can be modified with the PATCH method.", + "type": "object", + "additionalProperties": { + "description": "Key Value Pairs", + "type": "string" + }, + "x-nullable": true + }, + "_links": { + "$ref": "#/definitions/NSD_LinkSerializer" + } + } + }, + "CreateNsdInfoRequest": { + "type": "object", + "properties": { + "userDefinedData": { + "title": "Userdefineddata", + "description": "User-defined data for the NS descriptor resource to be created.It shall be present when the user defined data is set for the individual NS descriptor resource to be created.", + "type": "object", + "additionalProperties": { + "description": "Key Value Pairs", + "type": "string" + }, + "x-nullable": true + } + } + }, + "PNFD_LinkSerializer": { + "title": " links", + "description": "Links to resources related to this resource.", + "required": ["self", "pnfd_content"], + "type": "object", + "properties": { + "self": { + "$ref": "#/definitions/UriLink" + }, + "pnfd_content": { + "$ref": "#/definitions/UriLink" + } + } + }, + "PnfdInfo": { + "required": ["id", "pnfdOnboardingState", "pnfdUsageState", "_links"], + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "Identifier of the onboarded individual PNF descriptor resource. This identifier is allocated by the NFVO.", + "type": "string", + "minLength": 1 + }, + "pnfdId": { + "title": "Pnfdid", + "description": "This identifier, which is allocated by the PNFD designer, identifies the PNFD in a globally unique way. It is copied from the PNFD content and shall be present after the PNFD content is on-boarded.", + "type": "string", + "x-nullable": true + }, + "pnfdName": { + "title": "Pnfdname", + "description": "Name of the onboarded PNFD. This information is copied from the PNFD content and shall be present after the PNFD content is on-boarded.", + "type": "string", + "x-nullable": true + }, + "pnfdVersion": { + "title": "Pnfdversion", + "description": "Version of the on-boarded PNFD. This information is copied from the PNFD content and shall be present after the PNFD content is on-boarded.", + "type": "string", + "x-nullable": true + }, + "pnfdProvider": { + "title": "Pnfdprovider", + "description": "Provider of the on-boarded PNFD. This information is copied from the PNFD content and shall be present after the PNFD content is on-boarded.", + "type": "string", + "x-nullable": true + }, + "pnfdInvariantId": { + "title": "Pnfdinvariantid", + "description": "Identifies a PNFD in a version independent manner. This attribute is invariant across versions of PNFD.", + "type": "string", + "x-nullable": true + }, + "pnfdOnboardingState": { + "title": "Pnfdonboardingstate", + "description": "Onboarding state of the individual PNF descriptor resource.", + "type": "string", + "enum": ["CREATED", "UPLOADING", "PROCESSING", "ONBOARDED"] + }, + "onboardingFailureDetails": { + "$ref": "#/definitions/ProblemDetails" + }, + "pnfdUsageState": { + "title": "Pnfdusagestate", + "description": "Usage state of the individual PNF descriptor resource.", + "type": "string", + "enum": ["IN_USE", "NOT_IN_USE"] + }, + "userDefinedData": { + "title": "Userdefineddata", + "description": "User defined data for the individual PNF descriptor resource. This attribute can be modified with the PATCH method.", + "type": "object", + "additionalProperties": { + "description": "Key Value Pairs", + "type": "string" + }, + "x-nullable": true + }, + "_links": { + "$ref": "#/definitions/PNFD_LinkSerializer" + } + } + }, + "SUBSCRIPTION_ProblemDetailsSerializer": { + "required": ["status", "detail"], + "type": "object", + "properties": { + "type": { + "title": "Type", + "description": "Type", + "type": "string", + "minLength": 1, + "x-nullable": true + }, + "title": { + "title": "Title", + "description": "Title", + "type": "string", + "minLength": 1, + "x-nullable": true + }, + "status": { + "title": "Status", + "description": "Status", + "type": "integer" + }, + "detail": { + "title": "Detail", + "description": "Detail", + "type": "string", + "minLength": 1 + }, + "instance": { + "title": "Instance", + "description": "Instance", + "type": "string", + "minLength": 1, + "x-nullable": true + }, + "additional_details": { + "description": "Any number of additional attributes, as defined in a specification or by an implementation.", + "type": "array", + "items": { + "type": "string" + }, + "x-nullable": true + } + } + }, + "CreatePnfdInfoRequest": { + "type": "object", + "properties": { + "userDefinedData": { + "title": "Userdefineddata", + "description": "User-defined data for the PNF descriptor resource to be created.It shall be present when the user defined data is set for the individual PNF descriptor resource to be created.", + "type": "object", + "additionalProperties": { + "description": "Key Value Pairs", + "type": "string" + }, + "x-nullable": true + } + } + }, + "NsdmNotificationsFilter": { + "title": "Filter", + "description": "Filter settings for this subscription, to define the of all notifications this subscription relates to.", + "type": "object", + "properties": { + "notificationTypes": { + "description": "Match particular notification types", + "type": "array", + "items": { + "type": "string", + "enum": ["NsdOnBoardingNotification", "NsdOnboardingFailureNotification", "NsdChangeNotification", "NsdDeletionNotification", "PnfdOnBoardingNotification", "PnfdOnBoardingFailureNotification", "PnfdDeletionNotification"] + } + }, + "nsdInfoId": { + "description": "Match NS packages with particular nsdInfoIds", + "type": "array", + "items": { + "type": "string", + "format": "uuid" + } + }, + "nsdId": { + "description": "Match NS Packages with particular nsdIds", + "type": "array", + "items": { + "type": "string", + "format": "uuid" + } + }, + "nsdName": { + "description": "Match NS Packages with particular nsdNames", + "type": "array", + "items": { + "type": "string", + "maxLength": 255, + "minLength": 1 + } + }, + "nsdVersion": { + "description": "match NS packages that belong to certain nsdversion", + "type": "array", + "items": { + "type": "string", + "maxLength": 255, + "minLength": 1 + } + }, + "nsdInvariantId": { + "description": "Match NS Packages with particular nsdInvariantIds", + "type": "array", + "items": { + "type": "string", + "format": "uuid" + } + }, + "vnfPkgIds": { + "description": "Match NS Packages that has VNF PackageIds", + "type": "array", + "items": { + "type": "string", + "format": "uuid" + } + }, + "nestedNsdInfoIds": { + "description": "Match NS Packages with particular nsdInvariantIds", + "type": "array", + "items": { + "type": "string", + "format": "uuid" + } + }, + "nsdOnboardingState": { + "description": "Match NS Packages with particular NS Onboarding State", + "type": "array", + "items": { + "type": "string", + "enum": ["CREATED", "UPLOADING", "PROCESSING", "ONBOARDED"] + } + }, + "nsdOperationalState": { + "description": "Match NS Packages with particular NS Operational State", + "type": "array", + "items": { + "type": "string", + "enum": ["ENABLED", "DISABLED"] + } + }, + "nsdUsageState": { + "description": "Match NS Packages with particular NS Usage State", + "type": "array", + "items": { + "type": "string", + "enum": ["IN_USE", "NOT_IN_USE"] + } + }, + "pnfdInfoIds": { + "description": "Match PF packages with particular pnfdInfoIds", + "type": "array", + "items": { + "type": "string", + "format": "uuid" + } + }, + "pnfdId": { + "description": "Match PF packages with particular pnfdInfoIds", + "type": "array", + "items": { + "type": "string", + "format": "uuid" + } + }, + "pnfdName": { + "description": "Match PF Packages with particular pnfdNames", + "type": "array", + "items": { + "type": "string", + "maxLength": 255, + "minLength": 1 + } + }, + "pnfdVersion": { + "description": "match PF packages that belong to certain pnfd version", + "type": "array", + "items": { + "type": "string", + "maxLength": 255, + "minLength": 1 + } + }, + "pnfdProvider": { + "description": "Match PF Packages with particular pnfdProvider", + "type": "array", + "items": { + "type": "string", + "maxLength": 255, + "minLength": 1 + } + }, + "pnfdInvariantId": { + "description": "Match PF Packages with particular pnfdInvariantIds", + "type": "array", + "items": { + "type": "string", + "format": "uuid" + } + }, + "pnfdOnboardingState": { + "description": "Match PF Packages with particular PNF Onboarding State ", + "type": "array", + "items": { + "type": "string", + "enum": ["CREATED", "UPLOADING", "PROCESSING", "ONBOARDED"] + } + }, + "pnfdUsageState": { + "description": "Match PF Packages with particular PNF usage State", + "type": "array", + "items": { + "type": "string", + "enum": ["IN_USE", "NOT_IN_USE"] + } + } + } + }, + "NSDM_SUB_LinkSerializer": { + "title": " links", + "description": "Links to resources related to this resource.", + "required": ["self"], + "type": "object", + "properties": { + "self": { + "$ref": "#/definitions/UriLink" + } + } + }, + "NsdmSubscription": { + "required": ["id", "callbackUri", "_links"], + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "Identifier of this subscription resource.", + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "callbackUri": { + "title": "Callbackuri", + "description": "The URI of the endpoint to send the notification to.", + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "filter": { + "$ref": "#/definitions/NsdmNotificationsFilter" + }, + "_links": { + "$ref": "#/definitions/NSDM_SUB_LinkSerializer" + } + } + }, + "BasicAuth": { + "title": "Paramsbasic", + "description": "Parameters for authentication/authorization using BASIC.", + "type": "object", + "properties": { + "userName": { + "title": "Username", + "description": "Username to be used in HTTP Basic authentication.", + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "password": { + "title": "Password", + "description": "Password to be used in HTTP Basic authentication.", + "type": "string", + "maxLength": 255, + "minLength": 1 + } + } + }, + "OAuthCredentials": { + "title": "Paramsoauth2clientcredentials", + "description": "Parameters for authentication/authorization using OAUTH2_CLIENT_CREDENTIALS.", + "type": "object", + "properties": { + "clientId": { + "title": "Clientid", + "description": "Client identifier to be used in the access token request of the OAuth 2.0 client credentials grant type.", + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "clientPassword": { + "title": "Clientpassword", + "description": "Client password to be used in the access token request of the OAuth 2.0 client credentials grant type.", + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "tokenEndpoint": { + "title": "Tokenendpoint", + "description": "The token endpoint from which the access token can be obtained.", + "type": "string", + "maxLength": 255, + "minLength": 1 + } + } + }, + "SubscriptionAuthentication": { + "title": "Authentication", + "description": "Authentication parameters to configure the use of Authorization when sending notifications corresponding to this subscription.", + "required": ["authType"], + "type": "object", + "properties": { + "authType": { + "description": "Defines the types of Authentication / Authorization which the API consumer is willing to accept when receiving a notification.", + "type": "array", + "items": { + "type": "string", + "enum": ["BASIC", "OAUTH2_CLIENT_CREDENTIALS", "TLS_CERT"] + } + }, + "paramsBasic": { + "$ref": "#/definitions/BasicAuth" + }, + "paramsOauth2ClientCredentials": { + "$ref": "#/definitions/OAuthCredentials" + } + } + }, + "NsdmSubscriptionRequest": { + "required": ["callbackUri"], + "type": "object", + "properties": { + "callbackUri": { + "title": "Callbackuri", + "description": "The URI of the endpoint to send the notification to.", + "type": "string", + "minLength": 1 + }, + "filter": { + "$ref": "#/definitions/NsdmNotificationsFilter" + }, + "authentication": { + "$ref": "#/definitions/SubscriptionAuthentication" + } + } + }, + "ParseModelRequest": { + "required": ["csarId"], + "type": "object", + "properties": { + "csarId": { + "title": "Csarid", + "description": "CSAR ID", + "type": "string", + "minLength": 1 + }, + "packageType": { + "title": "Packagetype", + "description": "Package type: VNF, PNF, NS, Service", + "type": "string", + "minLength": 1 + }, + "inputs": { + "title": "Inputs", + "description": "Inputs", + "type": "string" + } + } + }, + "ParseModelResponse": { + "required": ["model"], + "type": "object", + "properties": { + "model": { + "title": "Model", + "description": "Model", + "type": "string" + } + } + }, + "VNF_SUBSCRIPTION_LINKSERIALIZER": { + "title": "Self", + "description": "URI of this resource.", + "required": ["href"], + "type": "object", + "properties": { + "href": { + "title": "Href", + "description": "URI of the referenced resource.", + "type": "string", + "minLength": 1 + } + } + }, + "LinkSelf": { + "title": " links", + "description": "Links to resources related to this resource.", + "required": ["self"], + "type": "object", + "properties": { + "self": { + "$ref": "#/definitions/VNF_SUBSCRIPTION_LINKSERIALIZER" + } + } + }, + "Version": { + "title": "Versions", + "description": "match VNF packages that contain VNF products with certain versions", + "required": ["vnfSoftwareVersion"], + "type": "object", + "properties": { + "vnfSoftwareVersion": { + "title": "Vnfsoftwareversion", + "description": "VNF software version to match.", + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "vnfdVersions": { + "description": "Match VNF packages that contain VNF products with certain VNFD versions", + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + } + } + }, + "vnfProducts": { + "title": "Vnfproducts", + "description": "match VNF packages that contain VNF products with certain product names, from one particular provider", + "required": ["vnfProductName"], + "type": "object", + "properties": { + "vnfProductName": { + "title": "Vnfproductname", + "description": "Name of the VNF product to match.", + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "versions": { + "$ref": "#/definitions/Version" + } + } + }, + "vnfProductsProviders": { + "title": "Vnfproductsfromproviders", + "description": "Match VNF packages that contain VNF products from certain providers.", + "required": ["vnfProvider"], + "type": "object", + "properties": { + "vnfProvider": { + "title": "Vnfprovider", + "description": "Name of the VNFprovider to match.", + "type": "string", + "maxLength": 255, + "minLength": 1 + }, + "vnfProducts": { + "$ref": "#/definitions/vnfProducts" + } + } + }, + "PkgmNotificationsFilter": { + "title": "Filter", + "description": "Filter settings for this subscription, to define the subset of all notifications this subscription relates to", + "type": "object", + "properties": { + "notificationTypes": { + "description": "Match particular notification types", + "type": "array", + "items": { + "type": "string", + "enum": ["VnfPackageOnboardingNotification", "VnfPackageChangeNotification"] + } + }, + "vnfProductsFromProviders": { + "$ref": "#/definitions/vnfProductsProviders" + }, + "vnfdId": { + "description": "Match VNF packages with a VNFD identifierlisted in the attribute", + "type": "array", + "items": { + "type": "string", + "format": "uuid" + } + }, + "vnfPkgId": { + "description": "Match VNF packages with a VNFD identifierlisted in the attribute", + "type": "array", + "items": { + "type": "string", + "format": "uuid" + } + }, + "operationalState": { + "description": "Operational state of the VNF package.", + "type": "array", + "items": { + "type": "string", + "enum": ["ENABLED", "DISABLED"] + } + }, + "usageState": { + "description": "Operational state of the VNF package.", + "type": "array", + "items": { + "type": "string", + "enum": ["IN_USE", "NOT_IN_USE"] + } + } + } + }, + "PkgmSubscription": { + "required": ["id", "callbackUri", "_links"], + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "Identifier of this subscription resource.", + "type": "string", + "format": "uuid" + }, + "callbackUri": { + "title": "Callbackuri", + "description": "The URI of the endpoint to send the notification to.", + "type": "string", + "format": "uri", + "minLength": 1 + }, + "_links": { + "$ref": "#/definitions/LinkSelf" + }, + "filter": { + "$ref": "#/definitions/PkgmNotificationsFilter" + } + } + }, + "PkgmSubscriptionRequest": { + "required": ["callbackUri"], + "type": "object", + "properties": { + "filters": { + "$ref": "#/definitions/PkgmNotificationsFilter" + }, + "callbackUri": { + "title": "Callbackuri", + "description": "Callback URI to sendthe notification", + "type": "string", + "format": "uri", + "minLength": 1 + }, + "authentication": { + "$ref": "#/definitions/SubscriptionAuthentication" + } + } + }, + "Checksum": { + "title": "Checksum", + "description": "Checksum of the on-boarded VNF package.", + "required": ["algorithm", "hash"], + "type": "object", + "properties": { + "algorithm": { + "title": "Algorithm", + "description": "Name of the algorithm used to generate the checksum.", + "type": "string", + "minLength": 1 + }, + "hash": { + "title": "Hash", + "description": "The hexadecimal value of the checksum.", + "type": "string", + "minLength": 1 + } + } + }, + "VnfPackageSoftwareImageInfo": { + "description": "Information about VNF package artifacts that are software images.", + "required": ["id", "name", "provider", "version", "checksum", "containerFormat", "diskFormat", "createdAt", "minDisk", "minRam", "size", "imagePath"], + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "Identifier of the software image.", + "type": "string", + "minLength": 1 + }, + "name": { + "title": "Name", + "description": "Name of the software image.", + "type": "string", + "minLength": 1 + }, + "provider": { + "title": "Provider", + "description": "Provider of the software image.", + "type": "string", + "minLength": 1 + }, + "version": { + "title": "Version", + "description": "Version of the software image.", + "type": "string", + "minLength": 1 + }, + "checksum": { + "$ref": "#/definitions/Checksum" + }, + "containerFormat": { + "title": "Containerformat", + "description": "terminationType: Indicates whether forceful or graceful termination is requested.", + "type": "string", + "enum": ["AKI", "AMI", "ARI", "BARE", "DOCKER", "OVA", "OVF"] + }, + "diskFormat": { + "title": "Diskformat", + "description": "Disk format of a software image is the format of the underlying disk image.", + "type": "string", + "enum": ["AKI", "AMI", "ARI", "ISO", "QCOW2", "RAW", "VDI", "VHD", "VHDX", "VMDK"] + }, + "createdAt": { + "title": "Createdat", + "description": "Time when this software image was created.", + "type": "string", + "format": "date-time" + }, + "minDisk": { + "title": "Mindisk", + "description": "The minimal disk for this software image in bytes.", + "type": "integer" + }, + "minRam": { + "title": "Minram", + "description": "The minimal RAM for this software image in bytes.", + "type": "integer" + }, + "size": { + "title": "Size", + "description": "Size of this software image in bytes.", + "type": "integer" + }, + "userMetadata": { + "title": "Usermetadata", + "description": "User-defined data.", + "type": "object", + "additionalProperties": { + "description": "KeyValue Pairs", + "type": "string" + }, + "x-nullable": true + }, + "imagePath": { + "title": "Imagepath", + "description": "Path in the VNF package.", + "type": "string", + "minLength": 1 + } + } + }, + "VnfPackageArtifactInfo": { + "description": "Information about VNF package artifacts contained in the VNF package that are not software images.", + "required": ["artifactPath", "checksum"], + "type": "object", + "properties": { + "artifactPath": { + "title": "Artifactpath", + "description": "Path in the VNF package.", + "type": "string", + "minLength": 1 + }, + "checksum": { + "$ref": "#/definitions/Checksum" + }, + "metadata": { + "title": "Metadata", + "description": "The metadata of the artifact that are available in the VNF package", + "type": "object", + "additionalProperties": { + "description": "KeyValue Pairs", + "type": "string" + }, + "x-nullable": true + } + } + }, + "VNF_PKGM_Link_Serializer": { + "title": " links", + "description": "Links to resources related to this resource.", + "required": ["self", "packageContent"], + "type": "object", + "properties": { + "self": { + "$ref": "#/definitions/UriLink" + }, + "vnfd": { + "$ref": "#/definitions/UriLink" + }, + "packageContent": { + "$ref": "#/definitions/UriLink" + } + } + }, + "VnfPkgInfo": { + "required": ["id", "onboardingState", "operationalState", "usageState", "_links"], + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "Identifier of the on-boarded VNF package.", + "type": "string", + "minLength": 1 + }, + "vnfdId": { + "title": "Vnfdid", + "description": "This identifier, which is managed by the VNF provider, identifies the VNF package and the VNFD in a globally unique way.", + "type": "string", + "x-nullable": true + }, + "vnfProvider": { + "title": "Vnfprovider", + "description": "Provider of the VNF package and the VNFD.", + "type": "string", + "x-nullable": true + }, + "vnfProductName": { + "title": "Vnfproductname", + "description": "Name to identify the VNF product.", + "type": "string", + "x-nullable": true + }, + "vnfSoftwareVersion": { + "title": "Vnfsoftwareversion", + "description": "Software version of the VNF.", + "type": "string", + "x-nullable": true + }, + "vnfdVersion": { + "title": "Vnfdversion", + "description": "The version of the VNvFD.", + "type": "string", + "x-nullable": true + }, + "checksum": { + "$ref": "#/definitions/Checksum" + }, + "softwareImages": { + "description": "Information about VNF package artifacts that are software images.", + "type": "array", + "items": { + "$ref": "#/definitions/VnfPackageSoftwareImageInfo" + }, + "x-nullable": true + }, + "additionalArtifacts": { + "description": "Information about VNF package artifacts contained in the VNF package that are not software images.", + "type": "array", + "items": { + "$ref": "#/definitions/VnfPackageArtifactInfo" + }, + "x-nullable": true + }, + "onboardingState": { + "title": "Onboardingstate", + "description": "On-boarding state of the VNF package.", + "type": "string", + "enum": ["CREATED", "UPLOADING", "PROCESSING", "ONBOARDED"] + }, + "operationalState": { + "title": "Operationalstate", + "description": "Operational state of the VNF package.", + "type": "string", + "enum": ["ENABLED", "DISABLED"] + }, + "usageState": { + "title": "Usagestate", + "description": "Usage state of the VNF package.", + "type": "string", + "enum": ["IN_USE", "NOT_IN_USE"] + }, + "userDefinedData": { + "title": "Userdefineddata", + "description": "User defined data for the VNF package.", + "type": "object", + "additionalProperties": { + "description": "KeyValue Pairs", + "type": "string" + }, + "x-nullable": true + }, + "_links": { + "$ref": "#/definitions/VNF_PKGM_Link_Serializer" + } + } + }, + "CreateVnfPkgInfoRequest": { + "type": "object", + "properties": { + "userDefinedData": { + "title": "Userdefineddata", + "description": "User defined data for the VNF package.", + "type": "object", + "additionalProperties": { + "description": "KeyValue Pairs", + "type": "string" + }, + "x-nullable": true + } + } + }, + "UploadVnfPackageFromUriRequest": { + "required": ["addressInformation"], + "type": "object", + "properties": { + "addressInformation": { + "title": "Addressinformation", + "description": "Address information of the VNF package content.", + "type": "string", + "minLength": 1 + }, + "userName": { + "title": "Username", + "description": "User name to be used for authentication.", + "type": "string", + "minLength": 1 + }, + "password": { + "title": "Password", + "description": "Password to be used for authentication.", + "type": "string", + "minLength": 1 + } + } + } + } +}
\ No newline at end of file diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java index 32c22356b3..84282e0c7f 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java @@ -23,10 +23,13 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import java.util.ArrayList; import java.util.Collection; +import org.onap.so.adapters.vnfmadapter.converters.Sol003EtsiVnfPkgInfoToPkgmInlineResponse2001Converter; import org.onap.so.adapters.vnfmadapter.oauth.OAuth2AccessTokenAdapter; import org.springframework.boot.autoconfigure.http.HttpMessageConverters; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.convert.ConversionService; +import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.GsonHttpMessageConverter; import org.springframework.security.oauth2.common.OAuth2AccessToken; @@ -38,6 +41,13 @@ import org.springframework.security.oauth2.common.OAuth2AccessToken; public class MessageConverterConfiguration { @Bean + public ConversionService conversionService() { + final DefaultConversionService service = new DefaultConversionService(); + service.addConverter(new Sol003EtsiVnfPkgInfoToPkgmInlineResponse2001Converter()); + return service; + } + + @Bean public HttpMessageConverters customConverters() { final Collection<HttpMessageConverter<?>> messageConverters = new ArrayList<>(); final Gson gson = new GsonBuilder() 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/Sol003PackageManagementControllerExceptionHandler.java new file mode 100644 index 0000000000..2a97bb47e4 --- /dev/null +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Sol003PackageManagementControllerExceptionHandler.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.vnfmadapter; + +import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails; +import org.onap.so.adapters.vnfmadapter.rest.Sol003PackageManagementController; +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.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; + +/** + * Exception Handler for the Package Management Controller {@link Sol003PackageManagementController Sol003Controller} + * + * @author gareth.roper@est.tech + */ +@ControllerAdvice(assignableTypes = Sol003PackageManagementController.class) + +public class Sol003PackageManagementControllerExceptionHandler { + + @ExceptionHandler(EtsiCatalogManagerRequestFailureException.class) + public ResponseEntity<ProblemDetails> handleEtsiCatalogManagerRequestFailureException( + final EtsiCatalogManagerRequestFailureException etsiCatalogManagerRequestFailureException) { + final ProblemDetails problemDetails = new ProblemDetails(); + problemDetails.setDetail(etsiCatalogManagerRequestFailureException.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(problemDetails); + } + + @ExceptionHandler(VnfPkgConflictException.class) + public ResponseEntity<ProblemDetails> handleVnfPkgConflictException( + final VnfPkgConflictException vnfPkgConflictException) { + final ProblemDetails problemDetails = new ProblemDetails(); + problemDetails.setDetail(vnfPkgConflictException.getMessage()); + return ResponseEntity.status(HttpStatus.CONFLICT).body(problemDetails); + } + + @ExceptionHandler(VnfPkgNotFoundException.class) + public ResponseEntity<ProblemDetails> handleVnfPkgNotFoundException( + final VnfPkgNotFoundException vnfPkgNotFoundException) { + final ProblemDetails problemDetails = new ProblemDetails(); + problemDetails.setDetail(vnfPkgNotFoundException.getMessage()); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(problemDetails); + } + + @ExceptionHandler(VnfPkgBadRequestException.class) + public ResponseEntity<ProblemDetails> handleVnfPkgBadRequestException( + final VnfPkgBadRequestException vnfPkgBadRequestException) { + final ProblemDetails problemDetails = new ProblemDetails(); + problemDetails.setDetail(vnfPkgBadRequestException.getMessage()); + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(problemDetails); + } +} diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/Sol003EtsiVnfPkgInfoToPkgmInlineResponse2001Converter.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/Sol003EtsiVnfPkgInfoToPkgmInlineResponse2001Converter.java new file mode 100644 index 0000000000..de18ecc43e --- /dev/null +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/Sol003EtsiVnfPkgInfoToPkgmInlineResponse2001Converter.java @@ -0,0 +1,180 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.vnfmadapter.converters; + +import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.*; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.List; + +/** + * Converter to convert from an Etsi Catalog Model {@link VnfPkgInfo} Object to a PackageManagement Model + * {@link InlineResponse2001} Object + * + * @author andrew.a.lamb@est.tech + */ +@Service +public class Sol003EtsiVnfPkgInfoToPkgmInlineResponse2001Converter + implements Converter<VnfPkgInfo, InlineResponse2001> { + private static final Logger logger = + LoggerFactory.getLogger(Sol003EtsiVnfPkgInfoToPkgmInlineResponse2001Converter.class); + + /** + * Convert a {@link VnfPkgInfo} Object to an {@link InlineResponse2001} Object + * + * @param vnfPkgInfo The VnfPkgInfo Object to Convert + * @return The Converted InlineResponse2001 Object + */ + @Override + public InlineResponse2001 convert(final VnfPkgInfo vnfPkgInfo) { + if (vnfPkgInfo == null) { + logger.info("No VnfPkgInfo Object Provided for Conversion. (Null object received, returning Null)"); + return null; + } + final InlineResponse2001 response = new InlineResponse2001(); + response.setId(vnfPkgInfo.getId()); + response.setVnfdId(vnfPkgInfo.getVnfdId()); + response.setVnfProvider(vnfPkgInfo.getVnfProvider()); + response.setVnfProductName(vnfPkgInfo.getVnfProductName()); + response.setVnfSoftwareVersion(vnfPkgInfo.getVnfSoftwareVersion()); + response.setVnfdVersion(vnfPkgInfo.getVnfdVersion()); + response.setChecksum(convertChecksumToVnfPackagesChecksum(vnfPkgInfo.getChecksum())); + response.setSoftwareImages( + convertVnfPackageSoftwareImageInfoListToVnfPackagesSoftwareImagesList(vnfPkgInfo.getSoftwareImages())); + response.setAdditionalArtifacts(convertVnfPackageArtifactInfoListToVnfPackagesAdditionalArtifactsList( + vnfPkgInfo.getAdditionalArtifacts())); + + if (vnfPkgInfo.getOnboardingState() != null) { + response.setOnboardingState( + InlineResponse2001.OnboardingStateEnum.fromValue(vnfPkgInfo.getOnboardingState().getValue())); + } + + if (vnfPkgInfo.getOperationalState() != null) { + response.setOperationalState( + InlineResponse2001.OperationalStateEnum.fromValue(vnfPkgInfo.getOperationalState().getValue())); + } + + response.setUserDefinedData((vnfPkgInfo.getUserDefinedData())); + + if (vnfPkgInfo.getLinks() != null) { + response.setLinks(convertVNFPKGMLinkSerializerToVnfPackagesLinks(vnfPkgInfo.getLinks())); + } + + return response; + } + + private VnfPackagesChecksum convertChecksumToVnfPackagesChecksum(final Checksum checksum) { + final VnfPackagesChecksum vnfPackagesChecksum = new VnfPackagesChecksum(); + if (checksum != null) { + vnfPackagesChecksum.setAlgorithm(checksum.getAlgorithm()); + vnfPackagesChecksum.setHash(checksum.getHash()); + } + return vnfPackagesChecksum; + } + + private List<VnfPackagesSoftwareImages> convertVnfPackageSoftwareImageInfoListToVnfPackagesSoftwareImagesList( + final List<VnfPackageSoftwareImageInfo> vnfPackageSoftwareImageInfoList) { + final List<VnfPackagesSoftwareImages> vnfPackagesSoftwareImages = new ArrayList<>(); + if (vnfPackageSoftwareImageInfoList != null) { + for (final VnfPackageSoftwareImageInfo vnfPackageSoftwareImageInfo : vnfPackageSoftwareImageInfoList) { + final VnfPackagesSoftwareImages softwareImage = + convertVnfPackageSoftwareImageInfoToVnfPackagesSoftwareImages(vnfPackageSoftwareImageInfo); + vnfPackagesSoftwareImages.add(softwareImage); + } + } + return vnfPackagesSoftwareImages; + } + + private VnfPackagesSoftwareImages convertVnfPackageSoftwareImageInfoToVnfPackagesSoftwareImages( + final VnfPackageSoftwareImageInfo vnfPackageSoftwareImageInfo) { + final VnfPackagesSoftwareImages vnfPackagesSoftwareImages = new VnfPackagesSoftwareImages(); + vnfPackagesSoftwareImages.setId(vnfPackageSoftwareImageInfo.getId()); + vnfPackagesSoftwareImages.setName(vnfPackageSoftwareImageInfo.getName()); + vnfPackagesSoftwareImages.setProvider(vnfPackageSoftwareImageInfo.getProvider()); + vnfPackagesSoftwareImages.setVersion(vnfPackageSoftwareImageInfo.getVersion()); + vnfPackagesSoftwareImages + .setChecksum(convertChecksumToVnfPackagesChecksum(vnfPackageSoftwareImageInfo.getChecksum())); + if (vnfPackageSoftwareImageInfo.getContainerFormat() != null) { + vnfPackagesSoftwareImages.setContainerFormat(VnfPackagesSoftwareImages.ContainerFormatEnum + .fromValue(vnfPackageSoftwareImageInfo.getContainerFormat().getValue())); + } + + if (vnfPackageSoftwareImageInfo.getDiskFormat() != null) { + vnfPackagesSoftwareImages.setDiskFormat(VnfPackagesSoftwareImages.DiskFormatEnum + .fromValue(vnfPackageSoftwareImageInfo.getDiskFormat().getValue())); + } + + vnfPackagesSoftwareImages.setCreatedAt(vnfPackageSoftwareImageInfo.getCreatedAt()); + vnfPackagesSoftwareImages.setMinDisk(vnfPackageSoftwareImageInfo.getMinDisk()); + vnfPackagesSoftwareImages.setMinRam(vnfPackageSoftwareImageInfo.getMinRam()); + vnfPackagesSoftwareImages.setSize(vnfPackageSoftwareImageInfo.getSize()); + vnfPackagesSoftwareImages.setUserMetadata(vnfPackageSoftwareImageInfo.getUserMetadata()); + vnfPackagesSoftwareImages.setImagePath(vnfPackageSoftwareImageInfo.getImagePath()); + return vnfPackagesSoftwareImages; + } + + private List<VnfPackagesAdditionalArtifacts> convertVnfPackageArtifactInfoListToVnfPackagesAdditionalArtifactsList( + final List<VnfPackageArtifactInfo> vnfPackageArtifactInfoList) { + if (vnfPackageArtifactInfoList != null) { + final List<VnfPackagesAdditionalArtifacts> additionalArtifacts = new ArrayList<>(); + for (final VnfPackageArtifactInfo artifactInfo : vnfPackageArtifactInfoList) { + final VnfPackagesAdditionalArtifacts artifact = + convertVnfPackageArtifactInfoToVnfPackagesAdditionalArtifacts(artifactInfo); + additionalArtifacts.add(artifact); + } + return additionalArtifacts; + } + return null; + } + + private VnfPackagesAdditionalArtifacts convertVnfPackageArtifactInfoToVnfPackagesAdditionalArtifacts( + final VnfPackageArtifactInfo vnfPackageArtifactInfo) { + final VnfPackagesAdditionalArtifacts vnfPackagesAdditionalArtifacts = new VnfPackagesAdditionalArtifacts(); + vnfPackagesAdditionalArtifacts.setArtifactPath(vnfPackageArtifactInfo.getArtifactPath()); + vnfPackagesAdditionalArtifacts + .setChecksum(convertChecksumToVnfPackagesChecksum(vnfPackageArtifactInfo.getChecksum())); + vnfPackagesAdditionalArtifacts.setMetadata(vnfPackageArtifactInfo.getMetadata()); + return vnfPackagesAdditionalArtifacts; + } + + private VnfPackagesLinks convertVNFPKGMLinkSerializerToVnfPackagesLinks( + final VNFPKGMLinkSerializer vnfpkgmLinkSerializer) { + final VnfPackagesLinks vnfPackagesLinks = new VnfPackagesLinks(); + vnfPackagesLinks.setSelf(convertUriLinkToVnfPackagesLinksSelf(vnfpkgmLinkSerializer.getSelf())); + vnfPackagesLinks.setVnfd(convertUriLinkToVnfPackagesLinksSelf(vnfpkgmLinkSerializer.getVnfd())); + vnfPackagesLinks + .setPackageContent(convertUriLinkToVnfPackagesLinksSelf(vnfpkgmLinkSerializer.getPackageContent())); + return vnfPackagesLinks; + } + + private VnfPackagesLinksSelf convertUriLinkToVnfPackagesLinksSelf(final UriLink uriLink) { + final VnfPackagesLinksSelf vnfPackagesLinksSelf = new VnfPackagesLinksSelf(); + if (uriLink != null) { + vnfPackagesLinksSelf.setHref(uriLink.getHref()); + } + return vnfPackagesLinksSelf; + } + +} diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/AbstractServiceProviderConfiguration.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/AbstractServiceProviderConfiguration.java new file mode 100644 index 0000000000..8f6d853997 --- /dev/null +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/AbstractServiceProviderConfiguration.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.vnfmadapter.extclients; + +import com.google.gson.Gson; +import java.util.Iterator; +import org.onap.vnfmadapter.v1.JSON; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.GsonHttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.client.RestTemplate; + +/** + * A base class that can be extended by classes for configuring HttpRestServiceProvider classes. Provides common methods + * that will be useful to some such classes. + * + * @author gareth.roper@est.tech + */ +public abstract class AbstractServiceProviderConfiguration { + + public void setGsonMessageConverter(final RestTemplate restTemplate) { + final Iterator<HttpMessageConverter<?>> iterator = restTemplate.getMessageConverters().iterator(); + while (iterator.hasNext()) { + if (iterator.next() instanceof MappingJackson2HttpMessageConverter) { + iterator.remove(); + } + } + final Gson gson = new JSON().getGson(); + restTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gson)); + } +} 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 new file mode 100644 index 0000000000..a73958e544 --- /dev/null +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog; + +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001; +import java.util.Optional; + +/** + * Provides methods for invoking REST calls to the ETSI Catalog Manager. + * + * @author gareth.roper@est.tech + */ +public interface EtsiCatalogServiceProvider { + + /** + * GET Package Content, from VNF Package. + * + * @param vnfPkgId The ID of the VNF Package from which the "package_content" will be retrieved. + * @return The Package Content of a VNF Package ("vnfPkgId"). + */ + Optional<byte[]> getVnfPackageContent(final String vnfPkgId); + + /** + * GET VNF packages information from ETSI Catalog. Will return zero or more VNF package representations. + * + * @return An Array of all VNF packages retrieved from the ETSI Catalog. + */ + Optional<InlineResponse2001[]> getVnfPackages(); + + /** + * GET specific VNF package information from ETSI Catalog. + * + * @param vnfPkgId The ID of the VNF Package that you want to query. + * @return The VNF package retrieved from the ETSI Catalog + */ + Optional<InlineResponse2001> getVnfPackage(final String vnfPkgId); + +} diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java new file mode 100644 index 0000000000..6840dd388b --- /dev/null +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog; + +import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; +import org.onap.so.adapters.vnfmadapter.extclients.AbstractServiceProviderConfiguration; +import org.onap.so.configuration.rest.BasicHttpHeadersProvider; +import org.onap.so.configuration.rest.HttpHeadersProvider; +import org.onap.so.rest.service.HttpRestServiceProvider; +import org.onap.so.rest.service.HttpRestServiceProviderImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; + +/** + * Configures the HttpRestServiceProvider to make REST calls to the ETSI Catalog Manager + * + * @author gareth.roper@est.tech + */ + +@Configuration +public class EtsiCatalogServiceProviderConfiguration extends AbstractServiceProviderConfiguration { + + @Bean(name = "etsiCatalogServiceProvider") + public HttpRestServiceProvider httpRestServiceProvider( + @Qualifier(CONFIGURABLE_REST_TEMPLATE) @Autowired final RestTemplate restTemplate) { + return getHttpRestServiceProvider(restTemplate, new BasicHttpHeadersProvider()); + } + + private HttpRestServiceProvider getHttpRestServiceProvider(final RestTemplate restTemplate, + final HttpHeadersProvider httpHeadersProvider) { + setGsonMessageConverter(restTemplate); + return new HttpRestServiceProviderImpl(restTemplate, httpHeadersProvider); + } + +} 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 new file mode 100644 index 0000000000..96b01f04e4 --- /dev/null +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java @@ -0,0 +1,160 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +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.rest.exceptions.HttpResouceNotFoundException; +import org.onap.so.rest.exceptions.InvalidRestRequestException; +import org.onap.so.rest.exceptions.RestProcessingException; +import org.onap.so.rest.service.HttpRestServiceProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.core.convert.ConversionService; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; + +/** + * Provides the implementations of the REST Requests to the ETSI Catalog Manager. + * + * @author gareth.roper@est.tech + */ +@Service +public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvider { + private static final Logger logger = LoggerFactory.getLogger(EtsiCatalogServiceProviderImpl.class); + + @Qualifier("etsiCatalogServiceProvider") + private final HttpRestServiceProvider httpServiceProvider; + private final EtsiCatalogUrlProvider etsiCatalogUrlProvider; + private final ConversionService conversionService; + + @Autowired + public EtsiCatalogServiceProviderImpl(final EtsiCatalogUrlProvider etsiCatalogUrlProvider, + final HttpRestServiceProvider httpServiceProvider, final ConversionService conversionService) { + this.etsiCatalogUrlProvider = etsiCatalogUrlProvider; + this.httpServiceProvider = httpServiceProvider; + this.conversionService = conversionService; + } + + @Override + public Optional<byte[]> getVnfPackageContent(final String vnfPkgId) + throws EtsiCatalogManagerRequestFailureException { + try { + final ResponseEntity<byte[]> response = httpServiceProvider + .getHttpResponse(etsiCatalogUrlProvider.getVnfPackageContentUrl(vnfPkgId), byte[].class); + logger.info("getVnfPackageContent 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 found with vnfPkgId: " + vnfPkgId); + } 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 = + httpServiceProvider.getHttpResponse(etsiCatalogUrlProvider.getVnfPackagesUrl(), VnfPkgInfo[].class); + logger.info("getVnfPackages Request to ETSI Catalog Manager Status Code: {}", + response.getStatusCodeValue()); + if (response.getStatusCode() == HttpStatus.OK) { + if (response.hasBody()) { + final VnfPkgInfo[] vnfPackages = response.getBody(); + final InlineResponse2001[] responses = new InlineResponse2001[vnfPackages.length]; + for (int index = 0; index < vnfPackages.length; index++) { + if (conversionService.canConvert(vnfPackages[index].getClass(), InlineResponse2001.class)) { + final InlineResponse2001 inlineResponse2001 = + conversionService.convert(vnfPackages[index], InlineResponse2001.class); + if (inlineResponse2001 != null) { + responses[index] = inlineResponse2001; + } + } + logger.error("Unable to find Converter for response class: {}", vnfPackages[index].getClass()); + } + return Optional.ofNullable(responses); + } + logger.error("Received response without body ..."); + } + logger.error("Unexpected status code received {}", response.getStatusCode()); + return Optional.empty(); + } catch (final InvalidRestRequestException invalidRestRequestException) { + logger.error("Caught InvalidRestRequestException", invalidRestRequestException); + throw new VnfPkgBadRequestException("Error: Bad Request Received"); + } catch (final HttpResouceNotFoundException httpResouceNotFoundException) { + logger.error("Caught HttpResouceNotFoundException", httpResouceNotFoundException); + throw new VnfPkgNotFoundException("No Vnf Packages found"); + } catch (final RestProcessingException restProcessingException) { + logger.error("Caught RestProcessingException with Status Code: {}", restProcessingException.getStatusCode(), + restProcessingException); + throw new EtsiCatalogManagerRequestFailureException("Internal Server Error Occurred."); + } + } + + @Override + public Optional<InlineResponse2001> getVnfPackage(final String vnfPkgId) { + try { + final ResponseEntity<VnfPkgInfo> response = httpServiceProvider + .getHttpResponse(etsiCatalogUrlProvider.getVnfPackageUrl(vnfPkgId), VnfPkgInfo.class); + logger.info("getVnfPackage Request for vnfPkgId {} to ETSI Catalog Manager Status Code: {}", vnfPkgId, + response.getStatusCodeValue()); + if (response.getStatusCode() == HttpStatus.OK) { + if (response.hasBody()) { + final VnfPkgInfo vnfPkgInfo = response.getBody(); + if (conversionService.canConvert(vnfPkgInfo.getClass(), InlineResponse2001.class)) { + return Optional.ofNullable(conversionService.convert(vnfPkgInfo, InlineResponse2001.class)); + } + logger.error("Unable to find Converter for response class: {}", vnfPkgInfo.getClass()); + } + logger.error("Received response without body ...."); + } + return Optional.empty(); + } catch (final InvalidRestRequestException invalidRestRequestException) { + logger.error("Caught InvalidRestRequestException", invalidRestRequestException); + throw new VnfPkgBadRequestException("Error: Bad Request Received"); + } catch (final HttpResouceNotFoundException httpResouceNotFoundException) { + logger.error("Caught HttpResouceNotFoundException", httpResouceNotFoundException); + throw new VnfPkgNotFoundException("No Vnf Package found with vnfPkgId: " + vnfPkgId); + } catch (final RestProcessingException restProcessingException) { + logger.error("Caught RestProcessingException with Status Code: {}", restProcessingException.getStatusCode(), + restProcessingException); + throw new EtsiCatalogManagerRequestFailureException("Internal Server Error Occurred."); + } + } +} 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 new file mode 100644 index 0000000000..d233c3f0fd --- /dev/null +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog; + +import static org.slf4j.LoggerFactory.getLogger; +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +/** + * Provides the URLs for the REST Requests to the ETSI Catalog Manager. + * + * @author gareth.roper@est.tech + */ +@Service +public class EtsiCatalogUrlProvider { + + private static final Logger logger = getLogger(EtsiCatalogUrlProvider.class); + + @Value("${msb.endpoint:#{\"http://msb_iag.onap:80\"}}") + private String msbEndpoint; + @Value("${msb.catalogServiceUrl:#{null}}") + private String catalogServiceUrl; + @Value("${msb.vnfpkgmServiceUrl:#{\"/api/vnfpkgm/v1\"}}") + private String vnfpkgmServiceUrl; + + public EtsiCatalogUrlProvider() {} + + /** + * Get the URL for retrieving the Package Content from the ETSI Catalog.". + * + * @param vnfPkgId The ID of the VNF Package + * @return the URL for the GET operation + */ + public String getVnfPackageContentUrl(final String vnfPkgId) { + final String url = msbEndpoint + vnfpkgmServiceUrl + "/vnf_packages/" + vnfPkgId + "/package_content"; + logger.info("getEtsiCatalogVnfPackageContentUrl: {}", url); + return url; + } + + /** + * Get the URL for retrieving VNF packages information from ETSI Catalog.". + * + * @return the URL for the GET operation + */ + public String getVnfPackagesUrl() { + final String url = msbEndpoint + vnfpkgmServiceUrl + "/vnf_packages"; + logger.info("getEtsiCatalogVnfPackagesEndpoint: {}", url); + return url; + } + + /** + * Get the URL for retrieving specific VNF package information from the ETSI Catalog.". + * + * @param vnfPkgId The ID of the VNF Package + * @return the URL for the GET operation + */ + public String getVnfPackageUrl(final String vnfPkgId) { + final String url = msbEndpoint + vnfpkgmServiceUrl + "/vnf_packages/" + vnfPkgId; + logger.info("getEtsiCatalogVnfPackageEndpoint: {}", url); + return url; + } + +} diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java index ae9316cfdf..073fc93107 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java @@ -21,7 +21,6 @@ package org.onap.so.adapters.vnfmadapter.extclients.vnfm; import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; -import com.google.gson.Gson; import java.io.IOException; import java.security.KeyManagementException; import java.security.KeyStore; @@ -29,7 +28,6 @@ import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; -import java.util.Iterator; import java.util.ListIterator; import java.util.Map; import java.util.UUID; @@ -43,7 +41,7 @@ import org.apache.http.ssl.SSLContextBuilder; import org.onap.aai.domain.yang.EsrSystemInfo; import org.onap.aai.domain.yang.EsrVnfm; import org.onap.logging.filter.spring.SpringClientPayloadFilter; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.JSON; +import org.onap.so.adapters.vnfmadapter.extclients.AbstractServiceProviderConfiguration; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; import org.onap.so.rest.service.HttpRestServiceProvider; @@ -58,9 +56,6 @@ import org.springframework.core.io.Resource; import org.springframework.http.client.BufferingClientHttpRequestFactory; import org.springframework.http.client.ClientHttpRequestInterceptor; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.json.GsonHttpMessageConverter; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.security.oauth2.client.OAuth2RestTemplate; import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; import org.springframework.web.client.RestTemplate; @@ -69,7 +64,7 @@ import org.springframework.web.client.RestTemplate; * Configures the HttpRestServiceProvider for REST call to a VNFM. */ @Configuration -public class VnfmServiceProviderConfiguration { +public class VnfmServiceProviderConfiguration extends AbstractServiceProviderConfiguration { private static final Logger logger = LoggerFactory.getLogger(VnfmServiceProviderConfiguration.class); private Map<String, HttpRestServiceProvider> mapOfVnfmIdToHttpRestServiceProvider = new ConcurrentHashMap<>(); @@ -135,17 +130,6 @@ public class VnfmServiceProviderConfiguration { return new OAuth2RestTemplate(resourceDetails); } - private void setGsonMessageConverter(final RestTemplate restTemplate) { - final Iterator<HttpMessageConverter<?>> iterator = restTemplate.getMessageConverters().iterator(); - while (iterator.hasNext()) { - if (iterator.next() instanceof MappingJackson2HttpMessageConverter) { - iterator.remove(); - } - } - final Gson gson = new JSON().getGson(); - restTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gson)); - } - private void setTrustStore(final RestTemplate restTemplate) { SSLContext sslContext; try { 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 1da1159be0..76ec492bd4 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 @@ -23,10 +23,13 @@ package org.onap.so.adapters.vnfmadapter.rest; import static org.onap.so.adapters.vnfmadapter.Constants.APPLICATION_ZIP; import static org.onap.so.adapters.vnfmadapter.Constants.PACKAGE_MANAGEMENT_BASE_URL; import static org.slf4j.LoggerFactory.getLogger; -import java.util.List; +import java.util.Optional; import javax.ws.rs.core.MediaType; +import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.EtsiCatalogServiceProvider; +import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001; import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -45,74 +48,120 @@ import org.springframework.web.bind.annotation.RequestMapping; @RequestMapping(value = PACKAGE_MANAGEMENT_BASE_URL, consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public class Sol003PackageManagementController { - private static final String LOG_REQUEST_RECEIVED = "VNF Package Management Controller: {} {} {} {} {}"; + private final EtsiCatalogServiceProvider etsiCatalogServiceProvider; + private static final String LOG_REQUEST_RECEIVED = "VNF PackageManagement Controller: {} {} {}"; private static final Logger logger = getLogger(Sol003PackageManagementController.class); + @Autowired + Sol003PackageManagementController(final EtsiCatalogServiceProvider etsiCatalogServiceProvider) { + this.etsiCatalogServiceProvider = etsiCatalogServiceProvider; + } + /** - * GET VNF packages information. Direction: VNFM -> VNFM-Adapter. Will return zero or more VNF package - * representations that match the attribute filter. These representations will be in a list. Section Number: 10.4.2 - * - * @return A List of all VNF packages. Object: List<InlineResponse2001> Response Code: 200 OK + * GET VNF packages information. Will return zero or more VNF package representations that match the attribute + * filter. These representations will be in a list. Section Number: 10.4.2 + * + * @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<List<InlineResponse2001>> getVnfPackages() { + public ResponseEntity getVnfPackages() { logger.info(LOG_REQUEST_RECEIVED, "getVnfPackages."); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + 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); + } + 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); } /** - * GET VNF package information. Direction: VNFM -> VNFM-Adapter. Will return a specific VNF package representation - * that match the attribute filter. Section Number: 10.4.3 + * GET VNF package information. Will return a specific VNF package representation that match the attribute filter. + * Section Number: 10.4.3 * * @param vnfPkgId The ID of the VNF Package that you want to query. * @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<InlineResponse2001> getVnfPackage(@PathVariable("vnfPkgId") final String vnfPkgId) { + public ResponseEntity getVnfPackage(@PathVariable("vnfPkgId") final String vnfPkgId) { logger.info(LOG_REQUEST_RECEIVED, "getVnfPackage: ", vnfPkgId); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + 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); + } + 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); } /** - * GET VNFD, from VNF package. Direction: VNFM -> VNFM-Adapter. Will return a copy of the file representing the VNFD - * or a ZIP file that contains the file/multiple files representing the VNFD specified. Section Number: 10.4.4 - * + * GET VNFD, from VNF package. Will return a copy of the file representing the VNFD or a ZIP file that contains the + * file/multiple files representing the VNFD specified. Section Number: 10.4.4 + * * @param vnfPkgId The ID of the VNF Package that you want to retrieve the VNFD from. * @return The VNFD of a VNF Package as a single file or within a ZIP file. Object: byte[] Response Code: 200 OK */ - @GetMapping(value = "/vnf_packages/{vnfPkgId}/vnfd", produces = {MediaType.TEXT_PLAIN, APPLICATION_ZIP}) + @GetMapping(value = "/vnf_packages/{vnfPkgId}/vnfd", + produces = {MediaType.TEXT_PLAIN, APPLICATION_ZIP, MediaType.APPLICATION_JSON}) public ResponseEntity<byte[]> getVnfPackageVnfd(@PathVariable("vnfPkgId") final String vnfPkgId) { logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageVnfd: ", vnfPkgId); return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } /** - * GET Package Content, from VNF Package. Direction: VNFM -> VNFM-Adapter. Will return a copy of the VNF package - * file that you specified. Section Number: 10.4.5 - * + * GET Package Content, from VNF Package. Will return a copy of the VNF package file that you specified. Section + * Number: 10.4.5 + * * @param vnfPkgId The ID of the VNF Package that you want to retrieve the "package_content" from. * @return The Package Content of a VNF Package. Object: byte[] Response Code: 200 OK */ - @GetMapping(value = "/vnf_packages/{vnfPkgId}/package_content", produces = {APPLICATION_ZIP}) - public ResponseEntity<byte[]> getVnfPackageContent(@PathVariable("vnfPkgId") final String vnfPkgId) { - logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageContent: ", vnfPkgId); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + @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) { + 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); + } + 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" + + " Sol003PackageManagementController from the EtsiCatalogManager using the GET \"package_content\" \n" + + "endpoint."), HttpStatus.INTERNAL_SERVER_ERROR); } /** - * GET Artifact, from VNF Package. Direction: VNFM -> VNFM-Adapter. Will return a the content of the artifact that - * you specified. Section Number: 10.4.6 - * + * GET Artifact, from VNF Package Will return a the content of the artifact that you specified. Section Number: + * 10.4.6 + * * @param vnfPkgId The ID of the VNF Package that you want to retrieve an artifact from. * @param artifactPath The path of the artifact that you want to retrieve. * @return An Artifact from a VNF Package. Object: byte[] Response Code: 200 OK */ @GetMapping(value = "/vnf_packages/{vnfPkgId}/artifacts/{artifactPath}", - produces = {MediaType.APPLICATION_OCTET_STREAM}) + produces = {MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON}) public ResponseEntity<byte[]> 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); } + + /** + * Builds the ProblemDetails Object, using the provided error message. + * + * @param detail The error message retrieved from the exception thrown. + * @return ProblemDetails Object, containing error information. + */ + private ProblemDetails buildProblemDetails(final String detail) { + final ProblemDetails problemDetails = new ProblemDetails(); + problemDetails.setDetail(detail); + return problemDetails; + } + } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementController.java index 6fac952aa8..16650d4a3d 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementController.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementController.java @@ -53,9 +53,9 @@ public class Sol003SubscriptionManagementController { private static final Logger logger = getLogger(Sol003SubscriptionManagementController.class); /** - * POST Subscribe request. Direction: VNFM -> VNFM Adapter. Will send request and respond with the subscription that - * you subscribed to, if successful. Section Number: 10.4.7 - * + * POST Subscribe request. Will send request and respond with the subscription that you subscribed to, if + * successful. Section Number: 10.4.7 + * * @param pkgmSubscriptionRequest This includes the details of the subscription to be created. * @return The subscription requested, if successful. Object: InlineRespone2002 Response Code: 201 Created Response * Code: 303 Duplicate Subscription @@ -68,9 +68,8 @@ public class Sol003SubscriptionManagementController { } /** - * GET all subscriptions. Direction: VNFM -> VNFM Adapter. Will return a list of all subscriptions currently active. - * Section Number: 10.4.7 - * + * GET all subscriptions. Will return a list of all subscriptions currently active. Section Number: 10.4.7 + * * @return All of the current active subscriptions. Object: List<InlineResponse2002> Response Code: 200 OK */ @GetMapping(value = "/subscriptions") @@ -80,8 +79,8 @@ public class Sol003SubscriptionManagementController { } /** - * GET a specific subscription, by subscriptionId. Direction: VNFM -> VNFM Adapter. Section Number: 10.4.8 - * + * GET a specific subscription, by subscriptionId. Section Number: 10.4.8 + * * @param subscriptionId The ID of the subscription that you wish to retrieve. * @return A subscription based on subscriptionId. Object: InlineResponse2002 Response Code: 200 OK */ @@ -93,8 +92,8 @@ public class Sol003SubscriptionManagementController { } /** - * DELETE a specific subscription, by subscriptionId. Direction: VNFM -> VNFM Adapter. Section Number: 10.4.7 - * + * DELETE a specific subscription, by subscriptionId. Section Number: 10.4.7 + * * @param subscriptionId The ID of the subscription that you wish to delete. * @return Empty response if successful. Object: Void Response Code: 204 No Content */ diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/EtsiCatalogManagerRequestFailureException.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/EtsiCatalogManagerRequestFailureException.java new file mode 100644 index 0000000000..dbdc354f4e --- /dev/null +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/EtsiCatalogManagerRequestFailureException.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.adapters.vnfmadapter.rest.exceptions; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +/** + * Exception for an ETSI Catalog Manager Request Failure + * + * @author gareth.roper@est.tech + */ +@ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR) +public class EtsiCatalogManagerRequestFailureException extends RuntimeException { + + private static final long serialVersionUID = 66862444537194516L; + + public EtsiCatalogManagerRequestFailureException(final String message) { + super(message); + } + + @Override + public synchronized Throwable fillInStackTrace() { + return this; + } +} diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgBadRequestException.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgBadRequestException.java new file mode 100644 index 0000000000..211131c2a4 --- /dev/null +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgBadRequestException.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.adapters.vnfmadapter.rest.exceptions; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +/** + * Exception for a Vnfpkg Bad Request failure, due to state of resource. + * + * @author andrew.a.lamb@est.tech + */ +@ResponseStatus(code = HttpStatus.BAD_REQUEST) +public class VnfPkgBadRequestException extends RuntimeException { + + private static final long serialVersionUID = 3301317418914258411L; + + public VnfPkgBadRequestException(final String message) { + super(message); + } + + @Override + public synchronized Throwable fillInStackTrace() { + return this; + } +} 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 new file mode 100644 index 0000000000..0cc9c5bd7e --- /dev/null +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgConflictException.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.adapters.vnfmadapter.rest.exceptions; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +/** + * Exception for a Vnfpkg Conflict failure, due to state of resource. + * + * @author gareth.roper@est.tech + */ +@ResponseStatus(code = HttpStatus.CONFLICT) +public class VnfPkgConflictException extends RuntimeException { + + private static final long serialVersionUID = 26862444537198441L; + + public VnfPkgConflictException(final String message) { + super(message); + } + + @Override + public synchronized Throwable fillInStackTrace() { + return this; + } +} 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 new file mode 100644 index 0000000000..0f9f214643 --- /dev/null +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgNotFoundException.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.adapters.vnfmadapter.rest.exceptions; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +/** + * Exception for a Vnfpkg Not Found Failure + * + * @author gareth.roper@est.tech + */ +@ResponseStatus(code = HttpStatus.NOT_FOUND) +public class VnfPkgNotFoundException extends RuntimeException { + + private static final long serialVersionUID = 26862444537198441L; + + public VnfPkgNotFoundException(final String message) { + super(message); + } + + @Override + public synchronized Throwable fillInStackTrace() { + return this; + } +} 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 801c468018..857bd7dc3e 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 @@ -1,74 +1,457 @@ -package org.onap.so.adapters.vnfmadapter.rest; +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.adapters.vnfmadapter.rest; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.*; +import static org.onap.so.adapters.vnfmadapter.Constants.PACKAGE_MANAGEMENT_BASE_URL; import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; -import java.net.URISyntaxException; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; +import java.util.ArrayList; import java.util.List; +import java.util.Random; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; +import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.*; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001; +import org.onap.so.configuration.rest.BasicHttpHeadersProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; 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.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.web.client.RestTemplate; +import com.google.gson.Gson; +/** + * @author gareth.roper@est.tech + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public class Sol003PackageManagementControllerTest { - private static final String vnfPackageId = "myVnfPackageId"; - private static final String artifactPath = "myArtifactPath"; + private static final Logger logger = LoggerFactory.getLogger(Sol003PackageManagementControllerTest.class); + + @LocalServerPort + private int port; @Autowired @Qualifier(CONFIGURABLE_REST_TEMPLATE) private RestTemplate testRestTemplate; - private MockRestServiceServer mockRestServer; @Autowired private Sol003PackageManagementController controller; + @Autowired + private TestRestTemplate restTemplate; + + private static final String VNF_PACKAGE_ID = "myVnfPackageId"; + private static final String ARTIFACT_PATH = "myArtifactPath"; + private static final String MSB_BASE_URL = "http://msb_iag.onap:80/api/vnfpkgm/v1/vnf_packages"; + private static final String VNFPKGM_BASE_URL = PACKAGE_MANAGEMENT_BASE_URL + "/vnf_packages"; + private static final String localhostUrl = "http://localhost:"; + private static final String GET_VNF_PACKAGES_URL = ""; + private static final String GET_VNF_PACKAGE_BY_ID_URL = "/" + VNF_PACKAGE_ID; + private static final String VNFD_ID = "vnfdId"; + private static final String VNF_PROVIDER = "vnfProvider"; + private static final String VNF_PRODUCT_NAME = "vnfProductName"; + private static final String VNF_SOFTWARE_VERSION = "vnfSoftwareVersion"; + private static final String VNFD_VERSION = "vnfdVersion"; + private static final String ALGORITHM = "algorithm"; + private static final String HASH = "hash"; + private static final String URI_HREF = "uriHref"; + + private MockRestServiceServer mockRestServer; + private BasicHttpHeadersProvider basicHttpHeadersProvider; + private final Gson gson = new Gson(); + + public Sol003PackageManagementControllerTest() {} + @Before - public void setUp() throws Exception { - mockRestServer = MockRestServiceServer.bindTo(testRestTemplate).build(); + public void setUp() { + final MockRestServiceServer.MockRestServiceServerBuilder builder = + MockRestServiceServer.bindTo(testRestTemplate); + builder.ignoreExpectOrder(true); + mockRestServer = builder.build(); + basicHttpHeadersProvider = new BasicHttpHeadersProvider(); + } + + @Test + public void testGetPackageContent_ValidArray_Success() { + final byte[] responseArray = buildByteArrayWithRandomData(10); + + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) + .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 + "/package_content"; + 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 getVnfPackages() throws URISyntaxException, InterruptedException { - final ResponseEntity<List<InlineResponse2001>> response = controller.getVnfPackages(); - assertEquals(HttpStatus.NOT_IMPLEMENTED, response.getStatusCode()); + public void testOnGetPackageContent_Conflict_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.CONFLICT)); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/package_content"); + + assertTrue(responseEntity.getBody() instanceof ProblemDetails); + assertEquals(HttpStatus.CONFLICT, responseEntity.getStatusCode()); } @Test - public void getVnfPackage() throws URISyntaxException, InterruptedException { - final ResponseEntity<InlineResponse2001> response = controller.getVnfPackage(vnfPackageId); - assertEquals(HttpStatus.NOT_IMPLEMENTED, response.getStatusCode()); + public void testOnGetPackageContent_NotFound_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.NOT_FOUND)); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/package_content"); + + assertTrue(responseEntity.getBody() instanceof ProblemDetails); + assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode()); } @Test - public void getVnfPackageVnfd() throws URISyntaxException, InterruptedException { - final ResponseEntity<byte[]> response = controller.getVnfPackageVnfd(vnfPackageId); - assertEquals(HttpStatus.NOT_IMPLEMENTED, response.getStatusCode()); + public void testOnGetPackageContent_UnauthorizedClient_Fail() { + final String testURL = "http://localhost:" + port + PACKAGE_MANAGEMENT_BASE_URL + "/vnf_packages/" + + VNF_PACKAGE_ID + "/package_content"; + final HttpEntity<?> request = new HttpEntity<>(basicHttpHeadersProvider.getHttpHeaders()); + final ResponseEntity<ProblemDetails> responseEntity = + restTemplate.exchange(testURL, HttpMethod.GET, request, ProblemDetails.class); + + assertTrue(responseEntity.getBody() instanceof ProblemDetails); + assertEquals(HttpStatus.UNAUTHORIZED, responseEntity.getStatusCode()); } @Test - public void getVnfPackageContents() throws URISyntaxException, InterruptedException { - final ResponseEntity<byte[]> response = controller.getVnfPackageContent(vnfPackageId); - assertEquals(HttpStatus.NOT_IMPLEMENTED, response.getStatusCode()); + public void testOnGetPackageContent_InternalServerError_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR)); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/package_content"); + + assertTrue(responseEntity.getBody() instanceof ProblemDetails); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); } @Test - public void getVnfPackageArtifact() throws URISyntaxException, InterruptedException { - final ResponseEntity<byte[]> response = controller.getVnfPackageArtifact(vnfPackageId, artifactPath); - assertEquals(HttpStatus.NOT_IMPLEMENTED, response.getStatusCode()); + public void testOnGetPackageContent_BadRequest_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.BAD_REQUEST)); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/package_content"); + + assertTrue(responseEntity.getBody() instanceof ProblemDetails); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); } + @Test + public void testOnGetPackageContent_UnauthorizedServer_InternalError_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.UNAUTHORIZED)); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/package_content"); + + assertTrue(responseEntity.getBody() instanceof ProblemDetails); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); + } + + @Test + public void testGetPackageContent_SuccessResponseFromServerWithNullPackage_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) + .andExpect(method(HttpMethod.GET)).andRespond(withSuccess()); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/package_content"); + + assertEquals(ProblemDetails.class, responseEntity.getBody().getClass()); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); + } + + @Test + public void testVnfPackagesReceivedAsInlineResponse2001ListIfGetVnfPackagesSuccessful() { + final VnfPkgInfo[] responses = createVnfPkgArray(); + + mockRestServer.expect(requestTo(MSB_BASE_URL)).andExpect(method(HttpMethod.GET)) + .andRespond(withSuccess(gson.toJson(responses), MediaType.APPLICATION_JSON)); + + final String testURL = localhostUrl + port + VNFPKGM_BASE_URL; + final HttpEntity<?> request = new HttpEntity<>(basicHttpHeadersProvider.getHttpHeaders()); + + final ResponseEntity<InlineResponse2001[]> responseEntity = restTemplate.withBasicAuth("test", "test") + .exchange(testURL, HttpMethod.GET, request, InlineResponse2001[].class); + + assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); + assertNotNull(responseEntity.getBody()); + final InlineResponse2001[] inlineResponse2001array = responseEntity.getBody(); + final InlineResponse2001 inlineResponse2001 = inlineResponse2001array[0]; + assertEquals(VNF_PACKAGE_ID, inlineResponse2001.getId()); + assertEquals(VNFD_ID, inlineResponse2001.getVnfdId()); + assertEquals(VNFD_ID, inlineResponse2001.getSoftwareImages().get(0).getId()); + assertEquals(VNF_PRODUCT_NAME, inlineResponse2001.getSoftwareImages().get(0).getName()); + assertEquals(ALGORITHM, inlineResponse2001.getChecksum().getAlgorithm()); + assertEquals(HASH, inlineResponse2001.getChecksum().getHash()); + assertEquals(ARTIFACT_PATH, inlineResponse2001.getAdditionalArtifacts().get(0).getArtifactPath()); + assertEquals(ALGORITHM, inlineResponse2001.getAdditionalArtifacts().get(0).getChecksum().getAlgorithm()); + assertEquals(HASH, inlineResponse2001.getAdditionalArtifacts().get(0).getChecksum().getHash()); + assertEquals(URI_HREF, inlineResponse2001.getLinks().getSelf().getHref()); + } + + @Test + public void test400BadRequestInfoReceivedAsProblemDetailsIfGetVnfPackagesIs400BadRequest() { + mockRestServer.expect(requestTo(MSB_BASE_URL)).andExpect(method(HttpMethod.GET)) + .andRespond(withStatus(HttpStatus.BAD_REQUEST)); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(GET_VNF_PACKAGES_URL); + assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode()); + + assertNotNull(responseEntity.getBody()); + final ProblemDetails problemDetails = responseEntity.getBody(); + assertEquals("Error: Bad Request Received", problemDetails.getDetail()); + } + + @Test + public void test404NotFoundInfoReceivedAsProblemDetailsIfGetVnfPackagesIs404NotFound() { + mockRestServer.expect(requestTo(MSB_BASE_URL)).andExpect(method(HttpMethod.GET)) + .andRespond(withStatus(HttpStatus.NOT_FOUND)); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(GET_VNF_PACKAGES_URL); + assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode()); + + assertNotNull(responseEntity.getBody()); + final ProblemDetails problemDetails = responseEntity.getBody(); + assertEquals("No Vnf Packages found", problemDetails.getDetail()); + } + + @Test + public void test500InternalServerErrorProblemDetailsReceivedIfGetVnfPackagesReturns500InternalServerError() { + mockRestServer.expect(requestTo(MSB_BASE_URL)).andExpect(method(HttpMethod.GET)) + .andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR)); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(GET_VNF_PACKAGES_URL); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); + + assertNotNull(responseEntity.getBody()); + final ProblemDetails problemDetails = responseEntity.getBody(); + assertEquals("Internal Server Error Occurred.", problemDetails.getDetail()); + } + + @Test + public void test500InternalServerErrorProblemDetailsReceivedIfGetVnfPackagesReturnsANullPackage() { + mockRestServer.expect(requestTo(MSB_BASE_URL)).andExpect(method(HttpMethod.GET)).andRespond(withSuccess()); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(GET_VNF_PACKAGES_URL); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); + + assertNotNull(responseEntity.getBody()); + final ProblemDetails problemDetails = responseEntity.getBody(); + assertEquals("An error occurred, a null response was received by the\n" + + " Sol003PackageManagementController from the EtsiCatalogManager using the GET \"vnf_packages\" \n" + + "endpoint.", problemDetails.getDetail()); + } + + @Test + public void testVnfPackageReceivedAsInlineResponse2001IfGetVnfPackageByIdSuccessful() { + final VnfPkgInfo response = createVnfPkgInfo(VNF_PACKAGE_ID); + + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID)).andExpect(method(HttpMethod.GET)) + .andRespond(withSuccess(gson.toJson(response), MediaType.APPLICATION_JSON)); + + final String testURL = localhostUrl + port + VNFPKGM_BASE_URL + "/" + VNF_PACKAGE_ID; + final HttpEntity<?> request = new HttpEntity<>(basicHttpHeadersProvider.getHttpHeaders()); + final ResponseEntity<InlineResponse2001> responseEntity = restTemplate.withBasicAuth("test", "test") + .exchange(testURL, HttpMethod.GET, request, InlineResponse2001.class); + + assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); + assertNotNull(responseEntity.getBody()); + final InlineResponse2001 inlineResponse2001 = responseEntity.getBody(); + assertEquals(VNF_PACKAGE_ID, inlineResponse2001.getId()); + assertEquals(VNFD_ID, inlineResponse2001.getVnfdId()); + assertEquals(VNFD_ID, inlineResponse2001.getSoftwareImages().get(0).getId()); + assertEquals(VNF_PRODUCT_NAME, inlineResponse2001.getSoftwareImages().get(0).getName()); + assertEquals(ALGORITHM, inlineResponse2001.getChecksum().getAlgorithm()); + assertEquals(HASH, inlineResponse2001.getChecksum().getHash()); + assertEquals(ARTIFACT_PATH, inlineResponse2001.getAdditionalArtifacts().get(0).getArtifactPath()); + assertEquals(ALGORITHM, inlineResponse2001.getAdditionalArtifacts().get(0).getChecksum().getAlgorithm()); + assertEquals(HASH, inlineResponse2001.getAdditionalArtifacts().get(0).getChecksum().getHash()); + assertEquals(URI_HREF, inlineResponse2001.getLinks().getSelf().getHref()); + } + + @Test + public void test400BadRequestInfoReceivedAsProblemDetailsIfGetVnfPackageByIdIs400BadRequest() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID)).andExpect(method(HttpMethod.GET)) + .andRespond(withStatus(HttpStatus.BAD_REQUEST)); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(GET_VNF_PACKAGE_BY_ID_URL); + + assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode()); + assertNotNull(responseEntity.getBody()); + final ProblemDetails problemDetails = responseEntity.getBody(); + assertEquals("Error: Bad Request Received", problemDetails.getDetail()); + } + + @Test + public void test404NotFoundInfoReceivedAsProblemDetailsIfGetVnfPackageByIdIs404NotFound() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID)).andExpect(method(HttpMethod.GET)) + .andRespond(withStatus(HttpStatus.NOT_FOUND)); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(GET_VNF_PACKAGE_BY_ID_URL); + + assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode()); + assertNotNull(responseEntity.getBody()); + final ProblemDetails problemDetails = responseEntity.getBody(); + assertEquals("No Vnf Package found with vnfPkgId: " + VNF_PACKAGE_ID, problemDetails.getDetail()); + } + + @Test + public void test500InternalServerErrorProblemDetailsReceivedIfGetVnfPackageByIdReturns500InternalServerError() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID)).andExpect(method(HttpMethod.GET)) + .andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR)); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(GET_VNF_PACKAGE_BY_ID_URL); + + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); + assertNotNull(responseEntity.getBody()); + final ProblemDetails problemDetails = responseEntity.getBody(); + assertEquals("Internal Server Error Occurred.", problemDetails.getDetail()); + } + + @Test + public void test500InternalServerErrorProblemDetailsReceivedIfGetVnfPackageByIdReturnsANullPackage() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID)).andExpect(method(HttpMethod.GET)) + .andRespond(withSuccess()); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(GET_VNF_PACKAGE_BY_ID_URL); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); + + assertNotNull(responseEntity.getBody()); + final ProblemDetails problemDetails = responseEntity.getBody(); + assertEquals("An error occurred, a null response was received by the\n" + + " Sol003PackageManagementController from the EtsiCatalogManager using the GET \"vnf_packages\" by vnfPkgId: \"" + + 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 + @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(); + final byte[] b = new byte[sizeInKb * 1024]; // converting kb to byte + rnd.nextBytes(b); + return b; + } + + private ResponseEntity<ProblemDetails> sendHttpRequest(final String url) { + final String testURL = localhostUrl + port + VNFPKGM_BASE_URL + "/" + url; + final HttpEntity<?> request = new HttpEntity<>(basicHttpHeadersProvider.getHttpHeaders()); + return restTemplate.withBasicAuth("test", "test").exchange(testURL, HttpMethod.GET, request, + ProblemDetails.class); + } + + private VnfPkgInfo[] createVnfPkgArray() { + final VnfPkgInfo[] vnfPkgInfoArray = new VnfPkgInfo[1]; + final VnfPkgInfo vnfPkgInfo = createVnfPkgInfo(VNF_PACKAGE_ID); + vnfPkgInfoArray[0] = vnfPkgInfo; + return vnfPkgInfoArray; + } + + private VnfPkgInfo createVnfPkgInfo(final String vnfPackageId) { + final VnfPkgInfo vnfPkgInfo = new VnfPkgInfo(); + vnfPkgInfo.setId(vnfPackageId); + vnfPkgInfo.setVnfdId(VNFD_ID); + vnfPkgInfo.setVnfProvider(VNF_PROVIDER); + vnfPkgInfo.setVnfProductName(VNF_PRODUCT_NAME); + vnfPkgInfo.setVnfSoftwareVersion(VNF_SOFTWARE_VERSION); + vnfPkgInfo.setVnfdVersion(VNFD_VERSION); + vnfPkgInfo.setChecksum(createVnfPkgChecksum()); + vnfPkgInfo.setSoftwareImages(createSoftwareImages()); + vnfPkgInfo.setAdditionalArtifacts(createAdditionalArtifacts()); + vnfPkgInfo.setLinks(createVNFPKGMLinkSerializerLinks()); + return vnfPkgInfo; + } + + private Checksum createVnfPkgChecksum() { + final Checksum checksum = new Checksum(); + checksum.setAlgorithm(ALGORITHM); + checksum.setHash(HASH); + return checksum; + } + + private List<VnfPackageSoftwareImageInfo> createSoftwareImages() { + final List<VnfPackageSoftwareImageInfo> softwareImages = new ArrayList<>(); + final VnfPackageSoftwareImageInfo vnfPackageSoftwareImageInfo = new VnfPackageSoftwareImageInfo(); + vnfPackageSoftwareImageInfo.setId(VNFD_ID); + vnfPackageSoftwareImageInfo.setName(VNF_PRODUCT_NAME); + vnfPackageSoftwareImageInfo.setProvider(""); + vnfPackageSoftwareImageInfo.setVersion(""); + vnfPackageSoftwareImageInfo.setChecksum(createVnfPkgChecksum()); + vnfPackageSoftwareImageInfo + .setContainerFormat(VnfPackageSoftwareImageInfo.ContainerFormatEnum.fromValue("AKI")); + softwareImages.add(vnfPackageSoftwareImageInfo); + return softwareImages; + } + + private List<VnfPackageArtifactInfo> createAdditionalArtifacts() { + final List<VnfPackageArtifactInfo> vnfPackageArtifactInfos = new ArrayList<>(); + final VnfPackageArtifactInfo vnfPackageArtifactInfo = + new VnfPackageArtifactInfo().artifactPath(ARTIFACT_PATH).checksum(createVnfPkgChecksum()); + vnfPackageArtifactInfos.add(vnfPackageArtifactInfo); + return vnfPackageArtifactInfos; + } + + private VNFPKGMLinkSerializer createVNFPKGMLinkSerializerLinks() { + final UriLink uriLink = new UriLink().href(URI_HREF); + final VNFPKGMLinkSerializer vnfpkgmLinkSerializer = new VNFPKGMLinkSerializer().self(uriLink); + return vnfpkgmLinkSerializer; + } } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementControllerTest.java index 999dd02f0f..8fc27c5943 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementControllerTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementControllerTest.java @@ -20,6 +20,10 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.web.client.RestTemplate; +/** + * @author gareth.roper@est.tech + */ + @RunWith(SpringRunner.class) @SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") |