
    [~                     b   d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 ddl
mZ ddlZddlmZ ddlmZmZmZmZ dd	lmZ dd
lmZmZmZmZ ddlmZ 	  ej        d          Zda	 d Z G d de           Z! G d de          Z"ddddddddedddddddfdZ#	 	 	 	 d6dZ$d Z%d Z&efdZ'efdZ(d  Z)efd!Z*d" Z+d# Z,d$ Z- G d% d&e           Z. G d' d(e           Z/d) Z0d* Z1d+ Z2d, Z3dddddd-dddd.ddddd/eddfd0Z4d1ddddddedddddddfd2Z5d1ddddddeddddddfd3Z6d7d4Z7d5 Z8dS )8zU
Connect to a VMOMI ServiceInstance.

Detailed description (for [e]pydoc goes here).
    )reraiseN)ElementTree)
ExpatErrorhttp_client)HTTPBasicAuth)vimvmodlSoapStubAdapterSessionOrientedStub) CONNECTION_POOL_IDLE_TIMEOUT_SEC)nsMapversionIdMap
versionMapIsChildVersion)GetServiceVersionsz(^\[.+\]|[^:]+)(:\d+)?$c                 X    |s'| dv r#ddl }t          |d          r |j                    }|S )z
    Connections to 'localhost' do not need SSL verification as a certificate
    will never match. The OS provides security by only allowing root to bind
    to low-numbered ports.
    )	localhostz	127.0.0.1z::1r   N_create_unverified_context)sslhasattrr   )host
sslContextr   s      //usr/lib/python3/dist-packages/pyVim/connect.pylocalSslFixupr   9   sI      :$"CCC


3455 	:7799J    c                   $    e Zd ZdZd Zd Zd ZdS )closingzt
   Helper class for using closable objects in a 'with' statement,
   similar to the one provided by contextlib.
   c                     || _         d S Nobj)selfr"   s     r   __init__zclosing.__init__J   s    dhhhr   c                     | j         S r    r!   r#   s    r   	__enter__zclosing.__enter__L   s	    Xor   c                 8    | j                                          d S r    )r"   closer#   exc_infos     r   __exit__zclosing.__exit__N   s    
hnnr   N)__name__
__module____qualname____doc__r$   r'   r,    r   r   r   r   E   sK                 r   r   c                       e Zd ZdZej        j        fZedd            Z	ed             Z
edd            Ze	 dd            ZdS )VimSessionOrientedStubzyA vim-specific SessionOrientedStub.  See the SessionOrientedStub class
   in pyVmomi/SoapAdapter.py for more information.Nc                       fd}|S )Return a function that will call the vim.SessionManager.Login() method
      with the given parameters.  The result of this function can be passed as
      the "loginMethod" to a SessionOrientedStub constructor.c                     t          j        d|           }|j        j        }|j        s#|j        j                                       d S d S NServiceInstance)r	   r8   contentsessionManagercurrentSessionLogin)soapStubsismlocalepasswordusernames      r   _doLoginz<VimSessionOrientedStub.makeUserLoginMethod.<locals>._doLogin`   s[    !"3X>>j'! 
HJ%++HhGGGGG
H 
Hr   r1   )rB   rA   r@   rC   s   ``` r   makeUserLoginMethodz*VimSessionOrientedStub.makeUserLoginMethod[   s6    
H H H H H H H or   c                       fd}|S )r5   c                     t          j        d|           }|j        j        }|j        s!|j        j                                       d S d S r7   )r	   r8   r9   r:   r;   LoginExtensionByCertificate)r=   r>   r?   extensionKeys      r   rC   zAVimSessionOrientedStub.makeExtensionLoginMethod.<locals>._doLoginm   sW    !"3X>>j'! 
PJ%AA,OOOOO
P 
Pr   r1   )rH   rC   s   ` r   makeExtensionLoginMethodz/VimSessionOrientedStub.makeExtensionLoginMethodh   s(    
P P P P P or   c                       sJ  fd}|S )ar  Return a function that will call the vim.SessionManager.LoginByToken()
      after obtaining a HoK SAML token from the STS. The result of this function
      can be passed as the "loginMethod" to a SessionOrientedStub constructor.

      @param stsUrl: URL of the SAML Token issuing service. (i.e. SSO server).
      @param stsCert: public key of the STS service.
      c                    ddl m | j        d         }| j        d                             
	          }|                    |          fd}t          j        d|           }|j        j        }|j	        sk| 
                    |          5  	 | _        |j        j                                         d | _        n# d | _        w xY w	 d d d            d S # 1 swxY w Y   d S d S )N   sso	cert_filekey_filests_urlsts_certc                 2                         |           S r    )add_saml_context)requestkeysamlAssertionrN   s    r   _requestModifierz^VimSessionOrientedStub.makeCertHokTokenLoginMethod.<locals>._doLogin.<locals>._requestModifier   s    ''DDDr   r8   ) rN   
schemeArgsSsoAuthenticatorget_hok_saml_assertionr	   r8   r9   r:   r;   requestModifier	samlTokenLoginByToken)r=   certauthenticatorrY   r>   r?   rW   rX   rN   stsCertstsUrls         @@@r   rC   zDVimSessionOrientedStub.makeCertHokTokenLoginMethod.<locals>._doLogin   s   						$[1":.--f7> . @ @ '==d3GG
E 
E 
E 
E 
E 
E 
E !"3X>>j'! 
,))*:;; , ,,'4($*+88:::'+($$t($++++$, , , , , , , , , , , , , , , , , ,
, 
,s*   C%C=C	CCC#&C#r1   )rd   rc   rC   s   `` r   makeCertHokTokenLoginMethodz2VimSessionOrientedStub.makeCertHokTokenLoginMethodu   s4     nnn, , , , , ,. or   c                 6      sJ sJ sJ  fd}|S )a  Return a function that will call the vim.SessionManager.LoginByToken()
      after obtaining a Bearer token from the STS. The result of this function
      can be passed as the "loginMethod" to a SessionOrientedStub constructor.

      @param username: username of the user/service registered with STS.
      @param password: password of the user/service registered with STS.
      @param stsUrl: URL of the SAML Token issueing service. (i.e. SSO server).
      @param stsCert: public key of the STS service.
      c                 l   ddl m} | j        d         }| j        d         }|                    
	          }|                    ||          }t          j        d|           }|j        j        }|j	        s;	 || _
        |j        j                                         d | _
        d S # d | _
        w xY wd S )NrL   rM   rO   rP   rQ   r8   )rZ   rN   r[   r\   get_bearer_saml_assertionr	   r8   r9   r:   r;   r_   r`   )r=   rN   ra   rW   rb   rX   r>   r?   rA   rc   rd   rB   s           r   rC   zGVimSessionOrientedStub.makeCredBearerTokenLoginMethod.<locals>._doLogin   s    						#K0":.--f7> . @ @&@@AIAEADF F !"3X>>j'! 
))$1x!z(55777$(x!!!Dx!((((
) 
)s   :%B( (	B1r1   )rB   rA   rd   rc   rC   s   ```` r   makeCredBearerTokenLoginMethodz5VimSessionOrientedStub.makeCredBearerTokenLoginMethod   sX     nnn) ) ) ) ) ) ) )& or   r    )r-   r.   r/   r0   r	   faultNotAuthenticatedSESSION_EXCEPTIONSstaticmethodrD   rI   re   ri   r1   r   r   r3   r3   R   s        6 6
 
i  
 
 
 L
 
 
 L
 ! ! ! L!F  /3$ $ $ L$ $ $r   r3   r     rootrZ   hostdSOAP/sdkuserpassc                    	 t          j        t          |           }|}|                    d          } | d         dk    r|                    d          dd         } |                    d          *t	          |                    d          dd                   }n# t
          $ r
}Y d}~nd}~ww xY wt          | |          }|r|	J t          |         }	n|	sd}	d\  }}|d	k    rt          | ||||||	||
||||          \  }}n3|d
k    rt          | ||||	||
|||||          \  }}nt          d          t          |           |S )aQ  
   Connect to the specified server, login and return the service
   instance object.

   Throws any exception back to caller. The service instance object is
   also saved in the library for easy access.

   Clients should modify the service parameter only when connecting to
   a VMOMI server other than hostd/vpxd. For both of the latter, the
   default value is fine.

   @param host: Which host to connect to.
   @type  host: string
   @param port: Port
   @type  port: int
   @param user: User
   @type  user: string
   @param pwd: Password
   @type  pwd: string
   @param service: Service
   @type  service: string
   @param adapter: Adapter
   @type  adapter: string
   @param namespace: Namespace *** Deprecated: Use version instead ***
   @type  namespace: string
   @param path: Path
   @type  path: string
   @param connectionPoolTimeout: Timeout in secs for idle connections to close, specify negative numbers for never
                                 closing the connections
   @type  connectionPoolTimeout: int
   @param version: Version
   @type  version: string
   @param keyFile: ssl key file path
   @type  keyFile: string
   @param certFile: ssl cert file path
   @type  certFile: string
   @param thumbprint: host cert thumbprint
   @type  thumbprint: string
   @param sslContext: SSL Context describing the various SSL options. It is only
                      supported in Python 2.7.9 or higher.
   @type  sslContext: SSL.Context
   @param b64token: base64 encoded token
   @type  b64token: string
   @param mechanism: authentication mechanism: userpass or sspi
   @type  mechanism: string
   NrL   r   [   zvim.version.version6)NNrs   sspizoThe provided connection mechanism is not available, the
              supported mechanisms are userpass or sspi)rematch_rxgroupint
ValueErrorr   r   __Login__LoginBySSPI	ExceptionSetSi)r   portuserpwdserviceadapter	namespacepathconnectionPoolTimeoutversionkeyFilecertFile
thumbprintr   b64token	mechanisminfover>   stubs                       r   Connectr      s   f	Xc4  d		

1GsNN::a==2&DJJqMM%tzz!}}QRR())D
   
dddd dJ//: '___9%gg '&g82t:tT3'4 (J
DY[ [hb$$VtT7GWd&*j(Tik khb$$  ; < < < 	999
9s   BB 
B0+B0c                     t          t          d          rt          j                    }nd}t          | |||||||||	|
||||          S )a/  
   Provides a standard method for connecting to a specified server without SSL
   verification. Useful when connecting to servers with self-signed certificates
   or when you wish to ignore SSL altogether. Will attempt to create an unverified
   SSL context and then connect via the Connect method.
   r   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s                  r   ConnectNoSSLr     so     c/00 133jjj
t!!%!!#''#%' ' ' 'r   c                 B    t          |            t          d           dS zc
   Disconnect (logout) service instance
   @param si: Service instance (returned from Connect)
   N)__Logoutr   r>   s    r   
Disconnectr   6  s     B<<<;;;;;r   c                    	 | j         j        }nt# t          $ rg}t          |          j        dk    r%d|z  }t
          j                            |          d|z  }t
          j                            |          d }~ww xY w|                    |          }t          |j
                  5 }|                                }d d d            n# 1 swxY w Y   |j        |fS )Nr   z8Malformed response while querying for local ticket: "%s"msgz&Failed to query for local ticket: "%s")userName)r9   r:   r   typer-   r	   rj   HostConnectFaultAcquireLocalTicketopenpasswordFilePathreadr   )r>   r   r:   er   localTicketfr9   s           r   GetLocalTicketr   A  s"   3z0nn
 3 3 3	a	\	)	)IAMy))c)22	27!;y))c)22	23  22D2AA;[)** ag              


''s'    
B A"A;;B -CCCc                    t          | ||||||	|
||
  
        \  }}}| dk    r|s	 t          ||          \  }}n#  Y nxY w	 |j                            ||d          }n'# t          j        j        $ r  t          $ r} d}~ww xY w||fS )aC  
   Private method that performs the actual Connect and returns a
   connected service instance object.

   @param host: Which host to connect to.
   @type  host: string
   @param port: Port
   @type  port: int
   @param user: User
   @type  user: string
   @param pwd: Password
   @type  pwd: string
   @param service: Service
   @type  service: string
   @param adapter: Adapter
   @type  adapter: string
   @param version: Version
   @type  version: string
   @param path: Path
   @type  path: string
   @param keyFile: ssl key file path
   @type  keyFile: string
   @param certFile: ssl cert file path
   @type  certFile: string
   @param thumbprint: host cert thumbprint
   @type  thumbprint: string
   @param sslContext: SSL Context describing the various SSL options. It is only
                      supported in Python 2.7.9 or higher.
   @type  sslContext: SSL.Context
   @param connectionPoolTimeout: Timeout in secs for idle connections to close, specify negative numbers for never
                                 closing the connections
   @type  connectionPoolTimeout: int
   r   N)__RetrieveContentr   r:   r<   r	   rj   InvalidLoginr   )r   r   r   r   r   r   r   r   r   r   r   r   r   r9   r>   r   xr   s                     r   r   r   T  s    J )tWgt)0(J
Tik k7B k#%b$//$	

 
&
&tS$
7
7aa
)
    
   
d(?s    : >A B=A>>Bc                     t          | ||||||||	|
  
        \  }}}|
t          d          	 |j                            |
          }n'# t          j        j        $ r  t          $ r} d}~ww xY w||fS )a-  
   Private method that performs the actual Connect and returns a
   connected service instance object.

   @param host: Which host to connect to.
   @type  host: string
   @param port: Port
   @type  port: int
   @param service: Service
   @type  service: string
   @param adapter: Adapter
   @type  adapter: string
   @param version: Version
   @type  version: string
   @param path: Path
   @type  path: string
   @param keyFile: ssl key file path
   @type  keyFile: string
   @param certFile: ssl cert file path
   @type  certFile: string
   @param thumbprint: host cert thumbprint
   @type  thumbprint: string
   @param sslContext: SSL Context describing the various SSL options. It is only
                      supported in Python 2.7.9 or higher.
   @type  sslContext: SSL.Context
   @param b64token: base64 encoded token
   @type  b64token: string
   @param connectionPoolTimeout: Timeout in secs for idle connections to close, specify negative numbers for never
                                 closing the connections
   @type  connectionPoolTimeout: int
   Nz#Token is not defined for sspi login)r   r   r:   LoginBySSPIr	   rj   r   )r   r   r   r   r   r   r   r   r   r   r   r   r9   r>   r   r   r   s                    r   r   r     s    F )tWgt)0(J
Tik k7B ;<<<

 
,
,X
6
6aa
)
    
   
d(?s   A
 
A.(A))A.c                     	 | r/|                                  }|j                                         dS dS # t          $ r}Y d}~dS d}~ww xY wr   )RetrieveContentr:   Logoutr   )r>   r9   r   s      r   r   r     ss    
	 )%%''			&	&	(	(	(	(	() )    
ddddds   /5 
A
A
c
                 4   |dk    rt          |          t          | ||||||||		  	        }
t          j        d|
          }d}	 |                                }n# t
          j        $ r  t          $ r}t          j	                    \  }}}|rNt          j
                            t          |                    }t          t          j
        j        ||           n-t          j
                            t          |                    Y d}~nd}~ww xY w|||
fS )a  
   Retrieve service instance for connection.
   @param host: Which host to connect to.
   @type  host: string
   @param port: Port
   @type  port: int
   @param adapter: Adapter
   @type  adapter: string
   @param version: Version
   @type  version: string
   @param path: Path
   @type  path: string
   @param keyFile: ssl key file path
   @type  keyFile: string
   @param certFile: ssl cert file path
   @type  certFile: string
   @param connectionPoolTimeout: Timeout in secs for idle connections to close, specify negative numbers for never
                                 closing the connections
   @type  connectionPoolTimeout: int
   rq   )r   r   certKeyFiler   r   r   r   r8   Nr   )r~   r   r	   r8   r   r
   MethodFaultr   sysr+   rj   r   strr   )r   r   r   r   r   r   r   r   r   r   r   r>   r9   r   r   value	tracebackrj   s                     r   r   r     sG   0 w $gD&-%/J0EG G G4 	-t44277""$$gg

   
 7 7 7 "%tUI	 7++A+77	+UI	>	>	>	>	**s1vv*66
6 
?	>	>	>	>7 2t
s   A D4BDDc                      t           S )z! Get the saved service instance. _sir1   r   r   GetSir     s    
:r   c                 
    | a dS )z! Set the saved service instance. Nr   r   s    r   r   r     s     
333r   c                  N    t                      } | r|                                 S dS )z Get the global saved stub. N)r   _GetStubr   s    r   GetStubr     s&    2 [[]]
$r   c                        e Zd Zd Zd Zd ZdS )
Connectionc                 0    || _         || _        d | _        d S r    argskwargsr>   r#   r   r   s      r   r$   zConnection.__init__'      didkdgggr   c                 F    t          | j        i | j        | _        | j        S r    )r   r   r   r>   r&   s    r   r'   zConnection.__enter__,  s!    2dk22dgWnr   c                 N    | j         rt          | j                    d | _         d S d S r    r>   r   r*   s     r   r,   zConnection.__exit__0  1    	 	DG			 r   Nr-   r.   r/   r$   r'   r,   r1   r   r   r   r   &  A          
      r   r   c                        e Zd Zd Zd Zd ZdS )SmartConnectionc                 0    || _         || _        d | _        d S r    r   r   s      r   r$   zSmartConnection.__init__6  r   r   c                 F    t          | j        i | j        | _        | j        S r    )SmartConnectr   r   r>   r&   s    r   r'   zSmartConnection.__enter__;  s!    di74;77dgWnr   c                 N    | j         rt          | j                    d | _         d S d S r    r   r*   s     r   r,   zSmartConnection.__exit__?  r   r   Nr   r1   r   r   r   r   5  r   r   r   c                    | dk    r|rd|ini }t          j        |fd|i|}n2| dk    rt          j        ||          }nt          d| z   dz             |                    d|           |                                }|j        d	k    r9	 t          j        |	                                          }|S # t          $ r Y nw xY wd
S )a  
   Private method that returns a root from ElementTree for a remote XML document.

   @param protocol: What protocol to use for the connection (e.g. https or http).
   @type  protocol: string
   @param server: Which server to connect to.
   @type  server: string
   @param port: Port
   @type  port: int
   @param path: Path
   @type  path: string
   @param sslContext: SSL Context describing the various SSL options. It is only
                      supported in Python 2.7.9 or higher.
   @type  sslContext: SSL.Context
   httpscontextr   http)r   z	Protocol z not supported.GET   N)r   HTTPSConnectionHTTPConnectionr   rV   getresponsestatusr   
fromstringr   r   )	protocolserverr   r   r   r   connresponsetrees	            r   __GetElementTreer   D  s    " '*4<	:&&"f(EEdEfEEddF'T:::ddkH,/@@AAA<<t  8o&x}}77   	
$s   'B4 4
C Cc                 f    t          | |||dz   |          }||S t          | |||dz   |          }|S )a  
   Private method that returns a root from an ElementTree describing the API versions
   supported by the specified server.  The result will be vimServiceVersions.xml
   if it exists, otherwise vimService.wsdl if it exists, otherwise None.

   @param protocol: What protocol to use for the connection (e.g. https or http).
   @type  protocol: string
   @param server: Which server to connect to.
   @type  server: string
   @param port: Port
   @type  port: int
   @param path: Path
   @type  path: string
   @param sslContext: SSL Context describing the various SSL options. It is only
                      supported in Python 2.7.9 or higher.
   @type  sslContext: SSL.Context
   z/vimServiceVersions.xmlNz/vimService.wsdl)r   )r   r   r   r   r   r   s         r   __GetServiceVersionDescriptionr   j  sX    & 8VT";;ZI I4
k
8VT"44jB B4
;r   c                    |}|j         dk    r|                    d          dk    r%t          d|                    d          z            t          |          }d}|                    d          D ]G}|                    d          }||k    r dS |                    d          D ]}|j        |k    r  dS HnTd	}|                    d
|z            }t          |                    d          dd                  }t          ||           rdS dS )a  
   Private method that returns true if the service version description document
   indicates that the desired version is supported

   @param desiredVersion: The version we want to see if the server supports
                          (eg. vim.version.version2.
   @type  desiredVersion: string
   @param serviceVersionDescription: A root ElementTree for vimServiceVersions.xml
                                     or vimService.wsdl.
   @type  serviceVersionDescription: root ElementTree
   
namespacesr   z1.0z>vimServiceVersions.xml has version %s, which is not understoodNr   TzpriorVersions/versionz http://schemas.xmlsoap.org/wsdl/z.//{%s}import   F)
taggetRuntimeErrorr   findallfindtexttextfindr   r   )	desiredVersionserviceVersionDescriptionro   desiredVersionIdsupportedVersionr   	versionIdwsdlNSimportElements	            r   __VersionIsSupportedr     sP    $4
h,	)			%	% (+/88I+>+>@ A A 
A%n5||K00  )''	22)))44&../FGG  	.$444 5 2f/44_v5MNNm#M$5$5k$B$B122$FG	(.	9	9 
%r   c                     t          | ||||          }|dS t          |t                    s|g}|D ]}t          ||          r|c S dS )aL  
   Private method that returns the most preferred API version supported by the
   specified server,

   @param protocol: What protocol to use for the connection (e.g. https or http).
   @type  protocol: string
   @param server: Which server to connect to.
   @type  server: string
   @param port: Port
   @type  port: int
   @param path: Path
   @type  path: string
   @param preferredApiVersions: Acceptable API version(s) (e.g. vim.version.version3)
                                If a list of versions is specified the versions should
                                be ordered from most to least preferred.
   @type  preferredApiVersions: string or string list
   @param sslContext: SSL Context describing the various SSL options. It is only
                      supported in Python 2.7.9 or higher.
   @type  sslContext: SSL.Context
   N)r   
isinstancelistr   )r   r   r   r   preferredApiVersionsr   r   r   s           r   __FindSupportedVersionr     s    ,  >h>D>B>B>H	 J  J
  'T
)4
0
0 635-  ~	n.G	H	H 			
$r      P   Tc                 *   |t          d          }t          | |          }t          |dk    rdnd| ||||          }|t          | d|d          t	          di d| d	|d
|d|d|d|d|d|d|d|	d|
d|d|d|d|d|d|d|S )a  
   Determine the most preferred API version supported by the specified server,
   then create a soap stub adapter using that version

   The parameters are the same as for pyVmomi.SoapStubAdapter except for
   version which is renamed to prefferedApiVersions

   @param preferredApiVersions: Acceptable API version(s) (e.g. vim.version.version3)
                                If a list of versions is specified the versions should
                                be ordered from most to least preferred.  If None is
                                specified, the list of versions support by pyVmomi will
                                be used.
   @type  preferredApiVersions: string or string list
   Nvim25r   r   r   : is not a VIM serverr   r   r   urlsockpoolSizer   r   httpProxyHosthttpProxyPortsslProxyPathr   cacertsFiler   acceptCompressedResponsesr   r_   r   r1   )r   r   r   r   r   )r   r   r   r  r  r  r   r   r	  r
  r  r   r  r   r  r   r_   r   r   s                      r   SmartStubAdapterr    st   , "/88dJ//:,qWWf-1-1-1-A-79 9 TTT444@AAA
 F F Ftt F$$ FTT F!cF(,F7?xF#+8F9DF )6F FS]F (4|	F AK
	F
 '2kF
 <L;KF 5N4MF 1F0EF %.IF ;E*F Fr   r   c                     |t          d          }t          ||          }t          | |||||          }|t          |d|d          | dk    rt	          |           pt	          |          }t          |||||d||||	|
||||          S )au  
   Determine the most preferred API version supported by the specified server,
   then connect to the specified server using that API version, login and return
   the service instance object.

   Throws any exception back to caller. The service instance object is
   also saved in the library for easy access.

   Clients should modify the service parameter only when connecting to
   a VMOMI server other than hostd/vpxd. For both of the latter, the
   default value is fine.

   @param protocol: What protocol to use for the connection (e.g. https or http).
   @type  protocol: string
   @param host: Which host to connect to.
   @type  host: string
   @param port: Port
   @type  port: int
   @param user: User
   @type  user: string
   @param pwd: Password
   @type  pwd: string
   @param service: Service
   @type  service: string
   @param path: Path
   @type  path: string
   @param connectionPoolTimeout: Timeout in secs for idle connections to close, specify negative numbers for never
                                 closing the connections
   @type  connectionPoolTimeout: int
   @param preferredApiVersions: Acceptable API version(s) (e.g. vim.version.version3)
                                If a list of versions is specified the versions should
                                be ordered from most to least preferred.  If None is
                                specified, the list of versions support by pyVmomi will
                                be used.
   @type  preferredApiVersions: string or string list
   @param keyFile: ssl key file path
   @type  keyFile: string
   @param certFile: ssl cert file path
   @type  certFile: string
   @param thumbprint: host cert thumbprint
   @type  thumbprint: string
   @param sslContext: SSL Context describing the various SSL options. It is only
                      supported in Python 2.7.9 or higher.
   @type  sslContext: SSL.Context
   Nr  r  r  r   rq   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r}   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   
portNumbers                    r   r   r     s    d "/88dJ//:,X-1-1-1-A-79 9 TTT444@AAAF"1D		z>SYY:
t!! *(=!#''#%' ' ' 'r   c                     t          t          d          rt          j                    }nd}t          | |||||||||	|
||||          S )a4  
   Provides a standard method for connecting to a specified server without SSL
   verification. Useful when connecting to servers with self-signed certificates
   or when you wish to ignore SSL altogether. Will attempt to create an unverified
   SSL context and then connect via the SmartConnect method.
   r   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s                  r   SmartConnectNoSSLr  Z  so     c/00 133jjj
   & -B,@& (",", (!*, , , ,r   c                 L    t          j        | t          ||          d          S )z
   Open the specified URL, using HTTP basic authentication to provide
   the specified credentials to the server as part of the request.
   Returns the response as a file-like object.
   F)authverify)requestsr   r   )r  r   r   s      r   OpenUrlWithBasicAuthr  z  s%     ,stS!9!9%
H
H
HHr   c                 f   ddl m} t          |d          st          j                                        |j        |j        k    rd}n1|j        |j        k    rd}nt          j                                        |j	        }|d|| }i }|j
        r
|j
        |d<   t          j        ||d	          S )
z
   Open the specified path using HTTP, using the host/port/protocol
   associated with the specified stub.  If the stub has a session cookie,
   it is included with the HTTP request.  Returns the response as a
   file-like object.
   r   r   schemer   r   z://CookieF)headersr  )	six.movesr   r   r
   rj   NotSupportedr  r   r   r   cookier  r   )r   r   r   r   hostPortr  r  s          r   OpenPathWithStubr     s     %$$$$$
$
!
! 'K$$&&&{111hh{222hhK$$&&&i8 ((DD	137
k &+gh
,sGE
:
:
::r   )r   rn   ro   rZ   rp   rq   Nrr   NNNNNrs   )ro   rZ   )9r0   sixr   r   ry   r   	xml.etreer   xml.parsers.expatr   r  r   r  requests.authr   pyVmomir	   r
   r   r   pyVmomi.SoapAdapterr   pyVmomi.VmomiSupportr   r   r   r   r   compiler{   r   r   objectr   r3   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r  r  r   r1   r   r   <module>r*     s  * 
       



 				 



 ! ! ! ! ! ! ( ( ( ( ( ( ! ! ! ! ! !  ' ' ' ' ' ' D D D D D D D D D D D D @ @ @ @ @ @ P P P P P P P P P P P P 3 3 3 3 3 3 bj+,,

 
 

 
 
 
 
f 
 
 
l l l l l0 l l l^ 3VVt&"B$$dj	S S S Sj ?AGMGK*4' ' ' '@  ( ( (* #C7 7 7 7~ )I0 0 0 0h
 
 
 Ee5 5 5 5t                 f        L  @$ $ $T$ $ $L &CfD1"#'r $$T/3+K#,F ,F ,F ,F\ "#FPR vEe&*D4 TDJP' P' P' P'd  '[sUW%FJj+/!%
, , , ,@I I I I; ; ; ; ;r   