]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
NSX: allow net-migration only in combined mode
authorarmando-migliaccio <armamig@gmail.com>
Tue, 29 Apr 2014 01:27:04 +0000 (18:27 -0700)
committerThomas Goirand <thomas@goirand.fr>
Mon, 9 Jun 2014 15:06:55 +0000 (23:06 +0800)
To allow migration of networks from the agent based model
to the agentless one, both modes need to be available; prior
to this change the extension was available in 'agentless' mode
too; this may lead to leftovers during the migration step.
This patch makes the extension available in 'combined' mode
only, which was the intended behavior.

Change-Id: I491ee3eaf25fc30c0ab4092ee198802a6b06d91d
Closes-bug: #1313985
(cherry picked from commit e737076c374d0743927782b6318132ecf226f05a)

neutron/plugins/vmware/dhcpmeta_modes.py
neutron/tests/unit/vmware/etc/nsx.ini.combined.test [new file with mode: 0644]
neutron/tests/unit/vmware/test_nsx_opts.py

index d8236ec1b3bf084d18b82768b556e8f4c02ee06d..85811b66852e9eadda1c15d38524362216c437b5 100644 (file)
@@ -102,10 +102,10 @@ class DhcpMetadataAccess(object):
             cfg.CONF.set_override('network_auto_schedule', False)
             LOG.warn(_('network_auto_schedule has been disabled'))
             notifier = combined.DhcpAgentNotifyAPI(self, lsn_manager)
-        self.supported_extension_aliases.append(lsn.EXT_ALIAS)
-        # Add the capability to migrate dhcp and metadata services over
-        self.migration_manager = (
-            migration.MigrationManager(self, lsn_manager, notifier))
+            self.supported_extension_aliases.append(lsn.EXT_ALIAS)
+            # Add the capability to migrate dhcp and metadata services over
+            self.migration_manager = (
+                migration.MigrationManager(self, lsn_manager, notifier))
         return notifier
 
     def _init_extensions(self):
diff --git a/neutron/tests/unit/vmware/etc/nsx.ini.combined.test b/neutron/tests/unit/vmware/etc/nsx.ini.combined.test
new file mode 100644 (file)
index 0000000..2a6f830
--- /dev/null
@@ -0,0 +1,17 @@
+[DEFAULT]
+default_tz_uuid = fake_tz_uuid
+nova_zone_id = whatever
+nsx_controllers = fake_1, fake_2
+nsx_user = foo
+nsx_password = bar
+default_l3_gw_service_uuid = whatever
+default_l2_gw_service_uuid = whatever
+default_service_cluster_uuid = whatever
+default_interface_name = whatever
+req_timeout = 14
+http_timeout = 13
+redirects = 12
+retries = 11
+
+[NSX]
+agent_mode = combined
index 99b6366a9ee433d89930f46e6aace3d07f3d228f..5aa8c7f23b678aa3a59baed07e52ed7a809faf2e 100644 (file)
@@ -36,6 +36,7 @@ BASE_CONF_PATH = get_fake_conf('neutron.conf.test')
 NSX_INI_PATH = get_fake_conf('nsx.ini.basic.test')
 NSX_INI_FULL_PATH = get_fake_conf('nsx.ini.full.test')
 NSX_INI_AGENTLESS_PATH = get_fake_conf('nsx.ini.agentless.test')
+NSX_INI_COMBINED_PATH = get_fake_conf('nsx.ini.combined.test')
 NVP_INI_DEPR_PATH = get_fake_conf('nvp.ini.full.test')
 
 
@@ -161,6 +162,8 @@ class ConfigurationTest(base.BaseTestCase):
                                  plugin.supported_extension_aliases)
                 self.assertNotIn('dhcp_agent_scheduler',
                                  plugin.supported_extension_aliases)
+                self.assertNotIn('lsn',
+                                 plugin.supported_extension_aliases)
 
     def test_agentless_extensions_version_fail(self):
         q_config.parse(['--config-file', BASE_CONF_PATH,
@@ -200,6 +203,26 @@ class ConfigurationTest(base.BaseTestCase):
         self.assertIn('dhcp_agent_scheduler',
                       plugin.supported_extension_aliases)
 
+    def test_combined_extensions(self):
+        q_config.parse(['--config-file', BASE_CONF_PATH,
+                        '--config-file', NSX_INI_COMBINED_PATH])
+        cfg.CONF.set_override('core_plugin', PLUGIN_NAME)
+        self.assertEqual(config.AgentModes.COMBINED,
+                         cfg.CONF.NSX.agent_mode)
+        with mock.patch.object(client.NsxApiClient,
+                               'get_version',
+                               return_value=version.Version("4.2")):
+            with mock.patch.object(lsnlib,
+                                   'service_cluster_exists',
+                                   return_value=True):
+                plugin = NeutronManager().get_plugin()
+                self.assertIn('agent',
+                              plugin.supported_extension_aliases)
+                self.assertIn('dhcp_agent_scheduler',
+                              plugin.supported_extension_aliases)
+                self.assertIn('lsn',
+                              plugin.supported_extension_aliases)
+
 
 class OldNVPConfigurationTest(base.BaseTestCase):