Yuvipanda has uploaded a new change for review.
https://gerrit.wikimedia.org/r/179110
Change subject: [WIP] Add dblist / shard support for bootstrapper
......................................................................
[WIP] Add dblist / shard support for bootstrapper
Change-Id: I8a4709e0b3803812fa85eb1f705f18426377bc9a
---
A auditor/__init__.py
A auditor/bootstrap.py
A auditor/dbreflector.py
3 files changed, 33 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/software/labsdb-auditor
refs/changes/10/179110/1
diff --git a/auditor/__init__.py b/auditor/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/auditor/__init__.py
diff --git a/auditor/bootstrap.py b/auditor/bootstrap.py
new file mode 100644
index 0000000..bd7bd2a
--- /dev/null
+++ b/auditor/bootstrap.py
@@ -0,0 +1,15 @@
+import argparse
+import MySQLdb
+
+from dbreflector import DBReflector
+
+argparser = argparse.ArgumentParser()
+
+argparser.add_argument('hosts', help='Hosts to connect to', nargs='*')
+
+args = argparser.parse_args()
+
+for host in args.hosts:
+ conn = MySQLdb.connect(host=host, read_default_file='~/.my.cnf')
+ reflector = DBReflector(conn)
+ print reflector.get_databases()
diff --git a/auditor/dbreflector.py b/auditor/dbreflector.py
new file mode 100644
index 0000000..4ea1287
--- /dev/null
+++ b/auditor/dbreflector.py
@@ -0,0 +1,18 @@
+class DBReflector(object):
+ """
+ Provides methods to gather metadata about objects in a database server
+ """
+ def __init__(self, conn):
+ self.conn = conn
+
+ def get_databases(self):
+ """
+ Get list of databases in given server
+
+ :return: List of databases from current server
+ """
+ cur = self.conn.cursor()
+ cur.execute("SHOW DATABASES")
+ results = [r[0] for r in cur.fetchall()]
+ cur.close()
+ return results
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/179110
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8a4709e0b3803812fa85eb1f705f18426377bc9a
Gerrit-PatchSet: 1
Gerrit-Project: operations/software/labsdb-auditor
Gerrit-Branch: master
Gerrit-Owner: Yuvipanda <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits