Browse Source

Add pool support to qvm-clone

Bahtiar `kalkin-` Gadimov 8 years ago
parent
commit
bb754b68c3
1 changed files with 9 additions and 1 deletions
  1. 9 1
      qvm-tools/qvm-clone

+ 9 - 1
qvm-tools/qvm-clone

@@ -38,6 +38,8 @@ def main():
                        help="Specify path to the template directory")
     parser.add_option ("--force-root", action="store_true", dest="force_root", default=False,
                        help="Force to run, even with root privileges")
+    parser.add_option ("-P", "--pool", dest="pool_name",
+                        help="Specify in to which storage pool to clone")
 
     (options, args) = parser.parse_args ()
     if (len (args) != 2):
@@ -45,6 +47,7 @@ def main():
     srcname = args[0]
     dstname = args[1]
 
+
     if hasattr(os, "geteuid") and os.geteuid() == 0:
         if not options.force_root:
             print >> sys.stderr, "*** Running this tool as root is strongly discouraged, this will lead you in permissions problems."
@@ -61,6 +64,11 @@ def main():
         print >> sys.stderr, "ERROR: A VM with the name '{0}' does not exist in the system.".format(srcname)
         exit(1)
 
+    if options.pool_name is None:
+        pool_name = src_vm.pool_name
+    else:
+        pool_name = options.pool_name
+
     if qvm_collection.get_vm_by_name(dstname) is not None:
         print >> sys.stderr, "ERROR: A VM with the name '{0}' already exists in the system.".format(dstname)
         exit(1)
@@ -70,7 +78,7 @@ def main():
         exit(1)
 
     dst_vm = qvm_collection.add_new_vm(src_vm.__class__.__name__,
-            name=dstname, template=src_vm.template,
+            name=dstname, template=src_vm.template, pool_name=pool_name,
             dir_path=options.dir_path, installed_by_rpm=False)
 
     try: