
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
3
^'                 @   sh   d dl mZ ddlmZ ddlmZ ddlmZmZ edddd	gZ	G d
d deZ
G dd deZdS )    )
namedtuple   )ContextWrapper)DiffResultDescriptor)
DifferenceWrapperZmodified_ibpkeyconZruleZadded_contextZremoved_contextc               @   s8   e Zd ZdZedZedZedZdd Zdd Z	dS )IbpkeyconsDifferencez<Determine the difference in ibpkeycons between two policies.diff_ibpkeyconsc             C   s   | j jdj|  | jdd | jj D dd | jj D \| _| _}g | _	x<|D ]4\}}t
|jt
|jkrT| j	jt||j|j qTW dS )z;Generate the difference in ibpkeycons between the policies.zIGenerating ibpkeycon differences from {0.left_policy} to {0.right_policy}c             s   s   | ]}t |V  qd S )N)IbpkeyconWrapper).0n r   !/usr/lib64/python3.6/ibpkeycon.py	<genexpr>0   s    z7IbpkeyconsDifference.diff_ibpkeycons.<locals>.<genexpr>c             s   s   | ]}t |V  qd S )N)r
   )r   r   r   r   r   r   1   s    N)loginfoformatZ	_set_diffZleft_policyZ
ibpkeyconsZright_policyadded_ibpkeyconsremoved_ibpkeyconsmodified_ibpkeyconsr   contextappendmodified_ibpkeycon_record)selfZmatched_ibpkeyconsZleft_ibpkeyZright_ibpkeyr   r   r   r	   '   s     z$IbpkeyconsDifference.diff_ibpkeyconsc             C   s"   | j jd d| _d| _d| _dS )z%Reset diff results on policy changes.zResetting ibpkeycon differencesN)r   debugr   r   r   )r   r   r   r   _reset_diffA   s    z IbpkeyconsDifference._reset_diffN)
__name__
__module____qualname____doc__r   r   r   r   r	   r   r   r   r   r   r      s   r   c               @   s4   e Zd ZdZdZdd Zdd Zd	d
 Zdd ZdS )r
   z,Wrap ibpkeycon statements for diff purposes.subnet_prefixlowhighc             C   s*   || _ |j| _|j\| _| _t|| _d S )N)originr    Zpkeysr!   r"   hashkey)r   Zoconr   r   r   __init__O   s    zIbpkeyconWrapper.__init__c             C   s   | j S )N)r%   )r   r   r   r   __hash__U   s    zIbpkeyconWrapper.__hash__c             C   s   | j |j k S )N)r#   )r   otherr   r   r   __lt__X   s    zIbpkeyconWrapper.__lt__c             C   s$   | j |j ko"| j|jko"| j|jkS )N)r    r!   r"   )r   r(   r   r   r   __eq__[   s    zIbpkeyconWrapper.__eq__N)r    r!   r"   )	r   r   r   r   	__slots__r&   r'   r)   r*   r   r   r   r   r
   I   s   r
   N)collectionsr   r   r   Zdescriptorsr   
differencer   r   r   r   r
   r   r   r   r   <module>   s   *