Search in sources :

Example 11 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 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();
}
Also used : HwvtepGlobalAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder) LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches) ArrayList(java.util.ArrayList)

Example 12 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 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());
}
Also used : HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) LocalMcastCmd(org.opendaylight.netvirt.elan.l2gw.ha.commands.LocalMcastCmd) LocalMcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalMcastMacs)

Example 13 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 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());
}
Also used : RemoteMcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacs) RemoteMcastCmd(org.opendaylight.netvirt.elan.l2gw.ha.commands.RemoteMcastCmd) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation)

Example 14 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 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);
                        }
                    }
                }
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) 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) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) PhysicalSwitchAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier)

Example 15 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 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);
        }
    }
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) 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) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier)

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