You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2012/08/02 04:08:32 UTC
[29/44] git commit: kvm: Use libvirt for polling storage pool
capacity and allocation
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/vpc
Commit: 2ffc9907f7b0d371737e39b7649f7af23026f5cf
Parents: a1b2f7a
Author: Wido den Hollander <wi...@widodh.nl>
Authored: Wed Aug 1 17:18:11 2012 +0200
Committer: Wido den Hollander <wi...@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());