of13: fix OFPGroupStats

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
FUJITA Tomonori 2013-10-15 17:36:28 +09:00
parent 650c5b9d42
commit ab46901518
2 changed files with 46 additions and 6 deletions

View File

@ -3982,16 +3982,48 @@ class OFPQueueStatsReply(OFPMultipartReply):
super(OFPQueueStatsReply, self).__init__(datapath, **kwargs)
class OFPGroupStats(ofproto_parser.namedtuple('OFPGroupStats', (
'length', 'group_id', 'ref_count', 'packet_count',
'byte_count', 'duration_sec', 'duration_nsec'))):
class OFPBucketCounter(StringifyMixin):
def __init__(self, packet_count, byte_count):
super(OFPBucketCounter, self).__init__()
self.packet_count = packet_count
self.byte_count = byte_count
@classmethod
def parser(cls, buf, offset):
packet_count, byte_count = struct.unpack_from(
ofproto_v1_3.OFP_BUCKET_COUNTER_PACK_STR, buf, offset)
return cls(packet_count, byte_count)
class OFPGroupStats(StringifyMixin):
def __init__(self, length=None, group_id=None, ref_count=None,
packet_count=None, byte_count=None, duration_sec=None,
duration_nsec=None, bucket_stats=None):
super(OFPGroupStats, self).__init__()
self.length = length
self.group_id = group_id
self.ref_count = ref_count
self.packet_count = packet_count
self.byte_count = byte_count
self.duration_sec = duration_sec
self.duration_nsec = duration_nsec
self.bucket_stats = bucket_stats
@classmethod
def parser(cls, buf, offset):
group = struct.unpack_from(ofproto_v1_3.OFP_GROUP_STATS_PACK_STR,
buf, offset)
stats = cls(*group)
stats.length = ofproto_v1_3.OFP_GROUP_STATS_SIZE
return stats
group_stats = cls(*group)
group_stats.bucket_stats = []
total_len = group_stats.length + offset
offset += ofproto_v1_3.OFP_GROUP_STATS_SIZE
while total_len > offset:
b = OFPBucketCounter.parser(buf, offset)
group_stats.bucket_stats.append(b)
offset += ofproto_v1_3.OFP_BUCKET_COUNTER_SIZE
return group_stats
@_set_stats_type(ofproto_v1_3.OFPMP_GROUP, OFPGroupStats)

View File

@ -3,6 +3,14 @@
"body": [
{
"OFPGroupStats": {
"bucket_stats": [
{
"OFPBucketCounter": {
"byte_count": 2345,
"packet_count": 234
}
}
],
"byte_count": 12345,
"duration_nsec": 609036000,
"duration_sec": 9,