Search in sources :

Example 1 with InterfaceChildEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry in project genius by opendaylight.

the class InterfaceManagerConfigurationTest method testVlanMemberInterface.

public void testVlanMemberInterface() throws Exception {
    // Test VlanMember interface creation
    InterfaceManagerTestUtil.putVlanInterfaceConfig(dataBroker, TRUNK_INTERFACE_NAME, INTERFACE_NAME, IfL2vlan.L2vlanMode.TrunkMember);
    InterfaceManagerTestUtil.waitTillOperationCompletes("create vlan member interface", coordinatorEventsWaiter, 7, 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(INTERFACE_NAME), new InterfaceChildEntryKey(TRUNK_INTERFACE_NAME));
    assertEqualBeans(ExpectedInterfaceChildEntry.interfaceChildEntry(TRUNK_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(TRUNK_INTERFACE_NAME)).checkedGet().get();
    assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(), TRUNK_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(TRUNK_INTERFACE_NAME, dataBroker.newReadOnlyTransaction().read(OPERATIONAL,
            ifIndexInterfaceInstanceIdentifier).checkedGet().get().getInterfaceName());*/
    // Update test
    // i) vlan member interface admin-state updated
    InterfaceManagerTestUtil.updateInterfaceAdminState(dataBroker, TRUNK_INTERFACE_NAME, false);
    InterfaceManagerTestUtil.waitTillOperationCompletes("update vlan member interface admin state", coordinatorEventsWaiter, 2, asyncEventsWaiter);
    // Then
    // a) check if operational/ietf-interfaces-state is updated for vlan interface
    ifaceState = dataBroker.newReadOnlyTransaction().read(OPERATIONAL, IfmUtil.buildStateInterfaceId(TRUNK_INTERFACE_NAME)).checkedGet().get();
    assertEqualBeans(ExpectedInterfaceState.newInterfaceState(ifaceState.getIfIndex(), TRUNK_INTERFACE_NAME, Interface.OperStatus.Down, L2vlan.class, DPN_ID_1.toString(), ifaceState.getStatistics().getDiscontinuityTime()), ifaceState);
    InterfaceManagerTestUtil.deleteInterfaceConfig(dataBroker, TRUNK_INTERFACE_NAME);
    InterfaceManagerTestUtil.waitTillOperationCompletes("delete vlan member interface", coordinatorEventsWaiter, 7, asyncEventsWaiter);
    // 1. Then
    // a)
    Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(CONFIGURATION, interfaceChildEntryInstanceIdentifier).get());
    // b) check if operational/ietf-interfaces-state is deleted for the vlan interface
    Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(OPERATIONAL, IfmUtil.buildStateInterfaceId(TRUNK_INTERFACE_NAME)).get());
// FIXME can assert this only once ResourceBatchingManager becomes testable
// c) check if lport-tag to interface mapping is deleted
/*Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(OPERATIONAL,
            ifIndexInterfaceInstanceIdentifier).get());*/
}
Also used : 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) 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) InterfaceChildEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntryKey) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) InterfaceParentEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info.InterfaceParentEntryKey) 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)

Example 2 with InterfaceChildEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry in project genius by opendaylight.

the class ItmTunnelAggregationHelper method updateTunnelAggregationGroup.

private void updateTunnelAggregationGroup(InterfaceParentEntry parentEntry) {
    String logicTunnelName = parentEntry.getParentInterface();
    InternalTunnel logicInternalTunnel = ItmUtils.ITM_CACHE.getInternalTunnel(logicTunnelName);
    if (logicInternalTunnel == null) {
        LOG.debug("MULTIPLE_VxLAN_TUNNELS: {} not found in internal tunnels list", logicTunnelName);
        return;
    }
    InterfaceInfo ifLogicTunnel = interfaceManager.getInterfaceInfoFromOperationalDataStore(logicTunnelName);
    long groupId = ifLogicTunnel != null ? interfaceManager.getLogicalTunnelSelectGroupId(ifLogicTunnel.getInterfaceTag()) : INVALID_ID;
    BigInteger srcDpnId = logicInternalTunnel.getSourceDPN();
    List<Bucket> listBuckets = new ArrayList<>();
    List<InterfaceChildEntry> interfaceChildEntries = parentEntry.getInterfaceChildEntry();
    if (interfaceChildEntries == null || interfaceChildEntries.isEmpty()) {
        LOG.debug("MULTIPLE_VxLAN_TUNNELS: empty child list in group {}", parentEntry.getParentInterface());
        return;
    }
    for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) {
        String curChildName = interfaceChildEntry.getChildInterface();
        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface childIface = ItmUtils.getInterface(curChildName, interfaceManager);
        IfTunnel ifTunnel = childIface != null ? childIface.getAugmentation(IfTunnel.class) : null;
        if (ifTunnel == null || !ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)) {
            LOG.debug("MULTIPLE_VxLAN_TUNNELS: not tunnel interface {} found in group {}", curChildName, logicTunnelName);
            continue;
        }
        ParentRefs parentRefs = childIface.getAugmentation(ParentRefs.class);
        if (parentRefs == null) {
            LOG.debug("MULTIPLE_VxLAN_TUNNELS: parent refs not specified for interface {} in group {}", curChildName, logicTunnelName);
            continue;
        }
        InterfaceInfo ifInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(curChildName);
        if (ifInfo == null) {
            LOG.debug("MULTIPLE_VxLAN_TUNNELS: interface state not found for {} in groupId {}", curChildName, groupId);
            continue;
        }
        int bucketId = interfaceChildEntries.indexOf(interfaceChildEntry);
        LOG.debug("MULTIPLE_VxLAN_TUNNELS: updateTunnelAggregationGroup - add bucketId {} to groupId {}", bucketId, groupId);
        listBuckets.add(createBucket(curChildName, ifTunnel, bucketId, ifInfo.getPortNo()));
    }
    if (!listBuckets.isEmpty()) {
        Group group = MDSALUtil.buildGroup(groupId, logicTunnelName, GroupTypes.GroupSelect, MDSALUtil.buildBucketLists(listBuckets));
        mdsalManager.syncInstallGroup(srcDpnId, group);
    }
}
Also used : TunnelTypeLogicalGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeLogicalGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) ArrayList(java.util.ArrayList) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) InternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) InterfaceChildEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry) BigInteger(java.math.BigInteger) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)

Example 3 with InterfaceChildEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry in project genius by opendaylight.

the class InterfacemgrProvider method getChildInterfaces.

@Override
public List<Interface> getChildInterfaces(ReadTransaction tx, String parentInterface) throws ReadFailedException {
    InterfaceParentEntry parentEntry = interfaceMetaUtils.getInterfaceParentEntryFromConfigDS(tx, parentInterface);
    if (parentEntry == null) {
        LOG.debug("No parent entry found for {}", parentInterface);
        return Collections.emptyList();
    }
    List<InterfaceChildEntry> childEntries = parentEntry.getInterfaceChildEntry();
    if (childEntries == null || childEntries.isEmpty()) {
        LOG.debug("No child entries found for parent {}", parentInterface);
        return Collections.emptyList();
    }
    List<Interface> childInterfaces = new ArrayList<>();
    for (InterfaceChildEntry childEntry : childEntries) {
        String interfaceName = childEntry.getChildInterface();
        Interface iface = interfaceManagerCommonUtils.getInterfaceFromConfigDS(tx, interfaceName);
        if (iface != null) {
            childInterfaces.add(iface);
        } else {
            LOG.debug("Child interface {} not found in config DS for parent interface {}", interfaceName, parentInterface);
        }
    }
    LOG.trace("Found child interfaces {} for parent {}", childInterfaces, parentInterface);
    return childInterfaces;
}
Also used : InterfaceChildEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry) ArrayList(java.util.ArrayList) InterfaceParentEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info.InterfaceParentEntry) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)

Example 4 with InterfaceChildEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry in project genius by opendaylight.

the class InterfaceManagerCommonUtils method deleteInterfaceChildEntry.

public void deleteInterfaceChildEntry(String parentInterface, String childInterface) {
    InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(parentInterface);
    InterfaceChildEntryKey interfaceChildEntryKey = new InterfaceChildEntryKey(childInterface);
    InstanceIdentifier<InterfaceChildEntry> intfId = InterfaceMetaUtils.getInterfaceChildEntryIdentifier(interfaceParentEntryKey, interfaceChildEntryKey);
    batchingUtils.delete(intfId, BatchingUtils.EntityType.DEFAULT_CONFIG);
}
Also used : InterfaceParentEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info.InterfaceParentEntryKey) InterfaceChildEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntryKey) InterfaceChildEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry)

Example 5 with InterfaceChildEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry in project genius by opendaylight.

the class OvsVlanMemberConfigRemoveHelper method removeConfiguration.

public List<ListenableFuture<Void>> removeConfiguration(ParentRefs parentRefs, Interface interfaceOld) {
    LOG.debug("remove vlan member configuration {}", interfaceOld.getName());
    List<ListenableFuture<Void>> futures = new ArrayList<>();
    InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(parentRefs.getParentInterface());
    InstanceIdentifier<InterfaceParentEntry> interfaceParentEntryIid = InterfaceMetaUtils.getInterfaceParentEntryIdentifier(interfaceParentEntryKey);
    InterfaceParentEntry interfaceParentEntry = interfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryIid);
    if (interfaceParentEntry == null) {
        return futures;
    }
    // Configuration changes
    futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
        // Delete the interface child information
        List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
        InterfaceChildEntryKey interfaceChildEntryKey = new InterfaceChildEntryKey(interfaceOld.getName());
        InstanceIdentifier<InterfaceChildEntry> interfaceChildEntryIid = InterfaceMetaUtils.getInterfaceChildEntryIdentifier(interfaceParentEntryKey, interfaceChildEntryKey);
        tx.delete(LogicalDatastoreType.CONFIGURATION, interfaceChildEntryIid);
        // If this is the last child, remove the interface parent info as well.
        if (interfaceChildEntries.size() <= 1) {
            tx.delete(LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIid);
        }
    }));
    // Operational changes
    futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceManagerCommonUtils.getInterfaceState(parentRefs.getParentInterface());
        if (ifState != null) {
            LOG.debug("delete vlan member interface state {}", interfaceOld.getName());
            BigInteger dpId = IfmUtil.getDpnFromInterface(ifState);
            interfaceManagerCommonUtils.deleteInterfaceStateInformation(interfaceOld.getName(), tx);
            FlowBasedServicesUtils.removeIngressFlow(interfaceOld.getName(), dpId, txRunner, futures);
        }
    }));
    return futures;
}
Also used : IfmUtil(org.opendaylight.genius.interfacemanager.IfmUtil) InterfaceChildEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry) Logger(org.slf4j.Logger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) InterfaceParentEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info.InterfaceParentEntryKey) LoggerFactory(org.slf4j.LoggerFactory) InterfaceManagerCommonUtils(org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils) Singleton(javax.inject.Singleton) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) ArrayList(java.util.ArrayList) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) Inject(javax.inject.Inject) List(java.util.List) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) InterfaceChildEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntryKey) BigInteger(java.math.BigInteger) InterfaceMetaUtils(org.opendaylight.genius.interfacemanager.commons.InterfaceMetaUtils) FlowBasedServicesUtils(org.opendaylight.genius.interfacemanager.servicebindings.flowbased.utilities.FlowBasedServicesUtils) InterfaceParentEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info.InterfaceParentEntry) InterfaceChildEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntryKey) ArrayList(java.util.ArrayList) InterfaceParentEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info.InterfaceParentEntry) InterfaceParentEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info.InterfaceParentEntryKey) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) BigInteger(java.math.BigInteger) ArrayList(java.util.ArrayList) List(java.util.List) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)

Aggregations

InterfaceChildEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry)12 InterfaceParentEntryKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info.InterfaceParentEntryKey)7 InterfaceChildEntryKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntryKey)7 BigInteger (java.math.BigInteger)4 ArrayList (java.util.ArrayList)4 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)4 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)4 List (java.util.List)3 InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)3 InterfaceParentEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info.InterfaceParentEntry)3 IfL2vlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 Inject (javax.inject.Inject)2 Singleton (javax.inject.Singleton)2 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)2 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)2 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)2 ManagedNewTransactionRunnerImpl (org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl)2 IfmUtil (org.opendaylight.genius.interfacemanager.IfmUtil)2 InterfaceManagerCommonUtils (org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils)2