Search in sources :

Example 31 with L2GatewayDevice

use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice 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;
    });
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) TunnelIps(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelIps) 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) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 32 with L2GatewayDevice

use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.

the class HwvtepPhysicalSwitchListener method removed.

@Override
protected void removed(InstanceIdentifier<PhysicalSwitchAugmentation> identifier, PhysicalSwitchAugmentation phySwitchDeleted) {
    NodeId nodeId = getNodeId(identifier);
    String psName = phySwitchDeleted.getHwvtepNodeName().getValue();
    LOG.info("Received physical switch {} removed event for node {}", psName, nodeId.getValue());
    L2GatewayDevice l2GwDevice = l2GatewayCache.get(psName);
    if (l2GwDevice != null) {
        if (!L2GatewayConnectionUtils.isGatewayAssociatedToL2Device(l2GwDevice)) {
            l2GatewayCache.remove(psName);
            LOG.debug("{} details removed from L2Gateway Cache", psName);
            MDSALUtil.syncDelete(this.dataBroker, LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils.createInstanceIdentifier(nodeId));
        } else {
            LOG.debug("{} details are not removed from L2Gateway Cache as it has L2Gateway reference", psName);
        }
        l2GwDevice.setConnected(false);
    // ElanL2GwCacheUtils.removeL2GatewayDeviceFromAllElanCache(psName);
    } else {
        LOG.error("Unable to find L2 Gateway details for {}", psName);
    }
}
Also used : NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 33 with L2GatewayDevice

use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.

the class L2GatewayConnectionListener method addL2DeviceToCache.

void addL2DeviceToCache(InstanceIdentifier<Node> psIid, Node globalNode, Node psNode) {
    LOG.trace("Adding device to cache {}", psNode.getNodeId().getValue());
    String deviceName = HwvtepHAUtil.getPsName(psIid);
    L2GatewayDevice l2GwDevice = l2GatewayCache.addOrGet(deviceName);
    l2GwDevice.setConnected(true);
    l2GwDevice.setHwvtepNodeId(globalNode.getNodeId().getValue());
    List<TunnelIps> tunnelIps = psNode.getAugmentation(PhysicalSwitchAugmentation.class) != null ? psNode.getAugmentation(PhysicalSwitchAugmentation.class).getTunnelIps() : null;
    if (tunnelIps != null) {
        for (TunnelIps tunnelIp : tunnelIps) {
            IpAddress tunnelIpAddr = tunnelIp.getTunnelIpsKey();
            l2GwDevice.addTunnelIp(tunnelIpAddr);
        }
    }
}
Also used : TunnelIps(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelIps) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 34 with L2GatewayDevice

use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.

the class LocalUcastMacListener method removed.

public void removed(final InstanceIdentifier<LocalUcastMacs> identifier, final LocalUcastMacs macRemoved) {
    String hwvtepNodeId = identifier.firstKeyOf(Node.class).getNodeId().getValue();
    String macAddress = macRemoved.getMacEntryKey().getValue().toLowerCase(Locale.getDefault());
    LOG.trace("LocalUcastMacs {} removed from {}", macAddress, hwvtepNodeId);
    ResourceBatchingManager.getInstance().delete(ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY, identifier);
    String elanName = getElanName(macRemoved);
    jobCoordinator.enqueueJob(elanName + HwvtepHAUtil.L2GW_JOB_KEY, () -> {
        L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
        if (elanL2GwDevice == null) {
            LOG.warn("Could not find L2GatewayDevice for ELAN: {}, nodeID:{} from cache", elanName, hwvtepNodeId);
            return null;
        }
        elanL2GwDevice.removeUcastLocalMac(macRemoved);
        ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
        elanL2GatewayUtils.unInstallL2GwUcastMacFromL2gwDevices(elanName, elanL2GwDevice, Collections.singletonList(new MacAddress(macAddress.toLowerCase(Locale.getDefault()))));
        elanL2GatewayUtils.unInstallL2GwUcastMacFromElanDpns(elanInstance, elanL2GwDevice, Collections.singletonList(new MacAddress(macAddress.toLowerCase(Locale.getDefault()))));
        return null;
    });
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 35 with L2GatewayDevice

use of org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice in project netvirt by opendaylight.

the class DeleteL2GwDeviceMacsFromElanJob method call.

/*
     * (non-Javadoc)
     *
     * @see java.util.concurrent.Callable#call()
     */
@Override
public List<ListenableFuture<Void>> call() {
    LOG.debug("Deleting l2gw device [{}] macs from other l2gw devices for elan [{}]", this.l2GwDevice.getHwvtepNodeId(), this.elanName);
    final String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(this.elanName);
    List<MacAddress> macs = new ArrayList<>();
    macAddresses.forEach((mac) -> macs.add(new MacAddress(mac.getValue().toLowerCase())));
    List<ListenableFuture<Void>> futures = new ArrayList<>();
    ConcurrentMap<String, L2GatewayDevice> elanL2GwDevices = ElanL2GwCacheUtils.getInvolvedL2GwDevices(this.elanName);
    for (L2GatewayDevice otherDevice : elanL2GwDevices.values()) {
        if (!otherDevice.getHwvtepNodeId().equals(this.l2GwDevice.getHwvtepNodeId()) && !ElanL2GatewayUtils.areMLAGDevices(this.l2GwDevice, otherDevice)) {
            final String hwvtepId = otherDevice.getHwvtepNodeId();
            // This delete is batched using resourcebatchingmnagaer
            futures.addAll(deleteRemoteUcastMacs(new NodeId(hwvtepId), logicalSwitchName, macs));
        }
    }
    return futures;
}
Also used : ArrayList(java.util.ArrayList) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Aggregations

L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)41 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)16 ArrayList (java.util.ArrayList)12 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)12 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)11 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)10 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)7 BigInteger (java.math.BigInteger)7 Devices (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices)7 LogicalSwitches (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches)7 List (java.util.List)5 Set (java.util.Set)5 Inject (javax.inject.Inject)5 Singleton (javax.inject.Singleton)5 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)5 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)5 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)5 MDSALUtil (org.opendaylight.genius.mdsalutil.MDSALUtil)5 HwvtepSouthboundUtils (org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils)5 HwvtepUtils (org.opendaylight.genius.utils.hwvtep.HwvtepUtils)5