mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
e4384459c9
This is more flexible regarding the location of the python binary but doesn't allow to pass the -u flag. The -i flag can be passed from inside the script using the PYTHONINSPECT env variable. This fixes a problem with the esx_vi_generator.py on FreeBSD.
37 lines
814 B
Python
Executable File
37 lines
814 B
Python
Executable File
#!/usr/bin/env python
|
|
# domstart - make sure a given domU is running, if not start it
|
|
|
|
import libvirt
|
|
import sys
|
|
import os
|
|
import libxml2
|
|
import pdb
|
|
|
|
def usage():
|
|
print 'Usage: %s DIR' % sys.argv[0]
|
|
print ' Restore all the domains contained in DIR'
|
|
print ' It is assumed that all files in DIR are'
|
|
print ' images of domU\'s previously created with save'
|
|
|
|
if len(sys.argv) != 2:
|
|
usage()
|
|
sys.exit(2)
|
|
|
|
dir = sys.argv[1]
|
|
imgs = os.listdir(dir)
|
|
|
|
conn = libvirt.open(None)
|
|
if conn == None:
|
|
print 'Failed to open connection to the hypervisor'
|
|
sys.exit(1)
|
|
|
|
for img in imgs:
|
|
file = os.path.join(dir, img)
|
|
print "Restoring %s ... " % img,
|
|
sys.stdout.flush()
|
|
ret = conn.restore(file)
|
|
if ret == 0:
|
|
print "done"
|
|
else:
|
|
print "error %d" % ret
|