use of org.onap.aai.domain.yang.VolumeGroup in project so by onap.
the class WorkflowAction method getVfModuleReplaceBuildingBlocks.
protected List<OrchestrationFlow> getVfModuleReplaceBuildingBlocks(ConfigBuildingBlocksDataObject dataObj) throws Exception {
String vnfId = dataObj.getWorkflowResourceIds().getVnfId();
String vfModuleId = dataObj.getWorkflowResourceIds().getVfModuleId();
logger.debug("BUILDING REPLACE LIST");
boolean volumeGroupExisted = false;
boolean volumeGroupWillExist = false;
boolean keepVolumeGroup = false;
boolean rebuildVolumeGroups = false;
if (dataObj.getRequestDetails().getRequestParameters() != null && dataObj.getRequestDetails().getRequestParameters().getRebuildVolumeGroups() != null) {
rebuildVolumeGroups = dataObj.getRequestDetails().getRequestParameters().getRebuildVolumeGroups();
}
String volumeGroupName = "";
Optional<VolumeGroup> volumeGroupFromVfModule = bbInputSetupUtils.getRelatedVolumeGroupFromVfModule(vnfId, vfModuleId);
if (volumeGroupFromVfModule.isPresent()) {
String volumeGroupId = volumeGroupFromVfModule.get().getVolumeGroupId();
volumeGroupName = volumeGroupFromVfModule.get().getVolumeGroupName();
logger.debug("Volume group id of the existing volume group is: {}", volumeGroupId);
volumeGroupExisted = true;
dataObj.getWorkflowResourceIds().setVolumeGroupId(volumeGroupId);
dataObj.getReplaceInformation().setOldVolumeGroupName(volumeGroupName);
}
List<OrchestrationFlow> orchFlows = dataObj.getOrchFlows();
VfModuleCustomization vfModuleCustomization = catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(dataObj.getRequestDetails().getModelInfo().getModelCustomizationUuid());
if (vfModuleCustomization != null && vfModuleCustomization.getVfModule() != null && vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null && vfModuleCustomization.getVolumeHeatEnv() != null) {
volumeGroupWillExist = true;
if (!volumeGroupExisted) {
String newVolumeGroupId = UUID.randomUUID().toString();
dataObj.getWorkflowResourceIds().setVolumeGroupId(newVolumeGroupId);
dataObj.getReplaceInformation().setOldVolumeGroupName(volumeGroupName);
logger.debug("newVolumeGroupId: {}", newVolumeGroupId);
}
}
if (volumeGroupExisted && volumeGroupWillExist && !rebuildVolumeGroups) {
keepVolumeGroup = true;
}
if (!volumeGroupExisted || keepVolumeGroup) {
logger.debug("Filtering out deletion of volume groups");
orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().matches(VOLUMEGROUP_DELETE_PATTERN)).collect(Collectors.toList());
}
if (!volumeGroupWillExist || keepVolumeGroup) {
logger.debug("Filtering out creation of volume groups");
orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().matches(VOLUMEGROUP_CREATE_PATTERN)).collect(Collectors.toList());
}
return orchFlows;
}
use of org.onap.aai.domain.yang.VolumeGroup in project so by onap.
the class AAIDataRetrieval method getVolumeGroup.
public VolumeGroup getVolumeGroup(String vnfId, String volumeGroupId) throws AAIEntityNotFound {
AAIResultWrapper wrapper = this.getAaiResourcesClient().get(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)).relatedTo(Types.VOLUME_GROUP.getFragment(volumeGroupId)));
Optional<VolumeGroup> volume = wrapper.asBean(VolumeGroup.class);
if (volume.isPresent()) {
return volume.get();
} else {
logger.debug("No VolumeGroup in A&AI found: {}", vnfId);
return null;
}
}
use of org.onap.aai.domain.yang.VolumeGroup in project so by onap.
the class AAIDataRetrieval method getVolumeGroupsOfVnf.
public List<VolumeGroup> getVolumeGroupsOfVnf(String vnfId) {
List<VolumeGroup> volumeGroupList = new ArrayList<VolumeGroup>();
AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)).relatedTo(Types.VOLUME_GROUPS.getFragment());
Optional<VolumeGroups> volumeGroups = getAaiResourcesClient().get(VolumeGroups.class, uri);
if (!volumeGroups.isPresent() || volumeGroups.get().getVolumeGroup().isEmpty()) {
logger.debug("No VolumeGroups attached to Vnf in AAI : {}", vnfId);
} else {
volumeGroupList = volumeGroups.get().getVolumeGroup();
}
return volumeGroupList;
}
use of org.onap.aai.domain.yang.VolumeGroup in project so by onap.
the class WorkflowActionTest method selectExecutionListALaCarteVfModuleKeepVolumeGroupReplaceRetainAssignmentsTest.
@Test
public void selectExecutionListALaCarteVfModuleKeepVolumeGroupReplaceRetainAssignmentsTest() throws Exception {
String gAction = "replaceInstanceRetainAssignments";
String resource = "VfModule";
String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON);
initExecution(gAction, bpmnRequest, true);
execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234");
execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d");
execution.setVariable("vfModuleId", "1234");
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("volumeGroupId");
doReturn(Optional.of(volumeGroup)).when(bbSetupUtils).getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234");
VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment());
org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
vfModule.setVolumeHeatTemplate(new HeatTemplate());
vfModuleCustomization.setVfModule(vfModule);
when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b")).thenReturn(vfModuleCustomization);
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
northBoundRequest.setOrchestrationFlowList(replaceRetainAssignmentsVfModuleOrchFlows);
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "ChangeModelVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
}
use of org.onap.aai.domain.yang.VolumeGroup in project so by onap.
the class WorkflowActionTest method selectExecutionListALaCarteVfModuleRebuildVolumeGroupReplaceTest.
@Test
public void selectExecutionListALaCarteVfModuleRebuildVolumeGroupReplaceTest() throws Exception {
String gAction = "replaceInstance";
String resource = "VfModule";
String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_REPLACE_REBUILD_VOLUME_GROUPS_JSON);
initExecution(gAction, bpmnRequest, true);
execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234");
execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d");
execution.setVariable("vfModuleId", "1234");
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("volumeGroupId");
doReturn(Optional.of(volumeGroup)).when(bbSetupUtils).getRelatedVolumeGroupFromVfModule("b80b16a5-f80d-4ffa-91c8-bd47c7438a3d", "1234");
VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
vfModuleCustomization.setVolumeHeatEnv(new HeatEnvironment());
org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
vfModule.setVolumeHeatTemplate(new HeatTemplate());
vfModuleCustomization.setVfModule(vfModule);
when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("9a6d01fd-19a7-490a-9800-460830a12e0b")).thenReturn(vfModuleCustomization);
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
northBoundRequest.setOrchestrationFlowList(replaceVfModuleOrchFlows);
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleATTBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "UnassignVFModuleBB", "UnassignVolumeGroupBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "ChangeModelVnfBB", "ChangeModelServiceInstanceBB");
}
Aggregations