Search in sources :

Example 26 with InstanceGroup

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;
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection) OrchestrationStatusValidationException(org.onap.so.client.exception.OrchestrationStatusValidationException) OrchestrationStatus(org.onap.so.db.catalog.beans.OrchestrationStatus) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)

Example 27 with InstanceGroup

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));
}
Also used : AAIObjectInstanceNameGenerator(org.onap.so.bpmn.infrastructure.common.name.generation.AAIObjectInstanceNameGenerator) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) Test(org.junit.Test)

Example 28 with InstanceGroup

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);
}
Also used : CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) ArrayList(java.util.ArrayList) Service(org.onap.so.db.catalog.beans.Service) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection) ModelInfoCollection(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) File(java.io.File) Test(org.junit.Test)

Example 29 with InstanceGroup

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));
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) Service(org.onap.so.db.catalog.beans.Service) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) Test(org.junit.Test)

Example 30 with InstanceGroup

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));
}
Also used : CollectionResource(org.onap.so.db.catalog.beans.CollectionResource) CollectionResourceInstanceGroupCustomization(org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization) ArrayList(java.util.ArrayList) ModelInfoCollection(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection) Service(org.onap.so.db.catalog.beans.Service) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) ModelInfoServiceInstance(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup) Collection(org.onap.so.bpmn.servicedecomposition.bbobjects.Collection) ModelInfoCollection(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection) CollectionResourceCustomization(org.onap.so.db.catalog.beans.CollectionResourceCustomization) NetworkCollectionResourceCustomization(org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization) Test(org.junit.Test)

Aggregations

InstanceGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)32 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)14 ModelInfoInstanceGroup (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup)13 Test (org.junit.Test)9 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)9 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)9 Collection (org.onap.so.bpmn.servicedecomposition.bbobjects.Collection)8 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)7 ArrayList (java.util.ArrayList)6 Service (org.onap.so.db.catalog.beans.Service)4 AAIFluentTypeBuilder (org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder)3 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)3 ServiceSubscription (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription)3 ModelInfoCollection (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection)3 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)3 NetworkCollectionResourceCustomization (org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization)3 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 GenericResourceApiVnfOperationInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation)2 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)2