1)flow table is improved for OpenOlt device adding more information e.g.
flow_id, flow_category, flow_type, gemport_id, alloc_id, o_pbits, intf_onu_id
2)exit command added
Change-Id: Ia7c8e2ad67455a78d99b1c439965c6c58df3b59e
diff --git a/cli/main.py b/cli/main.py
index 3a7dfed..3a30a0d 100755
--- a/cli/main.py
+++ b/cli/main.py
@@ -21,6 +21,7 @@
from optparse import make_option
from time import sleep, time
+import etcd3
import grpc
import requests
from cmd2 import Cmd, options
@@ -43,6 +44,7 @@
defs = dict(
# config=os.environ.get('CONFIG', './cli.yml'),
+ etcd=os.environ.get('ETCD', 'etcd-cluster.default.svc.cluster.local:2379'),
consul=os.environ.get('CONSUL', 'localhost:8500'),
voltha_grpc_endpoint=os.environ.get('VOLTHA_GRPC_ENDPOINT',
'localhost:50055'),
@@ -56,7 +58,7 @@
__ _____| | |_| |_ __ _ / __| | |_ _|
\ V / _ \ | _| ' \/ _` | | (__| |__ | |
\_/\___/_|\__|_||_\__,_| \___|____|___|
-(to exit type quit or hit Ctrl-D)
+(to exit type quit or exit or hit Ctrl-D)
"""
@@ -88,10 +90,11 @@
del Cmd.do_load
del Cmd.do__relative_load
- def __init__(self, voltha_grpc, voltha_sim_rest, global_request=False):
+ def __init__(self, voltha_grpc, voltha_sim_rest, etcd, global_request=False):
VolthaCli.voltha_grpc = voltha_grpc
VolthaCli.voltha_sim_rest = voltha_sim_rest
VolthaCli.global_request = global_request
+ VolthaCli.etcd = etcd
Cmd.__init__(self)
self.prompt = '(' + self.colorize(
self.colorize(self.prompt, 'blue'), 'bold') + ') '
@@ -154,6 +157,10 @@
while self.history:
self.history.pop()
+ def do_exit(self,line):
+ """exit from CLI"""
+ quit()
+
def do_launch(self, line):
"""If Voltha is not running yet, launch it"""
raise NotImplementedError('not implemented yet')
@@ -220,7 +227,7 @@
self.poutput( self.colorize('Error: ', 'red') +
'There is no such device')
raise Exception('<device-id> is not a valid one')
- sub = DeviceCli(device_id, self.get_stub)
+ sub = DeviceCli(device_id, self.get_stub, self.etcd)
sub.cmdloop()
def do_logical_device(self, line):
@@ -868,6 +875,10 @@
parser.add_argument(
'-C', '--consul', action='store', default=defs['consul'], help=_help)
+ _help = '<hostname>:<port> to etcd container (default: %s)' % defs['etcd']
+ parser.add_argument(
+ '-E', '--etcd', action='store', default=defs['etcd'], help=_help)
+
_help = 'Lookup Voltha endpoints based on service entries in Consul'
parser.add_argument(
'-L', '--lookup', action='store_true', help=_help)
@@ -908,7 +919,10 @@
args.sim_rest_endpoint = '{}:{}'.format(services[0]['ServiceAddress'],
services[0]['ServicePort'])
- c = VolthaCli(args.grpc_endpoint, args.sim_rest_endpoint,
+ host = args.etcd.split(':')[0].strip()
+ port = int(args.etcd.split(':')[1].strip())
+ etcd = etcd3.client(host=host, port=port)
+ c = VolthaCli(args.grpc_endpoint, args.sim_rest_endpoint, etcd,
args.global_request)
c.poutput(banner)
c.load_history()