Search in sources :

Example 91 with Interface

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.Interface in project netvirt by opendaylight.

the class L3vpnOverMplsGrePopulator method populateFib.

@Override
public void populateFib(L3vpnInput input, WriteTransaction writeConfigTxn) {
    if (input.getRouteOrigin() == RouteOrigin.CONNECTED) {
        LOG.info("populateFib : Found SubnetRoute for subnet {} rd {}", input.getSubnetIp(), input.getPrimaryRd());
        addSubnetRouteFibEntry(input);
        return;
    }
    Adjacency nextHop = input.getNextHop();
    long label = nextHop.getLabel();
    String vpnName = input.getVpnName();
    String primaryRd = input.getPrimaryRd();
    String rd = input.getRd();
    String nextHopIp = input.getNextHopIp();
    VrfEntry.EncapType encapType = input.getEncapType();
    LOG.info("populateFib : Found Interface Adjacency with prefix {} rd {}", nextHop.getIpAddress(), primaryRd);
    List<VpnInstanceOpDataEntry> vpnsToImportRoute = VpnUtil.getVpnsImportingMyRoute(broker, vpnName);
    long vpnId = VpnUtil.getVpnId(broker, vpnName);
    // it is a valid case for nextHopIpAddress to be null
    String nextHopIpAddress = nextHop.getIpAddress();
    // and internalVpnForExtraRoute (where rd is DpnId)
    if (VpnUtil.isEligibleForBgp(primaryRd, input.getVpnName(), input.getDpnId(), input.getNetworkName())) {
        // the DpnId is set as rd in case of extra routes present in router based VPN
        addToLabelMapper(label, input.getDpnId(), nextHopIpAddress, Arrays.asList(nextHopIp), vpnId, input.getInterfaceName(), null, false, primaryRd);
        Objects.requireNonNull(input.getRouteOrigin(), "RouteOrigin is mandatory");
        addPrefixToBGP(rd, primaryRd, null, /*macAddress*/
        nextHopIpAddress, nextHopIp, encapType, label, 0, /*l3vni*/
        input.getGatewayMac(), input.getRouteOrigin(), writeConfigTxn);
        // TODO: ERT - check for VPNs importing my route
        for (VpnInstanceOpDataEntry vpn : vpnsToImportRoute) {
            String vpnRd = vpn.getVrfId();
            if (vpnRd != null) {
                fibManager.addOrUpdateFibEntry(vpnRd, null, /*macAddress*/
                nextHopIpAddress, Arrays.asList(nextHopIp), encapType, (int) label, 0, /*l3vni*/
                input.getGatewayMac(), null, /*parentVpnRd*/
                RouteOrigin.SELF_IMPORTED, writeConfigTxn);
                LOG.info("populateFib: Exported route with rd {} prefix {} nexthop {} label {}" + " to VPN {} for interface {} on dpn {}", vpnRd, nextHop.getIpAddress(), nextHopIp, label, vpn, input.getInterfaceName(), input.getDpnId());
            }
        }
    } else {
        // ### add FIB route directly
        fibManager.addOrUpdateFibEntry(vpnName, null, /*macAddress*/
        nextHopIpAddress, Arrays.asList(nextHopIp), encapType, (int) label, 0, /*l3vni*/
        input.getGatewayMac(), null, /*parentVpnRd*/
        input.getRouteOrigin(), writeConfigTxn);
        LOG.info("populateFib: Added internal FIB entry for prefix {} nexthop {} label {}" + " to VPN {} for interface {} on dpn {}", nextHop.getIpAddress(), nextHopIp, label, vpnName, input.getInterfaceName(), input.getDpnId());
    }
}
Also used : VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)

Example 92 with Interface

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.Interface in project netvirt by opendaylight.

the class L3vpnOverVxlanPopulator method populateFib.

@Override
public void populateFib(L3vpnInput input, WriteTransaction writeConfigTxn) {
    if (input.getRouteOrigin() == RouteOrigin.CONNECTED) {
        LOG.info("populateFib : Found SubnetRoute for subnet {} rd {}", input.getSubnetIp(), input.getPrimaryRd());
        addSubnetRouteFibEntry(input);
        return;
    }
    String rd = input.getRd();
    String primaryRd = input.getPrimaryRd();
    Adjacency nextHop = input.getNextHop();
    LOG.info("populateFib : Found Interface Adjacency with prefix {} rd {}", nextHop.getIpAddress(), primaryRd);
    if (!rd.equalsIgnoreCase(input.getVpnName()) && !rd.equals(input.getNetworkName())) {
        Objects.requireNonNull(input.getRouteOrigin(), "populateFib: RouteOrigin is mandatory");
        addPrefixToBGP(rd, primaryRd, nextHop.getMacAddress(), nextHop.getIpAddress(), input.getNextHopIp(), input.getEncapType(), 0, /*label*/
        input.getL3vni(), input.getGatewayMac(), input.getRouteOrigin(), writeConfigTxn);
    } else {
        LOG.error("Internal VPN for L3 Over VxLAN is not supported. Aborting.");
        return;
    }
}
Also used : Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)

Example 93 with Interface

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.Interface in project netvirt by opendaylight.

the class DhcpInterfaceEventListener method remove.

@Override
protected void remove(InstanceIdentifier<Interface> identifier, Interface del) {
    if (!L2vlan.class.equals(del.getType()) && !Tunnel.class.equals(del.getType())) {
        return;
    }
    List<String> ofportIds = del.getLowerLayerIf();
    if (ofportIds == null || ofportIds.isEmpty()) {
        return;
    }
    String interfaceName = del.getName();
    Port port = dhcpPortCache.get(interfaceName);
    if (NeutronConstants.IS_DHCP_PORT.test(port)) {
        return;
    }
    NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
    BigInteger dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
    DhcpInterfaceRemoveJob job = new DhcpInterfaceRemoveJob(dhcpManager, dhcpExternalTunnelManager, dataBroker, del, dpnId, interfaceManager, elanService, port);
    jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), job, DhcpMConstants.RETRY_COUNT);
    dhcpPortCache.remove(interfaceName);
}
Also used : Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) BigInteger(java.math.BigInteger) DhcpInterfaceRemoveJob(org.opendaylight.netvirt.dhcpservice.jobs.DhcpInterfaceRemoveJob)

Example 94 with Interface

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.Interface in project netvirt by opendaylight.

the class DhcpInterfaceEventListener method update.

@Override
protected void update(InstanceIdentifier<Interface> identifier, Interface original, Interface update) {
    // We're only interested in Vlan and Tunnel ports
    if (!L2vlan.class.equals(update.getType()) && !Tunnel.class.equals(update.getType())) {
        return;
    }
    if ((original.getOperStatus().getIntValue() ^ update.getOperStatus().getIntValue()) == 0) {
        LOG.trace("Interface operstatus {} is same", update.getOperStatus());
        return;
    }
    if (original.getOperStatus().equals(OperStatus.Unknown) || update.getOperStatus().equals(OperStatus.Unknown)) {
        LOG.trace("New/old interface state is unknown not handling");
        return;
    }
    List<String> ofportIds = update.getLowerLayerIf();
    if (ofportIds == null || ofportIds.isEmpty()) {
        return;
    }
    NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
    BigInteger dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
    String interfaceName = update.getName();
    DhcpInterfaceUpdateJob job = new DhcpInterfaceUpdateJob(dhcpExternalTunnelManager, dataBroker, interfaceName, dpnId, update.getOperStatus(), interfaceManager);
    jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), job, DhcpMConstants.RETRY_COUNT);
}
Also used : NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) BigInteger(java.math.BigInteger) DhcpInterfaceUpdateJob(org.opendaylight.netvirt.dhcpservice.jobs.DhcpInterfaceUpdateJob)

Example 95 with Interface

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.Interface in project netvirt by opendaylight.

the class DhcpInterfaceEventListener method add.

@Override
protected void add(InstanceIdentifier<Interface> identifier, Interface add) {
    // We're only interested in Vlan and Tunnel ports
    if (!L2vlan.class.equals(add.getType()) && !Tunnel.class.equals(add.getType())) {
        return;
    }
    String interfaceName = add.getName();
    LOG.trace("DhcpInterfaceAddJob to be created for interface {}", interfaceName);
    List<String> ofportIds = add.getLowerLayerIf();
    if (ofportIds == null || ofportIds.isEmpty()) {
        return;
    }
    Port port = dhcpManager.getNeutronPort(interfaceName);
    if (NeutronConstants.IS_DHCP_PORT.test(port)) {
        return;
    }
    dhcpPortCache.put(interfaceName, port);
    NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
    BigInteger dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
    DhcpInterfaceAddJob job = new DhcpInterfaceAddJob(dhcpManager, dhcpExternalTunnelManager, dataBroker, add, dpnId, interfaceManager, elanService);
    jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), job, DhcpMConstants.RETRY_COUNT);
}
Also used : Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) BigInteger(java.math.BigInteger) DhcpInterfaceAddJob(org.opendaylight.netvirt.dhcpservice.jobs.DhcpInterfaceAddJob)

Aggregations

BigInteger (java.math.BigInteger)131 ArrayList (java.util.ArrayList)117 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)69 ExecutionException (java.util.concurrent.ExecutionException)64 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)56 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)52 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)47 List (java.util.List)45 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)44 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)40 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)39 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)39 Logger (org.slf4j.Logger)39 LoggerFactory (org.slf4j.LoggerFactory)39 Collections (java.util.Collections)38 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)37 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)34 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)33 Adjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)33 VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)32