]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
NSX: Make replication mode configurable
authorAaron Rosen <aaronorosen@gmail.com>
Wed, 26 Feb 2014 21:59:03 +0000 (13:59 -0800)
committerAaron Rosen <aaronorosen@gmail.com>
Mon, 10 Mar 2014 23:34:39 +0000 (16:34 -0700)
The replication mode on switches and routers should have been configurable
to use source replication if one did not want to deploy service node(s).
This patch fixes that by making this option configurable.

Change-Id: Id9e8043c602b5e9349c10247eab993e59db5a52c
Closes-bug: #1285383

etc/neutron/plugins/nicira/nvp.ini
etc/neutron/plugins/vmware/nsx.ini
neutron/plugins/vmware/common/config.py
neutron/plugins/vmware/nsxlib/router.py
neutron/plugins/vmware/nsxlib/switch.py
neutron/plugins/vmware/plugins/base.py
neutron/tests/unit/vmware/nsxlib/test_router.py
neutron/tests/unit/vmware/test_nsx_opts.py

index b22448ec440163965f7d9bff74d31ce4b48e7058..f6e928d36b07154d6335ad27815c933f0f3b13f7 100644 (file)
 # ignored, as new networks will no longer be scheduled to existing dhcp agents.
 # agent_mode = agent
 
+# Specifies which mode packet replication should be done in. If set to service
+# a service node is required in order to perform packet replication. This can
+# also be set to source if one wants replication to be performed locally (NOTE:
+# usually only useful for testing if one does not want to deploy a service node).
+# replication_mode = service
+
 [nsx_sync]
 # Interval in seconds between runs of the status synchronization task.
 # The plugin will aim at resynchronizing operational status for all
index e6add1997195f1d423a4c065ab902d7895147362..e270df57d6cdce6d10cd7245fe98486777954d7f 100644 (file)
 # ignored, as new networks will no longer be scheduled to existing dhcp agents.
 # agent_mode = agent
 
+# Specifies which mode packet replication should be done in. If set to service
+# a service node is required in order to perform packet replication. This can
+# also be set to source if one wants replication to be performed locally (NOTE:
+# usually only useful for testing if one does not want to deploy a service node).
+# replication_mode = service
+
 [nsx_sync]
 # Interval in seconds between runs of the status synchronization task.
 # The plugin will aim at resynchronizing operational status for all
index 8b135da8bce5c4eb1d02abf7490713a3e09f7249..848d6bded78caeb04f424a14869d70f8050d2c2e 100644 (file)
@@ -16,6 +16,8 @@
 
 from oslo.config import cfg
 
+from neutron.plugins.vmware.common import exceptions as nsx_exc
+
 
 class AgentModes:
     AGENT = 'agent'
@@ -28,6 +30,11 @@ class MetadataModes:
     INDIRECT = 'dhcp_host_route'
 
 
+class ReplicationModes:
+    SERVICE = 'service'
+    SOURCE = 'source'
+
+
 base_opts = [
     cfg.IntOpt('max_lp_per_bridged_ls', default=5000,
                deprecated_group='NVP',
@@ -61,7 +68,12 @@ base_opts = [
                       "bridge, ipsec_gre, or ipsec_stt)")),
     cfg.StrOpt('agent_mode', default=AgentModes.AGENT,
                deprecated_group='NVP',
-               help=_("The mode used to implement DHCP/metadata services."))
+               help=_("The mode used to implement DHCP/metadata services.")),
+    cfg.StrOpt('replication_mode', default=ReplicationModes.SERVICE,
+               help=_("The default option leverages service nodes to perform"
+                      " packet replication though one could set to this to "
+                      "'source' to perform replication locally. This is useful"
+                      " if one does not want to deploy a service node(s)."))
 ]
 
 sync_opts = [
@@ -176,3 +188,11 @@ cfg.CONF.register_opts(cluster_opts)
 cfg.CONF.register_opts(vcns_opts, group="vcns")
 cfg.CONF.register_opts(base_opts, group="NSX")
 cfg.CONF.register_opts(sync_opts, group="NSX_SYNC")
+
+
+def validate_config_options():
+    if cfg.CONF.NSX.replication_mode not in (ReplicationModes.SERVICE,
+                                             ReplicationModes.SOURCE):
+        error = (_("Invalid replication_mode: %s") %
+                 cfg.CONF.NSX.replication_mode)
+        raise nsx_exc.NsxPluginException(err_msg=error)
index 75c432911d74f42edb02b91a137347c32e3813c9..35e61da2bed4d71f0bc41222f0b00dda432613ab 100644 (file)
@@ -13,6 +13,8 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+from oslo.config import cfg
+
 from neutron.common import exceptions as exception
 from neutron.openstack.common import excutils
 from neutron.openstack.common import jsonutils
@@ -54,7 +56,8 @@ def _prepare_lrouter_body(name, neutron_router_id, tenant_id,
         "routing_config": {
             "type": router_type
         },
-        "type": "LogicalRouterConfig"
+        "type": "LogicalRouterConfig",
+        "replication_mode": cfg.CONF.NSX.replication_mode,
     }
     # add the distributed key only if not None (ie: True or False)
     if distributed is not None:
index a451add2a551d359d0b5498e59aaecffd2c3b04d..5df050ca438a34001b28972d0456f7b18973f653 100644 (file)
@@ -16,6 +16,8 @@
 
 import json
 
+from oslo.config import cfg
+
 from neutron.common import constants
 from neutron.common import exceptions as exception
 from neutron.openstack.common import log
@@ -115,6 +117,7 @@ def create_lswitch(cluster, neutron_net_id, tenant_id, display_name,
     # historical reasons
     lswitch_obj = {"display_name": utils.check_and_truncate(display_name),
                    "transport_zones": transport_zones_config,
+                   "replication_mode": cfg.CONF.NSX.replication_mode,
                    "tags": utils.get_tags(os_tid=tenant_id,
                                           quantum_net_id=neutron_net_id)}
     # TODO(salv-orlando): Now that we have async status synchronization
index e378d21c76d3c594ceba94b2bf33f158b323b723..15f442bd4163da399a14750cc95c2866eb8a4282 100644 (file)
@@ -123,6 +123,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
 
     def __init__(self):
         super(NsxPluginV2, self).__init__()
+        config.validate_config_options()
         # TODO(salv-orlando): Replace These dicts with
         # collections.defaultdict for better handling of default values
         # Routines for managing logical ports in NSX
index c2384400ceff8859aa57f7dee288d7c8c4b90c69..8250efd52bc5d1b670a4f547dad2546587189b5a 100644 (file)
@@ -16,6 +16,8 @@
 
 import mock
 
+from oslo.config import cfg
+
 from neutron.common import exceptions
 from neutron.openstack.common import uuidutils
 from neutron.plugins.vmware.api_client import exception as api_exc
@@ -115,7 +117,8 @@ class TestExplicitLRouters(base.NsxlibTestCase):
                         'type': 'SingleDefaultRouteImplicitRoutingConfig'},
                     'tags': utils.get_tags(os_tid='fake_tenant_id',
                                            q_router_id='pipita_higuain'),
-                    'type': 'LogicalRouterConfig'}
+                    'type': 'LogicalRouterConfig',
+                    'replication_mode': cfg.CONF.NSX.replication_mode}
         self.assertEqual(expected, body)
 
     def test_prepare_body_without_routing_config(self):
@@ -129,7 +132,8 @@ class TestExplicitLRouters(base.NsxlibTestCase):
                     'routing_config': {'type': 'RoutingTableRoutingConfig'},
                     'tags': utils.get_tags(os_tid='fake_tenant_id',
                                            q_router_id='marekiaro_hamsik'),
-                    'type': 'LogicalRouterConfig'}
+                    'type': 'LogicalRouterConfig',
+                    'replication_mode': cfg.CONF.NSX.replication_mode}
         self.assertEqual(expected, body)
 
     def test_get_lrouter(self):
index 69d88ca3bb051e277c32fb8e0dca746b9efe1118..99b6366a9ee433d89930f46e6aace3d07f3d228f 100644 (file)
@@ -121,6 +121,7 @@ class ConfigurationTest(base.BaseTestCase):
         self.assertEqual(10, cfg.CONF.NSX.concurrent_connections)
         self.assertEqual('access_network', cfg.CONF.NSX.metadata_mode)
         self.assertEqual('stt', cfg.CONF.NSX.default_transport_type)
+        self.assertEqual('service', cfg.CONF.NSX.replication_mode)
 
         self.assertIsNone(cfg.CONF.default_tz_uuid)
         self.assertEqual('admin', cfg.CONF.nsx_user)