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);
}
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();
}
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());
}
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());
}
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());
}
Aggregations