use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup in project so by onap.
the class UnassignVnf method deleteInstanceGroups.
/**
* BPMN access method to deleting instanceGroup in AAI.
*
* It will extract the vnf from BBobject ,It will get the instance group from the vnf and add it into a list.
*
* Then iterate that list and check the ModelInfoInstanceGroup type.
*
* Then it will delete that.
*
* @param execution
*/
public void deleteInstanceGroups(BuildingBlockExecution execution) {
try {
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
List<InstanceGroup> instanceGroups = vnf.getInstanceGroups();
for (InstanceGroup instanceGroup : instanceGroups) {
if (ModelInfoInstanceGroup.TYPE_VNFC.equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) {
aaiInstanceGroupResources.deleteInstanceGroup(instanceGroup);
}
}
} catch (Exception ex) {
logger.error("Exception occurred in UnassignVnf deleteInstanceGroups", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup in project so by onap.
the class BBInputSetupTest method testMapVnfcCollectionInstanceGroup.
@Test
public void testMapVnfcCollectionInstanceGroup() {
VnfResourceCustomization vnfResourceCust = Mockito.mock(VnfResourceCustomization.class);
GenericVnf genericVnf = new GenericVnf();
ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
Service service = Mockito.mock(Service.class);
org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
instanceGroup.setModelUUID("modelUUID");
List<VnfcInstanceGroupCustomization> vnfcInstanceGroups = new ArrayList<>();
VnfcInstanceGroupCustomization vnfcInstanceGroupCust = new VnfcInstanceGroupCustomization();
vnfcInstanceGroupCust.setInstanceGroup(instanceGroup);
vnfcInstanceGroupCust.setFunction("function");
vnfcInstanceGroupCust.setDescription("description");
vnfcInstanceGroups.add(vnfcInstanceGroupCust);
ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
modelInfoInstanceGroup.setModelUUID("modelUUID");
doReturn(vnfResourceCust).when(SPY_bbInputSetup).getVnfResourceCustomizationFromService(modelInfo, service);
doReturn(vnfcInstanceGroups).when(vnfResourceCust).getVnfcInstanceGroupCustomizations();
doReturn(instanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup("modelUUID");
doReturn(modelInfoInstanceGroup).when(bbInputSetupMapperLayer).mapCatalogInstanceGroupToInstanceGroup(null, instanceGroup);
SPY_bbInputSetup.mapVnfcCollectionInstanceGroup(genericVnf, modelInfo, service);
assertEquals("Instance Group was created", true, genericVnf.getInstanceGroups().size() == 1);
}
use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup in project so by onap.
the class AssignVnfTest method before.
@Before
public void before() throws BBObjectNotFoundException {
ModelInfoInstanceGroup modelVnfc = new ModelInfoInstanceGroup();
modelVnfc.setType("VNFC");
modelVnfc.setFunction("function");
ModelInfoInstanceGroup modelNetworkInstanceGroup = new ModelInfoInstanceGroup();
modelNetworkInstanceGroup.setType("L3-NETWORK");
modelNetworkInstanceGroup.setFunction("function");
instanceGroup1 = new InstanceGroup();
instanceGroup1.setId("test-001");
instanceGroup1.setModelInfoInstanceGroup(modelVnfc);
instanceGroup2 = new InstanceGroup();
instanceGroup2.setId("test-002");
instanceGroup2.setModelInfoInstanceGroup(modelVnfc);
instanceGroup3 = new InstanceGroup();
instanceGroup3.setId("test-003");
instanceGroup3.setModelInfoInstanceGroup(modelNetworkInstanceGroup);
instanceGroup4 = new InstanceGroup();
instanceGroup4.setId("test-004");
instanceGroup4.setModelInfoInstanceGroup(modelNetworkInstanceGroup);
genericVnf = setGenericVnf();
genericVnf.setVnfName("vnfName");
doNothing().when(aaiInstanceGroupResources).createInstanceGroup(isA(InstanceGroup.class));
doNothing().when(aaiInstanceGroupResources).connectInstanceGroupToVnf(isA(InstanceGroup.class), isA(GenericVnf.class));
when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf);
doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
}
use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup in project so by onap.
the class CreateNetworkCollectionTest method buildCreateNetworkRequestInstanceGroupModelInfoFunctionNullExceptionTest.
@Test(expected = BpmnError.class)
public void buildCreateNetworkRequestInstanceGroupModelInfoFunctionNullExceptionTest() throws Exception {
ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
serviceInstance.getCollection().getInstanceGroup().setModelInfoInstanceGroup(modelInfoInstanceGroup);
createNetworkCollection.buildNetworkCollectionName(execution);
}
use of org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup in project so by onap.
the class CreateNetworkCollectionTest method before.
@Before
public void before() throws BBObjectNotFoundException {
serviceInstance = setServiceInstance();
network = setL3Network();
cloudRegion = setCloudRegion();
List<L3Network> l3NetworkList = new ArrayList<L3Network>();
l3NetworkList.add(network);
ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
modelInfoInstanceGroup.setFunction("function");
serviceInstance.getCollection().getInstanceGroup().setModelInfoInstanceGroup(modelInfoInstanceGroup);
orchestrationContext = setOrchestrationContext();
orchestrationContext.setIsRollbackEnabled(true);
doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))).thenReturn(serviceInstance);
}
Aggregations