def update(self, *args, **kwargs): """Render UI according to current state and reset timer PegasusGUI only. """ interval = 1 current_state = self.config.getopt('current_state') if current_state == ControllerState.PLACEMENT: self.ui.render_placement_view(self.loop, self.config, self.commit_placement) elif current_state == ControllerState.INSTALL_WAIT: self.ui.render_node_install_wait(message="Waiting...") interval = self.config.node_install_wait_interval elif current_state == ControllerState.ADD_SERVICES: self.ui.render_add_services_dialog(self.deploy_new_services, self.cancel_add_services) elif current_state == ControllerState.SERVICES: self.update_node_states() else: raise Exception("Internal error, unexpected display " "state '{}'".format(current_state)) self.loop.redraw_screen() AlarmMonitor.add_alarm(self.loop.set_alarm_in(interval, self.update), "core-controller-update")
def update_progress(self, loop=None, userdata=None): self.alarm = None if self.stopped: # if stopped was set in a separate thread, return and # do not reschedule. return m = [] for (n, s, e) in self.tasks: if s is None: m.append(('label', "{n:>{mw}}: " "{ts:<22}\n".format(n=n, mw=self.max_width, ts=' -'))) elif e is None: e = time.time() ts = "{:6d} sec(s) elapsed".format(int(e) - int(s)) m.append("{n:>{mw}}: {ts:<22}" "\n".format(n=n, mw=self.max_width, ts=ts)) if self.task_info_func: m.append( ('label', "\n{}\n\n".format(self.task_info_func()))) else: ts = "{:6d} sec".format(int(e) - int(s)) m.append(('label', "{n:>{mw}}: {ts:<22}" "\n".format(n=n, mw=self.max_width, ts=ts))) if self.display_controller.node_install_wait_view is None: self.display_controller.render_node_install_wait(m) else: self.display_controller.node_install_wait_view.message.set_text(m) self.display_controller.node_install_wait_view.redraw_kitt() f = self.update_progress self.alarm = self.loop.set_alarm_in(0.3, f) AlarmMonitor.add_alarm(self.alarm, "tasker-update-progress")
def update_progress(self, loop=None, userdata=None): self.alarm = None if self.stopped: # if stopped was set in a separate thread, return and # do not reschedule. return m = [] for (n, s, e) in self.tasks: if s is None: m.append(('label', "{n:>{mw}}: " "{ts:<22}\n".format(n=n, mw=self.max_width, ts=' -'))) elif e is None: e = time.time() ts = "{:6.2f} sec elapsed".format(e - s) m.append("{n:>{mw}}: {ts:<22}" "\n".format(n=n, mw=self.max_width, ts=ts)) if self.task_info_func: m.append(('label', "\n{}\n\n".format(self.task_info_func()))) else: ts = "{:6.2f} sec".format(e - s) m.append(('label', "{n:>{mw}}: {ts:<22}" "\n".format(n=n, mw=self.max_width, ts=ts))) self.display_controller.render_node_install_wait(m) f = self.update_progress self.alarm = self.loop.set_alarm_in(0.3, f) AlarmMonitor.add_alarm(self.alarm, "tasker-update-progress")
def update(self, *args, **kwargs): "periodically check for display changes" if self.config.getopt('current_state') == InstallState.RUNNING: pass elif self.config.getopt('current_state') == InstallState.NODE_WAIT: self.ui.render_machine_wait_view(self.config) self.loop.redraw_screen() AlarmMonitor.add_alarm(self.loop.set_alarm_in(1, self.update), "installcontroller-update")
def start(self): """ Starts UI loop """ if self.config.getopt("headless"): self.initialize() else: self.ui.status_info_message("Welcome") rel = self.config.getopt("openstack_release") label = OPENSTACK_RELEASE_LABELS[rel] self.ui.set_openstack_rel(label) self.initialize() self.loop.register_callback("refresh_display", self.update) AlarmMonitor.add_alarm(self.loop.set_alarm_in(0, self.update), "controller-start") self.config.setopt("gui_started", True) self.loop.run() self.loop.close()
def start(self): """ Starts UI loop """ if self.config.getopt('headless'): self.initialize() else: self.ui.status_info_message("Welcome") rel = self.config.getopt('openstack_release') label = OPENSTACK_RELEASE_LABELS[rel] self.ui.set_openstack_rel(label) self.initialize() self.loop.register_callback('refresh_display', self.update) AlarmMonitor.add_alarm(self.loop.set_alarm_in(0, self.update), "controller-start") self.config.setopt("gui_started", True) self.loop.run() self.loop.close()
def show_exception_message(self, ex): msg = ("A fatal error has occurred: {}\n".format(ex.args[0])) log.error(msg) self.frame.body = ErrorView(ex.args[0]) AlarmMonitor.remove_all()
def show_exception_message(self, ex): msg = "A fatal error has occurred: {}\n".format(ex.args[0]) log.error(msg) self.frame.body = ErrorView(ex.args[0]) AlarmMonitor.remove_all()
self.add_services_dialog = AddServicesDialog(self.controller, deploy_cb=deploy, cancel_cb=cancel) self.add_services_dialog.update() self.frame.body = Filler(self.add_services_dialog) def show_exception_message(self, ex): if isinstance(ex, async .ThreadCancelledException): log.debug("Thread cancelled intentionally.") else: msg = ("A fatal error has occurred: {}\n".format(ex.args[0])) log.error(msg) log.exception(ex) self.frame.body = ErrorView(ex.args[0]) AlarmMonitor.remove_all() def select_install_type(self, install_types, cb): """ Dialog for selecting installation type """ self.show_selector_with_desc( 'Select the type of installation to perform', install_types, cb) def __repr__(self): return "<Ubuntu OpenStack Installer GUI Interface>" def tasker(self, loop, config): """ Interface with Tasker class :param loop: urwid.Mainloop :param dict config: config object
if self.add_services_dialog is None: self.add_services_dialog = AddServicesDialog(self.controller, deploy_cb=deploy, cancel_cb=cancel) self.add_services_dialog.update() self.frame.body = Filler(self.add_services_dialog) def show_exception_message(self, ex): if isinstance(ex, async.ThreadCancelledException): log.debug("Thread cancelled intentionally.") else: msg = ("A fatal error has occurred: {}\n".format(ex.args[0])) log.error(msg) self.frame.body = ErrorView(ex.args[0]) AlarmMonitor.remove_all() def select_install_type(self, install_types, cb): """ Dialog for selecting installation type """ self.show_selector_with_desc( 'Select the type of installation to perform', install_types, cb) def __repr__(self): return "<Ubuntu OpenStack Installer GUI Interface>" def tasker(self, loop, config): """ Interface with Tasker class