Search in sources :

Example 16 with HwvtepGlobalAugmentation

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

the class HAOpClusteredListener method addToHACacheIfBecameHAChild.

/**
 * If Normal non-ha node changes to HA node , its added to HA cache.
 *
 * @param childPath HA child path which got converted to HA node
 * @param updatedChildNode updated Child node
 * @param beforeChildNode non-ha node before updated to HA node
 */
public static void addToHACacheIfBecameHAChild(InstanceIdentifier<Node> childPath, Node updatedChildNode, Node beforeChildNode) {
    HwvtepGlobalAugmentation updatedAugmentaion = updatedChildNode.getAugmentation(HwvtepGlobalAugmentation.class);
    HwvtepGlobalAugmentation beforeAugmentaion = null;
    if (beforeChildNode != null) {
        beforeAugmentaion = beforeChildNode.getAugmentation(HwvtepGlobalAugmentation.class);
    }
    List<Managers> up = null;
    List<Managers> be = null;
    if (updatedAugmentaion != null) {
        up = updatedAugmentaion.getManagers();
    }
    if (beforeAugmentaion != null) {
        be = beforeAugmentaion.getManagers();
    }
    if (up != null) {
        if (be != null) {
            if (up.size() > 0) {
                if (be.size() > 0) {
                    Managers m1 = up.get(0);
                    Managers m2 = be.get(0);
                    if (!m1.equals(m2)) {
                        LOG.trace("Manager entry updated for node {} ", updatedChildNode.getNodeId().getValue());
                        addToCacheIfHAChildNode(childPath, updatedChildNode);
                    }
                }
            }
        }
    // TODO handle unhaed case
    }
}
Also used : Managers(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Managers) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation)

Example 17 with HwvtepGlobalAugmentation

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

the class NodeConnectedHandler method deleteChildPSConfigIfHAPSConfigIsMissing.

private void deleteChildPSConfigIfHAPSConfigIsMissing(Optional<Node> haPSCfg, Node childNode, ReadWriteTransaction tx) throws ReadFailedException {
    if (haPSCfg.isPresent()) {
        return;
    }
    LOG.info("HA ps node not present cleanup child {}", childNode);
    HwvtepGlobalAugmentation augmentation = childNode.getAugmentation(HwvtepGlobalAugmentation.class);
    if (augmentation != null) {
        List<Switches> switches = augmentation.getSwitches();
        if (switches != null) {
            for (Switches ps : switches) {
                HwvtepHAUtil.deleteNodeIfPresent(tx, CONFIGURATION, ps.getSwitchRef().getValue());
            }
        }
    } else {
        LOG.info("Global augumentation not present for connected ha child node {}", childNode);
    }
}
Also used : Switches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Switches) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation)

Example 18 with HwvtepGlobalAugmentation

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

the class TestComparators method compareLogicalSwitches.

public static void compareLogicalSwitches(Node d1, Node d2, Node ha, InstanceIdentifier<Node> nodePath) {
    LogicalSwitchesCmd cmd = new LogicalSwitchesCmd();
    HwvtepGlobalAugmentation d1Aug = d1.getAugmentation(HwvtepGlobalAugmentation.class);
    HwvtepGlobalAugmentation d2Aug = d2.getAugmentation(HwvtepGlobalAugmentation.class);
    HwvtepGlobalAugmentation haAug = ha.getAugmentation(HwvtepGlobalAugmentation.class);
    List<LogicalSwitches> d1Values = d1Aug.getLogicalSwitches() != null ? d1Aug.getLogicalSwitches() : new ArrayList<>();
    List<LogicalSwitches> result1 = cmd.transform(nodePath, d1Values);
    List<LogicalSwitches> d2Values = d2Aug.getLogicalSwitches() != null ? d2Aug.getLogicalSwitches() : new ArrayList<>();
    List<LogicalSwitches> result2 = cmd.transform(nodePath, d2Values);
    // Merge data of both d1 and d2 logical switch info should be same as ha
    Set<LogicalSwitches> set1 = new HashSet<>();
    set1.addAll(result1);
    set1.addAll(result2);
    List<LogicalSwitches> result = cmd.transform(nodePath, haAug.getLogicalSwitches());
    Set<LogicalSwitches> set2 = Sets.newHashSet(result);
    assertEquals("should have equal logical switches", 0, Sets.symmetricDifference(set1, set2).size());
}
Also used : LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches) LogicalSwitchesCmd(org.opendaylight.netvirt.elan.l2gw.ha.commands.LogicalSwitchesCmd) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) HashSet(java.util.HashSet)

Example 19 with HwvtepGlobalAugmentation

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

the class TestComparators method compareRemoteUcastMacs.

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

Example 20 with HwvtepGlobalAugmentation

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation 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

HwvtepGlobalAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation)19 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)11 ArrayList (java.util.ArrayList)8 LogicalSwitches (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches)8 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)7 Optional (com.google.common.base.Optional)4 HashSet (java.util.HashSet)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 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)4 HwvtepHAUtil (org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil)4 HwvtepGlobalAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder)4 LocalUcastMacs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs)4 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 Collection (java.util.Collection)3