[gnome-boxes] libvirt-machine-properties: Refactor mark_recommended_resources
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] libvirt-machine-properties: Refactor mark_recommended_resources
- Date: Mon, 9 Dec 2013 23:18:37 +0000 (UTC)
commit f2774c73f77591cd791a1423a7b3ae7fb8299d60
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Dec 3 18:35:17 2013 +0000
libvirt-machine-properties: Refactor mark_recommended_resources
Put code related to getting the os of a machine into a separate method.
src/libvirt-machine-properties.vala | 27 ++++++++++++++++-----------
1 files changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index b5bfbec..c12eca2 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -372,19 +372,10 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
if (ram_property == null && storage_property == null)
return;
- var os_id = VMConfigurator.get_os_id (machine.domain_config);
- if (os_id == null)
+ var os = yield get_os_for_machine (machine);
+ if (os == null)
return;
- var os_db = MediaManager.get_instance ().os_db;
- Osinfo.Os os;
- try {
- os = yield os_db.get_os_by_id (os_id);
- } catch (OSDatabaseError error) {
- warning ("Failed to find OS with ID '%s': %s", os_id, error.message);
- return;
- }
-
var architecture = machine.domain_config.get_os ().get_arch ();
var resources = OSDatabase.get_recommended_resources_for_os (os, architecture);
if (resources != null) {
@@ -395,6 +386,20 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
}
}
+ private async Osinfo.Os? get_os_for_machine (LibvirtMachine machine) {
+ var os_id = VMConfigurator.get_os_id (machine.domain_config);
+ if (os_id == null)
+ return null;
+
+ var os_db = MediaManager.get_instance ().os_db;
+ try {
+ return yield os_db.get_os_by_id (os_id);
+ } catch (OSDatabaseError error) {
+ warning ("Failed to find OS with ID '%s': %s", os_id, error.message);
+ return null;
+ }
+ }
+
private SizeProperty? add_ram_property (ref List<Boxes.Property> list) {
try {
var max_ram = machine.connection.get_node_info ().memory;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]