%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/states/esxcluster.pyc

�
���^c@@sXdZddlmZmZmZddlZddlZddlZddlZ	ddl
mZddlm
Z
ddlmZddlmZmZddlmZyddlZeZWnek
r�eZnXydd	lmZeZWnek
reZnXeje�Zd
�Z d�Z!d�Z"d
�Z#d�Z$dd�Z&dS(u�
Manage VMware ESXi Clusters.

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

- pyVmomi Python Module


pyVmomi
-------

PyVmomi can be installed via pip:

.. code-block:: bash

    pip install pyVmomi

.. note::

    Version 6.0 of pyVmomi has some problems with SSL error handling on certain
    versions of Python. If using version 6.0 of pyVmomi, Python 2.7.9,
    or newer must be present. This is due to an upstream dependency
    in pyVmomi 6.0 that is not supported in Python versions 2.7 to 2.7.8. If the
    version of Python is not in the supported range, you will need to install an
    earlier version of pyVmomi. See `Issue #29537`_ for more information.

.. _Issue #29537: https://github.com/saltstack/salt/issues/29537

Based on the note above, to install an earlier version of pyVmomi than the
version currently listed in PyPi, run the following:

.. code-block:: bash

    pip install pyVmomi==5.5.0.2014.1.1

The 5.5.0.2014.1.1 is a known stable version that this original ESXi State
Module was developed against.
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(trecursive_diff(t	list_diff(tESXClusterConfigSchemat
LicenseSchema(t
dictupdate(tVmomiSupportcC@s[tstdfSts tdfSdtjkrWtjdkrWtjd	krWtdfStS(
Nu/State module did not load: jsonschema not foundu,State module did not load: pyVmomi not foundu	vim25/6.0iii	uaState module did not load: Incompatible versions of Python and pyVmomi present. See Issue #29537.(ii(iii	(tHAS_JSONSCHEMAtFalsetHAS_PYVMOMIR	t
versionMaptsystversion_infotTrue(((s:/usr/lib/python2.7/site-packages/salt/states/esxcluster.pyt__virtual__Js


cC@stS(uT
    Retrieves and adapt the login credentials from the proxy connection module
    (R(tlow((s:/usr/lib/python2.7/site-packages/salt/states/esxcluster.pytmod_initYscC@sotjd�gtdd|�D]}|ddkr!|^q!}|sgtjjdj|���n|dS(uRetrieves the vsan_datastoreuRetrieving vsan datastoreu!vsphere.list_datastores_via_proxytservice_instanceutypeuvsanu4No vSAN datastores where retrieved for cluster '{0}'i(tlogttracet__salt__tsaltt
exceptionstVMwareObjectRetrievalErrortformat(tsitcluster_nametdstvsan_datastores((s:/usr/lib/python2.7/site-packages/salt/states/esxcluster.pyt_get_vsan_datastore`s


	c
C@s3td�}|dkr4|td�d}}nM|dkrftd�dtd�d}}ntjjdj|���tjd	j|||��|}tjd
j|��t}i|d6id6d.d
6dd6}g}i}	t}y�tjd�t
j�}
tjdj|
��ytj
||
�Wn+tjjk
rf}tjj|��nXd.}td�}
ytd||d|
�}Wn�tjjk
r�t}tdr |jdj|||��tj|d�td|
�|jid.d
6dj|�d6�|Stjdj||��td|||d|
�|jdj||��tj|d�|	ji|d6�nX|r[d.}d|krPd|dkrPt|jdi�jdg�|jdi�jdg�d �}tjd!j|j��|dd=d|krPd|dkrP|dd=qPnt||�}tjd"j|j��|jp�|o�|js�|jd#j||��tj|d�q[t}d$}|jr�d%j||j�}n|r?|jr?d&j|djg|jjd�D]}d'j|�^q��}ntdrk|jd(j||||��q[|j}|j}|r�|jr�tj|ii|jd6d6�n|r�|jr�tj|ii|jd6d6�ntjd)j|��td*|||d|
�|jd+j||��tj|d�|	ji|d6|d,6�ntd|
�t}tdr�|r�d.}n|ji|d
6dj|�d6|	d6�|SWnttjjk
r.}tj d-j|t!j"���|
rtd|
�n|jitd
6t#j$|�d6�|SXd.S(/u�
    Configures a cluster. Creates a new cluster, if it doesn't exist on the
    vCenter or reconfigures it if configured differently

    Supported proxies: esxdatacenter, esxcluster

    name
        Name of the state. If the state is run in by an ``esxdatacenter``
        proxy, it will be the name of the cluster.

    cluster_config
        Configuration applied to the cluster.
        Complex datastructure following the ESXClusterConfigSchema.
        Valid example is:

    .. code-block::yaml

        drs:
            default_vm_behavior: fullyAutomated
            enabled: true
            vmotion_rate: 3
        ha:
            admission_control
            _enabled: false
            default_vm_settings:
                isolation_response: powerOff
                restart_priority: medium
            enabled: true
            hb_ds_candidate_policy: userSelectedDs
            host_monitoring: enabled
            options:
                - key: das.ignoreinsufficienthbdatastore
                  value: 'true'
            vm_monitoring: vmMonitoringDisabled
        vm_swap_placement: vmDirectory
        vsan:
            auto_claim_storage: false
            compression_enabled: true
            dedup_enabled: true
            enabled: true

    uvsphere.get_proxy_typeu
esxdatacenteruesxdatacenter.get_detailsu
datacenteru
esxclusteruesxcluster.get_detailsuclusteruUnsupported proxy {0}u1Running {0} for cluster '{1}' in datacenter '{2}'ucluster_dict =  {0}unameuchangesuresultuDefaultucommentu)Validating cluster_configured state inputuschema = {0}u&vsphere.get_service_instance_via_proxyuvsphere.list_clusterRutestu8State {0} will create cluster '{1}' in datacenter '{2}'.i����uvsphere.disconnectu
u,Creating cluster '{0}' in datacenter '{1}'. uvsphere.create_clusteru)Created cluster '{0}' in datacenter '{1}'unewuhauoptionsukeyuoptions diffs = {0}udiffs = {0}uDCluster '{0}' in datacenter '{1}' is up to date. Nothing to be done.uu{0}{1}u{0}
ha:
  options:
{1}u  {0}u<State {0} will update cluster '{1}' in datacenter '{2}':
{3}unew_values = {0}uvsphere.update_clusteru)Updated cluster '{0}' in datacenter '{1}'uolduError: {0}
{1}N(%RRRtCommandExecutionErrorRRtinfoRRtNoneRt	serializet
jsonschematvalidatetValidationErrortInvalidESXClusterPayloadErrorRRt__opts__tappendtupdatetjoinRtgettdiffsRtchanges_strtchanges_str2tsplitt
new_valuest
old_valuesRterrort	tracebackt
format_excRt	text_type(tnametcluster_configt
proxy_typeRtdatacenter_nametcluster_dicttchanges_requiredtrettcommentstchangestschematexctcurrentRtldifftdiffR/tlR2R3t
ret_status((s:/usr/lib/python2.7/site-packages/salt/states/esxcluster.pytcluster_configuredps�+









	
			4
		

		cC@sztd�dtd�d}}dj||�}tjdj|��i|d6id6dd6d	d
6}g}i}t}y�td�}	t|	|�}
|
d|kr�|jdj|
d��tj|d
�n�t}t	dr|jdj||��tj|d
�n�tj
dj|
d|��tdd|
dd|d|	�|jdj|��iii|d6d6i|
dd6d6d6}tj|d
�td|	�|ji|s�tnt	dr�dntd6dj|�d
6|d6�|SWnnt
jjk
ru}tjdj|tj���|	rStd|	�n|jitd6|jd
6�|SXdS(u�
    Configures the cluster's VSAN datastore

    WARNING: The VSAN datastore is created automatically after the first
    ESXi host is added to the cluster; the state assumes that the datastore
    exists and errors if it doesn't.
    uesxcluster.get_detailsuclusteru
datacenteru{0}/{1}u+Running vsan_datastore_configured for '{0}'unameuchangesuresultuDefaultucommentu&vsphere.get_service_instance_via_proxyu<vSAN datastore is correctly named '{0}'. Nothing to be done.i����utestu2State {0} will rename the vSAN datastore to '{1}'.u&Renaming vSAN datastore '{0}' to '{1}'uvsphere.rename_datastoretdatastore_nametnew_datastore_nameRu Renamed vSAN datastore to '{0}'.unewuolduvsan_datastoreuvsphere.disconnectu
uError: {0}
{1}N(RRRR"R#RR R*RR)RR+R,RRR!R4R5R6tstrerror(R8RIRR;tdisplay_nameR>R?R@R=Rtvsan_dsRB((s:/usr/lib/python2.7/site-packages/salt/states/esxcluster.pytvsan_datastore_configured!s`









	c
C@s�i|d6id6d2d6dd6}|s=tjjd��ntd�dtd�d	}}d
j||�}tjdj|��tjdj|��idd
6|d	6|d6}tjdj|��g}i}g}	g}
t	}t	}y�tjd�t
j�}
ytj
i|d6|
�Wn+tjjk
rW}tjj|��nXtd�}tdd|�}|}x�|j�D]r\}}g|D]}|d|kr�|^q�}|s�t}tdr
|jdj|||��tj|d�q�q�y#tdd|d|d|�}WnCtjjk
rr}|j|j�tj|d�t}q�nX|jdj|��tj|d�n1|jdj|��tj|d�|d}tjd�tdd |d!|d|�}|r
|dnd2}|rV|d|krV|jd"j||��tj|d�q�nt}|d#|d$kr�|jd%j||��tj|d�t}q�ntdr�|jd&j|||��tj|d�q�y-td'd(|d)|d |d!|d|�WnCtjjk
rR}|j|j�tj|d�t}q�nX|jd*j||��tj|d�tdd |d!|d|�d}d+|d<|r�d+|d<n|r�|d#tjkr�d,|d#<ni|d-6|d.6||<q�q�Wtd/|�|ji|s%tntdr5d2n|rAt	ntd6d0j|�d6tdsh|nid6�|SWnntjjk
r�}tjd1j|tj���|r�td/|�n|jit	d6|jd6�|SXd2S(3u�
    Configures licenses on the cluster entity

    Checks if each license exists on the server:
        - if it doesn't, it creates it
    Check if license is assigned to the cluster:
        - if it's not assigned to the cluster:
            - assign it to the cluster if there is space
            - error if there's no space
        - if it's assigned to the cluster nothing needs to be done
    unameuchangesuresultuDefaultucommentuNo licenses provideduesxcluster.get_detailsuclusteru
datacenteru{0}/{1}u%Running licenses configured for '{0}'ulicenses = {0}utypeuentity = {0}uValidating licensesulicensesu&vsphere.get_service_instance_via_proxyuvsphere.list_licensesRukeyutestuAState {0} will add license '{1}', and assign it to cluster '{2}'.i����uvsphere.add_licensetkeytdescriptionuAdded license '{0}'.u1License '{0}' already exists. Nothing to be done.iuChecking licensed entities...uvsphere.list_assigned_licensestentitytentity_display_nameuDLicense '{0}' already assigned to cluster '{1}'. Nothing to be done.ucapacityuuseduICannot assign license '{0}' to cluster '{1}'. No free capacity available.u5State {0} will assign license '{1}' to cluster '{2}'.uvsphere.assign_licensetlicense_keytlicense_nameu(Assigned license '{0}' to cluster '{1}'.u<hidden>u	Unlimitedunewuolduvsphere.disconnectu
uError: {0}
{1}N(R#RRtArgumentValueErrorRRRR"RRRR$R%R&R'tInvalidLicenseErrortitemsRR)R*tVMwareApiErrorterr_msgR4RtmaxsizeR+R,R!R5R6RK(R8tlicensesR>RR;RLRQR?R@told_licensestnew_licensest
has_errorst
needs_changesRARBRtexisting_licensestremaining_licensesRTtlicenseRFtfiltered_licensestexisting_licensetextassigned_licensestalready_assigned_licensetassigned_license((s:/usr/lib/python2.7/site-packages/salt/states/esxcluster.pytlicenses_configuredcs�






	








	










#	('t__doc__t
__future__RRRtloggingR5Rtsalt.exceptionsRtsalt.extRtsalt.utils.dictdifferRtsalt.utils.listdifferRtsalt.config.schemas.esxclusterRRt
salt.utilsRR%RR
tImportErrorRtpyVmomiR	Rt	getLoggert__name__RRRR RHRNR#Ri(((s:/usr/lib/python2.7/site-packages/salt/states/esxcluster.pyt<module>(s6





				�	B

Zerion Mini Shell 1.0