%PDF- %PDF-
| Direktori : /proc/self/root/proc/thread-self/root/lib/python2.7/site-packages/salt/proxy/ |
| Current File : //proc/self/root/proc/thread-self/root/lib/python2.7/site-packages/salt/proxy/esxvm.pyc |
�
���^c @@ s� d Z d d l m Z m Z m Z d d l Z d d l Z d d l j Z d d l
m Z d g Z i Z
i Z e j e � Z d Z d � Z d � Z d � Z d � Z d
� Z d � Z d S( uI
Proxy Minion interface module for managing VMWare ESXi virtual machines.
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: esxvm
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: esxvm
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 ``esxvm``.
datacenter
^^^^^^^^^^
Name of the datacenter where the virtual machine should be deployed. Required.
vcenter
^^^^^^^
The location of the VMware vCenter server (host of ip) where the virtual
machine 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 realm 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 <proxy_id> test.ping
# Test vcenter connection
salt <proxy_id> vsphere.test_vcenter_connection
States
------
Associated states are documented in
:mod:`salt.states.esxvm </ref/states/all/salt.states.esxvm>`.
Look there to find an example structure for Pillar as well as an example
``.sls`` file for configuring an ESX virtual machine from scratch.
i ( t absolute_importt print_functiont unicode_literalsN( t mergeu esxvmc C@ s t S( uA
Only load if the vsphere execution module is available.
( t __virtualname__( ( ( s4 /usr/lib/python2.7/site-packages/salt/proxy/esxvm.pyt __virtual__� s c C@ s� t j d t j � � t j d � t | j d i � t j d i � � } t j d | � x d D] } | | t | <qa Wt d d k r� d | k r� t j
d
� � n d | k r� t j
d � � n xz d D] } | | t | <q� Wn[ d
| k rt j
d � � n d | k r#t j
d � � n x d D] } | | t | <q*W| j d � t d <| j d � t d <t d d k r�t j d � y t � \ } } | t d <Wq�t j k
r�} t j
d | � t SXn t S( um
This function gets called when the proxy starts up. For
login the protocol and port are cached.
u) Initting esxvm proxy module in process %su Validating esxvm proxy inputu proxyu proxy_conf = %su vcenteru
datacenteru mechanismu userpassu usernameuV Mechanism is set to 'userpass' , but no 'username' key found in pillar for this proxy.u passwordsuW Mechanism is set to 'userpass' , but no 'passwords' key found in pillar for this proxy.u domainuP Mechanism is set to 'sspi' , but no 'domain' key found in pillar for this proxy.u principaluS Mechanism is set to 'sspi' , but no 'principal' key found in pillar for this proxy.u protocolu portuO Retrieving credentials and testing vCenter connection for mehchanism 'userpass'u passwordu Error: %s( u vcenteru
datacenteru mechanism( u usernameu passwords( u domainu principal( t logt debugt ost getpidR t gett
__pillar__t tracet DETAILSt excst InvalidProxyInputErrort find_credentialst SaltSystemExitt criticalt Falset True( t optst
proxy_conft keyt usernamet passwordt err( ( s4 /usr/lib/python2.7/site-packages/salt/proxy/esxvm.pyt init� sD
'
c C@ s t S( ub
Returns True.
CLI Example:
.. code-block:: bash
salt esx-vm test.ping
( R ( ( ( s4 /usr/lib/python2.7/site-packages/salt/proxy/esxvm.pyt ping� s
c C@ s t j d � d S( u_
Shutdown the connection to the proxy device. For this proxy,
shutdown is a no-op.
u! ESX vm proxy shutdown() called...N( R R ( ( ( s4 /usr/lib/python2.7/site-packages/salt/proxy/esxvm.pyt shutdown� s c C@ s� d t k r* d t k r* t d t d f St d d } x6 | D]. } | t d <t d � sb q? n t d | f SWt j d � � d S( u]
Cycle through all the possible credentials and return the first one that
works.
u usernameu passwordu proxyu passwordsu vsphere.test_vcenter_connectionu3 Cannot complete login due to incorrect credentials.N( R
R t __salt__R t VMwareConnectionError( t passwordsR ( ( s4 /usr/lib/python2.7/site-packages/salt/proxy/esxvm.pyR s
c C@ s t S( u2
Function that returns the cached details
( R
( ( ( s4 /usr/lib/python2.7/site-packages/salt/proxy/esxvm.pyt get_details s ( t __doc__t
__future__R R R t loggingR t salt.exceptionst
exceptionsR t salt.utils.dictupdateR t __proxyenabled__t GRAINS_CACHER
t getLoggert __name__R R R R R R R R! ( ( ( s4 /usr/lib/python2.7/site-packages/salt/proxy/esxvm.pyt <module>� s 9