Search in sources :

Example 36 with L3Network

use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.

the class CloudInfoFromAAI method getCloudInfoFromAAI.

protected Optional<CloudRegion> getCloudInfoFromAAI(ServiceInstance serviceInstance) throws JsonProcessingException {
    Optional<Relationships> relationshipsOp = Optional.empty();
    if (!serviceInstance.getVnfs().isEmpty()) {
        GenericVnf vnf = serviceInstance.getVnfs().get(0);
        org.onap.aai.domain.yang.GenericVnf aaiVnf = bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId());
        AAIResultWrapper vnfWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiVnf));
        relationshipsOp = getRelationshipsFromWrapper(vnfWrapper);
    } else if (!serviceInstance.getNetworks().isEmpty()) {
        L3Network network = serviceInstance.getNetworks().get(0);
        org.onap.aai.domain.yang.L3Network aaiL3Network = bbInputSetupUtils.getAAIL3Network(network.getNetworkId());
        AAIResultWrapper networkWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiL3Network));
        relationshipsOp = getRelationshipsFromWrapper(networkWrapper);
    } else {
        logger.debug("BBInputSetup could not find a cloud region or tenant, since there are no resources under the SI.");
        return Optional.empty();
    }
    if (relationshipsOp.isPresent()) {
        return getRelatedCloudRegionAndTenant(relationshipsOp.get());
    } else {
        logger.debug("BBInputSetup could not find a cloud region or tenant");
        return Optional.empty();
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Example 37 with L3Network

use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.

the class GeneralTopologyObjectMapperTest method buildNetworkInformationNoModelTest.

@Test
public void buildNetworkInformationNoModelTest() {
    L3Network network = new L3Network();
    network.setNetworkId("my-network-id");
    network.setNetworkType("my-network-type");
    network.setNetworkTechnology("my-network-technology");
    GenericResourceApiNetworkinformationNetworkInformation networkInformation = new GenericResourceApiNetworkinformationNetworkInformation();
    networkInformation.setNetworkId("my-network-id");
    networkInformation.setNetworkType("my-network-type");
    networkInformation.networkTechnology("my-network-technology");
    networkInformation.setFromPreload(null);
    assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network)));
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) GenericResourceApiNetworkinformationNetworkInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkinformationNetworkInformation) Test(org.junit.Test)

Example 38 with L3Network

use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.

the class UnassignNetworkBBTest method checkRelationshipRelatedToTrueTest.

@Test
public void checkRelationshipRelatedToTrueTest() throws Exception {
    expectedException.expect(BpmnError.class);
    network = setL3Network();
    network.setNetworkId("testNetworkId1");
    final String aaiResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "unassignNetworkBB_queryAAIResponse_.json")));
    AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
    Optional<org.onap.aai.domain.yang.L3Network> l3network = aaiResultWrapper.asBean(org.onap.aai.domain.yang.L3Network.class);
    doReturn(network).when(extractPojosForBB).extractByKey(execution, ResourceKey.NETWORK_ID);
    doReturn(aaiResultWrapper).when(aaiNetworkResources).queryNetworkWrapperById(network);
    doReturn(true).when(networkBBUtils).isRelationshipRelatedToExists(any(Optional.class), eq("vf-module"));
    unassignNetworkBB.checkRelationshipRelatedTo(execution, "vf-module");
    assertThat(execution.getVariable("ErrorUnassignNetworkBB"), notNullValue());
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) Optional(java.util.Optional) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 39 with L3Network

use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.

the class AAIQueryTasks method querySubnet.

public void querySubnet(BuildingBlockExecution execution) {
    try {
        L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
        AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
        Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships();
        if (!networkRelationships.isPresent()) {
            throw (new Exception(ERROR_MSG));
        }
        List<AAIResourceUri> subnetsUriList = networkRelationships.get().getRelatedUris(Types.SUBNET);
        if (!subnetsUriList.isEmpty()) {
            for (AAIResourceUri subnetUri : subnetsUriList) {
                Optional<Subnet> oSubnet = aaiNetworkResources.getSubnet(subnetUri);
                if (oSubnet.isPresent()) {
                    l3network.getSubnets().add(modelMapper.map(oSubnet.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet.class));
                }
            }
        }
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) Subnet(org.onap.aai.domain.yang.Subnet) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Example 40 with L3Network

use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.

the class AAIQueryTasks method queryNetworkTableRef.

/**
 * BPMN access method to query data for network table ref from the AAI result wrapper The resulting route table
 * reference is mapped to the corresponding bbobject and added to the network bbobject contrail network route table
 * references list
 *
 * @param execution
 */
public void queryNetworkTableRef(BuildingBlockExecution execution) {
    try {
        L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
        AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
        Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships();
        if (!networkRelationships.isPresent()) {
            throw (new Exception(ERROR_MSG));
        }
        List<AAIResourceUri> routeTableUriList = networkRelationships.get().getRelatedUris(Types.ROUTE_TABLE_REFERENCE);
        if (!routeTableUriList.isEmpty()) {
            for (AAIResourceUri routeTableUri : routeTableUriList) {
                Optional<RouteTableReference> oRouteTableReference = aaiNetworkResources.getRouteTable(routeTableUri);
                if (oRouteTableReference.isPresent()) {
                    org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference mappedRouteTableReference = modelMapper.map(oRouteTableReference.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference.class);
                    l3network.getContrailNetworkRouteTableReferences().add(mappedRouteTableReference);
                }
            }
        }
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) RouteTableReference(org.onap.aai.domain.yang.RouteTableReference) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Aggregations

L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)68 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)34 Test (org.junit.Test)29 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)18 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)13 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)12 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)12 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)11 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)11 Service (org.onap.so.db.catalog.beans.Service)11 File (java.io.File)10 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)10 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)10 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)9 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)9 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)9 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)8 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)8 ModelInfoNetwork (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork)8 ArrayList (java.util.ArrayList)7