[VOL-1414] Update voltha CLI to support dynamic logging. This
update also cleans up the log library as well as remove XPON
from the CLI.
Change-Id: Ife44abdcca7ac078f29db297d94a4b96f66b1514
diff --git a/python/cli/main.py b/python/cli/main.py
index 00ea702..0fc9b5b 100755
--- a/python/cli/main.py
+++ b/python/cli/main.py
@@ -156,6 +156,41 @@
while self.history:
self.history.pop()
+ @options([
+ make_option('-p', '--package', action="store", dest='package',
+ help="Package Name"),
+ make_option('-l', '--level', action='store', dest='level'),
+ ])
+ def do_log(self, line, opts):
+
+ def logLevel(level):
+ switcher= {
+ "DEBUG": 0,
+ "INFO":1,
+ "WARNING":2,
+ "ERROR":3,
+ "CRITICAL":4,
+ "FATAL":5
+ }
+ return switcher.get(level, 3)
+
+ if opts.level is None:
+ return
+
+ stub = self.get_stub()
+ kw = dict()
+ if opts.package:
+ kw['package_name'] = "github.com/opencord/voltha-go/" + opts.package
+
+ kw['level'] = logLevel(opts.level.upper())
+
+ try:
+ logging = voltha_pb2.Logging(**kw)
+ stub.UpdateLogLevel(logging)
+ self.poutput('success')
+ except Exception as e:
+ self.poutput('Exception - {})'.format(e))
+
def do_launch(self, line):
"""If Voltha is not running yet, launch it"""
raise NotImplementedError('not implemented yet')
@@ -267,21 +302,6 @@
if d.startswith(text)]
return completions
- def do_xpon(self, line):
- """xpon <optional> [device_ID] - Enter xpon level command mode"""
- device_id = line.strip()
- if device_id:
- stub = self.get_stub()
- try:
- res = stub.GetDevice(voltha_pb2.ID(id=device_id))
- except Exception:
- self.poutput(
- self.colorize('Error: ', 'red') + 'No device id ' +
- self.colorize(device_id, 'blue') + ' is found')
- return
- sub = XponCli(self.get_channel, device_id)
- sub.cmdloop()
-
def do_omci(self, line):
"""omci <device_ID> - Enter OMCI level command mode"""