Beispiel #1
0
def graph_mode(client: MasterApiClient, args):
    if args.action == 'create':
        name, rev = client.create_graph(
            graph_struct=_prepare_graph_struct(args.name, args.graph, args.hosts, args.format),
            graph_name=args.name
        )
        print('Created graph "{}", revision {}.'.format(name, rev))
    elif args.action == 'info':
        if args.list_all:
            print(json.dumps([_.to_json() for _ in client.list_graphs(args.name, args.revision)],
                             indent=2, ensure_ascii=False))
        else:
            assert args.name, 'Graph name should be set'
            print(json.dumps(client.read_graph(args.name, args.revision).to_json(), indent=2, ensure_ascii=False))
    elif args.action == 'launch':
        print('Created new graph instance: {}'.format(client.launch_graph(args.name, args.revision)))
    else:
        logging.error('Not supported action for graph mode: %s', args.action)
        exit(1)