[gnome-boxes/wip/system-libvirt-import2: 3/7] vm-creator: Refactor config creation code



commit bf5ddfa6bc98b0aba4398aadb7b905a435a05921
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Sat Nov 2 17:23:33 2013 +0000

    vm-creator: Refactor config creation code
    
    Put config creation code into a separate method: create_domain_config.
    We keep it protected and virtual cause in a later patch we'll override
    this from a new subclass.

 src/vm-creator.vala |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index ad0d7c3..e1f72ab 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -49,12 +49,9 @@ private class Boxes.VMCreator {
             debug("Disabling unattended installation: %s", error.message);
         }
 
-        var volume = yield create_target_volume (name, install_media.resources.storage);
-        var caps = yield connection.get_capabilities_async (cancellable);
-        var config = VMConfigurator.create_domain_config (install_media, volume.get_path (), caps);
-        config.name = name;
-        config.title = title;
 
+        var volume = yield create_target_volume (name, install_media.resources.storage);
+        var config = yield create_domain_config (name, title, volume, cancellable);
         var domain = connection.create_domain (config);
 
         var machine = LibvirtBroker.get_default ().add_domain (App.app.default_source,
@@ -208,6 +205,18 @@ private class Boxes.VMCreator {
         return pool;
     }
 
+    protected virtual async GVirConfig.Domain create_domain_config (string       name,
+                                                                    string       title,
+                                                                    StorageVol   volume,
+                                                                    Cancellable? cancellable) throws 
GLib.Error {
+        var caps = yield connection.get_capabilities_async (cancellable);
+        var config = VMConfigurator.create_domain_config (install_media, volume.get_path (), caps);
+        config.name = name;
+        config.title = title;
+
+        return config;
+    }
+
     private void increment_num_reboots (LibvirtMachine machine) {
         num_reboots++;
         try {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]