-
Notifications
You must be signed in to change notification settings - Fork 1
/
mds-cli
executable file
·39 lines (34 loc) · 1.26 KB
/
mds-cli
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
#!/usr/bin/python
import mds, persistentdb, transientdb, gevent.server, rpc
import logging, config, util, sys, os.path
header="""Meta-Data Server of SoftSAN
Usage: mds-cli [options]
options:"""
cfgstruct = (\
('address', 'a', '0.0.0.0', 'IP address to bind'), \
('port', 'p', 0x6789, 'TCP port to bind'), \
('rootpath', 'r', None, 'root path for serving meta data'),\
('logging-level', 'l', 'info', 'logging level, can be "debug", "info", "warning", "error" or "critical"'), \
('logging-file', 'f', 'stdout', 'logging appends to this file'),\
('config', 'c', 'softsan.conf', 'config file'),\
('help', 'h', False, 'this help'),\
)
try:
configure,_ = config.config(cfgstruct, 'mds')
except:
pass
if configure['help']==True:
print header
config.usage_print(cfgstruct)
exit(0)
util.setupLogging(configure)
rootpath=configure['rootpath']
assert rootpath, 'the rootpath option must be specified'
assert os.path.isdir(rootpath), 'the rootpath "{0}" must exists'.format(rootpath)
pdb=persistentdb.PersistentDB(rootpath)
tdb=transientdb.TransientDB()
server=mds.MDS(tdb, pdb)
service=rpc.RpcService(server)
endpoint=(configure['address'], int(configure['port']))
framework=gevent.server.StreamServer(endpoint, service.handler)
framework.serve_forever()