diff --git a/subiquity/server/server.py b/subiquity/server/server.py index c601a126..916422b4 100644 --- a/subiquity/server/server.py +++ b/subiquity/server/server.py @@ -86,7 +86,7 @@ from subiquitycore.snapd import ( NOPROBERARG = "NOPROBER" iso_autoinstall_path = 'cdrom/autoinstall.yaml' -reload_autoinstall_path = 'run/subiquity/reload.autoinstall.yaml' +root_autoinstall_path = 'autoinstall.yaml' cloud_autoinstall_path = 'run/subiquity/cloud.autoinstall.yaml' log = logging.getLogger('subiquity.server.server') @@ -545,10 +545,10 @@ class SubiquityServer(Application): def select_autoinstall(self): # precedence - # 1. data from before reload + # 1. autoinstall at root of drive # 2. command line argument autoinstall # 3. autoinstall supplied by cloud config - # 4. autoinstall baked into the iso at /autoinstall.yaml + # 4. autoinstall baked into the iso, found at /cdrom/autoinstall.yaml # if opts.autoinstall is set and empty, that means # autoinstall has been explicitly disabled. @@ -559,7 +559,7 @@ class SubiquityServer(Application): raise Exception( f'Autoinstall argument {self.opts.autoinstall} not found') - locations = (self.base_relative(reload_autoinstall_path), + locations = (self.base_relative(root_autoinstall_path), self.opts.autoinstall, self.base_relative(cloud_autoinstall_path), self.base_relative(iso_autoinstall_path)) @@ -570,9 +570,9 @@ class SubiquityServer(Application): else: return None - isopath = self.base_relative(iso_autoinstall_path) - copy_file_if_exists(loc, isopath) - return isopath + rootpath = self.base_relative(root_autoinstall_path) + copy_file_if_exists(loc, rootpath) + return rootpath def _user_has_password(self, username): with open('/etc/shadow') as fp: @@ -651,10 +651,6 @@ class SubiquityServer(Application): open(stamp_file, 'w').close() await asyncio.sleep(1) self.load_autoinstall_config(only_early=False) - if self.autoinstall is not None: - copy_file_if_exists( - self.autoinstall, - self.base_relative(reload_autoinstall_path)) if self.autoinstall_config: self.interactive = bool( self.autoinstall_config.get('interactive-sections')) diff --git a/subiquity/server/tests/test_server.py b/subiquity/server/tests/test_server.py index 7675bb7d..8f879a98 100644 --- a/subiquity/server/tests/test_server.py +++ b/subiquity/server/tests/test_server.py @@ -23,7 +23,7 @@ from subiquity.server.server import ( SubiquityServer, cloud_autoinstall_path, iso_autoinstall_path, - reload_autoinstall_path, + root_autoinstall_path, ) @@ -51,39 +51,42 @@ class TestAutoinstallLoad(SubiTestCase): return path def test_autoinstall_disabled(self): - self.create(reload_autoinstall_path, 'reload') + 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_reload_wins(self): - self.create(reload_autoinstall_path, 'reload') + 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') - iso = self.create(iso_autoinstall_path, 'iso') - self.assertEqual(iso, self.server.select_autoinstall()) - self.assert_contents(iso, 'reload') + 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 self.create(cloud_autoinstall_path, 'cloud') - iso = self.create(iso_autoinstall_path, 'iso') - self.assertEqual(iso, self.server.select_autoinstall()) - self.assert_contents(iso, 'arg') + self.create(iso_autoinstall_path, 'iso') + self.assertEqual(root, self.server.select_autoinstall()) + self.assert_contents(root, 'arg') def test_cloud_wins(self): + root = self.path(root_autoinstall_path) self.create(cloud_autoinstall_path, 'cloud') - iso = self.create(iso_autoinstall_path, 'iso') - self.assertEqual(iso, self.server.select_autoinstall()) - self.assert_contents(iso, 'cloud') + self.create(iso_autoinstall_path, 'iso') + self.assertEqual(root, self.server.select_autoinstall()) + self.assert_contents(root, 'cloud') def test_iso_wins(self): - iso = self.create(iso_autoinstall_path, 'iso') - self.assertEqual(iso, self.server.select_autoinstall()) - self.assert_contents(iso, 'iso') + root = self.path(root_autoinstall_path) + self.create(iso_autoinstall_path, 'iso') + self.assertEqual(root, self.server.select_autoinstall()) + self.assert_contents(root, 'iso') def test_nobody_wins(self): self.assertIsNone(self.server.select_autoinstall()) @@ -96,14 +99,15 @@ class TestAutoinstallLoad(SubiTestCase): def test_early_commands_changes_autoinstall(self): self.server.controllers = Mock() self.server.controllers.instances = [] - isopath = self.create(iso_autoinstall_path, '') + rootpath = self.path(root_autoinstall_path) - cmd = f"sed -i -e '$ a stuff: things' {isopath}" + cmd = f"sed -i -e '$ a stuff: things' {rootpath}" contents = f'''\ version: 1 early-commands: ["{cmd}"] ''' - self.create(cloud_autoinstall_path, contents) + arg = self.create(self.path('arg.autoinstall.yaml'), contents) + self.server.opts.autoinstall = arg self.server.autoinstall = self.server.select_autoinstall() self.server.load_autoinstall_config(only_early=True)