summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2013-11-12 00:31:34 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2014-01-27 13:17:45 +0100
commit5fc2ea95ae1b1926350232635cdb322fe1750d4b (patch)
tree4b98bc2289c365c3bee891f7ebd212746ffdc1fc
parent41d32fd92f02ce212aaf199bc2565415e8eb1eeb (diff)
downloadvirt-manager-5fc2ea95ae1b1926350232635cdb322fe1750d4b.tar.gz
osdict: expose libosinfo recommended resources for an OS
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
-rw-r--r--virtinst/osdict.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/virtinst/osdict.py b/virtinst/osdict.py
index f92a8566..36c5038d 100644
--- a/virtinst/osdict.py
+++ b/virtinst/osdict.py
@@ -154,6 +154,14 @@ def lookup_osdict_key(variant, key, default):
return val
+def get_recommended_resources(variant, arch):
+ v = _allvariants.get(variant)
+ if v is None:
+ return None
+
+ return v.get_recommended_resources(arch)
+
+
class _OSVariant(object):
"""
Object tracking guest OS specific configuration bits.
@@ -272,6 +280,10 @@ class _OSVariant(object):
self.virtioconsole = _get_default("virtioconsole", virtioconsole)
self.qemu_ga = _get_default("qemu_ga", qemu_ga)
+ def get_recommended_resources(self, arch):
+ ignore1 = arch
+ return None
+
def _add_type(*args, **kwargs):
kwargs["is_type"] = True
@@ -523,6 +535,23 @@ class _OsVariantOsInfo(_OSVariant):
virtiommio=virtiommio, virtioconsole=virtioconsole,
xen_disable_acpi=xen_disable_acpi, qemu_ga=qemu_ga)
+ def get_recommended_resources(self, arch):
+ ret = {}
+ def read_resource(resources, arch):
+ for i in range(resources.get_length()):
+ r = resources.get_nth(i)
+ if r.get_architecture() == arch:
+ ret["ram"] = r.get_ram()
+ ret["cpu"] = r.get_cpu()
+ ret["n-cpus"] = r.get_n_cpus()
+ ret["storage"] = r.get_storage()
+ break
+
+ read_resource(self._os.get_recommended_resources(), "all")
+ read_resource(self._os.get_recommended_resources(), arch)
+
+ return ret
+
_add_type("linux", "Linux")
_add_type("windows", "Windows", clock="localtime", three_stage_install=True, inputtype="tablet", inputbus="usb", videomodel="vga")
_add_type("solaris", "Solaris", clock="localtime")