Search in sources :

Example 11 with Direction

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.Direction in project netvirt by opendaylight.

the class DisplayAclDataCaches method getRemoteAclIdMap.

protected void getRemoteAclIdMap(Class<? extends DirectionBase> direction) {
    if (all == null && uuidStr == null) {
        printRemoteAclIdMapHelp();
    } else if (all == null) {
        Uuid uuidRef;
        try {
            uuidRef = Uuid.getDefaultInstance(uuidStr);
        } catch (IllegalArgumentException e) {
            session.getConsole().println("Invalid uuid" + e.getMessage());
            log.error("Invalid uuid", e);
            return;
        }
        Collection<Uuid> remoteUuidLst = aclDataCache.getRemoteAcl(uuidRef, direction);
        if (remoteUuidLst == null || remoteUuidLst.isEmpty()) {
            session.getConsole().println("UUID not matched");
        } else {
            session.getConsole().println(REM_ID_HEAD);
            session.getConsole().print(String.format(KEY_TAB, uuidRef.getValue()));
            boolean first = true;
            for (Uuid uuid : remoteUuidLst) {
                if (first) {
                    session.getConsole().println(String.format(REM_ID_TAB, uuid.getValue()));
                    first = false;
                } else {
                    session.getConsole().println(String.format(REM_ID_TAB_FOR, "", uuid.getValue()));
                }
            }
        }
    } else if (uuidStr == null) {
        if (!validateAll()) {
            printRemoteAclIdMapHelp();
            return;
        }
        Map<Uuid, Collection<Uuid>> map = DirectionEgress.class.equals(direction) ? aclDataCache.getEgressRemoteAclIdMap() : aclDataCache.getIngressRemoteAclIdMap();
        if (map.isEmpty()) {
            session.getConsole().println("No data found");
        } else {
            session.getConsole().println(REM_ID_HEAD);
            for (Entry<Uuid, Collection<Uuid>> entry : map.entrySet()) {
                session.getConsole().print(String.format(KEY_TAB, entry.getKey().getValue()));
                if (entry.getValue() == null || entry.getValue().isEmpty()) {
                    session.getConsole().println(String.format(REM_ID_TAB, ""));
                } else {
                    boolean first = true;
                    for (Uuid uuid : entry.getValue()) {
                        if (first) {
                            session.getConsole().println(String.format(REM_ID_TAB, uuid.getValue()));
                            first = false;
                        } else {
                            session.getConsole().println(String.format(REM_ID_TAB_FOR, "", uuid.getValue()));
                        }
                    }
                }
            }
        }
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Collection(java.util.Collection) DirectionEgress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.DirectionEgress)

Example 12 with Direction

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.Direction in project netvirt by opendaylight.

the class AclServiceUtils method getRemoteAclTags.

public SortedSet<Integer> getRemoteAclTags(List<Uuid> aclIds, Class<? extends DirectionBase> direction) {
    SortedSet<Integer> remoteAclTags = new TreeSet<>();
    Set<Uuid> remoteAclIds = getRemoteAclIdsByDirection(aclIds, direction);
    for (Uuid remoteAclId : remoteAclIds) {
        Integer remoteAclTag = getAclTag(remoteAclId);
        if (remoteAclTag != null && remoteAclTag != AclConstants.INVALID_ACL_TAG) {
            remoteAclTags.add(remoteAclTag);
        }
    }
    return remoteAclTags;
}
Also used : BigInteger(java.math.BigInteger) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) TreeSet(java.util.TreeSet)

Example 13 with Direction

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.Direction 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 14 with Direction

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.Direction 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 15 with Direction

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.Direction in project netvirt by opendaylight.

the class AclLiveStatisticsRpcServiceTest method getStatsTwoPortEgressOnly.

/**
 * Test stats for two ports and egress direction only. <br>
 * port1 is valid <br>
 * port2 is invalid <br>
 * Expectation: Error expected for port2. Drop stats should be available for
 * egress direction only.
 *
 * @throws Exception the exception
 */
@Test
public void getStatsTwoPortEgressOnly() throws Exception {
    List<String> lstInterfaces = Arrays.asList(PORT_1, PORT_2);
    Direction direction = Direction.Egress;
    GetAclPortStatisticsInput input = new GetAclPortStatisticsInputBuilder().setDirection(direction).setInterfaceNames(lstInterfaces).build();
    Future<RpcResult<GetAclPortStatisticsOutput>> rpcResultFuture = aclStatsService.getAclPortStatistics(input);
    RpcResult<GetAclPortStatisticsOutput> output = rpcResultFuture.get();
    LOG.info("getStatsTwoPortEgressOnly output = {}", output);
    assertStatsOutput(output, direction);
}
Also used : GetAclPortStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetAclPortStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsInput) Direction(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.Direction) GetAclPortStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsInputBuilder) Test(org.junit.Test)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)9 BigInteger (java.math.BigInteger)5 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)5 GetAclPortStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsOutput)5 Direction (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.Direction)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 Test (org.junit.Test)3 GetAclPortStatisticsInput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsInput)3 GetAclPortStatisticsInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsInputBuilder)3 SecurityRuleAttr (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.SecurityRuleAttr)3 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Set (java.util.Set)2 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)2 AclInterface (org.opendaylight.netvirt.aclservice.api.utils.AclInterface)2 Acl (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl)2 AccessListEntries (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.AccessListEntries)2 Ace (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.Ace)2