-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdo_vacuum.py
50 lines (42 loc) · 1.3 KB
/
do_vacuum.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
import sys
import megamaid
#################################################################################
# CONFIGURABLE TABLE LIST
#
# Tables to be vacuumed for each day, of the form
# days : tables
# where 'days' is an iterable of 0-indexed days, 0 being monday
# and 'tables' is an iterable of table names
#
VACUUM_SCHEDULE = {
(0,2,4) : [
'table1',
'table2',
],
(1,3,6) : [
'table3',
'table1',
'table4',
],
(5) : [
megamaid.REMAINING_TABLES, # this is special. it means 'the rest'
],
}
DATABASE = 'mydatabase'
#################################################################################
def main(configdump=False, dryrun=False):
if not configdump:
megamaid.vacuum(database=DATABASE, table_config=VACUUM_SCHEDULE, dryrun=dryrun)
else:
for day in xrange(7):
megamaid.vacuum(day_index=day, database=DATABASE, table_config=VACUUM_SCHEDULE, dryrun=True)
return 0
if __name__ == '__main__':
dryrun = False
configdump = False
if '--dryrun' in sys.argv or '-d' in sys.argv: dryrun = True
if '--config' in sys.argv or '-c' in sys.argv:
configdump = True
dryrun = True
sys.exit(main(configdump, dryrun))