use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels in project netvirt by opendaylight.
the class ElanItmUtils method buildItmEgressActions.
/**
* Builds the list of actions to be taken when sending the packet over external port such as tunnel, physical
* port etc.
*
* @param interfaceName
* the interface name
* @param tunnelKey
* can be VNI for VxLAN tunnel interfaces, Gre Key for GRE
* tunnels, etc.
* @return the list
*/
@SuppressWarnings("checkstyle:IllegalCatch")
public List<Action> buildItmEgressActions(String interfaceName, Long tunnelKey) {
List<Action> result = Collections.emptyList();
try {
GetEgressActionsForInterfaceInput getEgressActInput = new GetEgressActionsForInterfaceInputBuilder().setIntfName(interfaceName).setTunnelKey(tunnelKey).build();
Future<RpcResult<GetEgressActionsForInterfaceOutput>> egressActionsOutputFuture = interfaceManagerRpcService.getEgressActionsForInterface(getEgressActInput);
if (egressActionsOutputFuture.get().isSuccessful()) {
GetEgressActionsForInterfaceOutput egressActionsOutput = egressActionsOutputFuture.get().getResult();
result = egressActionsOutput.getAction();
}
} catch (Exception e) {
LOG.error("Error in RPC call getEgressActionsForInterface {}", e);
}
if (result == null || result.isEmpty()) {
LOG.warn("Could not build Egress actions for interface {} and tunnelId {}", interfaceName, tunnelKey);
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels in project netvirt by opendaylight.
the class ElanUtils method getEgressActionsForInterface.
/**
* Returns the list of Actions to be taken when sending the packet through
* an Elan interface. Note that this interface can refer to an ElanInterface
* where the Elan VM is attached to a DPN or an ITM tunnel interface where
* Elan traffic can be sent through. In this latter case, the tunnelKey is
* mandatory and it can hold serviceId for internal tunnels or the VNI for
* external tunnels.
*
* @param ifName
* the if name
* @param tunnelKey
* the tunnel key
* @return the egress actions for interface
*/
@SuppressWarnings("checkstyle:IllegalCatch")
public List<Action> getEgressActionsForInterface(String ifName, Long tunnelKey) {
List<Action> listAction = new ArrayList<>();
try {
GetEgressActionsForInterfaceInput getEgressActionInput = new GetEgressActionsForInterfaceInputBuilder().setIntfName(ifName).setTunnelKey(tunnelKey).build();
Future<RpcResult<GetEgressActionsForInterfaceOutput>> result = interfaceManagerRpcService.getEgressActionsForInterface(getEgressActionInput);
RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
if (!rpcResult.isSuccessful()) {
LOG.debug("RPC Call to Get egress actions for interface {} returned with Errors {}", ifName, rpcResult.getErrors());
} else {
List<Action> actions = rpcResult.getResult().getAction();
listAction = actions;
}
} catch (Exception e) {
LOG.warn("Exception when egress actions for interface {}", ifName, e);
}
return listAction;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels in project netvirt by opendaylight.
the class HwvtepPhysicalSwitchListener method added.
@Override
protected void added(InstanceIdentifier<PhysicalSwitchAugmentation> identifier, final PhysicalSwitchAugmentation phySwitchAdded) {
String globalNodeId = getManagedByNodeId(identifier);
final InstanceIdentifier<Node> globalNodeIid = getManagedByNodeIid(identifier);
NodeId nodeId = getNodeId(identifier);
if (TUNNEL_IP_NOT_AVAILABLE.test(phySwitchAdded)) {
LOG.error("Could not find the /tunnel ips for node {}", nodeId.getValue());
return;
}
final String psName = getPsName(identifier);
LOG.trace("Received physical switch {} added event received for node {}", psName, nodeId.getValue());
haOpClusteredListener.runAfterNodeIsConnected(globalNodeIid, (node) -> {
LOG.trace("Running job for node {} ", globalNodeIid);
if (!node.isPresent()) {
LOG.error("Global node is absent {}", globalNodeId);
return;
}
HAOpClusteredListener.addToCacheIfHAChildNode(globalNodeIid, node.get());
if (hwvtepHACache.isHAEnabledDevice(globalNodeIid)) {
LOG.trace("Ha enabled device {}", globalNodeIid);
return;
}
LOG.trace("Updating cache for node {}", globalNodeIid);
L2GatewayDevice l2GwDevice = l2GatewayCache.get(psName);
if (childConnectedAfterParent.test(l2GwDevice, globalNodeIid)) {
LOG.trace("Device {} {} is already Connected by {}", psName, globalNodeId, l2GwDevice.getHwvtepNodeId());
return;
}
InstanceIdentifier<Node> existingIid = globalNodeIid;
if (l2GwDevice != null && l2GwDevice.getHwvtepNodeId() != null) {
existingIid = HwvtepHAUtil.convertToInstanceIdentifier(l2GwDevice.getHwvtepNodeId());
}
if (parentConnectedAfterChild.test(l2GwDevice, globalNodeIid) && alreadyHasL2Gwids.test(l2GwDevice)) {
LOG.error("Child node {} having l2gw configured became ha node " + " removing the l2device {} from all elan cache and provision parent node {}", existingIid, psName, globalNodeIid);
ElanL2GwCacheUtils.removeL2GatewayDeviceFromAllElanCache(l2GwDevice.getHwvtepNodeId());
}
l2GwDevice = l2GatewayCache.addOrGet(psName);
l2GwDevice.setConnected(true);
l2GwDevice.setHwvtepNodeId(globalNodeId);
List<TunnelIps> tunnelIps = phySwitchAdded.getTunnelIps();
if (tunnelIps != null) {
for (TunnelIps tunnelIp : tunnelIps) {
IpAddress tunnelIpAddr = tunnelIp.getTunnelIpsKey();
l2GwDevice.addTunnelIp(tunnelIpAddr);
}
}
handleAdd(l2GwDevice);
elanClusterUtils.runOnlyInOwnerNode("Update config tunnels IP ", () -> {
try {
updateConfigTunnelIp(identifier, phySwitchAdded);
} catch (ReadFailedException e) {
LOG.error("Failed to update tunnel ips {}", identifier);
}
});
return;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels in project netvirt by opendaylight.
the class HwvtepPhysicalSwitchListener method handleAdd.
/**
* Handle add.
*
* @param l2GwDevice
* the l2 gw device
*/
private void handleAdd(L2GatewayDevice l2GwDevice) {
final String psName = l2GwDevice.getDeviceName();
final String hwvtepNodeId = l2GwDevice.getHwvtepNodeId();
Set<IpAddress> tunnelIps = l2GwDevice.getTunnelIps();
for (final IpAddress tunnelIpAddr : tunnelIps) {
if (L2GatewayConnectionUtils.isGatewayAssociatedToL2Device(l2GwDevice)) {
LOG.debug("L2Gateway {} associated for {} physical switch; creating ITM tunnels for {}", l2GwDevice.getL2GatewayIds(), psName, tunnelIpAddr);
l2gwServiceProvider.provisionItmAndL2gwConnection(l2GwDevice, psName, hwvtepNodeId, tunnelIpAddr);
} else {
LOG.info("l2gw.provision.skip {}:{}", hwvtepNodeId, psName);
}
}
elanClusterUtils.runOnlyInOwnerNode("Stale entry cleanup", () -> {
InstanceIdentifier<Node> globalNodeIid = HwvtepSouthboundUtils.createInstanceIdentifier(new NodeId(hwvtepNodeId));
InstanceIdentifier<Node> psIid = HwvtepSouthboundUtils.createInstanceIdentifier(HwvtepSouthboundUtils.createManagedNodeId(new NodeId(hwvtepNodeId), psName));
staleVlanBindingsCleaner.scheduleStaleCleanup(psName, globalNodeIid, psIid);
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels in project netvirt by opendaylight.
the class TunnelCmd method areEqual.
@Override
public boolean areEqual(Tunnels updated, Tunnels orig) {
InstanceIdentifier<TerminationPoint> remoteLocatorRefUpdated = (InstanceIdentifier<TerminationPoint>) updated.getRemoteLocatorRef().getValue();
InstanceIdentifier<TerminationPoint> remoteLocatorRefOriginal = (InstanceIdentifier<TerminationPoint>) orig.getRemoteLocatorRef().getValue();
TpId tpId1 = remoteLocatorRefUpdated.firstKeyOf(TerminationPoint.class).getTpId();
TpId tpId2 = remoteLocatorRefOriginal.firstKeyOf(TerminationPoint.class).getTpId();
return tpId1.equals(tpId2);
}
Aggregations