class QueueInvalidDscp(qexception.InvalidInput):
- message = _("Invalid value for dscp %(data)s must be integer.")
+ message = _("Invalid value for dscp %(data)s must be integer value"
+ "between 0 and 63.")
class QueueMinGreaterMax(qexception.InvalidInput):
raise qexception.InvalidInput(error_message=msg)
return val
+
+def convert_to_unsigned_int_or_none_max_63(val):
+ val = convert_to_unsigned_int_or_none(val)
+ if val > 63:
+ raise QueueInvalidDscp(data=val)
+ return val
+
# Attribute Map
RESOURCE_ATTRIBUTE_MAP = {
'qos_queues': {
'default': 'untrusted', 'is_visible': True},
'dscp': {'allow_post': True, 'allow_put': False,
'is_visible': True, 'default': '0',
- 'convert_to': convert_to_unsigned_int_or_none},
+ 'convert_to': convert_to_unsigned_int_or_none_max_63},
'tenant_id': {'allow_post': True, 'allow_put': False,
'required_by_policy': True,
'validate': {'type:string': None},
port = self.deserialize('json', res)
self.assertEqual(ext_qos.QUEUE not in port['port'], True)
+ def test_dscp_value_out_of_range(self):
+ body = {'qos_queue': {'tenant_id': 'admin', 'dscp': '64',
+ 'name': 'foo', 'min': 20, 'max': 20}}
+ res = self._create_qos_queue('json', body)
+ self.assertEqual(res.status_int, 400)
+
def test_non_admin_cannot_create_queue(self):
body = {'qos_queue': {'tenant_id': 'not_admin',
'name': 'foo', 'min': 20, 'max': 20}}