I have to remove/Delete the VM from commvault using the Rest API
https://api.commvault.com/docs/api/cv/OpenAPI3/delete-virtual-machine
I have tried test running the api using python and I got the below mentioned error:
C:\Users\Ansible_user\Downloads>python vmdel.py WIN-C6TBRLJG6IM <commandcenter username> <commandcenter password
import requests
import urllib
#proxies={
#'http':'http://10.***.***.***:8080',
#'https':'http://10.***.***.***:8080'
#}
url = "https://win-c6tbrljg6im/commandcenter/api/V4/VirtualMachines/:<VM UUID>"
payload={}
headers = {
'Accept': 'application/json',
'Authtoken': '*******'
}
response = requests.request("GET", url, headers=headers, data=payload, proxies=urllib.request.getproxies())
print(response.text)
>
Traceback (most recent call last):
File "C:\Users\Ansible_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 779, in urlopen
self._prepare_proxy(conn)
File "C:\Users\Ansible_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 1048, in _prepare_proxy
conn.connect()
File "C:\Users\Ansible_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connection.py", line 633, in connect
self._tunnel() # type: ignoreyattr-defined]
^^^^^^^^^^^^^^
File "C:\Users\Ansible_user\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 973, in _tunnel
raise OSError(f"Tunnel connection failed: {code} {message.strip()}")
OSError: Tunnel connection failed: 502 Bad Gateway
The above exception was the direct cause of the following exception:
urllib3.exceptions.ProxyError: ('Unable to connect to proxy', OSError('Tunnel connection failed: 502 Bad Gateway'))
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Ansible_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\adapters.py", line 486, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "C:\Users\Ansible_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\connectionpool.py", line 847, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "C:\Users\Ansible_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\urllib3\util\retry.py", line 515, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignorelarg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='win-c6tbrljg6im', port=443): Max retries exceeded with url: /commandcenter/api/V4/VirtualMachines/ (Caused by ProxyError('Unable to connect to proxy', OSError('Tunnel connection failed: 502 Bad Gateway')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Ansible_user\Downloads\vmdel.py", line 16, in <module>
response = requests.request("GET", url, headers=headers, data=payload, proxies=urllib.request.getproxies())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ansible_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ansible_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ansible_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ansible_user\AppData\Local\Programs\Python\Python312\Lib\site-packages\requests\adapters.py", line 513, in send
raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='win-c6tbrljg6im', port=443): Max retries exceeded with url: /commandcenter/api/V4/VirtualMachines/ (Caused by ProxyError('Unable to connect to proxy', OSError('Tunnel connection failed: 502 Bad Gateway')))