use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.
the class E2EServiceInstances method updateE2EserviceInstances.
private Response updateE2EserviceInstances(String requestJSON, Action action, String version) throws ApiException {
String requestId = UUID.randomUUID().toString();
E2EServiceInstanceRequest e2eSir;
String serviceId = instanceIdMap.get(SERVICE_ID);
ObjectMapper mapper = new ObjectMapper();
try {
e2eSir = mapper.readValue(requestJSON, E2EServiceInstanceRequest.class);
} catch (Exception e) {
logger.debug("Mapping of request to JSON object failed : ", e);
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER, null, version);
logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, ErrorCode.SchemaError.getValue(), requestJSON, e);
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
ServiceInstancesRequest sir = mapReqJsonToSvcInstReq(e2eSir, requestJSON);
sir.getRequestDetails().getRequestParameters().setaLaCarte(true);
try {
parseRequest(sir, instanceIdMap, action, version, requestJSON, false, requestId);
} catch (Exception e) {
logger.debug("Validation failed: ", e);
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, "Error parsing request. " + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER, null, version);
if (requestId != null) {
logger.debug("Logging failed message to the database");
}
logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, ErrorCode.SchemaError.getValue(), requestJSON, e);
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
RecipeLookupResult recipeLookupResult;
try {
recipeLookupResult = getServiceInstanceOrchestrationURI(e2eSir.getService().getServiceUuid(), action);
} catch (Exception e) {
logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e);
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(), ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
if (recipeLookupResult == null) {
logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), MSO_PROP_APIHANDLER_INFRA, ErrorCode.DataError.getValue(), "No recipe found in DB");
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, "Recipe does not exist in catalog DB", ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version);
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
String serviceInstanceType = e2eSir.getService().getServiceType();
String sirRequestJson = convertToString(sir);
RequestClientParameter postParam = new RequestClientParameter.Builder().setRequestId(requestId).setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.name()).setServiceInstanceId(serviceId).setServiceType(serviceInstanceType).setRequestDetails(sirRequestJson).setApiVersion(version).setALaCarte(false).setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build();
return postRequest(recipeLookupResult.getOrchestrationURI(), postParam, version);
}
use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.
the class E2EServiceInstances method processE2EserviceInstances.
private Response processE2EserviceInstances(String requestJSON, Action action, HashMap<String, String> instanceIdMap, String version) throws ApiException {
String requestId = UUID.randomUUID().toString();
E2EServiceInstanceRequest e2eSir;
MsoRequest msoRequest = new MsoRequest();
ObjectMapper mapper = new ObjectMapper();
try {
e2eSir = mapper.readValue(requestJSON, E2EServiceInstanceRequest.class);
} catch (Exception e) {
logger.debug("Mapping of request to JSON object failed : ", e);
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER, null, version);
logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, ErrorCode.SchemaError.getValue(), requestJSON, e);
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
ServiceInstancesRequest sir = mapReqJsonToSvcInstReq(e2eSir, requestJSON);
sir.getRequestDetails().getRequestParameters().setaLaCarte(true);
try {
parseRequest(sir, instanceIdMap, action, version, requestJSON, false, requestId);
} catch (Exception e) {
logger.debug("Validation failed: ", e);
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, "Error parsing request. " + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER, null, version);
if (requestId != null) {
logger.debug("Logging failed message to the database");
}
logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, ErrorCode.SchemaError.getValue(), requestJSON, e);
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
RecipeLookupResult recipeLookupResult;
try {
recipeLookupResult = getServiceInstanceOrchestrationURI(e2eSir.getService().getServiceUuid(), action);
} catch (Exception e) {
logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e);
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(), ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
if (recipeLookupResult == null) {
logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), MSO_PROP_APIHANDLER_INFRA, ErrorCode.DataError.getValue(), "No recipe found in DB");
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, "Recipe does not exist in catalog DB", ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version);
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
String serviceInstanceType = e2eSir.getService().getServiceType();
String serviceId = e2eSir.getService().getServiceId();
String sirRequestJson = convertToString(sir);
RequestClientParameter parameter = new RequestClientParameter.Builder().setRequestId(requestId).setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.name()).setServiceInstanceId(serviceId).setServiceType(serviceInstanceType).setRequestDetails(sirRequestJson).setApiVersion(version).setALaCarte(false).setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build();
return postRequest(recipeLookupResult.getOrchestrationURI(), parameter, version);
}
use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.
the class WorkflowActionTest method getConfigBuildingBlocksTest.
@Test
public void getConfigBuildingBlocksTest() throws Exception {
String gAction = "deleteInstance";
ObjectMapper mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
WorkflowType resourceType = WorkflowType.VFMODULE;
execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
execution.setVariable("requestAction", gAction);
String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
execution.setVariable("bpmnRequest", bpmnRequest);
execution.setVariable("vnfId", "1234");
execution.setVariable("vfModuleId", "vfModuleId1234");
execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
RequestDetails requestDetails = sIRequest.getRequestDetails();
String requestAction = "deleteInstance";
String requestId = "9c944122-d161-4280-8594-48c06a9d96d5";
boolean aLaCarte = true;
String apiVersion = "7";
String vnfType = "vnfType";
String key = "00d15ebb-c80e-43c1-80f0-90c40dde70b0";
String resourceId = "d1d35800-783d-42d3-82f6-d654c5054a6e";
Resource resourceKey = new Resource(resourceType, key, aLaCarte, null);
WorkflowResourceIds workflowResourceIds = SPY_workflowAction.populateResourceIdsFromApiHandler(execution);
List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB", "DeleteFabricConfigurationBB");
ConfigBuildingBlocksDataObject dataObj = new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows).setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion).setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte).setVnfType(vnfType).setWorkflowResourceIds(workflowResourceIds).setRequestDetails(requestDetails).setExecution(execution);
org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
vnf.setVnfId("vnf0");
vnf.setModelCustomizationId("modelCustomizationId");
when(bbSetupUtils.getAAIGenericVnf(any())).thenReturn(vnf);
org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
vfModule.setModelCustomizationId("modelCustomizationId");
org.onap.aai.domain.yang.Configuration config1 = new org.onap.aai.domain.yang.Configuration();
config1.setConfigurationId("config1");
org.onap.aai.domain.yang.Configuration config2 = new org.onap.aai.domain.yang.Configuration();
config2.setConfigurationId("config2");
List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
org.onap.aai.domain.yang.Vnfc vnfc1 = new org.onap.aai.domain.yang.Vnfc();
vnfc1.setVnfcName("zauk53avetd02svm001");
org.onap.aai.domain.yang.Vnfc vnfc2 = new org.onap.aai.domain.yang.Vnfc();
vnfc2.setVnfcName("zauk53avetd02tvm001");
vnfcs.add(vnfc1);
vnfcs.add(vnfc2);
when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModule);
doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), eq(org.onap.aai.domain.yang.Vnfc.class), eq(Types.VNFC));
doReturn(config1).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc1), eq(org.onap.aai.domain.yang.Configuration.class), eq(Types.CONFIGURATION));
doReturn(config2).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc2), eq(org.onap.aai.domain.yang.Configuration.class), eq(Types.CONFIGURATION));
List<ExecuteBuildingBlock> results = SPY_workflowAction.getConfigBuildingBlocks(dataObj);
assertFalse(results.isEmpty());
assertEquals(2, results.size());
assertEquals("config1", results.get(0).getWorkflowResourceIds().getConfigurationId());
assertEquals("config2", results.get(1).getWorkflowResourceIds().getConfigurationId());
assertEquals("zauk53avetd02svm001", results.get(0).getConfigurationResourceKeys().getVnfcName());
assertEquals("zauk53avetd02tvm001", results.get(1).getConfigurationResourceKeys().getVnfcName());
}
use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.
the class WorkflowActionTest method getConfigBuildingBlocksNoVfModuleFabricDeleteTest.
@Test
public void getConfigBuildingBlocksNoVfModuleFabricDeleteTest() throws Exception {
String gAction = "deleteInstance";
ObjectMapper mapper = new ObjectMapper();
WorkflowType resourceType = WorkflowType.VFMODULE;
String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON);
execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
execution.setVariable("requestAction", gAction);
execution.setVariable("bpmnRequest", bpmnRequest);
execution.setVariable("vnfId", "1234");
execution.setVariable("vfModuleId", "vfModuleId1234");
execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
RequestDetails requestDetails = sIRequest.getRequestDetails();
String requestAction = "deleteInstance";
String requestId = "9c944122-d161-4280-8594-48c06a9d96d5";
boolean aLaCarte = true;
String apiVersion = "7";
String vnfType = "vnfType";
String key = "00d15ebb-c80e-43c1-80f0-90c40dde70b0";
String resourceId = "d1d35800-783d-42d3-82f6-d654c5054a6e";
Resource resourceKey = new Resource(resourceType, key, aLaCarte, null);
WorkflowResourceIds workflowResourceIds = SPY_workflowAction.populateResourceIdsFromApiHandler(execution);
thrown.expect(AAIEntityNotFoundException.class);
thrown.expectMessage(containsString("No matching VfModule is found in Generic-Vnf in AAI for vnfId: 1234 and vfModuleId : vfModuleId1234"));
List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB");
ConfigBuildingBlocksDataObject dataObj = new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows).setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion).setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte).setVnfType(vnfType).setWorkflowResourceIds(workflowResourceIds).setRequestDetails(requestDetails).setExecution(execution);
org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
vnf.setVnfId("vnf0");
vnf.setModelCustomizationId("modelCustomizationId");
when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
vfModule.setModelCustomizationId("modelCustomizationId");
when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(null);
SPY_workflowAction.getConfigBuildingBlocks(dataObj);
}
use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.
the class ServiceEBBLoaderTest method getResourceListForServiceWithRequestActionAssignInstance.
@Test
public void getResourceListForServiceWithRequestActionAssignInstance() throws IOException, VrfBondingServiceException {
String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON);
ObjectMapper mapper = new ObjectMapper();
ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
String requestAction = "assignInstance";
String serviceInstanceId = "123";
String resourceId = "si0";
List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
doReturn(prepareListWithResources()).when(mockUserParamsServiceTraversal).getResourceListFromUserParams(any(), anyList(), anyString(), anyString());
List<Resource> resources = serviceEBBLoader.getResourceListForService(sIRequest, requestAction, execution, serviceInstanceId, resourceId, aaiResourceIds);
assertNotNull(resources);
assertEquals(resources.size(), 6);
}
Aggregations