'Since under Xenserver, a compute node runs on a given host,
we can get host status information using xenapi.'

def update_status(self):

    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()
        self._stats = data
