cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtutkow...@apache.org
Subject git commit: updated refs/heads/master to ca2c3c3
Date Wed, 04 Feb 2015 01:14:03 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master d5db87f38 -> ca2c3c30e


Dynamic storage adaptor for KVM


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

Branch: refs/heads/master
Commit: ca2c3c30e29359b79b661af598c96e8c6722327e
Parents: d5db87f
Author: Marcus Sorensen <marcus_sorensen@apple.com>
Authored: Tue Feb 3 12:05:08 2015 -0700
Committer: Mike Tutkowski <mike.tutkowski@solidfire.com>
Committed: Tue Feb 3 12:08:24 2015 -0700

----------------------------------------------------------------------
 .../kvm/storage/IscsiAdmStorageAdaptor.java     |  1 +
 .../kvm/storage/KVMStoragePoolManager.java      | 26 +++++++++++++++++++-
 .../kvm/storage/StorageAdaptorInfo.java         | 15 +++++++++++
 3 files changed, 41 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ca2c3c30/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/IscsiAdmStorageAdaptor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/IscsiAdmStorageAdaptor.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/IscsiAdmStorageAdaptor.java
index f7a8cf7..46a48c9 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/IscsiAdmStorageAdaptor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/IscsiAdmStorageAdaptor.java
@@ -33,6 +33,7 @@ import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.script.OutputInterpreter;
 import com.cloud.utils.script.Script;
 
+@StorageAdaptorInfo(storagePoolType=StoragePoolType.Iscsi)
 public class IscsiAdmStorageAdaptor implements StorageAdaptor {
     private static final Logger s_logger = Logger.getLogger(IscsiAdmStorageAdaptor.class);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ca2c3c30/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 eaf3ba6..40ba11f 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,6 +23,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.log4j.Logger;
@@ -42,6 +43,8 @@ import com.cloud.storage.StorageLayer;
 import com.cloud.storage.Volume;
 import com.cloud.utils.exception.CloudRuntimeException;
 
+import org.reflections.Reflections;
+
 public class KVMStoragePoolManager {
     private static final Logger s_logger = Logger.getLogger(KVMStoragePoolManager.class);
 
@@ -95,8 +98,29 @@ public class KVMStoragePoolManager {
         this._storageMapper.put("libvirt", new LibvirtStorageAdaptor(storagelayer));
         // add other storage adaptors here
         // this._storageMapper.put("newadaptor", new NewStorageAdaptor(storagelayer));
-        this._storageMapper.put(StoragePoolType.Iscsi.toString(), new IscsiAdmStorageAdaptor());
         this._storageMapper.put(StoragePoolType.ManagedNFS.toString(), new ManagedNfsStorageAdaptor(storagelayer));
+
+        // add any adaptors that wish to register themselves via annotation
+        Reflections reflections = new Reflections("com.cloud.hypervisor.kvm.storage");
+        Set<Class<? extends StorageAdaptor>> storageAdaptors = reflections.getSubTypesOf(StorageAdaptor.class);
+        for (Class<? extends StorageAdaptor> storageAdaptor : storageAdaptors) {
+            StorageAdaptorInfo info = storageAdaptor.getAnnotation(StorageAdaptorInfo.class);
+            if (info != null && info.storagePoolType() != null) {
+                if (this._storageMapper.containsKey(info.storagePoolType().toString())) {
+                    s_logger.error("Duplicate StorageAdaptor type " + info.storagePoolType().toString()
+ ", not loading " + storageAdaptor.getName());
+                } else {
+                    try {
+                        this._storageMapper.put(info.storagePoolType().toString(), storageAdaptor.newInstance());
+                    } catch (Exception ex) {
+                       throw new CloudRuntimeException(ex.toString());
+                    }
+                }
+            }
+        }
+
+        for (Map.Entry<String, StorageAdaptor> adaptors : this._storageMapper.entrySet())
{
+            s_logger.debug("Registered a StorageAdaptor for " + adaptors.getKey());
+        }
     }
 
     public boolean connectPhysicalDisk(StoragePoolType type, String poolUuid, String volPath,
Map<String, String> details) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ca2c3c30/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/StorageAdaptorInfo.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/StorageAdaptorInfo.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/StorageAdaptorInfo.java
new file mode 100644
index 0000000..ffc97a5
--- /dev/null
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/StorageAdaptorInfo.java
@@ -0,0 +1,15 @@
+package com.cloud.hypervisor.kvm.storage;
+
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import com.cloud.storage.Storage.StoragePoolType;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ TYPE })
+public @interface StorageAdaptorInfo {
+    StoragePoolType storagePoolType();
+}


Mime
View raw message