forked from Flumotion/flumotion-common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate-config.py
66 lines (45 loc) · 1.79 KB
/
validate-config.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
import warnings
from flumotion.manager import manager, config
from flumotion.common import registry, setup
def _promoteDeprecationWarnings():
warnings.filterwarnings('error', category=DeprecationWarning,
module='.*flumotion.*')
def _validateManagerPlugs(conf):
for socket, plugs in conf.plugs.items():
for args in plugs:
defs = registry.getRegistry().getPlug(args['type'])
e = defs.getEntry()
e.getModuleName()
def validate(fname, onlyManager=False, printOnly=False):
if not printOnly:
_promoteDeprecationWarnings()
conf = config.ManagerConfigParser(fname)
conf.parseBouncerAndPlugs()
_validateManagerPlugs(conf)
if onlyManager:
return
conf = config.PlanetConfigParser(fname)
conf.parse()
def main(argv):
import optparse
usage = '%prog [options] CONFIG_FILENAME'
parser = optparse.OptionParser(usage=usage)
parser.add_option('-m', '--manager-only',
action='store_true', dest='managerOnly', default=False,
help=("only validate manager-specific parts - flow and"
" atmosphere configurations will not be checked"))
parser.add_option('-p', '--print-only',
action='store_true', dest='printOnly', default=False,
help=("only print warnings - don't actually raise"
" DeprecationWarning instances"))
options, args = parser.parse_args(argv)
if not len(args):
parser.error('No filename given.')
setup.setup()
setup.setupPackagePath()
validate(args[0], options.managerOnly, options.printOnly)
if __name__ == '__main__':
import sys
main(sys.argv[1:])