Search in sources :

Example 91 with Node

use of org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.node.data.Node 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.augmentation(HwvtepGlobalAugmentation.class);
        if (augmentation != null) {
            if (augmentation.getSwitches() != null) {
                if (augmentation.getSwitches().size() > 0) {
                    switchesAlreadyPresent = true;
                }
            }
        }
    }
    if (!switchesAlreadyPresent) {
        HwvtepGlobalAugmentation augmentation = childNode.augmentation(HwvtepGlobalAugmentation.class);
        if (augmentation != null && augmentation.getSwitches() != null) {
            List<Switches> src = new ArrayList<>(augmentation.nonnullSwitches().values());
            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)

Example 92 with Node

use of org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.node.data.Node in project netvirt by opendaylight.

the class HwvtepHAUtil method getChildNodeIdsFromManagerOtherConfig.

/**
 * Returns ha child node path from ha node of config data tree.
 *
 * @param haGlobalConfigNodeOptional HA global node
 * @return ha Child ids
 */
public static List<NodeId> getChildNodeIdsFromManagerOtherConfig(Optional<Node> haGlobalConfigNodeOptional) {
    List<NodeId> childNodeIds = new ArrayList<>();
    if (!haGlobalConfigNodeOptional.isPresent()) {
        return childNodeIds;
    }
    HwvtepGlobalAugmentation augmentation = haGlobalConfigNodeOptional.get().augmentation(HwvtepGlobalAugmentation.class);
    if (augmentation != null && augmentation.getManagers() != null && augmentation.getManagers().size() > 0) {
        Managers managers = new ArrayList<>(augmentation.nonnullManagers().values()).get(0);
        if (null == managers.getManagerOtherConfigs()) {
            return childNodeIds;
        }
        for (ManagerOtherConfigs otherConfigs : managers.nonnullManagerOtherConfigs().values()) {
            if (HA_CHILDREN.equals(otherConfigs.getOtherConfigKey())) {
                String nodeIdsVal = otherConfigs.getOtherConfigValue();
                if (nodeIdsVal != null) {
                    String[] parts = nodeIdsVal.split(",");
                    for (String part : parts) {
                        childNodeIds.add(new NodeId(part));
                    }
                }
            }
        }
    }
    return childNodeIds;
}
Also used : Managers(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Managers) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ArrayList(java.util.ArrayList) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) ManagerOtherConfigs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.managers.ManagerOtherConfigs)

Example 93 with Node

use of org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.node.data.Node 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
 */
public static void deletePSNodesOfNode(InstanceIdentifier<Node> key, Node haNode, TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException {
    // read from switches attribute and clean up them
    HwvtepGlobalAugmentation globalAugmentation = haNode.augmentation(HwvtepGlobalAugmentation.class);
    if (globalAugmentation == null) {
        return;
    }
    HashMap<InstanceIdentifier<Node>, Boolean> deleted = new HashMap<>();
    List<Switches> switches = new ArrayList<>(globalAugmentation.nonnullSwitches().values());
    if (switches != null) {
        for (Switches switche : switches) {
            InstanceIdentifier<Node> psId = (InstanceIdentifier<Node>) switche.getSwitchRef().getValue();
            deleteNodeIfPresent(tx, 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(key.firstIdentifierOf(Topology.class)).get();
    String deletedNodeId = key.firstKeyOf(Node.class).getNodeId().getValue();
    if (topologyOptional.isPresent()) {
        Topology topology = topologyOptional.get();
        if (topology.getNode() != null) {
            for (Node psNode : topology.nonnullNode().values()) {
                PhysicalSwitchAugmentation ps = psNode.augmentation(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, 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) ArrayList(java.util.ArrayList) 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 94 with Node

use of org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.node.data.Node in project netvirt by opendaylight.

the class HwvtepHAUtil method buildGlobalConfigForHANode.

/**
 * Build HA Global node from child nodes in config data tress.
 *
 * @param tx Transaction
 * @param childNode Child Node object
 * @param haNodePath Ha node path
 * @param haGlobalCfg HA global node object
 */
public static void buildGlobalConfigForHANode(TypedReadWriteTransaction<Configuration> tx, Node childNode, InstanceIdentifier<Node> haNodePath, Optional<Node> haGlobalCfg) {
    NodeBuilder nodeBuilder = new NodeBuilder();
    HwvtepGlobalAugmentationBuilder hwvtepGlobalBuilder = new HwvtepGlobalAugmentationBuilder();
    hwvtepGlobalBuilder.setSwitches(buildSwitchesForHANode(childNode, haNodePath, haGlobalCfg));
    hwvtepGlobalBuilder.setManagers(buildManagersForHANode(childNode, haGlobalCfg));
    nodeBuilder.setNodeId(haNodePath.firstKeyOf(Node.class).getNodeId());
    nodeBuilder.addAugmentation(hwvtepGlobalBuilder.build());
    Node configHANode = nodeBuilder.build();
    tx.mergeParentStructureMerge(haNodePath, configHANode);
}
Also used : HwvtepGlobalAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)

Example 95 with Node

use of org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.node.data.Node in project netvirt by opendaylight.

the class LocalMcastCmd method transform.

@Override
public LocalMcastMacs transform(InstanceIdentifier<Node> nodePath, LocalMcastMacs src) {
    LocalMcastMacsBuilder ucmlBuilder = new LocalMcastMacsBuilder(src);
    List<LocatorSet> locatorSet = new ArrayList<>();
    for (LocatorSet locator : src.nonnullLocatorSet()) {
        locatorSet.add(new LocatorSetBuilder().setLocatorRef(HwvtepHAUtil.buildLocatorRef(nodePath, HwvtepHAUtil.getTepIpVal(locator.getLocatorRef()))).build());
    }
    ucmlBuilder.setLocatorSet(locatorSet);
    ucmlBuilder.setLogicalSwitchRef(HwvtepHAUtil.convertLogicalSwitchRef(src.getLogicalSwitchRef(), nodePath));
    ucmlBuilder.setMacEntryUuid(HwvtepHAUtil.getUUid(src.getMacEntryKey().getValue()));
    LocalMcastMacsKey key = new LocalMcastMacsKey(ucmlBuilder.getLogicalSwitchRef(), ucmlBuilder.getMacEntryKey());
    ucmlBuilder.withKey(key);
    return ucmlBuilder.build();
}
Also used : LocatorSet(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.locator.set.attributes.LocatorSet) LocalMcastMacsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalMcastMacsKey) ArrayList(java.util.ArrayList) LocalMcastMacsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalMcastMacsBuilder) LocatorSetBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.locator.set.attributes.LocatorSetBuilder)

Aggregations

Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)220 ArrayList (java.util.ArrayList)160 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)160 Test (org.junit.Test)115 ExecutionException (java.util.concurrent.ExecutionException)108 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)108 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)105 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)93 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)89 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)88 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)81 TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)61 NodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)60 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)60 List (java.util.List)59 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)57 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)54 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)53 HwvtepGlobalAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation)53 Logger (org.slf4j.Logger)52