Review comments

This commit is contained in:
Dimitri John Ledkov 2020-04-16 00:22:52 +01:00
parent 5be2961a62
commit 760fbaa22f
4 changed files with 23 additions and 19 deletions

View File

@ -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()

View File

@ -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@'):

View File

@ -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), ""]

View File

@ -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