VOL-34 Add group printing at CLI

Change-Id: I4e8e55ffd397c3d1486dc2807e92dd87eea9856e
diff --git a/cli/utils.py b/cli/utils.py
index 105931b..729c3a2 100644
--- a/cli/utils.py
+++ b/cli/utils.py
@@ -32,9 +32,9 @@
 
 
 def p_cookie(cookie):
-    cookie = str(cookie)
+    cookie =  '%x' % int(cookie)
     if len(cookie) > 8:
-        return cookie[:6] + '...'
+        return '~' + cookie[len(cookie)-8:]
     else:
         return cookie
 
@@ -152,9 +152,27 @@
 
     table.print_table(header, printfn)
 
-    # see CORD-817 (https://jira.opencord.org/browse/CORD-817)
-    # assert len(groups) == 0
 
+def print_groups(what, id, type, groups, printfn=_printfn):
+    header = ''.join([
+        '{} '.format(what),
+        colored(id, color='green', attrs=['bold']),
+        ' (type: ',
+        colored(type, color='blue'),
+        ')'
+    ]) + '\nGroups ({}):'.format(len(groups))
+
+    table = TablePrinter()
+    for i, group in enumerate(groups):
+        output_ports = []
+        for bucket in group['desc']['buckets']:
+            for action in bucket['actions']:
+                if action['type'] == 'OFPAT_OUTPUT':
+                   output_ports.append(action['output']['port'])
+        table.add_cell(i, 0, 'group_id', value=str(group['desc']['group_id']))
+        table.add_cell(i, 1, 'buckets', value=str(dict(output=output_ports)))
+
+    table.print_table(header, printfn)
 
 def dict2line(d):
     assert isinstance(d, dict)