Search in sources :

Example 51 with TerminationPoint

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

the class HwvtepUtils method getPhysicalPortTerminationPoint.

/**
 * Gets physical port termination point.
 *
 * @param broker
 *          the broker
 * @param datastoreType
 *          the datastore type
 * @param nodeId
 *          the physical switch node id
 * @param portName
 *          port name under physical switch node id
 * @return the physical port termination point
 */
public static TerminationPoint getPhysicalPortTerminationPoint(DataBroker broker, LogicalDatastoreType datastoreType, NodeId nodeId, String portName) {
    TerminationPointKey tpKey = new TerminationPointKey(new TpId(portName));
    InstanceIdentifier<TerminationPoint> iid = HwvtepSouthboundUtils.createTerminationPointId(nodeId, tpKey);
    return MDSALUtil.read(broker, datastoreType, iid).orNull();
}
Also used : TpId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId) TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 52 with TerminationPoint

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

the class InterfaceManagerConfigurationTest method newTunnelInterface.

@Ignore
@Test
public void newTunnelInterface() throws Exception {
    // 3. Update DPN-ID of the bridge
    OvsdbSouthboundTestUtil.updateBridge(dataBroker, "00:00:00:00:00:00:00:02");
    waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
    BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(DPN_ID_2);
    InstanceIdentifier<BridgeRefEntry> bridgeRefEntryIid = InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
    // Verify if DPN-ID is updated in corresponding DS and cache
    BridgeRefEntry bridgeRefEntry = IfmUtil.read(LogicalDatastoreType.OPERATIONAL, bridgeRefEntryIid, dataBroker).orNull();
    assertEqualBeans(interfaceMetaUtils.getBridgeRefEntryFromCache(DPN_ID_2), bridgeRefEntry);
    // 1. Given
    // 2. When
    // i) dpn-id specified above configuration comes in
    // operational/network-topology
    // ii) Vlan interface written to config/ietf-interfaces DS and
    // corresponding parent-interface is not present
    // in operational/ietf-interface-state
    ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(DPN_ID_2).build();
    InterfaceManagerTestUtil.putInterfaceConfig(dataBroker, TUNNEL_INTERFACE_NAME, parentRefs, Tunnel.class);
    Thread.sleep(5000);
    // 3. Then
    // a) check expected bridge-interface mapping in
    // odl-interface-meta/config/bridge-interface-info was created
    BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(DPN_ID_2);
    BridgeInterfaceEntryKey bridgeInterfaceEntryKey = new BridgeInterfaceEntryKey(TUNNEL_INTERFACE_NAME);
    InstanceIdentifier<BridgeInterfaceEntry> bridgeInterfaceEntryIid = InterfaceMetaUtils.getBridgeInterfaceEntryIdentifier(bridgeEntryKey, bridgeInterfaceEntryKey);
    // TODO Later use nicer abstraction for DB access here.. see
    // ElanServiceTest
    assertEqualBeans(InterfaceMeta.newBridgeInterface(), dataBroker.newReadOnlyTransaction().read(CONFIGURATION, bridgeInterfaceEntryIid).checkedGet().get());
    // Then
    // a) check if termination end point is created in
    // config/network-topology
    final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node> bridgeIid = OvsdbSouthboundTestUtil.createInstanceIdentifier("192.168.56.101", 6640, "s2");
    InstanceIdentifier<TerminationPoint> tpIid = InterfaceManagerTestUtil.getTerminationPointId(bridgeIid, TUNNEL_INTERFACE_NAME);
    assertEqualTerminationPoints(ExpectedTerminationPoint.newTerminationPoint(), db.syncRead(CONFIGURATION, tpIid));
    // When termination end point is populated in network-topology
    OvsdbSouthboundTestUtil.createTerminationPoint(dataBroker, TUNNEL_INTERFACE_NAME, InterfaceTypeVxlan.class, null);
    InterfaceManagerTestUtil.createFlowCapableNodeConnector(dataBroker, TUNNEL_INTERFACE_NAME, Tunnel.class);
    waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
    Thread.sleep(3000);
    TestableQueues.awaitEmpty(batchingUtils.getQueue(DEFAULT_OPERATIONAL), 1, MINUTES);
    // Then
    // a) check if operational/ietf-interfaces-state is populated for the tunnel interface
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifaceState = dataBroker.newReadOnlyTransaction().read(OPERATIONAL, IfmUtil.buildStateInterfaceId(TUNNEL_INTERFACE_NAME)).checkedGet().get();
    assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(), TUNNEL_INTERFACE_NAME, Interface.OperStatus.Up, Tunnel.class, DPN_ID_2.toString(), ifaceState.getStatistics().getDiscontinuityTime()), ifaceState);
    // Test all RPCs related to tunnel interfaces
    checkTunnelRpcs();
    checkTunnelApis();
    // Update test
    // i) Enable Tunnel Monitoring
    InterfaceManagerTestUtil.updateTunnelMonitoringAttributes(dataBroker, TUNNEL_INTERFACE_NAME);
    InterfaceManagerTestUtil.waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
    // Then verify if bfd attributes are updated in topology config DS
    assertEqualTerminationPoints(ExpectedTerminationPoint.newBfdEnabledTerminationPoint(), db.syncRead(CONFIGURATION, tpIid));
    // state modification tests
    // 1. Make the operational state of port as DOWN
    InterfaceManagerTestUtil.updateFlowCapableNodeConnectorState(dataBroker, TUNNEL_INTERFACE_NAME, Tunnel.class, false);
    waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
    ifaceState = dataBroker.newReadOnlyTransaction().read(OPERATIONAL, IfmUtil.buildStateInterfaceId(TUNNEL_INTERFACE_NAME)).checkedGet().get();
    // Verify if operational/ietf-interface-state is still up
    assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(), TUNNEL_INTERFACE_NAME, Interface.OperStatus.Up, Tunnel.class, DPN_ID_2.toString(), ifaceState.getStatistics().getDiscontinuityTime()), ifaceState);
    // 2. Make BFD staus of tunnel port as down
    OvsdbSouthboundTestUtil.updateTerminationPoint(dataBroker, TUNNEL_INTERFACE_NAME, InterfaceTypeVxlan.class);
    waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
    ifaceState = dataBroker.newReadOnlyTransaction().read(OPERATIONAL, IfmUtil.buildStateInterfaceId(TUNNEL_INTERFACE_NAME)).checkedGet().get();
    // Verify if operational/ietf-interface-state is marked down
    assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(), TUNNEL_INTERFACE_NAME, Interface.OperStatus.Down, Tunnel.class, DPN_ID_2.toString(), ifaceState.getStatistics().getDiscontinuityTime()), ifaceState);
    // 2. Delete the Node
    InterfaceManagerTestUtil.removeNode(dataBroker);
    waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
    ifaceState = dataBroker.newReadOnlyTransaction().read(OPERATIONAL, IfmUtil.buildStateInterfaceId(TUNNEL_INTERFACE_NAME)).checkedGet().get();
    // Verify if operational/ietf-interface-state is marked unknown
    assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(), TUNNEL_INTERFACE_NAME, Interface.OperStatus.Unknown, Tunnel.class, DPN_ID_2.toString(), ifaceState.getStatistics().getDiscontinuityTime()), ifaceState);
    // Re-create port to proceed with further tests
    InterfaceManagerTestUtil.createFlowCapableNodeConnector(dataBroker, TUNNEL_INTERFACE_NAME, Tunnel.class);
    waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
    // 2. Delete the OF port
    InterfaceManagerTestUtil.removeFlowCapableNodeConnectorState(dataBroker, Tunnel.class);
    waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
    // Verify if operational-states are deleted
    Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(OPERATIONAL, IfmUtil.buildStateInterfaceId(TUNNEL_INTERFACE_NAME)).get());
    Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(OPERATIONAL, IfmUtil.buildStateInterfaceId(TUNNEL_INTERFACE_NAME)).get());
    // Delete test
    // iii) tunnel interface is deleted from config/ietf-interfaces
    InterfaceManagerTestUtil.deleteInterfaceConfig(dataBroker, TUNNEL_INTERFACE_NAME);
    InterfaceManagerTestUtil.waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
    // Then
    // a) check if tunnel is deleted from bridge-interface-info
    Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(CONFIGURATION, bridgeInterfaceEntryIid).get());
    // b) check if termination end point is deleted in
    // config/network-topology
    Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(CONFIGURATION, tpIid).get());
    waitTillOperationCompletes(coordinatorEventsWaiter, asyncEventsWaiter);
}
Also used : BridgeEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge._interface.info.BridgeEntryKey) Options(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.Options) AssertDataObjects.assertEqualBeans(org.opendaylight.mdsal.binding.testutils.AssertDataObjects.assertEqualBeans) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) BridgeInterfaceEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge._interface.info.bridge.entry.BridgeInterfaceEntryKey) BridgeRefEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge.ref.info.BridgeRefEntry) BridgeRefEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge.ref.info.BridgeRefEntryKey) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder) Tunnel(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel) BridgeInterfaceEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge._interface.info.bridge.entry.BridgeInterfaceEntry) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) ExpectedTerminationPoint(org.opendaylight.genius.interfacemanager.test.xtend.ExpectedTerminationPoint) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 53 with TerminationPoint

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

the class InterfacemgrProvider method getTunnelPortsOnBridge.

/**
 * Get all termination points of type tunnel on a given DPN.
 *
 * @param dpnId
 *            Datapath Node Identifier
 *
 * @return If the data at the supplied path exists, returns a list of all termination point
 *         Augmentations of type tunnel
 */
@Override
public List<OvsdbTerminationPointAugmentation> getTunnelPortsOnBridge(BigInteger dpnId) {
    List<OvsdbTerminationPointAugmentation> tunnelPorts = new ArrayList<>();
    List<TerminationPoint> portList = interfaceMetaUtils.getTerminationPointsOnBridge(dpnId);
    for (TerminationPoint ovsPort : portList) {
        OvsdbTerminationPointAugmentation portAug = ovsPort.getAugmentation(OvsdbTerminationPointAugmentation.class);
        if (portAug != null && SouthboundUtils.isInterfaceTypeTunnel(portAug.getInterfaceType())) {
            tunnelPorts.add(portAug);
        }
    }
    LOG.debug("Found {} tunnel ports on bridge {}", tunnelPorts.size(), dpnId);
    return tunnelPorts;
}
Also used : ArrayList(java.util.ArrayList) OvsdbTerminationPointAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 54 with TerminationPoint

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

the class InterfacemgrProvider method getPortsOnBridge.

@Override
public /**
 * Get all termination points on a given DPN.
 * This API uses read on Operational DS. If there are perf issues in cluster
 * setup, we can consider caching later.
 *
 * @param dpnId
 *            Datapath Node Identifier
 *
 * @return If the data at the supplied path exists, returns a list of all termination point
 *         Augmentations
 */
List<OvsdbTerminationPointAugmentation> getPortsOnBridge(BigInteger dpnId) {
    List<OvsdbTerminationPointAugmentation> ports = new ArrayList<>();
    List<TerminationPoint> portList = interfaceMetaUtils.getTerminationPointsOnBridge(dpnId);
    for (TerminationPoint ovsPort : portList) {
        if (ovsPort.getAugmentation(OvsdbTerminationPointAugmentation.class) != null) {
            ports.add(ovsPort.getAugmentation(OvsdbTerminationPointAugmentation.class));
        }
    }
    LOG.debug("Found {} ports on bridge {}", ports.size(), dpnId);
    return ports;
}
Also used : ArrayList(java.util.ArrayList) OvsdbTerminationPointAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 55 with TerminationPoint

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

the class SouthboundUtils method addTerminationPoint.

private void addTerminationPoint(InstanceIdentifier<?> bridgeIid, String portName, int vlanId, Class<? extends InterfaceTypeBase> type, Map<String, String> options, IfTunnel ifTunnel) {
    OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder();
    tpAugmentationBuilder.setName(portName);
    if (type != null) {
        tpAugmentationBuilder.setInterfaceType(type);
    }
    if (options != null) {
        List<Options> optionsList = new ArrayList<>();
        for (Map.Entry<String, String> entry : options.entrySet()) {
            OptionsBuilder optionsBuilder = new OptionsBuilder();
            optionsBuilder.setKey(new OptionsKey(entry.getKey()));
            optionsBuilder.setOption(entry.getKey());
            optionsBuilder.setValue(entry.getValue());
            optionsList.add(optionsBuilder.build());
        }
        tpAugmentationBuilder.setOptions(optionsList);
    }
    if (vlanId != 0) {
        tpAugmentationBuilder.setVlanMode(OvsdbPortInterfaceAttributes.VlanMode.Access);
        tpAugmentationBuilder.setVlanTag(new VlanId(vlanId));
    }
    if (bfdMonitoringEnabled(ifTunnel)) {
        if (isOfTunnel(ifTunnel)) {
            LOG.warn("BFD Monitoring not supported for OFTunnels");
        } else {
            List<InterfaceBfd> bfdParams = getBfdParams(ifTunnel);
            tpAugmentationBuilder.setInterfaceBfd(bfdParams);
        }
    }
    TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
    InstanceIdentifier<TerminationPoint> tpIid = createTerminationPointInstanceIdentifier(InstanceIdentifier.keyOf(bridgeIid.firstIdentifierOf(Node.class)), portName);
    tpBuilder.setKey(InstanceIdentifier.keyOf(tpIid));
    tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
    batchingUtils.write(tpIid, tpBuilder.build(), BatchingUtils.EntityType.TOPOLOGY_CONFIG);
}
Also used : Options(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.Options) TunnelOptions(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.tunnel.optional.params.TunnelOptions) ArrayList(java.util.ArrayList) TerminationPointBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder) OptionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.OptionsBuilder) OvsdbTerminationPointAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder) InterfaceBfd(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfd) Map(java.util.Map) HashMap(java.util.HashMap) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) OptionsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.OptionsKey)

Aggregations

TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)41 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)25 TpId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId)20 TerminationPointKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey)18 TerminationPointBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder)16 ArrayList (java.util.ArrayList)12 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)10 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)8 HwvtepPhysicalPortAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation)7 OvsdbTerminationPointAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder)7 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)7 Test (org.junit.Test)6 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)6 VlanBindings (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings)6 NetworkTopology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology)6 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)6 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)5 OvsdbTerminationPointAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation)5 BigInteger (java.math.BigInteger)4 List (java.util.List)3