File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/runners/__pycache__/drac.cpython-310.pyc
Back
o ;j5 � @ s� d Z ddlZzddlZdZW n ey dZY nw e�e�Zdd� Zddd �Z d d� Z ddd �Zddd�Zddd�Z ddd�Zddd�ZdS )z� Manage Dell DRAC from the Master The login credentials need to be configured in the Salt master configuration file. .. code-block:: yaml drac: username: admin password: secret � NTFc C s t rdS dS )NT)FzKThe drac runner module cannot be loaded: paramiko package is not installed.)�HAS_PARAMIKO� r r �E/opt/saltstack/salt/lib/python3.10/site-packages/salt/runners/drac.py�__virtual__ s r � c C s� t �d�}d}|s|du rt�|� dS |�dd�}|s-|du r't�|� dS |�dd�}t�� }|�t�� � z|j| |||d� W |S t y^ } zt�d| |� W Y d}~dS d}~ww ) z Connect to the DRAC Zdracz�No drac login credentials found. Please add the 'username' and 'password' fields beneath a 'drac' key in the master configuration file. Or you can pass in a username and password as kwargs at the CLI.NF�username�password)r r �timeoutzUnable to connect to %s: %s) Z__opts__�get�log�error�paramiko� SSHClientZset_missing_host_key_policyZ AutoAddPolicy�connect� Exception)�hostnamer r r Z drac_cred�err_msg�client�er r r � __connect% s. � ���r c C sx ddddddd�}t | tj�r:| �d�\}}}|�� D ]}|dd� �d�r9|�t|dd� �d �d �d� S qdS )z Grab DRAC version ZCMCZiDRAC6ZiDRAC7)� � � � � � zracadm getconfig -g idRacInfo� NZ idRacType�=� ) � isinstancer r �exec_command� readlines� startswithr �int�split)r Zversions�stdin�stdout�stderr�ir r r � __versionG s � &�r) c C s� g d�}t | |||�}t|tj�r?t|d�D ]\}}t�d|� |�|�\}} } qd| �� v r7t�d|� dS t� d|� dS dS ) z� Connect to the Dell DRAC and have the boot order set to PXE and power cycle the system to PXE boot CLI Example: .. code-block:: bash salt-run drac.pxe example.com )z>racadm config -g cfgServerInfo -o cfgServerFirstBootDevice pxez5racadm config -g cfgServerInfo -o cfgServerBootOnce 1�racadm serveraction powercycler zExecuting command %s� successfulzExecuting command: %szUnable to execute: %sFT) r r r r � enumerater �infor �readliner )r r r r Z_cmdsr r( �cmdr% r&