Merge "BigSwitch plugin: allow 'external' keyword in router rules"
This commit is contained in:
commit
f797905d20
@ -40,12 +40,13 @@ def convert_to_valid_router_rules(data):
|
|||||||
Validates and converts router rules to the appropriate data structure
|
Validates and converts router rules to the appropriate data structure
|
||||||
Example argument = [{'source': 'any', 'destination': 'any',
|
Example argument = [{'source': 'any', 'destination': 'any',
|
||||||
'action':'deny'},
|
'action':'deny'},
|
||||||
{'source': '1.1.1.1/32', 'destination': 'any',
|
{'source': '1.1.1.1/32', 'destination': 'external',
|
||||||
'action':'permit',
|
'action':'permit',
|
||||||
'nexthops': ['1.1.1.254', '1.1.1.253']}
|
'nexthops': ['1.1.1.254', '1.1.1.253']}
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
V4ANY = '0.0.0.0/0'
|
V4ANY = '0.0.0.0/0'
|
||||||
|
CIDRALL = ['any', 'external']
|
||||||
if not isinstance(data, list):
|
if not isinstance(data, list):
|
||||||
emsg = _("Invalid data format for router rule: '%s'") % data
|
emsg = _("Invalid data format for router rule: '%s'") % data
|
||||||
LOG.debug(emsg)
|
LOG.debug(emsg)
|
||||||
@ -58,8 +59,8 @@ def convert_to_valid_router_rules(data):
|
|||||||
if not isinstance(rule['nexthops'], list):
|
if not isinstance(rule['nexthops'], list):
|
||||||
rule['nexthops'] = rule['nexthops'].split('+')
|
rule['nexthops'] = rule['nexthops'].split('+')
|
||||||
|
|
||||||
src = V4ANY if rule['source'] == 'any' else rule['source']
|
src = V4ANY if rule['source'] in CIDRALL else rule['source']
|
||||||
dst = V4ANY if rule['destination'] == 'any' else rule['destination']
|
dst = V4ANY if rule['destination'] in CIDRALL else rule['destination']
|
||||||
|
|
||||||
errors = [attr._verify_dict_keys(expected_keys, rule, False),
|
errors = [attr._verify_dict_keys(expected_keys, rule, False),
|
||||||
attr._validate_subnet(dst),
|
attr._validate_subnet(dst),
|
||||||
|
@ -327,7 +327,7 @@ class RouterDBTestCase(test_l3_plugin.L3NatDBIntTestCase):
|
|||||||
rules = body['router']['router_rules']
|
rules = body['router']['router_rules']
|
||||||
self.assertEqual(_strip_rule_ids(rules), router_rules)
|
self.assertEqual(_strip_rule_ids(rules), router_rules)
|
||||||
# Try after adding another rule
|
# Try after adding another rule
|
||||||
router_rules.append({'source': 'any',
|
router_rules.append({'source': 'external',
|
||||||
'destination': '8.8.8.8/32',
|
'destination': '8.8.8.8/32',
|
||||||
'action': 'permit', 'nexthops': []})
|
'action': 'permit', 'nexthops': []})
|
||||||
body = self._update('routers', r['router']['id'],
|
body = self._update('routers', r['router']['id'],
|
||||||
|
Loading…
Reference in New Issue
Block a user