Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/landscape/user/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/landscape/user/changes.pyc


Tc@s*ddlmZdefdYZdS(i(tdifftUserChangescBsVeZdZdZdZdZdZdZdZdZ	dZ
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.
    cCs3tt|j||_||_|jdS(N(tsuperRt__init__t_persistt	_providert_refresh(tselftpersisttprovider((s:/usr/lib/python2.7/dist-packages/landscape/user/changes.pyRs		cCsp|jjdi|_|jjdi|_|jd|jj|_|jd|jj|_	dS(s3Load the previous snapshot and update current data.tuserstgroupstusernametnameN(
Rtgett
_old_userst_old_groupst
_create_indexRt	get_userst
_new_userst
get_groupst_new_groups(R((s:/usr/lib/python2.7/dist-packages/landscape/user/changes.pyRscCs0|jjd|j|jjd|jdS(s;Save the current state and use it as a comparison snapshot.R
RN(RtsetRR(R((s:/usr/lib/python2.7/dist-packages/landscape/user/changes.pytsnapshot scCs$|jjd|jjddS(s`
        Reset the snapshot state and forget all knowledge of users and
        groups.
        R
RN(Rtremove(R((s:/usr/lib/python2.7/dist-packages/landscape/user/changes.pytclear%scCs)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, ...}}.
        ((Rtkeytsequencetindextdata((s:/usr/lib/python2.7/dist-packages/landscape/user/changes.pyR-s
cCs:|ji}|j|j|j|j|S(sReturns the changes since the last snapshot.
        
        See landscape.message_schemas.USERS schema for a description of the
        dictionary returned by this method.
        (Rtupdatet_detect_user_changest_detect_group_changes(Rtchanges((s:/usr/lib/python2.7/dist-packages/landscape/user/changes.pytcreate_diff7s

cCsi}t|j|j\}}}|rCt|j|d<n|rbt|j|d<n|rt|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(RRRtlistt
itervaluestiterkeys(RR!tcreatestupdatestdeletes((s:/usr/lib/python2.7/dist-packages/landscape/user/changes.pyRCscCs"i}t|j|j\}}}|rg}i}xS|jD]E}|j}|jd}|r{|||d<n|j|qCW||d<|r||d<qn|ri}	i}g}
x|jD]\}}|j|}
t|
d}t|d}||}|r-t	|||<n||}|rPt	||	|<n|
d|dkr|
ji|d6|dd6qqW|r|j
di}|j|n|	r|j
di}|j|	n|
r|j
dg}|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.
        tmembersR
s
create-groupsscreate-group-memberstgidsdelete-group-memberss
update-groupss
delete-groups(RRRR$tcopytpoptappendt	iteritemsRtsortedt
setdefaultRtextendtkeys(RR!R&R'R(Rtcreate_memberstvalueR)tremove_memberst
update_groupst	groupnametnew_datatold_datatold_memberstnew_memberstcreatedtremoved((s:/usr/lib/python2.7/dist-packages/landscape/user/changes.pyR TsV



(t__name__t
__module__t__doc__RRRRRR"RR (((s:/usr/lib/python2.7/dist-packages/landscape/user/changes.pyRs						
		N(tlandscape.diffRtobjectR(((s:/usr/lib/python2.7/dist-packages/landscape/user/changes.pyt<module>s