rest_qos: Enable queue setting to interface individually
Added an option command to enable the queue setting to interface individually. Also, some minor fixes. Signed-off-by: Kiyonari Harigae <lakshmi@cloudysunny14.org> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
cfdce1f340
commit
b3d75d14ea
@ -64,7 +64,8 @@ from ryu.ofproto import inet
|
|||||||
# POST /qos/queue/{switch-id}
|
# POST /qos/queue/{switch-id}
|
||||||
#
|
#
|
||||||
# request body format:
|
# request body format:
|
||||||
# {"type": "<linux-htb or linux-other>",
|
# {"port_name":"<name of port>",
|
||||||
|
# "type": "<linux-htb or linux-other>",
|
||||||
# "max-rate": "<int>",
|
# "max-rate": "<int>",
|
||||||
# "queues":[{"max_rate": "<int>", "min_rate": "<int>"},...]}
|
# "queues":[{"max_rate": "<int>", "min_rate": "<int>"},...]}
|
||||||
#
|
#
|
||||||
@ -72,6 +73,9 @@ from ryu.ofproto import inet
|
|||||||
# previous configurations.
|
# previous configurations.
|
||||||
# Note: Queue configurations are available for
|
# Note: Queue configurations are available for
|
||||||
# OpenvSwitch.
|
# OpenvSwitch.
|
||||||
|
# Note: port_name is optional argument.
|
||||||
|
# If does not pass the port_name argument,
|
||||||
|
# all ports are target for configuration.
|
||||||
#
|
#
|
||||||
# delete queue
|
# delete queue
|
||||||
# DELETE /qos/queue/{swtich-id}
|
# DELETE /qos/queue/{swtich-id}
|
||||||
@ -121,7 +125,7 @@ from ryu.ofproto import inet
|
|||||||
# "nw_proto": "<TCP or UDP or ICMP or ICMPv6>"
|
# "nw_proto": "<TCP or UDP or ICMP or ICMPv6>"
|
||||||
# "tp_src" : "<int>"
|
# "tp_src" : "<int>"
|
||||||
# "tp_dst" : "<int>"
|
# "tp_dst" : "<int>"
|
||||||
# "dscp" : "<int>"
|
# "ip_dscp" : "<int>"
|
||||||
#
|
#
|
||||||
# * action field
|
# * action field
|
||||||
# "mark": <dscp-value>
|
# "mark": <dscp-value>
|
||||||
@ -182,6 +186,7 @@ REST_COMMAND_RESULT = 'command_result'
|
|||||||
REST_PRIORITY = 'priority'
|
REST_PRIORITY = 'priority'
|
||||||
REST_VLANID = 'vlan_id'
|
REST_VLANID = 'vlan_id'
|
||||||
REST_DL_VLAN = 'dl_vlan'
|
REST_DL_VLAN = 'dl_vlan'
|
||||||
|
REST_PORT_NAME = 'port_name'
|
||||||
REST_QUEUE_TYPE = 'type'
|
REST_QUEUE_TYPE = 'type'
|
||||||
REST_QUEUE_MAX_RATE = 'max_rate'
|
REST_QUEUE_MAX_RATE = 'max_rate'
|
||||||
REST_QUEUE_MIN_RATE = 'min_rate'
|
REST_QUEUE_MIN_RATE = 'min_rate'
|
||||||
@ -234,8 +239,8 @@ VLANID_MIN = 2
|
|||||||
VLANID_MAX = 4094
|
VLANID_MAX = 4094
|
||||||
COOKIE_SHIFT_VLANID = 32
|
COOKIE_SHIFT_VLANID = 32
|
||||||
|
|
||||||
base_url = '/qos'
|
BASE_URL = '/qos'
|
||||||
requirements = {'switchid': SWITCHID_PATTERN,
|
REQUIREMENTS = {'switchid': SWITCHID_PATTERN,
|
||||||
'vlanid': VLANID_PATTERN}
|
'vlanid': VLANID_PATTERN}
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -414,80 +419,80 @@ class QoSController(ControllerBase):
|
|||||||
ofs = QoSController._OFS_LIST.get(dpid, None)
|
ofs = QoSController._OFS_LIST.get(dpid, None)
|
||||||
ofs.set_ovsdb_addr(dpid, None)
|
ofs.set_ovsdb_addr(dpid, None)
|
||||||
|
|
||||||
@route('qos_switch', base_url + '/queue/{switchid}',
|
@route('qos_switch', BASE_URL + '/queue/{switchid}',
|
||||||
methods=['GET'], requirements=requirements)
|
methods=['GET'], requirements=REQUIREMENTS)
|
||||||
def get_queue(self, req, switchid, **_kwargs):
|
def get_queue(self, req, switchid, **_kwargs):
|
||||||
return self._access_switch(req, switchid, VLANID_NONE,
|
return self._access_switch(req, switchid, VLANID_NONE,
|
||||||
'get_queue', None)
|
'get_queue', None)
|
||||||
|
|
||||||
@route('qos_switch', base_url + '/queue/{switchid}',
|
@route('qos_switch', BASE_URL + '/queue/{switchid}',
|
||||||
methods=['POST'], requirements=requirements)
|
methods=['POST'], requirements=REQUIREMENTS)
|
||||||
def set_queue(self, req, switchid, **_kwargs):
|
def set_queue(self, req, switchid, **_kwargs):
|
||||||
return self._access_switch(req, switchid, VLANID_NONE,
|
return self._access_switch(req, switchid, VLANID_NONE,
|
||||||
'set_queue', None)
|
'set_queue', None)
|
||||||
|
|
||||||
@route('qos_switch', base_url + '/queue/{switchid}',
|
@route('qos_switch', BASE_URL + '/queue/{switchid}',
|
||||||
methods=['DELETE'], requirements=requirements)
|
methods=['DELETE'], requirements=REQUIREMENTS)
|
||||||
def delete_queue(self, req, switchid, **_kwargs):
|
def delete_queue(self, req, switchid, **_kwargs):
|
||||||
return self._access_switch(req, switchid, VLANID_NONE,
|
return self._access_switch(req, switchid, VLANID_NONE,
|
||||||
'delete_queue', None)
|
'delete_queue', None)
|
||||||
|
|
||||||
@route('qos_switch', base_url + '/queue/status/{switchid}',
|
@route('qos_switch', BASE_URL + '/queue/status/{switchid}',
|
||||||
methods=['GET'], requirements=requirements)
|
methods=['GET'], requirements=REQUIREMENTS)
|
||||||
def get_status(self, req, switchid, **_kwargs):
|
def get_status(self, req, switchid, **_kwargs):
|
||||||
return self._access_switch(req, switchid, VLANID_NONE,
|
return self._access_switch(req, switchid, VLANID_NONE,
|
||||||
'get_status', self.waiters)
|
'get_status', self.waiters)
|
||||||
|
|
||||||
@route('qos_switch', base_url + '/rules/{switchid}',
|
@route('qos_switch', BASE_URL + '/rules/{switchid}',
|
||||||
methods=['GET'], requirements=requirements)
|
methods=['GET'], requirements=REQUIREMENTS)
|
||||||
def get_qos(self, req, switchid, **_kwargs):
|
def get_qos(self, req, switchid, **_kwargs):
|
||||||
return self._access_switch(req, switchid, VLANID_NONE,
|
return self._access_switch(req, switchid, VLANID_NONE,
|
||||||
'get_qos', self.waiters)
|
'get_qos', self.waiters)
|
||||||
|
|
||||||
@route('qos_switch', base_url + '/rules/{switchid}/{vlanid}',
|
@route('qos_switch', BASE_URL + '/rules/{switchid}/{vlanid}',
|
||||||
methods=['GET'], requirements=requirements)
|
methods=['GET'], requirements=REQUIREMENTS)
|
||||||
def get_vlan_qos(self, req, switchid, vlanid, **_kwargs):
|
def get_vlan_qos(self, req, switchid, vlanid, **_kwargs):
|
||||||
return self._access_switch(req, switchid, vlanid,
|
return self._access_switch(req, switchid, vlanid,
|
||||||
'get_qos', self.waiters)
|
'get_qos', self.waiters)
|
||||||
|
|
||||||
@route('qos_switch', base_url + '/rules/{switchid}',
|
@route('qos_switch', BASE_URL + '/rules/{switchid}',
|
||||||
methods=['POST'], requirements=requirements)
|
methods=['POST'], requirements=REQUIREMENTS)
|
||||||
def set_qos(self, req, switchid, **_kwargs):
|
def set_qos(self, req, switchid, **_kwargs):
|
||||||
return self._access_switch(req, switchid, VLANID_NONE,
|
return self._access_switch(req, switchid, VLANID_NONE,
|
||||||
'set_qos', self.waiters)
|
'set_qos', self.waiters)
|
||||||
|
|
||||||
@route('qos_switch', base_url + '/rules/{switchid}/{vlanid}',
|
@route('qos_switch', BASE_URL + '/rules/{switchid}/{vlanid}',
|
||||||
methods=['POST'], requirements=requirements)
|
methods=['POST'], requirements=REQUIREMENTS)
|
||||||
def set_vlan_qos(self, req, switchid, vlanid, **_kwargs):
|
def set_vlan_qos(self, req, switchid, vlanid, **_kwargs):
|
||||||
return self._access_switch(req, switchid, vlanid,
|
return self._access_switch(req, switchid, vlanid,
|
||||||
'set_qos', self.waiters)
|
'set_qos', self.waiters)
|
||||||
|
|
||||||
@route('qos_switch', base_url + '/rules/{switchid}',
|
@route('qos_switch', BASE_URL + '/rules/{switchid}',
|
||||||
methods=['DELETE'], requirements=requirements)
|
methods=['DELETE'], requirements=REQUIREMENTS)
|
||||||
def delete_qos(self, req, switchid, **_kwargs):
|
def delete_qos(self, req, switchid, **_kwargs):
|
||||||
return self._access_switch(req, switchid, VLANID_NONE,
|
return self._access_switch(req, switchid, VLANID_NONE,
|
||||||
'delete_qos', self.waiters)
|
'delete_qos', self.waiters)
|
||||||
|
|
||||||
@route('qos_switch', base_url + '/rules/{switchid}/{vlanid}',
|
@route('qos_switch', BASE_URL + '/rules/{switchid}/{vlanid}',
|
||||||
methods=['DELETE'], requirements=requirements)
|
methods=['DELETE'], requirements=REQUIREMENTS)
|
||||||
def delete_vlan_qos(self, req, switchid, vlanid, **_kwargs):
|
def delete_vlan_qos(self, req, switchid, vlanid, **_kwargs):
|
||||||
return self._access_switch(req, switchid, vlanid,
|
return self._access_switch(req, switchid, vlanid,
|
||||||
'delete_qos', self.waiters)
|
'delete_qos', self.waiters)
|
||||||
|
|
||||||
@route('qos_switch', base_url + '/meter/{switchid}',
|
@route('qos_switch', BASE_URL + '/meter/{switchid}',
|
||||||
methods=['GET'], requirements=requirements)
|
methods=['GET'], requirements=REQUIREMENTS)
|
||||||
def get_meter(self, req, switchid, **_kwargs):
|
def get_meter(self, req, switchid, **_kwargs):
|
||||||
return self._access_switch(req, switchid, VLANID_NONE,
|
return self._access_switch(req, switchid, VLANID_NONE,
|
||||||
'get_meter', self.waiters)
|
'get_meter', self.waiters)
|
||||||
|
|
||||||
@route('qos_switch', base_url + '/meter/{switchid}',
|
@route('qos_switch', BASE_URL + '/meter/{switchid}',
|
||||||
methods=['POST'], requirements=requirements)
|
methods=['POST'], requirements=REQUIREMENTS)
|
||||||
def set_meter(self, req, switchid, **_kwargs):
|
def set_meter(self, req, switchid, **_kwargs):
|
||||||
return self._access_switch(req, switchid, VLANID_NONE,
|
return self._access_switch(req, switchid, VLANID_NONE,
|
||||||
'set_meter', self.waiters)
|
'set_meter', self.waiters)
|
||||||
|
|
||||||
@route('qos_switch', base_url + '/meter/{switchid}',
|
@route('qos_switch', BASE_URL + '/meter/{switchid}',
|
||||||
methods=['DELETE'], requirements=requirements)
|
methods=['DELETE'], requirements=REQUIREMENTS)
|
||||||
def delete_meter(self, req, switchid, **_kwargs):
|
def delete_meter(self, req, switchid, **_kwargs):
|
||||||
return self._access_switch(req, switchid, VLANID_NONE,
|
return self._access_switch(req, switchid, VLANID_NONE,
|
||||||
'delete_meter', self.waiters)
|
'delete_meter', self.waiters)
|
||||||
@ -673,10 +678,17 @@ class QoS(object):
|
|||||||
self.queue_list[queue_id] = {'config': config}
|
self.queue_list[queue_id] = {'config': config}
|
||||||
queue_id += 1
|
queue_id += 1
|
||||||
|
|
||||||
vif_ports = self.ovs_bridge.get_external_ports()
|
port_name = rest.get(REST_PORT_NAME, None)
|
||||||
for port in vif_ports:
|
vif_ports = self.ovs_bridge.get_port_name_list()
|
||||||
|
|
||||||
|
if port_name is not None:
|
||||||
|
if port_name not in vif_ports:
|
||||||
|
raise ValueError('%s port is not exists' % port_name)
|
||||||
|
vif_ports = [port_name]
|
||||||
|
|
||||||
|
for port_name in vif_ports:
|
||||||
try:
|
try:
|
||||||
self.ovs_bridge.set_qos(port.port_name, type=queue_type,
|
self.ovs_bridge.set_qos(port_name, type=queue_type,
|
||||||
max_rate=parent_max_rate,
|
max_rate=parent_max_rate,
|
||||||
queues=queue_config)
|
queues=queue_config)
|
||||||
except Exception, msg:
|
except Exception, msg:
|
||||||
@ -770,6 +782,8 @@ class QoS(object):
|
|||||||
if str(self.dp.id) in msgs:
|
if str(self.dp.id) in msgs:
|
||||||
flow_stats = msgs[str(self.dp.id)]
|
flow_stats = msgs[str(self.dp.id)]
|
||||||
for flow_stat in flow_stats:
|
for flow_stat in flow_stats:
|
||||||
|
if flow_stat['table_id'] != QOS_TABLE_ID:
|
||||||
|
continue
|
||||||
priority = flow_stat[REST_PRIORITY]
|
priority = flow_stat[REST_PRIORITY]
|
||||||
if priority != DEFAULT_FLOW_PRIORITY:
|
if priority != DEFAULT_FLOW_PRIORITY:
|
||||||
vid = flow_stat[REST_MATCH].get(REST_DL_VLAN, VLANID_NONE)
|
vid = flow_stat[REST_MATCH].get(REST_DL_VLAN, VLANID_NONE)
|
||||||
|
Loading…
Reference in New Issue
Block a user