Merge pull request #416 from mwhudson/installpath-rejig
rework installpath model to record what the user entered
This commit is contained in:
commit
fa58cb1fcc
|
@ -21,15 +21,10 @@ log = logging.getLogger("subiquity.models.installpath")
|
|||
|
||||
|
||||
class InstallpathModel(object):
|
||||
""" Model representing install options
|
||||
|
||||
List of install paths in the form of:
|
||||
('UI Text seen by user', <signal name>, <callback function string>)
|
||||
"""
|
||||
"""Model representing install options"""
|
||||
|
||||
path = 'ubuntu'
|
||||
# update() is not run, upon selecting the default choice...
|
||||
curtin = {}
|
||||
results = {}
|
||||
|
||||
def __init__(self, target, sources=None):
|
||||
self.target = target
|
||||
|
@ -59,21 +54,24 @@ class InstallpathModel(object):
|
|||
for n, u in enumerate(src_map[self.path])}
|
||||
|
||||
def update(self, results):
|
||||
self.curtin = {}
|
||||
self.results = results
|
||||
|
||||
def render(self):
|
||||
config = {}
|
||||
|
||||
def t(path):
|
||||
return os.path.join(self.target, path)
|
||||
|
||||
if self.path == 'maas_region':
|
||||
self.curtin['debconf_selections'] = {
|
||||
config['debconf_selections'] = {
|
||||
'maas-username': ('maas-region-controller maas/username '
|
||||
'string %s' % results['username']),
|
||||
'string %s' % self.results['username']),
|
||||
'maas-password': ('maas-region-controller maas/password '
|
||||
'password %s' % results['password']),
|
||||
'password %s' % self.results['password']),
|
||||
}
|
||||
self.curtin['late_commands'] = {
|
||||
# Maintainer scripts cache results, from config files, if they
|
||||
# exist. These shouldn't exist, since this was fixed in
|
||||
config['late_commands'] = {
|
||||
# Maintainer scripts cache self.results, from config files, if
|
||||
# they # exist. These shouldn't exist, since this was fixed in
|
||||
# livecd-rootfs but remove these, just to be sure.
|
||||
'900-maas': ['rm', '-f', t('etc/maas/rackd.conf')],
|
||||
'901-maas': ['rm', '-f', t('etc/maas/region.conf')],
|
||||
|
@ -128,15 +126,15 @@ class InstallpathModel(object):
|
|||
'915-maas': ['umount', t('proc')],
|
||||
}
|
||||
elif self.path == 'maas_rack':
|
||||
self.curtin['debconf_selections'] = {
|
||||
config['debconf_selections'] = {
|
||||
'maas-url': ('maas-rack-controller '
|
||||
'maas-rack-controller/maas-url '
|
||||
'string %s' % results['url']),
|
||||
'string %s' % self.results['url']),
|
||||
'maas-secret': ('maas-rack-controller '
|
||||
'maas-rack-controller/shared-secret '
|
||||
'password %s' % results['secret']),
|
||||
'password %s' % self.results['secret']),
|
||||
}
|
||||
self.curtin['late_commands'] = {
|
||||
config['late_commands'] = {
|
||||
'90-maas': ['rm', '-f', t('etc/maas/rackd.conf')],
|
||||
'91-maas': ['curtin', 'in-target', '--', 'maas-rack',
|
||||
'config', '--init'],
|
||||
|
@ -149,9 +147,6 @@ class InstallpathModel(object):
|
|||
'/var/lib/dpkg/info/maas-rack-controller.postinst'
|
||||
' configure || :')],
|
||||
}
|
||||
else:
|
||||
elif self.path != "ubuntu":
|
||||
raise ValueError("invalid Installpath %s" % self.path)
|
||||
self.curtin['sources'] = self.sources
|
||||
|
||||
def render(self):
|
||||
return self.curtin
|
||||
return config
|
||||
|
|
|
@ -65,17 +65,22 @@ class InstallpathView(BaseView):
|
|||
self.items = []
|
||||
back = back_btn(_("Back"), on_press=self.cancel)
|
||||
super().__init__(screen(
|
||||
[button_pile(self._build_choices()), Text("")], [back],
|
||||
[self._build_choices(), Text("")], [back],
|
||||
focus_buttons=False, excerpt=_(self.excerpt)))
|
||||
|
||||
def _build_choices(self):
|
||||
choices = []
|
||||
for label, path in self.model.paths:
|
||||
focus_position = 0
|
||||
for i, (label, path) in enumerate(self.model.paths):
|
||||
log.debug("Building inputs: {}".format(path))
|
||||
choices.append(
|
||||
forward_btn(
|
||||
label=label, on_press=self.confirm, user_arg=path))
|
||||
return choices
|
||||
if path == self.model.path:
|
||||
focus_position = i
|
||||
bp = button_pile(choices)
|
||||
bp.base_widget.focus_position = focus_position
|
||||
return bp
|
||||
|
||||
def confirm(self, sender, path):
|
||||
self.controller.choose_path(path)
|
||||
|
@ -174,9 +179,9 @@ class MAASView(BaseView):
|
|||
self.title = title
|
||||
|
||||
if self.model.path == "maas_region":
|
||||
self.form = RegionForm()
|
||||
self.form = RegionForm(initial=self.model.results)
|
||||
elif self.model.path == "maas_rack":
|
||||
self.form = RackForm()
|
||||
self.form = RackForm(initial=self.model.results)
|
||||
else:
|
||||
raise ValueError("invalid MAAS form %s" % self.model.path)
|
||||
|
||||
|
|
Loading…
Reference in New Issue