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

�
���^c@@sdZddlmZmZmZddlZddlZddlZej	e
�ZdZd�Z
ed�Zddddd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(d�Z)d �Z*dddd!ddd"�Z+d#�Z,dd$�Z-ddd%�Z.d&d&d&d&d'�Z/dddd(�Z0dd)d*�Z1dddddd+�Z2ddd,�Z3ddd-�Z4dS(.u�
Module to provide Cisco UCS compatibility to Salt

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


Configuration
=============
This module accepts connection configuration details either as
parameters, or as configuration settings in pillar as a Salt proxy.
Options passed into opts will be ignored if options are passed into pillar.

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

About
=====
This execution module was designed to handle connections to a Cisco UCS server.
This module adds support to send connections directly to the device through the
rest API.

i(tabsolute_importtprint_functiontunicode_literalsNucimccC@sLy.tjjj�r-tdddkr-tSWntk
rAnXtdfS(u/
    Will load for the cimc proxy minions.
    uproxyu	proxytypeucimcuDThe cimc execution module can only be loaded for cimc proxy minions.(tsalttutilstplatformtis_proxyt__opts__t__virtualname__tKeyErrortFalse(((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pyt__virtual__)s
cC@sJd}d}|tkr!d}ndj|�}td||t�}|S(u
    Activates the firmware backup image.

    CLI Example:

    Args:
        reset(bool): Reset the CIMC device on activate.

    .. code-block:: bash

        salt '*' cimc.activate_backup_image
        salt '*' cimc.activate_backup_image reset=True

    u2sys/rack-unit-1/mgmt/fw-boot-def/bootunit-combinedunouyesu�<firmwareBootUnit dn='sys/rack-unit-1/mgmt/fw-boot-def/bootunit-combined'
    adminState='trigger' image='backup' resetOnActivate='{0}' />ucimc.set_config_modify(tTruetformatt	__proxy__R
(tresettdntrtinconfigtret((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytactivate_backup_image7s	cC@s�|stjjd��n|s6tjjd��n|sQtjjd��n|sltjjd��ndj|�}dj||||�}td||t�}|S(u�
    Create a CIMC user with username and password.

    Args:
        uid(int): The user ID slot to create the user account in.

        username(str): The name of the user.

        password(str): The clear text password of the user.

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

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.create_user 11 username=admin password=foobar priv=admin

    uThe user ID must be specified.uThe username must be specified.uThe password must be specified.u&The privilege level must be specified.usys/user-ext/user-{0}uj<aaaUser id="{0}" accountStatus="active" name="{1}" priv="{2}"
    pwd="{3}"  dn="sys/user-ext/user-{0}"/>ucimc.set_config_modify(Rt
exceptionstCommandExecutionErrorR
RR
(tuidtusernametpasswordtprivRRR((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytcreate_userVs		cC@stddt�}|S(u�
    Get the default values of BIOS tokens.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_bios_defaults

    ucimc.get_config_resolver_classubiosPlatformDefaults(RR(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_bios_defaults�scC@stddt�}|S(u�
    Get the C240 server BIOS token values.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_bios_settings

    ucimc.get_config_resolver_classubiosSettings(RR(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_bios_settings�scC@stddt�}|S(u�
    Retrieves the configured boot order table.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_boot_order

    ucimc.get_config_resolver_classu	lsbootDef(RR(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_boot_order�scC@stddt�}|S(u}
    Get the CPU product ID details.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_cpu_details

    ucimc.get_config_resolver_classu
pidCatalogCpu(RR(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_cpu_details�scC@stddt�}|S(uw
    Get the HDD product ID details.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_disks

    ucimc.get_config_resolver_classu
pidCatalogHdd(RR(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pyt	get_disks�scC@stddt�}|S(u�
    Get the adapter Ethernet interface details.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_ethernet_interfaces

    ucimc.get_config_resolver_classuadaptorHostEthIf(RR(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_ethernet_interfaces�scC@stddt�}|S(u�
    Get the adapter fibre channel interface details.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_fibre_channel_interfaces

    ucimc.get_config_resolver_classuadaptorHostFcIf(RR(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_fibre_channel_interfaces�scC@stddt�}|S(u�
    Retrieves the current running firmware versions of server components.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_firmware

    ucimc.get_config_resolver_classufirmwareRunning(RR
(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_firmware�scC@sFtddt�}y|ddddSWntk
rA}dSXdS(u�
    Retrieves the hostname from the device.

    .. versionadded:: 2019.2.0

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_hostname

    ucimc.get_config_resolver_classumgmtIfu
outConfigsiuhostnameuUnable to retrieve hostnameN(RRt	Exception(Rterr((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_hostnames

cC@stddt�}|S(uu
    Retrieves LDAP server details.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_ldap

    ucimc.get_config_resolver_classuaaaLdap(RR(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_ldapscC@stddt�}|S(u�
    Retrieve the management interface details.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_management_interface

    ucimc.get_config_resolver_classumgmtIf(RR
(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_management_interface)scC@stddt�}|S(u}
    Get the memory RAS BIOS token.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_memory_token

    ucimc.get_config_resolver_classu"biosVfSelectMemoryRASConfiguration(RR
(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_memory_token9scC@stddt�}|S(u�
    Get the IMM/Memory unit product ID details.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_memory_unit

    ucimc.get_config_resolver_classupidCatalogDimm(RR(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_memory_unitIscC@stddt�}|S(u�
    Get the list of network adapaters and configuration details.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_network_adapters

    ucimc.get_config_resolver_classunetworkAdapterEthIf(RR(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_network_adaptersYscC@stddt�}|S(u�
    Retrieves the current running NTP configuration.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_ntp

    ucimc.get_config_resolver_classucommNtpProvider(RR
(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_ntpiscC@stddt�}|S(u
    Get the PCI adapter product ID details.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_disks

    ucimc.get_config_resolver_classupidCatalogPCIAdapter(RR(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_pci_adaptersyscC@stddt�}|S(u�
    Get the configuration of the power settings from the device. This is only available
    on some C-Series servers.

    .. versionadded:: 2019.2.0

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_power_configuration

    ucimc.get_config_resolver_classubiosVfResumeOnACPowerLoss(RR(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_power_configuration�scC@stddt�}|S(u�
    Retrieves the power supply unit details.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_power_supplies

    ucimc.get_config_resolver_classuequipmentPsu(RR
(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_power_supplies�scC@stddt�}|S(u�
    Get the snmp configuration details.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_snmp_config

    ucimc.get_config_resolver_classucommSnmp(RR
(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_snmp_config�scC@stddt�}|S(u~
    Get the Syslog client-server details.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_syslog

    ucimc.get_config_resolver_classucommSyslogClient(RR
(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pyt
get_syslog�scC@stddt�}|S(u�
    Get the Syslog configuration settings from the system.

    .. versionadded:: 2019.2.0

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_syslog_settings

    ucimc.get_config_resolver_classu
commSyslog(RR
(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_syslog_settings�s
cC@stddt�}|S(uy
    Get the system information.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_system_info

    ucimc.get_config_resolver_classucomputeRackUnit(RR
(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_system_info�scC@stddt�}|S(uk
    Get the CIMC users.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_users

    ucimc.get_config_resolver_classuaaaUser(RR
(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pyt	get_users�scC@stddt�}|S(u�
    Get the VIC adapter general profile details.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_vic_adapters

    ucimc.get_config_resolver_classuadaptorGenProfile(RR(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_vic_adapters�scC@stddt�}|S(u�
    Get the VIC adapter uplink port details.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.get_vic_uplinks

    ucimc.get_config_resolver_classuadaptorExtEthIf(RR(R((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytget_vic_uplinkssunfsc
C@s�|stjjd��n|s6tjjd��n|sQtjjd��n|rr|rrdj||�}nd}dj|�}dj|||||�}td||t�}	|	S(	ur
    Mounts a remote file through a remote share. Currently, this feature is supported in version 1.5 or greater.
    The remote share can be either NFS, CIFS, or WWW.

    Some of the advantages of CIMC Mounted vMedia include:
      Communication between mounted media and target stays local (inside datacenter)
      Media mounts can be scripted/automated
      No vKVM requirements for media connection
      Multiple share types supported
      Connections supported through all CIMC interfaces

      Note: CIMC Mounted vMedia is enabled through BIOS configuration.

    Args:
        name(str): The name of the volume on the CIMC device.

        remote_share(str): The file share link that will be used to mount the share. This can be NFS, CIFS, or WWW. This
        must be the directory path and not the full path to the remote file.

        remote_file(str): The name of the remote file to mount. It must reside within remote_share.

        mount_type(str): The type of share to mount. Valid options are nfs, cifs, and www.

        username(str): An optional requirement to pass credentials to the remote share. If not provided, an
        unauthenticated connection attempt will be made.

        password(str): An optional requirement to pass a password to the remote share. If not provided, an
        unauthenticated connection attempt will be made.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.mount_share name=WIN7 remote_share=10.xxx.27.xxx:/nfs remote_file=sl1huu.iso

        salt '*' cimc.mount_share name=WIN7 remote_share=10.xxx.27.xxx:/nfs remote_file=sl1huu.iso username=bob password=badpassword

    u!The share name must be specified.u(The remote share path must be specified.u'The remote file name must be specified.u) mountOptions='username={0},password={1}'uu sys/svc-ext/vmedia-svc/vmmap-{0}u�<commVMediaMap dn='sys/svc-ext/vmedia-svc/vmmap-{0}' map='{1}'{2}
    remoteFile='{3}' remoteShare='{4}' status='created'
    volumeName='Win12' />ucimc.set_config_modify(RRRR
RR
(
tnametremote_sharetremote_filet
mount_typeRRt
mount_optionsRRR((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytmount_shares-cC@s&d}d}td||t�}|S(un
    Power cycling the server.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.reboot

    usys/rack-unit-1uU<computeRackUnit adminPower="cycle-immediate" dn="sys/rack-unit-1"></computeRackUnit>ucimc.set_config_modify(RR
(RRR((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytrebootcscC@s�|stjjd��nd}dj|�}td||t�}y(|ddddd	kritStSWntk
r�}tSXd
S(u�
    Sets the hostname on the server.

    .. versionadded:: 2019.2.0

    Args:
        hostname(str): The new hostname to set.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.set_hostname foobar

    u!Hostname option must be provided.usys/rack-unit-1/mgmt/if-1u@<mgmtIf dn="sys/rack-unit-1/mgmt/if-1" hostname="{0}" ></mgmtIf>ucimc.set_config_modifyu	outConfigumgmtIfiustatusumodifiedN(RRRR
RR
RR$(thostnameRRRR%((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytset_hostnamexscC@s�ddddddddg}d	}|ra||krL|d
j|�7}qatjjd��n|r�||kr�|dj|�7}q�tjjd
��nd}dj|�}td||t�}|S(u�
    Sets the logging levels of the CIMC devices. The logging levels must match
    the following options: emergency, alert, critical, error, warning, notice,
    informational, debug.

    .. versionadded:: 2019.2.0

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

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

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.set_logging_levels remote=error local=notice

    u	emergencyualertucriticaluerroruwarningunoticeu
informationaludebuguu remoteSeverity="{0}"u$Remote Severity option is not valid.u localSeverity="{0}"u#Local Severity option is not valid.usys/svc-ext/syslogu5<commSyslog dn="sys/svc-ext/syslog"{0} ></commSyslog>ucimc.set_config_modify(R
RRRRR
(tremotetlocaltlogging_optionstqueryRRR((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytset_logging_levels�s*	ucC@s8d}dj||||�}td||t�}|S(u"
    Sets the NTP servers configuration. This will also enable the client NTP service.

    Args:
        server1(str): The first IP address or FQDN of the NTP servers.

        server2(str): The second IP address or FQDN of the NTP servers.

        server3(str): The third IP address or FQDN of the NTP servers.

        server4(str): The fourth IP address or FQDN of the NTP servers.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.set_ntp_server 10.10.10.1

        salt '*' cimc.set_ntp_server 10.10.10.1 foo.bar.com

    usys/svc-ext/ntp-svcu�<commNtpProvider dn="sys/svc-ext/ntp-svc" ntpEnable="yes" ntpServer1="{0}" ntpServer2="{1}"
    ntpServer3="{2}" ntpServer4="{3}"/>ucimc.set_config_modify(R
RR
(tserver1tserver2tserver3tserver4RRR((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytset_ntp_server�scC@s�d}|dkr�d}|r�|dkrS|d7}|r~|dj|�7}q~q�|dkrl|d7}q�tjjd	��q�n<|d
kr�d}n'|dkr�d}ntjjd
��d}dj|�}td||t�}|S(u�
    Sets the power configuration on the device. This is only available for some
    C-Series servers.

    .. versionadded:: 2019.2.0

    Args:
        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.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.set_power_configuration stay-off

        salt '*' cimc.set_power_configuration reset fixed 0

    uuresetu vpResumeOnACPowerLoss="reset"ufixedu delayType="fixed"u delay="{0}"urandomu delayType="random"uInvalid delay type entered.ustay-offu
last-stateu# vpResumeOnACPowerLoss="last-state"u"The power state must be specified.u-sys/rack-unit-1/board/Resume-on-AC-power-lossuv<biosVfResumeOnACPowerLoss
    dn="sys/rack-unit-1/board/Resume-on-AC-power-loss"{0}>
    </biosVfResumeOnACPowerLoss>ucimc.set_config_modify(R
RRRRR
(tpolicyt	delayTypet
delayValueRCRRR((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytset_power_configuration�s(*

		uprimarycC@s�|stjjd��n|dkr?d}dj|�}n6|dkrcd}dj|�}ntjjd��td	||t�}|S(
u�
    Set the SYSLOG server on the host.

    Args:
        server(str): The hostname or IP address of the SYSLOG server.

        type(str): Specifies the type of SYSLOG server. This can either be primary (default) or secondary.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.set_syslog_server foo.bar.com

        salt '*' cimc.set_syslog_server foo.bar.com primary

        salt '*' cimc.set_syslog_server foo.bar.com secondary

    u$The SYSLOG server must be specified.uprimaryu!sys/svc-ext/syslog/client-primaryu�<commSyslogClient name='primary' adminState='enabled'  hostname='{0}'
        dn='sys/svc-ext/syslog/client-primary'> </commSyslogClient>u	secondaryu#sys/svc-ext/syslog/client-secondaryu�<commSyslogClient name='secondary' adminState='enabled'  hostname='{0}'
        dn='sys/svc-ext/syslog/client-secondary'> </commSyslogClient>u4The SYSLOG type must be either primary or secondary.ucimc.set_config_modify(RRRR
RR
(tserverttypeRRR((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytset_syslog_server4sc	C@s�d}|s!tjjd��n|r=|dj|�7}n|rY|dj|�7}n|ru|dj|�7}n|r�|dj|�7}ndj|�}dj||�}td	||t�}|S(
u�
    Sets a CIMC user with specified configurations.

    .. versionadded:: 2019.2.0

    Args:
        uid(int): The user ID slot to create the user account in.

        username(str): The name of the user.

        password(str): The clear text password of the user.

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

        status(str): The account status of the user.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.set_user 11 username=admin password=foobar priv=admin active

    uuThe user ID must be specified.u accountStatus="{0}"u name="{0}"u priv="{0}"u
 pwd="{0}"usys/user-ext/user-{0}u1<aaaUser id="{0}"{1} dn="sys/user-ext/user-{0}"/>ucimc.set_config_modify(RRRR
RR
(	RRRRtstatustconfRRR((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pytset_user\s 		cC@sh|stjjd��n|s6tjjd��nd}dj||�}td||t�}|S(u.
    Update the BIOS firmware through TFTP.

    Args:
        server(str): The IP address or hostname of the TFTP server.

        path(str): The TFTP path and filename for the BIOS image.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.tftp_update_bios foo.bar.com HP-SL2.cap

    u"The server name must be specified.u The TFTP path must be specified.u!sys/rack-unit-1/bios/fw-updatableu�<firmwareUpdatable adminState='trigger' dn='sys/rack-unit-1/bios/fw-updatable'
    protocol='tftp' remoteServer='{0}' remotePath='{1}'
    type='blade-bios' />ucimc.set_config_modify(RRRR
RR
(RNtpathRRR((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pyttftp_update_bios�scC@sh|stjjd��n|s6tjjd��nd}dj||�}td||t�}|S(u.
    Update the CIMC firmware through TFTP.

    Args:
        server(str): The IP address or hostname of the TFTP server.

        path(str): The TFTP path and filename for the CIMC image.

    CLI Example:

    .. code-block:: bash

        salt '*' cimc.tftp_update_cimc foo.bar.com HP-SL2.bin

    u"The server name must be specified.u The TFTP path must be specified.u!sys/rack-unit-1/mgmt/fw-updatableu�<firmwareUpdatable adminState='trigger' dn='sys/rack-unit-1/mgmt/fw-updatable'
    protocol='tftp' remoteServer='{0}' remotePath='{1}'
    type='blade-controller' />ucimc.set_config_modify(RRRR
RR
(RNRTRRR((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pyttftp_update_cimc�s(5t__doc__t
__future__RRRtloggingtsalt.utils.platformRtsalt.proxy.cimct	getLoggert__name__tlogRRR
RtNoneRRRRRR R!R"R#R&R'R(R)R*R+R,R-R.R/R0R1R2R3R4R5R6R<R=R?RDRIRMRPRSRURV(((s5/usr/lib/python2.7/site-packages/salt/modules/cimc.pyt<module>sb	.																									@	!4 G(3"

Zerion Mini Shell 1.0