%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/dracr.pyc

�
���^c	@@sydZddlmZmZmZddlZddlZddlZddlm	Z	ddl
Zddlm
Z
ddlmZddlmZeje�ZdgZyed	ZWn9eefk
r�ddlZiejjjd	6ZnXd
�Zd�Zddddd�Zddddd
�Z dddd�Z!dddd�Z"ddddd�Z#ddde$ddddd�Z%dddddd�Z&ddddd�Z'ddddd�Z(e)ddddd�Z*dddd�Z+ddddd�Z,ddddd�Z-dddddd�Z.ddddd�Z/ddddd�Z0ddddd�Z1ddddd�Z2dddd�Z3dddd�Z4ddddd �Z5ddddd!�Z6ddddd"�Z7ddddd#�Z8ddddd$�Z9ddddd%�Z:dddd&�Z;dddd'�Z<dddd(�Z=dddd)�Z>dddd*�Z?dddd+�Z@dddd,�ZAdddd-�ZBdddd.�ZCdddd/�ZDdddd0�ZEdddd1�ZFdddd2�ZGddddd3�ZHdddd4�ZIdddd5�ZJdddd6�ZKdddd7�ZLdS(8u/
Manage Dell DRAC.

.. versionadded:: 2015.8.2
i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionError(tsix(trange(tmapufx2ucmd.run_allcC@s#tjjjd�rtStdfS(NuracadmuFThe drac execution module cannot be loaded: racadm binary not in path.(tsalttutilstpathtwhichtTruetFalse(((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pyt__virtual__$scC@s�i}d}x�|j�D]�}|j�jd�rZd|krZ|dd!}i||<nt|j��dkrd|kr||kr�||jtg|jd�D]}|j�^q�g��q�|j�}||kr�|r�i||<q�qqW|S(u 
    Parse Dell DRAC output
    uu:u=ii����(t
splitlineststriptendswithtlentrstriptupdatetdicttsplit(toutputtdractsectiontitprop((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pyt__parse_drac+s!

$
2cC@s�|rT|jd�rBd||jd�dt|�!j�}qZdj|�}nd}|stddj||��}n+tdd	j|||||�d
d�}|dd
kr�tjd|d�tSt	S(u
    Execute rac commands
    uALL_u-a u_iu-m {0}uucmd.run_alluracadm {0} {1}u#racadm -r {0} -u {1} -p {2} {3} {4}toutput_logleveluquieturetcodeiu"racadm returned an exit code of %s(
t
startswithtindexRtlowertformatt__salt__tlogtwarningRR(tcommandthosttadmin_usernametadmin_passwordtmodulet	modswitchtcmd((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pyt
__execute_cmdCs(*			c	C@so|r-|dkrd}q3dj|�}nd}|sXtddj||��}n+tddj|||||�dd	�}|d
dkr�tjd|d
�n�g}x�|d
j�D]�}|jd�r�q�n|jd�r�Pn|jd�rPn|jd�rq�nt|j��dkr5q�n|j|�d|kr�q�q�q�Wdj	|�|d
<|S(u
    Execute rac commands
    uALLu-a u-m {0}uucmd.run_alluracadm {0} {1}u#racadm -r {0} -u {1} -p {2} {3} {4}Ruquieturetcodeiu"racadm returned an exit code of %sustdoutuSecurity AlertuRAC1168:uRAC1169:uContinuing executionu=u
(
R R!R"R#RRRRtappendtjoin(	R$R%R&R'R(R)R*tfmtlinestl((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pyt
__execute_rethsD				

cC@s2tdd|d|d|�}t|d�}|S(Nuget iDRAC.NIC.DNSRacNameR%R&R'ustdout(R0R(R%R&R'trettparsed((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytget_dns_dracname�s
	cC@s+tdj|�d|d|d|�}|S(Nuset iDRAC.NIC.DNSRacName {0}R%R&R'(R0R (tnameR%R&R'R1((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytset_dns_dracname�s
	c
C@sZtdd|d|d|d|�}|ddkrLtjd|d�|St|d	�S(
ut
    Return System information

    CLI Example:

    .. code-block:: bash

        salt dell dracr.system_info
    u
getsysinfoR%R&R'R(uretcodeiu"racadm returned an exit code of %sustdout(R0R"R#R(R%R&R'R(R*((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytsystem_info�s	c	
C@sYd}|r|d7}n|d|d|d|7}t|d|d|d|d|�S(	Nu
setniccfg u-d u-s u R%R&R'R((R+(	tiptnetmasktgatewaytdhcpR%R&R'R(tcmdstr((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pyt
set_niccfg�s
c
C@sAd}|r||7}nt|d|d|d|d|�}|S(Nu
setniccfg -v R%R&R'R((R+(tvlanR%R&R'R(R;R1((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytset_nicvlan�s
	cC@s	td|d|d|�}|dkrEi}d|d<d|d<|S||jd�kr�||jd	�kr�i}d|d<d
j|�|d<|Stdd|d|d|d|�}|dd
kr�tjd|d�nd|d|d|d<t|d�S(ux
    Return Network Configuration

    CLI Example:

    .. code-block:: bash

        salt dell dracr.network_info
    R%R&R'i����uretcodeu Problem getting switch inventoryustdoutuswitchuserveruNo module {0} found.u	getniccfgR(iu"racadm returned an exit code of %su	Network:
u	Device = u
NuNetwork:
Device = (t	inventorytNonetgetR R0R"R#R(R%R&R'R(tinvR*((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytnetwork_info�s*	

*
	cC@s�t|�dkr#tjd�tSx]tdt|�d�D]B}tdj|||d�d|d|d|d|�s=tSq=WtS(	u5
    Configure the nameservers on the DRAC

    CLI Example:

    .. code-block:: bash

        salt dell dracr.nameservers [NAMESERVERS]
        salt dell dracr.nameservers ns1.example.com ns2.example.com
            admin_username=root admin_password=calvin module=server-1
            host=192.168.1.1
    iu$racadm only supports two nameserversiu1config -g cfgLanNetworking -o cfgDNSServer{0} {1}R%R&R'R((RR"R#RRR+R R(tnsR%R&R'R(R((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytnameserverss
 		cC@sw|rUtdd|d|d|dd�rUtdj|�d|d|d|d|�Stdd|d|d|d|�S(	um
    Configure syslog remote logging, by default syslog will automatically be
    enabled if a server is specified. However, if you want to disable syslog
    you will need to specify a server followed by False

    CLI Example:

    .. code-block:: bash

        salt dell dracr.syslog [SYSLOG IP] [ENABLE/DISABLE]
        salt dell dracr.syslog 0.0.0.0 False
    u3config -g cfgRemoteHosts -o cfgRhostsSyslogEnable 1R%R&R'R(u6config -g cfgRemoteHosts -o cfgRhostsSyslogServer1 {0}u3config -g cfgRemoteHosts -o cfgRhostsSyslogEnable 0N(R+R@R (tservertenableR%R&R'R(((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytsyslog8s 				cC@s0|r"tdd|d|d|�Std�SdS(u�
    Enable/Disable email alerts

    CLI Example:

    .. code-block:: bash

        salt dell dracr.email_alerts True
        salt dell dracr.email_alerts False
    u5config -g cfgEmailAlert -o cfgEmailAlertEnable -i 1 1R%R&R'u5config -g cfgEmailAlert -o cfgEmailAlertEnable -i 1 0N(R+(tactionR%R&R'((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytemail_alertsZs	c	C@s#i}d}xtdd�D]�}tdj|�d|d|d|�}|dd	krptjd
|d�nx�|dj�D]�}|jd�s�q�n|jd
�\}	}
|	jd�r�|
j�}|
r�i|d6||<qPq�t	|�d	kr�||j
i|
|	6�q�q�WqW|S(um
    List all DRAC users

    CLI Example:

    .. code-block:: bash

        salt dell dracr.list_users
    uiiu getconfig -g cfgUserAdmin -i {0}R%R&R'uretcodeiu"racadm returned an exit code of %sustdoutucfgu=ucfgUserAdminUserNameuindex(RR0R R"R#RRRRRR(R%R&R'R(tuserst	_usernametidxR*tusertkeytval((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pyt
list_usersss*
			#cC@si|dkr&t�}||d}n|rQtdj|�d|d|d|�Stjd|�tSdS(u�
    Delete a user

    CLI Example:

    .. code-block:: bash

        salt dell dracr.delete_user [USERNAME] [UID - optional]
        salt dell dracr.delete_user diana 4
    uindexu8config -g cfgUserAdmin -o cfgUserAdminUserName -i {0} ""R%R&R'uUser '%s' does not existN(R@RQR+R R"R#R(tusernametuidR%R&R'RN((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytdelete_user�s			c
C@s�t|�dkr!td��n|d
kr_td|d|d|d|�}||d}n|r�tdj||�d|d|d|d|�Stjd	|�tSd
S(u�
    Change user's password

    CLI Example:

    .. code-block:: bash

        salt dell dracr.change_password [USERNAME] [PASSWORD] uid=[OPTIONAL]
            host=<remote DRAC> admin_username=<DRAC user>
            admin_password=<DRAC PW>
        salt dell dracr.change_password diana secret

    Note that if only a username is specified then this module will look up
    details for all 16 possible DRAC users.  This is time consuming, but might
    be necessary if one is not sure which user slot contains the one you want.
    Many late-model Dell chassis have 'root' as UID 1, so if you can depend
    on that then setting the password is much quicker.
    Raises an error if the supplied password is greater than 20 chars.
    iu1Supplied password should be 20 characters or lessR%R&R'R(uindexu9config -g cfgUserAdmin -o cfgUserAdminPassword -i {0} {1}u racadm: user '%s' does not existN(	RRR@RQR+R R"R#R(RRtpasswordRSR%R&R'R(RN((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytchange_password�s	
c
C@s.tdj||�d|d|d|d|�S(u�
    Change the QuickDeploy password, used for switches as well

    CLI Example:

    .. code-block:: bash

        salt dell dracr.deploy_password [USERNAME] [PASSWORD]
            host=<remote DRAC> admin_username=<DRAC user>
            admin_password=<DRAC PW>
        salt dell dracr.change_password diana secret

    Note that if only a username is specified then this module will look up
    details for all 16 possible DRAC users.  This is time consuming, but might
    be necessary if one is not sure which user slot contains the one you want.
    Many late-model Dell chassis have 'root' as UID 1, so if you can depend
    on that then setting the password is much quicker.
    udeploy -u {0} -p {1}R%R&R'R((R+R (RRRUR%R&R'R(((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytdeploy_password�s	c
C@s+tdj|�d|d|d|d|�S(uJ
    Change the QuickDeploy SNMP community string, used for switches as well

    CLI Example:

    .. code-block:: bash

        salt dell dracr.deploy_snmp SNMP_STRING
            host=<remote DRAC or CMC> admin_username=<DRAC user>
            admin_password=<DRAC PW>
        salt dell dracr.deploy_password diana secret

    udeploy -v SNMPv2 {0} roR%R&R'R((R+R (tsnmpR%R&R'R(((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytdeploy_snmps
c
C@sft�}|d
kr!t�}n||krAtjd|�tSx,tj|�D]}|j||d�qQWt	t
ttdd��|�dt�j
�}	tdj|	|�d|d|d	|�s�t||	�tSt|||	�stjd
�t||	�tSt|||	�s<tjd�t||	�tStdj|	��sbt||	�tStS(u�
    Create user accounts

    CLI Example:

    .. code-block:: bash

        salt dell dracr.create_user [USERNAME] [PASSWORD] [PRIVILEGES]
        salt dell dracr.create_user diana secret login,test_alerts,clear_logs

    DRAC Privileges
      * login                   : Login to iDRAC
      * drac                    : Configure iDRAC
      * user_management         : Configure Users
      * clear_logs              : Clear Logs
      * server_control_commands : Execute Server Control Commands
      * console_redirection     : Access Console Redirection
      * virtual_media           : Access Virtual Media
      * test_alerts             : Test Alerts
      * debug_commands          : Execute Debug Commands
    u racadm: user '%s' already existsuindexiitreverseu9config -g cfgUserAdmin -o cfgUserAdminUserName -i {0} {1}R%R&R'uunable to set user permissionsuunable to set user passwordu5config -g cfgUserAdmin -o cfgUserAdminEnable -i {0} 1N(tsetR@RQR"R#RRtiterkeystaddtsortedtlistRRtpopR+R RTtset_permissionsRV(
RRRUtpermissionsRKR%R&R't_uidsRMRS((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytcreate_users8	1		




	
cC@s�i	dd6dd6dd6dd6d	d
6dd6d
d6dd6dd6}d}|dkrqt�}||d}nxI|jd�D]8}	|	j�}
|
|kr�|t||
d�7}q�q�Wtdj||�d|d|d|�S(u�
    Configure users permissions

    CLI Example:

    .. code-block:: bash

        salt dell dracr.set_permissions [USERNAME] [PRIVILEGES]
             [USER INDEX - optional]
        salt dell dracr.set_permissions diana login,test_alerts,clear_logs 4

    DRAC Privileges
      * login                   : Login to iDRAC
      * drac                    : Configure iDRAC
      * user_management         : Configure Users
      * clear_logs              : Clear Logs
      * server_control_commands : Execute Server Control Commands
      * console_redirection     : Access Console Redirection
      * virtual_media           : Access Virtual Media
      * test_alerts             : Test Alerts
      * debug_commands          : Execute Debug Commands
    u	0x0000001uloginu	0x0000002udracu	0x0000004uuser_managementu	0x0000008u
clear_logsu	0x0000010userver_control_commandsu	0x0000020uconsole_redirectionu	0x0000040u
virtual_mediau	0x0000080utest_alertsu	0x0000100udebug_commandsiuindexu,iu@config -g cfgUserAdmin -o cfgUserAdminPrivilege -i {0} 0x{1:08X}R%R&R'N(R@RQRRtintR+R (RRRbRSR%R&R't
privilegest
permissionRNRtperm((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pyRa[s*

		cC@s%tdj|�d|d|d|�S(u
    Configure CMC or individual iDRAC SNMP community string.
    Use ``deploy_snmp`` for configuring chassis switch SNMP.

    CLI Example:

    .. code-block:: bash

        salt dell dracr.set_snmp [COMMUNITY]
        salt dell dracr.set_snmp public
    u4config -g cfgOobSnmp -o cfgOobSnmpAgentCommunity {0}R%R&R'(R+R (t	communityR%R&R'((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytset_snmp�s
		cC@s+tdj|||d|d|d|��S(ur
    Configure Network on the CMC or individual iDRAC.
    Use ``set_niccfg`` for blade and switch addresses.

    CLI Example:

    .. code-block:: bash

        salt dell dracr.set_network [DRAC IP] [NETMASK] [GATEWAY]
        salt dell dracr.set_network 192.168.0.2 255.255.255.0 192.168.0.1
            admin_username=root admin_password=calvin host=192.168.1.1
    usetniccfg -s {0} {1} {2}R%R&R'(R+R (R7R8R9R%R&R'((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytset_network�s	c
C@s+tdj|�d|d|d|d|�S(u#
    status
        One of 'powerup', 'powerdown', 'powercycle', 'hardreset',
        'graceshutdown'

    host
        The chassis host.

    admin_username
        The username used to access the chassis.

    admin_password
        The password used to access the chassis.

    module
        The element to reboot on the chassis such as a blade. If not provided,
        the chassis will be rebooted.

    CLI Example:

    .. code-block:: bash

        salt dell dracr.server_reboot
        salt dell dracr.server_reboot module=server-1

    userveraction {0}R%R&R'R((R+R (tstatusR%R&R'R(((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytserver_power�sc
C@s"tdd|d|d|d|�S(u|
    Issues a power-cycle operation on the managed server. This action is
    similar to pressing the power button on the system's front panel to
    power down and then power up the system.

    host
        The chassis host.

    admin_username
        The username used to access the chassis.

    admin_password
        The password used to access the chassis.

    module
        The element to reboot on the chassis such as a blade. If not provided,
        the chassis will be rebooted.

    CLI Example:

    .. code-block:: bash

        salt dell dracr.server_reboot
        salt dell dracr.server_reboot module=server-1

    userveraction powercycleR%R&R'R((R+(R%R&R'R(((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pyt
server_reboot�s	c
C@s"tdd|d|d|d|�S(u�
    Powers down the managed server.

    host
        The chassis host.

    admin_username
        The username used to access the chassis.

    admin_password
        The password used to access the chassis.

    module
        The element to power off on the chassis such as a blade.
        If not provided, the chassis will be powered off.

    CLI Example:

    .. code-block:: bash

        salt dell dracr.server_poweroff
        salt dell dracr.server_poweroff module=server-1
    userveraction powerdownR%R&R'R((R+(R%R&R'R(((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytserver_poweroffs	c
C@s"tdd|d|d|d|�S(u�
    Powers up the managed server.

    host
        The chassis host.

    admin_username
        The username used to access the chassis.

    admin_password
        The password used to access the chassis.

    module
        The element to power on located on the chassis such as a blade. If
        not provided, the chassis will be powered on.

    CLI Example:

    .. code-block:: bash

        salt dell dracr.server_poweron
        salt dell dracr.server_poweron module=server-1
    userveraction powerupR%R&R'R((R+(R%R&R'R(((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytserver_poweron s	c
C@s"tdd|d|d|d|�S(u
    Performs a reset (reboot) operation on the managed server.

    host
        The chassis host.

    admin_username
        The username used to access the chassis.

    admin_password
        The password used to access the chassis.

    module
        The element to hard reset on the chassis such as a blade. If
        not provided, the chassis will be reset.

    CLI Example:

    .. code-block:: bash

        salt dell dracr.server_hardreset
        salt dell dracr.server_hardreset module=server-1
    userveraction hardresetR%R&R'R((R+(R%R&R'R(((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytserver_hardreset@s
	c
C@s�tdd|d|d|d|�}idd6}|dd	krXt|d
<d|d<n|dd
krt|d
<d|d<n|djd�r�t|d
<|d|d<n|S(u�
    return the power status for the passed module

    CLI Example:

    .. code-block:: bash

        salt dell drac.server_powerstatus
    userveraction powerstatusR%R&R'R(iuretcodeustdoutuONustatusuPower is onucommentuOFFuERROR(R0RRR(R%R&R'R(R1tresult((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytserver_powerstatusbs
		





cC@setdd|d|d|�rTtdd|d|d|�r@tStjd�tSntjd�tS(u�
    Configure server to PXE perform a one off PXE boot

    CLI Example:

    .. code-block:: bash

        salt dell dracr.server_pxe
    u7config -g cfgServerInfo -o cfgServerFirstBootDevice PXER%R&R'u.config -g cfgServerInfo -o cfgServerBootOnce 1ufailed to set boot orderufailed to configure PXE boot(R+RnR"R#R(R%R&R'((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pyt
server_pxe�s				

cC@s.tdd|d|d|�}|ddkr2|Si}t}x�|dj�D]�}|jd�rpt}qOn|r|qOn|j�}i||d<|d||dd	<t|�d
kr�|d
||dd<nd||dd<t|�d
kr|d
||dd<qOd||dd<qOW|S(u�
    List the names of all slots in the chassis.

    host
        The chassis host.

    admin_username
        The username used to access the chassis.

    admin_password
        The password used to access the chassis.

    CLI Example:

    .. code-block:: bash

        salt-call --local dracr.list_slotnames host=111.222.333.444
            admin_username=root admin_password=secret

    ugetslotnameR%R&R'uretcodeiustdoutu<uslotiuslotnameuiuhostname(R0RRRRRR(R%R&R'tslotrawtslotststripheaderR/tfields((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytlist_slotnames�s.		cC@s6td|d|d|�}tj|�}||dS(u�
    Get the name of a slot number in the chassis.

    slot
        The number of the slot for which to obtain the name.

    host
        The chassis host.

    admin_username
        The username used to access the chassis.

    admin_password
        The password used to access the chassis.

    CLI Example:

    .. code-block:: bash

        salt-call --local dracr.get_slotname 0 host=111.222.333.444
           admin_username=root admin_password=secret

    R%R&R'uslotname(RyRt	text_type(tslotR%R&R'Rv((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytget_slotname�s	cC@s(tdj||�d|d|d|�S(u�
    Set the name of a slot in a chassis.

    slot
        The slot number to change.

    name
        The name to set. Can only be 15 characters long.

    host
        The chassis host.

    admin_username
        The username used to access the chassis.

    admin_password
        The password used to access the chassis.

    CLI Example:

    .. code-block:: bash

        salt '*' dracr.set_slotname 2 my-slotname host=111.222.333.444
            admin_username=root admin_password=secret

    u3config -g cfgServerInfo -o cfgServerName -i {0} {1}R%R&R'(R+R (R{R4R%R&R'((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytset_slotname�scC@s%tdj|�d|d|d|�S(u�
    Set the name of the chassis.

    name
        The name to be set on the chassis.

    host
        The chassis host.

    admin_username
        The username used to access the chassis.

    admin_password
        The password used to access the chassis.

    CLI Example:

    .. code-block:: bash

        salt '*' dracr.set_chassis_name my-chassis host=111.222.333.444
            admin_username=root admin_password=secret

    usetsysinfo -c chassisname {0}R%R&R'(R+R (R4R%R&R'((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytset_chassis_namescC@stdd|d|d|�S(us
    Get the name of a chassis.

    host
        The chassis host.

    admin_username
        The username used to access the chassis.

    admin_password
        The password used to access the chassis.

    CLI Example:

    .. code-block:: bash

        salt '*' dracr.get_chassis_name host=111.222.333.444
            admin_username=root admin_password=secret

    ugetchassisnameR%R&R'(tbare_rac_cmd(R%R&R'((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytget_chassis_name2sc
C@s�d�}i}dddddg|d<ddd	d
g|d<dddg|d
<dd
dg|d<tdd|d|d|�}|ddkr�|St}t}t}t}	i}
i|
d<i|
d<i|
d
<i|
d<x�|dj�D]�}|jd�r t}t}t}t}	q�n|jd�rMt}t}t}t}	q�n|jd�rzt}t}t}t}	q�n|jd�r�t}t}t}t}	q�nt|�dkr�q�ntjd|j��}|rt	d�t
||d|�D��|
d|d<n|rMt	d�t
||d|�D��|
d|d<n|r�t	d�t
||d
|�D��|
d
|d<n|	r�t	d �t
||d|�D��|
d|d<q�q�W|
S(!NcS@si||6S(N((txty((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytmapitMsunameu
idrac_versionu
blade_typeugenu
updateableuserveru
model_nameu
hw_versionu
fw_versionuswitchucmc_versionucmcufqdduchassisu
getversionR%R&R'uretcodeiustdoutu<Server>u<Switch>u<CMC>u<Chassis Infrastructure>iu  +cs@s4|]*}|j�D]\}}||fVqqdS(N(titems(t.0tdtktv((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pys	<genexpr>�scs@s4|]*}|j�D]\}}||fVqqdS(N(R�(R�R�R�R�((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pys	<genexpr>�scs@s4|]*}|j�D]\}}||fVqqdS(N(R�(R�R�R�R�((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pys	<genexpr>�scs@s4|]*}|j�D]\}}||fVqqdS(N(R�(R�R�R�R�((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pys	<genexpr>�s(R0RRRRRtreRRRR(
R%R&R'R�Rxtrawinvt	in_servert	in_switchtin_cmct
in_chassisR1R/tline((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pyR?Ls|	
	



2226cC@s%tdj|�d|d|d|�S(u�
    Set the location of the chassis.

    location
        The name of the location to be set on the chassis.

    host
        The chassis host.

    admin_username
        The username used to access the chassis.

    admin_password
        The password used to access the chassis.

    CLI Example:

    .. code-block:: bash

        salt '*' dracr.set_chassis_location location-name host=111.222.333.444
            admin_username=root admin_password=secret

    u!setsysinfo -c chassislocation {0}R%R&R'(R+R (tlocationR%R&R'((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytset_chassis_location�scC@s!td|d|d|�ddS(u|
    Get the location of the chassis.

    host
        The chassis host.

    admin_username
        The username used to access the chassis.

    admin_password
        The password used to access the chassis.

    CLI Example:

    .. code-block:: bash

        salt '*' dracr.set_chassis_location host=111.222.333.444
           admin_username=root admin_password=secret

    R%R&R'uChassis InformationuChassis Location(R6(R%R&R'((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytget_chassis_location�sc
C@s"tdd|d|d|d|�S(u�
    Set the location of the chassis.

    location
        The name of the datacenter to be set on the chassis.

    host
        The chassis host.

    admin_username
        The username used to access the chassis.

    admin_password
        The password used to access the chassis.

    CLI Example:

    .. code-block:: bash

        salt '*' dracr.set_chassis_datacenter datacenter-name host=111.222.333.444
            admin_username=root admin_password=secret

    ucfgLocationucfgLocationDatacenterR%R&R'(tset_general(R�R%R&R'((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytset_chassis_datacenter�sc	C@stddd|d|d|�S(u~
    Get the datacenter of the chassis.

    host
        The chassis host.

    admin_username
        The username used to access the chassis.

    admin_password
        The password used to access the chassis.

    CLI Example:

    .. code-block:: bash

        salt '*' dracr.set_chassis_location host=111.222.333.444
           admin_username=root admin_password=secret

    ucfgLocationucfgLocationDatacenterR%R&R'(tget_general(R%R&R'((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytget_chassis_datacenter�scC@s+tdj|||�d|d|d|�S(Nuconfig -g {0} -o {1} {2}R%R&R'(R+R (tcfg_sectcfg_varRPR%R&R'((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pyR�s
cC@sJtdj||�d|d|d|�}|ddkrB|dS|SdS(Nugetconfig -g {0} -o {1}R%R&R'uretcodeiustdout(R0R (R�R�R%R&R'R1((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pyR�s	c
C@s|t||||�}|d
k	r*|}n|}|dd}t|d|ddd|�}	|	ddkrt|	d	S|	Sd
S(u
    Run a generic racadm command against a particular
    blade in a chassis.  Blades are usually named things like
    'server-1', 'server-2', etc.  If the iDRAC has a different
    password than the CMC, then you can pass it with the
    idrac_password kwarg.

    :param blade_name: Name of the blade to run the command on
    :param command: Command like to pass to racadm
    :param idrac_password: Password for the iDRAC if different from the CMC
    :param host: Chassis hostname
    :param admin_username: CMC username
    :param admin_password: CMC password
    :return: stdout if the retcode is 0, otherwise a standard cmd.run_all dictionary

    CLI Example:

    .. code-block:: bash

        salt fx2 chassis.cmd idrac_general server-1 'get BIOS.SysProfileSettings'

    uNetworku
IP AddressR%R&urootR'uretcodeiustdoutN(RCR@R0(
t
blade_nameR$tidrac_passwordR%R&R'tmodule_networkRUtidrac_ipR1((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pyt
idrac_general*s			cC@sl|stdd}n|s.tdd}nt|d|d|d|�}|ddkrd|d	S|SdS(
Nuproxyuadmin_usernameuadmin_passwordR%R&R'uretcodeiustdout(t
__pillar__R0(R*R%R&R'R1((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pyt_update_firmwareXs		cC@sGtdj|�d|d|d|�}|ddkr?|dS|SdS(Nu{0}R%R&R'uretcodeiustdout(R0R (R*R%R&R'R1((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pyRms	cC@sPtjj|�r7tdj|�dddddd�Stdj|���dS(uM
    Updates firmware using local firmware file

    .. code-block:: bash

         salt dell dracr.update_firmware firmware.exe

    This executes the following command on your FX2
    (using username and password stored in the pillar data)

    .. code-block:: bash

         racadm update –f firmware.exe -u user –p pass

    u
update -f {0}R%R&R'u Unable to find firmware file {0}N(tosR	texistsR�R R@R(tfilenameR%R&R'((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytupdate_firmwarezs	cC@sStjj|�r:tdj||�dddddd�Stdj|���dS(u�
    Executes the following for CIFS
    (using username and password stored in the pillar data)

    .. code-block:: bash

         racadm update -f <updatefile> -u user –p pass -l //IP-Address/share

    Or for NFS
    (using username and password stored in the pillar data)

    .. code-block:: bash

          racadm update -f <updatefile> -u user –p pass -l IP-address:/share


    Salt command for CIFS:

    .. code-block:: bash

         salt dell dracr.update_firmware_nfs_or_cifs          firmware.exe //IP-Address/share


    Salt command for NFS:

    .. code-block:: bash

         salt dell dracr.update_firmware_nfs_or_cifs          firmware.exe IP-address:/share
    uupdate -f {0} -l {1}R%R&R'u Unable to find firmware file {0}N(R�R	R�R�R R@R(R�tshareR%R&R'((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pytupdate_firmware_nfs_or_cifs�s#	(Mt__doc__t
__future__RRRtloggingR�R�tsalt.exceptionsRtsalt.utils.pathRtsalt.extRtsalt.ext.six.movesRRt	getLoggert__name__R"t__proxyenabled__R!trun_allt	NameErrortKeyErrortsalt.modules.cmdmodtmodulestcmdmodR
RR@R+R0R3R5R6RR<R>RCRERRHRJRQRTRVRWRYRdRaRjRkRmRnRoRpRqRsRtRyR|R}R~R�R?R�R�R�R�R�R�R�R�RR�R�(((s6/usr/lib/python2.7/site-packages/salt/modules/dracr.pyt<module>s&			#0
	'"+'C6  2 !R-


Zerion Mini Shell 1.0