%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddlmZddlm
Z
eje�Zd�Zed�Zdded�Zedd	�Zd
�Zed�Zd�Zdd
�ZdS(u!
Interface to SMBIOS/DMI

(Parsing through dmidecode)

External References
-------------------
| `Desktop Management Interface (DMI) <http://www.dmtf.org/standards/dmi>`_
| `System Management BIOS <http://www.dmtf.org/standards/smbios>`_
| `DMIdecode <http://www.nongnu.org/dmidecode/>`_

i(tabsolute_importtunicode_literalstprint_functionN(trange(tzipcC@s%ttjjjddg��dfS(u0
    Only work when dmidecode is installed.
    u	dmidecodeusmbiosuUThe smbios execution module failed to load: neither dmidecode nor smbios in the path.(tbooltsalttutilstpatht	which_bin(((s7/usr/lib/python2.7/site-packages/salt/modules/smbios.pyt__virtual__!scC@s�tdj|��j�}djg|jd�D]}|jd�s1|^q1�}|jd�sz|r�t||�r�d}n|S(u]
    Get an individual DMI string from SMBIOS info

    string
        The string to fetch. DMIdecode supports:
          - ``bios-vendor``
          - ``bios-version``
          - ``bios-release-date``
          - ``system-manufacturer``
          - ``system-product-name``
          - ``system-version``
          - ``system-serial-number``
          - ``system-uuid``
          - ``baseboard-manufacturer``
          - ``baseboard-product-name``
          - ``baseboard-version``
          - ``baseboard-serial-number``
          - ``baseboard-asset-tag``
          - ``chassis-manufacturer``
          - ``chassis-type``
          - ``chassis-version``
          - ``chassis-serial-number``
          - ``chassis-asset-tag``
          - ``processor-family``
          - ``processor-manufacturer``
          - ``processor-version``
          - ``processor-frequency``

    clean
      | Don't return well-known false information
      | (invalid UUID's, serial 000000000's, etcetera)
      | Defaults to ``True``

    CLI Example:

    .. code-block:: bash

        salt '*' smbios.get system-uuid clean=False
    u-s {0}u
u#u/dev/memN(t_dmidecodertformattstriptjointsplitt
startswitht_dmi_iscleantNone(tstringtcleantvaltv((s7/usr/lib/python2.7/site-packages/salt/modules/smbios.pytget)s
):%	cC@sI|dkr$tt�||�}n!ttdj|��||�}|S(u
    Return DMI records from SMBIOS

    type
        Return only records of type(s)
        The SMBIOS specification defines the following DMI types:

        ====  ======================================
        Type  Information
        ====  ======================================
         0    BIOS
         1    System
         2    Baseboard
         3    Chassis
         4    Processor
         5    Memory Controller
         6    Memory Module
         7    Cache
         8    Port Connector
         9    System Slots
        10    On Board Devices
        11    OEM Strings
        12    System Configuration Options
        13    BIOS Language
        14    Group Associations
        15    System Event Log
        16    Physical Memory Array
        17    Memory Device
        18    32-bit Memory Error
        19    Memory Array Mapped Address
        20    Memory Device Mapped Address
        21    Built-in Pointing Device
        22    Portable Battery
        23    System Reset
        24    Hardware Security
        25    System Power Controls
        26    Voltage Probe
        27    Cooling Device
        28    Temperature Probe
        29    Electrical Current Probe
        30    Out-of-band Remote Access
        31    Boot Integrity Services
        32    System Boot
        33    64-bit Memory Error
        34    Management Device
        35    Management Device Component
        36    Management Device Threshold Data
        37    Memory Channel
        38    IPMI Device
        39    Power Supply
        40    Additional Information
        41    Onboard Devices Extended Information
        42    Management Controller Host Interface
        ====  ======================================

    clean
      | Don't return well-known false information
      | (invalid UUID's, serial 000000000's, etcetera)
      | Defaults to ``True``

    CLI Example:

    .. code-block:: bash

        salt '*' smbios.records clean=False
        salt '*' smbios.records 14
        salt '*' smbios.records 4 core_count,thread_count,current_speed

    u-t {0}N(Rt
_dmi_parseRR(trec_typetfieldsRtsmbios((s7/usr/lib/python2.7/site-packages/salt/modules/smbios.pytrecords\sF!cC@s`g}tjdtjtj�}ttj||�d�}xt||�D]
\}}g|jd�D]}|j�d^qjdd!\}}|jd�}tjd|�i|d	6|j	d�j
�d
6t|�d6}	t|�s
|sN|j
|	�qNqNnt|||�}
t|
�rB|
|	d<|j
|	�qN|sN|j
|	�qNqNW|S(
ug
    Structurize DMI records into a nice list
    Optionally trash bogus entries and filter output
    u(handle [0-9]x[0-9a-f]+[^
]+)
iu,i����iiu
uParsing handle %suhandleudescriptionutypeudata(tretcompilet	MULTILINEt
IGNORECASEtiterRRtlogtdebugtpopR
tinttlentappendt	_dmi_data(tdataRRtdmit	dmi_splittdmi_rawthandlethlinethtypetrecordtdmi_data((s7/usr/lib/python2.7/site-packages/salt/modules/smbios.pyR�s,9
c
C@s�i}d	}d	gg}xr|D]j}tjd|�r*|d	k	r�|\}}t|�r�|d	k	rz|jd|�n|||<q�|d	k	r�|||<q�n|jdd�\}}	|j�j�jdd�}|r�|dks�|r	||kr	d	}qq�t	||	j�|�gg}q|d	kr<qqtjd|�rt	||j�|�}	|	d	k	r�|dj
|	�q�qqW|S(
uP
    Parse the raw DMIdecode output of a single handle
    into a nice dict
    u\t[^\s]+iu:iu u_uheader_and_datau
\t\t[^\s]+N(RRtmatchR&tinsertRR
tlowertreplacet	_dmi_castR'(
R,RRR1tkeytkey_datatlinetvaluetvlistR((s7/usr/lib/python2.7/site-packages/salt/modules/smbios.pyR(�s6

!cC@s�|rt||�rdStjd|dtj�s�d|krlg|jd�D]}|j�^qQ}q�yt|�}Wq�tk
r�q�Xn|S(uX
    Simple caster thingy for trying to fish out at least ints & lists from strings
    Nuserial|part|asset|producttflagsu,(RRR2R RR
R%t	Exception(R7RRtel((s7/usr/lib/python2.7/site-packages/salt/modules/smbios.pyR6s+
c	C@sk|dks4t|�s4tjd|dtj�r8tSd|kr�xItdd�D]8}ytj|d|�t	SWqTt
k
r�qTqTXqTWtjd||j
dd	��tStjd
|�rtjd|�otjd|�otjd
|dtj�Stjd|�r1tjd|dtj�Stjd|dtj�oftjd|dtj�SdS(u+
    Clean out well-known bogus values
    unoneR<uuuidiitversionu"DMI %s value %s is an invalid UUIDu
u userial|part|versionu^[0]+$u[0]?1234567[8]?[9]?[0]?u2sernum|part[_-]?number|specified|filled|applicableuasset|manufactureru3manufacturer|to be filled|available|asset|^no(ne|t)uto be filleduRun(known|specified)|no(t|ne)? (asset|provided|defined|available|present|specified)N(RR&RR2R tFalseRtuuidtUUIDtTruet
ValueErrorR"ttraceR5tsearch(R7Rtuuidver((s7/usr/lib/python2.7/site-packages/salt/modules/smbios.pyRs(4
	cC@s^tjjjddg�}|s9tjjj|�}n!tjjjdj||��}|S(u
    Call DMIdecode
    u	dmidecodeusmbiosu{0} {1}(RRRR	tmodulestcmdmodt
_run_quietR(targst
dmidecodertout((s7/usr/lib/python2.7/site-packages/salt/modules/smbios.pyR<s
!(t__doc__t
__future__RRRtloggingRARtsalt.utils.pathRtsalt.modules.cmdmodtsalt.ext.six.movesRRt	getLoggert__name__R"R
RCRRRRR(R6RR(((s7/usr/lib/python2.7/site-packages/salt/modules/smbios.pyt<module>
s"	3N(	4	$

Zerion Mini Shell 1.0