def template(request, appliance, provider, vm): template = mark_vm_as_template(appliance.rest_api, provider=provider, vm_name=vm) @request.addfinalizer def _finished(): if template.id in appliance.rest_api.collections.templates: appliance.rest_api.collections.templates.action.delete(*template) return template
def template(request, appliance, provider, vm): template = mark_vm_as_template(appliance, provider=provider, vm_name=vm) @request.addfinalizer def _finished(): appliance.rest_api.collections.templates.action.delete(*[template]) try: provider.mgmt.get_template(template.name).delete() except NotFoundError: logger.error( "Failed to delete template. No template found with name {}". format(template.name)) except MultipleItemsError: logger.error( "Failed to delete template. Multiple templates found with name {}" .format(template.name)) except Exception as e: logger.error(f"Failed to delete template. {e}") return template
def template(request, appliance, provider, vm): template = mark_vm_as_template(appliance, provider=provider, vm_name=vm) @request.addfinalizer def _finished(): appliance.rest_api.collections.templates.action.delete(*[template]) try: provider.mgmt.get_template(template.name).delete() except NotFoundError: logger.error( "Failed to delete template. No template found with name {}".format( template.name ) ) except MultipleItemsError: logger.error( "Failed to delete template. Multiple templates found with name {}".format( template.name ) ) except Exception as e: logger.error("Failed to delete template. {}".format(e)) return template