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 = [] errors = []
try: for template in os.listdir('/var/lib/qubes/vm-templates'):
self.configure_template() try:
except Exception as e: self.configure_template(template)
errors.append((self.stage, str(e))) except Exception as e:
errors.append((self.stage, str(e)))
try: try:
self.create_default_netvm() self.create_default_netvm()
self.create_default_fwvm() self.create_default_fwvm()
@ -97,6 +99,7 @@ class moduleClass(Module):
self.start_qubes_networking() self.start_qubes_networking()
except Exception as e: except Exception as e:
errors.append((self.stage, str(e))) errors.append((self.stage, str(e)))
try: try:
self.create_default_dvm() self.create_default_dvm()
except Exception as e: except Exception as e:
@ -138,12 +141,12 @@ class moduleClass(Module):
def set_default_template(self): def set_default_template(self):
subprocess.call(['/usr/bin/qubes-prefs', '--set', 'default-template', self.default_template]) subprocess.call(['/usr/bin/qubes-prefs', '--set', 'default-template', self.default_template])
def configure_template(self): def configure_template(self, name):
self.show_stage(_("Configuring default TemplateVM")) self.show_stage(_("Configuring TemplateVM {}".format(name)))
self.run_in_thread(self.do_configure_template) self.run_in_thread(self.do_configure_template, args=(name,))
def run_in_thread(self, method): def run_in_thread(self, method, args = None):
thread = threading.Thread(target=method) thread = threading.Thread(target=method, args = (args if args else ()))
thread.start() thread.start()
count = 0 count = 0
while thread.is_alive(): while thread.is_alive():
@ -254,17 +257,16 @@ class moduleClass(Module):
def do_start_networking(self): def do_start_networking(self):
self.run_command(['/usr/sbin/service', 'qubes-netvm', 'start']) self.run_command(['/usr/sbin/service', 'qubes-netvm', 'start'])
def do_configure_template(self): def do_configure_template(self, template):
for template in os.listdir('/var/lib/qubes/vm-templates'): self.run_command(['qvm-start', '--no-guid', template])
self.run_command(['qvm-start', '--no-guid', template]) # Copy timezone setting from Dom0 to template
# Copy timezone setting from Dom0 to template self.run_command(['qvm-run', '--nogui', '--pass-io',
self.run_command(['qvm-run', '--nogui', '--pass-io', '-u', 'root', template, 'cat > /etc/locale.conf'],
'-u', 'root', template, 'cat > /etc/locale.conf'], stdin=open('/etc/locale.conf', 'r'))
stdin=open('/etc/locale.conf', 'r')) self.run_command(['su', '-c',
self.run_command(['su', '-c', 'qvm-sync-appmenus {}'.format(template),
'qvm-sync-appmenus {}'.format(template), '-', self.qubes_user])
'-', self.qubes_user]) self.run_command(['qvm-shutdown', '--wait', template])
self.run_command(['qvm-shutdown', '--wait', template])
def do_create_appvms(self): def do_create_appvms(self):
self.run_command(['su', '-c', '/usr/bin/qvm-create work --label green', '-', self.qubes_user]) self.run_command(['su', '-c', '/usr/bin/qvm-create work --label green', '-', self.qubes_user])