components/openstack/nova/files/solariszones/driver.py
changeset 1840 bfe6a6253fcd
parent 1760 353323c7bdc1
child 1908 702ae3973fcc
equal deleted inserted replaced
1839:796735c6337a 1840:bfe6a6253fcd
  1597 
  1597 
  1598     def restore(self, instance):
  1598     def restore(self, instance):
  1599         """Restore the specified instance."""
  1599         """Restore the specified instance."""
  1600         raise NotImplementedError()
  1600         raise NotImplementedError()
  1601 
  1601 
       
  1602     def _get_zpool_property(self, prop, zpool):
       
  1603         """Get the value of property from the zpool."""
       
  1604         try:
       
  1605             value = None
       
  1606             (out, _err) = utils.execute('/usr/sbin/zpool', 'get', prop, zpool)
       
  1607         except exception.ProcessExecutionError as err:
       
  1608             LOG.error(_("Failed to get property '%s' from zpool '%s': %s")
       
  1609                       % (prop, zpool, err.stderr))
       
  1610             return value
       
  1611 
       
  1612         zpool_prop = out.splitlines()[1].split()
       
  1613         if zpool_prop[1] == prop:
       
  1614             value = zpool_prop[2]
       
  1615 
       
  1616         return value
       
  1617 
  1602     def _update_host_stats(self):
  1618     def _update_host_stats(self):
  1603         """Update currently known host stats."""
  1619         """Update currently known host stats."""
  1604         host_stats = {}
  1620         host_stats = {}
  1605         host_stats['vcpus'] = os.sysconf('SC_NPROCESSORS_ONLN')
  1621         host_stats['vcpus'] = os.sysconf('SC_NPROCESSORS_ONLN')
  1606         pages = os.sysconf('SC_PHYS_PAGES')
  1622         pages = os.sysconf('SC_PHYS_PAGES')
  1607         host_stats['memory_mb'] = self._pages_to_kb(pages) / 1024
  1623         host_stats['memory_mb'] = self._pages_to_kb(pages) / 1024
  1608         host_stats['local_gb'] = 0
  1624 
       
  1625         out, err = utils.execute('/usr/sbin/zfs', 'list', '-Ho', 'name', '/')
       
  1626         root_zpool = out.split('/')[0]
       
  1627         size = self._get_zpool_property('size', root_zpool)
       
  1628         if size is None:
       
  1629             host_stats['local_gb'] = 0
       
  1630         else:
       
  1631             host_stats['local_gb'] = utils.to_bytes(size)/(1024 ** 3)
  1609 
  1632 
  1610         # Account for any existing processor sets by looking at the the
  1633         # Account for any existing processor sets by looking at the the
  1611         # number of CPUs not assigned to any processor sets.
  1634         # number of CPUs not assigned to any processor sets.
  1612         kstat_data = self._get_kstat_by_name('misc', 'unix', '0', 'pset')
  1635         kstat_data = self._get_kstat_by_name('misc', 'unix', '0', 'pset')
  1613         if kstat_data is not None:
  1636         if kstat_data is not None: