Search in sources :

Example 16 with StateTunnelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList in project netvirt by opendaylight.

the class TunnelStateChangeListener method updateTunnelToUnderlayNetworkOperDs.

private void updateTunnelToUnderlayNetworkOperDs(StateTunnelList tunnelState, boolean isAdded) {
    BigInteger srcDpId = getTepDpnId(tunnelState.getSrcInfo());
    BigInteger dstDpId = getTepDpnId(tunnelState.getDstInfo());
    String tunnelInterfaceName = tunnelState.getTunnelInterfaceName();
    if (BigInteger.ZERO.equals(srcDpId) || BigInteger.ZERO.equals(dstDpId)) {
        LOG.warn("No valid DPN found for tunnel {}", tunnelInterfaceName);
        return;
    }
    IpAddress tunnelIp = getTunnelIp(tunnelState);
    if (tunnelIp == null) {
        LOG.warn("No tunnel ip found for tunnel {} DPN {}", tunnelInterfaceName, srcDpId);
        return;
    }
    String underlayNetwork = policyServiceUtil.getTunnelUnderlayNetwork(srcDpId, tunnelIp);
    if (underlayNetwork == null) {
        LOG.debug("No underlay networks defined for tunnel {} DPN {}", tunnelInterfaceName, srcDpId);
        return;
    }
    LOG.info("Handle tunnel state update for interface {} on DPN {} underlay network {}", tunnelInterfaceName, srcDpId, underlayNetwork);
    policyServiceUtil.updateTunnelInterfaceForUnderlayNetwork(underlayNetwork, srcDpId, dstDpId, tunnelInterfaceName, isAdded);
}
Also used : BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Example 17 with StateTunnelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList in project genius by opendaylight.

the class TepCommandHelperTest method setupMocks.

private void setupMocks() {
    System.setOut(new PrintStream(outContent));
    instanceIdentifierList.add(transportZoneIdentifier);
    instanceIdentifierList.add(vtepsIdentifier);
    instanceIdentifierList.add(subnetsIdentifier);
    DeviceVteps deviceVteps = new DeviceVtepsBuilder().setIpAddress(ipAddress1).setKey(new DeviceVtepsKey(ipAddress1, sourceDevice)).setNodeId(sourceDevice).setTopologyId(destinationDevice).build();
    vteps = new VtepsBuilder().setPortname(portName1).setDpnId(dpId2).setIpAddress(ipAddress1).setKey(new VtepsKey(dpId2, portName1)).build();
    vtepsTest = new VtepsBuilder().build();
    deviceVtepsList.add(deviceVteps);
    vtepsList.add(vteps);
    subnetsTest = new SubnetsBuilder().setGatewayIp(gtwyIp1).setVlanId(vlanId).setKey(new SubnetsKey(ipPrefixTest)).setDeviceVteps(deviceVtepsList).setVteps(vtepsList).build();
    subnetsList.add(subnetsTest);
    transportZone = new TransportZoneBuilder().setZoneName(transportZone1).setTunnelType(tunnelType1).setKey(new TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
    transportZoneNew = new TransportZoneBuilder().setZoneName(transportZone1).setTunnelType(tunnelType2).setKey(new TransportZoneKey(transportZone1)).setSubnets(subnetsList).build();
    transportZoneList.add(transportZone);
    transportZones = new TransportZonesBuilder().setTransportZone(transportZoneList).build();
    transportZonesNew = new TransportZonesBuilder().setTransportZone(transportZoneListNew).build();
    tunnelMonitorInterval = new TunnelMonitorIntervalBuilder().setInterval(10000).build();
    tunnelMonitorParams = new TunnelMonitorParamsBuilder().setEnabled(true).build();
    InternalTunnel internalTunnelTest = new InternalTunnelBuilder().setSourceDPN(dpId1).setDestinationDPN(dpId2).setTunnelInterfaceNames(Collections.singletonList(tunnelInterfaceName)).setKey(new InternalTunnelKey(dpId1, dpId2, tunnelType1)).setTransportType(tunnelType1).build();
    internalTunnelList.add(internalTunnelTest);
    StateTunnelList stateTunnelListTest = new StateTunnelListBuilder().setTunnelInterfaceName(tunnelInterfaceName).setOperState(TunnelOperStatus.Up).build();
    stateTunnelList.add(stateTunnelListTest);
    lowerLayerIfList.add(dpId1.toString());
    interfaceTest = new InterfaceBuilder().setOperStatus(Interface.OperStatus.Up).setAdminStatus(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus.Up).setPhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress.getDefaultInstance("AA:AA:AA:AA:AA:AA")).setIfIndex(100).setLowerLayerIf(lowerLayerIfList).setType(L2vlan.class).build();
    interfaceTestNew = ItmUtils.buildTunnelInterface(dpId1, tunnelInterfaceName, destinationDevice, enabled, TunnelTypeVxlan.class, ipAddress1, ipAddress2, gtwyIp1, vlanId, true, enabled, monitorProtocol, interval, false, null);
    doReturn(mockReadTx).when(dataBroker).newReadOnlyTransaction();
    doReturn(mockWriteTx).when(dataBroker).newWriteOnlyTransaction();
    doReturn(Futures.immediateCheckedFuture(null)).when(mockWriteTx).submit();
}
Also used : DeviceVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps) PrintStream(java.io.PrintStream) SubnetsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey) StateTunnelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListBuilder) VtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey) DeviceVtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey) TunnelMonitorParamsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorParamsBuilder) InternalTunnelKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnelKey) TransportZonesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZonesBuilder) TunnelMonitorIntervalBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorIntervalBuilder) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) DeviceVtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsKey) InternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) VtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder) DeviceVtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder) DeviceVtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVtepsBuilder) SubnetsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder) InternalTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnelBuilder) TransportZoneBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)

Example 18 with StateTunnelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList in project genius by opendaylight.

the class ItmTunnelStateAddHelper method addTunnel.

@SuppressWarnings("checkstyle:IllegalCatch")
public static List<ListenableFuture<Void>> addTunnel(Interface iface, IInterfaceManager ifaceManager, DataBroker broker) throws Exception {
    LOG.debug("Invoking ItmTunnelStateAddHelper for Interface {} ", iface);
    final WriteTransaction writeTransaction = broker.newWriteOnlyTransaction();
    StateTunnelListKey tlKey = ItmUtils.getTunnelStateKey(iface);
    LOG.trace("TunnelStateKey: {} for interface: {}", tlKey, iface.getName());
    InstanceIdentifier<StateTunnelList> stListId = ItmUtils.buildStateTunnelListId(tlKey);
    StateTunnelList tunnelStateList;
    TunnelOperStatus tunnelOperStatus;
    boolean tunnelState = iface.getOperStatus().equals(Interface.OperStatus.Up);
    switch(iface.getOperStatus()) {
        case Up:
            tunnelOperStatus = TunnelOperStatus.Up;
            break;
        case Down:
            tunnelOperStatus = TunnelOperStatus.Down;
            break;
        case Unknown:
            tunnelOperStatus = TunnelOperStatus.Unknown;
            break;
        default:
            tunnelOperStatus = TunnelOperStatus.Ignore;
    }
    // Create new Tunnel State
    try {
        /*
             * FIXME: A defensive try-catch to find issues without
             * disrupting existing behavior.
             */
        tunnelStateList = ItmUtils.buildStateTunnelList(tlKey, iface.getName(), tunnelState, tunnelOperStatus, ifaceManager, broker);
        LOG.trace("Batching the Creation of tunnel_state: {} for Id: {}", tunnelStateList, stListId);
        ITMBatchingUtils.write(stListId, tunnelStateList, ITMBatchingUtils.EntityType.DEFAULT_OPERATIONAL);
    } catch (Exception e) {
        LOG.warn("Exception trying to create tunnel state for {}", iface.getName(), e);
    }
    return Collections.singletonList(writeTransaction.submit());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) StateTunnelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListKey) TunnelOperStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList)

Example 19 with StateTunnelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList in project genius by opendaylight.

the class ItmTunnelStateRemoveHelper method removeTunnel.

public static List<ListenableFuture<Void>> removeTunnel(Interface iface, DataBroker broker) throws Exception {
    LOG.debug("Invoking ItmTunnelStateRemoveHelper for Interface {} ", iface);
    WriteTransaction writeTransaction = broker.newWriteOnlyTransaction();
    StateTunnelListKey tlKey = ItmUtils.getTunnelStateKey(iface);
    InstanceIdentifier<StateTunnelList> stListId = ItmUtils.buildStateTunnelListId(tlKey);
    LOG.trace("Deleting tunnel_state for Id: {}", stListId);
    ITMBatchingUtils.delete(stListId, ITMBatchingUtils.EntityType.DEFAULT_OPERATIONAL);
    return Collections.singletonList(writeTransaction.submit());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) StateTunnelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListKey) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList)

Example 20 with StateTunnelList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList in project genius by opendaylight.

the class InterfaceStateListener method updateTunnel.

private List<ListenableFuture<Void>> updateTunnel(Interface updated) throws Exception {
    LOG.debug("Invoking ItmTunnelStateUpdateHelper for Interface {} ", updated);
    final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
    StateTunnelListKey tlKey = ItmUtils.getTunnelStateKey(updated);
    LOG.trace("TunnelStateKey: {} for interface: {}", tlKey, updated.getName());
    InstanceIdentifier<StateTunnelList> stListId = ItmUtils.buildStateTunnelListId(tlKey);
    Optional<StateTunnelList> tunnelsState = tunnelStateCache.get(stListId);
    StateTunnelListBuilder stlBuilder;
    TunnelOperStatus tunnelOperStatus;
    boolean tunnelState = updated.getOperStatus().equals(Interface.OperStatus.Up);
    switch(updated.getOperStatus()) {
        case Up:
            tunnelOperStatus = TunnelOperStatus.Up;
            break;
        case Down:
            tunnelOperStatus = TunnelOperStatus.Down;
            break;
        case Unknown:
            tunnelOperStatus = TunnelOperStatus.Unknown;
            break;
        default:
            tunnelOperStatus = TunnelOperStatus.Ignore;
    }
    if (tunnelsState.isPresent()) {
        stlBuilder = new StateTunnelListBuilder(tunnelsState.get());
        stlBuilder.setTunnelState(tunnelState);
        stlBuilder.setOperState(tunnelOperStatus);
        StateTunnelList stList = stlBuilder.build();
        LOG.trace("Batching the updation of tunnel_state: {} for Id: {}", stList, stListId);
        ITMBatchingUtils.update(stListId, stList, ITMBatchingUtils.EntityType.DEFAULT_OPERATIONAL);
    }
    return Collections.singletonList(writeTransaction.submit());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) StateTunnelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListKey) StateTunnelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListBuilder) TunnelOperStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList)

Aggregations

BigInteger (java.math.BigInteger)9 StateTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList)8 TunnelOperStatus (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus)6 ArrayList (java.util.ArrayList)5 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)4 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)4 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)3 StateTunnelListKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelListKey)3 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)3 AdjacenciesOp (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp)3 Adjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)3 VpnInterfaceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)3 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)3 Optional (com.google.common.base.Optional)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2