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

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddl	m
Z
ddlmZdgZ
yddlZeZWnek
r�eZnXiZiZeje�ZdZd�Zd�Zd	�Zd
�Zd�Zd�ZdS(
u�
Proxy Minion interface module for managing VMWare ESXi clusters.

Dependencies
============

- pyVmomi
- jsonschema

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

Pillar
------

Proxy minions get their configuration from Salt's Pillar. This can now happen
from the proxy's configuration file.

Example pillars:

``userpass`` mechanism:

.. code-block:: yaml

    proxy:
      proxytype: esxcluster
      cluster: <cluster name>
      datacenter: <datacenter name>
      vcenter: <ip or dns name of parent vcenter>
      mechanism: userpass
      username: <vCenter username>
      passwords: (required if userpass is used)
        - first_password
        - second_password
        - third_password

``sspi`` mechanism:

.. code-block:: yaml

    proxy:
      proxytype: esxcluster
      cluster: <cluster name>
      datacenter: <datacenter name>
      vcenter: <ip or dns name of parent vcenter>
      mechanism: sspi
      domain: <user domain>
      principal: <host kerberos principal>

proxytype
^^^^^^^^^
To use this Proxy Module, set this to ``esxdatacenter``.

cluster
^^^^^^^
Name of the managed cluster. Required.

datacenter
^^^^^^^^^^
Name of the datacenter the managed cluster is in. Required.

vcenter
^^^^^^^
The location of the VMware vCenter server (host of ip) where the datacenter
should be managed. Required.

mechanism
^^^^^^^^
The mechanism used to connect to the vCenter server. Supported values are
``userpass`` and ``sspi``. Required.

Note:
    Connections are attempted using all (``username``, ``password``)
    combinations on proxy startup.

username
^^^^^^^^
The username used to login to the host, such as ``root``. Required if mechanism
is ``userpass``.

passwords
^^^^^^^^^
A list of passwords to be used to try and login to the vCenter server. At least
one password in this list is required if mechanism is ``userpass``.  When the
proxy comes up, it will try the passwords listed in order.

domain
^^^^^^
User domain. Required if mechanism is ``sspi``.

principal
^^^^^^^^
Kerberos principal. Rquired if mechanism is ``sspi``.

protocol
^^^^^^^^
If the ESXi host is not using the default protocol, set this value to an
alternate protocol. Default is ``https``.

port
^^^^
If the ESXi host is not using the default port, set this value to an
alternate port. Default is ``443``.

Salt Proxy
----------

After your pillar is in place, you can test the proxy. The proxy can run on
any machine that has network connectivity to your Salt Master and to the
vCenter server in the pillar. SaltStack recommends that the machine running the
salt-proxy process also run a regular minion, though it is not strictly
necessary.

To start a proxy minion one needs to establish its identity <id>:

.. code-block:: bash

    salt-proxy --proxyid <proxy_id>

On the machine that will run the proxy, make sure there is a configuration file
present. By default this is ``/etc/salt/proxy``. If in a different location, the
``<configuration_folder>`` has to be specified when running the proxy:
file with at least the following in it:

.. code-block:: bash

    salt-proxy --proxyid <proxy_id> -c <configuration_folder>

Commands
--------

Once the proxy is running it will connect back to the specified master and
individual commands can be runs against it:

.. code-block:: bash

    # Master - minion communication
    salt <cluster_name> test.ping

    # Test vcenter connection
    salt <cluster_name> vsphere.test_vcenter_connection

States
------

Associated states are documented in
:mod:`salt.states.esxcluster </ref/states/all/salt.states.esxcluster>`.
Look there to find an example structure for Pillar as well as an example
``.sls`` file for configuring an ESX cluster from scratch.
i(tabsolute_importtprint_functiontunicode_literalsN(tEsxclusterProxySchema(tmergeu
esxclustercC@str
tStdfS(uA
    Only load if the vsphere execution module is available.
    u)The esxcluster proxy module did not load.(tHAS_JSONSCHEMAt__virtualname__tFalse(((s9/usr/lib/python2.7/site-packages/salt/proxy/esxcluster.pyt__virtual__�scC@s@tjdtj��tjd�tj�}tjd|�t|jdi�t	jdi��}tjd|�yt
j||�Wn+t
jj
k
r�}tjj|��nXxdD]}||t|<q�Wtd	d
krKd|krtjjd��nd
|kr)tjjd��nx�dD]}||t|<q0Wnad|krltjjd��nd|kr�tjjd��nxdD]}||t|<q�W|jd�td<|jd�td<td	d
kr<tjd�yt�\}}|td<Wq<tjjk
r8}tjd|�tSXntS(uq
    This function gets called when the proxy starts up. For
    login
    the protocol and port are cached.
    u.Initting esxcluster proxy module in process %su!Validating esxcluster proxy inputuschema = %suproxyuproxy_conf = %suvcenteru
datacenteruclusteru	mechanismuuserpassuusernameuLMechanism is set to 'userpass', but no 'username' key found in proxy config.u	passwordsuMMechanism is set to 'userpass', but no 'passwords' key found in proxy config.udomainuFMechanism is set to 'sspi', but no 'domain' key found in proxy config.u	principaluIMechanism is set to 'sspi', but no 'principal' key found in proxy config.uprotocoluportuORetrieving credentials and testing vCenter connection for mehchanism 'userpass'upasswordu	Error: %s(uvcenteru
datacenteruclusteru	mechanism(uusernameu	passwords(udomainu	principal(tlogtdebugtostgetpidRt	serializettraceRtgett
__pillar__t
jsonschematvalidatet
exceptionstValidationErrortsalttInvalidConfigErrortDETAILStfind_credentialstSaltSystemExittcriticalRtTrue(toptstschemat
proxy_conftexctkeytusernametpasswordterr((s9/usr/lib/python2.7/site-packages/salt/proxy/esxcluster.pytinit�sP
'
		
		

cC@stS(ug
    Returns True.

    CLI Example:

    .. code-block:: bash

        salt esx-cluster test.ping
    (R(((s9/usr/lib/python2.7/site-packages/salt/proxy/esxcluster.pytpings
cC@stjd�dS(u_
    Shutdown the connection to the proxy device. For this proxy,
    shutdown is a no-op.
    u%esxcluster proxy shutdown() called...N(R	R
(((s9/usr/lib/python2.7/site-packages/salt/proxy/esxcluster.pytshutdownscC@s�dtkr*dtkr*tdtdfStd}x6|D].}|td<td�s^q;ntd|fSWtjjd��dS(u]
    Cycle through all the possible credentials and return the first one that
    works.
    uusernameupasswordu	passwordsuvsphere.test_vcenter_connectionu3Cannot complete login due to incorrect credentials.N(Rt__salt__RRtVMwareConnectionError(t	passwordsR"((s9/usr/lib/python2.7/site-packages/salt/proxy/esxcluster.pyRs



cC@stS(u2
    Function that returns the cached details
    (R(((s9/usr/lib/python2.7/site-packages/salt/proxy/esxcluster.pytget_details1s(t__doc__t
__future__RRRtloggingRtsalt.exceptionsRtsalt.config.schemas.esxclusterRtsalt.utils.dictupdateRt__proxyenabled__RRRtImportErrorRtGRAINS_CACHERt	getLoggert__name__R	RRR$R%R&RR*(((s9/usr/lib/python2.7/site-packages/salt/proxy/esxcluster.pyt<module>�s,	


	
	?	
		

Zerion Mini Shell 1.0