def schema_verifier(**args):
zk_prefix = SHARDED_DBS_PREFIX_MAP[args.instance_type]['zk_prefix']
seed_instance = HostAddr(args.seed_instance)
desired = show_create_table(seed_instance, args.seed_db, args.table)
tbl_hash = hashlib.md5(desired).hexdigest()
print("Desired table definition:\n{desired}").format(desired=desired)
incorrect = check_schema(zk_prefix, args.table, tbl_hash)
if len(incorrect) == 0:
print "It appears that all schema is synced"
sys.exit(0)
d = difflib.Differ()
for problem in incorrect.iteritems():
represenative = list(problem[1])[0].split(' ')
hostaddr = HostAddr(represenative[0])
create = show_create_table(hostaddr, represenative[1], args.table)
diff = d.compare(desired.splitlines(), create.splitlines())
print 'The following difference has been found:'
print '\n'.join(diff)
print "It is present on the following db's:"
print '\n'.join(list(problem[1]))
sys.exit(1)
评论列表
文章目录