Search in sources :

Example 1 with MdsalEvent

use of org.opendaylight.netvirt.elan.l2gw.MdsalEvent in project netvirt by opendaylight.

the class HwvtepPhysicalSwitchListener method handleAdd.

/**
 * Handle add.
 *
 * @param l2GwDevice
 *            the l2 gw device
 */
private void handleAdd(L2GatewayDevice l2GwDevice, InstanceIdentifier<PhysicalSwitchAugmentation> identifier, PhysicalSwitchAugmentation phySwitchAdded) {
    LOG.info("PhysicalSwitchListener Handle add of tunnel ips {} psNode {} device {}", phySwitchAdded.getTunnelIps(), identifier.firstKeyOf(Node.class).getNodeId(), l2GwDevice);
    final String psName = l2GwDevice.getDeviceName();
    final String hwvtepNodeId = l2GwDevice.getHwvtepNodeId();
    Set<IpAddress> tunnelIps = l2GwDevice.getTunnelIps();
    if (tunnelIps != null) {
        // TODO add logical switch and mcast put itm tep event and update mcast
        hwvtepHACache.addDebugEvent(new MdsalEvent("ps add provision", l2GwDevice.getHwvtepNodeId()));
        for (final IpAddress tunnelIpAddr : tunnelIps) {
            if (L2GatewayConnectionUtils.isGatewayAssociatedToL2Device(l2GwDevice)) {
                LOG.info("PhysicalSwitchListener 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 : {}", hwvtepNodeId, psName);
            }
        }
        InstanceIdentifier<Node> globalNodeIid = HwvtepSouthboundUtils.createInstanceIdentifier(new NodeId(hwvtepNodeId));
        HwvtepHACache.getInstance().setTepIpOfNode(globalNodeIid, tunnelIps.iterator().next());
        elanClusterUtils.runOnlyInOwnerNode(psName, "Stale entry cleanup", () -> {
            InstanceIdentifier<Node> psIid = HwvtepSouthboundUtils.createInstanceIdentifier(HwvtepSouthboundUtils.createManagedNodeId(new NodeId(hwvtepNodeId), psName));
            staleVlanBindingsCleaner.scheduleStaleCleanup(psName, globalNodeIid, psIid);
            transportZoneListener.createL2gwZeroDayConfig();
            return Collections.emptyList();
        });
    }
}
Also used : MdsalEvent(org.opendaylight.netvirt.elan.l2gw.MdsalEvent) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Example 2 with MdsalEvent

use of org.opendaylight.netvirt.elan.l2gw.MdsalEvent in project netvirt by opendaylight.

the class HAOpClusteredListener method onGlobalNodeAdd.

@Override
public synchronized void onGlobalNodeAdd(InstanceIdentifier<Node> key, Node updated, TypedReadWriteTransaction<Operational> tx) {
    connectedNodes.add(key);
    addToCacheIfHAChildNode(key, updated);
    hwvtepHACache.updateConnectedNodeStatus(key);
    if (waitingJobs.containsKey(key) && !waitingJobs.get(key).isEmpty()) {
        try {
            HAJobScheduler jobScheduler = HAJobScheduler.getInstance();
            Optional<Node> nodeOptional = tx.read(key).get();
            if (nodeOptional.isPresent()) {
                waitingJobs.get(key).forEach((waitingJob) -> jobScheduler.submitJob(() -> waitingJob.accept(nodeOptional)));
                waitingJobs.get(key).clear();
                hwvtepHACache.addDebugEvent(new MdsalEvent("Waiting jobs of node are run ", getNodeId(key)));
            } else {
                LOG.error("Failed to read oper node {}", key);
            }
        } catch (InterruptedException | ExecutionException e) {
            LOG.error("Failed to read oper node {}", key);
        }
    }
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) MdsalEvent(org.opendaylight.netvirt.elan.l2gw.MdsalEvent) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with MdsalEvent

use of org.opendaylight.netvirt.elan.l2gw.MdsalEvent in project netvirt by opendaylight.

the class HAOpClusteredListener method onGlobalNodeUpdate.

@Override
void onGlobalNodeUpdate(InstanceIdentifier<Node> childPath, Node updatedChildNode, Node beforeChildNode, DataObjectModification<Node> mod, TypedReadWriteTransaction<Operational> tx) {
    boolean wasHAChild = hwvtepHACache.isHAEnabledDevice(childPath);
    addToHACacheIfBecameHAChild(childPath, updatedChildNode, beforeChildNode);
    boolean isHAChild = hwvtepHACache.isHAEnabledDevice(childPath);
    if (!wasHAChild && isHAChild) {
        hwvtepHACache.addDebugEvent(new MdsalEvent(getNodeId(childPath), "became ha child"));
        LOG.debug("{} became ha_child", getNodeId(childPath));
    } else if (wasHAChild && !isHAChild) {
        LOG.debug("{} unbecome ha_child", getNodeId(childPath));
    }
}
Also used : MdsalEvent(org.opendaylight.netvirt.elan.l2gw.MdsalEvent)

Aggregations

MdsalEvent (org.opendaylight.netvirt.elan.l2gw.MdsalEvent)3 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)2 ExecutionException (java.util.concurrent.ExecutionException)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)1