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/utils.py b/cli/utils.py
index 82d6a12..ea190a1 100644
--- a/cli/utils.py
+++ b/cli/utils.py
@@ -111,7 +111,7 @@
}
-def print_flows(what, id, type, flows, groups, printfn=_printfn):
+def print_flows(what, id, type, flows, groups, printfn=_printfn, flows_info=[], fields_to_omit=[]):
header = ''.join([
'{} '.format(what),
@@ -124,9 +124,31 @@
table = TablePrinter()
for i, flow in enumerate(flows):
- table.add_cell(i, 0, 'table_id', value=str(flow['table_id']))
- table.add_cell(i, 1, 'priority', value=str(flow['priority']))
- table.add_cell(i, 2, 'cookie', p_cookie(flow['cookie']))
+ if flows_info:
+ flow_info = flows_info[i]
+ else:
+ flow_info = dict()
+
+ if 'table_id' not in fields_to_omit:
+ table.add_cell(i, 0, 'table_id', value=str(flow['table_id']))
+ if 'flow_id' not in fields_to_omit and 'flow_id' in flow_info:
+ table.add_cell(i, 1, 'flow_id', value=str(flow_info['flow_id']))
+ if 'flow_category' not in fields_to_omit and 'flow_category' in flow_info:
+ table.add_cell(i, 2, 'flow_category', value=str(flow_info['flow_category']))
+ if 'flow_type' not in fields_to_omit and 'flow_type' in flow_info:
+ table.add_cell(i, 3, 'flow_type', value=str(flow_info['flow_type']))
+ if 'priority' not in fields_to_omit:
+ table.add_cell(i, 4, 'priority', value=str(flow['priority']))
+ if 'gemport_id' not in fields_to_omit and 'gemport_id' in flow_info:
+ table.add_cell(i, 5, 'gemport_id', value=str(flow_info['gemport_id']))
+ if 'alloc_id' not in fields_to_omit and 'alloc_id' in flow_info:
+ table.add_cell(i, 6, 'alloc_id', value=str(flow_info['alloc_id']))
+ if 'o_pbits' not in fields_to_omit and 'o_pbits' in flow_info:
+ table.add_cell(i, 7, 'o_pbits', value=str(flow_info['o_pbits']))
+ if 'pon_intf_onu_id' not in fields_to_omit and 'pon_intf_onu_id' in flow_info:
+ table.add_cell(i, 8, 'intf_onu_id', value=str(flow_info['pon_intf_onu_id']))
+ if 'cookie' not in fields_to_omit:
+ table.add_cell(i, 9, 'cookie', p_cookie(flow['cookie']))
assert flow['match']['type'] == 'OFPMT_OXM'
for field in flow['match']['oxm_fields']:
@@ -142,16 +164,20 @@
atype = action['type'][len('OFPAT_'):]
table.add_cell(i, *action_printers[atype](action))
elif itype == 1:
- table.add_cell(i, 10000, 'goto-table',
- instruction['goto_table']['table_id'])
+ if 'goto-table' not in fields_to_omit:
+ table.add_cell(i, 10000, 'goto-table',
+ instruction['goto_table']['table_id'])
elif itype == 2:
- table.add_cell(i, 10001, 'write-metadata',
- instruction['write_metadata']['metadata'])
+ if 'write-metadata' not in fields_to_omit:
+ table.add_cell(i, 10001, 'write-metadata',
+ instruction['write_metadata']['metadata'])
elif itype == 5:
- table.add_cell(i, 10002, 'clear-actions', [])
+ if 'clear-actions' not in fields_to_omit:
+ table.add_cell(i, 10002, 'clear-actions', [])
elif itype == 6:
- table.add_cell(i, 10003, 'meter',
- instruction['meter']['meter_id'])
+ if 'meter' not in fields_to_omit:
+ table.add_cell(i, 10003, 'meter',
+ instruction['meter']['meter_id'])
else:
raise NotImplementedError(
'not handling instruction type {}'.format(itype))