You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ed...@apache.org on 2013/02/01 00:56:54 UTC
git commit: refs/heads/ipv6 - libvirt has bug to report storage
stastics
Updated Branches:
refs/heads/ipv6 ed777bb7f -> 5fc858de7
libvirt has bug to report storage stastics
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/5fc858de
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/5fc858de
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/5fc858de
Branch: refs/heads/ipv6
Commit: 5fc858de7887e655db1876942799cf4299f7a75e
Parents: ed777bb
Author: Edison Su <su...@gmail.com>
Authored: Thu Jan 31 15:55:54 2013 -0800
Committer: Edison Su <su...@gmail.com>
Committed: Thu Jan 31 15:55:54 2013 -0800
----------------------------------------------------------------------
.../kvm/storage/LibvirtStorageAdaptor.java | 27 ++++++++++++---
1 files changed, 22 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5fc858de/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..f9dcd77 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
@@ -386,8 +386,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
}
pool.refresh();
- pool.setCapacity(storage.getInfo().capacity);
- pool.setUsed(storage.getInfo().allocation);
+ getStats(pool);
return pool;
} catch (LibvirtException e) {
@@ -423,6 +422,26 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
}
}
+
+ 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 createStoragePool(String name, String host, int port,
@@ -474,9 +493,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
pool.setLocalPath("");
}
- pool.setCapacity(sp.getInfo().capacity);
- pool.setUsed(sp.getInfo().allocation);
-
+ getStats(pool);
return pool;
} catch (LibvirtException e) {
throw new CloudRuntimeException(e.toString());