Allow specifying arbitrary script_args on CLI

Allow the specifying of arbitrary provisioner script install() args on
the provisioner create CLI, either overriding or adding additional
per-VM arguments to those found in the profile. Reference example is
setting a "vm_fqdn" on a per-run basis.

Closes #100
This commit is contained in:
2020-07-08 13:18:12 -04:00
parent 8fc5299d38
commit a1ba9d2eeb
4 changed files with 33 additions and 10 deletions

View File

@ -3316,6 +3316,11 @@ def provisioner_profile_remove(name, confirm_flag):
@click.argument(
'profile'
)
@click.option(
'-a', '--script-arg', 'script_args',
default=[], multiple=True,
help='Additional argument to the script install() function in key=value format.'
)
@click.option(
'-d/-D', '--define/--no-define', 'define_flag',
is_flag=True, default=True, show_default=True,
@ -3332,7 +3337,7 @@ def provisioner_profile_remove(name, confirm_flag):
help='Wait for provisioning to complete, showing progress'
)
@cluster_req
def provisioner_create(name, profile, wait_flag, define_flag, start_flag):
def provisioner_create(name, profile, wait_flag, define_flag, start_flag, script_args):
"""
Create a new VM NAME with profile PROFILE.
@ -3345,11 +3350,14 @@ def provisioner_create(name, profile, wait_flag, define_flag, start_flag):
created VM on the PVC cluster. This can be useful for the administrator to create a "template"
set of VM disks via the normal provisioner, but without ever starting the resulting VM. The
resulting disk(s) can then be used as source volumes in other disk templates.
The "--script-arg" option can be specified as many times as required to pass additional,
VM-specific arguments to the provisioner install() function, beyond those set by the profile.
"""
if not define_flag:
start_flag = False
retcode, retdata = pvc_provisioner.vm_create(config, name, profile, wait_flag, define_flag, start_flag)
retcode, retdata = pvc_provisioner.vm_create(config, name, profile, wait_flag, define_flag, start_flag, script_args)
if retcode and wait_flag:
task_id = retdata