Merge "Neutron metering does not check overlap ip range"
This commit is contained in:
commit
1721b31b1c
@ -148,7 +148,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':
|
||||
|
@ -39,7 +39,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")
|
||||
|
||||
|
@ -267,6 +267,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'
|
||||
|
Loading…
Reference in New Issue
Block a user