HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/drac.cpython-310.pyc
o

�N�gr�@s8dZddlZddlZdd�Zdd�Zdd�Zd	d
�ZdS)ag
Management of Dell DRAC

The DRAC module is used to create and manage DRAC cards on Dell servers


Ensure the user damian is present

  .. code-block:: yaml

    damian:
      drac.present:
        - name: damian
        - password: secret
        - permission: login,test_alerts,clear_logs


Ensure the user damian does not exist

  .. code-block:: yaml

    damian:
      drac.absent:
        - name: damian


Ensure DRAC network is in a consistent state

  .. code-block:: yaml

    my_network:
      drac.network:
        - ip: 10.225.108.29
        - netmask: 255.255.255.224
        - gateway: 10.225.108.1

�NcCstjj�d�r	dSdS)z0
    Ensure the racadm command is installed
    ZracadmT)Fzracadm command not found)�salt�utils�path�which�rr�D/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/drac.py�__virtual__+srcCs�|didd�}td�}tdr.||vrd|�d�|d<|Sd|�d	�|d<|d
i|d<|S||vr<d|�d�|d<|Std||||�rUd|�d
�|d<|di|d<|Sd|d<d|d<|S)z�
    Ensure the user exists on the Dell DRAC

    name:
        The users username

    password
        The password used to authenticate

    permission
        The permissions that should be assigned to a user
    T���name�result�changes�comment�drac.list_users�test�`z` already existsrz` will be createdzwill be createdr
zdrac.create_userz` user createdznew user createdzUnable to create userFr��__salt__�__opts__)r�passwordZ
permission�ret�usersrrr�present4s&
�	��rcCs�|didd�}td�}tdr.||vr$d|�d�|d<|d	i|d
<|Sd|�d�|d<|S||vrWtd|||d
�rMd|�d�|d<|di|d
<|Sd|d<d|d<|Sd|�d�|d<|S)z]
    Ensure a user does not exist on the Dell DRAC

    name:
        The users username
    Tr	r
rrrz` is set to be deletedrzwill be deletedr
z` does not existzdrac.delete_user�indexz	` deletedZdeletedzUnable to delete userFrr)rrrrrr�absent[s&
���rcCs�|didd�}td�}i}||ddkr&|d�d|dd|d�i�||dd	kr>|d�d
|dd	|d�i�||ddkrV|d�d|dd|d�i�tdr`d
|d<|Std|||�rr|dspd|d<|Sd|d<d|d<|S)z9
    Ensure the DRAC network settings are consistent
    Tr	r
zdrac.network_infoz
IPv4 settingsz
IP Addressr
)ZOldZNewzSubnet MaskZNetmaskZGatewayrNrzdrac.set_networkzNetwork is in the desired staterFzunable to configure network)r�updater)�ip�netmaskZgatewayrZcurrent_networkZnew_networkrrr�network|sJ

���	
���	
���	r)�__doc__Zsalt.exceptionsrZsalt.utils.pathrrrrrrrr�<module>s&	'!