18617606 local_gb is 0 and free_disk_fb is negative in output of nova hypervisor_show
authorStrony <strony.zhang@oracle.com>
Mon, 21 Apr 2014 20:55:06 +0800
changeset 1840 bfe6a6253fcd
parent 1839 796735c6337a
child 1841 2dfc0526bfdd
18617606 local_gb is 0 and free_disk_fb is negative in output of nova hypervisor_show
components/openstack/nova/files/solariszones/driver.py
components/openstack/nova/nova.p5m
--- a/components/openstack/nova/files/solariszones/driver.py	Mon Apr 21 02:59:34 2014 -0700
+++ b/components/openstack/nova/files/solariszones/driver.py	Mon Apr 21 20:55:06 2014 +0800
@@ -1599,13 +1599,36 @@
         """Restore the specified instance."""
         raise NotImplementedError()
 
+    def _get_zpool_property(self, prop, zpool):
+        """Get the value of property from the zpool."""
+        try:
+            value = None
+            (out, _err) = utils.execute('/usr/sbin/zpool', 'get', prop, zpool)
+        except exception.ProcessExecutionError as err:
+            LOG.error(_("Failed to get property '%s' from zpool '%s': %s")
+                      % (prop, zpool, err.stderr))
+            return value
+
+        zpool_prop = out.splitlines()[1].split()
+        if zpool_prop[1] == prop:
+            value = zpool_prop[2]
+
+        return value
+
     def _update_host_stats(self):
         """Update currently known host stats."""
         host_stats = {}
         host_stats['vcpus'] = os.sysconf('SC_NPROCESSORS_ONLN')
         pages = os.sysconf('SC_PHYS_PAGES')
         host_stats['memory_mb'] = self._pages_to_kb(pages) / 1024
-        host_stats['local_gb'] = 0
+
+        out, err = utils.execute('/usr/sbin/zfs', 'list', '-Ho', 'name', '/')
+        root_zpool = out.split('/')[0]
+        size = self._get_zpool_property('size', root_zpool)
+        if size is None:
+            host_stats['local_gb'] = 0
+        else:
+            host_stats['local_gb'] = utils.to_bytes(size)/(1024 ** 3)
 
         # Account for any existing processor sets by looking at the the
         # number of CPUs not assigned to any processor sets.
--- a/components/openstack/nova/nova.p5m	Mon Apr 21 02:59:34 2014 -0700
+++ b/components/openstack/nova/nova.p5m	Mon Apr 21 20:55:06 2014 +0800
@@ -536,6 +536,12 @@
 # force a dependency on package delivering iscsiadm(1M)
 depend type=require fmri=__TBD pkg.debug.depend.file=usr/sbin/iscsiadm
 
+# force a dependency on package delivering zfs(1M)
+depend type=require fmri=__TBD pkg.debug.depend.file=usr/sbin/zfs
+
+# force a dependency on package delivering zpool(1M)
+depend type=require fmri=__TBD pkg.debug.depend.file=usr/sbin/zpool
+
 # force a dependency on anyjson; pkgdepend work is needed to flush this out.
 depend type=require fmri=library/python/anyjson-26