Exemplo n.º 1
0
def list():
    """
    list all templates
    """
    cl = utils.get_client()
    for template in sorted_by_uid(cl.templates.uids.values()):
        print(template.uid)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
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
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
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))