From 35e6449cbf6be7b088b1b747176f3e034046cc59 Mon Sep 17 00:00:00 2001 From: Lili Nie Date: Tue, 19 Nov 2024 04:26:25 -0500 Subject: [PATCH] Support passing pubkeys to authorized_keys for `mrack` (#3354) --- docs/releases.rst | 3 +++ tmt/schemas/provision/beaker.yaml | 5 +++++ tmt/steps/provision/mrack.py | 16 +++++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/releases.rst b/docs/releases.rst index 57b9de08cf..0c77ffa435 100644 --- a/docs/releases.rst +++ b/docs/releases.rst @@ -16,6 +16,9 @@ support for :ref:`system.model-name`, The ``tmt lint`` command now reports a failure if empty environment files are found. +The :ref:`/plugins/provision/beaker` provision plugin gains support +for adding pubkeys to instance by populating the kickstart file. + tmt-1.38.0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tmt/schemas/provision/beaker.yaml b/tmt/schemas/provision/beaker.yaml index 50acc91467..c430f766a5 100644 --- a/tmt/schemas/provision/beaker.yaml +++ b/tmt/schemas/provision/beaker.yaml @@ -49,5 +49,10 @@ properties: beaker-job-owner: type: string + public-keys: + type: array + items: + type: string + required: - how diff --git a/tmt/steps/provision/mrack.py b/tmt/steps/provision/mrack.py index 967c1d069d..5c1a7f40e9 100644 --- a/tmt/steps/provision/mrack.py +++ b/tmt/steps/provision/mrack.py @@ -866,6 +866,16 @@ class BeakerGuestData(tmt.steps.provision.GuestSshData): Submitting user must be a submission delegate for the ``USERNAME``. """) + public_keys: Optional[list[str]] = field( + default=None, + option='--public-keys', + metavar='PUBLICKEYS', + help=""" + If set, Beaker jobs will be submitted on behalf of ``USERNAME``. + Submitting user must be a submission delegate for the ``USERNAME``. + """, + normalize=tmt.utils.normalize_string_list) + @dataclasses.dataclass class ProvisionBeakerData(BeakerGuestData, tmt.steps.provision.ProvisionStepData): @@ -901,6 +911,7 @@ class CreateJobParameters: kickstart: dict[str, str] whiteboard: Optional[str] beaker_job_owner: Optional[str] + public_keys: Optional[list[str]] group: str = 'linux' def to_mrack(self) -> dict[str, Any]: @@ -911,6 +922,8 @@ def to_mrack(self) -> dict[str, Any]: if self.kickstart: data['beaker']['ks_meta'] = self.kickstart.get('metadata') data['beaker']['ks_append'] = self.kickstart + if self.public_keys: + data['beaker']['pubkeys'] = self.public_keys return data @@ -1090,7 +1103,8 @@ def _create(self, tmt_name: str) -> None: os=self.image, name=f'{self.image}-{self.arch}', whiteboard=self.whiteboard or tmt_name, - beaker_job_owner=self.beaker_job_owner) + beaker_job_owner=self.beaker_job_owner, + public_keys=self.public_keys) try: response = self.api.create(data)