From aa074b23d91c203c172264bd12b8bfa2cc18c89b Mon Sep 17 00:00:00 2001 From: Yuichi Ito Date: Wed, 8 Jan 2014 14:29:36 +0900 Subject: [PATCH] ofctl_rest: improve readability of the result of MeterFeatures although 'band_types' of MeterFeatures were bitmaps of supported band types, it was expressed numerically. this patch makes 'band_types' human-readable. e.g.) curl http://localhost:8080/stats/meterfeatures/8796750050962 { "8796750050962": [ { "max_meter": 16777216, "max_color": 0, "max_band": 255, "band_types": ["DROP", "DSCP_REMARK"] } ] } Signed-off-by: Yuichi Ito Signed-off-by: FUJITA Tomonori --- ryu/lib/ofctl_v1_3.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ryu/lib/ofctl_v1_3.py b/ryu/lib/ofctl_v1_3.py index 99b55d6e..9f996800 100644 --- a/ryu/lib/ofctl_v1_3.py +++ b/ryu/lib/ofctl_v1_3.py @@ -550,6 +550,11 @@ def get_meter_stats(dp, waiters): def get_meter_features(dp, waiters): + + ofp = dp.ofproto + type_convert = {ofp.OFPMBT_DROP: 'DROP', + ofp.OFPMBT_DSCP_REMARK: 'DSCP_REMARK'} + stats = dp.ofproto_parser.OFPMeterFeaturesStatsRequest(dp, 0) msgs = [] send_stats_request(dp, stats, waiters, msgs) @@ -557,8 +562,12 @@ def get_meter_features(dp, waiters): features = [] for msg in msgs: for feature in msg.body: + band_types = [] + for k, v in type_convert.items(): + if (1 << k) & feature.band_types: + band_types.append(v) f = {'max_meter': feature.max_meter, - 'band_types': feature.band_types, + 'band_types': band_types, 'max_band': feature.max_band, 'max_color': feature.max_color} features.append(f)