Improved error handling when vpn host not created

This commit is contained in:
Ivan Gromov 2020-08-09 00:55:21 +05:00
parent 12e75333d6
commit ca3230c0de
4 changed files with 27 additions and 14 deletions

View file

@ -186,6 +186,9 @@ class PlaybookCLI(CLI):
display.display(taskmsg) display.display(taskmsg)
if 'vpn-host' not in inventory.groups:
raise ValueError('no_vpn_host')
else:
host = inventory.groups['vpn-host'].hosts[0].name host = inventory.groups['vpn-host'].hosts[0].name
host_vars = variable_manager.get_vars()['hostvars'][host] host_vars = variable_manager.get_vars()['hostvars'][host]
return { return {

View file

@ -40,7 +40,10 @@ async def playbook_get_handler(request):
return web.json_response({'status': None}) return web.json_response({'status': None})
if task_future.done(): if task_future.done():
try:
return web.json_response({'status': 'done', 'program': task_program, 'result': task_future.result()}) return web.json_response({'status': 'done', 'program': task_program, 'result': task_future.result()})
except ValueError as e:
return web.json_response({'status': 'error', 'program': task_program, 'result': str(e)})
elif task_future.cancelled(): elif task_future.cancelled():
return web.json_response({'status': 'cancelled', 'program': task_program}) return web.json_response({'status': 'cancelled', 'program': task_program})
else: else:

View file

@ -20,7 +20,9 @@
v-bind:disabled="ui_loading_check || ui_token_from_env" v-bind:disabled="ui_loading_check || ui_token_from_env"
v-model="scaleway_token" v-model="scaleway_token"
/> />
<p v-if="ui_token_from_env">Token was read from the environment</p> <div v-if="ui_token_from_env" class="form-text alert alert-success" role="alert">
Token was read from the environment variable
</div>
</div> </div>
<div class="form-group"> <div class="form-group">

View file

@ -20,6 +20,9 @@
v-bind:disabled="ui_loading_check" v-bind:disabled="ui_loading_check"
v-model="vultr_config" v-model="vultr_config"
/> />
<div v-if="ui_token_from_env" class="form-text alert alert-success" role="alert">
Configuration file was found in your system. You still can change the path to it
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -47,6 +50,7 @@ module.exports = {
vultr_config: null, vultr_config: null,
region: null, region: null,
// helper variables // helper variables
ui_token_from_env: false,
ui_loading_check: false, ui_loading_check: false,
ui_loading_regions: false, ui_loading_regions: false,
ui_region_options: [] ui_region_options: []
@ -69,6 +73,7 @@ module.exports = {
.then(response => { .then(response => {
if (response.path) { if (response.path) {
this.vultr_config = response.path; this.vultr_config = response.path;
this.ui_token_from_env = true;
} }
}) })
.finally(() => { .finally(() => {