Search in sources :

Example 16 with LocalUcastMacs

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

the class HwvtepLocalUcastMacListener method removed.

@Override
protected void removed(InstanceIdentifier<LocalUcastMacs> identifier, 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);
    String elanName = getElanName(macRemoved);
    L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
    if (elanL2GwDevice == null) {
        LOG.warn("Could not find L2GatewayDevice for ELAN: {}, nodeID:{} from cache", elanName, hwvtepNodeId);
        return;
    }
    // Remove MAC from cache
    elanL2GwDevice.removeUcastLocalMac(macRemoved);
    elanL2GatewayUtils.unInstallL2GwUcastMacFromL2gwDevices(elanName, elanL2GwDevice, Collections.singletonList(new MacAddress(macAddress.toLowerCase(Locale.getDefault()))));
    elanL2GatewayUtils.unInstallL2GwUcastMacFromElanDpns(elanInstanceCache.get(elanName).orNull(), elanL2GwDevice, Collections.singletonList(new MacAddress(macAddress.toLowerCase(Locale.getDefault()))));
}
Also used : 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 17 with LocalUcastMacs

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

the class HwvtepLocalUcastMacListener method added.

@Override
public void added(InstanceIdentifier<LocalUcastMacs> identifier, LocalUcastMacs macAdded) {
    String hwvtepNodeId = identifier.firstKeyOf(Node.class).getNodeId().getValue();
    String macAddress = macAdded.getMacEntryKey().getValue().toLowerCase(Locale.getDefault());
    LOG.trace("LocalUcastMacs {} added to {}", macAddress, hwvtepNodeId);
    String elanName = getElanName(macAdded);
    ElanInstance elan = elanInstanceCache.get(elanName).orNull();
    if (elan == null) {
        LOG.warn("Could not find ELAN for mac {} being added", macAddress);
        return;
    }
    L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
    if (elanL2GwDevice == null) {
        LOG.warn("Could not find L2GatewayDevice for ELAN: {}, nodeID:{} from cache", elanName, hwvtepNodeId);
        return;
    }
    // Cache MAC for furthur processing later
    elanL2GwDevice.addUcastLocalMac(macAdded);
    elanL2GatewayUtils.installL2GwUcastMacInElan(elan, elanL2GwDevice, macAddress.toLowerCase(Locale.getDefault()), macAdded, null);
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 18 with LocalUcastMacs

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

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

the class LocalUcastCmd method generateId.

@Override
public InstanceIdentifier<LocalUcastMacs> generateId(InstanceIdentifier<Node> id, LocalUcastMacs node) {
    HwvtepLogicalSwitchRef lsRef = HwvtepHAUtil.convertLogicalSwitchRef(node.getKey().getLogicalSwitchRef(), id);
    LocalUcastMacsKey key = new LocalUcastMacsKey(lsRef, node.getMacEntryKey());
    return id.augmentation(HwvtepGlobalAugmentation.class).child(LocalUcastMacs.class, key);
}
Also used : HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) HwvtepLogicalSwitchRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef) LocalUcastMacsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacsKey)

Example 20 with LocalUcastMacs

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

the class TestComparators method compareLocalUcastMacs.

public static void compareLocalUcastMacs(Node d1, Node d2, Node ha, InstanceIdentifier<Node> nodePath) {
    LocalUcastCmd cmd = new LocalUcastCmd();
    HwvtepGlobalAugmentation d1Aug = d1.getAugmentation(HwvtepGlobalAugmentation.class);
    HwvtepGlobalAugmentation d2Aug = d2.getAugmentation(HwvtepGlobalAugmentation.class);
    HwvtepGlobalAugmentation haAug = ha.getAugmentation(HwvtepGlobalAugmentation.class);
    List<LocalUcastMacs> d1Values = d1Aug.getLocalUcastMacs() != null ? d1Aug.getLocalUcastMacs() : new ArrayList<>();
    List<LocalUcastMacs> result1 = cmd.transform(nodePath, d1Values);
    List<LocalUcastMacs> d2Values = d2Aug.getLocalUcastMacs() != null ? d2Aug.getLocalUcastMacs() : new ArrayList<>();
    List<LocalUcastMacs> result2 = cmd.transform(nodePath, d2Values);
    List<LocalUcastMacs> result = cmd.transform(nodePath, haAug.getLocalUcastMacs());
    List<LocalUcastMacs> luMacList = new ArrayList<>();
    luMacList.addAll(result1);
    luMacList.addAll(result2);
    Set<LocalUcastMacs> set1 = Sets.newHashSet(luMacList);
    Set<LocalUcastMacs> set2 = Sets.newHashSet(result);
    assertEquals("should have equal Local ucast macs ", 0, Sets.symmetricDifference(set1, set2).size());
}
Also used : LocalUcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) ArrayList(java.util.ArrayList) LocalUcastCmd(org.opendaylight.netvirt.elan.l2gw.ha.commands.LocalUcastCmd)

Aggregations

L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)12 LocalUcastMacs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs)8 LogicalSwitches (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches)8 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)7 HwvtepGlobalAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation)7 ArrayList (java.util.ArrayList)6 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)6 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)6 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)5 Collections (java.util.Collections)4 Set (java.util.Set)4 Inject (javax.inject.Inject)4 Singleton (javax.inject.Singleton)4 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)4 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)4 HwvtepSouthboundUtils (org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils)4 JobCoordinator (org.opendaylight.infrautils.jobcoordinator.JobCoordinator)4 ElanInstanceCache (org.opendaylight.netvirt.elan.cache.ElanInstanceCache)4 ElanL2GwCacheUtils (org.opendaylight.netvirt.elanmanager.utils.ElanL2GwCacheUtils)4 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)4