Search in sources :

Example 1 with SwitchesCmd

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;
}
Also used : SwitchesCmd(org.opendaylight.netvirt.elan.l2gw.ha.commands.SwitchesCmd) Switches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Switches) LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ArrayList(java.util.ArrayList) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation)

Aggregations

ArrayList (java.util.ArrayList)1 SwitchesCmd (org.opendaylight.netvirt.elan.l2gw.ha.commands.SwitchesCmd)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 Switches (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Switches)1 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)1