Support showing individual userdata and script doc

Closes #89
This commit is contained in:
Joshua Boniface 2020-02-27 14:31:08 -05:00
parent fd80eb9e22
commit 11f045f100
2 changed files with 60 additions and 0 deletions

View File

@ -189,6 +189,21 @@ def userdata_list(config, limit):
else:
return False, response.json()['message']
def userdata_show(config, name):
"""
Get information about userdata name
API endpoint: GET /api/v1/provisioner/userdata/{name}
API arguments:
API schema: [{json_data_object},{json_data_object},etc.]
"""
response = call_api(config, 'get', '/provisioner/userdata/{}'.format(name))
if response.status_code == 200:
return True, response.json()[0]['userdata']
else:
return False, response.json()['message']
def userdata_add(config, params):
"""
Add a new userdata with {params}
@ -291,6 +306,21 @@ def script_list(config, limit):
else:
return False, response.json()['message']
def script_show(config, name):
"""
Get information about script name
API endpoint: GET /api/v1/provisioner/script/{name}
API arguments:
API schema: [{json_data_object},{json_data_object},etc.]
"""
response = call_api(config, 'get', '/provisioner/script/{}'.format(name))
if response.status_code == 200:
return True, response.json()[0]['script']
else:
return False, response.json()['message']
def script_add(config, params):
"""
Add a new script with {params}

View File

@ -2678,6 +2678,20 @@ def provisioner_userdata_list(limit, full):
retdata = pvc_provisioner.format_list_userdata(retdata, lines)
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner userdata show
###############################################################################
@click.command(name='show', short_help='Show contents of userdata documents.')
@click.argument(
'name'
)
def provisioner_userdata_show(name):
"""
Show the full contents of userdata document NAME.
"""
retcode, retdata = pvc_provisioner.userdata_show(config, name)
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner userdata add
###############################################################################
@ -2836,6 +2850,20 @@ def provisioner_script_list(limit, full):
retdata = pvc_provisioner.format_list_script(retdata, lines)
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner script show
###############################################################################
@click.command(name='show', short_help='Show contents of script documents.')
@click.argument(
'name'
)
def provisioner_script_show(name):
"""
Show the full contents of script document NAME.
"""
retcode, retdata = pvc_provisioner.script_show(config, name)
cleanup(retcode, retdata)
###############################################################################
# pvc provisioner script add
###############################################################################
@ -3578,11 +3606,13 @@ provisioner_template.add_command(provisioner_template_storage)
provisioner_template.add_command(provisioner_template_list)
provisioner_userdata.add_command(provisioner_userdata_list)
provisioner_userdata.add_command(provisioner_userdata_show)
provisioner_userdata.add_command(provisioner_userdata_add)
provisioner_userdata.add_command(provisioner_userdata_modify)
provisioner_userdata.add_command(provisioner_userdata_remove)
provisioner_script.add_command(provisioner_script_list)
provisioner_script.add_command(provisioner_script_show)
provisioner_script.add_command(provisioner_script_add)
provisioner_script.add_command(provisioner_script_modify)
provisioner_script.add_command(provisioner_script_remove)