Пример #1
0
    def inspect_disks(self, instance):
        instance_name = get_instance_name(instance)
        for disk_metrics in self._utils.get_disk_metrics(instance_name):
            disk = virt_inspector.Disk(device=disk_metrics['instance_id'])
            stats = virt_inspector.DiskStats(
                read_requests=0,
                # Return bytes
                read_bytes=disk_metrics['read_mb'] * units.Mi,
                write_requests=0,
                write_bytes=disk_metrics['write_mb'] * units.Mi,
                errors=0)

            yield (disk, stats)
Пример #2
0
    def inspect_disks(self, instance):
        domain = self._get_domain_not_shut_off_or_raise(instance)

        tree = etree.fromstring(domain.XMLDesc(0))
        for device in filter(bool, [
                target.get("dev")
                for target in tree.findall('devices/disk/target')
        ]):
            disk = virt_inspector.Disk(device=device)
            block_stats = domain.blockStats(device)
            stats = virt_inspector.DiskStats(read_requests=block_stats[0],
                                             read_bytes=block_stats[1],
                                             write_requests=block_stats[2],
                                             write_bytes=block_stats[3],
                                             errors=block_stats[4])
            yield (disk, stats)
Пример #3
0
    def inspect_disks(self, instance_name):
        for disk_metrics in self._utils.get_disk_metrics(instance_name):
            device = dict([(i, disk_metrics[i])
                           for i in ['instance_id', 'host_resource']
                           if i in disk_metrics])

            disk = virt_inspector.Disk(device=device)
            stats = virt_inspector.DiskStats(
                read_requests=0,
                # Return bytes
                read_bytes=disk_metrics['read_mb'] * units.Mi,
                write_requests=0,
                write_bytes=disk_metrics['write_mb'] * units.Mi,
                errors=0)

            yield (disk, stats)
Пример #4
0
 def inspect_disks(self, instance_name):
     domain = self._lookup_by_name(instance_name)
     state = domain.info()[0]
     if state == libvirt.VIR_DOMAIN_SHUTOFF:
         return
     tree = etree.fromstring(domain.XMLDesc(0))
     for device in filter(
             bool,
             [target.get("dev")
              for target in tree.findall('devices/disk/target')]):
         disk = virt_inspector.Disk(device=device)
         block_stats = domain.blockStats(device)
         stats = virt_inspector.DiskStats(read_requests=block_stats[0],
                                          read_bytes=block_stats[1],
                                          write_requests=block_stats[2],
                                          write_bytes=block_stats[3],
                                          errors=block_stats[4])
         yield (disk, stats)