def __init__(self, ui, opts): try: prober = Prober(opts) except ProberException as e: err = "Prober init failed: {}".format(e) log.exception(err) raise ApplicationError(err) opts.project = self.project answers = {} if opts.answers is not None: answers = yaml.safe_load(open(opts.answers).read()) log.debug("Loaded answers %s", answers) self.common = { "ui": ui, "opts": opts, "signal": Signal(), "prober": prober, "loop": None, "pool": futures.ThreadPoolExecutor(1), "answers": answers, } if opts.screens: self.controllers = [ c for c in self.controllers if c in opts.screens ] ui.progress_completion = len(self.controllers) self.common['controllers'] = dict.fromkeys(self.controllers) self.controller_index = -1
def __init__(self, opts, block_log_dir): super().__init__(opts) self.block_log_dir = block_log_dir self.cloud_init_ok = None self._state = ApplicationState.STARTING_UP self.state_event = asyncio.Event() self.interactive = None self.confirming_tty = '' self.fatal_error = None self.running_error_commands = False self.echo_syslog_id = 'subiquity_echo.{}'.format(os.getpid()) self.event_syslog_id = 'subiquity_event.{}'.format(os.getpid()) self.log_syslog_id = 'subiquity_log.{}'.format(os.getpid()) self.error_reporter = ErrorReporter( self.context.child("ErrorReporter"), self.opts.dry_run, self.root) self.prober = Prober(opts.machine_config, self.debug_flags) self.kernel_cmdline = shlex.split(opts.kernel_cmdline) if opts.snaps_from_examples: connection = FakeSnapdConnection( os.path.join( os.path.dirname(os.path.dirname( os.path.dirname(__file__))), "examples", "snaps"), self.scale_factor) else: connection = SnapdConnection(self.root, self.snapd_socket_path) self.snapd = AsyncSnapd(connection) self.note_data_for_apport("SnapUpdated", str(self.updated)) self.event_listeners = [] self.autoinstall_config = None self.signal.connect_signals([ ('network-proxy-set', lambda: schedule_task(self._proxy_set())), ('network-change', self._network_change), ])
def make_fsm(self, _get_storage, _load_machine_config): _get_storage.return_value = fakes.FAKE_MACHINE_STORAGE_DATA _load_machine_config.return_value = fakes.FAKE_MACHINE_JSON_DATA self.opts = argparse.Namespace() self.opts.machine_config = fakes.FAKE_MACHINE_JSON self.opts.dry_run = True self.prober = Prober(self.opts) self.storage = fakes.FAKE_MACHINE_STORAGE_DATA self.fsm = FilesystemModel(self.prober, self.opts)
def __init__(self, opts): self.debug_flags = () if opts.dry_run: # Recognized flags are: # - install-fail: makes curtin install fail by replaying curtin # events from a failed installation, see # subiquity/controllers/installprogress.py # - bpfail-full, bpfail-restricted: makes block probing fail, see # subiquitycore/prober.py # - copy-logs-fail: makes post-install copying of logs fail, see # subiquity/controllers/installprogress.py self.debug_flags = os.environ.get('SUBIQUITY_DEBUG', '').split(',') prober = Prober(opts.machine_config, self.debug_flags) self.ui = self.make_ui() self.opts = opts opts.project = self.project self.root = '/' if opts.dry_run: self.root = '.subiquity' self.state_dir = os.path.join(self.root, 'run', self.project) os.makedirs(self.state_path('states'), exist_ok=True) self.answers = {} if opts.answers is not None: self.answers = yaml.safe_load(opts.answers.read()) log.debug("Loaded answers %s", self.answers) if not opts.dry_run: open('/run/casper-no-prompt', 'w').close() # Set rich_mode to the opposite of what we want, so we can # call toggle_rich to get the right things set up. self.rich_mode = opts.run_on_serial self.color_palette = make_palette(self.COLORS, self.STYLES) self.is_linux_tty = is_linux_tty() if self.is_linux_tty: self.input_filter = KeyCodesFilter() else: self.input_filter = DummyKeycodesFilter() self.scale_factor = float( os.environ.get('SUBIQUITY_REPLAY_TIMESCALE', "1")) self.updated = os.path.exists(self.state_path('updating')) self.signal = Signal() self.prober = prober self.new_event_loop() self.urwid_loop = None self.controllers = ControllerSet(self, self.controllers) self.context = Context.new(self)
def __init__(self, opts, chooser_input, chooser_output): """Takes the options and raw input/output streams for communicating with the chooser parent process. """ self._chooser_output = chooser_output # make_model is used by super()'s constructor, but we need to use the # instance data self.make_model = lambda: RecoverySystemsModel.from_systems_stream( chooser_input) super().__init__(opts) self.prober = Prober(opts.machine_config, self.debug_flags)
def __init__(self, ui, opts): try: prober = Prober(opts) except ProberException as e: err = "Prober init failed: {}".format(e) log.exception(err) raise ApplicationError(err) opts.project = self.project self.root = '/' if opts.dry_run: self.root = '.subiquity' self.state_dir = os.path.join(self.root, 'run', self.project) os.makedirs(os.path.join(self.state_dir, 'states'), exist_ok=True) answers = {} if opts.answers is not None: answers = yaml.safe_load(opts.answers.read()) log.debug("Loaded answers %s", answers) if not opts.dry_run: open('/run/casper-no-prompt', 'w').close() if is_linux_tty(): log.debug("is_linux_tty") input_filter = KeyCodesFilter() else: input_filter = DummyKeycodesFilter() scale = float(os.environ.get('SUBIQUITY_REPLAY_TIMESCALE', "1")) updated = os.path.exists(os.path.join(self.state_dir, 'updating')) self.common = { "application": self, "updated": updated, "ui": ui, "opts": opts, "signal": Signal(), "prober": prober, "loop": None, "pool": futures.ThreadPoolExecutor(10), "answers": answers, "input_filter": input_filter, "scale_factor": scale, "run_in_bg": self.run_in_bg, } if opts.screens: self.controllers = [c for c in self.controllers if c in opts.screens] else: self.controllers = self.controllers[:] ui.progress_completion = len(self.controllers) self.common['controllers'] = dict.fromkeys(self.controllers) self.controller_index = -1
def __init__(self, ui, opts): try: prober = Prober(opts) except ProberException as e: err = "Prober init failed: {}".format(e) log.exception(err) raise ApplicationError(err) self.common = { "ui": ui, "opts": opts, "signal": Signal(), "prober": prober, "loop": None } self.common['controllers'] = dict.fromkeys(self.controllers) self.controller_index = -1
def __init__(self, opts): prober = Prober(opts) self.ui = self.make_ui() self.opts = opts opts.project = self.project self.root = '/' if opts.dry_run: self.root = '.subiquity' self.state_dir = os.path.join(self.root, 'run', self.project) os.makedirs(os.path.join(self.state_dir, 'states'), exist_ok=True) self.answers = {} if opts.answers is not None: self.answers = yaml.safe_load(opts.answers.read()) log.debug("Loaded answers %s", self.answers) if not opts.dry_run: open('/run/casper-no-prompt', 'w').close() self.is_color = False self.color_palette = make_palette(self.COLORS, self.STYLES, opts.ascii) self.is_linux_tty = is_linux_tty() if self.is_linux_tty: self.input_filter = KeyCodesFilter() else: self.input_filter = DummyKeycodesFilter() self.scale_factor = float( os.environ.get('SUBIQUITY_REPLAY_TIMESCALE', "1")) self.updated = os.path.exists(os.path.join(self.state_dir, 'updating')) self.signal = Signal() self.prober = prober self.loop = None self.pool = futures.ThreadPoolExecutor(10) if opts.screens: self.controllers = [ c for c in self.controllers if c in opts.screens ] else: self.controllers = self.controllers[:] self.ui.progress_completion = len(self.controllers) self.controller_instances = dict.fromkeys(self.controllers) self.controller_index = -1
def __init__(self, opts, block_log_dir): if is_linux_tty(): self.input_filter = KeyCodesFilter() else: self.input_filter = DummyKeycodesFilter() self.help_menu = HelpMenu(self) super().__init__(opts) self.event_syslog_id = 'subiquity_event.{}'.format(os.getpid()) self.log_syslog_id = 'subiquity_log.{}'.format(os.getpid()) self.server_updated = None self.restarting_server = False self.prober = Prober(opts.machine_config, self.debug_flags) journald_listen(self.aio_loop, ["subiquity"], self.subiquity_event, seek=True) self.event_listeners = [] self.install_lock_file = Lockfile(self.state_path("installing")) self.global_overlays = [] self.block_log_dir = block_log_dir self.kernel_cmdline = shlex.split(opts.kernel_cmdline) if opts.snaps_from_examples: connection = FakeSnapdConnection( os.path.join(os.path.dirname(os.path.dirname(__file__)), "examples", "snaps"), self.scale_factor) else: connection = SnapdConnection(self.root, self.snapd_socket_path) self.snapd = AsyncSnapd(connection) self.signal.connect_signals([ ('network-proxy-set', lambda: schedule_task(self._proxy_set())), ('network-change', self._network_change), ]) self.conn = aiohttp.UnixConnector(self.opts.socket) self.client = make_client_for_conn(API, self.conn, self.resp_hook) self.autoinstall_config = {} self.error_reporter = ErrorReporter( self.context.child("ErrorReporter"), self.opts.dry_run, self.root, self.client) self.note_data_for_apport("SnapUpdated", str(self.updated)) self.note_data_for_apport("UsingAnswers", str(bool(self.answers)))
def __init__(self, ui, opts): try: prober = Prober(opts) except ProberException as e: err = "Prober init failed: {}".format(e) log.exception(err) raise ApplicationError(err) opts.project = self.project answers = {} if opts.answers is not None: answers = yaml.safe_load(open(opts.answers).read()) log.debug("Loaded answers %s", answers) if not opts.dry_run: open('/run/casper-no-prompt', 'w').close() if is_linux_tty(): log.debug("is_linux_tty") input_filter = KeyCodesFilter() else: input_filter = DummyKeycodesFilter() self.common = { "ui": ui, "opts": opts, "signal": Signal(), "prober": prober, "loop": None, "pool": futures.ThreadPoolExecutor(4), "answers": answers, "input_filter": input_filter, } if opts.screens: self.controllers = [ c for c in self.controllers if c in opts.screens ] ui.progress_completion = len(self.controllers) self.common['controllers'] = dict.fromkeys(self.controllers) self.controller_index = -1
def __init__(self, opts): super().__init__(opts) self.prober = Prober(opts.machine_config, self.debug_flags)