Add OVA script support

1. Ensure that system_template and script are not nullable in the DB.
2. Ensure that the CLI and API enforce the above and clean up CLI
arguments for profile add.
3. Ensure that, before uploading OVAs, a 'default_ova' provisioning
script is present.
4. Use the 'default_ova' script for new OVA uploads.
5. Ensure that OVA details are properly added to the vm_data dict in the
provisioner vmbuilder.
This commit is contained in:
2022-10-06 10:27:08 -04:00
parent bffab7a5a1
commit 7a3870fc44
7 changed files with 104 additions and 21 deletions

View File

@ -168,6 +168,15 @@ def delete_ova(zkhandler, name):
@ZKConnection(config)
def upload_ova(zkhandler, pool, name, ova_size):
# Check that we have a default_ova provisioning script
_, retcode = provisioner.list_script("default_ova", is_fuzzy=False)
if retcode != "200":
output = {
"message": "Did not find a 'default_ova' provisioning script. Please add one with that name, either the example from '/usr/share/pvc/provisioner/examples/script/2-ova.py' or a custom one, before uploading OVAs."
}
retcode = 400
return output, retcode
ova_archive = None
# Cleanup function
@ -402,7 +411,7 @@ def upload_ova(zkhandler, pool, name, ova_size):
None,
None,
userdata=None,
script=None,
script="default_ova",
ova=name,
arguments=None,
)