from indextoastname import IndexToastName lt=LogTime() work_cursor=database.db_conn.cursor() work_cursor.execute("SELECT id FROM host_cluster WHERE alive AND observable") for hc_id in work_cursor.fetchall(): hc=HostCluster(hc_id[0]) hc.discover_cluster_params() hc.stat(lt.id) for dbs in hc.get_dependants(obs=True): db_conn_string=hc.return_conn_string(dbs['db_name']) dn=DatabaseName(dbs['id'],db_conn_string) dn.stat(lt.id) db_cursor=dn.get_prod_cursor() if db_cursor: for sn_id in dn.get_dependants(obs=True): sn=SchemaName(sn_id) sn.discover_tables(db_cursor) sn.discover_functions(db_cursor) for tbl_id in sn.get_tables(): tn=TableName(tbl_id) tn.stat(lt.id,db_cursor) tn.va_stat(lt.id,db_cursor) tn.discover_indexes(db_cursor) for ind_id in tn.get_dependants():
elif param in ('-p','--port'): if not isinstance(value,int) and value <= 0: print "Port parameter is incorrect: {0}".format(value) sys.exit(2) else: port=value elif param in ("-s","--dsn"): string_output=False cur=database.db_conn.cursor() get_stat=cur.mogrify("SELECT id FROM host_cluster WHERE {0}=%s AND param_port=%s".format(host_search),(host,port)) cur.execute(get_stat) res_id=cur.fetchone() if not res_id: print "No PostgreSQL cluster found for host: {0} port {1}".format(host,port) cur.close() sys.exit(2) hc=HostCluster(res_id[0]) for dbs in hc.get_dependants(): if dbs['db_name'] == db_name: print hc.return_conn_string(dbname=db_name) cur.close() sys.exit(0) print "No PostgreSQL cluster found for host: {0} port {1} database {2}".format(host,port,db_name) cur.close() sys.exit(2)