Search in sources :

Example 51 with Group

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group 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 52 with Group

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project genius by opendaylight.

the class IfmUtil method getEgressActionInfosForInterface.

/**
 * Returns the list of egress actions for a given interface.
 *
 * @param interfaceInfo the interface to look up
 * @param portNo port number
 * @param ifaceType the type of the interface
 * @param tunnelKey the tunnel key
 * @param actionKeyStart the start for the first key assigned for the new actions
 * @param isDefaultEgress if it is the default egress
 * @param ifIndex interface index
 * @param groupId group Id
 * @return list of actions for the interface
 */
// The following suppression is for javac, not for checkstyle
@SuppressWarnings("fallthrough")
@SuppressFBWarnings("SF_SWITCH_FALLTHROUGH")
public static List<ActionInfo> getEgressActionInfosForInterface(Interface interfaceInfo, String portNo, InterfaceInfo.InterfaceType ifaceType, Long tunnelKey, int actionKeyStart, boolean isDefaultEgress, int ifIndex, long groupId) {
    List<ActionInfo> result = new ArrayList<>();
    switch(ifaceType) {
        case MPLS_OVER_GRE:
        // fall through
        case GRE_TRUNK_INTERFACE:
            if (!isDefaultEgress) {
                // stores the value coming from a VXLAN tunnel
                if (tunnelKey == null) {
                    tunnelKey = 0L;
                }
            }
        // fall through
        case VXLAN_TRUNK_INTERFACE:
            if (!isDefaultEgress) {
                if (tunnelKey != null) {
                    result.add(new ActionSetFieldTunnelId(actionKeyStart++, BigInteger.valueOf(tunnelKey)));
                }
            } else {
                // For OF Tunnels default egress actions need to set tunnelIps
                IfTunnel ifTunnel = interfaceInfo.getAugmentation(IfTunnel.class);
                if (BooleanUtils.isTrue(ifTunnel.isTunnelRemoteIpFlow() && ifTunnel.getTunnelDestination() != null)) {
                    result.add(new ActionSetTunnelDestinationIp(actionKeyStart++, ifTunnel.getTunnelDestination()));
                }
                if (BooleanUtils.isTrue(ifTunnel.isTunnelSourceIpFlow() && ifTunnel.getTunnelSource() != null)) {
                    result.add(new ActionSetTunnelSourceIp(actionKeyStart++, ifTunnel.getTunnelSource()));
                }
            }
        // fall through
        case VLAN_INTERFACE:
            if (isDefaultEgress) {
                IfL2vlan vlanIface = interfaceInfo.getAugmentation(IfL2vlan.class);
                LOG.trace("get egress actions for l2vlan interface: {}", vlanIface);
                boolean isVlanTransparent = false;
                int vlanVid = 0;
                if (vlanIface != null) {
                    vlanVid = vlanIface.getVlanId() == null ? 0 : vlanIface.getVlanId().getValue();
                    isVlanTransparent = vlanIface.getL2vlanMode() == IfL2vlan.L2vlanMode.Transparent;
                }
                if (vlanVid != 0 && !isVlanTransparent) {
                    result.add(new ActionPushVlan(actionKeyStart++));
                    result.add(new ActionSetFieldVlanVid(actionKeyStart++, vlanVid));
                }
                result.add(new ActionOutput(actionKeyStart++, new Uri(portNo)));
            } else {
                addEgressActionInfosForInterface(ifIndex, actionKeyStart, result);
            }
            break;
        case LOGICAL_GROUP_INTERFACE:
            if (isDefaultEgress) {
                result.add(new ActionGroup(groupId));
            } else {
                addEgressActionInfosForInterface(ifIndex, actionKeyStart, result);
            }
            break;
        default:
            LOG.warn("Interface Type {} not handled yet", ifaceType);
            break;
    }
    return result;
}
Also used : ActionSetTunnelDestinationIp(org.opendaylight.genius.mdsalutil.actions.ActionSetTunnelDestinationIp) ArrayList(java.util.ArrayList) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) ActionSetFieldVlanVid(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldVlanVid) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) ActionPushVlan(org.opendaylight.genius.mdsalutil.actions.ActionPushVlan) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) ActionSetTunnelSourceIp(org.opendaylight.genius.mdsalutil.actions.ActionSetTunnelSourceIp) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) ActionOutput(org.opendaylight.genius.mdsalutil.actions.ActionOutput) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 53 with Group

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project genius by opendaylight.

the class OvsInterfaceConfigAddHelper method createLogicalTunnelSelectGroup.

private long createLogicalTunnelSelectGroup(BigInteger srcDpnId, String interfaceName, int lportTag) {
    long groupId = IfmUtil.getLogicalTunnelSelectGroupId(lportTag);
    Group group = MDSALUtil.buildGroup(groupId, interfaceName, GroupTypes.GroupSelect, MDSALUtil.buildBucketLists(Collections.emptyList()));
    LOG.debug("MULTIPLE_VxLAN_TUNNELS: group id {} installed for {} srcDpnId {}", group.getGroupId().getValue(), interfaceName, srcDpnId);
    mdsalApiManager.syncInstallGroup(srcDpnId, group);
    return groupId;
}
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)

Example 54 with Group

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project genius by opendaylight.

the class MDSALManager method writeGroupEntityInternal.

public void writeGroupEntityInternal(GroupEntity groupEntity, WriteTransaction tx) {
    Group group = groupEntity.getGroupBuilder().build();
    Node nodeDpn = buildDpnNode(groupEntity.getDpnId());
    InstanceIdentifier<Group> groupInstanceId = buildGroupInstanceIdentifier(groupEntity.getGroupId(), nodeDpn);
    tx.put(LogicalDatastoreType.CONFIGURATION, groupInstanceId, group, true);
}
Also used : ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)

Example 55 with Group

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project genius by opendaylight.

the class MDSALManager method syncSetUpGroupInternal.

public void syncSetUpGroupInternal(GroupEntity groupEntity, boolean isRemove) {
    if (LOG.isTraceEnabled()) {
        LOG.trace("syncSetUpGroup for groupEntity {} ", groupEntity);
    }
    Group group = groupEntity.getGroupBuilder().build();
    BigInteger dpId = groupEntity.getDpnId();
    long groupId = groupEntity.getGroupId();
    InstanceIdentifier<Group> groupInstanceId = buildGroupInstanceIdentifier(groupId, buildDpnNode(dpId));
    if (isRemove) {
        synchronized (getGroupKey(groupId, dpId)) {
            if (groupExists(dpId, groupId)) {
                MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, groupInstanceId);
            } else {
                LOG.debug("Group {} does not exist for dpn {}", groupId, dpId);
            }
        }
    } else {
        MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, groupInstanceId, group);
    }
}
Also used : ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) BigInteger(java.math.BigInteger)

Aggregations

ArrayList (java.util.ArrayList)71 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)50 Test (org.junit.Test)45 BigInteger (java.math.BigInteger)35 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)31 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)27 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)21 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)20 GroupBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder)18 GroupKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey)18 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)17 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)15 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)14 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)13 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)13 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)13 ByteBuf (io.netty.buffer.ByteBuf)12 List (java.util.List)12 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)11 StaleGroup (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup)11