def get_available_resource(self, nodename): if not hasattr(self, "_nodename"): self._nodename = nodename if nodename != self._nodename: LOG.error( _("Hostname has changed from %(old)s to %(new)s. " "A restart is required to take effect.") % {"old": self._nodename, "new": nodename} ) memory = hostinfo.get_memory_usage() disk = hostinfo.get_disk_usage() stats = { "vcpus": 1, "vcpus_used": 0, "memory_mb": memory["total"] / units.Mi, "memory_mb_used": memory["used"] / units.Mi, "local_gb": disk["total"] / units.Gi, "local_gb_used": disk["used"] / units.Gi, "disk_available_least": disk["available"] / units.Gi, "hypervisor_type": "docker", "hypervisor_version": utils.convert_version_to_int("1.0"), "hypervisor_hostname": self._nodename, "cpu_info": "?", "supported_instances": jsonutils.dumps([("i686", "docker", "lxc"), ("x86_64", "docker", "lxc")]), } return stats
def get_available_resource(self, nodename): if not hasattr(self, '_nodename'): self._nodename = nodename if nodename != self._nodename: LOG.error(_('Hostname has changed from %(old)s to %(new)s. ' 'A restart is required to take effect.' ) % {'old': self._nodename, 'new': nodename}) memory = hostinfo.get_memory_usage() disk = hostinfo.get_disk_usage() stats = { 'vcpus': 1, 'vcpus_used': 0, 'memory_mb': memory['total'] / units.Mi, 'memory_mb_used': memory['used'] / units.Mi, 'local_gb': disk['total'] / units.Gi, 'local_gb_used': disk['used'] / units.Gi, 'disk_available_least': disk['available'] / units.Gi, 'hypervisor_type': 'docker', 'hypervisor_version': utils.convert_version_to_int('1.0'), 'hypervisor_hostname': self._nodename, 'cpu_info': '?', 'supported_instances': jsonutils.dumps([ ('i686', 'docker', 'lxc'), ('x86_64', 'docker', 'lxc') ]) } return stats
def get_available_resource(self, nodename): memory = hostinfo.get_memory_usage() disk = hostinfo.get_disk_usage() stats = { 'vcpus': 1, 'vcpus_used': 0, 'memory_mb': memory['total'] / (1024**2), 'memory_mb_used': memory['used'] / (1024**2), 'local_gb': disk['total'] / (1024**3), 'local_gb_used': disk['used'] / (1024**3), 'disk_available_least': disk['available'] / (1024**3), 'hypervisor_type': 'docker', 'hypervisor_version': '1.0', 'hypervisor_hostname': nodename, 'cpu_info': '?', 'supported_instances': jsonutils.dumps([('i686', 'docker', 'lxc'), ('x86_64', 'docker', 'lxc')]) } return stats
def get_host_stats(self, refresh=False): hostname = socket.gethostname() memory = hostinfo.get_memory_usage() disk = hostinfo.get_disk_usage() stats = self.get_available_resource(hostname) stats['hypervisor_hostname'] = stats['hypervisor_hostname'] stats['host_hostname'] = stats['hypervisor_hostname'] stats['host_name_label'] = stats['hypervisor_hostname'] return stats
def get_available_resource(self, nodename): memory = hostinfo.get_memory_usage() disk = hostinfo.get_disk_usage() stats = { 'vcpus': 1, 'memory_mb': memory['total'] / 1024 / 1024, 'local_gb': disk['total'] / 1024 / 1024 / 1024, 'vcpus_used': 0, 'memory_mb_used': memory['used'] / 1024 / 1024, 'local_gb_used': disk['used'] / 1024 / 1024 / 1024, 'hypervisor_type': 'docker', 'hypervisor_version': '1.0', 'hypervisor_hostname': nodename, 'cpu_info': '?' } return stats
def get_host_stats(self, refresh=False): hostname = socket.gethostname() memory = hostinfo.get_memory_usage() disk = hostinfo.get_disk_usage() stats = { 'hypervisor_hostname': hostname, 'host_hostname': hostname, 'host_name_label': hostname, 'host_name-description': hostname, 'host_memory_total': memory['total'], 'host_memory_overhead': memory['used'], 'host_memory_free': memory['free'], 'host_memory_free_computed': memory['free'], 'host_other_config': {}, 'host_cpu_info': {}, 'disk_available': disk['available'], 'disk_total': disk['total'], 'disk_used': disk['used'] } return stats
def get_available_resource(self, nodename): if not hasattr(self, '_nodename'): self._nodename = nodename if nodename != self._nodename: LOG.error( _('Hostname has changed from %(old)s to %(new)s. ' 'A restart is required to take effect.') % { 'old': self._nodename, 'new': nodename }) memory = hostinfo.get_memory_usage() disk = hostinfo.get_disk_usage() stats = { 'vcpus': 1, 'vcpus_used': 0, 'memory_mb': memory['total'] / unit.Mi, 'memory_mb_used': memory['used'] / unit.Mi, 'local_gb': disk['total'] / unit.Gi, 'local_gb_used': disk['used'] / unit.Gi, 'disk_available_least': disk['available'] / unit.Gi, 'hypervisor_type': 'docker', 'hypervisor_version': '1.0', 'hypervisor_hostname': self._nodename, 'cpu_info': '?', 'supported_instances': jsonutils.dumps([('i686', 'docker', 'lxc'), ('x86_64', 'docker', 'lxc')]) } return stats
def get_available_resource(self, nodename): memory = hostinfo.get_memory_usage() disk = hostinfo.get_disk_usage() stats = { 'vcpus': 1, 'vcpus_used': 0, 'memory_mb': memory['total'] / (1024 ** 2), 'memory_mb_used': memory['used'] / (1024 ** 2), 'local_gb': disk['total'] / (1024 ** 3), 'local_gb_used': disk['used'] / (1024 ** 3), 'disk_available_least': disk['available'] / (1024 ** 3), 'hypervisor_type': 'docker', 'hypervisor_version': '1.0', 'hypervisor_hostname': nodename, 'cpu_info': '?', 'supported_instances': jsonutils.dumps([ ('i686', 'docker', 'lxc'), ('x86_64', 'docker', 'lxc') ]) } return stats
def test_get_memory_usage(self): usage = hostinfo.get_memory_usage() self.assertEqual(usage['total'], 1043234816) self.assertEqual(usage['used'], 730849280) self.assertEqual(usage['free'], 312385536)