def list(): """ list all templates """ cl = utils.get_client() for template in sorted_by_uid(cl.templates.uids.values()): print(template.uid)
def get(guid, task, tb): """ print the detail of a task """ if not guid: print("no service guid specified") sys.exit(1) if not task: print("no task guid specified") sys.exit(1) cl = utils.get_client() try: service = cl.services.guids[guid] except KeyError: print("no service found with guid=%s" % guid) sys.exit(1) try: task = service.task_list.get_task_by_guid(task) except KeyError: print("no task with guid %s" % task) sys.exit(1) print_task(task, tb)
def list(): """ list all the services """ cl = utils.get_client() services = cl.services.names.values() for s in _sort_by_template(services): print_service(s)
def add(addr): """ add a template repository to the robot """ if not addr: print('not repository address specified') sys.exit(1) cl = utils.get_client() templates = cl.templates.add_repo(addr) print("template added:") for template in sorted_by_uid(templates): print(template.uid)
def delete(guid): """ delete a service """ if not guid: print("not guid specified") sys.exit(1) cl = utils.get_client() try: service = cl.services.guids[guid] service.delete() except KeyError: return
def schedule(guid, action): """ schedule an action on a service and prints the guid of the task created """ if not guid: print("no service guid specified") sys.exit(1) if not action: print("no action specified") sys.exit(1) cl = utils.get_client() try: service = cl.services.guids[guid] except KeyError: print("no service found with guid=%s" % guid) sys.exit(1) task = service.schedule_action(action, args=None) print('task created - %s' % task.guid)
def list(guid, all): """ list all task of a service """ if not guid: print("no service guid specified") sys.exit(1) cl = utils.get_client() try: service = cl.services.guids[guid] except KeyError: print("no service found with guid=%s" % guid) sys.exit(1) tasks = service.task_list.list_tasks(all=all) for task in sort_by_created(tasks): print("{created} - {guid} - {action} - {state}".format( created=j.data.time.epoch2HRDateTime(task.created), guid=task.guid, action=task.action_name, state=task.state))