commit
6facddd2e5
163
pyVim/connect.py
163
pyVim/connect.py
@ -179,7 +179,7 @@ class VimSessionOrientedStub(SessionOrientedStub):
|
||||
def Connect(host='localhost', port=443, user='root', pwd='',
|
||||
service="hostd", adapter="SOAP", namespace=None, path="/sdk",
|
||||
version=None, keyFile=None, certFile=None, thumbprint=None,
|
||||
sslContext=None):
|
||||
sslContext=None, b64token=None, mechanism='userpass'):
|
||||
"""
|
||||
Connect to the specified server, login and return the service
|
||||
instance object.
|
||||
@ -218,6 +218,10 @@ def Connect(host='localhost', port=443, user='root', pwd='',
|
||||
@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
|
||||
"""
|
||||
try:
|
||||
info = re.match(_rx, host)
|
||||
@ -234,9 +238,19 @@ def Connect(host='localhost', port=443, user='root', pwd='',
|
||||
assert(version is None)
|
||||
version = versionMap[namespace]
|
||||
elif not version:
|
||||
version="vim.version.version6"
|
||||
si, stub = __Login(host, port, user, pwd, service, adapter, version, path,
|
||||
keyFile, certFile, thumbprint, sslContext)
|
||||
version = "vim.version.version6"
|
||||
|
||||
si, stub = None, None
|
||||
if mechanism == 'userpass':
|
||||
si, stub = __Login(host, port, user, pwd, service, adapter, version, path,
|
||||
keyFile, certFile, thumbprint, sslContext)
|
||||
elif mechanism == 'sspi':
|
||||
si, stub = __LoginBySSPI(host, port, service, adapter, version, path,
|
||||
keyFile, certFile, thumbprint, sslContext, b64token)
|
||||
else:
|
||||
raise Exception('''The provided connection mechanism is not available, the
|
||||
supported mechanisms are userpass or sspi''')
|
||||
|
||||
SetSi(si)
|
||||
|
||||
return si
|
||||
@ -303,33 +317,8 @@ def __Login(host, port, user, pwd, service, adapter, version, path,
|
||||
@type sslContext: SSL.Context
|
||||
"""
|
||||
|
||||
# XXX remove the adapter and service arguments once dependent code is fixed
|
||||
if adapter != "SOAP":
|
||||
raise ValueError(adapter)
|
||||
|
||||
# Create the SOAP stub adapter
|
||||
stub = SoapStubAdapter(host, port, version=version, path=path,
|
||||
certKeyFile=keyFile, certFile=certFile,
|
||||
thumbprint=thumbprint, sslContext=sslContext)
|
||||
|
||||
# Get Service instance
|
||||
si = vim.ServiceInstance("ServiceInstance", stub)
|
||||
try:
|
||||
content = si.RetrieveContent()
|
||||
except vmodl.MethodFault:
|
||||
raise
|
||||
except Exception as e:
|
||||
# NOTE (hartsock): preserve the traceback for diagnostics
|
||||
# pulling and preserving the traceback makes diagnosing connection
|
||||
# failures easier since the fault will also include where inside the
|
||||
# library the fault occurred. Without the traceback we have no idea
|
||||
# why the connection failed beyond the message string.
|
||||
(type, value, traceback) = sys.exc_info()
|
||||
if traceback:
|
||||
fault = vim.fault.HostConnectFault(msg=str(e))
|
||||
reraise(vim.fault.HostConnectFault, fault, traceback)
|
||||
else:
|
||||
raise vim.fault.HostConnectFault(msg=str(e))
|
||||
content, si, stub = __RetrieveContent(host, port, adapter, version, path,
|
||||
keyFile, certFile, thumbprint, sslContext)
|
||||
|
||||
# Get a ticket if we're connecting to localhost and password is not specified
|
||||
if host == 'localhost' and not pwd:
|
||||
@ -348,6 +337,55 @@ def __Login(host, port, user, pwd, service, adapter, version, path,
|
||||
raise
|
||||
return si, stub
|
||||
|
||||
## Private method that performs LoginBySSPI and returns a
|
||||
## connected service instance object.
|
||||
## Copyright (c) 2015 Morgan Stanley. All rights reserved.
|
||||
|
||||
def __LoginBySSPI(host, port, service, adapter, version, path,
|
||||
keyFile, certFile, thumbprint, sslContext, b64token):
|
||||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
content, si, stub = __RetrieveContent(host, port, adapter, version, path,
|
||||
keyFile, certFile, thumbprint, sslContext)
|
||||
|
||||
if b64token is None:
|
||||
raise Exception('Token is not defined for sspi login')
|
||||
|
||||
# Login
|
||||
try:
|
||||
x = content.sessionManager.LoginBySSPI(b64token)
|
||||
except vim.fault.InvalidLogin:
|
||||
raise
|
||||
except Exception as e:
|
||||
raise
|
||||
return si, stub
|
||||
|
||||
## Private method that performs the actual Disonnect
|
||||
|
||||
@ -363,6 +401,59 @@ def __Logout(si):
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
## Private method that returns the service content
|
||||
|
||||
def __RetrieveContent(host, port, adapter, version, path, keyFile, certFile,
|
||||
thumbprint, sslContext):
|
||||
"""
|
||||
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
|
||||
"""
|
||||
|
||||
# XXX remove the adapter and service arguments once dependent code is fixed
|
||||
if adapter != "SOAP":
|
||||
raise ValueError(adapter)
|
||||
|
||||
# Create the SOAP stub adapter
|
||||
stub = SoapStubAdapter(host, port, version=version, path=path,
|
||||
certKeyFile=keyFile, certFile=certFile,
|
||||
thumbprint=thumbprint, sslContext=sslContext)
|
||||
|
||||
# Get Service instance
|
||||
si = vim.ServiceInstance("ServiceInstance", stub)
|
||||
content = None
|
||||
try:
|
||||
content = si.RetrieveContent()
|
||||
except vmodl.MethodFault:
|
||||
raise
|
||||
except Exception as e:
|
||||
# NOTE (hartsock): preserve the traceback for diagnostics
|
||||
# pulling and preserving the traceback makes diagnosing connection
|
||||
# failures easier since the fault will also include where inside the
|
||||
# library the fault occurred. Without the traceback we have no idea
|
||||
# why the connection failed beyond the message string.
|
||||
(type, value, traceback) = sys.exc_info()
|
||||
if traceback:
|
||||
fault = vim.fault.HostConnectFault(msg=str(e))
|
||||
reraise(vim.fault.HostConnectFault, fault, traceback)
|
||||
else:
|
||||
raise vim.fault.HostConnectFault(msg=str(e))
|
||||
|
||||
return content, si, stub
|
||||
|
||||
|
||||
## Get the saved service instance.
|
||||
|
||||
@ -607,8 +698,8 @@ def SmartStubAdapter(host='localhost', port=443, path='/sdk',
|
||||
|
||||
def SmartConnect(protocol='https', host='localhost', port=443, user='root', pwd='',
|
||||
service="hostd", path="/sdk",
|
||||
preferredApiVersions=None,
|
||||
keyFile=None, certFile=None, thumbprint=None, sslContext=None):
|
||||
preferredApiVersions=None, keyFile=None, certFile=None,
|
||||
thumbprint=None, sslContext=None, b64token=None, mechanism='userpass'):
|
||||
"""
|
||||
Determine the most preferred API version supported by the specified server,
|
||||
then connect to the specified server using that API version, login and return
|
||||
@ -677,7 +768,9 @@ def SmartConnect(protocol='https', host='localhost', port=443, user='root', pwd=
|
||||
keyFile=keyFile,
|
||||
certFile=certFile,
|
||||
thumbprint=thumbprint,
|
||||
sslContext=sslContext)
|
||||
sslContext=sslContext,
|
||||
b64token=b64token,
|
||||
mechanism=mechanism)
|
||||
|
||||
def OpenUrlWithBasicAuth(url, user='root', pwd=''):
|
||||
"""
|
||||
@ -707,6 +800,6 @@ def OpenPathWithStub(path, stub):
|
||||
url = '%s://%s%s' % (protocol, hostPort, path)
|
||||
headers = {}
|
||||
if stub.cookie:
|
||||
headers["Cookie"] = stub.cookie
|
||||
headers["Cookie"] = stub.cookie
|
||||
return requests.get(url, headers=headers, verify=False)
|
||||
|
||||
|
258
tests/fixtures/sspi_connection.yaml
vendored
Normal file
258
tests/fixtures/sspi_connection.yaml
vendored
Normal file
@ -0,0 +1,258 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: '<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<soapenv:Body><RetrieveServiceContent xmlns="urn:vim25"><_this type="ServiceInstance">ServiceInstance</_this></RetrieveServiceContent></soapenv:Body>
|
||||
|
||||
</soapenv:Envelope>'
|
||||
headers:
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Content-Type: [text/xml; charset=UTF-8]
|
||||
Cookie: ['']
|
||||
SOAPAction: ['"urn:vim25/4.1"']
|
||||
method: POST
|
||||
uri: https://vcsa/sdk
|
||||
response:
|
||||
body: {string: !!python/unicode "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
|
||||
<soapenv:Envelope xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"\
|
||||
\n xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n xmlns:xsd=\"\
|
||||
http://www.w3.org/2001/XMLSchema\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
|
||||
>\n<soapenv:Body>\n<RetrieveServiceContentResponse xmlns=\"urn:vim25\"><returnval><rootFolder\
|
||||
\ type=\"Folder\">group-d1</rootFolder><propertyCollector type=\"PropertyCollector\"\
|
||||
>propertyCollector</propertyCollector><viewManager type=\"ViewManager\">ViewManager</viewManager><about><name>VMware\
|
||||
\ vCenter Server</name><fullName>VMware vCenter Server 6.0.0 build-3018523</fullName><vendor>VMware,\
|
||||
\ Inc.</vendor><version>6.0.0</version><build>3018523</build><localeVersion>INTL</localeVersion><localeBuild>000</localeBuild><osType>linux-x64</osType><productLineId>vpx</productLineId><apiType>VirtualCenter</apiType><apiVersion>6.0</apiVersion><instanceUuid>6cbd40cc-1416-4b2d-ba7c-ae53a166d00a</instanceUuid><licenseProductName>VMware\
|
||||
\ VirtualCenter Server</licenseProductName><licenseProductVersion>6.0</licenseProductVersion></about><setting\
|
||||
\ type=\"OptionManager\">VpxSettings</setting><userDirectory type=\"UserDirectory\"\
|
||||
>UserDirectory</userDirectory><sessionManager type=\"SessionManager\">SessionManager</sessionManager><authorizationManager\
|
||||
\ type=\"AuthorizationManager\">AuthorizationManager</authorizationManager><perfManager\
|
||||
\ type=\"PerformanceManager\">PerfMgr</perfManager><scheduledTaskManager type=\"\
|
||||
ScheduledTaskManager\">ScheduledTaskManager</scheduledTaskManager><alarmManager\
|
||||
\ type=\"AlarmManager\">AlarmManager</alarmManager><eventManager type=\"EventManager\"\
|
||||
>EventManager</eventManager><taskManager type=\"TaskManager\">TaskManager</taskManager><extensionManager\
|
||||
\ type=\"ExtensionManager\">ExtensionManager</extensionManager><customizationSpecManager\
|
||||
\ type=\"CustomizationSpecManager\">CustomizationSpecManager</customizationSpecManager><customFieldsManager\
|
||||
\ type=\"CustomFieldsManager\">CustomFieldsManager</customFieldsManager><diagnosticManager\
|
||||
\ type=\"DiagnosticManager\">DiagMgr</diagnosticManager><licenseManager type=\"\
|
||||
LicenseManager\">LicenseManager</licenseManager><searchIndex type=\"SearchIndex\"\
|
||||
>SearchIndex</searchIndex><fileManager type=\"FileManager\">FileManager</fileManager><virtualDiskManager\
|
||||
\ type=\"VirtualDiskManager\">virtualDiskManager</virtualDiskManager><snmpSystem\
|
||||
\ type=\"HostSnmpSystem\">SnmpSystem</snmpSystem><vmProvisioningChecker type=\"\
|
||||
VirtualMachineProvisioningChecker\">ProvChecker</vmProvisioningChecker><vmCompatibilityChecker\
|
||||
\ type=\"VirtualMachineCompatibilityChecker\">CompatChecker</vmCompatibilityChecker><ovfManager\
|
||||
\ type=\"OvfManager\">OvfManager</ovfManager><ipPoolManager type=\"IpPoolManager\"\
|
||||
>IpPoolManager</ipPoolManager><dvSwitchManager type=\"DistributedVirtualSwitchManager\"\
|
||||
>DVSManager</dvSwitchManager><hostProfileManager type=\"HostProfileManager\"\
|
||||
>HostProfileManager</hostProfileManager><clusterProfileManager type=\"ClusterProfileManager\"\
|
||||
>ClusterProfileManager</clusterProfileManager><complianceManager type=\"ProfileComplianceManager\"\
|
||||
>MoComplianceManager</complianceManager><localizationManager type=\"LocalizationManager\"\
|
||||
>LocalizationManager</localizationManager><storageResourceManager type=\"\
|
||||
StorageResourceManager\">StorageResourceManager</storageResourceManager></returnval></RetrieveServiceContentResponse>\n\
|
||||
</soapenv:Body>\n</soapenv:Envelope>"}
|
||||
headers:
|
||||
cache-control: [no-cache]
|
||||
connection: [Keep-Alive]
|
||||
content-length: ['3320']
|
||||
content-type: [text/xml; charset=utf-8]
|
||||
date: ['Mon, 12 Oct 2015 16:20:20 GMT']
|
||||
status: {code: 200, message: OK}
|
||||
- request:
|
||||
body: '<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<soapenv:Body><LoginBySSPI xmlns="urn:vim25"><_this type="SessionManager">SessionManager</_this><base64Token>my_base64token</base64Token></LoginBySSPI></soapenv:Body>
|
||||
|
||||
</soapenv:Envelope>'
|
||||
headers:
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Content-Type: [text/xml; charset=UTF-8]
|
||||
Cookie: ['']
|
||||
SOAPAction: ['"urn:vim25/4.1"']
|
||||
method: POST
|
||||
uri: https://vcsa/sdk
|
||||
response:
|
||||
body: {string: !!python/unicode "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
|
||||
<soapenv:Envelope xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"\
|
||||
\n xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n xmlns:xsd=\"\
|
||||
http://www.w3.org/2001/XMLSchema\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
|
||||
>\n<soapenv:Body>\n<LoginResponse xmlns=\"urn:vim25\"><returnval><key>52b5395a-85c2-9902-7835-13a9b77e1fec</key><userName>my_user</userName><fullName>my_user</fullName><loginTime>2015-10-12T16:20:20.388804Z</loginTime><lastActiveTime>2015-10-12T16:20:20.388804Z</lastActiveTime><locale>en</locale><messageLocale>en</messageLocale></returnval></LoginResponse>\n\
|
||||
</soapenv:Body>\n</soapenv:Envelope>"}
|
||||
headers:
|
||||
cache-control: [no-cache]
|
||||
connection: [Keep-Alive]
|
||||
content-length: ['704']
|
||||
content-type: [text/xml; charset=utf-8]
|
||||
date: ['Mon, 12 Oct 2015 16:20:20 GMT']
|
||||
set-cookie: [vmware_soap_session="57e9ef0e1210352a3cf607db32a20792334f5b81";
|
||||
Path=/; HttpOnly; Secure;]
|
||||
status: {code: 200, message: OK}
|
||||
- request:
|
||||
body: '<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<soapenv:Body><RetrieveServiceContent xmlns="urn:vim25"><_this type="ServiceInstance">ServiceInstance</_this></RetrieveServiceContent></soapenv:Body>
|
||||
|
||||
</soapenv:Envelope>'
|
||||
headers:
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Content-Type: [text/xml; charset=UTF-8]
|
||||
Cookie: [vmware_soap_session="57e9ef0e1210352a3cf607db32a20792334f5b81"; Path=/;
|
||||
HttpOnly; Secure;]
|
||||
SOAPAction: ['"urn:vim25/4.1"']
|
||||
method: POST
|
||||
uri: https://vcsa/sdk
|
||||
response:
|
||||
body: {string: !!python/unicode "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
|
||||
<soapenv:Envelope xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"\
|
||||
\n xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n xmlns:xsd=\"\
|
||||
http://www.w3.org/2001/XMLSchema\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
|
||||
>\n<soapenv:Body>\n<RetrieveServiceContentResponse xmlns=\"urn:vim25\"><returnval><rootFolder\
|
||||
\ type=\"Folder\">group-d1</rootFolder><propertyCollector type=\"PropertyCollector\"\
|
||||
>propertyCollector</propertyCollector><viewManager type=\"ViewManager\">ViewManager</viewManager><about><name>VMware\
|
||||
\ vCenter Server</name><fullName>VMware vCenter Server 6.0.0 build-3018523</fullName><vendor>VMware,\
|
||||
\ Inc.</vendor><version>6.0.0</version><build>3018523</build><localeVersion>INTL</localeVersion><localeBuild>000</localeBuild><osType>linux-x64</osType><productLineId>vpx</productLineId><apiType>VirtualCenter</apiType><apiVersion>6.0</apiVersion><instanceUuid>6cbd40cc-1416-4b2d-ba7c-ae53a166d00a</instanceUuid><licenseProductName>VMware\
|
||||
\ VirtualCenter Server</licenseProductName><licenseProductVersion>6.0</licenseProductVersion></about><setting\
|
||||
\ type=\"OptionManager\">VpxSettings</setting><userDirectory type=\"UserDirectory\"\
|
||||
>UserDirectory</userDirectory><sessionManager type=\"SessionManager\">SessionManager</sessionManager><authorizationManager\
|
||||
\ type=\"AuthorizationManager\">AuthorizationManager</authorizationManager><perfManager\
|
||||
\ type=\"PerformanceManager\">PerfMgr</perfManager><scheduledTaskManager type=\"\
|
||||
ScheduledTaskManager\">ScheduledTaskManager</scheduledTaskManager><alarmManager\
|
||||
\ type=\"AlarmManager\">AlarmManager</alarmManager><eventManager type=\"EventManager\"\
|
||||
>EventManager</eventManager><taskManager type=\"TaskManager\">TaskManager</taskManager><extensionManager\
|
||||
\ type=\"ExtensionManager\">ExtensionManager</extensionManager><customizationSpecManager\
|
||||
\ type=\"CustomizationSpecManager\">CustomizationSpecManager</customizationSpecManager><customFieldsManager\
|
||||
\ type=\"CustomFieldsManager\">CustomFieldsManager</customFieldsManager><diagnosticManager\
|
||||
\ type=\"DiagnosticManager\">DiagMgr</diagnosticManager><licenseManager type=\"\
|
||||
LicenseManager\">LicenseManager</licenseManager><searchIndex type=\"SearchIndex\"\
|
||||
>SearchIndex</searchIndex><fileManager type=\"FileManager\">FileManager</fileManager><virtualDiskManager\
|
||||
\ type=\"VirtualDiskManager\">virtualDiskManager</virtualDiskManager><snmpSystem\
|
||||
\ type=\"HostSnmpSystem\">SnmpSystem</snmpSystem><vmProvisioningChecker type=\"\
|
||||
VirtualMachineProvisioningChecker\">ProvChecker</vmProvisioningChecker><vmCompatibilityChecker\
|
||||
\ type=\"VirtualMachineCompatibilityChecker\">CompatChecker</vmCompatibilityChecker><ovfManager\
|
||||
\ type=\"OvfManager\">OvfManager</ovfManager><ipPoolManager type=\"IpPoolManager\"\
|
||||
>IpPoolManager</ipPoolManager><dvSwitchManager type=\"DistributedVirtualSwitchManager\"\
|
||||
>DVSManager</dvSwitchManager><hostProfileManager type=\"HostProfileManager\"\
|
||||
>HostProfileManager</hostProfileManager><clusterProfileManager type=\"ClusterProfileManager\"\
|
||||
>ClusterProfileManager</clusterProfileManager><complianceManager type=\"ProfileComplianceManager\"\
|
||||
>MoComplianceManager</complianceManager><localizationManager type=\"LocalizationManager\"\
|
||||
>LocalizationManager</localizationManager><storageResourceManager type=\"\
|
||||
StorageResourceManager\">StorageResourceManager</storageResourceManager></returnval></RetrieveServiceContentResponse>\n\
|
||||
</soapenv:Body>\n</soapenv:Envelope>"}
|
||||
headers:
|
||||
cache-control: [no-cache]
|
||||
connection: [Keep-Alive]
|
||||
content-length: ['3320']
|
||||
content-type: [text/xml; charset=utf-8]
|
||||
date: ['Mon, 12 Oct 2015 16:20:20 GMT']
|
||||
status: {code: 200, message: OK}
|
||||
- request:
|
||||
body: '<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<soapenv:Body><RetrievePropertiesEx xmlns="urn:vim25"><_this type="PropertyCollector">propertyCollector</_this><specSet><propSet><type>ServiceInstance</type><all>false</all><pathSet>content</pathSet></propSet><objectSet><obj
|
||||
type="ServiceInstance">ServiceInstance</obj><skip>false</skip></objectSet></specSet><options><maxObjects>1</maxObjects></options></RetrievePropertiesEx></soapenv:Body>
|
||||
|
||||
</soapenv:Envelope>'
|
||||
headers:
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Content-Type: [text/xml; charset=UTF-8]
|
||||
Cookie: [vmware_soap_session="57e9ef0e1210352a3cf607db32a20792334f5b81"; Path=/;
|
||||
HttpOnly; Secure;]
|
||||
SOAPAction: ['"urn:vim25/4.1"']
|
||||
method: POST
|
||||
uri: https://vcsa/sdk
|
||||
response:
|
||||
body: {string: !!python/unicode "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
|
||||
<soapenv:Envelope xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"\
|
||||
\n xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n xmlns:xsd=\"\
|
||||
http://www.w3.org/2001/XMLSchema\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
|
||||
>\n<soapenv:Body>\n<RetrievePropertiesExResponse xmlns=\"urn:vim25\"><returnval><objects><obj\
|
||||
\ type=\"ServiceInstance\">ServiceInstance</obj><propSet><name>content</name><val\
|
||||
\ xsi:type=\"ServiceContent\"><rootFolder type=\"Folder\">group-d1</rootFolder><propertyCollector\
|
||||
\ type=\"PropertyCollector\">propertyCollector</propertyCollector><viewManager\
|
||||
\ type=\"ViewManager\">ViewManager</viewManager><about><name>VMware vCenter\
|
||||
\ Server</name><fullName>VMware vCenter Server 6.0.0 build-3018523</fullName><vendor>VMware,\
|
||||
\ Inc.</vendor><version>6.0.0</version><build>3018523</build><localeVersion>INTL</localeVersion><localeBuild>000</localeBuild><osType>linux-x64</osType><productLineId>vpx</productLineId><apiType>VirtualCenter</apiType><apiVersion>6.0</apiVersion><instanceUuid>6cbd40cc-1416-4b2d-ba7c-ae53a166d00a</instanceUuid><licenseProductName>VMware\
|
||||
\ VirtualCenter Server</licenseProductName><licenseProductVersion>6.0</licenseProductVersion></about><setting\
|
||||
\ type=\"OptionManager\">VpxSettings</setting><userDirectory type=\"UserDirectory\"\
|
||||
>UserDirectory</userDirectory><sessionManager type=\"SessionManager\">SessionManager</sessionManager><authorizationManager\
|
||||
\ type=\"AuthorizationManager\">AuthorizationManager</authorizationManager><perfManager\
|
||||
\ type=\"PerformanceManager\">PerfMgr</perfManager><scheduledTaskManager type=\"\
|
||||
ScheduledTaskManager\">ScheduledTaskManager</scheduledTaskManager><alarmManager\
|
||||
\ type=\"AlarmManager\">AlarmManager</alarmManager><eventManager type=\"EventManager\"\
|
||||
>EventManager</eventManager><taskManager type=\"TaskManager\">TaskManager</taskManager><extensionManager\
|
||||
\ type=\"ExtensionManager\">ExtensionManager</extensionManager><customizationSpecManager\
|
||||
\ type=\"CustomizationSpecManager\">CustomizationSpecManager</customizationSpecManager><customFieldsManager\
|
||||
\ type=\"CustomFieldsManager\">CustomFieldsManager</customFieldsManager><diagnosticManager\
|
||||
\ type=\"DiagnosticManager\">DiagMgr</diagnosticManager><licenseManager type=\"\
|
||||
LicenseManager\">LicenseManager</licenseManager><searchIndex type=\"SearchIndex\"\
|
||||
>SearchIndex</searchIndex><fileManager type=\"FileManager\">FileManager</fileManager><virtualDiskManager\
|
||||
\ type=\"VirtualDiskManager\">virtualDiskManager</virtualDiskManager><snmpSystem\
|
||||
\ type=\"HostSnmpSystem\">SnmpSystem</snmpSystem><vmProvisioningChecker type=\"\
|
||||
VirtualMachineProvisioningChecker\">ProvChecker</vmProvisioningChecker><vmCompatibilityChecker\
|
||||
\ type=\"VirtualMachineCompatibilityChecker\">CompatChecker</vmCompatibilityChecker><ovfManager\
|
||||
\ type=\"OvfManager\">OvfManager</ovfManager><ipPoolManager type=\"IpPoolManager\"\
|
||||
>IpPoolManager</ipPoolManager><dvSwitchManager type=\"DistributedVirtualSwitchManager\"\
|
||||
>DVSManager</dvSwitchManager><hostProfileManager type=\"HostProfileManager\"\
|
||||
>HostProfileManager</hostProfileManager><clusterProfileManager type=\"ClusterProfileManager\"\
|
||||
>ClusterProfileManager</clusterProfileManager><complianceManager type=\"ProfileComplianceManager\"\
|
||||
>MoComplianceManager</complianceManager><localizationManager type=\"LocalizationManager\"\
|
||||
>LocalizationManager</localizationManager><storageResourceManager type=\"\
|
||||
StorageResourceManager\">StorageResourceManager</storageResourceManager></val></propSet></objects></returnval></RetrievePropertiesExResponse>\n\
|
||||
</soapenv:Body>\n</soapenv:Envelope>"}
|
||||
headers:
|
||||
cache-control: [no-cache]
|
||||
connection: [Keep-Alive]
|
||||
content-length: ['3460']
|
||||
content-type: [text/xml; charset=utf-8]
|
||||
date: ['Mon, 12 Oct 2015 16:20:20 GMT']
|
||||
status: {code: 200, message: OK}
|
||||
- request:
|
||||
body: '<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<soapenv:Body><RetrievePropertiesEx xmlns="urn:vim25"><_this type="PropertyCollector">propertyCollector</_this><specSet><propSet><type>SessionManager</type><all>false</all><pathSet>currentSession</pathSet></propSet><objectSet><obj
|
||||
type="SessionManager">SessionManager</obj><skip>false</skip></objectSet></specSet><options><maxObjects>1</maxObjects></options></RetrievePropertiesEx></soapenv:Body>
|
||||
|
||||
</soapenv:Envelope>'
|
||||
headers:
|
||||
Accept-Encoding: ['gzip, deflate']
|
||||
Content-Type: [text/xml; charset=UTF-8]
|
||||
Cookie: [vmware_soap_session="57e9ef0e1210352a3cf607db32a20792334f5b81"; Path=/;
|
||||
HttpOnly; Secure;]
|
||||
SOAPAction: ['"urn:vim25/4.1"']
|
||||
method: POST
|
||||
uri: https://vcsa/sdk
|
||||
response:
|
||||
body: {string: !!python/unicode "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
|
||||
<soapenv:Envelope xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"\
|
||||
\n xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n xmlns:xsd=\"\
|
||||
http://www.w3.org/2001/XMLSchema\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
|
||||
>\n<soapenv:Body>\n<RetrievePropertiesExResponse xmlns=\"urn:vim25\"><returnval><objects><obj\
|
||||
\ type=\"SessionManager\">SessionManager</obj><propSet><name>currentSession</name><val\
|
||||
\ xsi:type=\"UserSession\"><key>52b5395a-85c2-9902-7835-13a9b77e1fec</key><userName>my_user</userName><fullName>my_user</fullName><loginTime>2015-10-12T16:20:20.388804Z</loginTime><lastActiveTime>2015-10-12T16:20:20.400795Z</lastActiveTime><locale>en</locale><messageLocale>en</messageLocale></val></propSet></objects></returnval></RetrievePropertiesExResponse>\n\
|
||||
</soapenv:Body>\n</soapenv:Envelope>"}
|
||||
headers:
|
||||
cache-control: [no-cache]
|
||||
connection: [Keep-Alive]
|
||||
content-length: ['880']
|
||||
content-type: [text/xml; charset=utf-8]
|
||||
date: ['Mon, 12 Oct 2015 16:20:20 GMT']
|
||||
status: {code: 200, message: OK}
|
||||
version: 1
|
@ -40,6 +40,23 @@ class ConnectionTests(tests.VCRTestBase):
|
||||
self.assertTrue(session_id is not None)
|
||||
self.assertEqual('52b5395a-85c2-9902-7835-13a9b77e1fec', session_id)
|
||||
|
||||
@vcr.use_cassette('sspi_connection.yaml',
|
||||
cassette_library_dir=tests.fixtures_path,
|
||||
record_mode='none')
|
||||
def test_sspi_connection(self):
|
||||
# see: http://python3porting.com/noconv.html
|
||||
si = connect.Connect(host='vcsa',
|
||||
mechanism='sspi',
|
||||
b64token='my_base64token')
|
||||
cookie = si._stub.cookie
|
||||
session_id = si.content.sessionManager.currentSession.key
|
||||
# NOTE (hartsock): The cookie value should never change during
|
||||
# a connected session. That should be verifiable in these tests.
|
||||
self.assertEqual(cookie, si._stub.cookie)
|
||||
# NOTE (hartsock): assertIsNotNone does not work in Python 2.6
|
||||
self.assertTrue(session_id is not None)
|
||||
self.assertEqual('52b5395a-85c2-9902-7835-13a9b77e1fec', session_id)
|
||||
|
||||
@vcr.use_cassette('basic_connection_bad_password.yaml',
|
||||
cassette_library_dir=tests.fixtures_path,
|
||||
record_mode='none')
|
||||
|
Loading…
x
Reference in New Issue
Block a user