def main(): '''Import command main. This is the command line entry point for the import command. ''' opts = getopts() initv(opts.verbose) info(f'import from {opts.xconf}') conf = get_conf(opts.base, opts.fname, opts.grxport, opts.pgxport) ximport(conf, opts.xconf) info('done')
def main(): '''Create command main. This is the command line entry point for the create command. ''' opts = getopts() initv(opts.verbose) info(f'creating {opts.base} based containers') conf = get_conf(opts.base, '', opts.grxport, opts.pgxport) create(conf, opts.wait) info('done')
def main(): '''Load command main. This is the command line entry point for the load command. ''' opts = getopts() initv(opts.verbose) info(f'load {opts.fname} into {opts.base}') conf = get_conf(opts.base, opts.fname, opts.grxport, opts.pgxport) load(conf, opts.wait) info('done')
def main(): '''Status command main. This is the command line entry point for the status command. It list the statistics for all grape containers running on the current system. ''' opts = getopts() initv(opts.verbose) info('status') client = docker.from_env() containers = client.containers.list(filters={'label': 'grape.type'}) # Collect report rows for each column. cols = { 'created': Column('Created'), 'id': Column('Id'), 'elapsed': Column('Elapsed'), 'image': Column('Image'), 'name': Column('Name'), 'ports': Column('Port'), 'started': Column('Started'), 'status': Column('Status'), 'type': Column('Type'), 'version': Column('Version') } populate_columns(containers, cols) # Report the status for all of the containers. colnames = [ 'name', 'type', 'version', 'status', 'started', 'elapsed', 'id', 'image', 'created', 'ports' ] ofp = sys.stdout if opts.verbose: if ofp == sys.stdout: ofp.write('\x1b[34m') for key in colnames: ofp.write(cols[key].hdr()) if ofp == sys.stdout: ofp.write('\x1b[0m') ofp.write('\n') for i in range(cols['name'].size()): for key in colnames: ofp.write(cols[key].get(i)) ofp.write('\n') info('done')
def main(): '''Tree command main. This is the command line entry point for the tree command. It presents a tree view of one or more grafana servers. ''' opts = getopts() initv(opts.verbose) info('tree') container = check_port(opts.grxport) burl = f'http://127.0.0.1:{opts.grxport}' name = container.name + ':' + str(opts.grxport) root = collect(burl, DEFAULT_AUTH, name) if opts.fname: with open(opts.fname, 'w', encoding='utf-8') as ofp: print_tree(opts, ofp, root) else: print_tree(opts, sys.stdout, root) info('done')