use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation in project netvirt by opendaylight.
the class LogicalSwitchesCmdTest method getData.
HwvtepGlobalAugmentation getData(LogicalSwitches[] elements) {
HwvtepGlobalAugmentationBuilder newDataBuilder = new HwvtepGlobalAugmentationBuilder();
List<LogicalSwitches> ls = new ArrayList<>();
for (LogicalSwitches ele : elements) {
ls.add(ele);
}
newDataBuilder.setLogicalSwitches(ls);
return newDataBuilder.build();
}
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 compareLocalMcastMacs.
public static void compareLocalMcastMacs(Node src, Node dst, InstanceIdentifier<Node> nodePath) {
LocalMcastCmd cmd = new LocalMcastCmd();
HwvtepGlobalAugmentation d1Aug = src.getAugmentation(HwvtepGlobalAugmentation.class);
HwvtepGlobalAugmentation haAug = dst.getAugmentation(HwvtepGlobalAugmentation.class);
List<LocalMcastMacs> d1Values = d1Aug.getLocalUcastMacs() != null ? d1Aug.getLocalMcastMacs() : new ArrayList<>();
List<LocalMcastMacs> result1 = cmd.transform(nodePath, d1Values);
List<LocalMcastMacs> result2 = cmd.transform(nodePath, haAug.getLocalMcastMacs());
Set<LocalMcastMacs> set1 = Sets.newHashSet(result1);
Set<LocalMcastMacs> set2 = Sets.newHashSet(result2);
assertEquals("should have equal remote ucast macs ", 0, Sets.symmetricDifference(set1, set2).size());
}
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 compareRemoteMcastMacs.
public static void compareRemoteMcastMacs(Node src, Node dst, InstanceIdentifier<Node> nodePath) {
RemoteMcastCmd cmd = new RemoteMcastCmd();
HwvtepGlobalAugmentation d1Aug = src.getAugmentation(HwvtepGlobalAugmentation.class);
HwvtepGlobalAugmentation haAug = dst.getAugmentation(HwvtepGlobalAugmentation.class);
List<RemoteMcastMacs> d1Values = d1Aug.getRemoteMcastMacs() != null ? d1Aug.getRemoteMcastMacs() : new ArrayList<>();
List<RemoteMcastMacs> result1 = cmd.transform(nodePath, d1Values);
List<RemoteMcastMacs> result2 = cmd.transform(nodePath, haAug.getRemoteMcastMacs());
Set<RemoteMcastMacs> set1 = Sets.newHashSet(result1);
Set<RemoteMcastMacs> set2 = Sets.newHashSet(result2);
assertEquals("should have equal remote ucast macs ", 0, Sets.symmetricDifference(set1, set2).size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation in project netvirt by opendaylight.
the class HwvtepHAUtil method deletePSNodesOfNode.
/**
* Delete PS data of HA node of Config Data tree.
*
* @param key Node object
* @param haNode Ha Node from which to be deleted
* @param tx Transaction
* @throws ReadFailedException Exception thrown if read fails
*/
public static void deletePSNodesOfNode(InstanceIdentifier<Node> key, Node haNode, ReadWriteTransaction tx) throws ReadFailedException {
// read from switches attribute and clean up them
HwvtepGlobalAugmentation globalAugmentation = haNode.getAugmentation(HwvtepGlobalAugmentation.class);
if (globalAugmentation == null) {
return;
}
HashMap<InstanceIdentifier<Node>, Boolean> deleted = new HashMap<>();
List<Switches> switches = globalAugmentation.getSwitches();
if (switches != null) {
for (Switches switche : switches) {
InstanceIdentifier<Node> psId = (InstanceIdentifier<Node>) switche.getSwitchRef().getValue();
deleteNodeIfPresent(tx, CONFIGURATION, psId);
deleted.put(psId, Boolean.TRUE);
}
}
// also read from managed by attribute of switches and cleanup them as a back up if the above cleanup fails
Optional<Topology> topologyOptional = tx.read(CONFIGURATION, key.firstIdentifierOf(Topology.class)).checkedGet();
String deletedNodeId = key.firstKeyOf(Node.class).getNodeId().getValue();
if (topologyOptional.isPresent()) {
Topology topology = topologyOptional.get();
if (topology.getNode() != null) {
for (Node psNode : topology.getNode()) {
PhysicalSwitchAugmentation ps = psNode.getAugmentation(PhysicalSwitchAugmentation.class);
if (ps != null) {
InstanceIdentifier<Node> iid = (InstanceIdentifier<Node>) ps.getManagedBy().getValue();
String nodeIdVal = iid.firstKeyOf(Node.class).getNodeId().getValue();
if (deletedNodeId.equals(nodeIdVal)) {
InstanceIdentifier<Node> psNodeId = convertToInstanceIdentifier(psNode.getNodeId().getValue());
if (deleted.containsKey(psNodeId)) {
deleteNodeIfPresent(tx, CONFIGURATION, psNodeId);
}
}
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation in project netvirt by opendaylight.
the class HwvtepHAUtil method deleteSwitchesManagedByNode.
/**
* Delete switches from Node in Operational Data Tree .
*
* @param haPath HA node path from whih switches will be deleted
* @param tx Transaction object
* @throws ReadFailedException Exception thrown if read fails
*/
public static void deleteSwitchesManagedByNode(InstanceIdentifier<Node> haPath, ReadWriteTransaction tx) throws ReadFailedException {
Optional<Node> nodeOptional = tx.read(OPERATIONAL, haPath).checkedGet();
if (!nodeOptional.isPresent()) {
return;
}
Node node = nodeOptional.get();
HwvtepGlobalAugmentation globalAugmentation = node.getAugmentation(HwvtepGlobalAugmentation.class);
if (globalAugmentation == null) {
return;
}
List<Switches> switches = globalAugmentation.getSwitches();
if (switches != null) {
for (Switches switche : switches) {
InstanceIdentifier<Node> id = (InstanceIdentifier<Node>) switche.getSwitchRef().getValue();
deleteNodeIfPresent(tx, OPERATIONAL, id);
}
}
}
Aggregations