epcim
12/21/2013 - 2:06 AM

gistfile1.txt

import getopt
import pycassa
import subprocess
import sys

from pycassa.pool import ConnectionPool
from pycassa.columnfamily import ColumnFamily

def query_typename(column, typename):
    data = column.get(typename.replace('-', '_'))
    for item in data:
        (name, uuid) = item.rsplit(':', 1)
        print name, uuid

def usage():
    print 'vnc_query typename'

def main(argv):
    pool = ConnectionPool('config_db_uuid')
    column = ColumnFamily(pool, 'obj_fq_name_table')

    if len(argv) != 1:
        usage()
        sys.exit(1)

    query_typename(column, argv[0])

if __name__ == '__main__':
    main(sys.argv[1:])