def __init__(self, model, signal): self.model = model self.signal = signal self.volgroup = UsernameEditor() self.selected_disks = [] body = [ Padding.center_50(self._build_disk_selection()), Padding.line_break(""), Padding.center_50(self._build_lvm_configuration()), Padding.line_break(""), Padding.fixed_10(self._build_buttons()) ] super().__init__(ListBox(body))
def __init__(self, model, controller): self.model = model self.controller = controller self.bond_iface = None self.bond_mode = Selector(self.model.bonding_modes.values()) self.selected_ifaces = [] body = [ Padding.center_50(self._build_iface_selection()), Padding.line_break(""), Padding.center_50(self._build_bondmode_configuration()), Padding.line_break(""), Padding.fixed_10(self._build_buttons()) ] super().__init__(ListBox(body))
def __init__(self, model, signal): self.model = model self.signal = signal self.raid_level = Selector(self.model.raid_levels) self.hot_spares = IntegerEditor() self.chunk_size = StringEditor(edit_text="4K") self.selected_disks = [] body = [ Padding.center_50(self._build_disk_selection()), Padding.line_break(""), Padding.center_50(self._build_raid_configuration()), Padding.line_break(""), Padding.fixed_10(self._build_buttons()) ] super().__init__(ListBox(body))
def __init__(self, model, signal): self.model = model self.signal = signal self.selected_disks = { 'CACHE': None, 'BACKING': None, } body = [ Padding.center_50(self._build_disk_selection(section='CACHE')), Padding.line_break(""), Padding.center_50(self._build_disk_selection(section='BACKING')), Padding.line_break(""), Padding.fixed_10(self._build_buttons()) ] super().__init__(ListBox(body))
def show_edit_default_route(self, btn): log.debug("Re-rendering specify default route") self.default_gateway_w = StringEditor( caption="Default gateway will be ") self.gateway_options.contents[-1] = (Padding.center_50( Color.string_input(self.default_gateway_w)), self.gateway_options.options())
def __init__(self, size, existing, initial, back): mountpoint_to_devpath_mapping = self.model.get_mountpoint_to_devpath_mapping( ) if existing is not None: fs = existing.fs() if fs is not None: if existing.flag != "boot": initial['fstype'] = self.model.fs_by_name[fs.fstype] mount = fs.mount() if mount is not None: initial['mount'] = mount.path if mount.path in mountpoint_to_devpath_mapping: del mountpoint_to_devpath_mapping[mount.path] else: initial['fstype'] = self.model.fs_by_name[None] self.form = self.form_cls(mountpoint_to_devpath_mapping, size, initial) self.back = back connect_signal(self.form, 'submit', self.done) connect_signal(self.form, 'cancel', self.cancel) partition_box = Padding.center_50(ListBox(self.make_body())) super().__init__( Pile([ ('pack', Text("")), partition_box, ('pack', Pile([ ('pack', Text("")), self.form.buttons, ('pack', Text("")), ])), ]))
def __init__(self, model, signal, selected_disk): log.debug('AddPartitionView: selected_disk=[{}]'.format(selected_disk)) self.model = model self.signal = signal self.selected_disk = selected_disk self.disk_obj = self.model.get_disk(selected_disk) self.partnum = IntegerEditor(caption="", default=self.disk_obj.lastpartnumber + 1) self.size_str = _humanize_size(self.disk_obj.freespace) self.size = StringEditor(caption="".format(self.size_str)) self.mountpoint = MountEditor(caption="", edit_text="/") self.fstype = Selector(opts=self.model.supported_filesystems) body = [ Columns([ ("weight", 0.2, Text("Adding partition to {}".format(self.disk_obj.devpath), align="right")), ("weight", 0.3, Text("")) ]), Padding.line_break(""), self._container(), Padding.line_break(""), Padding.fixed_10(self._build_buttons()) ] partition_box = Padding.center_50(ListBox(body)) super().__init__(partition_box)
def _build_model_inputs(self): local_tpl = ("This device is registered to {realname}.") remote_tpl = ( "\n\nRemote access was enabled via authentication with SSO user" " <{username}>.\nPublic SSH keys were added to the device " "for remote access.\n\n{realname} can connect remotely to this " "device via SSH:") sl = [] ssh = [] user = self.model.user login_info = { 'realname': user.realname, 'username': user.username, } login_text = local_tpl.format(**login_info) login_text += remote_tpl.format(**login_info) ips = [] for iface in self.ifaces: for addr in iface.dhcp4_addresses: try: ip = str(addr[0]).split("/")[0] except IndexError: ip = None if ip is not None: ips.append(ip) for addr in iface.ipv4_addresses: try: ip = str(addr).split("/")[0] except IndexError: ip = None if ip is not None: ips.append(ip) for addr in iface.dhcp6_addresses: try: ip = str(addr[0]).split("/")[0] except IndexError: ip = None if ip is not None: ips.append(ip) for addr in iface.ipv6_addresses: try: ip = str(addr).split("/")[0] except IndexError: ip = None if ip is not None: ips.append(ip) for ip in ips: ssh_iface = " ssh %s@%s" % (user.username, ip) ssh += [Padding.center_50(Text(ssh_iface))] sl += [Text(login_text), Padding.line_break("")] + ssh return Pile(sl)
def __init__(self, model, controller): self.model = model self.controller = controller super().__init__(Pile([ ('pack', Text("")), Padding.center_50(self._build_model_inputs()), ('pack', Text("")), ]))
def _build_model_inputs(self): """ This device is registered to Ryan Harper. Ryan Harper added a user, raharper, to the device for local access on the console. Remote access was enabled via authentication with Launchpad as lp:raharper and public ssh keys were added to the system for remote access. Ryan Harper can remotely connect to this system via SSH: ssh [email protected] ssh [email protected] """ local_tpl = ( "This device is registered to {realname}. {realname} added a" " user, <{username}> to the device for access.") remote_tpl = ( "\n\nRemote access was enabled via authentication with {auth} user" " <{ssh_import_id}>.\nPublic SSH keys were added to the device " "for remote access.\n\n{realname} can connect remotely to this " "device via SSH:") sl = [] ssh = [] user = self.model.user login_info = { 'realname': user.realname, 'username': user.username, } login_text = local_tpl.format(**login_info) if user.ssh_import_id: login_info.update({ 'auth': self.auth_name(user.ssh_import_id), 'ssh_import_id': user.ssh_import_id.split(":")[-1] }) login_text += remote_tpl.format(**login_info) ips = [] for dev in self.ifaces: for addr in dev.actual_ip_addresses: ips.append(addr) for ip in ips: ssh_iface = " ssh %s@%s" % (user.username, ip) ssh += [Padding.center_50(Text(ssh_iface))] print(login_info) sl += [Text(login_text), Padding.line_break("")] + ssh return Pile(sl)
def __init__(self, model, signal): self.model = model self.signal = signal self.iscsi_host = StringEditor() self.connect_anon = YesNo() self.connect_username = StringEditor() self.connect_password = PasswordEditor() self.server_auth = YesNo() self.server_username = StringEditor() self.server_password = PasswordEditor() body = [ Padding.center_50(self._build_model_inputs()), Padding.line_break(""), Padding.center_50(self._build_menu()), Padding.line_break(""), Padding.center_75(self._build_volume_mount_selector()) ] super().__init__(ListBox(body))
def __init__(self, model, controller): self.model = model self.controller = controller super().__init__( Pile([ ('pack', Text("")), ('pack', Padding.center_79( Text(_("Please choose your preferred language")))), ('pack', Text("")), Padding.center_50(self._build_model_inputs()), ('pack', Text("")), ]))
def __init__(self, model, signal): self.model = model self.signal = signal self.ceph_mon = StringEditor() self.username = StringEditor() self.ceph_key = StringEditor() self.pool = [] body = [ Padding.center_50(self._build_model_inputs()), Padding.line_break(""), Padding.fixed_10(self._build_buttons()) ] super().__init__(ListBox(body))
def __init__(self, model, signal, selected_disk): self.model = model self.signal = signal self.selected_disk = selected_disk self.disk_obj = self.model.get_disk(selected_disk) self.mountpoint = MountEditor(caption="", edit_text="/") self.fstype = Selector(opts=self.model.supported_filesystems) body = [ Padding.line_break(""), self._container(), Padding.line_break(""), Padding.fixed_10(self._build_buttons()) ] format_box = Padding.center_50(ListBox(body)) super().__init__(format_box)