Merge pull request #649 from mwhudson/no-autoinstall-merging

stop merging autoinstall files in subiquity
This commit is contained in:
Michael Hudson-Doyle 2020-03-06 17:38:51 +01:00 committed by GitHub
commit 4147e02754
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 47 deletions

View File

@ -1,28 +0,0 @@
# Copyright 2019 Canonical, Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import yaml
from curtin.config import merge_config
def merge_autoinstall_configs(source_paths, target_path):
config = {}
for path in source_paths:
with open(path) as fp:
c = yaml.safe_load(fp)
merge_config(config, c)
with open(target_path, 'w') as fp:
yaml.dump(config, fp)

View File

@ -31,13 +31,6 @@ class ClickAction(argparse.Action):
namespace.scripts.append("c(" + repr(values) + ")")
AUTO_INSTALL_LOCATIONS = (
"/run/initrd-autoinstall.yaml",
"/autoinstall.yaml",
"/autoinstall/autoinstall.yaml",
)
def parse_options(argv):
parser = argparse.ArgumentParser(
description='SUbiquity - Ubiquity for Servers',
@ -46,9 +39,7 @@ def parse_options(argv):
ascii_default = os.ttyname(0) == "/dev/ttysclp0"
except OSError:
ascii_default = False
autoinstall_files = [
p for p in AUTO_INSTALL_LOCATIONS if os.path.exists(p)]
parser.set_defaults(ascii=ascii_default, autoinstall=autoinstall_files)
parser.set_defaults(ascii=ascii_default)
parser.add_argument('--dry-run', action='store_true',
dest='dry_run',
help='menu-only, do not call installer function')
@ -76,7 +67,8 @@ 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('--autoinstall', action='append')
parser.add_argument('--autoinstall', action='store',
default="/autoinstall.yaml")
parser.add_argument('--source', default=[], action='append',
dest='sources', metavar='URL',
help='install from url instead of default.')

View File

@ -32,7 +32,6 @@ from subiquitycore.controller import Skip
from subiquitycore.core import Application
from subiquitycore.utils import run_command
from subiquity.autoinstall import merge_autoinstall_configs
from subiquity.controllers.error import (
ErrorReportKind,
)
@ -121,8 +120,6 @@ class Subiquity(Application):
self._apport_files = []
self.autoinstall_config = {}
self.merged_autoinstall_path = os.path.join(
self.root, 'autoinstall.yaml')
self.note_data_for_apport("SnapUpdated", str(self.updated))
self.note_data_for_apport("UsingAnswers", str(bool(self.answers)))
@ -152,17 +149,15 @@ class Subiquity(Application):
return s
def run(self):
if self.opts.autoinstall:
merge_autoinstall_configs(
self.opts.autoinstall, self.merged_autoinstall_path)
with open(self.merged_autoinstall_path) as fp:
if os.path.exists(self.opts.autoinstall):
with open(self.opts.autoinstall) as fp:
self.autoinstall_config = yaml.safe_load(fp)
self.controllers.load("Early")
self.controllers.load("Reporting")
self.controllers.Reporting.start()
self.aio_loop.run_until_complete(self.controllers.Early.run())
self.new_event_loop()
with open(self.merged_autoinstall_path) as fp:
with open(self.opts.autoinstall) as fp:
self.autoinstall_config = yaml.safe_load(fp)
try:
super().run()