Search in sources :

Example 6 with L3Network

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

the class AAICreateTasks method createNetwork.

/**
 * BPMN access method to execute Create L3Network operation (PUT )in AAI
 *
 * @param execution
 * @throws Exception
 */
public void createNetwork(BuildingBlockExecution execution) {
    try {
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
        // set default to false. ToBe updated by SDNC
        l3network.setIsBoundToVpn(false);
        // define is bound to vpn flag as true if NEUTRON_NETWORK_TYPE is PROVIDER
        if (l3network.getModelInfoNetwork().getNeutronNetworkType().equalsIgnoreCase(networkTypeProvider))
            l3network.setIsBoundToVpn(true);
        // put network shell in AAI
        aaiNetworkResources.createNetworkConnectToServiceInstance(l3network, serviceInstance);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

Example 7 with L3Network

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

the class AAICreateTasks method connectNetworkToNetworkCollectionServiceInstance.

/**
 * BPMN access method to establish relationships in AAI
 *
 * @param execution
 * @throws Exception
 */
public void connectNetworkToNetworkCollectionServiceInstance(BuildingBlockExecution execution) {
    try {
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
        aaiNetworkResources.connectNetworkToNetworkCollectionServiceInstance(l3network, serviceInstance);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

Example 8 with L3Network

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

the class AAIQueryTasks method queryNetworkVpnBinding.

/**
 * BPMN access method to query data for VPN bindings from the AAI result wrapper. The resulting VPN bindings are
 * mapped to the corresponding bbobject and placed in the customer bbobject
 *
 * @param execution
 */
public void queryNetworkVpnBinding(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> netBindingsUriList = networkRelationships.get().getRelatedUris(Types.VPN_BINDING);
        List<org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding> mappedVpnBindings = new ArrayList<>();
        if (netBindingsUriList != null && !netBindingsUriList.isEmpty()) {
            for (AAIResourceUri netBindingUri : netBindingsUriList) {
                Optional<VpnBinding> oVpnBinding = aaiNetworkResources.getVpnBinding(netBindingUri);
                if (oVpnBinding.isPresent()) {
                    org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding mappedVpnBinding = modelMapper.map(oVpnBinding.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding.class);
                    if (oVpnBinding.get().getRouteTargets() != null) {
                        mappedVpnBinding.getRouteTargets().addAll(mapRouteTargets(oVpnBinding.get().getRouteTargets().getRouteTarget()));
                        mappedVpnBindings.add(mappedVpnBinding);
                    }
                }
            }
        }
        execution.getGeneralBuildingBlock().getCustomer().getVpnBindings().addAll(mappedVpnBindings);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ArrayList(java.util.ArrayList) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) VpnBinding(org.onap.aai.domain.yang.VpnBinding) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Example 9 with L3Network

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

the class AAIQueryTasks method getNetworkVpnBinding.

/**
 * BPMN access method to extract VPN Binding data from AAI result and populate proper fields into
 * CreateNetworkRequest
 */
public void getNetworkVpnBinding(BuildingBlockExecution execution) {
    try {
        L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
        AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
        CreateNetworkRequest createNetworkRequest = execution.getVariable("createNetworkRequest");
        Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships();
        if (!networkRelationships.isPresent()) {
            throw (new Exception(ERROR_MSG));
        }
        List<AAIResourceUri> netBindingsUriList = networkRelationships.get().getRelatedUris(Types.VPN_BINDING);
        List<org.onap.so.openstack.beans.RouteTarget> routeTargets = new ArrayList<>();
        for (AAIResourceUri netBindingUri : netBindingsUriList) {
            logger.info("Get Route Targests");
            Optional<VpnBinding> oVpnBinding = aaiNetworkResources.getVpnBinding(netBindingUri);
            if (oVpnBinding.isPresent()) {
                VpnBinding vpnBinding = oVpnBinding.get();
                RouteTargets rts = vpnBinding.getRouteTargets();
                if (rts != null) {
                    List<org.onap.aai.domain.yang.RouteTarget> rtList = rts.getRouteTarget();
                    if (!rtList.isEmpty()) {
                        PropertyMap<org.onap.aai.domain.yang.RouteTarget, org.onap.so.openstack.beans.RouteTarget> personMap = new PropertyMap<org.onap.aai.domain.yang.RouteTarget, org.onap.so.openstack.beans.RouteTarget>() {

                            @Override
                            protected void configure() {
                                map().setRouteTarget(source.getGlobalRouteTarget());
                                map(source.getRouteTargetRole(), destination.getRouteTargetRole());
                            }
                        };
                        modelMapper.addMappings(personMap);
                        for (org.onap.aai.domain.yang.RouteTarget rt : rtList) {
                            org.onap.so.openstack.beans.RouteTarget openstackRtBean = modelMapper.map(rt, org.onap.so.openstack.beans.RouteTarget.class);
                            routeTargets.add(openstackRtBean);
                        }
                    }
                }
            }
        }
        // store route targets data in execution - to be used as part of
        // Network adapter input
        createNetworkRequest.getContrailNetwork().setRouteTargets(routeTargets);
        execution.setVariable("createNetworkRequest", createNetworkRequest);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) ArrayList(java.util.ArrayList) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) RouteTargets(org.onap.aai.domain.yang.RouteTargets) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) CreateNetworkRequest(org.onap.so.adapters.nwrest.CreateNetworkRequest) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) VpnBinding(org.onap.aai.domain.yang.VpnBinding) PropertyMap(org.modelmapper.PropertyMap)

Example 10 with L3Network

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

the class AAIQueryTasks method queryNetworkPolicy.

/**
 * BPMN access method to query data for network policies from the AAI result wrapper From the resulting network
 * policy, the network policy fqdn parameter is added to the network bbobject contrail network policy fqdns list
 *
 * @param execution
 */
public void queryNetworkPolicy(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> netPoliciesUriList = networkRelationships.get().getRelatedUris(Types.NETWORK_POLICY);
        if (!netPoliciesUriList.isEmpty()) {
            for (AAIResourceUri netPolicyUri : netPoliciesUriList) {
                Optional<NetworkPolicy> oNetPolicy = aaiNetworkResources.getNetworkPolicy(netPolicyUri);
                if (oNetPolicy.isPresent()) {
                    l3network.getNetworkPolicies().add(modelMapper.map(oNetPolicy.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy.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) NetworkPolicy(org.onap.aai.domain.yang.NetworkPolicy) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) 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