]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
BigSwitch plugin: allow 'external' keyword in router rules
authorKevin Benton <kevin.benton@bigswitch.com>
Tue, 17 Sep 2013 20:43:02 +0000 (13:43 -0700)
committerKevin Benton <kevin.benton@bigswitch.com>
Tue, 17 Sep 2013 20:44:45 +0000 (13:44 -0700)
Allows 'external' keyword in addition to 'any' keyword
in BigSwitch router rules support.

Closes-Bug: #1226814
Change-Id: Ia92513e89b0c95c5b3b98921e126fdd21cc4f405

neutron/plugins/bigswitch/extensions/routerrule.py
neutron/tests/unit/bigswitch/test_router_db.py

index 5f682de2ffb3de20b48948849981fc44cf5f1001..2563d113d56ae1ccbbe2a6a7c2b016c4112a26c6 100644 (file)
@@ -40,12 +40,13 @@ def convert_to_valid_router_rules(data):
     Validates and converts router rules to the appropriate data structure
     Example argument = [{'source': 'any', 'destination': 'any',
                          'action':'deny'},
-                        {'source': '1.1.1.1/32', 'destination': 'any',
+                        {'source': '1.1.1.1/32', 'destination': 'external',
                          'action':'permit',
                          'nexthops': ['1.1.1.254', '1.1.1.253']}
                        ]
     """
     V4ANY = '0.0.0.0/0'
+    CIDRALL = ['any', 'external']
     if not isinstance(data, list):
         emsg = _("Invalid data format for router rule: '%s'") % data
         LOG.debug(emsg)
@@ -58,8 +59,8 @@ def convert_to_valid_router_rules(data):
         if not isinstance(rule['nexthops'], list):
             rule['nexthops'] = rule['nexthops'].split('+')
 
-        src = V4ANY if rule['source'] == 'any' else rule['source']
-        dst = V4ANY if rule['destination'] == 'any' else rule['destination']
+        src = V4ANY if rule['source'] in CIDRALL else rule['source']
+        dst = V4ANY if rule['destination'] in CIDRALL else rule['destination']
 
         errors = [attr._verify_dict_keys(expected_keys, rule, False),
                   attr._validate_subnet(dst),
index f5275ed2d58d7f269907cf1f55ce15db0bd84b27..ae655bafa651110da42c11bc385033711eea7f2d 100644 (file)
@@ -327,7 +327,7 @@ class RouterDBTestCase(test_l3_plugin.L3NatDBIntTestCase):
             rules = body['router']['router_rules']
             self.assertEqual(_strip_rule_ids(rules), router_rules)
             # Try after adding another rule
-            router_rules.append({'source': 'any',
+            router_rules.append({'source': 'external',
                                  'destination': '8.8.8.8/32',
                                  'action': 'permit', 'nexthops': []})
             body = self._update('routers', r['router']['id'],