Search in sources :

Example 31 with Acl

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl in project netvirt by opendaylight.

the class AclServiceUtils method allocateId.

public static Integer allocateId(IdManagerService idManager, String poolName, String idKey, Integer defaultId) {
    AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(poolName).setIdKey(idKey).build();
    try {
        Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
        RpcResult<AllocateIdOutput> rpcResult = result.get();
        if (rpcResult.isSuccessful()) {
            Integer allocatedId = rpcResult.getResult().getIdValue().intValue();
            LOG.debug("Allocated ACL ID: {} with key: {} into pool: {}", allocatedId, idKey, poolName);
            return allocatedId;
        } else {
            LOG.error("RPC Call to Get Unique Id for key {} from pool {} returned with Errors {}", idKey, poolName, rpcResult.getErrors());
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Exception when getting Unique Id for key {} from pool {} ", idKey, poolName, e);
    }
    return defaultId;
}
Also used : BigInteger(java.math.BigInteger) 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)

Example 32 with Acl

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl in project netvirt by opendaylight.

the class AclServiceUtils method getHardTimoutForApplyStatefulChangeOnExistingTraffic.

/**
 * Returns the hard timeout based on the protocol when a ACL rule removed from the instance.
 * It will returns the timeout configured in the {@link AclserviceConfig} class.
 *
 * @param ace the ace
 * @param aclServiceUtils acl service utils
 * @return the hard time out
 */
public static Integer getHardTimoutForApplyStatefulChangeOnExistingTraffic(Ace ace, AclServiceUtils aclServiceUtils) {
    int hardTimeout = AclConstants.SECURITY_GROUP_ICMP_IDLE_TIME_OUT;
    Matches matches = ace.getMatches();
    AceIp acl = (AceIp) matches.getAceType();
    Short protocol = acl.getProtocol();
    if (protocol == null) {
        return hardTimeout;
    } else if (protocol == NwConstants.IP_PROT_TCP) {
        hardTimeout = aclServiceUtils.getConfig().getSecurityGroupTcpIdleTimeout();
    } else if (protocol == NwConstants.IP_PROT_UDP) {
        hardTimeout = aclServiceUtils.getConfig().getSecurityGroupUdpIdleTimeout();
    }
    return hardTimeout;
}
Also used : Matches(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches) AceIp(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.AceIp)

Example 33 with Acl

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl in project netvirt by opendaylight.

the class AclServiceUtils method getRemoteAclIdsByDirection.

public static Set<Uuid> getRemoteAclIdsByDirection(Acl acl, Class<? extends DirectionBase> direction) {
    Set<Uuid> remoteAclIds = new HashSet<>();
    AccessListEntries accessListEntries = acl.getAccessListEntries();
    if (accessListEntries != null && accessListEntries.getAce() != null) {
        for (Ace ace : accessListEntries.getAce()) {
            SecurityRuleAttr aceAttr = AclServiceUtils.getAccesssListAttributes(ace);
            if (aceAttr.getDirection().equals(direction) && doesAceHaveRemoteGroupId(aceAttr)) {
                remoteAclIds.add(aceAttr.getRemoteGroupId());
            }
        }
    }
    return remoteAclIds;
}
Also used : Ace(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.Ace) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) SecurityRuleAttr(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.SecurityRuleAttr) AccessListEntries(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.AccessListEntries) HashSet(java.util.HashSet)

Example 34 with Acl

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl in project netvirt by opendaylight.

the class AclServiceUtils method getRemoteAclIdsByDirection.

public Set<Uuid> getRemoteAclIdsByDirection(List<Uuid> aclIds, Class<? extends DirectionBase> direction) {
    Set<Uuid> remoteAclIds = new HashSet<>();
    if (aclIds == null || aclIds.isEmpty()) {
        return remoteAclIds;
    }
    for (Uuid aclId : aclIds) {
        Acl acl = this.aclDataUtil.getAcl(aclId.getValue());
        if (null == acl) {
            LOG.warn("ACL {} not found in cache.", aclId.getValue());
            continue;
        }
        remoteAclIds.addAll(getRemoteAclIdsByDirection(acl, direction));
    }
    return remoteAclIds;
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Acl(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl) Ipv4Acl(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.Ipv4Acl) InterfaceAcl(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.InterfaceAcl) NetvirtAcl(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.types.rev170711.NetvirtAcl) HashSet(java.util.HashSet)

Example 35 with Acl

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl in project netvirt by opendaylight.

the class AclLiveStatisticsRpcServiceTest method setUp.

@Before
public void setUp() throws Exception {
    aclStatsService = new AclLiveStatisticsRpcServiceImpl(config, dataBroker, odlDirectStatsService);
    singleTransactionDataBroker = new SingleTransactionDataBroker(dataBroker);
    LOG.info("Acl mode: {}", config.getSecurityGroupMode());
    newElan(ELAN, ELAN_TAG);
    newElanInterface(ELAN, PORT_1, true);
    Pair<DataTreeIdentifier<Interface>, Interface> port1 = new IdentifiedInterfaceWithAclBuilder().interfaceName(PORT_1).portSecurity(true).build();
    dataBrokerUtil.put(port1);
    testInterfaceManager.addInterface(port1.getValue());
    putNewStateInterface(dataBroker, "port1", PORT_MAC_1);
    asyncEventsWaiter.awaitEventsConsumption();
}
Also used : DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) IdentifiedInterfaceWithAclBuilder(org.opendaylight.netvirt.aclservice.tests.IdentifiedInterfaceWithAclBuilder) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) StateInterfaceBuilderHelper.putNewStateInterface(org.opendaylight.netvirt.aclservice.tests.StateInterfaceBuilderHelper.putNewStateInterface) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) Before(org.junit.Before)

Aggregations

ArrayList (java.util.ArrayList)27 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)19 AclInterface (org.opendaylight.netvirt.aclservice.api.utils.AclInterface)16 BigInteger (java.math.BigInteger)15 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)15 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)13 AllowedAddressPairs (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs)13 List (java.util.List)12 IpPrefixOrAddress (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.IpPrefixOrAddress)10 HashMap (java.util.HashMap)9 HashSet (java.util.HashSet)9 Ace (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.Ace)9 Set (java.util.Set)8 Acl (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl)8 Collections (java.util.Collections)7 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)7 MDSALUtil (org.opendaylight.genius.mdsalutil.MDSALUtil)7 NwConstants (org.opendaylight.genius.mdsalutil.NwConstants)7 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)7 MatchEthernetType (org.opendaylight.genius.mdsalutil.matches.MatchEthernetType)7