Search in sources :

Example 21 with Group

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

the class ElanInterfaceManager method removeElanInterface.

public List<ListenableFuture<Void>> removeElanInterface(ElanInstance elanInfo, String interfaceName, InterfaceInfo interfaceInfo) {
    String elanName = elanInfo.getElanInstanceName();
    boolean isLastElanInterface = false;
    boolean isLastInterfaceOnDpn = false;
    BigInteger dpId = null;
    long elanTag = elanInfo.getElanTag();
    // We use two transaction so we don't suffer on multiple shards (interfaces and flows)
    WriteTransaction interfaceTx = broker.newWriteOnlyTransaction();
    Elan elanState = removeElanStateForInterface(elanInfo, interfaceName, interfaceTx);
    if (elanState == null) {
        interfaceTx.cancel();
        return Collections.emptyList();
    }
    WriteTransaction flowTx = broker.newWriteOnlyTransaction();
    List<String> elanInterfaces = elanState.getElanInterfaces();
    if (elanInterfaces.isEmpty()) {
        isLastElanInterface = true;
    }
    if (interfaceInfo != null) {
        dpId = interfaceInfo.getDpId();
        DpnInterfaces dpnInterfaces = removeElanDpnInterfaceFromOperationalDataStore(elanName, dpId, interfaceName, elanTag, interfaceTx);
        /*
             * If there are not elan ports, remove the unknown dmac, terminating
             * service table flows, remote/local bc group
             */
        if (dpnInterfaces == null || dpnInterfaces.getInterfaces() == null || dpnInterfaces.getInterfaces().isEmpty()) {
            // No more Elan Interfaces in this DPN
            LOG.debug("deleting the elan: {} present on dpId: {}", elanInfo.getElanInstanceName(), dpId);
            if (!elanUtils.isOpenstackVniSemanticsEnforced()) {
                removeDefaultTermFlow(dpId, elanInfo.getElanTag());
            }
            removeUnknownDmacFlow(dpId, elanInfo, flowTx, elanInfo.getElanTag());
            removeEtreeUnknownDmacFlow(dpId, elanInfo, flowTx);
            removeElanBroadcastGroup(elanInfo, interfaceInfo, flowTx);
            removeLocalBroadcastGroup(elanInfo, interfaceInfo, flowTx);
            removeEtreeBroadcastGrups(elanInfo, interfaceInfo, flowTx);
            if (isVxlanNetworkOrVxlanSegment(elanInfo)) {
                if (elanUtils.isOpenstackVniSemanticsEnforced()) {
                    elanUtils.removeTerminatingServiceAction(dpId, elanUtils.getVxlanSegmentationId(elanInfo).intValue());
                }
                unsetExternalTunnelTable(dpId, elanInfo);
            }
            isLastInterfaceOnDpn = true;
        } else {
            setupLocalBroadcastGroups(elanInfo, dpnInterfaces, interfaceInfo);
        }
    }
    List<ListenableFuture<Void>> futures = new ArrayList<>();
    futures.add(ElanUtils.waitForTransactionToComplete(interfaceTx));
    futures.add(ElanUtils.waitForTransactionToComplete(flowTx));
    if (isLastInterfaceOnDpn && dpId != null && isVxlanNetworkOrVxlanSegment(elanInfo)) {
        setElanAndEtreeBCGrouponOtherDpns(elanInfo, dpId);
    }
    InterfaceRemoveWorkerOnElanInterface removeInterfaceWorker = new InterfaceRemoveWorkerOnElanInterface(interfaceName, elanInfo, interfaceInfo, this, isLastElanInterface);
    jobCoordinator.enqueueJob(ElanUtils.getElanInterfaceJobKey(interfaceName), removeInterfaceWorker, ElanConstants.JOB_MAX_RETRIES);
    return futures;
}
Also used : ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Elan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 22 with Group

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

the class PortPairGroupTranslator method buildServiceFunctionForwarder.

public static ServiceFunctionForwarder buildServiceFunctionForwarder(PortPairGroup portPairGroup, List<PortPair> portPairs) {
    Preconditions.checkNotNull(portPairGroup, "Port pair group must not be null");
    Preconditions.checkNotNull(portPairs, "Port pairs must not be null");
    Preconditions.checkElementIndex(0, portPairs.size(), "There must be at least one port pair");
    // Currently we only support one SF per type. Mean, one port-pair per port-pair-group.
    final PortPair portPair = portPairs.get(0);
    ServiceFunctionForwarderBuilder sffBuilder = new ServiceFunctionForwarderBuilder();
    sffBuilder.setName(new SffName(SfcMdsalHelper.NETVIRT_LOGICAL_SFF_NAME));
    DataPlaneLocatorBuilder forwardDplBuilder = new DataPlaneLocatorBuilder();
    forwardDplBuilder.setTransport(Mac.class);
    String forwardPort = portPair.getIngress().getValue();
    LogicalInterface forwardInterface = new LogicalInterfaceBuilder().setInterfaceName(forwardPort).build();
    forwardDplBuilder.setLocatorType(forwardInterface);
    SffDataPlaneLocatorBuilder sffForwardDplBuilder = new SffDataPlaneLocatorBuilder();
    sffForwardDplBuilder.setDataPlaneLocator(forwardDplBuilder.build());
    String forwardDplName = portPair.getName() + DPL_INGRESS_SUFFIX;
    sffForwardDplBuilder.setName(new SffDataPlaneLocatorName(forwardDplName));
    DataPlaneLocatorBuilder reverseDplBuilder = new DataPlaneLocatorBuilder();
    reverseDplBuilder.setTransport(Mac.class);
    String reversePort = portPair.getEgress().getValue();
    LogicalInterface reverseInterface = new LogicalInterfaceBuilder().setInterfaceName(reversePort).build();
    reverseDplBuilder.setLocatorType(reverseInterface);
    SffDataPlaneLocatorBuilder sffReverseDplBuilder = new SffDataPlaneLocatorBuilder();
    sffReverseDplBuilder.setDataPlaneLocator(reverseDplBuilder.build());
    String reverseDplName = portPair.getName() + DPL_EGRESS_SUFFIX;
    sffReverseDplBuilder.setName(new SffDataPlaneLocatorName(reverseDplName));
    List<SffDataPlaneLocator> sffDataPlaneLocator = new ArrayList<>();
    sffDataPlaneLocator.add(sffForwardDplBuilder.build());
    sffDataPlaneLocator.add(sffReverseDplBuilder.build());
    sffBuilder.setSffDataPlaneLocator(sffDataPlaneLocator);
    SffSfDataPlaneLocatorBuilder sffSfDataPlaneLocatorBuilder = new SffSfDataPlaneLocatorBuilder();
    sffSfDataPlaneLocatorBuilder.setSffForwardDplName(new SffDataPlaneLocatorName(forwardDplName));
    sffSfDataPlaneLocatorBuilder.setSfForwardDplName(new SfDataPlaneLocatorName(forwardDplName));
    sffSfDataPlaneLocatorBuilder.setSffReverseDplName(new SffDataPlaneLocatorName(reverseDplName));
    sffSfDataPlaneLocatorBuilder.setSfReverseDplName(new SfDataPlaneLocatorName(reverseDplName));
    ServiceFunctionDictionaryBuilder sfdBuilder = new ServiceFunctionDictionaryBuilder();
    sfdBuilder.setName(new SfName(portPair.getName()));
    sfdBuilder.setSffSfDataPlaneLocator(sffSfDataPlaneLocatorBuilder.build());
    List<ServiceFunctionDictionary> sfdList = new ArrayList<>();
    sfdList.add(sfdBuilder.build());
    sffBuilder.setServiceFunctionDictionary(sfdList);
    return sffBuilder.build();
}
Also used : SffSfDataPlaneLocatorBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder) DataPlaneLocatorBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.sff.data.plane.locator.DataPlaneLocatorBuilder) SffDataPlaneLocatorBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocatorBuilder) ServiceFunctionForwarderBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder) ArrayList(java.util.ArrayList) SffName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName) SffDataPlaneLocatorBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocatorBuilder) SffDataPlaneLocatorName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffDataPlaneLocatorName) SfDataPlaneLocatorName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfDataPlaneLocatorName) LogicalInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.data.plane.locator.locator.type.LogicalInterfaceBuilder) LogicalInterface(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.data.plane.locator.locator.type.LogicalInterface) PortPair(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pairs.PortPair) SffSfDataPlaneLocatorBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder) SfName(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName) ServiceFunctionDictionary(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionary) SffDataPlaneLocator(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarder.base.SffDataPlaneLocator) ServiceFunctionDictionaryBuilder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder)

Example 23 with Group

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

the class AclServiceOFFlowBuilder method programIcmpFlow.

/**
 *Converts icmp matches to flows.
 * @param acl the access control list
 * @return the map containing the flows and the respective flow id
 */
public static Map<String, List<MatchInfoBase>> programIcmpFlow(AceIp acl) {
    List<MatchInfoBase> flowMatches = new ArrayList<>();
    flowMatches.addAll(addSrcIpMatches(acl));
    flowMatches.addAll(addDstIpMatches(acl));
    // For ICMP port range indicates type and code
    SourcePortRange sourcePortRange = acl.getSourcePortRange();
    String flowId = "ICMP_";
    if (sourcePortRange != null) {
        if (acl.getAceIpVersion() instanceof AceIpv4) {
            flowMatches.add(new MatchIcmpv4(sourcePortRange.getLowerPort().getValue().shortValue(), sourcePortRange.getUpperPort().getValue().shortValue()));
            flowId = flowId + "V4_SOURCE_" + sourcePortRange.getLowerPort().getValue() + sourcePortRange.getUpperPort().getValue();
        } else if (acl.getAceIpVersion() instanceof AceIpv6) {
            flowMatches.add(new MatchIcmpv6(sourcePortRange.getLowerPort().getValue().shortValue(), sourcePortRange.getUpperPort().getValue().shortValue()));
            flowId = flowId + "V6_SOURCE_" + sourcePortRange.getLowerPort().getValue() + "_" + sourcePortRange.getUpperPort().getValue() + "_";
        }
    }
    DestinationPortRange destinationPortRange = acl.getDestinationPortRange();
    if (destinationPortRange != null) {
        if (acl.getAceIpVersion() instanceof AceIpv4) {
            flowMatches.add(new MatchIcmpv4(destinationPortRange.getLowerPort().getValue().shortValue(), destinationPortRange.getUpperPort().getValue().shortValue()));
            flowId = flowId + "V4_DESTINATION_" + destinationPortRange.getLowerPort().getValue() + destinationPortRange.getUpperPort().getValue() + "_";
        } else if (acl.getAceIpVersion() instanceof AceIpv6) {
            flowMatches.add(new MatchIcmpv6(destinationPortRange.getLowerPort().getValue().shortValue(), destinationPortRange.getUpperPort().getValue().shortValue()));
            flowId = flowId + "V6_DESTINATION_" + destinationPortRange.getLowerPort().getValue() + destinationPortRange.getUpperPort().getValue() + "_";
        }
    }
    if (acl.getAceIpVersion() instanceof AceIpv6 && acl.getProtocol() == NwConstants.IP_PROT_ICMP) {
        // We are aligning our implementation similar to Neutron Firewall driver where a Security
        // Group rule with "Ethertype as IPv6 and Protocol as icmp" is treated as ICMPV6 SG Rule.
        flowMatches.add(new MatchIpProtocol(AclConstants.IP_PROT_ICMPV6));
    } else {
        flowMatches.add(new MatchIpProtocol(acl.getProtocol()));
    }
    Map<String, List<MatchInfoBase>> flowMatchesMap = new HashMap<>();
    flowMatchesMap.put(flowId, flowMatches);
    return flowMatchesMap;
}
Also used : SourcePortRange(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160218.acl.transport.header.fields.SourcePortRange) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MatchIpProtocol(org.opendaylight.genius.mdsalutil.matches.MatchIpProtocol) DestinationPortRange(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160218.acl.transport.header.fields.DestinationPortRange) MatchIcmpv4(org.opendaylight.genius.mdsalutil.matches.MatchIcmpv4) MatchIcmpv6(org.opendaylight.genius.mdsalutil.matches.MatchIcmpv6) ArrayList(java.util.ArrayList) List(java.util.List) AceIpv6(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv6) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) AceIpv4(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4)

Example 24 with Group

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

the class ExternalNetworkGroupInstaller method buildExtNetGroupEntity.

private GroupEntity buildExtNetGroupEntity(String macAddress, String subnetName, long groupId, String extInterface, BigInteger dpnId) {
    List<ActionInfo> actionList = new ArrayList<>();
    final int setFieldEthDestActionPos = 0;
    List<ActionInfo> egressActionList = new ArrayList<>();
    if (extInterface != null) {
        egressActionList = NatUtil.getEgressActionsForInterface(interfaceManager, extInterface, null, setFieldEthDestActionPos + 1);
    }
    if (Strings.isNullOrEmpty(macAddress) || egressActionList.isEmpty()) {
        if (Strings.isNullOrEmpty(macAddress)) {
            LOG.trace("buildExtNetGroupEntity : Building ext-net group {} entry with drop action since " + "GW mac has not been resolved for subnet {} extInterface {}", groupId, subnetName, extInterface);
        } else {
            LOG.warn("buildExtNetGroupEntity : Building ext-net group {} entry with drop action since " + "no egress actions were found for subnet {} extInterface {}", groupId, subnetName, extInterface);
        }
        actionList.add(new ActionDrop());
    } else {
        LOG.trace("Building ext-net group {} entry for subnet {} extInterface {} macAddress {}", groupId, subnetName, extInterface, macAddress);
        actionList.add(new ActionSetFieldEthernetDestination(setFieldEthDestActionPos, new MacAddress(macAddress)));
        actionList.addAll(egressActionList);
    }
    List<BucketInfo> listBucketInfo = new ArrayList<>();
    listBucketInfo.add(new BucketInfo(actionList));
    return MDSALUtil.buildGroupEntity(dpnId, groupId, subnetName, GroupTypes.GroupAll, listBucketInfo);
}
Also used : ActionSetFieldEthernetDestination(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ActionDrop(org.opendaylight.genius.mdsalutil.actions.ActionDrop)

Example 25 with Group

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

the class ExternalRoutersListener method createGroupId.

protected long createGroupId(String groupIdKey) {
    AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(NatConstants.SNAT_IDPOOL_NAME).setIdKey(groupIdKey).build();
    try {
        Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
        RpcResult<AllocateIdOutput> rpcResult = result.get();
        return rpcResult.getResult().getIdValue();
    } catch (NullPointerException | InterruptedException | ExecutionException e) {
        LOG.error("Exception While allocating id for group: {}", groupIdKey, e);
    }
    return 0;
}
Also used : AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ExecutionException(java.util.concurrent.ExecutionException) AllocateIdOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)

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