Add support for --source on command line.

This provides the ability to install from a different source
by providing it on the command line.  So we can boot into a system,
and then run:
  subiquity --source=/tmp/xenial-server-cloudimg-amd64.squashfs
or
  subiquity --source=http://cloud-images.ubuntu.com/.../some.squashfs

And install that image rather than the hard coded paths.
This commit is contained in:
Scott Moser 2018-06-07 13:45:17 -04:00 committed by GitHub
parent c40a03a346
commit 7bf11ef883
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 12 deletions

View File

@ -78,6 +78,9 @@ def parse_options(argv):
parser.add_argument('--click', metavar="PAT", action=ClickAction,
help='Synthesize a click on a button matching PAT')
parser.add_argument('--answers')
parser.add_argument('--source', default=[], action='append',
dest='sources', metavar='URL',
help='install from url instead of default.')
parser.add_argument(
'--snaps-from-examples', action='store_true',
help=("Load snap details from examples/snaps instead of store. "

View File

@ -54,6 +54,10 @@ class InstallpathController(BaseController):
log.debug("Installing Ubuntu path chosen.")
self.signal.emit_signal('next-screen')
def install_cmdline(self):
log.debug("Installing from command line sources.")
self.signal.emit_signal('next-screen')
def install_maas_region(self):
# show region questions, seed model
title = "MAAS Region Controller Setup"

View File

@ -28,23 +28,37 @@ class InstallpathModel(object):
path = 'ubuntu'
# update() is not run, upon selecting the default choice...
source = '/media/filesystem'
curtin = {}
def __init__(self, sources=None):
self.cmdline_sources = sources
if sources:
self.path = 'cmdline'
@property
def paths(self):
return [
cmdline = []
if self.cmdline_sources:
cmdline = [(_('Install from cli provided sources'), 'cmdline')]
return cmdline + [
(_('Install Ubuntu'), 'ubuntu'),
(_('Install MAAS bare-metal cloud (region)'), 'maas_region'),
(_('Install MAAS bare-metal cloud (rack)'), 'maas_rack'),
]
@property
def sources(self):
src_map = {
'ubuntu': ['cp:///media/filesystem'],
'maas_region': ['cp:///media/region'],
'maas_rack': ['cp:///media/rack'],
'cmdline': self.cmdline_sources}
return {self.path + "%02d" % n: u
for n, u in enumerate(src_map[self.path])}
def update(self, results):
if self.path == 'ubuntu':
self.source = '/media/filesystem'
self.curtin = {}
elif self.path == 'maas_region':
self.source = '/media/region'
self.curtin = {}
if self.path == 'maas_region':
self.curtin['debconf_selections'] = {
'maas-username': ('maas-region-controller maas/username '
'string %s' % results['username']),
@ -108,7 +122,6 @@ class InstallpathModel(object):
'915-maas': ['umount', '/target/proc'],
}
elif self.path == 'maas_rack':
self.source = '/media/rack'
self.curtin['debconf_selections'] = {
'maas-url': ('maas-rack-controller '
'maas-rack-controller/maas-url '
@ -132,6 +145,7 @@ class InstallpathModel(object):
}
else:
raise ValueError("invalid Installpath %s" % self.path)
self.curtin['sources'] = self.sources
def render(self):
return self.curtin

View File

@ -49,7 +49,7 @@ class SubiquityModel:
root = os.path.abspath(".subiquity")
self.locale = LocaleModel(common['signal'])
self.keyboard = KeyboardModel(root)
self.installpath = InstallpathModel()
self.installpath = InstallpathModel(sources=common['opts'].sources)
self.network = NetworkModel(support_wlan=False)
self.filesystem = FilesystemModel(common['prober'])
self.identity = IdentityModel()
@ -135,9 +135,7 @@ class SubiquityModel:
'/var/log/installer/curtin-install.log',
},
'sources': {
'rofs': 'cp://%s' % self.installpath.source,
},
'sources': self.installpath.sources,
'verbosity': 3,