autoinstall: allow for specifying autoinstall path on kernel command line
This commit is contained in:
parent
aaaf87355c
commit
76b520afa9
|
@ -574,10 +574,11 @@ class SubiquityServer(Application):
|
|||
|
||||
def select_autoinstall(self):
|
||||
# precedence
|
||||
# 1. autoinstall at root of drive
|
||||
# 2. command line argument autoinstall
|
||||
# 3. autoinstall supplied by cloud config
|
||||
# 4. autoinstall baked into the iso, found at /cdrom/autoinstall.yaml
|
||||
# 1. command line argument autoinstall
|
||||
# 2. kernel command line argument subiquity.autoinstallpath
|
||||
# 3. autoinstall at root of drive
|
||||
# 4. autoinstall supplied by cloud config
|
||||
# 5. autoinstall baked into the iso, found at /cdrom/autoinstall.yaml
|
||||
|
||||
# if opts.autoinstall is set and empty, that means
|
||||
# autoinstall has been explicitly disabled.
|
||||
|
@ -588,9 +589,12 @@ class SubiquityServer(Application):
|
|||
):
|
||||
raise Exception(f"Autoinstall argument {self.opts.autoinstall} not found")
|
||||
|
||||
kernel_install_path = self.kernel_cmdline.get("subiquity.autoinstallpath", None)
|
||||
|
||||
locations = (
|
||||
self.base_relative(root_autoinstall_path),
|
||||
self.opts.autoinstall,
|
||||
kernel_install_path,
|
||||
self.base_relative(root_autoinstall_path),
|
||||
self.base_relative(cloud_autoinstall_path),
|
||||
self.base_relative(iso_autoinstall_path),
|
||||
)
|
||||
|
|
|
@ -54,31 +54,46 @@ class TestAutoinstallLoad(SubiTestCase):
|
|||
return path
|
||||
|
||||
def test_autoinstall_disabled(self):
|
||||
self.server.opts.autoinstall = ""
|
||||
self.server.kernel_cmdline = {"subiquity.autoinstallpath": "kernel"}
|
||||
self.create(root_autoinstall_path, "root")
|
||||
self.create(cloud_autoinstall_path, "cloud")
|
||||
self.create(iso_autoinstall_path, "iso")
|
||||
self.server.opts.autoinstall = ""
|
||||
self.assertIsNone(self.server.select_autoinstall())
|
||||
|
||||
def test_root_wins(self):
|
||||
root = self.create(root_autoinstall_path, "root")
|
||||
autoinstall = self.create(self.path("arg.autoinstall.yaml"), "arg")
|
||||
self.server.opts.autoinstall = autoinstall
|
||||
self.create(cloud_autoinstall_path, "cloud")
|
||||
self.create(iso_autoinstall_path, "iso")
|
||||
self.assertEqual(root, self.server.select_autoinstall())
|
||||
self.assert_contents(root, "root")
|
||||
|
||||
def test_arg_wins(self):
|
||||
root = self.path(root_autoinstall_path)
|
||||
arg = self.create(self.path("arg.autoinstall.yaml"), "arg")
|
||||
self.server.opts.autoinstall = arg
|
||||
kernel = self.create(self.path("kernel.autoinstall.yaml"), "kernel")
|
||||
self.server.kernel_cmdline = {"subiquity.autoinstallpath": kernel}
|
||||
root = self.create(root_autoinstall_path, "root")
|
||||
self.create(cloud_autoinstall_path, "cloud")
|
||||
self.create(iso_autoinstall_path, "iso")
|
||||
self.assertEqual(root, self.server.select_autoinstall())
|
||||
self.assert_contents(root, "arg")
|
||||
|
||||
def test_kernel_wins(self):
|
||||
self.server.opts.autoinstall = None
|
||||
kernel = self.create(self.path("kernel.autoinstall.yaml"), "kernel")
|
||||
self.server.kernel_cmdline = {"subiquity.autoinstallpath": kernel}
|
||||
root = self.create(root_autoinstall_path, "root")
|
||||
self.create(cloud_autoinstall_path, "cloud")
|
||||
self.create(iso_autoinstall_path, "iso")
|
||||
self.assertEqual(root, self.server.select_autoinstall())
|
||||
self.assert_contents(root, "kernel")
|
||||
|
||||
def test_root_wins(self):
|
||||
self.server.opts.autoinstall = None
|
||||
self.server.kernel_cmdline = {}
|
||||
root = self.create(root_autoinstall_path, "root")
|
||||
self.create(cloud_autoinstall_path, "cloud")
|
||||
self.create(iso_autoinstall_path, "iso")
|
||||
self.assertEqual(root, self.server.select_autoinstall())
|
||||
self.assert_contents(root, "root")
|
||||
|
||||
def test_cloud_wins(self):
|
||||
self.server.opts.autoinstall = None
|
||||
self.server.kernel_cmdline = {}
|
||||
root = self.path(root_autoinstall_path)
|
||||
self.create(cloud_autoinstall_path, "cloud")
|
||||
self.create(iso_autoinstall_path, "iso")
|
||||
|
@ -86,7 +101,10 @@ class TestAutoinstallLoad(SubiTestCase):
|
|||
self.assert_contents(root, "cloud")
|
||||
|
||||
def test_iso_wins(self):
|
||||
self.server.opts.autoinstall = None
|
||||
self.server.kernel_cmdline = {}
|
||||
root = self.path(root_autoinstall_path)
|
||||
# No cloud config file
|
||||
self.create(iso_autoinstall_path, "iso")
|
||||
self.assertEqual(root, self.server.select_autoinstall())
|
||||
self.assert_contents(root, "iso")
|
||||
|
|
Loading…
Reference in New Issue