From 255fd1564e2703e7dec96c7e453f4f781defc2cb Mon Sep 17 00:00:00 2001 From: Minoru TAKAHASHI Date: Tue, 10 May 2016 14:29:46 +0900 Subject: ofctl_rest: Support OpenFlow 1.5 Signed-off-by: Minoru TAKAHASHI Signed-off-by: Shinpei Muraoka Signed-off-by: IWASE Yusuke Signed-off-by: FUJITA Tomonori --- ryu/app/ofctl_rest.py | 73 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 7 deletions(-) diff --git a/ryu/app/ofctl_rest.py b/ryu/app/ofctl_rest.py index 91258b78..9167fbf3 100644 --- a/ryu/app/ofctl_rest.py +++ b/ryu/app/ofctl_rest.py @@ -29,10 +29,12 @@ from ryu.ofproto import ofproto_v1_0 from ryu.ofproto import ofproto_v1_2 from ryu.ofproto import ofproto_v1_3 from ryu.ofproto import ofproto_v1_4 +from ryu.ofproto import ofproto_v1_5 from ryu.lib import ofctl_v1_0 from ryu.lib import ofctl_v1_2 from ryu.lib import ofctl_v1_3 from ryu.lib import ofctl_v1_4 +from ryu.lib import ofctl_v1_5 from ryu.app.wsgi import ControllerBase, WSGIApplication @@ -44,6 +46,7 @@ supported_ofctl = { ofproto_v1_2.OFP_VERSION: ofctl_v1_2, ofproto_v1_3.OFP_VERSION: ofctl_v1_3, ofproto_v1_4.OFP_VERSION: ofctl_v1_4, + ofproto_v1_5.OFP_VERSION: ofctl_v1_5, } # REST API @@ -57,6 +60,12 @@ supported_ofctl = { # get the desc stats of the switch # GET /stats/desc/ # +# get flows desc stats of the switch +# GET /stats/flowdesc/ +# +# get flows desc stats of the switch filtered by the fields +# POST /stats/flowdesc/ +# # get flows stats of the switch # GET /stats/flow/ # @@ -104,6 +113,10 @@ supported_ofctl = { # GET /stats/meterconfig/[/] # Note: Specification of meter id is optional # +# get meter desc stats of the switch +# GET /stats/meterdesc/[/] +# Note: Specification of meter id is optional +# # get meters stats of the switch # GET /stats/meter/[/] # Note: Specification of meter id is optional @@ -112,14 +125,16 @@ supported_ofctl = { # GET /stats/groupfeatures/ # # get groups desc stats of the switch -# GET /stats/groupdesc/ +# GET /stats/groupdesc/[/] +# Note: Specification of group id is optional (OpenFlow 1.5 or later) # # get groups stats of the switch # GET /stats/group/[/] # Note: Specification of group id is optional # # get ports description of the switch -# GET /stats/portdesc/ +# GET /stats/portdesc/[/] +# Note: Specification of port number is optional (OpenFlow 1.5 or later) # Update the switch stats # @@ -290,6 +305,11 @@ class StatsController(ControllerBase): def get_desc_stats(self, req, dp, ofctl, **kwargs): return ofctl.get_desc_stats(dp, self.waiters) + @stats_method + def get_flow_desc(self, req, dp, ofctl, **kwargs): + flow = req.json if req.body else {} + return ofctl.get_flow_desc(dp, self.waiters, flow) + @stats_method def get_flow_stats(self, req, dp, ofctl, **kwargs): flow = req.json if req.body else {} @@ -355,6 +375,13 @@ class StatsController(ControllerBase): return ofctl.get_meter_config(dp, self.waiters, meter_id) + @stats_method + def get_meter_desc(self, req, dp, ofctl, meter_id=None, **kwargs): + if meter_id == "ALL": + meter_id = None + + return ofctl.get_meter_desc(dp, self.waiters, meter_id) + @stats_method def get_meter_stats(self, req, dp, ofctl, meter_id=None, **kwargs): if meter_id == "ALL": @@ -367,8 +394,11 @@ class StatsController(ControllerBase): return ofctl.get_group_features(dp, self.waiters) @stats_method - def get_group_desc(self, req, dp, ofctl, **kwargs): - return ofctl.get_group_desc(dp, self.waiters) + def get_group_desc(self, req, dp, ofctl, group_id=None, **kwargs): + if dp.ofproto.OFP_VERSION < ofproto_v1_5.OFP_VERSION: + return ofctl.get_group_desc(dp, self.waiters) + else: + return ofctl.get_group_desc(dp, self.waiters, group_id) @stats_method def get_group_stats(self, req, dp, ofctl, group_id=None, **kwargs): @@ -378,8 +408,11 @@ class StatsController(ControllerBase): return ofctl.get_group_stats(dp, self.waiters, group_id) @stats_method - def get_port_desc(self, req, dp, ofctl, **kwargs): - return ofctl.get_port_desc(dp, self.waiters) + def get_port_desc(self, req, dp, ofctl, port_no=None, **kwargs): + if dp.ofproto.OFP_VERSION < ofproto_v1_5.OFP_VERSION: + return ofctl.get_port_desc(dp, self.waiters) + else: + return ofctl.get_port_desc(dp, self.waiters, port_no) @command_method def mod_flow_entry(self, req, dp, ofctl, flow, cmd, **kwargs): @@ -460,7 +493,8 @@ class RestStatsApi(app_manager.RyuApp): OFP_VERSIONS = [ofproto_v1_0.OFP_VERSION, ofproto_v1_2.OFP_VERSION, ofproto_v1_3.OFP_VERSION, - ofproto_v1_4.OFP_VERSION] + ofproto_v1_4.OFP_VERSION, + ofproto_v1_5.OFP_VERSION] _CONTEXTS = { 'dpset': dpset.DPSet, 'wsgi': WSGIApplication @@ -488,6 +522,11 @@ class RestStatsApi(app_manager.RyuApp): controller=StatsController, action='get_desc_stats', conditions=dict(method=['GET'])) + uri = path + '/flowdesc/{dpid}' + mapper.connect('stats', uri, + controller=StatsController, action='get_flow_stats', + conditions=dict(method=['GET', 'POST'])) + uri = path + '/flow/{dpid}' mapper.connect('stats', uri, controller=StatsController, action='get_flow_stats', @@ -574,6 +613,16 @@ class RestStatsApi(app_manager.RyuApp): controller=StatsController, action='get_meter_config', conditions=dict(method=['GET'])) + uri = path + '/meterdesc/{dpid}' + mapper.connect('stats', uri, + controller=StatsController, action='get_meter_desc', + conditions=dict(method=['GET'])) + + uri = path + '/meterdesc/{dpid}/{meter_id}' + mapper.connect('stats', uri, + controller=StatsController, action='get_meter_desc', + conditions=dict(method=['GET'])) + uri = path + '/meter/{dpid}' mapper.connect('stats', uri, controller=StatsController, action='get_meter_stats', @@ -594,6 +643,11 @@ class RestStatsApi(app_manager.RyuApp): controller=StatsController, action='get_group_desc', conditions=dict(method=['GET'])) + uri = path + '/groupdesc/{dpid}/{group_id}' + mapper.connect('stats', uri, + controller=StatsController, action='get_group_desc', + conditions=dict(method=['GET'])) + uri = path + '/group/{dpid}' mapper.connect('stats', uri, controller=StatsController, action='get_group_stats', @@ -609,6 +663,11 @@ class RestStatsApi(app_manager.RyuApp): controller=StatsController, action='get_port_desc', conditions=dict(method=['GET'])) + uri = path + '/portdesc/{dpid}/{port_no}' + mapper.connect('stats', uri, + controller=StatsController, action='get_port_desc', + conditions=dict(method=['GET'])) + uri = path + '/flowentry/{cmd}' mapper.connect('stats', uri, controller=StatsController, action='mod_flow_entry', -- cgit v1.2.3