Yuvipanda has submitted this change and it was merged.
Change subject: Read whitelist/greylist from files and compare to db
......................................................................
Read whitelist/greylist from files and compare to db
Change-Id: I616ea7bb4b4d61bf95184b9e34ccfcb929dcc0b1
---
M auditor/run.py
M auditor/table.py
2 files changed, 16 insertions(+), 2 deletions(-)
Approvals:
Yuvipanda: Verified; Looks good to me, approved
diff --git a/auditor/run.py b/auditor/run.py
index 8a4758a..a7a688b 100644
--- a/auditor/run.py
+++ b/auditor/run.py
@@ -12,7 +12,7 @@
argparser.add_argument('--hosts', help='Hosts to connect to')
argparser.add_argument('--mwconfig', help='Path to mediawiki-config
repository')
-argparser.add_argument('--expectedconfig', help='Path to yaml file listing
expected table config', nargs='+')
+argparser.add_argument('--expectedconfig', help='Path to yaml file listing
expected table config')
argparser.add_argument('--db_suffix', help='Suffix to use for each database
name',
default='')
@@ -54,6 +54,19 @@
tables[tablename] = table
db.add_table(table)
+expected_tables = {}
+for configfile in args.expectedconfig.split(','):
+ configdata = yaml.load(open(configfile))
+ for tablename, tabledict in configdata.items():
+ expected_tables[tablename] = Table.from_dict(tablename, tabledict)
+
+extra_tables = set(tables.keys()) - set(expected_tables.keys())
+
+# Write out extra tables list
+yaml.dump({
+ tables[table].name: tables[table].dbs.keys() for table in extra_tables
+}, open('extratables.yaml', 'w'))
+
# Write out db lists
yaml.dump({
'not-in-db': list(whitelist_dbs - set(dbs.keys())),
diff --git a/auditor/table.py b/auditor/table.py
index c7f412c..c1de4d0 100644
--- a/auditor/table.py
+++ b/auditor/table.py
@@ -38,7 +38,7 @@
@classmethod
def from_dict(cls, tablename, tabledata):
- table = cls(tablename, tabledata.get('where', None))
+ table = cls(tablename, [], tabledata.get('where', None))
if isinstance(tabledata['columns'], list):
# Whitelisted table
for colname in tabledata['columns']:
@@ -47,3 +47,4 @@
# Greylisted table!
for colname, coldata in tabledata['columns'].items():
table.add_column(Column(colname, False,
coldata.get('condition'), coldata.get('replacewith')))
+ return table
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/180104
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I616ea7bb4b4d61bf95184b9e34ccfcb929dcc0b1
Gerrit-PatchSet: 5
Gerrit-Project: operations/software/labsdb-auditor
Gerrit-Branch: master
Gerrit-Owner: Yuvipanda <[email protected]>
Gerrit-Reviewer: Yuvipanda <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits