mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-04 20:06:09 +02:00
ofctl_rest: Support port number and queue id in get_queue_stats()
This patch enables to specify the port number and the queue id to get the queue stats. Usage) $ curl -X GET http://localhost:8080/stats/queue/<dpid>[/<port>[/<queue_id>]] Note: Specification of port number and queue id are optional. If you want to omitting the port number and setting the queue id, please specify the keyword "ALL" to the port number. e.g. GET /stats/queue/1/ALL/1 Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
3e180d8504
commit
32f5c622b3
@ -79,7 +79,11 @@ supported_ofctl = {
|
||||
# Note: Specification of port number is optional
|
||||
#
|
||||
# get queues stats of the switch
|
||||
# GET /stats/queue/<dpid>
|
||||
# GET /stats/queue/<dpid>[/<port>[/<queue_id>]]
|
||||
# Note: Specification of port number and queue id are optional
|
||||
# If you want to omitting the port number and setting the queue id,
|
||||
# please specify the keyword "ALL" to the port number
|
||||
# e.g. GET /stats/queue/1/ALL/1
|
||||
#
|
||||
# get queues config stats of the switch
|
||||
# GET /stats/queueconfig/<dpid>/<port>
|
||||
@ -338,12 +342,26 @@ class StatsController(ControllerBase):
|
||||
body = json.dumps(ports)
|
||||
return Response(content_type='application/json', body=body)
|
||||
|
||||
def get_queue_stats(self, req, dpid, **_kwargs):
|
||||
def get_queue_stats(self, req, dpid, port=None, queue_id=None, **_kwargs):
|
||||
|
||||
if type(dpid) == str and not dpid.isdigit():
|
||||
LOG.debug('invalid dpid %s', dpid)
|
||||
return Response(status=400)
|
||||
|
||||
if port == "ALL":
|
||||
port = None
|
||||
|
||||
if type(port) == str and not port.isdigit():
|
||||
LOG.debug('invalid port %s', port)
|
||||
return Response(status=400)
|
||||
|
||||
if queue_id == "ALL":
|
||||
queue_id = None
|
||||
|
||||
if type(queue_id) == str and not queue_id.isdigit():
|
||||
LOG.debug('invalid queue_id %s', queue_id)
|
||||
return Response(status=400)
|
||||
|
||||
dp = self.dpset.get(int(dpid))
|
||||
|
||||
if dp is None:
|
||||
@ -353,7 +371,7 @@ class StatsController(ControllerBase):
|
||||
|
||||
_ofctl = supported_ofctl.get(_ofp_version, None)
|
||||
if _ofctl is not None:
|
||||
queues = _ofctl.get_queue_stats(dp, self.waiters)
|
||||
queues = _ofctl.get_queue_stats(dp, self.waiters, port, queue_id)
|
||||
|
||||
else:
|
||||
LOG.debug('Unsupported OF protocol')
|
||||
@ -914,6 +932,16 @@ class RestStatsApi(app_manager.RyuApp):
|
||||
controller=StatsController, action='get_queue_stats',
|
||||
conditions=dict(method=['GET']))
|
||||
|
||||
uri = path + '/queue/{dpid}/{port}'
|
||||
mapper.connect('stats', uri,
|
||||
controller=StatsController, action='get_queue_stats',
|
||||
conditions=dict(method=['GET']))
|
||||
|
||||
uri = path + '/queue/{dpid}/{port}/{queue_id}'
|
||||
mapper.connect('stats', uri,
|
||||
controller=StatsController, action='get_queue_stats',
|
||||
conditions=dict(method=['GET']))
|
||||
|
||||
uri = path + '/queueconfig/{dpid}/{port}'
|
||||
mapper.connect('stats', uri,
|
||||
controller=StatsController, action='get_queue_config',
|
||||
|
||||
@ -314,9 +314,19 @@ def get_desc_stats(dp, waiters):
|
||||
return desc
|
||||
|
||||
|
||||
def get_queue_stats(dp, waiters):
|
||||
stats = dp.ofproto_parser.OFPQueueStatsRequest(dp, 0, dp.ofproto.OFPP_ALL,
|
||||
dp.ofproto.OFPQ_ALL)
|
||||
def get_queue_stats(dp, waiters, port=None, queue_id=None):
|
||||
if port is None:
|
||||
port = dp.ofproto.OFPP_ALL
|
||||
else:
|
||||
port = int(str(port), 0)
|
||||
|
||||
if queue_id is None:
|
||||
queue_id = dp.ofproto.OFPQ_ALL
|
||||
else:
|
||||
queue_id = int(str(queue_id), 0)
|
||||
|
||||
stats = dp.ofproto_parser.OFPQueueStatsRequest(dp, 0, port,
|
||||
queue_id)
|
||||
msgs = []
|
||||
send_stats_request(dp, stats, waiters, msgs)
|
||||
|
||||
|
||||
@ -432,10 +432,21 @@ def get_desc_stats(dp, waiters):
|
||||
return desc
|
||||
|
||||
|
||||
def get_queue_stats(dp, waiters):
|
||||
def get_queue_stats(dp, waiters, port=None, queue_id=None):
|
||||
ofp = dp.ofproto
|
||||
stats = dp.ofproto_parser.OFPQueueStatsRequest(dp, ofp.OFPP_ANY,
|
||||
ofp.OFPQ_ALL, 0)
|
||||
|
||||
if port is None:
|
||||
port = ofp.OFPP_ANY
|
||||
else:
|
||||
port = int(str(port), 0)
|
||||
|
||||
if queue_id is None:
|
||||
queue_id = ofp.OFPQ_ALL
|
||||
else:
|
||||
queue_id = int(str(queue_id), 0)
|
||||
|
||||
stats = dp.ofproto_parser.OFPQueueStatsRequest(dp, port,
|
||||
queue_id, 0)
|
||||
msgs = []
|
||||
send_stats_request(dp, stats, waiters, msgs)
|
||||
|
||||
|
||||
@ -470,10 +470,21 @@ def get_desc_stats(dp, waiters):
|
||||
return desc
|
||||
|
||||
|
||||
def get_queue_stats(dp, waiters):
|
||||
def get_queue_stats(dp, waiters, port=None, queue_id=None):
|
||||
ofp = dp.ofproto
|
||||
stats = dp.ofproto_parser.OFPQueueStatsRequest(dp, 0, ofp.OFPP_ANY,
|
||||
ofp.OFPQ_ALL)
|
||||
|
||||
if port is None:
|
||||
port = ofp.OFPP_ANY
|
||||
else:
|
||||
port = int(str(port), 0)
|
||||
|
||||
if queue_id is None:
|
||||
queue_id = ofp.OFPQ_ALL
|
||||
else:
|
||||
queue_id = int(str(queue_id), 0)
|
||||
|
||||
stats = dp.ofproto_parser.OFPQueueStatsRequest(dp, 0, port,
|
||||
queue_id)
|
||||
msgs = []
|
||||
send_stats_request(dp, stats, waiters, msgs)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user