diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2013-11-22 15:55:39 +0000 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2013-11-22 15:55:39 +0000 |
commit | 34aa32ba8a4d3373ce01f999021e58638c4c3324 (patch) | |
tree | 3bba26150dff600f9f1ca99a34e5397c4c786c66 /examples/domrestore.py | |
parent | 70b8c9a2a3fe293aa055fde0d8a9df13263c3fd8 (diff) | |
download | libvirt-python-v9-34aa32ba8a4d3373ce01f999021e58638c4c3324.tar.gz libvirt-python-v9-34aa32ba8a4d3373ce01f999021e58638c4c3324.tar.xz libvirt-python-v9-34aa32ba8a4d3373ce01f999021e58638c4c3324.zip |
Move python example programs into python/examples/ subdirectory
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'examples/domrestore.py')
-rwxr-xr-x | examples/domrestore.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/examples/domrestore.py b/examples/domrestore.py new file mode 100755 index 0000000..fffc90f --- /dev/null +++ b/examples/domrestore.py @@ -0,0 +1,36 @@ +#!/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 is 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 |