Commit 9bdb21b0 authored by Daniele Venzano's avatar Daniele Venzano
Browse files

Implement exec-get also in the zoe-admin tool

parent 478630f2
Pipeline #4524 passed with stages
in 4 minutes and 40 seconds
......@@ -17,6 +17,7 @@
This module contains the entrypoint for the commandline Zoe client
import datetime
import json
import logging
import os
......@@ -30,6 +31,7 @@ from zoe_cmd import utils
from import ZoeInfoAPI
from zoe_lib.exceptions import ZoeAPIException, InvalidApplicationDescription
from zoe_lib.executions import ZoeExecutionsAPI
from import ZoeServiceAPI
from zoe_lib.applications import app_validate
from zoe_lib.version import ZOE_API_VERSION
......@@ -80,6 +82,51 @@ def exec_list_cmd(auth, args):
print(tabulate(tabular_data, headers))
def exec_get_cmd(auth, args):
"""Gather information about an execution."""
exec_api = ZoeExecutionsAPI(auth['url'], auth['user'], auth['pass'])
cont_api = ZoeServiceAPI(auth['url'], auth['user'], auth['pass'])
execution = exec_api.get(
if execution is None:
print('Execution not found')
print('Execution {} (ID: {})'.format(execution['name'], execution['id']))
print('Application name: {}'.format(execution['description']['name']))
print('Status: {}'.format(execution['status']))
if execution['status'] == 'error':
print('Last error: {}'.format(execution['error_message']))
print('Time submit: {}'.format(datetime.datetime.fromtimestamp(execution['time_submit'])))
if execution['time_start'] is None:
print('Time start: {}'.format('not yet'))
print('Time start: {}'.format(datetime.datetime.fromtimestamp(execution['time_start'])))
if execution['time_end'] is None:
print('Time end: {}'.format('not yet'))
print('Time end: {}'.format(datetime.datetime.fromtimestamp(execution['time_end'])))
endpoints = exec_api.endpoints(execution['id'])
if endpoints is not None and len(endpoints) > 0:
print('Exposed endpoints:')
for endpoint in endpoints:
print(' - {}: {}'.format(endpoint[0], endpoint[1]))
print('This ZApp does not expose any endpoint')
tabular_data = []
for c_id in execution['services']:
service = cont_api.get(c_id)
service_data = [service['id'], service['name'], 'true' if service['essential'] else 'false', service['status'], service['backend_status'], service['error_message'] if service['error_message'] is not None else '']
headers = ['ID', 'Name', 'Essential', 'Zoe status', 'Backend status', 'Error message']
print(tabulate(tabular_data, headers))
def exec_rm_cmd(auth, args):
"""Delete an execution and kill it if necessary."""
exec_api = ZoeExecutionsAPI(auth['url'], auth['user'], auth['pass'])
......@@ -127,6 +174,10 @@ def process_arguments() -> Tuple[ArgumentParser, Namespace]:
argparser_app_list.add_argument('--later-than-end', help='Show only executions ended later than this timestamp (seconds since UTC epoch)')
argparser_execution_get = subparser.add_parser('exec-get', help="Get execution status")
argparser_execution_get.add_argument('id', type=int, help="Execution id")
argparser_execution_rm = subparser.add_parser('exec-rm', help="Deletes an execution")
argparser_execution_rm.add_argument('id', type=int, help="Execution id")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment