forked from biot/ops-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ops-cli
executable file
·37 lines (29 loc) · 890 Bytes
/
ops-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
#!/usr/bin/env python
import sys
from getopt import getopt
from opscli.cli import Opscli
from opscli.debug import debug_enable
DEFAULT_SERVER = 'unix:/var/run/openvswitch/db.sock'
COMMAND_MODULE_PATHS = ("cli-commands", )
def usage():
print "Usage: ops-cli [-h] [-s <server>] [-d <debug options>,...]"
sys.exit()
def main(args):
ovsdb_server = DEFAULT_SERVER
opts, args = getopt(args, 'hs:d:')
for opt, arg in opts:
if opt == '-h':
usage()
elif opt == '-s':
ovsdb_server = arg
elif opt == '-d':
for key in arg.split(','):
debug_enable(key)
try:
cli = Opscli(ovsdb_server, command_module_paths=COMMAND_MODULE_PATHS)
cli.start_shell()
except Exception as e:
# TODO log exception to debug log
raise
if __name__ == '__main__':
main(sys.argv[1:])