Search in sources :

Example 6 with TunnelIps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelIps 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 7 with TunnelIps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelIps in project netvirt by opendaylight.

the class TestComparators method comparePhysicalSwitches.

public static void comparePhysicalSwitches(Node d1ps, Node haps, InstanceIdentifier<Node> d1psnodePath, InstanceIdentifier<Node> haPsnodePath, ReadWriteTransaction readWriteTransaction, String switchName, Node d1, Node ha) throws ReadFailedException {
    // Compare Physical Augmentation data
    PhysicalSwitchAugmentation d1PsAug = d1ps.getAugmentation(PhysicalSwitchAugmentation.class);
    PhysicalSwitchAugmentation haPsAug = haps.getAugmentation(PhysicalSwitchAugmentation.class);
    HwvtepGlobalRef managerd1Ps = d1PsAug.getManagedBy();
    assertEquals("Hwvtep node name should be same", d1PsAug.getHwvtepNodeName().getValue(), haPsAug.getHwvtepNodeName().getValue());
    assertEquals("Managers should be equal  for d1 ", d1ps.getNodeId().getValue(), managerd1Ps.getValue().firstKeyOf(Node.class).getNodeId().getValue() + "/physicalswitch/" + switchName);
    HwvtepGlobalRef managerhaPs = haPsAug.getManagedBy();
    assertEquals("Managers should be equal for ha ", haps.getNodeId().getValue(), managerhaPs.getValue().firstKeyOf(Node.class).getNodeId().getValue() + "/physicalswitch/" + switchName);
    assertEquals("Should have equal number TunnelIps", d1PsAug.getTunnelIps().size(), haPsAug.getTunnelIps().size());
    if (d1PsAug.getTunnelIps().size() == haPsAug.getTunnelIps().size()) {
        assertTrue(d1PsAug.getTunnelIps().containsAll(haPsAug.getTunnelIps()));
    }
    // Compare Termination point
    assertTerminationPoint(DataProvider.getPortNameListD1(), d1psnodePath, haPsnodePath, readWriteTransaction, d1, ha);
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) PhysicalSwitchAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation) HwvtepGlobalRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalRef)

Example 8 with TunnelIps

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelIps in project netvirt by opendaylight.

the class L2GatewayListener method removeL2Device.

private void removeL2Device(Devices l2Device, L2gateway input) {
    final String l2DeviceName = l2Device.getDeviceName();
    L2GatewayDevice l2GwDevice = l2GatewayCache.get(l2DeviceName);
    if (l2GwDevice != null) {
        // Also, do not delete device from cache if it's connected
        if (L2GatewayUtils.isLastL2GatewayBeingDeleted(l2GwDevice)) {
            if (l2GwDevice.isConnected()) {
                l2GwDevice.removeL2GatewayId(input.getUuid());
                // Delete ITM tunnels
                final String hwvtepId = l2GwDevice.getHwvtepNodeId();
                final Set<IpAddress> tunnelIps = l2GwDevice.getTunnelIps();
                jobCoordinator.enqueueJob(hwvtepId, () -> {
                    if (entityOwnershipUtils.isEntityOwner(HwvtepSouthboundConstants.ELAN_ENTITY_TYPE, HwvtepSouthboundConstants.ELAN_ENTITY_NAME)) {
                        LOG.info("Deleting ITM Tunnels for {} connected to cluster node owner", l2DeviceName);
                        for (IpAddress tunnelIp : tunnelIps) {
                            L2GatewayUtils.deleteItmTunnels(itmRpcService, hwvtepId, l2DeviceName, tunnelIp);
                        }
                    } else {
                        LOG.info("ITM Tunnels are not deleted on the cluster node as this is not owner for {}", l2DeviceName);
                    }
                    return null;
                });
            } else {
                l2GatewayCache.remove(l2DeviceName);
                // Cleaning up the config DS
                NodeId nodeId = new NodeId(l2GwDevice.getHwvtepNodeId());
                NodeId psNodeId = HwvtepSouthboundUtils.createManagedNodeId(nodeId, l2DeviceName);
                // FIXME: These should be removed
                MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils.createInstanceIdentifier(nodeId));
                MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils.createInstanceIdentifier(psNodeId));
            }
        } else {
            l2GwDevice.removeL2GatewayId(input.getUuid());
            LOG.trace("ITM tunnels are not deleted for {} as this device has other L2gateway associations", l2DeviceName);
        }
    } else {
        LOG.error("Unable to find L2 Gateway details for {}", l2DeviceName);
    }
}
Also used : 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)

Aggregations

IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)6 ArrayList (java.util.ArrayList)3 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)3 TunnelIps (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.TunnelIps)3 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)3 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)3 HwvtepGlobalRef (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalRef)2 Sets (com.google.common.collect.Sets)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Collectors (java.util.stream.Collectors)1 Nonnull (javax.annotation.Nonnull)1 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)1 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)1