Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/module_utils/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pyo

�
�Udac@`s�ddlmZmZmZeZddlZdZyddl	Z	e
ZWn#ek
roej
�ZeZnXdZy0ddlmZddlmZmZe
ZWn#ek
r�ej
�ZeZnXdZyxddlmZddlmZddlmZddlmZdd	lm Z m!Z!m"Z"m#Z#m$Z$m%Z%e
Z&Wn#ek
roej
�ZeZ&nXdd
l'm(Z(m)Z)de*fd��YZ+dS(
i(tabsolute_importtdivisiontprint_functionN(tconnect(tvimtvmodl(t	DynamicID(tcreate_vsphere_client(tUnauthorized(tItem(tFoldert
DatacentertResourcePoolt	DatastoretClustertHost(tenv_fallbacktmissing_required_libtVmwareRestClientcB`s�eZd�Zd�Zd�Zed��Zd�Zdddd�Z	ddd�Z
dd�Zdd�Zdd	�Z
dddd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zedd��ZRS(cC`s2||_|j|_|j�|j�|_dS(s
        Constructor

        N(tmoduletparamstcheck_required_librarytconnect_to_vsphere_clientt
api_client(tselfR((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pyt__init__1s	
cC`s^g}|js&t|t�r"dSdSx(|jD]}|j|j|j�q0Wdj|�S(sH
        Helper function to show human readable error messages.
        sAuthorization required.sGeneric error occurred.s ,(tmessagest
isinstanceRtappendtdefault_messagetargstjoin(Rterrorterr_msgterr((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pytget_error_message<s	cC`s�ts(|jjdtd�dt�ntsP|jjdtd�dt�nts~|jjdtddd�dt�ndS(	s+
        Check required libraries

        tmsgtrequestst	exceptiontPyVmomisvSphere Automation SDKturls<https://code.vmware.com/web/sdk/65/vsphere-automation-pythonN(	tHAS_REQUESTSRt	fail_jsonRtREQUESTS_IMP_ERRtHAS_PYVMOMItPYVMOMI_IMP_ERRtHAS_VSPHEREtVSPHERE_IMP_ERR(R((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pyRKs

		cC`s�tdtdddtdgf�dtdddtdgfdd	d
g�dtdddtdgfdd
dgdt�dtdddddddg�dtdddtdgfdt��S(NthostnamettypetstrtfallbacktVMWARE_HOSTtusernametVMWARE_USERtaliasestusertadmintpasswordtVMWARE_PASSWORDtpasstpwdtno_logtprotocoltdefaultthttpstchoicesthttptvalidate_certstbooltVMWARE_VALIDATE_CERTS(tdictRtTrue(((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pytvmware_client_argument_spec\s 	c	C`s�|jjd�}|jjd�}|jjd�}tj�}|jjd�|_t|||g�s�|jjdd�ntd|d|d|d|�}|d
kr�|jjdd	|�n|S(sK
        Connect to vSphere API Client with Username and Password

        R5R:R0RDR$spMissing one of the following : hostname, username, password. Please read the documentation for more information.tservertsessionsFailed to login to %sN(
RtgetR%tSessiontverifytallRR*RtNone(RR5R:R0RKtclient((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pyRps	cC`szg}|s|S|s(|jjj}n|s@|jjj}n|j|�}x$|D]}|j|j|��qVW|S(s
        Return list of tag objects associated with an object
        Args:
            dobj: Dynamic object
            tag_service: Tag service object
            tag_assoc_svc: Tag Association object
        Returns: List of tag objects associated with the given object
        (RttaggingtTagtTagAssociationtlist_attached_tagsRRL(Rttag_servicet
tag_assoc_svctdobjttagsttag_idsttag_id((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pytget_tags_for_object�s
cC`s�g}|dkr|Std|d|�}|jd|�}|jjj}xY|D]Q}|ji|jd6|j|j	�j
d6|j
d6|jd6|j	d6�qSW|S(	s

        Return list of tag object details associated with object
        Args:
            mid: Dynamic object for specified object
            type: Type of DynamicID to lookup

        Returns: List of tag object details associated with the given object

        R1tidRXt
category_nametnametdescriptiontcategory_idN(RPRR\RRRtCategoryRR]RLRaR_R`(RtmidR1RYtdynamic_managed_objectttemp_tags_modeltcategory_servicettag_obj((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pytget_tags_for_dynamic_obj�s

	


cC`s|jd|dd�S(s�
        Return list of tag object associated with cluster
        Args:
            cluster_mid: Dynamic object for cluster

        Returns: List of tag object associated with the given cluster

        RcR1tClusterComputeResource(Rh(Rtcluster_mid((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pytget_tags_for_cluster�s	cC`s|jd|dd�S(s�
        Return list of tag object associated with host system
        Args:
            hostsystem_mid: Dynamic object for host system

        Returns: List of tag object associated with the given host system

        RcR1t
HostSystem(Rh(Rthostsystem_mid((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pytget_tags_for_hostsystem�s	cC`s|jd|dd�S(s�
        Return list of tag object associated with virtual machine
        Args:
            vm_mid: Dynamic object for virtual machine

        Returns: List of tag object associated with the given virtual machine

        RcR1tVirtualMachine(Rh(Rtvm_mid((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pytget_tags_for_vm�s	cC`seg}|dkr|Stddd|�}|j|||�}x|D]}|j|j�qGW|S(sB
        Return list of tag name associated with virtual machine
        Args:
            tag_service:  Tag service object
            tag_association_svc: Tag association object
            vm_mid: Dynamic object for virtual machine

        Returns: List of tag names associated with the given virtual machine

        R1RoR]N(RPRR\RR_(RRVttag_association_svcRpRYRdReRg((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pytget_vm_tags�s

cC`sGtjd|�}|jjjjj|�}|r=|dnd}|S(s�
        Returns the identifier of the library item with the given name.

        Args:
            name (str): The name of item to look for

        Returns:
            str: The item ID or None if the item is not found
        R_iN(R	tFindSpecRtcontenttlibrarytfindRP(RR_t	find_spectitem_idstitem_id((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pytget_library_item_by_name�s
cC`s\tjdt|g��}|jjjj|�}t|�dkrR|djnd}|S(s�
        Returns the identifier of a datacenter
        Note: The method assumes only one datacenter with the mentioned name.
        tnamesiN(	Rt
FilterSpectsetRtvcentertlisttlent
datacenterRP(Rtdatacenter_nametfilter_spectdatacenter_summariesR�((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pytget_datacenter_by_names%cC`s�|j|�}|sdStjdtjjdt|g�dt|g��}|jjjj	|�}t
|�dkr�|djnd}|S(sV
        Returns the identifier of a folder
        with the mentioned names.
        R1R|tdatacentersiN(R�RPR
R}tTypetVIRTUAL_MACHINER~RRR�R�tfolder(RR�tfolder_nameR�R�tfolder_summariesR�((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pytget_folder_by_names%cC`s�|j|�}|sdS|r.t|g�nd}tjdt|g�d|�}|jjjj|�}t|�dkr�|dj	nd}|S(s]
        Returns the identifier of a resource pool
        with the mentioned names.
        R�R|iN(
R�RPR~RR}RRR�R�t
resource_pool(RR�tresourcepool_nameR�R|R�tresource_pool_summariesR�((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pytget_resource_pool_by_name%s	%cC`s�|j|�}|sdS|r.t|g�nd}tjdt|g�d|�}|jjjj|�}t|�dkr�|dj	nd}|S(sY
        Returns the identifier of a datastore
        with the mentioned names.
        R�R|iN(
R�RPR~R
R}RRR�R�t	datastore(RR�tdatastore_nameR�R|R�tdatastore_summariesR�((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pytget_datastore_by_name4s	%cC`s�|j|�}|sdS|r.t|g�nd}tjdt|g�d|�}|jjjj|�}t|�dkr�|dj	nd}|S(sW
        Returns the identifier of a cluster
        with the mentioned names.
        R�R|iN(
R�RPR~RR}RRR�R�tcluster(RR�tcluster_nameR�R|R�tcluster_summariesR�((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pytget_cluster_by_nameCs	%cC`s�|j|�}|sdS|r.t|g�nd}tjdt|g�d|�}|jjjj|�}t|�dkr�|dj	nd}|S(sT
        Returns the identifier of a Host
        with the mentioned names.
        R�R|iN(
R�RPR~RR}RRR�R�thost(RR�t	host_nameR�R|R�thost_summariesR�((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pytget_host_by_nameRs	%cC`sG|s
dSx6|j�D](}|j|�}|j|kr|SqWdS(s�
        Return service object by name
        Args:
            service: Service object
            svc_obj_name: Name of service object to find

        Returns: Service object if found else None

        N(RPR�RLR_(tservicetsvc_obj_namet
svc_objecttsvc_obj((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pytsearch_svc_object_by_nameasN(t__name__t
__module__RR#RtstaticmethodRIRRPR\RhRkRnRqRsR{R�R�R�R�R�R�R�(((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pyR0s(						
					(,t
__future__RRRR1t
__metaclass__t	tracebackRPR+R%RHR)tImportErrort
format_exctFalseR-tpyVimRtpyVmomiRRR,R/tcom.vmware.vapi.std_clientRtvmware.vapi.vsphere.clientRt!com.vmware.vapi.std.errors_clientRt!com.vmware.content.library_clientR	tcom.vmware.vcenter_clientR
RRR
RRR.tansible.module_utils.basicRRtobjectR(((sK/usr/lib/python2.7/site-packages/ansible/module_utils/vmware_rest_client.pyt<module>s<





.




Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]