Example #1
0
 def update_status(self):
     """Since under Xenserver, a compute node runs on a given host,
     we can get host status information using xenapi.
     """
     LOG.debug(_("Updating host stats"))
     data = call_xenhost(self._session, "host_data", {})
     if data:
         sr_ref = vm_utils.scan_default_sr(self._session)
         sr_rec = self._session.call_xenapi("SR.get_record", sr_ref)
         total = int(sr_rec["physical_size"])
         used = int(sr_rec["physical_utilisation"])
         data["disk_total"] = total
         data["disk_used"] = used
         data["disk_available"] = total - used
         data["supported_instances"] = to_supported_instances(
             data.get("host_capabilities"))
         host_memory = data.get('host_memory', None)
         if host_memory:
             data["host_memory_total"] = host_memory.get('total', 0)
             data["host_memory_overhead"] = host_memory.get('overhead', 0)
             data["host_memory_free"] = host_memory.get('free', 0)
             data["host_memory_free_computed"] = host_memory.get(
                 'free-computed', 0)
             del data['host_memory']
         if (data['host_hostname'] != self._stats.get(
                 'host_hostname', data['host_hostname'])):
             LOG.error(
                 _('Hostname has changed from %(old)s '
                   'to %(new)s. A restart is required to take effect.') % {
                       'old': self._stats['host_hostname'],
                       'new': data['host_hostname']
                   })
             data['host_hostname'] = self._stats['host_hostname']
         data['hypervisor_hostname'] = data['host_hostname']
         self._stats = data
Example #2
0
 def update_status(self):
     """Since under Xenserver, a compute node runs on a given host,
     we can get host status information using xenapi.
     """
     LOG.debug(_("Updating host stats"))
     data = call_xenhost(self._session, "host_data", {})
     if data:
         sr_ref = vm_utils.scan_default_sr(self._session)
         sr_rec = self._session.call_xenapi("SR.get_record", sr_ref)
         total = int(sr_rec["physical_size"])
         used = int(sr_rec["physical_utilisation"])
         data["disk_total"] = total
         data["disk_used"] = used
         data["disk_available"] = total - used
         data["supported_instances"] = to_supported_instances(
             data.get("host_capabilities")
         )
         host_memory = data.get('host_memory', None)
         if host_memory:
             data["host_memory_total"] = host_memory.get('total', 0)
             data["host_memory_overhead"] = host_memory.get('overhead', 0)
             data["host_memory_free"] = host_memory.get('free', 0)
             data["host_memory_free_computed"] = host_memory.get(
                                                 'free-computed', 0)
             del data['host_memory']
         if (data['host_hostname'] !=
                 self._stats.get('host_hostname', data['host_hostname'])):
             LOG.error(_('Hostname has changed from %(old)s '
                         'to %(new)s. A restart is required to take effect.'
                         ) % {'old': self._stats['host_hostname'],
                              'new': data['host_hostname']})
             data['host_hostname'] = self._stats['host_hostname']
         data['hypervisor_hostname'] = data['host_hostname']
         self._stats = data
Example #3
0
    def update_status(self):
        """Since under Xenserver, a compute node runs on a given host,
        we can get host status information using xenapi.
        """
        LOG.debug("Updating host stats")
        data = call_xenhost(self._session, "host_data", {})


        def _get_total_network_bandwidth ():
            ethersOut = os.popen('ls -d /sys/class/net/eth*');
            ethers = ethersOut.readlines();
            totalSpeed = 0;

            for ether in ethers:
                cmd = 'cat ' + ether[:-1] + '/speed';
                speed = os.popen(cmd);
                speedInMB = int (speed.read());
                totalSpeed = totalSpeed + speedInMB;
                speed.close();

            ethersOut.close();

            return totalSpeed;

        if data:
            sr_ref = vm_utils.scan_default_sr(self._session)
            sr_rec = self._session.SR.get_record(sr_ref)
            total = int(sr_rec["physical_size"])
            used = int(sr_rec["physical_utilisation"])
            data["disk_total"] = total
            data["disk_used"] = used
            data["disk_allocated"] = int(sr_rec["virtual_allocation"])
            data["disk_available"] = total - used
            data["supported_instances"] = to_supported_instances(
                data.get("host_capabilities")
            )
            host_memory = data.get('host_memory', None)
            if host_memory:
                data["host_memory_total"] = host_memory.get('total', 0)
                data["host_memory_overhead"] = host_memory.get('overhead', 0)
                data["host_memory_free"] = host_memory.get('free', 0)
                data["host_memory_free_computed"] = host_memory.get(
                                                    'free-computed', 0)
                del data['host_memory']
            if (data['host_hostname'] !=
                    self._stats.get('host_hostname', data['host_hostname'])):
                LOG.error(_('Hostname has changed from %(old)s '
                            'to %(new)s. A restart is required to take effect.'
                            ) % {'old': self._stats['host_hostname'],
                                 'new': data['host_hostname']})
                data['host_hostname'] = self._stats['host_hostname']
            data['hypervisor_hostname'] = data['host_hostname']
            vcpus_used = 0
            for vm_ref, vm_rec in vm_utils.list_vms(self._session):
                vcpus_used = vcpus_used + int(vm_rec['VCPUs_max'])
            data['vcpus_used'] = vcpus_used
            data['pci_passthrough_devices'] = self._get_passthrough_devices()
            data['total_bandwidth'] = _get_total_network_bandwidth ();
            data['bandwidth_used'] = 0;
            self._stats = data
 def update_status(self):
     """Since under Xenserver, a compute node runs on a given host,
     we can get host status information using xenapi.
     """
     LOG.debug("Updating host stats")
     data = _call_host_management(self._session,
                                  host_management.get_host_data)
     if data:
         sr_ref = vm_utils.scan_default_sr(self._session)
         sr_rec = self._session.SR.get_record(sr_ref)
         total = int(sr_rec["physical_size"])
         (allocated, used) = self.get_disk_used(sr_ref)
         data["disk_total"] = total
         data["disk_used"] = used
         data["disk_allocated"] = allocated
         data["disk_available"] = total - used
         data["supported_instances"] = to_supported_instances(
             data.get("host_capabilities")
         )
         data["cpu_model"] = to_cpu_model(
             data.get("host_cpu_info")
         )
         host_memory = data.get('host_memory', None)
         if host_memory:
             data["host_memory_total"] = host_memory.get('total', 0)
             data["host_memory_overhead"] = host_memory.get('overhead', 0)
             data["host_memory_free"] = host_memory.get('free', 0)
             data["host_memory_free_computed"] = host_memory.get(
                                                 'free-computed', 0)
             del data['host_memory']
         if (data['host_hostname'] !=
                 self._stats.get('host_hostname', data['host_hostname'])):
             LOG.error('Hostname has changed from %(old)s to %(new)s. '
                       'A restart is required to take effect.',
                       {'old': self._stats['host_hostname'],
                        'new': data['host_hostname']})
             data['host_hostname'] = self._stats['host_hostname']
         data['hypervisor_hostname'] = data['host_hostname']
         vcpus_used = 0
         for vm_ref, vm_rec in vm_utils.list_vms(self._session):
             vcpus_used = vcpus_used + int(vm_rec['VCPUs_max'])
         data['vcpus_used'] = vcpus_used
         data['pci_passthrough_devices'] = self._get_passthrough_devices()
         data['vgpu_stats'] = self._get_vgpu_stats()
         self._stats = data
Example #5
0
 def update_status(self):
     """Since under Xenserver, a compute node runs on a given host,
     we can get host status information using xenapi.
     """
     LOG.debug("Updating host stats")
     data = _call_host_management(self._session,
                                  host_management.get_host_data)
     if data:
         sr_ref = vm_utils.scan_default_sr(self._session)
         sr_rec = self._session.SR.get_record(sr_ref)
         total = int(sr_rec["physical_size"])
         (allocated, used) = self.get_disk_used(sr_ref)
         data["disk_total"] = total
         data["disk_used"] = used
         data["disk_allocated"] = allocated
         data["disk_available"] = total - used
         data["supported_instances"] = to_supported_instances(
             data.get("host_capabilities")
         )
         data["cpu_model"] = to_cpu_model(
             data.get("host_cpu_info")
         )
         host_memory = data.get('host_memory', None)
         if host_memory:
             data["host_memory_total"] = host_memory.get('total', 0)
             data["host_memory_overhead"] = host_memory.get('overhead', 0)
             data["host_memory_free"] = host_memory.get('free', 0)
             data["host_memory_free_computed"] = host_memory.get(
                                                 'free-computed', 0)
             del data['host_memory']
         if (data['host_hostname'] !=
                 self._stats.get('host_hostname', data['host_hostname'])):
             LOG.error('Hostname has changed from %(old)s to %(new)s. '
                       'A restart is required to take effect.',
                       {'old': self._stats['host_hostname'],
                        'new': data['host_hostname']})
             data['host_hostname'] = self._stats['host_hostname']
         data['hypervisor_hostname'] = data['host_hostname']
         vcpus_used = 0
         for vm_ref, vm_rec in vm_utils.list_vms(self._session):
             vcpus_used = vcpus_used + int(vm_rec['VCPUs_max'])
         data['vcpus_used'] = vcpus_used
         data['pci_passthrough_devices'] = self._get_passthrough_devices()
         data['vgpu_stats'] = self._get_vgpu_stats()
         self._stats = data