Skip to content

Commit

Permalink
Pass {USER, COREOS}_DATA separately in testcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
frantisekz committed Oct 7, 2024
1 parent 0af72a0 commit 3977e9e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tmt/steps/provision/testcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 """
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 3977e9e

Please sign in to comment.