Skip to content

Commit

Permalink
Support passing pubkeys to authorized_keys for mrack (#3354)
Browse files Browse the repository at this point in the history
  • Loading branch information
skycastlelily committed Nov 19, 2024
1 parent efb4663 commit 35e6449
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ support for :ref:`system.model-name</spec/hardware/system>`,
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
5 changes: 5 additions & 0 deletions tmt/schemas/provision/beaker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,10 @@ properties:
beaker-job-owner:
type: string

public-keys:
type: array
items:
type: string

required:
- how
16 changes: 15 additions & 1 deletion tmt/steps/provision/mrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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]:
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 35e6449

Please sign in to comment.