Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- pool = ConnectionPool('config_db_uuid')
- col_fam = ColumnFamily(pool, 'obj_uuid_table')
- zk = KazooClient(hosts='127.0.0.1:2181')
- zk.start()
- uuid = sys.argv[1]
- print 'Looking up %s in Cassandra... ' % (uuid,),
- cass_data = col_fam.get_range(uuid).next()[1]
- print 'Found it!'
- t = cass_data['type']
- if t != '"route_target"':
- print 'Unexpected type:', t
- sys.exit(1)
- print 'Backrefs:'
- backrefs_found = False
- for k in cass_data:
- if k.startswith('backref'):
- _br, _type, next_uuid = k.split(':')
- print '%s: %s' % (_type, next_uuid)
- backrefs_found = True
- if not backrefs_found:
- print ' No backrefs'
- print
- display_name = cass_data['prop:display_name'].strip('"')
- print 'Display name:', display_name
- rt_id = int(display_name.split(':')[-1])
- zk_path = '/id/bgp/route-targets/%010d' % (rt_id,)
- print 'Looking it up in Zookeeper (%s)... ' % (zk_path,),
- zk_data, _zk_stat = zk.get(zk_path)
- print 'Found it!'
- print
- print 'Data:', zk_data
- print
- zk_path = '/fq-name-to-uuid/routing_instance:%s' % (zk_data,)
- try:
- print 'Looking up as routing instance (%s)... ' % (zk_path,),
- zk_data, _zk_stat = zk.get(zk_path)
- print 'Found it!'
- print 'UUID:', zk_data
- print
- print 'Looking it up in Cassandra...',
- cass_data = col_fam.get_range(zk_data).next()[1]
- print 'Found it!'
- print
- print cass_data
- except:
- print 'Not found!'
- print
- print 'Scanning through Cassandra for fq_name: %s' % zk_data
- fq_name = zk_data.split(':')
- match = None
- for d in col_fam.get_range():
- uuid, data = d
- if data.get('type', '') == '"routing_instance"' and data['fq_name'] == fq_name:
- match = d
- break
- if match:
- print 'Found it!'
- print data['fq_name']
- print fq_name
- else:
- print 'Not found!'
- zk.stop()
Advertisement
Add Comment
Please, Sign In to add comment