Skip to content

Commit

Permalink
autoinstall: allow for specifying autoinstall path on kernel command …
Browse files Browse the repository at this point in the history
…line
  • Loading branch information
Chris-Peterson444 committed Sep 21, 2023
1 parent aaaf873 commit 76b520a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 15 deletions.
14 changes: 9 additions & 5 deletions subiquity/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,10 +574,11 @@ async def wait_for_cloudinit(self):

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.
Expand All @@ -588,9 +589,12 @@ def select_autoinstall(self):
):
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),
)
Expand Down
38 changes: 28 additions & 10 deletions subiquity/server/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,39 +54,57 @@ def create(self, path, contents):
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):
def test_arg_wins(self):
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")
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")
self.assert_contents(root, "arg")

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
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, "arg")
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")
self.assertEqual(root, self.server.select_autoinstall())
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")
Expand Down

0 comments on commit 76b520a

Please sign in to comment.