Treat all negative quota values as -1
Currently if the quota_port, quota_network, quota_subnet values in the neutron.conf are set to a negative value not equal to -1, neutron reports the values as is to consumers like Nova. Nova treats -1 as the infinite quota indicator and doesn't expect neutron to return any other non-negative value. The fix allows the flexibility of having any negative number for the quota parameters in the neutron.conf file and allows the nova boot to succeed subsequently. The fix would report any negative value as -1 for port, subnet and network. Change-Id: Ib9a7136b0bfd01bdf04a5d0937854590029b1010 Closes-Bug: 1438738 Co-Authored-By: Salvatore Orlando <salv.orlando@gmail.com>
This commit is contained in:
parent
ef53ce40df
commit
2041ead12d
@ -156,9 +156,12 @@ class BaseResource(object):
|
||||
@property
|
||||
def default(self):
|
||||
"""Return the default value of the quota."""
|
||||
return getattr(cfg.CONF.QUOTAS,
|
||||
self.flag,
|
||||
cfg.CONF.QUOTAS.default_quota)
|
||||
# Any negative value will be interpreted as an infinite quota,
|
||||
# and stored as -1 for compatibility with current behaviour
|
||||
value = getattr(cfg.CONF.QUOTAS,
|
||||
self.flag,
|
||||
cfg.CONF.QUOTAS.default_quota)
|
||||
return max(value, -1)
|
||||
|
||||
|
||||
class CountableResource(BaseResource):
|
||||
|
@ -79,6 +79,16 @@ class QuotaExtensionTestCase(testlib_api.WebTestCase):
|
||||
attributes.RESOURCE_ATTRIBUTE_MAP = self.saved_attr_map
|
||||
super(QuotaExtensionTestCase, self).tearDown()
|
||||
|
||||
def _test_quota_default_values(self, expected_values):
|
||||
tenant_id = 'tenant_id1'
|
||||
env = {'neutron.context': context.Context('', tenant_id)}
|
||||
res = self.api.get(_get_path('quotas', id=tenant_id, fmt=self.fmt),
|
||||
extra_environ=env)
|
||||
quota = self.deserialize(res)
|
||||
for resource, expected_value in expected_values.items():
|
||||
self.assertEqual(expected_value,
|
||||
quota['quota'][resource])
|
||||
|
||||
|
||||
class QuotaExtensionDbTestCase(QuotaExtensionTestCase):
|
||||
fmt = 'json'
|
||||
@ -97,15 +107,24 @@ class QuotaExtensionDbTestCase(QuotaExtensionTestCase):
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
def test_quotas_default_values(self):
|
||||
tenant_id = 'tenant_id1'
|
||||
env = {'neutron.context': context.Context('', tenant_id)}
|
||||
res = self.api.get(_get_path('quotas', id=tenant_id, fmt=self.fmt),
|
||||
extra_environ=env)
|
||||
quota = self.deserialize(res)
|
||||
self.assertEqual(10, quota['quota']['network'])
|
||||
self.assertEqual(10, quota['quota']['subnet'])
|
||||
self.assertEqual(50, quota['quota']['port'])
|
||||
self.assertEqual(-1, quota['quota']['extra1'])
|
||||
self._test_quota_default_values(
|
||||
{'network': 10,
|
||||
'subnet': 10,
|
||||
'port': 50,
|
||||
'extra1': -1})
|
||||
|
||||
def test_quotas_negative_default_value(self):
|
||||
cfg.CONF.set_override(
|
||||
'quota_port', -666, group='QUOTAS')
|
||||
cfg.CONF.set_override(
|
||||
'quota_network', -10, group='QUOTAS')
|
||||
cfg.CONF.set_override(
|
||||
'quota_subnet', -50, group='QUOTAS')
|
||||
self._test_quota_default_values(
|
||||
{'network': -1,
|
||||
'subnet': -1,
|
||||
'port': -1,
|
||||
'extra1': -1})
|
||||
|
||||
def test_show_quotas_with_admin(self):
|
||||
tenant_id = 'tenant_id1'
|
||||
@ -337,15 +356,20 @@ class QuotaExtensionCfgTestCase(QuotaExtensionTestCase):
|
||||
super(QuotaExtensionCfgTestCase, self).setUp()
|
||||
|
||||
def test_quotas_default_values(self):
|
||||
tenant_id = 'tenant_id1'
|
||||
env = {'neutron.context': context.Context('', tenant_id)}
|
||||
res = self.api.get(_get_path('quotas', id=tenant_id, fmt=self.fmt),
|
||||
extra_environ=env)
|
||||
quota = self.deserialize(res)
|
||||
self.assertEqual(10, quota['quota']['network'])
|
||||
self.assertEqual(10, quota['quota']['subnet'])
|
||||
self.assertEqual(50, quota['quota']['port'])
|
||||
self.assertEqual(-1, quota['quota']['extra1'])
|
||||
self._test_quota_default_values(
|
||||
{'network': 10,
|
||||
'subnet': 10,
|
||||
'port': 50,
|
||||
'extra1': -1})
|
||||
|
||||
def test_quotas_negative_default_value(self):
|
||||
cfg.CONF.set_override(
|
||||
'quota_port', -666, group='QUOTAS')
|
||||
self._test_quota_default_values(
|
||||
{'network': 10,
|
||||
'subnet': 10,
|
||||
'port': -1,
|
||||
'extra1': -1})
|
||||
|
||||
def test_show_quotas_with_admin(self):
|
||||
tenant_id = 'tenant_id1'
|
||||
|
Loading…
Reference in New Issue
Block a user