Search in sources :

Example 1 with TerminationPointKey

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey in project netvirt by opendaylight.

the class HwvtepHAUtil method convertLocatorRef.

/**
 * Trnaform locator reference to nodepath passed .
 *
 * @param src {@link HwvtepPhysicalLocatorRef} Logical Switch Ref which needs to be transformed
 * @param nodePath {@link InstanceIdentifier} src needs to be transformed to this path
 * @return physicalLocatorRef {@link HwvtepPhysicalLocatorRef} the transforrmed result
 */
public static HwvtepPhysicalLocatorRef convertLocatorRef(HwvtepPhysicalLocatorRef src, InstanceIdentifier<Node> nodePath) {
    InstanceIdentifier<TerminationPoint> srcTepPath = (InstanceIdentifier<TerminationPoint>) src.getValue();
    TpId tpId = srcTepPath.firstKeyOf(TerminationPoint.class).getTpId();
    InstanceIdentifier<TerminationPoint> tpPath = nodePath.child(TerminationPoint.class, new TerminationPointKey(tpId));
    HwvtepPhysicalLocatorRef physicalLocatorRef = new HwvtepPhysicalLocatorRef(tpPath);
    return physicalLocatorRef;
}
Also used : TpId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId) HwvtepPhysicalLocatorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorRef) TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 2 with TerminationPointKey

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey in project netvirt by opendaylight.

the class TestBuilders method buildTerminationPoint.

public static TerminationPoint buildTerminationPoint(InstanceIdentifier<Node> nodeIid, String ip) {
    TerminationPointKey tpKey = new TerminationPointKey(new TpId("vxlan_over_ipv4:" + ip));
    TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
    if (nodeIid != null && tpKey != null) {
        tpBuilder.setKey(tpKey);
        tpBuilder.setTpId(tpKey.getTpId());
        InstanceIdentifier<TerminationPoint> tpPath = buildTpId(nodeIid, ip);
        HwvtepPhysicalLocatorAugmentationBuilder tpAugmentationBuilder = new HwvtepPhysicalLocatorAugmentationBuilder();
        tpAugmentationBuilder.setPhysicalLocatorUuid(getUUid(ip));
        tpAugmentationBuilder.setEncapsulationType(createEncapsulationType("vxlan_over_ipv4"));
        tpAugmentationBuilder.setDstIp(new IpAddress(ip.toCharArray()));
        tpBuilder.addAugmentation(HwvtepPhysicalLocatorAugmentation.class, tpAugmentationBuilder.build());
    }
    return tpBuilder.build();
}
Also used : TpId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId) HwvtepPhysicalLocatorAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentationBuilder) TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) TerminationPointBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 3 with TerminationPointKey

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey in project netvirt by opendaylight.

the class TestComparators method assertTerminationPoint.

public static void assertTerminationPoint(List<String> terminationPointNames, InstanceIdentifier<Node> d1ps, InstanceIdentifier<Node> haPsa, ReadWriteTransaction readWriteTransaction, Node nodeD, Node nodeHa) throws ReadFailedException {
    for (String portName : terminationPointNames) {
        InstanceIdentifier<TerminationPoint> tpPathd = d1ps.child(TerminationPoint.class, new TerminationPointKey(new TpId(portName)));
        TerminationPoint tpNoded = readWriteTransaction.read(LogicalDatastoreType.OPERATIONAL, tpPathd).checkedGet().get();
        HwvtepPhysicalPortAugmentation hwvtepPhysicalPortAugmentationD = tpNoded.getAugmentation(HwvtepPhysicalPortAugmentation.class);
        InstanceIdentifier<TerminationPoint> tpPathha = haPsa.child(TerminationPoint.class, new TerminationPointKey(new TpId(portName)));
        TerminationPoint tpNodeha = readWriteTransaction.read(LogicalDatastoreType.OPERATIONAL, tpPathha).checkedGet().get();
        HwvtepPhysicalPortAugmentation hwvtepPhysicalPortAugmentationHa = tpNodeha.getAugmentation(HwvtepPhysicalPortAugmentation.class);
        assertEquals("Termination point hwvtep-node-name should be same", hwvtepPhysicalPortAugmentationD.getHwvtepNodeName(), hwvtepPhysicalPortAugmentationHa.getHwvtepNodeName());
        List<VlanBindings> vlanBindingsesD = hwvtepPhysicalPortAugmentationD.getVlanBindings();
        List<VlanBindings> vlanBindingsesHa = hwvtepPhysicalPortAugmentationHa.getVlanBindings();
        assertEquals("Size of VlanBindings should be same", vlanBindingsesD.size(), vlanBindingsesHa.size());
        List<Integer> vlanKeysD = new ArrayList<>();
        List<Integer> vlanKeysHa = new ArrayList<>();
        String logicalSwitchRefD = new String();
        String logicalSwitchRefHa = new String();
        List<String> logicalSwitchNameD = new ArrayList<>();
        List<String> logicalSwitchNameHa = new ArrayList<>();
        if (vlanBindingsesD.size() == vlanBindingsesHa.size()) {
            for (int i = 0; i < vlanBindingsesD.size(); i++) {
                vlanKeysD.add(vlanBindingsesD.get(i).getVlanIdKey().getValue());
                logicalSwitchRefD = vlanBindingsesD.get(i).getLogicalSwitchRef().getValue().firstKeyOf(Node.class).getNodeId().getValue();
                logicalSwitchNameD.add(vlanBindingsesD.get(i).getLogicalSwitchRef().getValue().firstKeyOf(LogicalSwitches.class).getHwvtepNodeName().getValue());
                vlanKeysHa.add(vlanBindingsesHa.get(i).getVlanIdKey().getValue());
                logicalSwitchRefHa = vlanBindingsesHa.get(i).getLogicalSwitchRef().getValue().firstKeyOf(Node.class).getNodeId().getValue();
                logicalSwitchNameHa.add(vlanBindingsesHa.get(i).getLogicalSwitchRef().getValue().firstKeyOf(LogicalSwitches.class).getHwvtepNodeName().getValue());
            }
            assertTrue(vlanKeysD.containsAll(vlanKeysHa));
            assertTrue(logicalSwitchRefD.equals(nodeD.getNodeId().getValue()));
            assertTrue(logicalSwitchRefHa.equals(nodeHa.getNodeId().getValue()));
            assertTrue(logicalSwitchNameD.containsAll(logicalSwitchNameHa));
        }
    }
}
Also used : LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches) TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ArrayList(java.util.ArrayList) 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) TpId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId) VlanBindings(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 4 with TerminationPointKey

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey in project netvirt by opendaylight.

the class DhcpExternalTunnelManager method createRemoteMcastMac.

public RemoteMcastMacs createRemoteMcastMac(Node dstDevice, String logicalSwitchName, IpAddress internalTunnelIp) {
    Set<LocatorSet> locators = new HashSet<>();
    TerminationPointKey terminationPointKey = HwvtepSouthboundUtils.getTerminationPointKey(internalTunnelIp.getIpv4Address().getValue());
    HwvtepPhysicalLocatorRef phyLocRef = new HwvtepPhysicalLocatorRef(HwvtepSouthboundUtils.createInstanceIdentifier(dstDevice.getNodeId()).child(TerminationPoint.class, terminationPointKey));
    locators.add(new LocatorSetBuilder().setLocatorRef(phyLocRef).build());
    HwvtepLogicalSwitchRef lsRef = new HwvtepLogicalSwitchRef(HwvtepSouthboundUtils.createLogicalSwitchesInstanceIdentifier(dstDevice.getNodeId(), new HwvtepNodeName(logicalSwitchName)));
    RemoteMcastMacs remoteMcastMacs = new RemoteMcastMacsBuilder().setMacEntryKey(new MacAddress(UNKNOWN_DMAC)).setLogicalSwitchRef(lsRef).build();
    InstanceIdentifier<RemoteMcastMacs> iid = HwvtepSouthboundUtils.createRemoteMcastMacsInstanceIdentifier(dstDevice.getNodeId(), remoteMcastMacs.getKey());
    ReadOnlyTransaction transaction = broker.newReadOnlyTransaction();
    try {
        // TODO do async mdsal read
        remoteMcastMacs = transaction.read(LogicalDatastoreType.CONFIGURATION, iid).checkedGet().get();
        locators.addAll(remoteMcastMacs.getLocatorSet());
        return new RemoteMcastMacsBuilder(remoteMcastMacs).setLocatorSet(new ArrayList<>(locators)).build();
    } catch (ReadFailedException e) {
        LOG.error("Failed to read the macs {}", iid);
    }
    return null;
}
Also used : LocatorSet(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.locator.set.attributes.LocatorSet) HwvtepPhysicalLocatorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorRef) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) ArrayList(java.util.ArrayList) HwvtepLogicalSwitchRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) LocatorSetBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.locator.set.attributes.LocatorSetBuilder) RemoteMcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacs) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) HwvtepNodeName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName) RemoteMcastMacsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacsBuilder) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) HashSet(java.util.HashSet)

Example 5 with TerminationPointKey

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey in project bgpcep by opendaylight.

the class LinkstateTopologyBuilder method buildTp.

private static TerminationPoint buildTp(final TpId id, final TerminationPointType type) {
    final TerminationPointBuilder stpb = new TerminationPointBuilder();
    stpb.setKey(new TerminationPointKey(id));
    stpb.setTpId(id);
    if (type != null) {
        stpb.addAugmentation(TerminationPoint1.class, new TerminationPoint1Builder().setIgpTerminationPointAttributes(new IgpTerminationPointAttributesBuilder().setTerminationPointType(type).build()).build());
    }
    return stpb.build();
}
Also used : TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) TerminationPointBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder) IgpTerminationPointAttributesBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.termination.point.attributes.IgpTerminationPointAttributesBuilder) TerminationPoint1Builder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.TerminationPoint1Builder)

Aggregations

TerminationPointKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey)26 TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)20 TpId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId)19 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)11 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)8 TerminationPointBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder)7 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)6 CountDownLatch (java.util.concurrent.CountDownLatch)5 Test (org.junit.Test)5 Mockito.doReturn (org.mockito.Mockito.doReturn)5 DataTreeModification (org.opendaylight.controller.md.sal.binding.api.DataTreeModification)5 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)5 TestUtils.newInvNodeKey (org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newInvNodeKey)5 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)5 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)4 TestUtils.newLink (org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newLink)3 NetworkTopology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology)3 TopologyBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder)3 TopologyKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey)3 NodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)3