Добрый день. Извините, я плохо говорю по-английски sh ... Наша компания использует прокси, что сильно мешает моей работе. Когда я запускаю код, который должен просто подключиться к vcenter и вернуть список vms:
import requests
import urllib3
from vmware.vapi.vsphere.client import create_vsphere_client
session = requests.session()
session.verify = False
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
vsphere_client = create_vsphere_client(server='*********',
username='******', password='*****', session=session)
vsphere_client.vcenter.VM.list()
Затем этот код возвращает следующее сообщение об ошибке:
/usr/bin/python3.8 /home/vminfo/PycharmProjects/VMware/tester.py
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 662, in urlopen
self._prepare_proxy(conn)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 950, in _prepare_proxy
conn.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 308, in connect
self._tunnel()
File "/usr/lib/python3.8/http/client.py", line 900, in _tunnel
raise OSError("Tunnel connection failed: %d %s" % (code,
OSError: Tunnel connection failed: 504 Gateway Timeout
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
retries = retries.increment(
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 436, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='********', port=443): Max
retries exceeded with url: /api (Caused by ProxyError('Cannot connect to proxy.',
OSError('Tunnel connection failed: 504 Gateway Timeout')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/vminfo/PycharmProjects/VMware/tester.py", line 15, in <module>
vsphere_client = create_vsphere_client(server='*******',
username='********', password='*******', session=session)
File "/home/vminfo/.local/lib/python3.8/site-packages/vmware/vapi/vsphere/client.py", line
170, in create_vsphere_client
return VsphereClient(session=session, server=server, username=username,
File "/home/vminfo/.local/lib/python3.8/site-packages/vmware/vapi/vsphere/client.py", line
113, in __init__
session_id = session_svc.create()
File "/home/vminfo/.local/lib/python3.8/site-packages/com/vmware/cis_client.py", line 199, in
create
return self._invoke('create', None)
File "/home/vminfo/.local/lib/python3.8/site-packages/vmware/vapi/bindings/stub.py", line
345, in _invoke
return self._api_interface.native_invoke(ctx, _method_name, kwargs)
File "/home/vminfo/.local/lib/python3.8/site-packages/vmware/vapi/bindings/stub.py", line
266, in native_invoke
method_result = self.invoke(ctx, method_id, data_val)
File "/home/vminfo/.local/lib/python3.8/site-packages/vmware/vapi/bindings/stub.py", line
199, in invoke
return self._api_provider.invoke(self._iface_id.get_name(),
File "/home/vminfo/.local/lib/python3.8/site-
packages/vmware/vapi/security/client/security_context_filter.py", line 101, in invoke
method_result = ApiProviderFilter.invoke(
File "/home/vminfo/.local/lib/python3.8/site-packages/vmware/vapi/provider/filter.py", line
75, in invoke
method_result = self.next_provider.invoke(
File "/home/vminfo/.local/lib/python3.8/site-
packages/vmware/vapi/protocol/client/msg/json_connector.py", line 79, in invoke
response = self._do_request(VAPI_INVOKE, ctx, params)
File "/home/vminfo/.local/lib/python3.8/site-
packages/vmware/vapi/protocol/client/msg/json_connector.py", line 120, in _do_request
http_response = self.http_provider.do_request(
File "/home/vminfo/.local/lib/python3.8/site-
packages/vmware/vapi/protocol/client/rpc/requests_provider.py", line 95, in do_request
output = self._session.request(
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 510, in send
raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='*******', port=443): Max
retries exceeded with url: /api (Caused by ProxyError('Cannot connect to proxy.',
OSError('Tunnel connection failed: 504 Gateway Timeout')))
Exception ignored in: <function VsphereClient.__del__ at 0x7efd9c9883a0>
Traceback (most recent call last):
File "/home/vminfo/.local/lib/python3.8/site-packages/vmware/vapi/vsphere/client.py", line
138, in __del__
if hasattr(self, 'session'):
File "/home/vminfo/.local/lib/python3.8/site-packages/vmware/vapi/bindings/stub.py", line
443, in __getattr__
return getattr(self._stub_factory, name)
File "/home/vminfo/.local/lib/python3.8/site-packages/vmware/vapi/bindings/stub.py", line
443, in __getattr__
return getattr(self._stub_factory, name)
File "/home/vminfo/.local/lib/python3.8/site-packages/vmware/vapi/bindings/stub.py", line
443, in __getattr__
return getattr(self._stub_factory, name)
[Previous line repeated 995 more times]
RecursionError: maximum recursion depth exceeded
Process finished with exit code 1
, я сразу скажу, что все данные для подключения введены правильно. Теоретически прокси не должен на это влиять. Как это исправить? Заранее спасибо всем.