0

Does anybody know if python-libvirt has any API to perform 'domtime operations'.

I'm writing a python script that runs the command manually using os module.

...
os.system("virsh domtime %s --sync" % my_domain)
...

I want to use the libvirt API for that.

Do you know if it is possible?

I'm not finding any reference into the Documentation.

jcfaracco
  • 853
  • 2
  • 6
  • 21

1 Answers1

0

As stated in the documentation:

The Python binding should be complete and are mostly automatically generated from the formal description of the API in xml.

According to the source of domtime, the command uses the calls virDomainSetTime and virDomainGetTime, which can be accessed through Python as libvirt.virDomain.setTime and libvirt.virDomain.getTime.

Paulo Almeida
  • 7,803
  • 28
  • 36
  • Hi Paulo. Thanks for you answer. What is the options to use the same parameters as "--now"? setTime(None, 1) ? – jcfaracco Aug 23 '17 at 13:36
  • I'm not sure, to be honest. Why not just do `datetime.now()` and convert that to seconds? If you're on Python 3.3+ you can just do `date.timestamp()`. – Paulo Almeida Aug 23 '17 at 14:31