%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
ddlZy ddlmZmZeZWnek
r�eZnXyddlmZeZWnek
r�eZnXeje�Zd�Zd	�Zd
�Zd�Z dd�Z"d
�Z#d�Z$eddd�Z%ddeed�Z&d�Z'd�Z(d�Z)dS(u^
Connection library for VMware vSAN endpoint

This library used the vSAN extension of the VMware SDK
used to manage vSAN related objects

:codeauthor: Alexandru Bleotu <alexandru.bleotu@morganstaley.com>

Dependencies
~~~~~~~~~~~~

- pyVmomi Python Module

pyVmomi
-------

PyVmomi can be installed via pip:

.. code-block:: bash

    pip install pyVmomi

.. note::

    versions of Python. If using version 6.0 of pyVmomi, Python 2.6,
    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 VMware utils file
was developed against.
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tVMwareApiErrortVMwareRuntimeErrortVMwareObjectRetrievalError(tvimtvmodl(tvsanapiutilscC@strtrtStdfSdS(u,
    Only load if PyVmomi is installed.
    u`Missing dependency: The salt.utils.vsan module requires pyvmomi and the pyvsan extension libraryN(t
HAS_PYVSANtHAS_PYVMOMItTruetFalse(((s3/usr/lib/python2.7/site-packages/salt/utils/vsan.pyt__virtual__JscC@s�y|jjj}Wn�tjjk
rS}tj|�tdj	|j
���nftjjk
r�}tj|�t|j��n2t
jk
r�}tj|�t|j��nXt|jd�d�dkr�tStS(u�
    Returns whether vsan is supported on the vCenter:
        api version needs to be 6 or higher

    service_instance
        Service instance to the host or vCenter
    u/Not enough permissions. Required privilege: {0}u.ii(tcontenttaboutt
apiVersionRtfaulttNoPermissiontlogt	exceptionRtformattprivilegeIdtVimFaulttmsgRtRuntimeFaultRtinttsplitR
R(tservice_instancetapi_versiontexc((s3/usr/lib/python2.7/site-packages/salt/utils/vsan.pytvsan_supportedUs
	

cC@scd}tjd dkr=tj�}t|_tj|_n|j	}t
j|d|�}|dS(	u�
    Returns a vim.cluster.VsanVcClusterConfigSystem object

    service_instance
        Service instance to the host or vCenter
    iiiitcontextuvsan-cluster-config-systemN(iii(tNonetsystversion_infotssltcreate_default_contextR
tcheck_hostnamet	CERT_NONEtverify_modet_stubR	tGetVsanVcMos(RR!tstubtvc_mos((s3/usr/lib/python2.7/site-packages/salt/utils/vsan.pytget_vsan_cluster_config_systemns
		cC@scd}tjd dkr=tj�}t|_tj|_n|j	}t
j|d|�}|dS(	u�
    Returns a vim.VimClusterVsanVcDiskManagementSystem object

    service_instance
        Service instance to the host or vCenter
    iiiiR!uvsan-disk-management-systemN(iii(R"R#R$R%R&R
R'R(R)R*R	R+(RR!R,R-((s3/usr/lib/python2.7/site-packages/salt/utils/vsan.pytget_vsan_disk_management_system�s
		c	C@s�|stjjj|�}ntjjjdddtj	dt
�}tjjj|tjddgd|d|�}|s�t
d	j|���ntjd
|�|ddS(
u�
    Returns a host's vsan system

    service_instance
        Service instance to the host or vCenter

    host_ref
        Refernce to ESXi host

    hostname
        Name of ESXi host. Default value is None.
    tpathuconfigManager.vsanSystemttypetskipt
property_listuconfig.enabledt
container_refttraversal_specu*Host's '{0}' VSAN system was not retrievedu[%s] Retrieved VSAN systemiuobject(tsalttutilstvmwaretget_managed_object_nameRtquerytPropertyCollectort
TraversalSpecRt
HostSystemR
tget_mors_with_propertiestHostVsanSystemRRRttrace(Rthost_refthostnameR5tobjs((s3/usr/lib/python2.7/site-packages/salt/utils/vsan.pytget_host_vsan_system�s
			cC@s�tjjj|�}|j}tjd||�tjdg|D]}|j^qA�tj	�}|g|_
||_t|dd�r�dnd|_
||_y|j|�}	Wn�tjjk
r�}
tj|
�tdj|
j���n�tjjk
r*}
tj|
�t|
j��notjjk
rg}
tj|
�tdj|
j���n2tjk
r�}
tj|
�t|
j��nXt|	g|�tS(	u�
    Creates a disk group

    service_instance
        Service instance to the host or vCenter

    vsan_disk_mgmt_system
        vim.VimClusterVsanVcDiskManagemenetSystem representing the vSan disk
        management system retrieved from the vsan endpoint.

    host_ref
        vim.HostSystem object representing the target host the disk group will
        be created on

    cache_disk
        The vim.HostScsidisk to be used as a cache disk. It must be an ssd disk.

    capacity_disks
        List of vim.HostScsiDisk objects representing of disks to be used as
        capacity disks. Can be either ssd or non-ssd. There must be a minimum
        of 1 capacity disk in the list.
    u;Creating a new disk group with cache disk '%s' on host '%s'ucapacity_disk_ids = %siussduallFlashuhybridu/Not enough permissions. Required privilege: {0}uMethod '{0}' not found(R6R7R8R9t
canonicalNameRtdebugR@Rt"VimVsanHostDiskMappingCreationSpect
cacheDiskst
capacityDiskstgetattrtcreationTypethosttInitializeDiskMappingsRRRRRRRRRtMethodNotFoundRtmethodRt_wait_for_tasksR(Rtvsan_disk_mgmt_systemRAt
cache_disktcapacity_disksRBt
cache_disk_idtctspecttaskR((s3/usr/lib/python2.7/site-packages/salt/utils/vsan.pytcreate_diskgroup�s:	
&			
	


cC@s�tjjj|�}|j}|j}tjd||�tjdg|D]}|j^qJ�t	j
�}	|g|	_||	_t
|dd�r�dnd|	_||	_y|j|	�}
Wn�t	jjk
r�}tj|�tdj|j���n�t	jjk
r3}tj|�t|j��nbtjjk
rp}tj|�tdj|j���n%tjk
r�}t|j��nXt|
g|�tS(	u�
    Adds capacity disk(s) to a disk group.

    service_instance
        Service instance to the host or vCenter

    vsan_disk_mgmt_system
        vim.VimClusterVsanVcDiskManagemenetSystem representing the vSan disk
        management system retrieved from the vsan endpoint.

    host_ref
        vim.HostSystem object representing the target host the disk group will
        be created on

    diskgroup
        The vsan.HostDiskMapping object representing the host's diskgroup where
        the additional capacity needs to be added

    new_capacity_disks
        List of vim.HostScsiDisk objects representing the disks to be added as
        capacity disks. Can be either ssd or non-ssd. There must be a minimum
        of 1 new capacity disk in the list.
    u?Adding capacity to disk group with cache disk '%s' on host '%s'unew_capacity_disk_ids = %siussduallFlashuhybridu/Not enough permissions. Required privilege: {0}uMethod '{0}' not found( R6R7R8R9tssdRERRFR@RRGRHRIRJRKRLRMRRRRRRRRRRNRRORRPR(RRQRAt	diskgrouptnew_capacity_disksRBRRRTRURVRWR((s3/usr/lib/python2.7/site-packages/salt/utils/vsan.pytadd_capacity_to_diskgroup�s>		
			
	

c
C@s�|stjjj|�}n|j}|j}tjd||�tjdg|D]}	|	j^qS�|s�t	|||�}nt
j�}
t
j�|
_
|r�t
jj|
j
_nt
jj|
j
_y|jd|d|
�}Wn�t
jjk
r(}tj|�tdj|j���nft
jjk
r\}tj|�t|j��n2tjk
r�}tj|�t|j��nXtjjj||d�tS(u}
    Removes capacity disk(s) from a disk group.

    service_instance
        Service instance to the host or vCenter

    host_vsan_system
        ESXi host's VSAN system

    host_ref
        Reference to the ESXi host

    diskgroup
        The vsan.HostDiskMapping object representing the host's diskgroup from
        where the capacity needs to be removed

    capacity_disks
        List of vim.HostScsiDisk objects representing the capacity disks to be
        removed. Can be either ssd or non-ssd. There must be a minimum
        of 1 capacity disk in the list.

    data_evacuation
        Specifies whether to gracefully evacuate the data on the capacity disks
        before removing them from the disk group. Default value is True.

    hostname
        Name of ESXi host. Default value is None.

    host_vsan_system
        ESXi host's VSAN system. Default value is None.
    uCRemoving capacity from disk group with cache disk '%s' on host '%s'ucapacity_disk_ids = %stdisktmaintenanceSpecu/Not enough permissions. Required privilege: {0}uremove_capacity( R6R7R8R9RYRERRFR@RDRtHostMaintenanceSpectVsanHostDecommissionModetvsanModet$VsanHostDecommissionModeObjectActiontevacuateAllDatatobjectActiontnoActiontRemoveDisk_TaskRRRRRRRRRRRt
wait_for_taskR(
RRARZRStdata_evacuationRBthost_vsan_systemRRRTRUt
maint_specRWR((s3/usr/lib/python2.7/site-packages/salt/utils/vsan.pytremove_capacity_from_diskgroup4s@#		
	

	

cC@s�|stjjj|�}n|jj}tjd||�|sXt|||�}nt	j
�}t	j�|_t	j
}	|r�|	j|j_n|	j|j_y|jd|gd|�}
Wn�t	jjk
r}tj|�tdj|j���nft	jjk
r6}tj|�t|j��n2tjk
rg}tj|�t|j��nXtjjj|
|d�tjd||�tS(u
    Removes a disk group.

    service_instance
        Service instance to the host or vCenter

    host_ref
        Reference to the ESXi host

    diskgroup
        The vsan.HostDiskMapping object representing the host's diskgroup from
        where the capacity needs to be removed

    hostname
        Name of ESXi host. Default value is None.

    host_vsan_system
        ESXi host's VSAN system. Default value is None.

    data_accessibility
        Specifies whether to ensure data accessibility. Default value is True.
    u5Removing disk group with cache disk '%s' on host '%s'tmappingR^u/Not enough permissions. Required privilege: {0}uremove_diskgroupu4Removed disk group with cache disk '%s' on host '%s'(R6R7R8R9RYRERRFRDRR_R`RaRbtensureObjectAccessibilityRdRetRemoveDiskMapping_TaskRRRRRRRRRRRRgR(RRARZRBRiterase_disk_partitionstdata_accessibilityRTRjt
object_actionRWR((s3/usr/lib/python2.7/site-packages/salt/utils/vsan.pytremove_diskgroup~s>	
		
	

	
cC@stjjj|�}tjd|�tjjj|�}t|�}y|j|�SWn�t	j
jk
r�}tj|�t
dj|j���nft	j
jk
r�}tj|�t
|j��n2tjk
r�}tj|�t|j��nXdS(u�
    Returns the extended cluster vsan configuration object
    (vim.VsanConfigInfoEx).

    cluster_ref
        Reference to the cluster
    u,Retrieving cluster vsan info of cluster '%s'u/Not enough permissions. Required privilege: {0}N(R6R7R8R9RR@t(get_service_instance_from_managed_objectR.tVsanClusterGetConfigRRRRRRRRRRRR(tcluster_reftcluster_nametsitvsan_cl_conf_sysR((s3/usr/lib/python2.7/site-packages/salt/utils/vsan.pytget_cluster_vsan_info�s"		
	

cC@s"tjjj|�}tjd||�tjjj|�}tjjj|�}y|j	||�}Wn�t
jjk
r�}tj
|�tdj|j���nft
jjk
r�}tj
|�t|j��n2tjk
r
}tj
|�t|j��nXt|g|�dS(u�
    Reconfigures the VSAN system of a cluster.

    cluster_ref
        Reference to the cluster

    cluster_vsan_spec
        Cluster VSAN reconfigure spec (vim.vsan.ReconfigSpec).
    u&Reconfiguring vsan on cluster '%s': %su/Not enough permissions. Required privilege: {0}N(R6R7R8R9RR@RstvsanR.tVsanClusterReconfigRRRRRRRRRRRRRP(Rutcluster_vsan_specRvRwRxRWR((s3/usr/lib/python2.7/site-packages/salt/utils/vsan.pytreconfigure_cluster_vsan�s(
	
		

	

cC@s(tjddjg|D]}tj|�^q��ytj||�Wn�tjj	k
r�}tj
|�tdj|j
���nftjjk
r�}tj
|�t|j��n2tjk
r�}tj
|�t|j��nXtjddjg|D]}tj|�^q��dS(u1
    Wait for tasks created via the VSAN API
    uWaiting for vsan tasks: {0}u, u/Not enough permissions. Required privilege: {0}uTasks %s finished successfullyN(RR@tjoinRt	text_typeR	tWaitForTasksRRRRRRRRRRRR(ttasksRttR((s3/usr/lib/python2.7/site-packages/salt/utils/vsan.pyRP�s 	,
	

	(*t__doc__t
__future__RRRR#tloggingR%tsalt.extRtsalt.exceptionsRRRtsalt.utils.vmwareR6tpyVmomiRRRRtImportErrorR
t
salt.ext.vsanR	R
t	getLoggert__name__RRR R.R/R"RDRXR\RkRrRyR}RP(((s3/usr/lib/python2.7/site-packages/salt/utils/vsan.pyt<module>+sD





					:	@G;		 

Zerion Mini Shell 1.0