Search in sources :

Example 1 with LogicalSwitchesCmd

use of org.opendaylight.netvirt.elan.l2gw.ha.commands.LogicalSwitchesCmd 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)

Aggregations

HashSet (java.util.HashSet)1 LogicalSwitchesCmd (org.opendaylight.netvirt.elan.l2gw.ha.commands.LogicalSwitchesCmd)1 HwvtepGlobalAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation)1 LogicalSwitches (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches)1