Neutron metering does not check overlap ip range

Neutron does not return "MeteringLabelRuleOverlaps" error, when the
remote ip ranges in the meter label rules are overlapped.

Change-Id: I4c2536a7d38b5f6d311db365c8c108d5367705a7
Closes-bug: #1361264
This commit is contained in:
Liping Mao 2014-08-25 23:30:21 +08:00
parent b062a9db28
commit b0b7b66495
3 changed files with 25 additions and 2 deletions

View File

@ -150,7 +150,7 @@ class MeteringDbMixin(metering.MeteringPluginBase,
direction, excluded):
r_ips = self.get_metering_label_rules(context,
filters={'metering_label_id':
label_id,
[label_id],
'direction':
[direction],
'excluded':

View File

@ -41,7 +41,7 @@ class MeteringLabelRuleNotFound(qexception.NotFound):
message = _("Metering label rule %(rule_id)s does not exist")
class MeteringLabelRuleOverlaps(qexception.NotFound):
class MeteringLabelRuleOverlaps(qexception.Conflict):
message = _("Metering label rule with remote_ip_prefix "
"%(remote_ip_prefix)s overlaps another")

View File

@ -269,6 +269,29 @@ class TestMetering(MeteringPluginDbTestCase):
self._test_list_resources('metering-label-rule',
metering_label_rule)
def test_create_overlap_metering_label_rules(self):
name = 'my label'
description = 'my metering label'
with self.metering_label(name, description) as metering_label:
metering_label_id = metering_label['metering_label']['id']
direction = 'egress'
remote_ip_prefix1 = '192.168.0.0/24'
remote_ip_prefix2 = '192.168.0.0/16'
excluded = True
with self.metering_label_rule(metering_label_id,
direction,
remote_ip_prefix1,
excluded):
res = self._create_metering_label_rule(self.fmt,
metering_label_id,
direction,
remote_ip_prefix2,
excluded)
self.assertEqual(webob.exc.HTTPConflict.code, res.status_int)
def test_create_metering_label_rule_two_labels(self):
name1 = 'my label 1'
name2 = 'my label 2'