Current Path : /usr/lib/python2.7/dist-packages/landscape/user/ |
Current File : //usr/lib/python2.7/dist-packages/landscape/user/changes.pyc |
Tc @ s* d d l m Z d e f d YZ d S( i( t difft UserChangesc B sV e Z d Z d Z d Z d Z d Z d Z d Z d Z d Z RS( s Detect changes made since the last snapshot was taken. If no snapshot is available all users and groups are reported. When a snapshot is available, only the changes between the current state and the snapshotted state are transmitted to the server. c C s3 t t | j | | _ | | _ | j d S( N( t superR t __init__t _persistt _providert _refresh( t selft persistt provider( ( s: /usr/lib/python2.7/dist-packages/landscape/user/changes.pyR s c C sp | j j d i | _ | j j d i | _ | j d | j j | _ | j d | j j | _ d S( s3 Load the previous snapshot and update current data.t userst groupst usernamet nameN( R t gett _old_userst _old_groupst _create_indexR t get_userst _new_userst get_groupst _new_groups( R ( ( s: /usr/lib/python2.7/dist-packages/landscape/user/changes.pyR s c C s0 | j j d | j | j j d | j d S( s; Save the current state and use it as a comparison snapshot.R R N( R t setR R ( R ( ( s: /usr/lib/python2.7/dist-packages/landscape/user/changes.pyt snapshot s c C s$ | j j d | j j d d S( s` Reset the snapshot state and forget all knowledge of users and groups. R R N( R t remove( R ( ( s: /usr/lib/python2.7/dist-packages/landscape/user/changes.pyt clear% s c C s) i } x | D] } | | | | <q W| S( ss Given a key and a sequence of dicts, return a dict of the form C{{dict[key]: dict, ...}}. ( ( R t keyt sequencet indext data( ( s: /usr/lib/python2.7/dist-packages/landscape/user/changes.pyR - s c C s: | j i } | j | j | j | j | S( s Returns the changes since the last snapshot. See landscape.message_schemas.USERS schema for a description of the dictionary returned by this method. ( R t updatet _detect_user_changest _detect_group_changes( R t changes( ( s: /usr/lib/python2.7/dist-packages/landscape/user/changes.pyt create_diff7 s c C s i } t | j | j \ } } } | rC t | j | d <n | rb t | j | d <n | r t | j | d <n | S( s Compare the current user snapshot to the old one and return a C{dict} with C{create-users}, C{update-users} and C{delete-users} fields. Fields without data aren't included in the result. s create-userss update-userss delete-users( R R R t listt itervaluest iterkeys( R R! t createst updatest deletes( ( s: /usr/lib/python2.7/dist-packages/landscape/user/changes.pyR C s c C s" i } t | j | j \ } } } | r g } i } xS | j D]E } | j } | j d } | r{ | | | d <n | j | qC W| | d <| r | | d <q n | ri } i } g } x | j D] \ } } | j | } t | d } t | d } | | } | r-t | | | <n | | } | rPt | | | <n | d | d k r | j i | d 6| d d 6 q q W| r| j d i } | j | n | r| j d i } | j | n | r| j d g } | j | qn | r| j | d <n | S( s Compare the current group snapshot to the old one and create a C{dict} with C{create-groups}, C{delete-groups}, C{create-group-members} and {delete-group-members} fields. Fields without data aren't included in the result. t membersR s create-groupss create-group-memberst gids delete-group-memberss update-groupss delete-groups( R R R R$ t copyt popt appendt iteritemsR t sortedt setdefaultR t extendt keys( R R! R&