use of org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext in project so by onap.
the class VnfAdapterVfModuleObjectMapperPayloadTest method createVfModuleWithSingleAvailabilityZoneRequestMapperTest.
@Test
public void createVfModuleWithSingleAvailabilityZoneRequestMapperTest() throws Exception {
// prepare and set service instance
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setServiceInstanceId("serviceInstanceId");
ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
modelInfoServiceInstance.setModelName("serviceModelName");
modelInfoServiceInstance.setModelUuid("serviceModelUuid");
modelInfoServiceInstance.setModelVersion("serviceModelVersion");
modelInfoServiceInstance.setEnvironmentContext("environmentContext");
modelInfoServiceInstance.setWorkloadContext("workloadContext");
serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
RequestContext requestContext = new RequestContext();
Map<String, Object> userParams = new HashMap<>();
userParams.put("key1", "value2");
requestContext.setMsoRequestId("requestId");
requestContext.setUserParams(userParams);
requestContext.setProductFamilyId("productFamilyId");
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("vnfId");
vnf.setVnfType("vnfType");
vnf.setVnfName("vnfName");
ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
modelInfoGenericVnf.setModelName("vnfModelName");
modelInfoGenericVnf.setModelVersion("vnfModelVersion");
modelInfoGenericVnf.setModelUuid("vnfModelUuid");
modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
Integer vfModuleIndex = 1;
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("vfModuleId");
vfModule.setVfModuleName("vfModuleName");
vfModule.setModuleIndex(vfModuleIndex);
ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
modelInfoVfModule.setModelName("vfModuleModelName");
modelInfoVfModule.setModelVersion("vfModuleModelVersion");
modelInfoVfModule.setModelUUID("vfModuleModelUuid");
modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
vfModule.setModelInfoVfModule(modelInfoVfModule);
CloudRegion cloudRegion = new CloudRegion();
cloudRegion.setLcpCloudRegionId("cloudRegionId");
cloudRegion.setTenantId("tenantId");
OrchestrationContext orchestrationContext = new OrchestrationContext();
orchestrationContext.setIsRollbackEnabled(false);
String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopologyWithSingletonArray.json")));
String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestWithSingleAvailabilityZone.json")));
CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
}
use of org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext in project so by onap.
the class VnfAdapterVfModuleObjectMapperPayloadTest method createVfModuleWithFalseRollbackRequestMapperTest.
@Test
public void createVfModuleWithFalseRollbackRequestMapperTest() throws Exception {
// prepare and set service instance
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setServiceInstanceId("serviceInstanceId");
ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid");
modelInfoServiceInstance.setModelName("serviceModelName");
modelInfoServiceInstance.setModelUuid("serviceModelUuid");
modelInfoServiceInstance.setModelVersion("serviceModelVersion");
modelInfoServiceInstance.setEnvironmentContext("environmentContext");
modelInfoServiceInstance.setWorkloadContext("workloadContext");
serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
RequestContext requestContext = new RequestContext();
Map<String, Object> userParams = new HashMap<>();
userParams.put("key1", "value2");
requestContext.setMsoRequestId("requestId");
requestContext.setUserParams(userParams);
requestContext.setProductFamilyId("productFamilyId");
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("vnfId");
vnf.setVnfType("vnfType");
vnf.setVnfName("vnfName");
ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid");
modelInfoGenericVnf.setModelName("vnfModelName");
modelInfoGenericVnf.setModelVersion("vnfModelVersion");
modelInfoGenericVnf.setModelUuid("vnfModelUuid");
modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid");
vnf.setModelInfoGenericVnf(modelInfoGenericVnf);
Integer vfModuleIndex = 1;
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("vfModuleId");
vfModule.setVfModuleName("vfModuleName");
vfModule.setModuleIndex(vfModuleIndex);
ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid");
modelInfoVfModule.setModelName("vfModuleModelName");
modelInfoVfModule.setModelVersion("vfModuleModelVersion");
modelInfoVfModule.setModelUUID("vfModuleModelUuid");
modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid");
vfModule.setModelInfoVfModule(modelInfoVfModule);
HashMap<String, String> cloudParams = new HashMap<String, String>();
cloudParams.put("key3", "value3");
vfModule.setCloudParams(cloudParams);
CloudRegion cloudRegion = new CloudRegion();
cloudRegion.setLcpCloudRegionId("cloudRegionId");
cloudRegion.setTenantId("tenantId");
OrchestrationContext orchestrationContext = new OrchestrationContext();
orchestrationContext.setIsRollbackEnabled(true);
String sdncVnfQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVnfTopology.json")));
String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
CreateVfModuleRequest vfModuleVNFAdapterRequest = vfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, vnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "vnfAdapterCreateVfModuleRequestTrueBackout.json")));
CreateVfModuleRequest reqMapper1 = omapper.readValue(jsonToCompare, CreateVfModuleRequest.class);
assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl"));
}
use of org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext in project so by onap.
the class BBInputSetup method populateGBBWithSIAndAdditionalInfo.
protected GeneralBuildingBlock populateGBBWithSIAndAdditionalInfo(BBInputSetupParameter parameter) throws Exception {
GeneralBuildingBlock outputBB = new GeneralBuildingBlock();
OrchestrationContext orchContext = mapperLayer.mapOrchestrationContext(parameter.getRequestDetails());
RequestContext requestContext = mapperLayer.mapRequestContext(parameter.getRequestDetails());
requestContext.setAction(parameter.getRequestAction());
requestContext.setMsoRequestId(parameter.getExecuteBB().getRequestId());
requestContext.setIsHelm(parameter.getIsHelm());
org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(parameter.getRequestDetails().getCloudConfiguration());
CloudRegion cloudRegion = mapperLayer.mapCloudRegion(parameter.getRequestDetails().getCloudConfiguration(), aaiCloudRegion);
Tenant tenant = getTenant(parameter.getRequestDetails().getCloudConfiguration(), aaiCloudRegion);
outputBB.setOrchContext(orchContext);
outputBB.setRequestContext(requestContext);
outputBB.setCloudRegion(cloudRegion);
outputBB.setTenant(tenant);
Customer customer = parameter.getCustomer();
if (customer == null) {
Map<String, String> uriKeys = bbInputSetupUtils.getURIKeysFromServiceInstance(parameter.getServiceInstance().getServiceInstanceId());
String globalCustomerId = uriKeys.get(AAIFluentTypeBuilder.Types.CUSTOMER.getUriParams().globalCustomerId);
String subscriptionServiceType = uriKeys.get(AAIFluentTypeBuilder.Types.SERVICE_SUBSCRIPTION.getUriParams().serviceType);
customer = mapCustomer(globalCustomerId, subscriptionServiceType);
}
outputBB.setServiceInstance(parameter.getServiceInstance());
if (customer.getServiceSubscription() != null) {
customer.getServiceSubscription().getServiceInstances().add(parameter.getServiceInstance());
}
outputBB.setCustomer(customer);
return outputBB;
}
use of org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext in project so by onap.
the class VnfAdapterCreateTasks method createVfModule.
/**
* This method is used for creating the request for the VfModule.
*
* @param execution
* @return
*/
public void createVfModule(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
ServiceInstance serviceInstance = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0);
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
VolumeGroup volumeGroup = null;
try {
volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
} catch (BBObjectNotFoundException bbException) {
logger.info("Volume Group not found in GBB. ");
}
CloudRegion cloudRegion = gBBInput.getCloudRegion();
RequestContext requestContext = gBBInput.getRequestContext();
OrchestrationContext orchestrationContext = gBBInput.getOrchContext();
String sdncVfModuleQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + vfModule.getVfModuleId());
String sdncVnfQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + genericVnf.getVnfId());
CreateVfModuleRequest createVfModuleRequest = vnfAdapterVfModuleResources.createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
execution.setVariable(VNFREST_REQUEST, createVfModuleRequest.toXmlString());
} catch (Exception ex) {
logger.error("Exception occurred", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext in project so by onap.
the class VnfAdapterObjectMapperTest method test_createVolumeGroupRequestMapper.
@Test
public void test_createVolumeGroupRequestMapper() throws Exception {
RequestContext requestContext = new RequestContext();
requestContext.setMsoRequestId("msoRequestId");
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setServiceInstanceId("serviceInstanceId");
ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
modelInfoServiceInstance.setModelVersion("modelVersion");
serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
GenericVnf genericVnf = new GenericVnf();
genericVnf.setVnfId("vnfId");
genericVnf.setVnfName("vnfName");
genericVnf.setVnfType("vnfType");
serviceInstance.getVnfs().add(genericVnf);
ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
modelInfoVfModule.setModelName("modelName");
modelInfoVfModule.setModelCustomizationUUID("modelCustomizationUUID");
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("volumeGroupId");
volumeGroup.setVolumeGroupName("volumeGroupName");
volumeGroup.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
volumeGroup.setModelInfoVfModule(modelInfoVfModule);
serviceInstance.getVnfs().get(0).getVolumeGroups().add(volumeGroup);
CloudRegion cloudRegion = new CloudRegion();
cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
cloudRegion.setTenantId("tenantId");
OrchestrationContext orchestrationContext = new OrchestrationContext();
orchestrationContext.setIsRollbackEnabled(true);
String sdncVfModuleQueryResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleSdncVfModuleTopology.json")));
CreateVolumeGroupRequest expectedCreateVolumeGroupRequest = new CreateVolumeGroupRequest();
expectedCreateVolumeGroupRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
expectedCreateVolumeGroupRequest.setTenantId(cloudRegion.getTenantId());
expectedCreateVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
expectedCreateVolumeGroupRequest.setVolumeGroupName(volumeGroup.getVolumeGroupName());
expectedCreateVolumeGroupRequest.setVnfType(genericVnf.getVnfType());
expectedCreateVolumeGroupRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
expectedCreateVolumeGroupRequest.setVfModuleType(volumeGroup.getModelInfoVfModule().getModelName());
expectedCreateVolumeGroupRequest.setModelCustomizationUuid(volumeGroup.getModelInfoVfModule().getModelCustomizationUUID());
Map<String, Object> volumeGroupParams = new HashMap<>();
volumeGroupParams.put("vnf_id", genericVnf.getVnfId());
volumeGroupParams.put("vnf_name", genericVnf.getVnfName());
volumeGroupParams.put("vf_module_id", volumeGroup.getVolumeGroupId());
volumeGroupParams.put("vf_module_name", volumeGroup.getVolumeGroupName());
volumeGroupParams.put("paramOne", "paramOneValue");
volumeGroupParams.put("paramTwo", "paramTwoValue");
volumeGroupParams.put("paramThree", "paramThreeValue");
expectedCreateVolumeGroupRequest.setVolumeGroupParams(volumeGroupParams);
expectedCreateVolumeGroupRequest.setSkipAAI(true);
expectedCreateVolumeGroupRequest.setSuppressBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
expectedCreateVolumeGroupRequest.setFailIfExists(false);
MsoRequest msoRequest = new MsoRequest();
msoRequest.setRequestId(requestContext.getMsoRequestId());
msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
expectedCreateVolumeGroupRequest.setMsoRequest(msoRequest);
expectedCreateVolumeGroupRequest.setMessageId("messageId");
expectedCreateVolumeGroupRequest.setNotificationUrl("endpoint/VNFAResponse/messageId");
doReturn("endpoint/").when(vnfAdapterObjectMapper).getProperty(isA(String.class));
doReturn("messageId").when(vnfAdapterObjectMapper).getRandomUuid();
CreateVolumeGroupRequest actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest));
doReturn("false").when(vnfAdapterObjectMapper).getProperty("mso.bridgeEnabled");
actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest));
doReturn(null).when(vnfAdapterObjectMapper).getProperty("mso.bridgeEnabled");
expectedCreateVolumeGroupRequest.setEnableBridge(true);
actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest));
doReturn("true").when(vnfAdapterObjectMapper).getProperty("mso.bridgeEnabled");
expectedCreateVolumeGroupRequest.setEnableBridge(true);
actualCreateVolumeGroupRequest = vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
assertThat(actualCreateVolumeGroupRequest, sameBeanAs(expectedCreateVolumeGroupRequest));
}
Aggregations