Search in sources :

Example 6 with Path

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.Path 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)

Example 7 with Path

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.Path in project netvirt by opendaylight.

the class TerminationPointCmd method transform.

@Override
public TerminationPoint transform(InstanceIdentifier<Node> nodePath, TerminationPoint src) {
    HwvtepPhysicalPortAugmentation augmentation = src.getAugmentation(HwvtepPhysicalPortAugmentation.class);
    if (augmentation == null) {
        return new TerminationPointBuilder(src).build();
    }
    String nodeIdVal = nodePath.firstKeyOf(Node.class).getNodeId().getValue();
    int idx = nodeIdVal.indexOf("/physicalswitch");
    if (idx > 0) {
        nodeIdVal = nodeIdVal.substring(0, idx);
        nodePath = HwvtepHAUtil.convertToInstanceIdentifier(nodeIdVal);
    }
    final InstanceIdentifier<Node> path = nodePath;
    TerminationPointBuilder tpBuilder = new TerminationPointBuilder(src);
    tpBuilder.removeAugmentation(HwvtepPhysicalPortAugmentation.class);
    HwvtepPhysicalPortAugmentationBuilder tpAugmentationBuilder = new HwvtepPhysicalPortAugmentationBuilder(augmentation);
    if (augmentation.getVlanBindings() != null && augmentation.getVlanBindings().size() > 0) {
        tpAugmentationBuilder.setVlanBindings(augmentation.getVlanBindings().stream().map(vlanBindings -> {
            VlanBindingsBuilder vlanBindingsBuilder = new VlanBindingsBuilder(vlanBindings);
            vlanBindingsBuilder.setLogicalSwitchRef(HwvtepHAUtil.convertLogicalSwitchRef(vlanBindings.getLogicalSwitchRef(), path));
            return vlanBindingsBuilder.build();
        }).collect(Collectors.toList()));
    }
    tpBuilder.addAugmentation(HwvtepPhysicalPortAugmentation.class, tpAugmentationBuilder.build());
    return tpBuilder.build();
}
Also used : HwvtepPhysicalPortAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentationBuilder) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) TerminationPointBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder) HwvtepPhysicalPortAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) VlanBindingsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindingsBuilder)

Example 8 with Path

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.Path in project netvirt by opendaylight.

the class NodeConnectedHandler method copyHANodeConfigToChild.

/**
 * Copy HA global node data to Child HA node of config data tree .
 *
 * @param srcNode Node which to be transformed
 * @param childPath Path to which source node will be transformed
 * @param tx Transaction
 */
private void copyHANodeConfigToChild(Node srcNode, InstanceIdentifier<Node> childPath, ReadWriteTransaction tx) {
    if (srcNode == null) {
        return;
    }
    HwvtepGlobalAugmentation src = srcNode.getAugmentation(HwvtepGlobalAugmentation.class);
    if (src == null) {
        return;
    }
    NodeBuilder nodeBuilder = HwvtepHAUtil.getNodeBuilderForPath(childPath);
    HwvtepGlobalAugmentationBuilder dstBuilder = new HwvtepGlobalAugmentationBuilder();
    globalAugmentationMerger.mergeConfigData(dstBuilder, src, childPath);
    globalNodeMerger.mergeConfigData(nodeBuilder, srcNode, childPath);
    nodeBuilder.addAugmentation(HwvtepGlobalAugmentation.class, dstBuilder.build());
    Node dstNode = nodeBuilder.build();
    tx.put(CONFIGURATION, childPath, dstNode, WriteTransaction.CREATE_MISSING_PARENTS);
}
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) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)

Example 9 with Path

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.Path in project netvirt by opendaylight.

the class NodeConnectedHandler method copyChildOpToHA.

/**
 * Copy HA child node to HA node of Operational data tree.
 *
 * @param childNode HA Child Node
 * @param haNodePath HA node path
 * @param tx Transaction
 * @throws ReadFailedException  Exception thrown if read fails
 */
private void copyChildOpToHA(Node childNode, InstanceIdentifier<Node> haNodePath, ReadWriteTransaction tx) throws ReadFailedException {
    if (childNode == null) {
        return;
    }
    HwvtepGlobalAugmentation childData = childNode.getAugmentation(HwvtepGlobalAugmentation.class);
    if (childData == null) {
        return;
    }
    NodeBuilder haNodeBuilder = HwvtepHAUtil.getNodeBuilderForPath(haNodePath);
    HwvtepGlobalAugmentationBuilder haBuilder = new HwvtepGlobalAugmentationBuilder();
    Optional<Node> existingHANodeOptional = tx.read(OPERATIONAL, haNodePath).checkedGet();
    Node existingHANode = existingHANodeOptional.isPresent() ? existingHANodeOptional.get() : null;
    HwvtepGlobalAugmentation existingHAData = HwvtepHAUtil.getGlobalAugmentationOfNode(existingHANode);
    globalAugmentationMerger.mergeOperationalData(haBuilder, existingHAData, childData, haNodePath);
    globalNodeMerger.mergeOperationalData(haNodeBuilder, existingHANode, childNode, haNodePath);
    haBuilder.setManagers(HwvtepHAUtil.buildManagersForHANode(childNode, existingHANodeOptional));
    haBuilder.setSwitches(HwvtepHAUtil.buildSwitchesForHANode(childNode, haNodePath, existingHANodeOptional));
    haBuilder.setDbVersion(childData.getDbVersion());
    haNodeBuilder.addAugmentation(HwvtepGlobalAugmentation.class, haBuilder.build());
    Node haNode = haNodeBuilder.build();
    tx.merge(OPERATIONAL, haNodePath, haNode, true);
}
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) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)

Example 10 with Path

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.Path in project netvirt by opendaylight.

the class NodeConnectedHandler method copyHAPSConfigToChildPS.

/**
 * Copy HA physical switch data to Child Physical switch node of config data tree.
 *
 * @param haPsNode HA physical Switch Node
 * @param childPath HA Child Node path
 * @param tx Transaction
 */
public void copyHAPSConfigToChildPS(Node haPsNode, InstanceIdentifier<Node> childPath, ReadWriteTransaction tx) {
    InstanceIdentifier<Node> childPsPath = HwvtepHAUtil.convertPsPath(haPsNode, childPath);
    NodeBuilder childPsBuilder = HwvtepHAUtil.getNodeBuilderForPath(childPsPath);
    PhysicalSwitchAugmentationBuilder dstBuilder = new PhysicalSwitchAugmentationBuilder();
    PhysicalSwitchAugmentation src = haPsNode.getAugmentation(PhysicalSwitchAugmentation.class);
    psAugmentationMerger.mergeConfigData(dstBuilder, src, childPath);
    psNodeMerger.mergeConfigData(childPsBuilder, haPsNode, childPath);
    childPsBuilder.addAugmentation(PhysicalSwitchAugmentation.class, dstBuilder.build());
    Node childPSNode = childPsBuilder.build();
    tx.put(CONFIGURATION, childPsPath, childPSNode, WriteTransaction.CREATE_MISSING_PARENTS);
}
Also used : PhysicalSwitchAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentationBuilder) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) PhysicalSwitchAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)

Aggregations

Test (org.junit.Test)45 ArrayList (java.util.ArrayList)42 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)22 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)19 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)19 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)18 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)17 ExecutionException (java.util.concurrent.ExecutionException)16 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)16 ByteBuf (io.netty.buffer.ByteBuf)15 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)15 TransportZones (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones)15 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update)15 List (java.util.List)14 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)14 AsPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPathBuilder)14 Logger (org.slf4j.Logger)14 LoggerFactory (org.slf4j.LoggerFactory)14 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)13 BigInteger (java.math.BigInteger)12