Add provisioner formatters
This commit is contained in:
parent
b2e6feeba3
commit
30ebd6b42c
|
@ -4091,23 +4091,27 @@ def cli_provisioner_template_system_remove(name):
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# > pvc provisioner template system list TODO:formatter
|
# > pvc provisioner template system list
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@click.command(name="list", short_help="List all system templates.")
|
@click.command(name="list", short_help="List all system templates.")
|
||||||
@connection_req
|
@connection_req
|
||||||
@click.argument("limit", default=None, required=False)
|
@click.argument("limit", default=None, required=False)
|
||||||
def cli_provisioner_template_system_list(limit):
|
@format_opt(
|
||||||
|
{
|
||||||
|
"pretty": cli_provisioner_template_system_list_format_pretty,
|
||||||
|
"raw": lambda d: "\n".join([t["name"] for t in d]),
|
||||||
|
"json": lambda d: jdumps(d),
|
||||||
|
"json-pretty": lambda d: jdumps(d, indent=2),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
def cli_provisioner_template_system_list(limit, format_function):
|
||||||
"""
|
"""
|
||||||
List all system templates in the PVC cluster provisioner.
|
List all system templates in the PVC cluster provisioner.
|
||||||
"""
|
"""
|
||||||
retcode, retdata = pvc.lib.provisioner.template_list(
|
retcode, retdata = pvc.lib.provisioner.template_list(
|
||||||
CLI_CONFIG, limit, template_type="system"
|
CLI_CONFIG, limit, template_type="system"
|
||||||
)
|
)
|
||||||
if retcode:
|
finish(retcode, retdata, format_function)
|
||||||
retdata = pvc.lib.provisioner.format_list_template(
|
|
||||||
retdata, template_type="system"
|
|
||||||
)
|
|
||||||
finish(retcode, retdata)
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -4203,23 +4207,27 @@ def cli_provisioner_template_network_remove(name):
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# > pvc provisioner template network list TODO:formatter
|
# > pvc provisioner template network list
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@click.command(name="list", short_help="List all network templates.")
|
@click.command(name="list", short_help="List all network templates.")
|
||||||
@connection_req
|
@connection_req
|
||||||
@click.argument("limit", default=None, required=False)
|
@click.argument("limit", default=None, required=False)
|
||||||
def cli_provisioner_template_network_list(limit):
|
@format_opt(
|
||||||
|
{
|
||||||
|
"pretty": cli_provisioner_template_network_list_format_pretty,
|
||||||
|
"raw": lambda d: "\n".join([t["name"] for t in d]),
|
||||||
|
"json": lambda d: jdumps(d),
|
||||||
|
"json-pretty": lambda d: jdumps(d, indent=2),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
def cli_provisioner_template_network_list(limit, format_function):
|
||||||
"""
|
"""
|
||||||
List all network templates in the PVC cluster provisioner.
|
List all network templates in the PVC cluster provisioner.
|
||||||
"""
|
"""
|
||||||
retcode, retdata = pvc.lib.provisioner.template_list(
|
retcode, retdata = pvc.lib.provisioner.template_list(
|
||||||
CLI_CONFIG, limit, template_type="network"
|
CLI_CONFIG, limit, template_type="network"
|
||||||
)
|
)
|
||||||
if retcode:
|
finish(retcode, retdata, format_function)
|
||||||
retdata = pvc.lib.provisioner.format_list_template(
|
|
||||||
retdata, template_type="network"
|
|
||||||
)
|
|
||||||
finish(retcode, retdata)
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -4336,23 +4344,27 @@ def cli_provisioner_template_storage_remove(name):
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# > pvc provisioner template storage list TODO:formatter
|
# > pvc provisioner template storage list
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@click.command(name="list", short_help="List all storage templates.")
|
@click.command(name="list", short_help="List all storage templates.")
|
||||||
@connection_req
|
@connection_req
|
||||||
@click.argument("limit", default=None, required=False)
|
@click.argument("limit", default=None, required=False)
|
||||||
def cli_provisioner_template_storage_list(limit):
|
@format_opt(
|
||||||
|
{
|
||||||
|
"pretty": cli_provisioner_template_storage_list_format_pretty,
|
||||||
|
"raw": lambda d: "\n".join([t["name"] for t in d]),
|
||||||
|
"json": lambda d: jdumps(d),
|
||||||
|
"json-pretty": lambda d: jdumps(d, indent=2),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
def cli_provisioner_template_storage_list(limit, format_function):
|
||||||
"""
|
"""
|
||||||
List all storage templates in the PVC cluster provisioner.
|
List all storage templates in the PVC cluster provisioner.
|
||||||
"""
|
"""
|
||||||
retcode, retdata = pvc.lib.provisioner.template_list(
|
retcode, retdata = pvc.lib.provisioner.template_list(
|
||||||
CLI_CONFIG, limit, template_type="storage"
|
CLI_CONFIG, limit, template_type="storage"
|
||||||
)
|
)
|
||||||
if retcode:
|
finish(retcode, retdata, format_function)
|
||||||
retdata = pvc.lib.provisioner.format_list_template(
|
|
||||||
retdata, template_type="storage"
|
|
||||||
)
|
|
||||||
finish(retcode, retdata)
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -4633,32 +4645,35 @@ def cli_provisioner_userdata_show(name):
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# > pvc provisioner userdata list TODO:formatter
|
# > pvc provisioner userdata list
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@click.command(name="list", short_help="List all userdata documents.")
|
@click.command(name="list", short_help="List all userdata documents.")
|
||||||
@connection_req
|
@connection_req
|
||||||
@click.argument("limit", default=None, required=False)
|
@click.argument("limit", default=None, required=False)
|
||||||
@click.option(
|
@click.option(
|
||||||
"-f",
|
"-l",
|
||||||
"--full",
|
"--long",
|
||||||
"full",
|
"long_output",
|
||||||
is_flag=True,
|
is_flag=True,
|
||||||
default=False,
|
default=False,
|
||||||
help="Show all lines of the document instead of first 4.",
|
help="Show all lines of the document instead of first 4 ('pretty' format only).",
|
||||||
)
|
)
|
||||||
def cli_provisioner_userdata_list(limit, full):
|
@format_opt(
|
||||||
|
{
|
||||||
|
"pretty": cli_provisioner_userdata_list_format_pretty,
|
||||||
|
"raw": lambda d: "\n".join([u["name"] for u in d]),
|
||||||
|
"json": lambda d: jdumps(d),
|
||||||
|
"json-pretty": lambda d: jdumps(d, indent=2),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
def cli_provisioner_userdata_list(limit, long_output, format_function):
|
||||||
"""
|
"""
|
||||||
List all userdata documents in the PVC cluster provisioner.
|
List all userdata documents in the PVC cluster provisioner.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
retcode, retdata = pvc.lib.provisioner.userdata_list(CLI_CONFIG, limit)
|
retcode, retdata = pvc.lib.provisioner.userdata_list(CLI_CONFIG, limit)
|
||||||
if retcode:
|
CLI_CONFIG["long_output"] = long_output
|
||||||
if not full:
|
finish(retcode, retdata, format_function)
|
||||||
lines = 4
|
|
||||||
else:
|
|
||||||
lines = None
|
|
||||||
retdata = pvc.lib.provisioner.format_list_userdata(retdata, lines)
|
|
||||||
finish(retcode, retdata)
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -4812,32 +4827,35 @@ def cli_provisioner_script_show(name):
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# > pvc provisioner script list TODO:formatter
|
# > pvc provisioner script list
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@click.command(name="list", short_help="List all scripts.")
|
@click.command(name="list", short_help="List all scripts.")
|
||||||
@connection_req
|
@connection_req
|
||||||
@click.argument("limit", default=None, required=False)
|
@click.argument("limit", default=None, required=False)
|
||||||
@click.option(
|
@click.option(
|
||||||
"-f",
|
"-l",
|
||||||
"--full",
|
"--long",
|
||||||
"full",
|
"long_output",
|
||||||
is_flag=True,
|
is_flag=True,
|
||||||
default=False,
|
default=False,
|
||||||
help="Show all lines of the document instead of first 4.",
|
help="Show all lines of the document instead of first 4 ('pretty' format only).",
|
||||||
)
|
)
|
||||||
def cli_provisioner_script_list(limit, full):
|
@format_opt(
|
||||||
|
{
|
||||||
|
"pretty": cli_provisioner_script_list_format_pretty,
|
||||||
|
"raw": lambda d: "\n".join([s["name"] for s in d]),
|
||||||
|
"json": lambda d: jdumps(d),
|
||||||
|
"json-pretty": lambda d: jdumps(d, indent=2),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
def cli_provisioner_script_list(limit, long_output, format_function):
|
||||||
"""
|
"""
|
||||||
List all scripts in the PVC cluster provisioner.
|
List all scripts in the PVC cluster provisioner.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
retcode, retdata = pvc.lib.provisioner.script_list(CLI_CONFIG, limit)
|
retcode, retdata = pvc.lib.provisioner.script_list(CLI_CONFIG, limit)
|
||||||
if retcode:
|
CLI_CONFIG["long_output"] = long_output
|
||||||
if not full:
|
finish(retcode, retdata, format_function)
|
||||||
lines = 4
|
|
||||||
else:
|
|
||||||
lines = None
|
|
||||||
retdata = pvc.lib.provisioner.format_list_script(retdata, lines)
|
|
||||||
finish(retcode, retdata)
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -4915,20 +4933,26 @@ def cli_provisioner_ova_remove(name):
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# > pvc provisioner ova list TODO:formatter
|
# > pvc provisioner ova list
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@click.command(name="list", short_help="List all OVA images.")
|
@click.command(name="list", short_help="List all OVA images.")
|
||||||
@connection_req
|
@connection_req
|
||||||
@click.argument("limit", default=None, required=False)
|
@click.argument("limit", default=None, required=False)
|
||||||
def cli_provisioner_ova_list(limit):
|
@format_opt(
|
||||||
|
{
|
||||||
|
"pretty": cli_provisioner_ova_list_format_pretty,
|
||||||
|
"raw": lambda d: "\n".join([o["name"] for o in d]),
|
||||||
|
"json": lambda d: jdumps(d),
|
||||||
|
"json-pretty": lambda d: jdumps(d, indent=2),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
def cli_provisioner_ova_list(limit, format_function):
|
||||||
"""
|
"""
|
||||||
List all OVA images in the PVC cluster provisioner.
|
List all OVA images in the PVC cluster provisioner.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
retcode, retdata = pvc.lib.provisioner.ova_list(CLI_CONFIG, limit)
|
retcode, retdata = pvc.lib.provisioner.ova_list(CLI_CONFIG, limit)
|
||||||
if retcode:
|
finish(retcode, retdata, format_function)
|
||||||
retdata = pvc.lib.provisioner.format_list_ova(retdata)
|
|
||||||
finish(retcode, retdata)
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -5140,6 +5164,34 @@ def cli_provisioner_profile_remove(name):
|
||||||
finish(retcode, retdata)
|
finish(retcode, retdata)
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# > pvc provisioner profile info
|
||||||
|
###############################################################################
|
||||||
|
# Not implemented
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# > pvc provisioner profile list
|
||||||
|
###############################################################################
|
||||||
|
@click.command(name="list", short_help="List all profiles.")
|
||||||
|
@connection_req
|
||||||
|
@click.argument("limit", default=None, required=False)
|
||||||
|
@format_opt(
|
||||||
|
{
|
||||||
|
"pretty": cli_provisioner_profile_list_format_pretty,
|
||||||
|
"raw": lambda d: "\n".join([o["name"] for o in d]),
|
||||||
|
"json": lambda d: jdumps(d),
|
||||||
|
"json-pretty": lambda d: jdumps(d, indent=2),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
def cli_provisioner_profile_list(limit, format_function):
|
||||||
|
"""
|
||||||
|
List all profiles in the PVC cluster provisioner.
|
||||||
|
"""
|
||||||
|
retcode, retdata = pvc.lib.provisioner.profile_list(CLI_CONFIG, limit)
|
||||||
|
finish(retcode, retdata, format_function)
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# > pvc provisioner create
|
# > pvc provisioner create
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -5262,139 +5314,27 @@ def cli_provisioner_create(
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# > pvc provisioner status TODO:formatter
|
# > pvc provisioner status
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@click.command(name="status", short_help="Show status of provisioner job.")
|
@click.command(name="status", short_help="Show status of provisioner job.")
|
||||||
@connection_req
|
@connection_req
|
||||||
@click.argument("job", required=False, default=None)
|
@click.argument("job", required=False, default=None)
|
||||||
def cli_provisioner_status(job):
|
@format_opt(
|
||||||
|
{
|
||||||
|
"pretty": cli_provisioner_status_format_pretty,
|
||||||
|
"raw": lambda d: "\n".join([t["id"] for t in d])
|
||||||
|
if isinstance(d, list)
|
||||||
|
else d["state"],
|
||||||
|
"json": lambda d: jdumps(d),
|
||||||
|
"json-pretty": lambda d: jdumps(d, indent=2),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
def cli_provisioner_status(job, format_function):
|
||||||
"""
|
"""
|
||||||
Show status of provisioner job JOB or a list of jobs.
|
Show status of provisioner job JOB or a list of jobs.
|
||||||
"""
|
"""
|
||||||
retcode, retdata = pvc.lib.provisioner.task_status(CLI_CONFIG, job)
|
retcode, retdata = pvc.lib.provisioner.task_status(CLI_CONFIG, job)
|
||||||
if job is None and retcode:
|
finish(retcode, retdata, format_function)
|
||||||
retdata = pvc.lib.provisioner.format_list_task(retdata)
|
|
||||||
finish(retcode, retdata)
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# > pvc
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -5862,6 +5802,7 @@ cli_provisioner_template_storage_disk.add_command(
|
||||||
)
|
)
|
||||||
cli_provisioner_template_storage.add_command(cli_provisioner_template_storage_disk)
|
cli_provisioner_template_storage.add_command(cli_provisioner_template_storage_disk)
|
||||||
cli_provisioner_template.add_command(cli_provisioner_template_storage)
|
cli_provisioner_template.add_command(cli_provisioner_template_storage)
|
||||||
|
cli_provisioner.add_command(cli_provisioner_template)
|
||||||
cli_provisioner_userdata.add_command(cli_provisioner_userdata_add)
|
cli_provisioner_userdata.add_command(cli_provisioner_userdata_add)
|
||||||
cli_provisioner_userdata.add_command(cli_provisioner_userdata_modify)
|
cli_provisioner_userdata.add_command(cli_provisioner_userdata_modify)
|
||||||
cli_provisioner_userdata.add_command(cli_provisioner_userdata_remove)
|
cli_provisioner_userdata.add_command(cli_provisioner_userdata_remove)
|
||||||
|
@ -5881,6 +5822,7 @@ cli_provisioner.add_command(cli_provisioner_ova)
|
||||||
cli_provisioner_profile.add_command(cli_provisioner_profile_add)
|
cli_provisioner_profile.add_command(cli_provisioner_profile_add)
|
||||||
cli_provisioner_profile.add_command(cli_provisioner_profile_modify)
|
cli_provisioner_profile.add_command(cli_provisioner_profile_modify)
|
||||||
cli_provisioner_profile.add_command(cli_provisioner_profile_remove)
|
cli_provisioner_profile.add_command(cli_provisioner_profile_remove)
|
||||||
|
cli_provisioner_profile.add_command(cli_provisioner_profile_list)
|
||||||
cli_provisioner.add_command(cli_provisioner_profile)
|
cli_provisioner.add_command(cli_provisioner_profile)
|
||||||
cli_provisioner.add_command(cli_provisioner_create)
|
cli_provisioner.add_command(cli_provisioner_create)
|
||||||
cli_provisioner.add_command(cli_provisioner_status)
|
cli_provisioner.add_command(cli_provisioner_status)
|
||||||
|
|
|
@ -42,6 +42,12 @@ from pvc.lib.storage import format_list_osd as storage_format_osd_list
|
||||||
from pvc.lib.storage import format_list_pool as storage_format_pool_list
|
from pvc.lib.storage import format_list_pool as storage_format_pool_list
|
||||||
from pvc.lib.storage import format_list_volume as storage_format_volume_list
|
from pvc.lib.storage import format_list_volume as storage_format_volume_list
|
||||||
from pvc.lib.storage import format_list_snapshot as storage_format_snapshot_list
|
from pvc.lib.storage import format_list_snapshot as storage_format_snapshot_list
|
||||||
|
from pvc.lib.provisioner import format_list_template as provisioner_format_template_list
|
||||||
|
from pvc.lib.provisioner import format_list_userdata as provisioner_format_userdata_list
|
||||||
|
from pvc.lib.provisioner import format_list_script as provisioner_format_script_list
|
||||||
|
from pvc.lib.provisioner import format_list_ova as provisioner_format_ova_list
|
||||||
|
from pvc.lib.provisioner import format_list_profile as provisioner_format_profile_list
|
||||||
|
from pvc.lib.provisioner import format_list_task as provisioner_format_task_status
|
||||||
|
|
||||||
|
|
||||||
# Define colour values for use in formatters
|
# Define colour values for use in formatters
|
||||||
|
@ -660,3 +666,67 @@ def cli_storage_snapshot_list_format_pretty(CLI_CONFIG, data):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return storage_format_snapshot_list(CLI_CONFIG, data)
|
return storage_format_snapshot_list(CLI_CONFIG, data)
|
||||||
|
|
||||||
|
|
||||||
|
def cli_provisioner_template_system_list_format_pretty(CLI_CONFIG, data):
|
||||||
|
"""
|
||||||
|
Pretty format the output of cli_provisioner_template_system_list
|
||||||
|
"""
|
||||||
|
|
||||||
|
return provisioner_format_template_list(CLI_CONFIG, data, template_type="system")
|
||||||
|
|
||||||
|
|
||||||
|
def cli_provisioner_template_network_list_format_pretty(CLI_CONFIG, data):
|
||||||
|
"""
|
||||||
|
Pretty format the output of cli_provisioner_template_network_list
|
||||||
|
"""
|
||||||
|
|
||||||
|
return provisioner_format_template_list(CLI_CONFIG, data, template_type="network")
|
||||||
|
|
||||||
|
|
||||||
|
def cli_provisioner_template_storage_list_format_pretty(CLI_CONFIG, data):
|
||||||
|
"""
|
||||||
|
Pretty format the output of cli_provisioner_template_storage_list
|
||||||
|
"""
|
||||||
|
|
||||||
|
return provisioner_format_template_list(CLI_CONFIG, data, template_type="storage")
|
||||||
|
|
||||||
|
|
||||||
|
def cli_provisioner_userdata_list_format_pretty(CLI_CONFIG, data):
|
||||||
|
"""
|
||||||
|
Pretty format the output of cli_provisioner_userdata_list
|
||||||
|
"""
|
||||||
|
|
||||||
|
return provisioner_format_userdata_list(CLI_CONFIG, data)
|
||||||
|
|
||||||
|
|
||||||
|
def cli_provisioner_script_list_format_pretty(CLI_CONFIG, data):
|
||||||
|
"""
|
||||||
|
Pretty format the output of cli_provisioner_script_list
|
||||||
|
"""
|
||||||
|
|
||||||
|
return provisioner_format_script_list(CLI_CONFIG, data)
|
||||||
|
|
||||||
|
|
||||||
|
def cli_provisioner_ova_list_format_pretty(CLI_CONFIG, data):
|
||||||
|
"""
|
||||||
|
Pretty format the output of cli_provisioner_ova_list
|
||||||
|
"""
|
||||||
|
|
||||||
|
return provisioner_format_ova_list(CLI_CONFIG, data)
|
||||||
|
|
||||||
|
|
||||||
|
def cli_provisioner_profile_list_format_pretty(CLI_CONFIG, data):
|
||||||
|
"""
|
||||||
|
Pretty format the output of cli_provisioner_profile_list
|
||||||
|
"""
|
||||||
|
|
||||||
|
return provisioner_format_profile_list(CLI_CONFIG, data)
|
||||||
|
|
||||||
|
|
||||||
|
def cli_provisioner_status_format_pretty(CLI_CONFIG, data):
|
||||||
|
"""
|
||||||
|
Pretty format the output of cli_provisioner_status
|
||||||
|
"""
|
||||||
|
|
||||||
|
return provisioner_format_task_status(CLI_CONFIG, data)
|
||||||
|
|
|
@ -750,24 +750,11 @@ def task_status(config, task_id=None, is_watching=False):
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
retvalue = True
|
retvalue = True
|
||||||
respjson = response.json()
|
respjson = response.json()
|
||||||
|
|
||||||
if is_watching:
|
if is_watching:
|
||||||
# Just return the raw JSON to the watching process instead of formatting it
|
# Just return the raw JSON to the watching process instead of including value
|
||||||
return respjson
|
return respjson
|
||||||
|
|
||||||
job_state = respjson["state"]
|
|
||||||
if job_state == "RUNNING":
|
|
||||||
retdata = "Job state: RUNNING\nStage: {}/{}\nStatus: {}".format(
|
|
||||||
respjson["current"], respjson["total"], respjson["status"]
|
|
||||||
)
|
|
||||||
elif job_state == "FAILED":
|
|
||||||
retdata = "Job state: FAILED\nStatus: {}".format(respjson["status"])
|
|
||||||
elif job_state == "COMPLETED":
|
|
||||||
retdata = "Job state: COMPLETED\nStatus: {}".format(respjson["status"])
|
|
||||||
else:
|
else:
|
||||||
retdata = "Job state: {}\nStatus: {}".format(
|
return retvalue, respjson
|
||||||
respjson["state"], respjson["status"]
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
retvalue = False
|
retvalue = False
|
||||||
retdata = response.json().get("message", "")
|
retdata = response.json().get("message", "")
|
||||||
|
@ -814,7 +801,7 @@ def task_status(config, task_id=None, is_watching=False):
|
||||||
#
|
#
|
||||||
# Format functions
|
# Format functions
|
||||||
#
|
#
|
||||||
def format_list_template(template_data, template_type=None):
|
def format_list_template(config, template_data, template_type=None):
|
||||||
"""
|
"""
|
||||||
Format the returned template template
|
Format the returned template template
|
||||||
|
|
||||||
|
@ -1330,7 +1317,12 @@ def format_list_template_storage(template_template):
|
||||||
return "\n".join(template_list_output)
|
return "\n".join(template_list_output)
|
||||||
|
|
||||||
|
|
||||||
def format_list_userdata(userdata_data, lines=None):
|
def format_list_userdata(config, userdata_data):
|
||||||
|
if not config.get("long_output"):
|
||||||
|
lines = 4
|
||||||
|
else:
|
||||||
|
lines = None
|
||||||
|
|
||||||
if isinstance(userdata_data, dict):
|
if isinstance(userdata_data, dict):
|
||||||
userdata_data = [userdata_data]
|
userdata_data = [userdata_data]
|
||||||
|
|
||||||
|
@ -1432,7 +1424,12 @@ def format_list_userdata(userdata_data, lines=None):
|
||||||
return "\n".join(userdata_list_output)
|
return "\n".join(userdata_list_output)
|
||||||
|
|
||||||
|
|
||||||
def format_list_script(script_data, lines=None):
|
def format_list_script(config, script_data):
|
||||||
|
if not config.get("long_output"):
|
||||||
|
lines = 4
|
||||||
|
else:
|
||||||
|
lines = None
|
||||||
|
|
||||||
if isinstance(script_data, dict):
|
if isinstance(script_data, dict):
|
||||||
script_data = [script_data]
|
script_data = [script_data]
|
||||||
|
|
||||||
|
@ -1531,7 +1528,7 @@ def format_list_script(script_data, lines=None):
|
||||||
return "\n".join(script_list_output)
|
return "\n".join(script_list_output)
|
||||||
|
|
||||||
|
|
||||||
def format_list_ova(ova_data):
|
def format_list_ova(config, ova_data):
|
||||||
if isinstance(ova_data, dict):
|
if isinstance(ova_data, dict):
|
||||||
ova_data = [ova_data]
|
ova_data = [ova_data]
|
||||||
|
|
||||||
|
@ -1678,7 +1675,7 @@ def format_list_ova(ova_data):
|
||||||
return "\n".join(ova_list_output)
|
return "\n".join(ova_list_output)
|
||||||
|
|
||||||
|
|
||||||
def format_list_profile(profile_data):
|
def format_list_profile(config, profile_data):
|
||||||
if isinstance(profile_data, dict):
|
if isinstance(profile_data, dict):
|
||||||
profile_data = [profile_data]
|
profile_data = [profile_data]
|
||||||
|
|
||||||
|
@ -1867,7 +1864,23 @@ def format_list_profile(profile_data):
|
||||||
return "\n".join(profile_list_output)
|
return "\n".join(profile_list_output)
|
||||||
|
|
||||||
|
|
||||||
def format_list_task(task_data):
|
def format_list_task(config, task_data):
|
||||||
|
if not isinstance(task_data, list):
|
||||||
|
job_state = task_data["state"]
|
||||||
|
if job_state == "RUNNING":
|
||||||
|
retdata = "Job state: RUNNING\nStage: {}/{}\nStatus: {}".format(
|
||||||
|
task_data["current"], task_data["total"], task_data["status"]
|
||||||
|
)
|
||||||
|
elif job_state == "FAILED":
|
||||||
|
retdata = "Job state: FAILED\nStatus: {}".format(task_data["status"])
|
||||||
|
elif job_state == "COMPLETED":
|
||||||
|
retdata = "Job state: COMPLETED\nStatus: {}".format(task_data["status"])
|
||||||
|
else:
|
||||||
|
retdata = "Job state: {}\nStatus: {}".format(
|
||||||
|
task_data["state"], task_data["status"]
|
||||||
|
)
|
||||||
|
return retdata
|
||||||
|
|
||||||
task_list_output = []
|
task_list_output = []
|
||||||
|
|
||||||
# Determine optimal column widths
|
# Determine optimal column widths
|
||||||
|
|
Loading…
Reference in New Issue