コード例 #1
0
    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': hostinfo.get_total_vcpus(),
            'vcpus_used': hostinfo.get_vcpus_used(self.list_instances(True)),
            '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([
                (arch.I686, hv_type.DOCKER, vm_mode.EXE),
                (arch.X86_64, hv_type.DOCKER, vm_mode.EXE)
            ])
        }
        return stats
コード例 #2
0
ファイル: driver.py プロジェクト: cc272309126/nova-docker
    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
コード例 #3
0
ファイル: driver.py プロジェクト: almightyyeh/nova-docker
    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': hostinfo.get_total_vcpus(),
            'vcpus_used': hostinfo.get_vcpus_used(self.list_instances(True)),
            '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': versionutils.convert_version_to_int('1.0'),
            'hypervisor_hostname': self._nodename,
            'cpu_info': '?',
            'numa_topology': None,
            'supported_instances': [
                (arch.I686, hv_type.DOCKER, vm_mode.EXE),
                (arch.X86_64, hv_type.DOCKER, vm_mode.EXE)
            ]
        }
        return stats
コード例 #4
0
ファイル: test_hostinfo.py プロジェクト: huyanhua/nova-docker
 def test_get_disk_usage(self):
     disk_usage = hostinfo.get_disk_usage()
     self.assertEqual(disk_usage['total'],
                      self._FAKE_DISK_INFO['total_size'])
     self.assertEqual(disk_usage['available'],
                      self._FAKE_DISK_INFO['free_size'])
     self.assertEqual(disk_usage['used'], self._FAKE_DISK_INFO['used_size'])
コード例 #5
0
ファイル: driver.py プロジェクト: sckevmit/nova-docker
 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
コード例 #6
0
ファイル: driver.py プロジェクト: prydeep/nova-docker
 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
コード例 #7
0
    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':
            hostinfo.get_total_vcpus(),
            'vcpus_used':
            hostinfo.get_vcpus_used(self.list_instances(True)),
            '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':
            versionutils.convert_version_to_int('1.0'),
            'hypervisor_hostname':
            self._nodename,
            'cpu_info':
            '?',
            'numa_topology':
            None,
            # zy: pay attention that if you do not define supported_instance,you won't start an container from this node
            # zy: add new architectures
            'supported_instances':
            [(arch.I686, hv_type.DOCKER, vm_mode.EXE),
             (arch.X86_64, hv_type.DOCKER, vm_mode.EXE),
             (arch.ARMV7, hv_type.DOCKER, vm_mode.EXE),
             (arch.AARCH64, hv_type.DOCKER, vm_mode.EXE),
             (arch.PPC64LE, hv_type.DOCKER, vm_mode.EXE)]
        }
        return stats
コード例 #8
0
 def test_get_disk_usage(self):
     disk_usage = hostinfo.get_disk_usage()
     self.assertEqual(disk_usage['total'], 41154895872)
     self.assertEqual(disk_usage['available'], 27935518720)
     self.assertEqual(disk_usage['used'], 11121963008)
コード例 #9
0
 def test_get_disk_usage(self):
     disk_usage = hostinfo.get_disk_usage()
     self.assertEqual(disk_usage['total'], 41154895872)
     self.assertEqual(disk_usage['available'], 27935518720)
     self.assertEqual(disk_usage['used'], 11121963008)