Work out ability to run curtin multiple times

Add additional signals to handle calling curtin
multiple times from additional input views

Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
This commit is contained in:
Adam Stokes 2015-08-28 11:06:59 -04:00
parent 0823db3b03
commit 810306b586
4 changed files with 40 additions and 50 deletions

View File

@ -56,8 +56,8 @@ class FilesystemController(ControllerPolicy):
curtin_write_storage_actions(actions=actions)
log.info("Generating post-install config")
curtin_write_postinst_config()
urwid.emit_signal(self.signal, 'installprogress:do-initial-install')
urwid.emit_signal(self.signal, 'identity:show')
# self.install_progress()
# Filesystem/Disk partition -----------------------------------------------
def disk_partition(self, disk):

View File

@ -29,57 +29,44 @@ class InstallProgressController(ControllerPolicy):
self.signal = signal
self.opts = opts
self.model = InstallProgressModel()
self.progress_output_w = ProgressOutput(
self.signal,
"Waiting...")
@coroutine
def run_curtin(self):
try:
yield utils.run_command_async(
"/usr/local/bin/curtin_wrap.sh",
self.install_progress_status)
except Exception as e:
# TODO: Implement an Error View/Controller for displaying
# exceptions rather than kicking out of installer.
log.error("Problem running curtin_wrap: {}".format(e))
def curtin_dispatch(self):
if self.opts.dry_run:
log.debug("Install Progress: Curtin dispatch dry-run")
yield utils.run_command_async("cat /var/log/syslog",
log.debug)
else:
try:
yield utils.run_command_async("/usr/local/bin/curtin_wrap.sh",
log.debug)
except:
log.error("Problem with curtin dispatch run")
raise Exception("Problem with curtin dispatch run")
@coroutine
def run_test_curtin(self):
""" testing streaming output
"""
self.install_progress_status("Starting run")
yield utils.run_command_async(
"cat /var/log/syslog",
self.install_progress_status)
log.debug("done")
return
def install_progress(self):
title = ("Installing system")
excerpt = ("Please wait for the installation "
"to finish before rebooting.")
footer = ("Thank you for using Ubuntu!")
self.ui.set_header(title, excerpt)
self.ui.set_footer(footer)
self.ui.set_body(ProgressView(self.signal, self.progress_output_w))
def initial_install(self):
# title = ("Installing system")
# excerpt = ("Please wait for the installation "
# "to finish before rebooting.")
# footer = ("Thank you for using Ubuntu!")
# self.ui.set_header(title, excerpt)
# self.ui.set_footer(footer)
# self.ui.set_body(ProgressView(self.signal, self.progress_output_w))
if self.opts.dry_run:
log.debug("Filesystem: this is a dry-run")
banner = [
"**** DRY_RUN ****",
"NOT calling:"
"subprocess.check_call(/usr/local/bin/curtin_wrap.sh)"
"",
"",
"Press (Q) to Quit."
]
self.install_progress_status("\n".join(banner))
# XXX: Test routine to verify the callback streaming
# self.run_test_curtin()
# banner = [
# "**** DRY_RUN ****",
# "NOT calling:"
# "subprocess.check_call(/usr/local/bin/curtin_wrap.sh)"
# "",
# "",
# "Press (Q) to Quit."
# ]
# self.install_progress_status("\n".join(banner))
yield utils.run_command_async("cat /var/log/syslog",
log.debug)
else:
log.debug("filesystem: this is the *real* thing")
self.run_curtin()
def install_progress_status(self, data):
self.progress_output_w.set_text(data)
self.signal.emit_signal('refresh')
yield utils.run_command_async(
"/usr/local/bin/curtin_wrap.sh", log.debug)

View File

@ -29,8 +29,11 @@ class InstallProgressModel(ModelPolicy):
signals = [
("Installprogress view",
'installprogress:show',
'install_progress')
'installprogress:do-initial-install',
'initial_install'),
("Run once curtin commands",
'installprogress:curtin-dispatch',
'curtin_dispatch')
]
installprogress_menu = []

View File

@ -96,7 +96,7 @@ class IdentityView(ViewPolicy):
"confirm_password": self.confirm_password.value
}
log.debug("User input: {}".format(result))
emit_signal(self.signal, 'installprogress:show')
emit_signal(self.signal, 'installprogress:curtin-dispatch')
def cancel(self, button):
self.signal.emit_signal("quit")