incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [1/5] git commit: refs/heads/qemu-img - Move the PhysicalDiskFormat type from KVMPhysicalDisk to QemuImg
Date Wed, 06 Feb 2013 16:51:33 GMT
Move the PhysicalDiskFormat type from KVMPhysicalDisk to QemuImg

This way we have one point where we keep track of the Qemu disk formats
instead of multiple points in the code.


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

Branch: refs/heads/qemu-img
Commit: 5dbaaa8183cb6e71fd3d83a19781c8436c58e9c6
Parents: ad88091
Author: Wido den Hollander <wido@widodh.nl>
Authored: Wed Feb 6 13:57:14 2013 +0100
Committer: Wido den Hollander <wido@widodh.nl>
Committed: Wed Feb 6 13:57:14 2013 +0100

----------------------------------------------------------------------
 .../kvm/resource/LibvirtComputingResource.java     |    8 ++++----
 .../kvm/resource/LibvirtDomainXMLParser.java       |    1 +
 .../hypervisor/kvm/storage/KVMPhysicalDisk.java    |   15 ++-------------
 .../hypervisor/kvm/storage/KVMStoragePool.java     |    2 +-
 .../kvm/storage/KVMStoragePoolManager.java         |    9 +++++----
 .../kvm/storage/LibvirtStorageAdaptor.java         |    8 ++++----
 .../hypervisor/kvm/storage/LibvirtStoragePool.java |    2 +-
 .../hypervisor/kvm/storage/StorageAdaptor.java     |    2 +-
 8 files changed, 19 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5dbaaa81/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index f320a66..f11fa46 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -55,6 +55,7 @@ import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
 import org.apache.log4j.Logger;
+import org.apache.cloudstack.utils.QemuImg.PhysicalDiskFormat;
 import org.libvirt.Connect;
 import org.libvirt.Domain;
 import org.libvirt.DomainInfo;
@@ -188,7 +189,6 @@ import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef.hostNicType;
 import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.SerialDef;
 import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.TermPolicy;
 import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk;
-import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
 import com.cloud.hypervisor.kvm.storage.KVMStoragePool;
 import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager;
 import com.cloud.network.Networks.BroadcastDomainType;
@@ -1400,12 +1400,12 @@ ServerResource {
         StoragePoolType poolType = pool.getType();
         PhysicalDiskFormat volFormat = vol.getFormat();
          
-        if(pool.getType() == StoragePoolType.CLVM && volFormat == KVMPhysicalDisk.PhysicalDiskFormat.RAW)
{
+        if(pool.getType() == StoragePoolType.CLVM && volFormat == PhysicalDiskFormat.RAW)
{
             return "CLVM";
         } else if ((poolType == StoragePoolType.NetworkFilesystem
                   || poolType == StoragePoolType.SharedMountPoint
                   || poolType == StoragePoolType.Filesystem)
-                  && volFormat == KVMPhysicalDisk.PhysicalDiskFormat.QCOW2 ) {
+                  && volFormat == PhysicalDiskFormat.QCOW2 ) {
             return "QCOW2";
         }
         return null;
@@ -3255,7 +3255,7 @@ ServerResource {
 
         if (!foundDisk) {
             s_logger.debug("generating new patch disk for " + vmName + " since none was found");
-            KVMPhysicalDisk disk = pool.createPhysicalDisk(patchName, KVMPhysicalDisk.PhysicalDiskFormat.RAW,
+            KVMPhysicalDisk disk = pool.createPhysicalDisk(patchName, PhysicalDiskFormat.RAW,
                     10L * 1024 * 1024);
         } else {
             s_logger.debug("found existing patch disk at " + patchDiskPath + " using it for
" + vmName);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5dbaaa81/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
index b622b6d..26c8968 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java
@@ -25,6 +25,7 @@ import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.apache.cloudstack.utils.QemuImg.PhysicalDiskFormat;
 import org.apache.log4j.Logger;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5dbaaa81/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMPhysicalDisk.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMPhysicalDisk.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMPhysicalDisk.java
index 08f51a4..a3e3cee 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMPhysicalDisk.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMPhysicalDisk.java
@@ -16,24 +16,13 @@
 // under the License.
 package com.cloud.hypervisor.kvm.storage;
 
+import org.apache.cloudstack.utils.QemuImg.PhysicalDiskFormat;
+
 public class KVMPhysicalDisk {
     private String path;
     private String name;
     private KVMStoragePool pool;
 
-    public static enum PhysicalDiskFormat {
-        RAW("raw"), QCOW2("qcow2");
-        String format;
-
-        private PhysicalDiskFormat(String format) {
-            this.format = format;
-        }
-
-        public String toString() {
-            return this.format;
-        }
-    }
-
     public static String RBDStringBuilder(String monHost, int monPort,
                             String authUserName, String authSecret, String image) {
         String rbdOpts;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5dbaaa81/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePool.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePool.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePool.java
index 5437e7c..956a6c1 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePool.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePool.java
@@ -18,7 +18,7 @@ package com.cloud.hypervisor.kvm.storage;
 
 import java.util.List;
 
-import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
+import org.apache.cloudstack.utils.QemuImg.PhysicalDiskFormat;
 import com.cloud.storage.Storage.StoragePoolType;
 
 public interface KVMStoragePool {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5dbaaa81/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java
index c2bfad9..0ab7808 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java
@@ -23,10 +23,11 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.HashMap;
 import java.util.UUID;
 
+import org.apache.cloudstack.utils.QemuImg.PhysicalDiskFormat;
+
 import com.cloud.hypervisor.kvm.resource.KVMHABase;
 import com.cloud.hypervisor.kvm.resource.KVMHABase.PoolType;
 import com.cloud.hypervisor.kvm.resource.KVMHAMonitor;
-import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
 import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.StorageLayer;
 import com.cloud.utils.exception.CloudRuntimeException;
@@ -134,14 +135,14 @@ public class KVMStoragePoolManager {
         // LibvirtStorageAdaptor-specific statement
         if (destPool.getType() == StoragePoolType.RBD) {
             return adaptor.createDiskFromTemplate(template, name,
-                    KVMPhysicalDisk.PhysicalDiskFormat.RAW, template.getSize(), destPool);
+                    PhysicalDiskFormat.RAW, template.getSize(), destPool);
         } else if (destPool.getType() == StoragePoolType.CLVM) {
             return adaptor.createDiskFromTemplate(template, name,
-                                       KVMPhysicalDisk.PhysicalDiskFormat.RAW, template.getSize(),
+                                       PhysicalDiskFormat.RAW, template.getSize(),
                                        destPool);
         } else {
             return adaptor.createDiskFromTemplate(template, name,
-                    KVMPhysicalDisk.PhysicalDiskFormat.QCOW2,
+                    PhysicalDiskFormat.QCOW2,
             template.getSize(), destPool);
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5dbaaa81/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
index d350ef9..b809498 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
@@ -24,6 +24,7 @@ import java.util.List;
 import java.util.UUID;
 import org.apache.log4j.Logger;
 import org.apache.commons.codec.binary.Base64;
+import org.apache.cloudstack.utils.QemuImg.PhysicalDiskFormat;
 import org.libvirt.Connect;
 import org.libvirt.LibvirtException;
 import org.libvirt.Secret;
@@ -43,7 +44,6 @@ import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef.poolType;
 import com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef.authType;
 import com.cloud.hypervisor.kvm.resource.LibvirtStorageVolumeDef.volFormat;
 import com.cloud.hypervisor.kvm.resource.LibvirtStorageVolumeXMLParser;
-import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
 import com.cloud.exception.InternalErrorException;
 import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.StorageLayer;
@@ -411,11 +411,11 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
             if (voldef.getFormat() == null) {
                 disk.setFormat(pool.getDefaultFormat());
             } else if (pool.getType() == StoragePoolType.RBD) {
-                disk.setFormat(KVMPhysicalDisk.PhysicalDiskFormat.RAW);
+                disk.setFormat(PhysicalDiskFormat.RAW);
             } else if (voldef.getFormat() == LibvirtStorageVolumeDef.volFormat.QCOW2) {
-                disk.setFormat(KVMPhysicalDisk.PhysicalDiskFormat.QCOW2);
+                disk.setFormat(PhysicalDiskFormat.QCOW2);
             } else if (voldef.getFormat() == LibvirtStorageVolumeDef.volFormat.RAW) {
-                disk.setFormat(KVMPhysicalDisk.PhysicalDiskFormat.RAW);
+                disk.setFormat(PhysicalDiskFormat.RAW);
             }
             return disk;
         } catch (LibvirtException e) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5dbaaa81/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStoragePool.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStoragePool.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStoragePool.java
index 32f8ce9..688ab95 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStoragePool.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStoragePool.java
@@ -18,9 +18,9 @@ package com.cloud.hypervisor.kvm.storage;
 
 import java.util.List;
 
+import org.apache.cloudstack.utils.QemuImg.PhysicalDiskFormat;
 import org.libvirt.StoragePool;
 
-import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
 import com.cloud.storage.Storage.StoragePoolType;
 
 public class LibvirtStoragePool implements KVMStoragePool {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5dbaaa81/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/StorageAdaptor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/StorageAdaptor.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/StorageAdaptor.java
index 79c3b92..4e4e91b 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/StorageAdaptor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/StorageAdaptor.java
@@ -18,7 +18,7 @@ package com.cloud.hypervisor.kvm.storage;
 
 import java.util.List;
 
-import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk.PhysicalDiskFormat;
+import org.apache.cloudstack.utils.QemuImg.PhysicalDiskFormat;
 import com.cloud.storage.Storage.StoragePoolType;
 
 public interface StorageAdaptor {


Mime
View raw message