Exemplo n.º 1
0
 def do_meters(self, _):
     """Show flow meter table for logical device"""
     logical_device = pb2dict(self.get_logical_device(-1))
     print_meters('Logical Device',
                  self.logical_device_id,
                  type='n/a',
                  meters=logical_device['meters']['items'])
Exemplo n.º 2
0
 def do_groups(self, _):
     """Show flow group table for logical device"""
     logical_device = pb2dict(self.get_logical_device(-1))
     print_groups('Logical Device',
                  self.logical_device_id,
                  type='n/a',
                  groups=logical_device['flow_groups']['items'])
Exemplo n.º 3
0
 def do_flows(self, line):
     """Show flow table for device"""
     device = pb2dict(self.get_device(-1))
     print_flows('Device',
                 self.device_id,
                 type=device['type'],
                 flows=device['flows']['items'],
                 groups=device['flow_groups']['items'])
Exemplo n.º 4
0
 def add(_row, pb, prefix='', number=0):
     d = pb2dict(pb)
     if show_nulls:
         fields = pb.DESCRIPTOR.fields
         for field in fields:
             set_row(d, _row, field, getattr(pb, field.name), t, prefix,
                     fields_to_omit, number)
     else:
         fields = pb.ListFields()
         for (field, value) in fields:
             set_row(d, _row, field, value, t, prefix, fields_to_omit,
                     number)
Exemplo n.º 5
0
    def set_cell(pb, field, value, t, prefix, fields_to_omit):
        d = pb2dict(pb)
        fname = prefix + field.name

        if fname in fields_to_omit:
            return
        if isinstance(value, Message):
            pr(value, fname + '.')
        elif is_repeated_item(value):  # handles any list
            row = t.number_of_rows()
            t.add_cell(row, 0, 'field', fname)
            t.add_cell(row, 1, 'value',
                       '{} item(s)'.format(len(d.get(field.name))))
        else:
            row = t.number_of_rows()
            t.add_cell(row, 0, 'field', fname)
            t.add_cell(row, 1, 'value', value)