[virt-tools-list] [PATCH libosinfo] Minimum/recommended resources API/data

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Sat Sep 10 00:04:58 UTC 2011


These patches add the needed API and data (only windows ATM) for minimum and
recommended resources for operating systems.

You can test this using the following python script:

----python code-----------

from gi.repository import Libosinfo as libosinfo
from glib import MainLoop, GError
import sys

def cpu_to_str(cpu):
    if cpu < 0:
        return "Unknown"

    mhz = float(cpu) / libosinfo.MEGAHERTZ
    if mhz > 999:
        return str(mhz / 1000) + " GHz"
    else:
        return str(mhz) + " MHz"

def n_cpus_to_str(n_cpus):
    if n_cpus < 0:
        return "Unknown"

    return str(n_cpus)

def memory_to_str(memory):
    if memory < 0:
        return "Unknown"

    mebi = float(memory) / libosinfo.MEBIBYTES
    if mebi > 1024:
        return str(mebi / 1024) + " GiB"
    else:
        return str(mebi) + " MiB"

def print_resources_list(resources_list, name):
    for resources in resources_list.get_elements():
        print " ", name, "resources for", \
              resources.get_architecture()
        print "    cpu:", cpu_to_str(resources.get_cpu())
        print "    ncpus:", n_cpus_to_str(resources.get_n_cpus())
        print "    ram:", memory_to_str(resources.get_ram())
        print "    storage:", memory_to_str(resources.get_storage())

def print_os_info(os):
    print os.get_short_id()

    resources_list = os.get_minimum_resources()
    print_resources_list(resources_list, "Minimum")

    resources_list = os.get_recommended_resources()
    print_resources_list(resources_list, "Recommended")

loader = libosinfo.Loader()
loader.process_default_path()
db = loader.get_db()
oss = db.get_os_list()
for os in oss.get_elements():
   print_os_info(os)

----end of python code----

This code should produce the following on stdout (excl. uninteresting bits):

win2k8
  Minimum resources for x86_64
    cpu: 1.4 GHz
    ncpus: 1
    ram: 512.0 MiB
    storage: 10.0 GiB
  Minimum resources for i386
    cpu: 1.0 GHz
    ncpus: 1
    ram: 512.0 MiB
    storage: 10.0 GiB
  Recommended resources for x86_64
    cpu: 2.0 GHz
    ncpus: Unknown
    ram: 2.0 GiB
    storage: 40.0 GiB
  Recommended resources for i386
    cpu: 2.0 GHz
    ncpus: Unknown
    ram: 2.0 GiB
    storage: 40.0 GiB
win2k3
  Minimum resources for i386
    cpu: 133.0 MHz
    ncpus: 1
    ram: 128.0 MiB
    storage: 2.0 GiB
  Minimum resources for x86_64
    cpu: 1.5 GHz
    ncpus: 1
    ram: 512.0 MiB
    storage: 4.0 GiB
  Recommended resources for i386
    cpu: 550.0 MHz
    ncpus: Unknown
    ram: 256.0 MiB
    storage: 4.0 GiB
  Recommended resources for x86_64
    cpu: Unknown
    ncpus: Unknown
    ram: Unknown
    storage: 8.0 GiB
winxp
  Minimum resources for i386
    cpu: 233.0 MHz
    ncpus: 1
    ram: 64.0 MiB
    storage: 1.5 GiB
  Recommended resources for i386
    cpu: 300.0 MHz
    ncpus: Unknown
    ram: 128.0 MiB
    storage: 2.0 GiB
win7
  Minimum resources for i386
    cpu: 1.0 GHz
    ncpus: 1
    ram: 1024.0 MiB
    storage: 16.0 GiB
  Minimum resources for x86_64
    cpu: 1.0 GHz
    ncpus: 1
    ram: 2.0 GiB
    storage: 20.0 GiB
vista
  Minimum resources for i386
    cpu: 1.0 GHz
    ncpus: 1
    ram: 1024.0 MiB
    storage: 40.0 GiB
  Minimum resources for x86_64
    cpu: 1.0 GHz
    ncpus: 1
    ram: 1024.0 MiB
    storage: 40.0 GiB




More information about the virt-tools-list mailing list