Search in sources :

Example 1 with ServiceIndex

use of org.opendaylight.genius.utils.ServiceIndex in project netvirt by opendaylight.

the class EgressAclServiceImpl method bindService.

/**
 * Bind service.
 *
 * @param aclInterface the acl interface
 */
@Override
public void bindService(AclInterface aclInterface) {
    String interfaceName = aclInterface.getInterfaceId();
    jobCoordinator.enqueueJob(interfaceName, () -> {
        int instructionKey = 0;
        List<Instruction> instructions = new ArrayList<>();
        instructions.add(MDSALUtil.buildAndGetGotoTableInstruction(getAclAntiSpoofingTable(), ++instructionKey));
        short serviceIndex = ServiceIndex.getIndex(AclConstants.INGRESS_ACL_SERVICE_NAME, AclConstants.INGRESS_ACL_SERVICE_INDEX);
        int flowPriority = AclConstants.INGRESS_ACL_SERVICE_INDEX;
        BoundServices serviceInfo = AclServiceUtils.getBoundServices(String.format("%s.%s.%s", "acl", "ingressacl", interfaceName), serviceIndex, flowPriority, AclConstants.COOKIE_ACL_BASE, instructions);
        InstanceIdentifier<BoundServices> path = AclServiceUtils.buildServiceId(interfaceName, serviceIndex, serviceMode);
        return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.put(LogicalDatastoreType.CONFIGURATION, path, serviceInfo, WriteTransaction.CREATE_MISSING_PARENTS)));
    });
}
Also used : ServiceModeIngress(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeIngress) LoggerFactory(org.slf4j.LoggerFactory) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) AclServiceUtils(org.opendaylight.netvirt.aclservice.utils.AclServiceUtils) ArrayList(java.util.ArrayList) ServiceIndex(org.opendaylight.genius.utils.ServiceIndex) AllowedAddressPairs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs) MatchEthernetSource(org.opendaylight.genius.mdsalutil.matches.MatchEthernetSource) AclInterfaceCache(org.opendaylight.netvirt.aclservice.api.AclInterfaceCache) MatchEthernetType(org.opendaylight.genius.mdsalutil.matches.MatchEthernetType) BigInteger(java.math.BigInteger) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) MatchArpSha(org.opendaylight.genius.mdsalutil.matches.MatchArpSha) AclServiceOFFlowBuilder(org.opendaylight.netvirt.aclservice.utils.AclServiceOFFlowBuilder) DirectionBase(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionBase) AclInterface(org.opendaylight.netvirt.aclservice.api.utils.AclInterface) MatchCriteria(org.opendaylight.netvirt.aclservice.api.AclServiceManager.MatchCriteria) BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) Logger(org.slf4j.Logger) AclConstants(org.opendaylight.netvirt.aclservice.utils.AclConstants) AclDataUtil(org.opendaylight.netvirt.aclservice.utils.AclDataUtil) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) Set(java.util.Set) Collectors(java.util.stream.Collectors) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) List(java.util.List) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) Action(org.opendaylight.netvirt.aclservice.api.AclServiceManager.Action) IpPrefixOrAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress) Collections(java.util.Collections) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) DirectionEgress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionEgress) BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) ArrayList(java.util.ArrayList) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)

Example 2 with ServiceIndex

use of org.opendaylight.genius.utils.ServiceIndex in project netvirt by opendaylight.

the class IngressAclServiceImpl method bindService.

/**
 * Bind service.
 *
 * @param aclInterface the acl interface
 */
@Override
public void bindService(AclInterface aclInterface) {
    String interfaceName = aclInterface.getInterfaceId();
    jobCoordinator.enqueueJob(interfaceName, () -> {
        int instructionKey = 0;
        List<Instruction> instructions = new ArrayList<>();
        instructions.add(MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.EGRESS_ACL_DUMMY_TABLE, ++instructionKey));
        int flowPriority = NwConstants.EGRESS_ACL_SERVICE_INDEX;
        short serviceIndex = ServiceIndex.getIndex(NwConstants.EGRESS_ACL_SERVICE_NAME, NwConstants.EGRESS_ACL_SERVICE_INDEX);
        BoundServices serviceInfo = AclServiceUtils.getBoundServices(String.format("%s.%s.%s", "acl", "egressacl", interfaceName), serviceIndex, flowPriority, AclConstants.COOKIE_ACL_BASE, instructions);
        InstanceIdentifier<BoundServices> path = AclServiceUtils.buildServiceId(interfaceName, ServiceIndex.getIndex(NwConstants.EGRESS_ACL_SERVICE_NAME, NwConstants.EGRESS_ACL_SERVICE_INDEX), serviceMode);
        return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.put(LogicalDatastoreType.CONFIGURATION, path, serviceInfo, WriteTransaction.CREATE_MISSING_PARENTS)));
    });
}
Also used : LoggerFactory(org.slf4j.LoggerFactory) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) AclServiceUtils(org.opendaylight.netvirt.aclservice.utils.AclServiceUtils) ArrayList(java.util.ArrayList) MatchEthernetDestination(org.opendaylight.genius.mdsalutil.matches.MatchEthernetDestination) ServiceIndex(org.opendaylight.genius.utils.ServiceIndex) AllowedAddressPairs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs) AclInterfaceCache(org.opendaylight.netvirt.aclservice.api.AclInterfaceCache) MatchEthernetType(org.opendaylight.genius.mdsalutil.matches.MatchEthernetType) BigInteger(java.math.BigInteger) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) AclServiceOFFlowBuilder(org.opendaylight.netvirt.aclservice.utils.AclServiceOFFlowBuilder) ServiceModeEgress(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeEgress) DirectionBase(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionBase) DirectionIngress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionIngress) AclInterface(org.opendaylight.netvirt.aclservice.api.utils.AclInterface) MatchCriteria(org.opendaylight.netvirt.aclservice.api.AclServiceManager.MatchCriteria) BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) Logger(org.slf4j.Logger) AclConstants(org.opendaylight.netvirt.aclservice.utils.AclConstants) AclDataUtil(org.opendaylight.netvirt.aclservice.utils.AclDataUtil) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) List(java.util.List) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) Action(org.opendaylight.netvirt.aclservice.api.AclServiceManager.Action) IpPrefixOrAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress) Collections(java.util.Collections) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) ArrayList(java.util.ArrayList) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)

Aggregations

BigInteger (java.math.BigInteger)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 List (java.util.List)2 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)2 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)2 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)2 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)2 MDSALUtil (org.opendaylight.genius.mdsalutil.MDSALUtil)2 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)2 NwConstants (org.opendaylight.genius.mdsalutil.NwConstants)2 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)2 IMdsalApiManager (org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager)2 MatchEthernetType (org.opendaylight.genius.mdsalutil.matches.MatchEthernetType)2 ServiceIndex (org.opendaylight.genius.utils.ServiceIndex)2 JobCoordinator (org.opendaylight.infrautils.jobcoordinator.JobCoordinator)2 AclInterfaceCache (org.opendaylight.netvirt.aclservice.api.AclInterfaceCache)2 Action (org.opendaylight.netvirt.aclservice.api.AclServiceManager.Action)2 MatchCriteria (org.opendaylight.netvirt.aclservice.api.AclServiceManager.MatchCriteria)2 AclInterface (org.opendaylight.netvirt.aclservice.api.utils.AclInterface)2