From 3977e9e4abeec864a1f662351d42f0fc172b53f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Zatloukal?= Date: Mon, 7 Oct 2024 19:45:39 +0200 Subject: [PATCH] Pass {USER, COREOS}_DATA separately in testcloud --- tmt/steps/provision/testcloud.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tmt/steps/provision/testcloud.py b/tmt/steps/provision/testcloud.py index 0e12dfaa06..4bb051fce1 100644 --- a/tmt/steps/provision/testcloud.py +++ b/tmt/steps/provision/testcloud.py @@ -767,11 +767,7 @@ def prepare_ssh_key(self, key_type: Optional[str] = None) -> None: with open(self.workdir / f'{key_name}.pub') as pubkey_file: public_key = pubkey_file.read() - # Place public key content into the machine configuration - self.config.USER_DATA = Template(USER_DATA).safe_substitute( - user_name=self.user, public_key=public_key) - self.config.COREOS_DATA = Template(COREOS_DATA).safe_substitute( - user_name=self.user, public_key=public_key) + return public_key def prepare_config(self) -> None: """ Prepare common configuration """ @@ -1009,18 +1005,23 @@ def start(self) -> None: # Prepare ssh key # TODO: Maybe... some better way to do this? + public_key = self.prepare_ssh_key(SSH_KEYGEN_TYPE) if self._domain.coreos: self._instance.coreos = True # prepare_ssh_key() writes key directly to COREOS_DATA self._instance.ssh_path = [] - self.prepare_ssh_key(SSH_KEYGEN_TYPE) + data_tpl = Template(COREOS_DATA).safe_substitute( + user_name=self.user, public_key=public_key) + else: + data_tpl = Template(USER_DATA).safe_substitute( + user_name=self.user, public_key=public_key) # Boot the virtual machine self.info('progress', 'booting...', 'cyan') assert libvirt is not None try: - self._instance.prepare() + self._instance.prepare(data_tpl=data_tpl) self._instance.spawn_vm() self._instance.start(BOOT_TIMEOUT * time_coeff) except (testcloud.exceptions.TestcloudInstanceError,