Implement QemuImg.create()

Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/9ae1221d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/9ae1221d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/9ae1221d

Branch: refs/heads/qemu-img
Commit: 9ae1221d96b7d162f214c79f22c236b618ddd61e
Parents: 2b56edb
Author: Wido den Hollander <[email protected]>
Authored: Wed Feb 6 17:50:59 2013 +0100
Committer: Wido den Hollander <[email protected]>
Committed: Thu Feb 14 15:01:59 2013 +0100

----------------------------------------------------------------------
 utils/src/org/apache/cloudstack/utils/QemuImg.java |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9ae1221d/utils/src/org/apache/cloudstack/utils/QemuImg.java
----------------------------------------------------------------------
diff --git a/utils/src/org/apache/cloudstack/utils/QemuImg.java 
b/utils/src/org/apache/cloudstack/utils/QemuImg.java
index cf406c3..414022f 100644
--- a/utils/src/org/apache/cloudstack/utils/QemuImg.java
+++ b/utils/src/org/apache/cloudstack/utils/QemuImg.java
@@ -16,11 +16,16 @@
 // under the License.
 package org.apache.cloudstack.utils;
 
+import com.cloud.utils.script.Script;
+
 import java.util.List;
 import java.util.Map;
 
 public class QemuImg {
 
+    /* The qemu-img binary. We expect this to be in $PATH */
+    public static String _qemuImgPath = "qemu-img";
+
     /* Shouldn't we have KVMPhysicalDisk and LibvirtVMDef read this? */
     public static enum PhysicalDiskFormat {
         RAW("raw"), QCOW2("qcow2"), VMDK("vmdk"), FILE("file"), RBD("rbd"), 
SHEEPDOG("sheepdog"), HTTP("http"), HTTPS("https");
@@ -44,7 +49,12 @@ public class QemuImg {
 
     /* Create a new disk image */
     public static void create(String filename, long size, PhysicalDiskFormat 
format, List<Map<String, String>> options) {
-
+        Script s = new Script(_qemuImgPath);
+        s.add("create");
+        s.add("-f");
+        s.add(format.toString());
+        s.add(filename);
+        s.add(Long.toString(size));
     }
 
     public static void create(String filename, long size, PhysicalDiskFormat 
format) {
@@ -93,5 +103,4 @@ public class QemuImg {
             newSize = "-" + size;
         }
     }
-
 }
\ No newline at end of file

Reply via email to