incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject git commit: kvm: Use libvirt for polling storage pool capacity and allocation
Date Wed, 01 Aug 2012 15:20:59 GMT
Updated Branches:
  refs/heads/master a1b2f7aec -> 2ffc9907f


kvm: Use libvirt for polling storage pool capacity and allocation

Since we are using libvirt for handling our storage pools we should rely on that information
as well.

Before fetching the capacity we refresh the pool so libvirt has the most up-to-date information.

This is not needed with newly created pools since libvirt does a refresh on creation.


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

Branch: refs/heads/master
Commit: 2ffc9907f7b0d371737e39b7649f7af23026f5cf
Parents: a1b2f7a
Author: Wido den Hollander <wido@widodh.nl>
Authored: Wed Aug 1 17:18:11 2012 +0200
Committer: Wido den Hollander <wido@widodh.nl>
Committed: Wed Aug 1 17:18:11 2012 +0200

----------------------------------------------------------------------
 .../kvm/storage/LibvirtStorageAdaptor.java         |   37 ++------------
 1 files changed, 6 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2ffc9907/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 90003f9..4efffd6 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
@@ -446,25 +446,6 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
         return pool;
     }
 
-    private void getStats(LibvirtStoragePool pool) {
-        Script statsScript = new Script("/bin/bash", s_logger);
-        statsScript.add("-c");
-        statsScript.add("stats=$(df --total " + pool.getLocalPath()
-                + " |grep total|awk '{print $2,$3}');echo $stats");
-        final OutputInterpreter.OneLineParser statsParser = new OutputInterpreter.OneLineParser();
-        String result = statsScript.execute(statsParser);
-        if (result == null) {
-            String stats = statsParser.getLine();
-            if (stats != null && !stats.isEmpty()) {
-                String sizes[] = stats.trim().split(" ");
-                if (sizes.length == 2) {
-                    pool.setCapacity(Long.parseLong(sizes[0]) * 1024);
-                    pool.setUsed(Long.parseLong(sizes[1]) * 1024);
-                }
-            }
-        }
-    }
-
     @Override
     public KVMStoragePool getStoragePool(String uuid) {
         StoragePool storage = null;
@@ -503,12 +484,9 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
                 }
             }
 
-            if (pool.getType() == StoragePoolType.RBD) {
-                pool.setCapacity(storage.getInfo().capacity);
-                pool.setUsed(storage.getInfo().allocation);
-            } else {
-                getStats(pool);
-            }
+            pool.refresh();
+            pool.setCapacity(storage.getInfo().capacity);
+            pool.setUsed(storage.getInfo().allocation);
 
             return pool;
         } catch (LibvirtException e) {
@@ -593,12 +571,9 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
                 pool.setLocalPath("");
             }
 
-            if (pool.getType() == StoragePoolType.RBD) {
-                pool.setCapacity(sp.getInfo().capacity);
-                pool.setUsed(sp.getInfo().allocation);
-            } else {
-                getStats(pool);
-            }
+            pool.setCapacity(sp.getInfo().capacity);
+            pool.setUsed(sp.getInfo().allocation);
+  
             return pool;
         } catch (LibvirtException e) {
             throw new CloudRuntimeException(e.toString());


Mime
View raw message