firstboot: do not abort configuring other templates if one fails

This commit is contained in:
Marek Marczykowski-Górecki 2015-04-15 12:11:16 +02:00
parent ed9a728235
commit 73f06661bb

View File

@ -86,10 +86,12 @@ class moduleClass(Module):
errors = []
for template in os.listdir('/var/lib/qubes/vm-templates'):
try:
self.configure_template()
self.configure_template(template)
except Exception as e:
errors.append((self.stage, str(e)))
try:
self.create_default_netvm()
self.create_default_fwvm()
@ -97,6 +99,7 @@ class moduleClass(Module):
self.start_qubes_networking()
except Exception as e:
errors.append((self.stage, str(e)))
try:
self.create_default_dvm()
except Exception as e:
@ -138,12 +141,12 @@ class moduleClass(Module):
def set_default_template(self):
subprocess.call(['/usr/bin/qubes-prefs', '--set', 'default-template', self.default_template])
def configure_template(self):
self.show_stage(_("Configuring default TemplateVM"))
self.run_in_thread(self.do_configure_template)
def configure_template(self, name):
self.show_stage(_("Configuring TemplateVM {}".format(name)))
self.run_in_thread(self.do_configure_template, args=(name,))
def run_in_thread(self, method):
thread = threading.Thread(target=method)
def run_in_thread(self, method, args = None):
thread = threading.Thread(target=method, args = (args if args else ()))
thread.start()
count = 0
while thread.is_alive():
@ -254,8 +257,7 @@ class moduleClass(Module):
def do_start_networking(self):
self.run_command(['/usr/sbin/service', 'qubes-netvm', 'start'])
def do_configure_template(self):
for template in os.listdir('/var/lib/qubes/vm-templates'):
def do_configure_template(self, template):
self.run_command(['qvm-start', '--no-guid', template])
# Copy timezone setting from Dom0 to template
self.run_command(['qvm-run', '--nogui', '--pass-io',