@olivierlambert
Thank you for the link , i think this should help me:
wget http://xoahostname/vm_rrd?session_id=<token>&uuid=x&start=<secondsinceepoch>
seems it needs session id token. So in order to generate one , i installed XenAPI-24.15.0 , and used following snippet to generate the token -
import XenAPI
username = "user1"
password = "user1's ldap password"
url = "http://xoahostname.example.com"
session = XenAPI.Session(url)
session.xenapi.login_with_password(username, password, "1.0", "session_getter")
print(session._session)
i got following error -
File "./test.py", line 6, in <module>
session.xenapi.login_with_password(username, password, "1.0", "session_getter")
File "/work/user1/MyWork/XAPI/venv01/lib/python3.6/site-packages/XenAPI/XenAPI.py", line 260, in __call__
return self.__send(self.__name, args)
File "/work/user1/MyWork/XAPI/venv01/lib/python3.6/site-packages/XenAPI/XenAPI.py", line 145, in xenapi_request
self._login(methodname, params)
File "/work/user1/MyWork/XAPI/venv01/lib/python3.6/site-packages/XenAPI/XenAPI.py", line 170, in _login
getattr(self, 'session.%s' % method)(*params))
File "/tools/FOSS/python3/3.6.7/x86_64/lib/python3.6/xmlrpc/client.py", line 1112, in __call__
return self.__send(self.__name, args)
File "/tools/FOSS/python3/3.6.7/x86_64/lib/python3.6/xmlrpc/client.py", line 1452, in __request
verbose=self.__verbose
File "/tools/FOSS/python3/3.6.7/x86_64/lib/python3.6/xmlrpc/client.py", line 1154, in request
return self.single_request(host, handler, request_body, verbose)
File "/tools/FOSS/python3/3.6.7/x86_64/lib/python3.6/xmlrpc/client.py", line 1187, in single_request
dict(resp.getheaders())
xmlrpc.client.ProtocolError: <ProtocolError for xoahostname.example.com/RPC2: 302 Found>
I retried with HTTPS
url = "https://xoahostname"
and i get following error -
Traceback (most recent call last):
File "./test.py", line 6, in <module>
session.xenapi.login_with_password(username, password, "1.0", "session_getter")
File "/work/user1/MyWork/XAPI/venv01/lib/python3.6/site-packages/XenAPI/XenAPI.py", line 260, in __call__
return self.__send(self.__name, args)
File "/work/user1/MyWork/XAPI/venv01/lib/python3.6/site-packages/XenAPI/XenAPI.py", line 145, in xenapi_request
self._login(methodname, params)
File "/work/user1/MyWork/XAPI/venv01/lib/python3.6/site-packages/XenAPI/XenAPI.py", line 182, in _login
raise e
File "/work/user1/MyWork/XAPI/venv01/lib/python3.6/site-packages/XenAPI/XenAPI.py", line 170, in _login
getattr(self, 'session.%s' % method)(*params))
File "/tools/FOSS/python3/3.6.7/x86_64/lib/python3.6/xmlrpc/client.py", line 1112, in __call__
return self.__send(self.__name, args)
File "/tools/FOSS/python3/3.6.7/x86_64/lib/python3.6/xmlrpc/client.py", line 1452, in __request
verbose=self.__verbose
File "/tools/FOSS/python3/3.6.7/x86_64/lib/python3.6/xmlrpc/client.py", line 1154, in request
return self.single_request(host, handler, request_body, verbose)
File "/tools/FOSS/python3/3.6.7/x86_64/lib/python3.6/xmlrpc/client.py", line 1166, in single_request
http_conn = self.send_request(host, handler, request_body, verbose)
File "/tools/FOSS/python3/3.6.7/x86_64/lib/python3.6/xmlrpc/client.py", line 1279, in send_request
self.send_content(connection, request_body)
File "/tools/FOSS/python3/3.6.7/x86_64/lib/python3.6/xmlrpc/client.py", line 1309, in send_content
connection.endheaders(request_body)
File "/tools/FOSS/python3/3.6.7/x86_64/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/tools/FOSS/python3/3.6.7/x86_64/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/tools/FOSS/python3/3.6.7/x86_64/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/tools/FOSS/python3/3.6.7/x86_64/lib/python3.6/http/client.py", line 1400, in connect
server_hostname=server_hostname)
File "/tools/FOSS/python3/3.6.7/x86_64/lib/python3.6/ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "/tools/FOSS/python3/3.6.7/x86_64/lib/python3.6/ssl.py", line 817, in __init__
self.do_handshake()
File "/tools/FOSS/python3/3.6.7/x86_64/lib/python3.6/ssl.py", line 1077, in do_handshake
self._sslobj.do_handshake()
File "/tools/FOSS/python3/3.6.7/x86_64/lib/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:847)
Any hints on know what additional flags are required in the XENApi's python api to make this work ?
-
We are using xo-server 5.111.1 , XCP-ng 8.2 OS. This version supports the pythonapi which i am trying to use ?
-
If i am able to generate the session id token, how long will this token valid? can i use this same token for 3 hours to download data from across multiple VMs ?
-
the user1 account is a non admin account but with privileges to create/terminate VMs and view host utilization metrics. Do i strictly need to use the root user account's session id to ken to use the API?. user1 has permission to access the following sections of the XOA UI
-
Instead of the python API , the tokens generated using the following web page are valid to be used with wget as sessionid?