use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class VnfEBBLoaderTest method traverseAAIVnf_should_add_vnfs_and_vfmodules.
@Test
public void traverseAAIVnf_should_add_vnfs_and_vfmodules() throws Exception {
List<Resource> resourceList = new ArrayList<>();
List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
GenericVnf genericVnf = mock(GenericVnf.class);
doReturn(vnfId).when(genericVnf).getVnfId();
org.onap.aai.domain.yang.GenericVnf aaiVnf = mock(org.onap.aai.domain.yang.GenericVnf.class);
doReturn(aaiVnf).when(bbInputSetupUtils).getAAIGenericVnf(vnfId);
VfModule vfModule = mock(VfModule.class);
doReturn(vfModuleId).when(vfModule).getVfModuleId();
ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
modelInfoVfModule.setIsBaseBoolean(true);
doReturn(modelInfoVfModule).when(vfModule).getModelInfoVfModule();
org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule();
aaiVfModule.setIsBaseVfModule(true);
doReturn(aaiVfModule).when(bbInputSetupUtils).getAAIVfModule(vnfId, vfModuleId);
doReturn(serviceInstanceAAI).when(bbInputSetupUtils).getAAIServiceInstanceById(serviceId);
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
doReturn(List.of(genericVnf)).when(serviceInstanceMSO).getVnfs();
doReturn(List.of(vfModule)).when(genericVnf).getVfModules();
cut = new VnfEBBLoader(bbInputSetupUtils, bbInputSetup, workflowActionUtils, exceptionBuilder);
cut.traverseAAIVnf(delegateExecution, resourceList, serviceId, vnfId, aaiResourceIds);
assertEquals(3, resourceList.size());
assertEquals(WorkflowType.VNF, resourceList.get(1).getResourceType());
assertEquals(WorkflowType.VFMODULE, resourceList.get(2).getResourceType());
assertTrue(resourceList.get(2).isBaseVfModule());
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class VnfAdapterVfModuleObjectMapper method createVfModuleRequestMapper.
public CreateVfModuleRequest createVfModuleRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule, VolumeGroup volumeGroup, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse) throws IOException, MissingValueTagException {
CreateVfModuleRequest createVfModuleRequest = new CreateVfModuleRequest();
createVfModuleRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
createVfModuleRequest.setCloudOwner(cloudRegion.getCloudOwner());
createVfModuleRequest.setTenantId(cloudRegion.getTenantId());
createVfModuleRequest.setVfModuleId(vfModule.getVfModuleId());
createVfModuleRequest.setVfModuleName(vfModule.getVfModuleName());
createVfModuleRequest.setVnfId(genericVnf.getVnfId());
createVfModuleRequest.setVnfType(genericVnf.getVnfType());
createVfModuleRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
createVfModuleRequest.setVfModuleType(vfModule.getModelInfoVfModule().getModelName());
createVfModuleRequest.setModelCustomizationUuid(vfModule.getModelInfoVfModule().getModelCustomizationUUID());
if (volumeGroup != null) {
createVfModuleRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
createVfModuleRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId());
}
VfModule baseVfModule = getBaseVfModule(genericVnf);
if (baseVfModule != null) {
createVfModuleRequest.setBaseVfModuleId(baseVfModule.getVfModuleId());
createVfModuleRequest.setBaseVfModuleStackId(baseVfModule.getHeatStackId());
}
createVfModuleRequest.setVfModuleParams(buildVfModuleParamsMap(requestContext, serviceInstance, genericVnf, vfModule, sdncVnfQueryResponse, sdncVfModuleQueryResponse));
createVfModuleRequest.setSkipAAI(true);
createVfModuleRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
createVfModuleRequest.setFailIfExists(false);
MsoRequest msoRequest = buildMsoRequest(requestContext, serviceInstance);
createVfModuleRequest.setMsoRequest(msoRequest);
String messageId = vnfAdapterObjectMapperUtils.getRandomUuid();
createVfModuleRequest.setMessageId(messageId);
createVfModuleRequest.setNotificationUrl(vnfAdapterObjectMapperUtils.createCallbackUrl("VNFAResponse", messageId));
String enableBridge = getProperty(ENABLE_BRIDGE);
if (enableBridge == null || Boolean.valueOf(enableBridge)) {
createVfModuleRequest.setEnableBridge(true);
}
return createVfModuleRequest;
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class VnfAdapterVfModuleObjectMapper method getBaseVfModule.
private VfModule getBaseVfModule(GenericVnf genericVnf) {
List<VfModule> vfModules = genericVnf.getVfModules();
VfModule baseVfModule = null;
if (vfModules != null) {
for (int i = 0; i < vfModules.size(); i++) {
if (vfModules.get(i).getModelInfoVfModule().getIsBaseBoolean()) {
baseVfModule = vfModules.get(i);
break;
}
}
}
return baseVfModule;
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class AAIVfModuleResources method updateContrailServiceInstanceFqdnVfModule.
public void updateContrailServiceInstanceFqdnVfModule(VfModule vfModule, GenericVnf vnf) {
AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId()).vfModule(vfModule.getVfModuleId()));
VfModule copiedVfModule = vfModule.shallowCopyId();
copiedVfModule.setContrailServiceInstanceFqdn(vfModule.getContrailServiceInstanceFqdn());
org.onap.aai.domain.yang.VfModule aaiVfModule = aaiObjectMapper.mapVfModule(copiedVfModule);
injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule);
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule in project so by onap.
the class AAIVfModuleResources method updateOrchestrationStatusVfModule.
public void updateOrchestrationStatusVfModule(VfModule vfModule, GenericVnf vnf, OrchestrationStatus orchestrationStatus) {
AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnf.getVnfId()).vfModule(vfModule.getVfModuleId()));
VfModule copiedVfModule = vfModule.shallowCopyId();
vfModule.setOrchestrationStatus(orchestrationStatus);
copiedVfModule.setOrchestrationStatus(orchestrationStatus);
org.onap.aai.domain.yang.VfModule aaiVfModule = aaiObjectMapper.mapVfModule(copiedVfModule);
injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule);
}
Aggregations