%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/proxy/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/proxy/cimc.pyo

�
���^c@@s	dZddlmZmZmZddlZddlZddlZddl	m
ZdgZidd6Z
iZeje�ZdZd�Zd	�Zdded
�Zded�Zd�Zdd
�Zd�Zd�Zd�Zd�Zd�Zd�Z dS(u�
Proxy Minion interface module for managing Cisco Integrated Management Controller devices
=========================================================================================

.. versionadded:: 2018.3.0

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

This proxy minion enables Cisco Integrated Management Controller devices (hereafter referred to
as simply 'cimc' devices to be treated individually like a Salt Minion.

The cimc proxy leverages the XML API functionality on the Cisco Integrated Management Controller.
The Salt proxy must have access to the cimc on HTTPS (tcp/443).

More in-depth conceptual reading on Proxy Minions can be found in the
:ref:`Proxy Minion <proxy-minion>` section of Salt's
documentation.


Configuration
=============

To use this integration proxy module, please configure the following:

Pillar
------

Proxy minions get their configuration from Salt's Pillar. Every proxy must
have a stanza in Pillar and a reference in the Pillar top-file that matches
the ID.

.. code-block:: yaml

    proxy:
      proxytype: cimc
      host: <ip or dns name of cimc host>
      username: <cimc username>
      password: <cimc password>

proxytype
^^^^^^^^^

The ``proxytype`` key and value pair is critical, as it tells Salt which
interface to load from the ``proxy`` directory in Salt's install hierarchy,
or from ``/srv/salt/_proxy`` on the Salt Master (if you have created your
own proxy module, for example). To use this cimc Proxy Module, set this to
``cimc``.

host
^^^^

The location, or ip/dns, of the cimc host. Required.

username
^^^^^^^^

The username used to login to the cimc host. Required.

password
^^^^^^^^

The password used to login to the cimc host. Required.
i(tabsolute_importtprint_functiontunicode_literalsN(tElementTreeucimcuCiscouvendorcC@stS(u7
    Only return if all the modules are available.
    (t__virtualname__(((s3/usr/lib/python2.7/site-packages/salt/proxy/cimc.pyt__virtual__]scC@sd|dkr!tjd�tSd|dkrBtjd�tSd|dkrctjd�tSdj|dd�td	<id
d6dd
6dd6td<|ddtd<|djd�td<|djd�td<tjd�td�tjd�ttd<dS(u=
    This function gets called when the proxy starts up.
    uhostuproxyu-No 'host' key found in pillar for this proxy.uusernameu1No 'username' key found in pillar for this proxy.upasswordu2No 'passwords' key found in pillar for this proxy.uhttps://{0}/nuovauurlu!application/x-www-form-urlencodeduContent-Typei>uContent-Lengthulwp-request/2.06u
USER-Agentuheadersu)Attempting to connect to cimc proxy host.ucomputeRackUnitu*Successfully connected to cimc proxy host.uinitializedN(	tlogtcriticaltFalsetformattDETAILStgettdebugtget_config_resolver_classtTrue(topts((s3/usr/lib/python2.7/site-packages/salt/proxy/cimc.pytinitds(






cC@s�i}t�}d}|tkr*d}ndj||||�}tdtdd|ddd	d
dtdtd
tdtd�}tjd|d�d}tj	|�}	t
|�x!|	D]}
t|
�||
j<q�W|S(up
    The configConfMo method configures the specified managed object in a single subtree (for example, DN).
    ufalseutrueu`<configConfMo cookie="{0}" inHierarchical="{1}" dn="{2}"><inConfig>{3}</inConfig></configConfMo>u
http.queryuurltdatatmethoduPOSTtdecode_typeuplaintdecodet
verify_ssltraise_errortheadersuheadersu(<[\s\S.]*>)utexti(
tlogonRR	t	__utils__R
RtretfindalltETt
fromstringtlogouttprepare_returnttag(tdntinconfigthierarchicaltrettcookiethtpayloadtrtanswertitemstitem((s3/usr/lib/python2.7/site-packages/salt/proxy/cimc.pytset_config_modify�s*		


c
C@s�i}t�}d}|tkr*d}ndj|||�}tdtdd|ddd	d
dtdtd
tdtd�}tjd|d�d}tj	|�}t
|�x!|D]}	t|	�||	j<q�W|S(uZ
    The configResolveClass method returns requested managed object in a given class.
    ufalseutrueuE<configResolveClass cookie="{0}" inHierarchical="{1}" classId="{2}"/>u
http.queryuurlRRuPOSTRuplainRRRRuheadersu(<[\s\S.]*>)utexti(
RRR	RR
RRRRRRRR (
tcidR#R$R%R&R'R(R)R*R+((s3/usr/lib/python2.7/site-packages/salt/proxy/cimc.pyR
�s(		


cC@s�i}djtdtd�}tdtdd|ddd	d
dtdtd
tdtd�}tjd|d�d}tj|�}x"|j	D]}|j	|||<q�Wd|kr�t
jjd��n|dS(uC
    Logs into the cimc device and returns the session cookie.
    u3<aaaLogin inName='{0}' inPassword='{1}'></aaaLogin>uusernameupasswordu
http.queryuurlRRuPOSTRuplainRRRRuheadersu(<[\s\S.]*>)utextiu	outCookieu Unable to log into proxy device.(
R	R
RRRRRRRtattribtsaltt
exceptionstCommandExecutionError(tcontentR'R(R)R*R+((s3/usr/lib/python2.7/site-packages/salt/proxy/cimc.pyR�s"
cC@sSdj|�}tdtdd|ddddd	td
tdtdtd
�dS(u-
    Closes the session with the device.
    u3<aaaLogout cookie="{0}" inCookie="{0}"></aaaLogout>u
http.queryuurlRRuPOSTRuplainRRRRuheadersN(R	RR
RR(R%R'((s3/usr/lib/python2.7/site-packages/salt/proxy/cimc.pyR�scC@si}xMt|�D]?}|j|kr8g||j<n||jjt|��qWx"|jD]}|j|||<q`W|S(u$
    Converts the etree to dict
    (tlistR tappendRR.(txR$ta((s3/usr/lib/python2.7/site-packages/salt/proxy/cimc.pyR�scC@stjdt�S(u�
    Since grains are loaded in many different places and some of those
    places occur before the proxy can be initialized, return whether
    our init() function has been called
    uinitialized(R
RR(((s3/usr/lib/python2.7/site-packages/salt/proxy/cimc.pytinitialized�scC@sotjdi�sgttd<y%tdt�}|ddtd<Wqgtk
rc}tj|�qgXntdS(u0
    Get the grains from the proxied device
    ugrains_cacheucomputeRackUnitu
outConfigs(R
RtGRAINS_CACHER
Rt	ExceptionRterror(tcompute_rackterr((s3/usr/lib/python2.7/site-packages/salt/proxy/cimc.pytgrainss
cC@sdtd<t�S(u4
    Refresh the grains from the proxied device
    ugrains_cacheN(tNoneR
R=(((s3/usr/lib/python2.7/site-packages/salt/proxy/cimc.pytgrains_refreshs
cC@s?yt�}t|�Wn!tk
r:}tj|�tSXtS(u>
    Returns true if the device is reachable, else false.
    (RRR9RRRR(R%R<((s3/usr/lib/python2.7/site-packages/salt/proxy/cimc.pytpings	
cC@stjd�dS(u_
    Shutdown the connection to the proxy device. For this proxy,
    shutdown is a no-op.
    uCIMC proxy shutdown() called.N(RR(((s3/usr/lib/python2.7/site-packages/salt/proxy/cimc.pytshutdown#s(!t__doc__t
__future__RRRtloggingRtsalt.exceptionsR/tsalt._compatRRt__proxyenabled__R8R
t	getLoggert__file__RRRRR>RR,R
RRRR7R=R?R@RA(((s3/usr/lib/python2.7/site-packages/salt/proxy/cimc.pyt<module>Cs,	
		 							

Zerion Mini Shell 1.0