Search in sources :

Example 6 with PrefixBuilder

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.igp.node.attributes.PrefixBuilder in project bgpcep by opendaylight.

the class LinkstateNlriParser method serializeAdvertisedNodeDescriptor.

private static void serializeAdvertisedNodeDescriptor(final CLinkstateDestinationBuilder builder, final ChoiceNode objectType) {
    // prefix node descriptors
    final PrefixCaseBuilder prefixBuilder = new PrefixCaseBuilder();
    prefixBuilder.setAdvertisingNodeDescriptors(NodeNlriParser.serializeAdvNodeDescriptors((ContainerNode) objectType.getChild(ADVERTISING_NODE_DESCRIPTORS_NID).get()));
    // prefix descriptors
    final Optional<DataContainerChild<? extends PathArgument, ?>> prefixDescriptors = objectType.getChild(PREFIX_DESCRIPTORS_NID);
    if (prefixDescriptors.isPresent()) {
        prefixBuilder.setPrefixDescriptors(AbstractPrefixNlriParser.serializePrefixDescriptors((ContainerNode) prefixDescriptors.get()));
    }
    builder.setObjectType(prefixBuilder.build());
}
Also used : PrefixCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.PrefixCaseBuilder) DataContainerChild(org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) DataContainerNode(org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)

Example 7 with PrefixBuilder

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.igp.node.attributes.PrefixBuilder in project netvirt by opendaylight.

the class VrfEntryListener method cleanUpOpDataForFib.

protected void cleanUpOpDataForFib(Long vpnId, String primaryRd, final VrfEntry vrfEntry) {
    /* Get interface info from prefix to interface mapping;
        Use the interface info to get the corresponding vpn interface op DS entry,
        remove the adjacency corresponding to this fib entry.
        If adjacency removed is the last adjacency, clean up the following:
         - vpn interface from dpntovpn list, dpn if last vpn interface on dpn
         - prefix to interface entry
         - vpn interface op DS
     */
    LOG.debug("Cleanup of prefix {} in VPN {}", vrfEntry.getDestPrefix(), vpnId);
    Prefixes prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
    if (prefixInfo == null) {
        List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, vrfEntry.getDestPrefix());
        String usedRd = usedRds.isEmpty() ? primaryRd : usedRds.get(0);
        Routes extraRoute = baseVrfEntryHandler.getVpnToExtraroute(vpnId, usedRd, vrfEntry.getDestPrefix());
        if (extraRoute != null) {
            for (String nextHopIp : extraRoute.getNexthopIpList()) {
                LOG.debug("NextHop IP for destination {} is {}", vrfEntry.getDestPrefix(), nextHopIp);
                if (nextHopIp != null) {
                    String ipPrefix;
                    if (isIpv4Address(nextHopIp)) {
                        ipPrefix = nextHopIp + NwConstants.IPV4PREFIX;
                    } else {
                        ipPrefix = nextHopIp + NwConstants.IPV6PREFIX;
                    }
                    prefixInfo = fibUtil.getPrefixToInterface(vpnId, ipPrefix);
                    checkCleanUpOpDataForFib(prefixInfo, vpnId, primaryRd, vrfEntry, extraRoute);
                }
            }
        }
        if (prefixInfo == null) {
            java.util.Optional<Long> optionalLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
            if (optionalLabel.isPresent()) {
                Long label = optionalLabel.get();
                List<String> nextHopAddressList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
                LabelRouteInfo lri = getLabelRouteInfo(label);
                if (isPrefixAndNextHopPresentInLri(vrfEntry.getDestPrefix(), nextHopAddressList, lri)) {
                    PrefixesBuilder prefixBuilder = new PrefixesBuilder();
                    prefixBuilder.setDpnId(lri.getDpnId());
                    prefixBuilder.setVpnInterfaceName(lri.getVpnInterfaceName());
                    prefixBuilder.setIpAddress(lri.getPrefix());
                    prefixInfo = prefixBuilder.build();
                    LOG.debug("Fetched labelRouteInfo for label {} interface {} and got dpn {}", label, prefixInfo.getVpnInterfaceName(), lri.getDpnId());
                    checkCleanUpOpDataForFib(prefixInfo, vpnId, primaryRd, vrfEntry, extraRoute);
                }
            }
        }
    } else {
        checkCleanUpOpDataForFib(prefixInfo, vpnId, primaryRd, vrfEntry, null);
    }
}
Also used : LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) PrefixesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.PrefixesBuilder) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes)

Example 8 with PrefixBuilder

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.igp.node.attributes.PrefixBuilder in project netvirt by opendaylight.

the class VrfEntryListener method updateVpnReferencesInLri.

private Prefixes updateVpnReferencesInLri(LabelRouteInfo lri, String vpnInstanceName, boolean isPresentInList) {
    LOG.debug("updating LRI : for label {} vpninstancename {}", lri.getLabel(), vpnInstanceName);
    PrefixesBuilder prefixBuilder = new PrefixesBuilder();
    prefixBuilder.setDpnId(lri.getDpnId());
    prefixBuilder.setVpnInterfaceName(lri.getVpnInterfaceName());
    prefixBuilder.setIpAddress(lri.getPrefix());
    // Increment the refCount here
    InstanceIdentifier<LabelRouteInfo> lriId = InstanceIdentifier.builder(LabelRouteMap.class).child(LabelRouteInfo.class, new LabelRouteInfoKey(lri.getLabel())).build();
    LabelRouteInfoBuilder builder = new LabelRouteInfoBuilder(lri);
    if (!isPresentInList) {
        LOG.debug("vpnName {} is not present in LRI with label {}..", vpnInstanceName, lri.getLabel());
        List<String> vpnInstanceNames = lri.getVpnInstanceList();
        vpnInstanceNames.add(vpnInstanceName);
        builder.setVpnInstanceList(vpnInstanceNames);
        MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, lriId, builder.build());
    } else {
        LOG.debug("vpnName {} is present in LRI with label {}..", vpnInstanceName, lri.getLabel());
    }
    return prefixBuilder.build();
}
Also used : LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) PrefixesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.PrefixesBuilder) LabelRouteInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder) LabelRouteInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoKey)

Aggregations

PrefixesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.PrefixesBuilder)4 LabelRouteInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo)3 Prefixes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes)3 ArrayList (java.util.ArrayList)2 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)2 Routes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes)2 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)2 IgpNodeAttributes (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.IgpNodeAttributes)2 Prefix (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.igp.node.attributes.Prefix)2 PrefixBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.igp.node.attributes.PrefixBuilder)2 PrefixKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.igp.node.attributes.PrefixKey)2 BigInteger (java.math.BigInteger)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)1 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)1 LabelRouteInfoBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder)1 LabelRouteInfoKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoKey)1 PrefixToInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.PrefixToInterface)1 PrefixesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.PrefixesKey)1 Ipv4Prefixes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.prefixes.destination.ipv4.Ipv4Prefixes)1