Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testflinger-yaml-generator: add provision parameters for oem_autoinstall connector #76

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions Tools/PC/testflinger_yaml_generator/testflinger_yaml_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,28 @@ def __init__(self, cid, default_yaml_file_path="./template/template.yaml",
self.is_distupgrade = is_distupgrade

def provision_setting(self, is_provision, image="desktop-22-04-2-uefi",
provision_type="distro"):
provision_type="distro", provision_token="",
provision_auth_keys="", provision_user_data=""):
if not is_provision:
self.yaml_remove_field("provision_data")
return
setting_dict = {'provision_data': {provision_type: image}}

# additional parameters if use oem_autoinstall connector
attachments = []
if provision_user_data:
setting_dict['provision_data']['user_data'] = provision_user_data
attachments.append({'local': provision_user_data})
if provision_token:
setting_dict['provision_data']['token_file'] = provision_token
attachments.append({'local': provision_token})
if provision_auth_keys:
setting_dict['provision_data'][
'authorized_keys'] = provision_auth_keys
attachments.append({'local': provision_auth_keys})
if attachments:
setting_dict['provision_data']['attachments'] = attachments

self.yaml_update_field(setting_dict)

def reserve_setting(self, is_reserve, lp_username, timeout=120):
Expand Down Expand Up @@ -326,6 +343,21 @@ def parse_input_arg():
help='The provision image. \
ie, desktop-22-04-2-uefi. \
If didn\'t set this mean no provision')
opt_args.add_argument('--provisionToken', default="", type=str,
help='Optional file with username and token \
when image URL requires authentication \
(i.e Jenkins artifact). This file must be \
in YAML format, i.e: \
\"username: $JENKINS_USERNAME \\n \
token: $JENKINS_API_TOKEN\"')
opt_args.add_argument('--provisionUserData', default="", type=str,
help='user-data file for autoinstall and cloud-init \
provisioning. This argument is a MUST required \
if deploy the image using the autoinstall image \
(i.e. 24.04 image)')
opt_args.add_argument('--provisionAuthKeys', default="", type=str,
help='ssh authorized_keys file to add in \
provisioned system')
opt_args.add_argument('--globalTimeout', type=int, default=43200,
help="Set the testflinger's global timeout. \
Max:43200")
Expand Down Expand Up @@ -392,7 +424,10 @@ def parse_input_arg():

builder.provision_setting(is_provision=provision,
image=args.provisionImage,
provision_type=args.provisionType)
provision_type=args.provisionType,
provision_token=args.provisionToken,
provision_user_data=args.provisionUserData,
provision_auth_keys=args.provisionAuthKeys)

builder.reserve_setting(is_reserve=reserve,
lp_username=args.LpID,
Expand Down
Loading