509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
í«„^â  ã               @   sV   d dl Z d dlZddlmZ ddlmZ ddlmZ ddlm	Z	 G dd„ deeƒZ
dS )	é    Né   )ÚMatchContext)ÚIbpkeyconRange)ÚPolicyQuery)Úmatch_rangec                   st   e Zd ZdZdZdZdZdZdZdZ	‡ fdd„Z
edd„ ƒZejdd„ ƒZed	d
„ ƒZejdd
„ ƒZdd„ Z‡  ZS )ÚIbpkeyconQuerya   
    Infiniband pkey context query.

    Parameter:
    policy          The policy to query.

    Keyword Parameters/Class attributes:
    subnet_prefix   A subnet prefix to match.
    pkeys           A 2-tuple of the pkey range to match. (Set both to
                    the same value for a single pkey)
    pkeys_subset    If true, the criteria will match if it is a subset
                    of the ibpkeycon's range.
    pkeys_overlap   If true, the criteria will match if it overlaps
                    any of the ibpkeycon's range.
    pkeys_superset  If true, the criteria will match if it is a superset
                    of the ibpkeycon's range.
    pkeys_proper    If true, use proper superset/subset operations.
                    No effect if not using set operations.
    user            The criteria to match the context's user.
    user_regex      If true, regular expression matching
                    will be used on the user.
    role            The criteria to match the context's role.
    role_regex      If true, regular expression matching
                    will be used on the role.
    type_           The criteria to match the context's type.
    type_regex      If true, regular expression matching
                    will be used on the type.
    range_          The criteria to match the context's range.
    range_subset    If true, the criteria will match if it is a subset
                    of the context's range.
    range_overlap   If true, the criteria will match if it overlaps
                    any of the context's range.
    range_superset  If true, the criteria will match if it is a superset
                    of the context's range.
    range_proper    If true, use proper superset/subset operations.
                    No effect if not using set operations.
    NFc                s$   t t| ƒj|f|Ž tjtƒ| _d S )N)Úsuperr   Ú__init__ÚloggingZ	getLoggerÚ__name__Úlog)ÚselfÚpolicyÚkwargs)Ú	__class__© ú&/usr/lib64/python3.6/ibpkeyconquery.pyr	   K   s    zIbpkeyconQuery.__init__c             C   s   | j S )N)Ú_pkeys)r   r   r   r   ÚpkeysO   s    zIbpkeyconQuery.pkeysc             C   s€   |d k	rvt |Ž }|jdk s$|jdk r2tdj|ƒƒ‚|jdksF|jdkrTtdj|ƒƒ‚|j|jkrntdj|ƒƒ‚|| _nd | _d S )Nr   z.Pkeys must be positive: {0.low:#x}-{0.high:#x}iÿÿ  z/Pkeys maximum is 0xffff: {0.low:#x}-{0.high:#x}zGThe low pkey must be smaller than the high pkey: {0.low:#x}-{0.high:#x})r   ZlowZhighÚ
ValueErrorÚformatr   )r   ÚvalueZpending_pkeysr   r   r   r   S   s    c             C   s   | j S )N)Ú_subnet_prefix)r   r   r   r   Úsubnet_prefixi   s    zIbpkeyconQuery.subnet_prefixc             C   s   |rt j|ƒ| _nd | _d S )N)Ú	ipaddressZIPv6Addressr   )r   r   r   r   r   r   m   s    c             c   s®   | j jdj| ƒƒ | j jdj| ƒƒ | j jdj| ƒƒ | j| j ƒ xf| jjƒ D ]X}| jdk	rj| j|jkrjqN| jr’t	|j| j| j
| j| j| jƒ r’qN| j|jƒs qN|V  qNW dS )z/Generator which yields all matching ibpkeycons.z,Generating ibpkeycon results from {0.policy}z Subnet Prefix: {0.subnet_prefix}z~Pkeys: {0.pkeys}, overlap: {0.pkeys_overlap}, subset: {0.pkeys_subset}, superset: {0.pkeys_superset}, proper: {0.pkeys_proper}N)r   Úinfor   ÚdebugZ_match_context_debugr   Z
ibpkeyconsr   r   r   Úpkeys_subsetÚpkeys_overlapÚpkeys_supersetÚpkeys_properZ_match_contextÚcontext)r   Zpkr   r   r   Úresultst   s&    

zIbpkeyconQuery.results)r   Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r    r	   Úpropertyr   Úsetterr   r"   Ú__classcell__r   r   )r   r   r      s   &r   )r   r
   Zmixinsr   Z	policyrepr   Zqueryr   Úutilr   r   r   r   r   r   Ú<module>   s   