%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/inspectlib/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyc

�
���^c@@s�ddlmZddlZddlZddlZddlZddlZddlZddl	m
Z
mZddlm
Z
ddlmZmZmZeje�Zdefd��YZde
fd	��YZdS(
i(tabsolute_importN(tInspectorQueryExceptiontSIException(t	EnvLoader(tPackagetPackageCfgFiletPayloadFiletSysInfocB@s_eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZRS(
s
    System information.
    cC@s.|j�dkr*tdj|���ndS(Ntsolariss!Platform {0} not (yet) supported.(tlowerRtformat(tselftsystype((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt__init__'scC@stj|d�S(s-
        An alias for grains getter.
        sN/A(t
__grains__tget(Rtgrain((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt_grain+scC@s�tddj|��}|drRdj|d�}tj|�t|��ng|djtj�djd�D]}|rv|^qv\}}}}}	}
i|d	6|d
6|d6|d6|	d
6|
d6S(s'
        Get a size of a disk.
        scmd.run_allsdf {0}tretcodesDisk size info error: {0}tstderrtstdouti����t tdevicetblockstusedt	availablesused (%)tmounted(t__salt__R
tlogterrorRtsplittostlinesep(RRtouttmsgtelmtdevpathRRRtused_pt
mountpoint((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt_get_disk_size1s

KcC@slt�}x\tjjj�j�D]B\}}|j|�}|jd�}|d|d<|||<q"W|S(s=
        Get available file systems and their types.
        Rttype(tdicttsalttutilstfsutilst_blkidtitemsR'tpop(Rtdatatdevtdev_dataR((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt_get_fsBs	%cC@stjjj�S(s/
        Get mounted FS on the system.
        (R*R+R,t_get_mounts(R((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyR4PscC@s�tdd�}tjjj|�t�}xYg|djtj�D]}|jdd�^qFD]"\}}|j	�||j	�<qbW|S(s0
        Get available CPU information.
        scmd.run_alltlscpuRt:i(
RR*R+R,t_verify_runR)RRR tstrip(RR!R0R#tdescrtvalue((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt_get_cpuVs	BcC@s�tdd�}|dr6tdj|d���nt�}x~|djtj�D]f}|j�}|stqVn|jdd�\}}|jd	�r�|d
}|d}n|||<qVW|S(s
        Get memory.
        scmd.run_alls	vmstat -sRsMemory info error: {0}RRRisK itK(	RRR
R)RRR R8t
startswith(RR!trettlinetsizeR9((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt_get_memcs
	

cC@s9t�}tjjj�|d<tjjj�|d<|S(s,
        Get network configuration.
        t
interfacestsubnets(R)R*R+tnetworkRBRC(RR0((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt_get_networkws	cC@sDi|jd�d6|jd�d6|jd�d6|jd�d6S(	s.
        Get operating system summary
        Rtnamet	os_familytfamilytosarchtarcht	osreleasetrelease(R(R((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt_get_os�s
(t__name__t
__module__t__doc__R
RR'R3R4R;RARERM(((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyR"s						
		
tQuerycB@s�eZdZddddddddgZdd	�Zd
�Zd�Zd�Zdd
�Z	d�Z
d�Zd�Zd�Z
d�Zd�Zeed�Zd�Zd�ZRS(s�
    Query the system.
    This class is actually puts all Salt features together,
    so there would be no need to pick it from various places.
    tchangest
configurationtidentitytsystemtsoftwaretservicestpayloadtallcC@s�|rB||jkrBtdjt|�dj|j����n*|sltdjdj|j����ntj|d|�d||_t�|_	dS(sF
        Constructor.

        :param scope:
        :return:
        s'Unknown scope: {0}. Must be one of: {1}s, s*Scope cannot be empty. Must be one of: {0}tcachedirt_N(
tSCOPESRR
treprtjoinRR
tscopeR)tlocal_identity(RR_RZ((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyR
�s*!
cO@st||j�||�S(sv
        Call the query with the defined scope.

        :param args:
        :param kwargs:
        :return:
        (tgetattrR_(Rtargstkwargs((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt__call__�s	cO@std��dS(s?
        Returns all diffs to the configuration files.
        sNot yet implementedN(t	Exception(RRbRc((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt_changes�scO@s�t�}|jj�xm|jjt�D]Y}t�}x:|jjtdi|jd6�D]}|j|j	�q[W|||j
<q)W|s�td��n|S(s-
        Return configuration files.
        teqtpkgids)No inspected configuration yet available.(R)tdbtopenRRtlistRtidtappendtpathRFR(RRbRcR0tpkgtconfigstpkg_cfg((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt_configuration�s	
	)c
C@st�}d}tjjj|d���}x�|D]�}|j�}d|krUq1n|jd�\}}}}	}
}}|dkp�|jd�}
|tkr�|
s�|t	kr�|
s�|dkr1i|d6|	d6|
d6|d	6|d
6|
d6||<q1q1WWdQX|S(
s@
        Return all known local accounts to the system.
        s/etc/passwdtrR6t*t!tuidtgittinfothometshelltdisabledN(R)R*R+tfilestfopenR8RR=tFalsetTruetNone(RR{tusersRntfp_R?RFtpasswordRvtgidtgecost	directoryRztactive((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt_get_local_users�s$	
$1c		C@s�t�}d}tjjj|d���}xx|D]p}|j�}d|krUq1n|jd�\}}}}i|d6||<|r1|jd�||d<q1q1WWdQX|S(s>
        Return all known local groups to the system.
        s
/etc/groupRsR6R�t,R�N(R)R*R+R|R}R8R(	RtgroupsRnR�R?RFR�R�R�((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt_get_local_groups�s	
$c	C@s�t�}tdd�}|dr'|Sidd6dd6dd	6dd
6}x�g|djtj�D]'}|j�rc|j�jd�^qcD]a}t|�d
kr�q�n|d
 \}}||kr�i|d6|j|d�d6||<q�q�W|S(sF
        Return all known accounts, excluding local accounts.
        scmd.run_allspasswd -S -aRtLockedtLsNo passwordtNPsUsable passwordtPtLKRRitloginsN/Atstatus(R)RRRR R8tlenR(	RtlocalsR�R!R�R#R0RFR�((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt_get_external_accountss	
"K!cO@skd}d}t�}|jd|jd��||<|j||j��pPd||<|j�|d<|S(s^
        Local users and groups.

        accounts
            Can be either 'local', 'remote' or 'all' (equal to "local,remote").
            Remote accounts cannot be resolved on all systems, but only
            those, which supports 'passwd -S -a'.

        disabled
            True (or False, default) to return only disabled accounts.
        slocal accountssexternal accountsR{sN/Aslocal groups(R)R�RR�tkeysR�(RRbRctLOCALtEXTR0((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt	_identitys	#cO@s�ttjd��}t�}|j�|d<|j�|d<|j�|d<|j�|d<|j�|d<|j	�|d<|S(s�
        This basically calls grains items and picks out only
        necessary information in a certain structure.

        :param args:
        :param kwargs:
        :return:
        tkerneltcputdiskstmountstmemoryRDR(
RRRR)R;R3R4RARERM(RRbRctsysinfoR0((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt_system/s		cO@s�t�}d|kr+|djd�}n	t�}tjd�j�}|dkr�d}d|kr�td�}|r�||d<q�q�n|dkr�d	}nd}|r�d
|kr�t|�}|r�||d
<q�n|dkr�d}	n|dkrd}	nd}	|	rBd
|krBt|	�}
|
rB|
|d
<qBnd|krbtd�|d<nd|kr�td�}|r�||d<q�n|S(s,
        Return installed software.
        texcludeR�RGtsusespkg.list_lockstproductsspkg.list_productstredhatspkg.get_locked_packagestlocksspkg.list_installed_patternsspkg.group_listtpatternstpackagess
pkg.list_pkgstrepositoriesspkg.list_reposN(R)RRkRRR	RR�(RRbRcR0texcludesRGtLOCKSR�R�tPATTERNSR�trepos((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt	_softwareDsD		
	
		

cO@s itd�d6td�d6S(sU
        Get list of enabled and disabled services on the particular system.
        sservice.get_enabledtenabledsservice.get_disabledR{(R(RRbRc((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt	_serviceszsc
C@s�|js2|j�|jd<|j�|jd<n|s<|Sxz|j|rQdpTdj�D]Y\}}|r�t|jdd��|ks�|r\t|jdd��|kr\|Sq\W|S(s�
        Resolve local users and groups.

        :param iid:
        :param named:
        :param uid:
        :return:
        R�R�Rvi����R�(R`R�R�R.tintR(RtiidtnamedRvRFtmeta((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt
_id_resolv�s
	,Ic
@s�d�}|jd�}|jdd�}|jdd���d,kr`tdj����n�fd	�}|jd
�}|d-k	r�|j�d.kr�tdj����n|jdd�}|d/kr�tdj|���ng|jdd�j�jd�D]}	|	r|	^q}
|
s:|
jd�nx;|
D]3}|d0krAtdjdj|
����qAqAW|jj	�d |kr�it
|jjt��d 6S|jd!�}|r�t�nt
�}
x�|jjt�|||jd"d#�!D]�}|r|
j|j�q�i|j|jd$|dk�d%6|j|jd$|dkd%t�d&6||jd'|�d
6t|j�d(6||j�d)6||j�d*6||j�d+6|
|j<q�W|
S(1sp
        Find all unmanaged files. Returns maximum 1000 values.

        Parameters:

        * **filter**: Include only results which path starts from the filter string.
        * **time**: Display time in Unix ticks or format according to the configured TZ (default)
                    Values: ticks, tz (default)
        * **size**: Format size. Values: B, KB, MB, GB
        * **owners**: Resolve UID/GID to an actual names or leave them numeric (default).
                      Values: name (default), id
        * **type**: Comma-separated type of included payload: dir (or directory), link and/or file.
        * **brief**: Return just a list of matches, if True. Default: False
        * **offset**: Offset of the files
        * **max**: Maximum returned values. Default 1000.

        Options:

        * **total**: Return a total amount of found payload files
        cS@s�|dkr|S|j�}|dkr5dj|�S|dkradjtt|�dd��S|dkr�djtt|�ddd��S|d	kr�d
jtt|�dddd��SdS(Ntbs	{0} Bytestkbs{0} Kbiitmbs{0} Mbtgbs{0} Gb(R�R	R
troundtfloat(R@tfmt((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt_size_format�s
 $tfiltertoffsetittimettzttickss(Unknown "{0}" value for parameter "time"c@s1�dkr'tjdtj|��p0t|�S(NR�s%b %d %Y %H:%M:%S(R�tstrftimetgmtimeR�(tparam(t
timeformat(sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt<lambda>�sR@R�R�R�R�sJUnknown "{0}" value for parameter "size". Should be either B, Kb, Mb or GbtownersRlRFsQUnknown "{0}" value for parameter "owners". Should be either name or id (default)R(tR�tfileR�tdirtdtftlinktlsjUnknown "{0}" values for parameter "type". Should be comma separated one or more of dir, file and/or link.s, ttotaltbrieftmaxi�R�RvR�R�tmodetaccessedtmodifiedtcreated(R�stzN(R�skbsmbsgb(snamesid(s	directorysdirR�sfileR�slinkR�(RRR
R�R	RRmR^RiRjR�RRkR)RnR�RvR�R~tp_sizetoctR�tatimetmtimetctime(RRbRcR�R�R�ttfmttsize_fmtR�tprmt	incl_typeti_typeR�t	pld_filestpld_data((R�sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt_payload�sN			:
	
0%cO@s�t�}|j|�|d<|j|�|d<|j|�|d<y|j|�|d<Wn*tk
r�}d|d<tj|�nX|j|�p�d|d<|S(sB
        Return all the summary of the particular system.
        RVRURWRSsN/ARX(	R)R�R�R�RrRRRR�(RRbRcR0tex((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt_all�s	
N(RNRORPR\R�R
RdRfRrR�R�R�R�R�R�R�RR�R�R�(((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyRQ�s 								6			U(t
__future__RRR�tloggingtsalt.utils.filesR*tsalt.utils.fsutilstsalt.utils.networkt"salt.modules.inspectlib.exceptionsRRtsalt.modules.inspectlibRt salt.modules.inspectlib.entitiesRRRt	getLoggerRNRtobjectRRQ(((sA/usr/lib/python2.7/site-packages/salt/modules/inspectlib/query.pyt<module>sk

Zerion Mini Shell 1.0