You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by wi...@apache.org on 2013/02/26 15:14:11 UTC
[36/36] git commit: refs/heads/qemu-img - Check the output of
Script.Execute and throw an exception if it's not NULL
Updated Branches:
refs/heads/qemu-img d93582d0a -> ff62902df
Check the output of Script.Execute and throw an exception if it's not NULL
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/ff62902d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/ff62902d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/ff62902d
Branch: refs/heads/qemu-img
Commit: ff62902dfa798aa9593c642d7180d32161d0e887
Parents: 9f970b1
Author: Wido den Hollander <wi...@widodh.nl>
Authored: Tue Feb 26 15:03:24 2013 +0100
Committer: Wido den Hollander <wi...@widodh.nl>
Committed: Tue Feb 26 15:03:24 2013 +0100
----------------------------------------------------------------------
.../org/apache/cloudstack/utils/qemu/QemuImg.java | 36 +++++++++-----
.../apache/cloudstack/utils/qemu/QemuImgTest.java | 18 ++++----
2 files changed, 32 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ff62902d/utils/src/org/apache/cloudstack/utils/qemu/QemuImg.java
----------------------------------------------------------------------
diff --git a/utils/src/org/apache/cloudstack/utils/qemu/QemuImg.java b/utils/src/org/apache/cloudstack/utils/qemu/QemuImg.java
index 43107ea..26c1a61 100644
--- a/utils/src/org/apache/cloudstack/utils/qemu/QemuImg.java
+++ b/utils/src/org/apache/cloudstack/utils/qemu/QemuImg.java
@@ -83,7 +83,7 @@ public class QemuImg {
* pairs which are passed on to qemu-img without validation.
* @return void
*/
- public void create(QemuImgFile file, QemuImgFile backingFile, Map<String, String> options) {
+ public void create(QemuImgFile file, QemuImgFile backingFile, Map<String, String> options) throws QemuImgException {
Script s = new Script(_qemuImgPath);
s.add("create");
@@ -114,7 +114,10 @@ public class QemuImg {
if (backingFile == null) {
s.add(Long.toString(file.getSize()));
}
- s.execute();
+ String result = s.execute();
+ if (result != null) {
+ throw new QemuImgException(result);
+ }
}
/**
@@ -126,7 +129,7 @@ public class QemuImg {
* The file to create
* @return void
*/
- public void create(QemuImgFile file) {
+ public void create(QemuImgFile file) throws QemuImgException {
this.create(file, null, null);
}
@@ -141,7 +144,7 @@ public class QemuImg {
* A backing file if used (for example with qcow2)
* @return void
*/
- public void create(QemuImgFile file, QemuImgFile backingFile) {
+ public void create(QemuImgFile file, QemuImgFile backingFile) throws QemuImgException {
this.create(file, backingFile, null);
}
@@ -157,7 +160,7 @@ public class QemuImg {
* pairs which are passed on to qemu-img without validation.
* @return void
*/
- public void create(QemuImgFile file, Map<String, String> options) {
+ public void create(QemuImgFile file, Map<String, String> options) throws QemuImgException {
this.create(file, null, options);
}
@@ -177,7 +180,7 @@ public class QemuImg {
* pairs which are passed on to qemu-img without validation.
* @return void
*/
- public void convert(QemuImgFile srcFile, QemuImgFile destFile, Map<String, String> options) {
+ public void convert(QemuImgFile srcFile, QemuImgFile destFile, Map<String, String> options) throws QemuImgException {
Script s = new Script(_qemuImgPath);
s.add("convert");
s.add("-f");
@@ -196,7 +199,11 @@ public class QemuImg {
s.add(srcFile.getFileName());
s.add(destFile.getFileName());
- s.execute();
+
+ String result = s.execute();
+ if (result != null) {
+ throw new QemuImgException(result);
+ }
}
/**
@@ -212,7 +219,7 @@ public class QemuImg {
* The destination file
* @return void
*/
- public void convert(QemuImgFile srcFile, QemuImgFile destFile) {
+ public void convert(QemuImgFile srcFile, QemuImgFile destFile) throws QemuImgException {
this.convert(srcFile, destFile, null);
}
@@ -226,7 +233,7 @@ public class QemuImg {
* The file of which changes have to be committed
* @return void
*/
- public void commit(QemuImgFile file) {
+ public void commit(QemuImgFile file) throws QemuImgException {
}
@@ -244,12 +251,15 @@ public class QemuImg {
* A QemuImgFile object containing the file to get the information from
* @return A HashMap with String key-value information as returned by 'qemu-img info'
*/
- public Map<String, String> info(QemuImgFile file) {
+ public Map<String, String> info(QemuImgFile file) throws QemuImgException {
Script s = new Script(_qemuImgPath);
s.add("info");
s.add(file.getFileName());
OutputInterpreter.AllLinesParser parser = new OutputInterpreter.AllLinesParser();
- s.execute(parser);
+ String result = s.execute(parser);
+ if (result != null) {
+ throw new QemuImgException(result);
+ }
HashMap<String,String> info = new HashMap<String,String>();
String[] outputBuffer = parser.getLines().trim().split("\n");
@@ -272,12 +282,12 @@ public class QemuImg {
}
/* List, apply, create or delete snapshots in image */
- public void snapshot() {
+ public void snapshot() throws QemuImgException {
}
/* Changes the backing file of an image */
- public void rebase() {
+ public void rebase() throws QemuImgException {
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ff62902d/utils/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java
----------------------------------------------------------------------
diff --git a/utils/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java b/utils/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java
index e89ab91..cd513bf 100644
--- a/utils/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java
+++ b/utils/test/org/apache/cloudstack/utils/qemu/QemuImgTest.java
@@ -29,7 +29,7 @@ import java.io.File;
public class QemuImgTest {
@Test
- public void testCreateAndInfo() {
+ public void testCreateAndInfo() throws QemuImgException {
String filename = "/tmp/" + UUID.randomUUID() + ".qcow2";
/* 10TB virtual_size */
@@ -56,7 +56,7 @@ public class QemuImgTest {
}
@Test
- public void testCreateAndInfoWithOptions() {
+ public void testCreateAndInfoWithOptions() throws QemuImgException {
String filename = "/tmp/" + UUID.randomUUID() + ".qcow2";
/* 10TB virtual_size */
@@ -86,7 +86,7 @@ public class QemuImgTest {
}
@Test
- public void testCreateAndResize() {
+ public void testCreateAndResize() throws QemuImgException {
String filename = "/tmp/" + UUID.randomUUID() + ".qcow2";
long startSize = 20480;
@@ -115,7 +115,7 @@ public class QemuImgTest {
}
@Test
- public void testCreateAndResizeDeltaPositive() {
+ public void testCreateAndResizeDeltaPositive() throws QemuImgException {
String filename = "/tmp/" + UUID.randomUUID() + ".qcow2";
long startSize = 20480;
@@ -143,7 +143,7 @@ public class QemuImgTest {
}
@Test
- public void testCreateAndResizeDeltaNegative() {
+ public void testCreateAndResizeDeltaNegative() throws QemuImgException {
String filename = "/tmp/" + UUID.randomUUID() + ".qcow2";
long startSize = 81920;
@@ -198,7 +198,7 @@ public class QemuImgTest {
}
@Test(expected = QemuImgException.class)
- public void testCreateAndResizeZero() throws QemuImgException {
+ public void testCreateAndResizeZero() throws QemuImgException {
String filename = "/tmp/" + UUID.randomUUID() + ".qcow2";
long startSize = 20480;
@@ -214,7 +214,7 @@ public class QemuImgTest {
}
@Test
- public void testCreateWithBackingFile() {
+ public void testCreateWithBackingFile() throws QemuImgException {
String firstFileName = "/tmp/" + UUID.randomUUID() + ".qcow2";
String secondFileName = "/tmp/" + UUID.randomUUID() + ".qcow2";
@@ -237,7 +237,7 @@ public class QemuImgTest {
}
@Test
- public void testConvertBasic() {
+ public void testConvertBasic() throws QemuImgException {
long srcSize = 20480;
String srcFileName = "/tmp/" + UUID.randomUUID() + ".qcow2";
String destFileName = "/tmp/" + UUID.randomUUID() + ".qcow2";
@@ -262,7 +262,7 @@ public class QemuImgTest {
}
@Test
- public void testConvertAdvanced() {
+ public void testConvertAdvanced() throws QemuImgException {
long srcSize = 4019200;
String srcFileName = "/tmp/" + UUID.randomUUID() + ".qcow2";
String destFileName = "/tmp/" + UUID.randomUUID() + ".qcow2";