VMware {code} Community
dbiswas91
Contributor
Contributor
Jump to solution

Does vsphere-automation-sdk-python require vddk

As the current vddk8.0 version does not support Perl vsphere automation sdk,

Is it require vddk to be installed on same system for  vsphere-automation-sdk-python.

I am new to vmware, plz correct me if my understading wrong.

 

facing following error:

[root@vsphere-automation-sdk-python-master]# python3 ./samples/vsphere/vcenter/vm/list_vms.py -s x.x.x.x -u root -p xxxxx
vcenter server = x.x.x.x
vc username = root
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 456, in wrap_socket
cnx.do_handshake()
File "/usr/local/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1934, in do_handshake
self._raise_ssl_error(self._ssl, result)
File "/usr/local/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1671, in _raise_ssl_error
_raise_current_error()
File "/usr/local/lib/python3.6/site-packages/OpenSSL/_util.py", line 54, in exception_from_error_queue
raise exception_type(errors)
OpenSSL.SSL.Error: [('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 344, in connect
ssl_context=context)
File "/usr/local/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 358, in ssl_wrap_socket
return context.wrap_socket(sock)
File "/usr/local/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 462, in wrap_socket
raise ssl.SSLError('bad handshake: %r' % e)
ssl.SSLError: ("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='x.x.x.x', port=443): Max retries exceeded with url: /api (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "./samples/vsphere/vcenter/vm/list_vms.py", line 62, in <module>
main()
File "./samples/vsphere/vcenter/vm/list_vms.py", line 57, in main
list_vm = ListVM()
File "./samples/vsphere/vcenter/vm/list_vms.py", line 42, in __init__
session=session)
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/vsphere/client.py", line 175, in create_vsphere_client
hok_token=hok_token, private_key=private_key)
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/vsphere/client.py", line 116, in __init__
session_id = session_svc.create()
File "/usr/local/lib/python3.6/site-packages/com/vmware/cis_client.py", line 201, in create
return self._invoke('create', None)
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/stub.py", line 345, in _invoke
return self._api_interface.native_invoke(ctx, _method_name, kwargs)
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/stub.py", line 266, in native_invoke
method_result = self.invoke(ctx, method_id, data_val)
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/stub.py", line 202, in invoke
ctx)
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/security/client/security_context_filter.py", line 102, in invoke
self, service_id, operation_id, input_value, ctx)
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/provider/filter.py", line 76, in invoke
service_id, operation_id, input_value, ctx)
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/protocol/client/msg/json_connector.py", line 79, in invoke
response = self._do_request(VAPI_INVOKE, ctx, params)
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/protocol/client/msg/json_connector.py", line 122, in _do_request
headers=request_headers, body=request_body))
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/protocol/client/rpc/requests_provider.py", line 98, in do_request
cookies=http_request.cookies, timeout=timeout)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='x.x.x.x', port=443): Max retries exceeded with url: /api (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),))

 

plz help me on this.

Tags (2)
Reply
0 Kudos
2 Solutions

Accepted Solutions
doskiran
Enthusiast
Enthusiast
Jump to solution

Add argument "--skipverification" at the end of the command.

--skipverification = It skips verifying server certificate when connecting to vc.

Eg:
> python3 ./samples/vsphere/vcenter/vm/list_vms.py -s x.x.x.x -u Administrator@vsphere.local -p xxxxx --skipverification

View solution in original post

Reply
0 Kudos
doskiran
Enthusiast
Enthusiast
Jump to solution

vSphere Automation SDK works only with vCenter sessions.

Because there are no public APIs for ESXi VMODL2.

Hence pass vCenter credentials in the command.

To run with ESXi credentials, use vSphere management SDKs .
i.e,

pyVmomi(SOAP based) allows you to manage VMware ESXi and vCenter using Python.
 

View solution in original post

Reply
0 Kudos
4 Replies
scott28tt
VMware Employee
VMware Employee
Jump to solution

As your post probably sits best in the {code} section of the Communities where there are dedicated areas for SDKs, I have reported it to the volunteer moderators.

 


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
doskiran
Enthusiast
Enthusiast
Jump to solution

Add argument "--skipverification" at the end of the command.

--skipverification = It skips verifying server certificate when connecting to vc.

Eg:
> python3 ./samples/vsphere/vcenter/vm/list_vms.py -s x.x.x.x -u Administrator@vsphere.local -p xxxxx --skipverification

Reply
0 Kudos
dbiswas91
Contributor
Contributor
Jump to solution

Thanks a lot above error,

[root@vmware-ub-200-251 vsphere-automation-sdk-python-master]# python3 ./samples/vsphere/vcenter/vm/list_vms.py -s x.x.x.x -u root -p QAteams1 --skipverification
vcenter server = x.x.xx
vc username = root
Traceback (most recent call last):
File "./samples/vsphere/vcenter/vm/list_vms.py", line 63, in <module>
main()
File "./samples/vsphere/vcenter/vm/list_vms.py", line 58, in main
list_vm = ListVM()
File "./samples/vsphere/vcenter/vm/list_vms.py", line 43, in __init__
session=session)
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/vsphere/client.py", line 175, in create_vsphere_client
hok_token=hok_token, private_key=private_key)
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/vsphere/client.py", line 116, in __init__
session_id = session_svc.create()
File "/usr/local/lib/python3.6/site-packages/com/vmware/cis_client.py", line 201, in create
return self._invoke('create', None)
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/stub.py", line 345, in _invoke
return self._api_interface.native_invoke(ctx, _method_name, kwargs)
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/stub.py", line 266, in native_invoke
method_result = self.invoke(ctx, method_id, data_val)
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/bindings/stub.py", line 202, in invoke
ctx)
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/security/client/security_context_filter.py", line 102, in invoke
self, service_id, operation_id, input_value, ctx)
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/provider/filter.py", line 76, in invoke
service_id, operation_id, input_value, ctx)
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/protocol/client/msg/json_connector.py", line 79, in invoke
response = self._do_request(VAPI_INVOKE, ctx, params)
File "/usr/local/lib/python3.6/site-packages/vmware/vapi/protocol/client/msg/json_connector.py", line 127, in _do_request
http_response.data.raise_for_status()
File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://x.x.x.x/api/

 

Reply
0 Kudos
doskiran
Enthusiast
Enthusiast
Jump to solution

vSphere Automation SDK works only with vCenter sessions.

Because there are no public APIs for ESXi VMODL2.

Hence pass vCenter credentials in the command.

To run with ESXi credentials, use vSphere management SDKs .
i.e,

pyVmomi(SOAP based) allows you to manage VMware ESXi and vCenter using Python.
 
Reply
0 Kudos