From 760fbaa22f32bee7531444619be9580e6cdeda1c Mon Sep 17 00:00:00 2001 From: Dimitri John Ledkov Date: Thu, 16 Apr 2020 00:22:52 +0100 Subject: [PATCH] Review comments --- console_conf/controllers/identity.py | 17 +---------------- subiquity/cmd/tui.py | 8 +++++--- subiquity/ui/views/help.py | 1 + subiquitycore/ssh.py | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/console_conf/controllers/identity.py b/console_conf/controllers/identity.py index 0e2ba2d6..5be759af 100644 --- a/console_conf/controllers/identity.py +++ b/console_conf/controllers/identity.py @@ -20,7 +20,7 @@ import shlex import sys from subiquitycore.controller import BaseController -from subiquitycore.ssh import host_key_info +from subiquitycore.ssh import host_key_info, get_ips_standalone from subiquitycore.utils import disable_console_conf, run_command from console_conf.ui.views import IdentityView, LoginView @@ -108,21 +108,6 @@ def write_login_details(fp, username, ips): first_ip=first_ip, version=version)) -def get_ips_standalone(): - from probert.prober import Prober - from subiquitycore.models.network import NETDEV_IGNORED_IFACE_TYPES - prober = Prober() - prober.probe_network() - links = prober.get_results()['network']['links'] - ips = [] - for l in sorted(links, key=lambda l: l['netlink_data']['name']): - if l['type'] in NETDEV_IGNORED_IFACE_TYPES: - continue - for addr in l['addresses']: - if addr['scope'] == "global": - ips.append(addr['address'].split('/')[0]) - return ips - def write_login_details_standalone(): owner = get_device_owner() diff --git a/subiquity/cmd/tui.py b/subiquity/cmd/tui.py index 98121097..a90220a5 100755 --- a/subiquity/cmd/tui.py +++ b/subiquity/cmd/tui.py @@ -164,9 +164,11 @@ def main(): logging.getLogger('block-discover').addHandler(handler) if opts.ssh: - from subiquity.ui.views.help import ssh_help_texts, get_installer_password - from console_conf.controllers.identity import get_ips_standalone - texts = ssh_help_texts(get_ips_standalone(), get_installer_password(opts.dry_run)) + from subiquity.ui.views.help import ( + ssh_help_texts, get_installer_password) + from subiquitycore.ssh import get_ips_standalone + texts = ssh_help_texts( + get_ips_standalone(), get_installer_password(opts.dry_run)) for line in texts: if hasattr(line, 'text'): if line.text.startswith('installer@'): diff --git a/subiquity/ui/views/help.py b/subiquity/ui/views/help.py index 9241fdf9..213f6c91 100644 --- a/subiquity/ui/views/help.py +++ b/subiquity/ui/views/help.py @@ -124,6 +124,7 @@ Unfortunately the installer was unable to detect the password that has been set. """) + def ssh_help_texts(ips, password): texts = [_(SSH_HELP_PROLOGUE), ""] diff --git a/subiquitycore/ssh.py b/subiquitycore/ssh.py index db01dbf0..a312e693 100644 --- a/subiquitycore/ssh.py +++ b/subiquitycore/ssh.py @@ -75,3 +75,19 @@ def host_key_info(): fingerprint=fingerprint, width=longest_type)) return "".join(lines) + + +def get_ips_standalone(): + from probert.prober import Prober + from subiquitycore.models.network import NETDEV_IGNORED_IFACE_TYPES + prober = Prober() + prober.probe_network() + links = prober.get_results()['network']['links'] + ips = [] + for l in sorted(links, key=lambda l: l['netlink_data']['name']): + if l['type'] in NETDEV_IGNORED_IFACE_TYPES: + continue + for addr in l['addresses']: + if addr['scope'] == "global": + ips.append(addr['address'].split('/')[0]) + return ips