Search in sources :

Example 6 with ParentRefsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder in project genius by opendaylight.

the class InterfaceManagerTestUtil method buildInterface.

static Interface buildInterface(String ifName, String desc, boolean enabled, Object ifType, String parentInterface, IfL2vlan.L2vlanMode l2vlanMode) {
    InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(ifName)).setName(ifName).setDescription(desc).setEnabled(enabled).setType((Class<? extends InterfaceType>) ifType);
    ParentRefs parentRefs = new ParentRefsBuilder().setParentInterface(parentInterface).build();
    builder.addAugmentation(ParentRefs.class, parentRefs);
    if (ifType.equals(L2vlan.class)) {
        IfL2vlanBuilder ifL2vlanBuilder = new IfL2vlanBuilder().setL2vlanMode(l2vlanMode);
        if (IfL2vlan.L2vlanMode.TrunkMember.equals(l2vlanMode)) {
            ifL2vlanBuilder.setVlanId(new VlanId(100));
        } else {
            ifL2vlanBuilder.setVlanId(VlanId.getDefaultInstance("0"));
        }
        builder.addAugmentation(IfL2vlan.class, ifL2vlanBuilder.build());
    } else if (ifType.equals(IfTunnel.class)) {
        IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(null).setTunnelGateway(null).setTunnelSource(null).setTunnelInterfaceType(null).build();
        builder.addAugmentation(IfTunnel.class, tunnel);
    }
    return builder.build();
}
Also used : ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) IfTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder) IfL2vlanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder)

Example 7 with ParentRefsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder in project genius by opendaylight.

the class InterfaceHelper method buildVxlanTunnelInterfaceFromInfo.

public static Interface buildVxlanTunnelInterfaceFromInfo(TunnelInterfaceDetails tunnelInterfaceDetails) {
    InterfaceInfo interfaceInfo = tunnelInterfaceDetails.getInterfaceInfo();
    ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(interfaceInfo.getDpId()).setParentInterface(interfaceInfo.getInterfaceName()).build();
    IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(new IpAddress(new Ipv4Address(tunnelInterfaceDetails.getDstIp()))).setTunnelGateway(new IpAddress(new Ipv4Address(DEFAULT_GW))).setTunnelSource(new IpAddress(new Ipv4Address(tunnelInterfaceDetails.getSrcIp()))).setTunnelInterfaceType(TunnelTypeVxlan.class).setInternal(!tunnelInterfaceDetails.isExternal()).setTunnelRemoteIpFlow(false).setTunnelOptions(Collections.emptyList()).build();
    return new InterfaceBuilder().setKey(new InterfaceKey(interfaceInfo.getInterfaceName())).setName(interfaceInfo.getInterfaceName()).setDescription("Tunnel interface").setEnabled(true).setType(Tunnel.class).addAugmentation(ParentRefs.class, parentRefs).addAugmentation(IfTunnel.class, tunnel).build();
}
Also used : ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) Tunnel(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) IfTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 8 with ParentRefsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder in project genius by opendaylight.

the class ItmUtils method buildTunnelInterface.

public static Interface buildTunnelInterface(BigInteger dpn, String ifName, String desc, boolean enabled, Class<? extends TunnelTypeBase> tunType, IpAddress localIp, IpAddress remoteIp, IpAddress gatewayIp, Integer vlanId, boolean internal, Boolean monitorEnabled, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, Integer monitorInterval, boolean useOfTunnel, String parentIfaceName, List<TunnelOptions> tunnelOptions) {
    InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(ifName)).setName(ifName).setDescription(desc).setEnabled(enabled).setType(Tunnel.class);
    ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).setParentInterface(parentIfaceName).build();
    builder.addAugmentation(ParentRefs.class, parentRefs);
    Long monitoringInterval = null;
    if (vlanId > 0) {
        IfL2vlan l2vlan = new IfL2vlanBuilder().setVlanId(new VlanId(vlanId)).build();
        builder.addAugmentation(IfL2vlan.class, l2vlan);
    }
    LOG.debug("buildTunnelInterface: monitorProtocol = {} and monitorInterval = {}", monitorProtocol.getName(), monitorInterval);
    if (monitorInterval != null) {
        monitoringInterval = monitorInterval.longValue();
    }
    IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(remoteIp).setTunnelGateway(gatewayIp).setTunnelSource(localIp).setTunnelInterfaceType(tunType).setInternal(internal).setMonitorEnabled(monitorEnabled).setMonitorProtocol(monitorProtocol).setMonitorInterval(monitoringInterval).setTunnelRemoteIpFlow(useOfTunnel).setTunnelOptions(tunnelOptions).build();
    builder.addAugmentation(IfTunnel.class, tunnel);
    return builder.build();
}
Also used : ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) IfTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder) IfL2vlanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 9 with ParentRefsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder in project genius by opendaylight.

the class InterfaceManagerConfigurationTest method newl2vlanInterfaceTests.

@Test
public void newl2vlanInterfaceTests() throws Exception {
    // 1. When
    // i) parent-interface specified in above vlan configuration comes in operational/ietf-interfaces-state
    OvsdbSouthboundTestUtil.createTerminationPoint(dataBroker, PARENT_INTERFACE, null, INTERFACE_NAME);
    InterfaceManagerTestUtil.createFlowCapableNodeConnector(dataBroker, PARENT_INTERFACE, null);
    // 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().setParentInterface(PARENT_INTERFACE).build();
    InterfaceManagerTestUtil.putInterfaceConfig(dataBroker, INTERFACE_NAME, parentRefs, L2vlan.class);
    InterfaceManagerTestUtil.waitTillOperationCompletes("create interface configuration", coordinatorEventsWaiter, 11, asyncEventsWaiter);
    // 3. Then
    // a) check expected interface-child entry mapping in
    // odl-interface-meta/config/interface-child-info was created
    InstanceIdentifier<InterfaceChildEntry> interfaceChildEntryInstanceIdentifier = InterfaceMetaUtils.getInterfaceChildEntryIdentifier(new InterfaceParentEntryKey(PARENT_INTERFACE), new InterfaceChildEntryKey(INTERFACE_NAME));
    assertEqualBeans(ExpectedInterfaceChildEntry.interfaceChildEntry(INTERFACE_NAME), dataBroker.newReadOnlyTransaction().read(CONFIGURATION, interfaceChildEntryInstanceIdentifier).checkedGet().get());
    // Then
    // a) check if operational/ietf-interfaces-state is populated for the vlan 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(INTERFACE_NAME)).checkedGet().get();
    assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(), INTERFACE_NAME, Interface.OperStatus.Up, L2vlan.class, DPN_ID_1.toString(), ifaceState.getStatistics().getDiscontinuityTime()), ifaceState);
    // FIXME can assert this only once ResourceBatchingManager becomes testable
    // b) check if lport-tag to interface mapping is created
    /*(InstanceIdentifier<IfIndexInterface> ifIndexInterfaceInstanceIdentifier = InstanceIdentifier
                .builder(IfIndexesInterfaceMap.class)
                .child(IfIndexInterface.class, new IfIndexInterfaceKey(ifaceState.getIfIndex())).build();
        Assert.assertEquals(INTERFACE_NAME, dataBroker.newReadOnlyTransaction()
                .read(OPERATIONAL, ifIndexInterfaceInstanceIdentifier).checkedGet().get().getInterfaceName());*/
    // c) check expected flow entries were created in Interface Ingress
    // Table
    BigInteger dpnId = BigInteger.valueOf(1);
    String ingressFlowRef = FlowBasedServicesUtils.getFlowRef(VLAN_INTERFACE_INGRESS_TABLE, dpnId, INTERFACE_NAME);
    FlowKey ingressFlowKey = new FlowKey(new FlowId(ingressFlowRef));
    Node nodeDpn = InterfaceManagerTestUtil.buildInventoryDpnNode(dpnId);
    InstanceIdentifier<Flow> ingressFlowInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(VLAN_INTERFACE_INGRESS_TABLE)).child(Flow.class, ingressFlowKey).build();
    flowAssertTestUtils.assertFlowsInAnyOrder(ExpectedFlowEntries.newIngressFlow(), dataBroker.newReadOnlyTransaction().read(CONFIGURATION, ingressFlowInstanceId).checkedGet().get());
    // d) check if default egress service is bound on the interface
    InstanceIdentifier<BoundServices> boundServicesInstanceIdentifier = InstanceIdentifier.builder(ServiceBindings.class).child(ServicesInfo.class, new ServicesInfoKey(INTERFACE_NAME, ServiceModeEgress.class)).child(BoundServices.class, new BoundServicesKey(DEFAULT_EGRESS_SERVICE_INDEX)).build();
    assertEqualBeans(ExpectedServicesInfo.newboundService(), dataBroker.newReadOnlyTransaction().read(CONFIGURATION, boundServicesInstanceIdentifier).checkedGet().get());
    // Test all RPCs related to vlan-interfaces
    checkVlanRpcs();
    // Test all APIs exposed by interface-manager
    checkVlanApis();
    // Update config test
    // i) vlan interface admin-state updated
    InterfaceManagerTestUtil.updateInterfaceAdminState(dataBroker, INTERFACE_NAME, false);
    InterfaceManagerTestUtil.waitTillOperationCompletes("disable interface admin state", coordinatorEventsWaiter, 1, asyncEventsWaiter);
    // Then
    // a) check if operational/ietf-interfaces-state is updated for vlan interface
    ifaceState = dataBroker.newReadOnlyTransaction().read(OPERATIONAL, IfmUtil.buildStateInterfaceId(INTERFACE_NAME)).checkedGet().get();
    assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(), INTERFACE_NAME, Interface.OperStatus.Down, L2vlan.class, DPN_ID_1.toString(), ifaceState.getStatistics().getDiscontinuityTime()), ifaceState);
    // Restore the opState back to UP for proceeding with further tests
    InterfaceManagerTestUtil.updateInterfaceAdminState(dataBroker, INTERFACE_NAME, true);
    InterfaceManagerTestUtil.waitTillOperationCompletes("enable interface admin state", coordinatorEventsWaiter, 1, asyncEventsWaiter);
    // state modification tests
    // 1. Make the operational state of port as DOWN
    InterfaceManagerTestUtil.updateFlowCapableNodeConnectorState(dataBroker, PARENT_INTERFACE, L2vlan.class, false);
    waitTillOperationCompletes("disable interface op state", coordinatorEventsWaiter, 2, asyncEventsWaiter);
    ifaceState = dataBroker.newReadOnlyTransaction().read(OPERATIONAL, IfmUtil.buildStateInterfaceId(INTERFACE_NAME)).checkedGet().get();
    // Verify if operational/ietf-interface-state is marked down
    assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(), INTERFACE_NAME, Interface.OperStatus.Down, L2vlan.class, DPN_ID_1.toString(), ifaceState.getStatistics().getDiscontinuityTime()), ifaceState);
    // 4. Delete the southbound OF port
    InterfaceManagerTestUtil.removeFlowCapableNodeConnectorState(dataBroker, L2vlan.class);
    waitTillOperationCompletes("remove flow capable node connector", coordinatorEventsWaiter, 5, asyncEventsWaiter);
    // Verify if interfaces are deleted from oper/ietf-interfaces-state
    Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(OPERATIONAL, IfmUtil.buildStateInterfaceId(PARENT_INTERFACE)).get());
    Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(OPERATIONAL, IfmUtil.buildStateInterfaceId(INTERFACE_NAME)).get());
    // 3. Re-create the OF port to proceeed with vlan-member tests
    InterfaceManagerTestUtil.createFlowCapableNodeConnector(dataBroker, PARENT_INTERFACE, null);
    waitTillOperationCompletes("remove flow capable node connector", coordinatorEventsWaiter, 7, asyncEventsWaiter);
    testVlanMemberInterface();
    // Delete test
    // iii) vlan interface is deleted from config/ietf-interfaces
    InterfaceManagerTestUtil.deleteInterfaceConfig(dataBroker, INTERFACE_NAME);
    InterfaceManagerTestUtil.waitTillOperationCompletes("delete interface configuration", coordinatorEventsWaiter, 6, asyncEventsWaiter);
    // 3. Then
    // a) check expected interface-child entry mapping in
    // odl-interface-meta/config/interface-child-info is deleted
    // TODO Later use nicer abstraction for DB access here.. see
    // ElanServiceTest
    Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(CONFIGURATION, interfaceChildEntryInstanceIdentifier).get());
    // Then
    // a) check if operational/ietf-interfaces-state is deleted for the vlan
    // interface
    Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(OPERATIONAL, IfmUtil.buildStateInterfaceId(INTERFACE_NAME)).get());
// b) check if lport-tag to interface mapping is deleted
/*Assert.assertEquals(Optional.absent(),
                dataBroker.newReadOnlyTransaction().read(OPERATIONAL, ifIndexInterfaceInstanceIdentifier).get());*/
}
Also used : 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) ServiceModeEgress(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeEgress) InterfaceChildEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntryKey) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) ServicesInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.ServicesInfoKey) InterfaceParentEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info.InterfaceParentEntryKey) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) BoundServicesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServicesKey) BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) ServiceBindings(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceBindings) InterfaceChildEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry) ExpectedInterfaceChildEntry(org.opendaylight.genius.interfacemanager.test.xtend.ExpectedInterfaceChildEntry) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Example 10 with ParentRefsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder 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)

Aggregations

ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)12 ParentRefsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder)12 InterfaceBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder)9 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey)8 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)6 IfTunnelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder)6 IfL2vlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)5 IfL2vlanBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder)5 L2vlan (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan)4 VlanId (org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId)4 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)3 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 AssertDataObjects.assertEqualBeans (org.opendaylight.mdsal.binding.testutils.AssertDataObjects.assertEqualBeans)2 Tunnel (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)2 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)2 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)2 Options (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.Options)2