use of org.opendaylight.netvirt.elan.l2gw.ha.commands.SwitchesCmd in project netvirt by opendaylight.
the class HwvtepHAUtil method buildSwitchesForHANode.
/**
* Transform child switch (Source) to HA swicthes using HA node path.
*
* @param childNode HA child node
* @param haNodePath HA node path
* @param haNode Ha node object
* @return Transformed switches
*/
public static List<Switches> buildSwitchesForHANode(Node childNode, InstanceIdentifier<Node> haNodePath, Optional<Node> haNode) {
List<Switches> psList = new ArrayList<>();
boolean switchesAlreadyPresent = false;
if (haNode.isPresent()) {
Node node = haNode.get();
HwvtepGlobalAugmentation augmentation = node.getAugmentation(HwvtepGlobalAugmentation.class);
if (augmentation != null) {
if (augmentation.getSwitches() != null) {
if (augmentation.getSwitches().size() > 0) {
switchesAlreadyPresent = true;
}
}
}
}
if (!switchesAlreadyPresent) {
HwvtepGlobalAugmentation augmentation = childNode.getAugmentation(HwvtepGlobalAugmentation.class);
if (augmentation != null && augmentation.getSwitches() != null) {
List<Switches> src = augmentation.getSwitches();
if (src != null && src.size() > 0) {
psList.add(new SwitchesCmd().transform(haNodePath, src.get(0)));
}
}
}
return psList;
}
Aggregations