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__/cimc.cpython-310.pyc
o

�N�gM9�@sddZddlZe�e�Zdd�Zdd�Zddd�Zdd	d
�Zdd�Z	dd
d�Z
ddd�Zddd�ZdS)a�
A state module to manage Cisco UCS chassis devices.

:codeauthor: ``Spencer Ervin <spencer_ervin@hotmail.com>``
:maturity:   new
:depends:    none
:platform:   unix


About
=====
This state module was designed to handle connections to a Cisco Unified Computing System (UCS) chassis. This module
relies on the CIMC proxy module to interface with the device.

.. seealso::
    :py:mod:`CIMC Proxy Module <salt.proxy.cimc>`

�NcCsdtvrdSdS)Nzcimc.get_system_infoT)Fzcimc module could not be loaded)�__salt__�rr�D/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/cimc.py�__virtual__srcCs|iddd�}|S)z+
    Set the default response values.

    F�)�name�changes�result�commentr)r�retrrr�_default_retsrc
Cs�t|�}td�}d}z2||krd}|r8td|�}|s'd|d<d|d<|WS||dd	<||dd
<d|d<nd|d<Wn!ty^}zd|d<d
|d<t�|�|WYd}~Sd}~wwd|d<|S)aA
    Ensures that the hostname is set to the specified value.

    .. versionadded:: 2019.2.0

    name: The name of the module function to execute.

    hostname(str): The hostname of the server.

    SLS Example:

    .. code-block:: yaml

        set_name:
          cimc.hostname:
            - hostname: foobar

    zcimc.get_hostnameFTzcimc.set_hostnamer	zError setting hostname.r
r�before�afterzHostname modified.z1Hostname already configured. No changes required.z Error occurred setting hostname.N�rr�	Exception�log�error)r�hostnamerZcurrent_name�
req_change�update�errrrrr(s4

�
��rc	
Cst|�}td�}d}zW|ddd}|r|d|krd}n
|r)|d|kr)d}|r]td	||�}|d
ddddkrId|d
<d|d<|WS||dd<td�|dd<d|d<nd|d<Wn!ty�}zd|d
<d|d<t�|�|WYd}~Sd}~wwd|d
<|S)a1
    Ensures that the logging levels are set on the device. The logging levels
    must match the following options: emergency, alert, critical, error, warning,
    notice, informational, debug.

    .. versionadded:: 2019.2.0

    name: The name of the module function to execute.

    remote(str): The logging level for SYSLOG logs.

    local(str): The logging level for the local device.

    SLS Example:

    .. code-block:: yaml

        logging_levels:
          cimc.logging_levels:
            - remote: informational
            - local: notice

    zcimc.get_syslog_settingsF�
outConfigsZ
commSyslogrZremoteSeverityTZ
localSeverityzcimc.set_logging_levels�	outConfig�status�modifiedr	zError setting logging levels.r
rr
rz Logging level settings modified.z6Logging level already configured. No changes required.z.Error occurred setting logging level settings.Nr)	rZremote�localrZsyslog_confrZsyslog_dictrrrrr�logging_levelsas:

�
��rc

Cs�t|�}gd�}t|t�rd}|D]
}|||<|d7}qn||d<td�}d}zH|ddddd	ksm|d|dddd
ksm|d|ddddksm|d|dddd
ksm|d|ddddkrod}Wn!ty�}zd|d<d|d<t�|�|WYd}~Sd}~ww|r�z*td|d|d|d|d�}	|	dddddkr�d|d<d|d<|WSWn!ty�}zd|d<d|d<t�|�|WYd}~Sd}~ww||dd<td�|dd<d|d<nd|d<d|d<|S)aI
    Ensures that the NTP servers are configured. Servers are provided as an individual string or list format. Only four
    NTP servers will be reviewed. Any entries past four will be ignored.

    name: The name of the module function to execute.

    servers(str, list): The IP address or FQDN of the NTP servers.

    SLS Example:

    .. code-block:: yaml

        ntp_configuration_list:
          cimc.ntp:
            - servers:
              - foo.bar.com
              - 10.10.10.10

        ntp_configuration_str:
          cimc.ntp:
            - servers: foo.bar.com

    )rrrrr�zcimc.get_ntpFrZcommNtpProviderZ	ntpEnableZyesZ
ntpServer1Z
ntpServer2�Z
ntpServer3�Z
ntpServer4Tr	z'Unable to confirm current NTP settings.r
Nzcimc.set_ntp_serverrrrz Error setting NTP configuration.rr
rzNTP settings modified.z,NTP already configured. No changes required.)r�
isinstance�listr�KeyErrorrrr)
rZserversrZntp_servers�i�x�confrrrrrr�ntp�sb

�
�
����
��
r&c

CsXt|�}td�}d}zy|ddd}|r|d|krd}n+|dkr?|d	|kr,d}n|d	d
kr>t|d�t|�kr>d}nd|d<d
|d<|WS|rtd|||�}|dddddkrkd|d<d|d<|WS||dd<td�|dd<d|d<nd|d<Wn!ty�}	zd|d<d|d<t�|	�|WYd}	~	Sd}	~	wwd|d<|S)a
    Ensures that the power configuration is configured on the system. This is
    only available on some C-Series servers.

    .. versionadded:: 2019.2.0

    name: The name of the module function to execute.

    policy(str): The action to be taken when chassis power is restored after
    an unexpected power loss. This can be one of the following:

        reset: The server is allowed to boot up normally when power is
        restored. The server can restart immediately or, optionally, after a
        fixed or random delay.

        stay-off: The server remains off until it is manually restarted.

        last-state: The server restarts and the system attempts to restore
        any processes that were running before power was lost.

    delayType(str): If the selected policy is reset, the restart can be
    delayed with this option. This can be one of the following:

        fixed: The server restarts after a fixed delay.

        random: The server restarts after a random delay.

    delayValue(int): If a fixed delay is selected, once chassis power is
    restored and the Cisco IMC has finished rebooting, the system waits for
    the specified number of seconds before restarting the server. Enter an
    integer between 0 and 240.


    SLS Example:

    .. code-block:: yaml

        reset_power:
          cimc.power_configuration:
            - policy: reset
            - delayType: fixed
            - delayValue: 0

        power_off:
          cimc.power_configuration:
            - policy: stay-off


    zcimc.get_power_configurationFrZbiosVfResumeOnACPowerLossrZvpResumeOnACPowerLossT�reset�	delayType�fixed�delayr	z#The power policy must be specified.r
zcimc.set_power_configurationrrrz"Error setting power configuration.rr
rzPower settings modified.z7Power settings already configured. No changes required.z&Error occurred setting power settings.N�rr�strrrr)
r�policyr(Z
delayValuerZ
power_confrZ
power_dictrrrrr�power_configuration�sR3
���
�
��r.c
Cs$t|�}td�}d}|r~d}d|vr7d|dvr7|ddD]}|ddkr(q|dd	kr6|d
|kr6d}q|r~z#td|d�}|ddd
ddkrPd}nd|d<d|d<|WSWn!ty}}	zd|d<d|d<t�|	�|WYd}	~	Sd}	~	ww|r�d}
d|vr�d|dvr�|ddD]}|ddkr�q�|dd	kr�|d
|kr�d}
q�|
r�z#td|d�}|ddd
ddkr�d}nd|d<d|d<|WSWn!ty�}	zd|d<d|d<t�|	�|WYd}	~	Sd}	~	ww|�r||dd<td�|dd<d|d<nd|d<d|d<|S)a�
    Ensures that the syslog servers are set to the specified values. A value of None will be ignored.

    name: The name of the module function to execute.

    primary(str): The IP address or FQDN of the primary syslog server.

    secondary(str): The IP address or FQDN of the secondary syslog server.

    SLS Example:

    .. code-block:: yaml

        syslog_configuration:
          cimc.syslog:
            - primary: 10.10.10.10
            - secondary: foo.bar.com

    zcimc.get_syslogFTrZcommSyslogClientr�primaryZ
adminState�enabledrzcimc.set_syslog_serverrrrrr	z$Error setting primary SYSLOG server.r
N�	secondaryz&Error setting secondary SYSLOG server.rr
rzSYSLOG settings modified.z/SYSLOG already configured. No changes required.r)rr/r1rr%rZprim_change�entryrrZ
sec_changerrr�syslog]sx
��
����
��
r3r�activec
Cst|�}td�}zR|ddD]}|dt|�kr|}	q|	s*d|d<d|d<|WStd	t|�||||�}
d
|
vrO|	|dd<|
d
d|dd
<d|d<nd|d<d|d<|WSWn!ty|}zd|d<d|d<t�|�|WYd}~Sd}~wwd|d<|S)a�
    Ensures that a user is configured on the device. Due to being unable to
    verify the user password. This is a forced operation.

    .. versionadded:: 2019.2.0

    name: The name of the module function to execute.

    id(int): The user ID slot on the device.

    user(str): The username of the user.

    priv(str): The privilege level of the user.

    password(str): The password of the user.

    status(str): The status of the user. Can be either active or inactive.

    SLS Example:

    .. code-block:: yaml

        user_configuration:
          cimc.user:
            - id: 11
            - user: foo
            - priv: admin
            - password: mypassword
            - status: active

    zcimc.get_usersrZaaaUser�idFr	zFUnable to find requested user id on device. Please verify id is valid.r
z
cimc.set_userrrr
rzUser settings modified.z!Error setting user configuration.NTr+)rr5�userZpriv�passwordrrZ	user_confr2r%Zupdatesrrrrr6�s<!
��
�
��r6)N)NN)NNN)rrrrr4)
�__doc__�logging�	getLogger�__name__rrrrrr&r.r3r6rrrr�<module>s

	
9A
S
hV