use of org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup in project so by onap.
the class OrchestrationStatusValidator method getOrchestrationStatus.
private OrchestrationStatus getOrchestrationStatus(BuildingBlockExecution execution, String buildingBlockFlowName, BuildingBlockDetail buildingBlockDetail) throws BBObjectNotFoundException, OrchestrationStatusValidationException {
OrchestrationStatus orchestrationStatus = null;
switch(buildingBlockDetail.getResourceType()) {
case SERVICE:
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
orchestrationStatus = serviceInstance.getOrchestrationStatus();
break;
case VNF:
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
orchestrationStatus = genericVnf.getOrchestrationStatus();
break;
case VF_MODULE:
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
orchestrationStatus = vfModule.getOrchestrationStatus();
break;
case VOLUME_GROUP:
VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
orchestrationStatus = volumeGroup.getOrchestrationStatus();
break;
case NETWORK:
L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
orchestrationStatus = network.getOrchestrationStatus();
break;
case NETWORK_COLLECTION:
Collection networkCollection = getNetworkCollection(execution);
orchestrationStatus = networkCollection.getOrchestrationStatus();
break;
case CONFIGURATION:
Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
orchestrationStatus = configuration.getOrchestrationStatus();
break;
case INSTANCE_GROUP:
InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
orchestrationStatus = instanceGroup.getOrchestrationStatus();
break;
case NO_VALIDATE:
// short circuit and exit method
execution.setVariable(ORCHESTRATION_STATUS_VALIDATION_RESULT, OrchestrationStatusValidationDirective.VALIDATION_SKIPPED);
break;
default:
// code
throw new OrchestrationStatusValidationException(String.format(UNKNOWN_RESOURCE_TYPE, buildingBlockFlowName, buildingBlockDetail.getResourceType(), buildingBlockDetail.getTargetAction()));
}
return orchestrationStatus;
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup in project so by onap.
the class AAIObjectInstanceNameGeneratorTest method generateInstanceGroupNameTest.
@Test
public void generateInstanceGroupNameTest() throws Exception {
ModelInfoInstanceGroup modelVnfc = new ModelInfoInstanceGroup();
modelVnfc.setFunction("vre");
modelVnfc.setType("VNFC");
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setId("test-001");
instanceGroup.setModelInfoInstanceGroup(modelVnfc);
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("vnf-123");
vnf.setVnfName("test-vnf");
assertEquals("test-vnf_vre", new AAIObjectInstanceNameGenerator().generateInstanceGroupName(instanceGroup, vnf));
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup in project so by onap.
the class BBInputSetupTest method testPopulateNetworkCollectionAndInstanceGroupAssign.
@Test
public void testPopulateNetworkCollectionAndInstanceGroupAssign() throws Exception {
Service service = Mockito.mock(Service.class);
String key = "collectionCustId";
ServiceInstance serviceInstance = mapper.readValue(new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"), ServiceInstance.class);
String resourceId = "123";
Collection collection = SPY_bbInputSetup.createCollection(resourceId);
InstanceGroup instanceGroup = SPY_bbInputSetup.createInstanceGroup();
assertNull(serviceInstance.getCollection());
doReturn(true).when(SPY_bbInputSetup).isVlanTagging(service, key);
doReturn(collection).when(SPY_bbInputSetup).createCollection(resourceId);
doReturn(instanceGroup).when(SPY_bbInputSetup).createInstanceGroup();
doNothing().when(SPY_bbInputSetup).mapCatalogCollection(service, collection, key);
NetworkCollectionResourceCustomization networkCollection = new NetworkCollectionResourceCustomization();
networkCollection.setModelCustomizationUUID(key);
networkCollection.setCollectionResource(new CollectionResource());
networkCollection.getCollectionResource().setInstanceGroup(new org.onap.so.db.catalog.beans.InstanceGroup());
networkCollection.getCollectionResource().getInstanceGroup().setToscaNodeType("NetworkCollectionResource");
networkCollection.getCollectionResource().getInstanceGroup().setType(InstanceGroupType.L3_NETWORK);
networkCollection.getCollectionResource().getInstanceGroup().setCollectionInstanceGroupCustomizations(new ArrayList<>());
List<CollectionResourceCustomization> customizations = new ArrayList<>();
customizations.add(networkCollection);
doReturn(customizations).when(service).getCollectionResourceCustomizations();
BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setService(service).setServiceInstance(serviceInstance).setResourceId(resourceId).setKey(key).setBbName(AssignFlows.NETWORK_COLLECTION.toString()).build();
SPY_bbInputSetup.populateNetworkCollectionAndInstanceGroupAssign(parameter);
assertNotNull(serviceInstance.getCollection());
assertNotNull(serviceInstance.getCollection().getInstanceGroup());
verify(SPY_bbInputSetup, times(1)).mapCatalogCollection(service, serviceInstance.getCollection(), key);
verify(SPY_bbInputSetup, times(1)).mapCatalogNetworkCollectionInstanceGroup(service, serviceInstance.getCollection().getInstanceGroup(), key);
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup in project so by onap.
the class BBInputSetupTest method testPopulateInstanceGroup.
@Test
public void testPopulateInstanceGroup() throws Exception {
ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
Service service = Mockito.mock(Service.class);
List<InstanceGroup> instanceGroups = Mockito.spy(new ArrayList<>());
ServiceInstance serviceInstance = Mockito.spy(new ServiceInstance());
serviceInstance.setServiceInstanceId("si-001");
serviceInstance.setServiceInstanceName("test service instance");
serviceInstance.setInstanceGroups(instanceGroups);
BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setModelInfo(modelInfo).setService(service).setServiceInstance(serviceInstance).setResourceId("instance-group-001").setInstanceName("test instance group").build();
SPY_bbInputSetup.populateInstanceGroup(parameter);
verify(SPY_bbInputSetup, times(1)).mapCatalogInstanceGroup(isA(InstanceGroup.class), isA(ModelInfo.class), isA(Service.class));
verify(instanceGroups, times(1)).add(isA(InstanceGroup.class));
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup in project so by onap.
the class BBInputSetupTest method testMapCatalogCollectionAndInstanceGroup.
@Test
public void testMapCatalogCollectionAndInstanceGroup() {
ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
modelInfoCollection.setCollectionFunction("collectionFunction");
modelInfoCollection.setCollectionRole("collectionRole");
modelInfoCollection.setCollectionType("collectionType");
modelInfoCollection.setDescription("description");
modelInfoCollection.setModelInvariantUUID("modelInvariantUUID");
modelInfoCollection.setQuantity(0);
ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
modelInfoInstanceGroup.setFunction("function");
modelInfoInstanceGroup.setInstanceGroupRole("instanceGroupRole");
modelInfoInstanceGroup.setModelInvariantUUID("modelInvariantUUID");
modelInfoInstanceGroup.setModelUUID("modelUUID");
modelInfoInstanceGroup.setType("VNFC");
modelInfoInstanceGroup.setDescription("description");
InstanceGroup instanceGroup = new InstanceGroup();
Collection collection = new Collection();
collection.setInstanceGroup(instanceGroup);
CollectionResource collectionResource = new CollectionResource();
org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
collectionResource.setToscaNodeType("NetworkCollection");
collectionResource.setInstanceGroup(catalogInstanceGroup);
CollectionResourceCustomization collectionCust = new NetworkCollectionResourceCustomization();
collectionCust.setModelCustomizationUUID("modelCustomizationUUID");
collectionCust.setCollectionResource(collectionResource);
Service service = new Service();
service.getCollectionResourceCustomizations().add(collectionCust);
ServiceInstance serviceInstance = new ServiceInstance();
serviceInstance.setCollection(collection);
List<CollectionResourceInstanceGroupCustomization> instanceGroupCustList = new ArrayList<>();
CollectionResourceInstanceGroupCustomization instanceGroupCust = new CollectionResourceInstanceGroupCustomization();
instanceGroupCust.setFunction("function");
instanceGroupCust.setDescription("description");
doReturn(modelInfoCollection).when(bbInputSetupMapperLayer).mapCatalogCollectionToCollection(collectionCust, collectionResource);
doReturn(modelInfoInstanceGroup).when(bbInputSetupMapperLayer).mapCatalogInstanceGroupToInstanceGroup(collectionCust, catalogInstanceGroup);
SPY_bbInputSetup.mapCatalogCollection(service, serviceInstance.getCollection(), "modelCustomizationUUID");
SPY_bbInputSetup.mapCatalogNetworkCollectionInstanceGroup(service, serviceInstance.getCollection().getInstanceGroup(), collectionCust.getModelCustomizationUUID());
assertThat(collection.getModelInfoCollection(), sameBeanAs(modelInfoCollection));
assertThat(instanceGroup.getModelInfoInstanceGroup(), sameBeanAs(modelInfoInstanceGroup));
}
Aggregations