From 52ed0153396d88b22ed0dcd1f0a76e7d2751e799 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Wed, 22 Jan 2014 04:55:46 -0800 Subject: [PATCH] Rename nvp_cluster for VMware NSX plugin Rename the module into nsx_cluster and the class into NSXCluster, and update references accordingly. Also, rename utility method create_nvp_cluster to create_nsx_cluster and move it into nsx_utils. Partial-implements blueprint: nicira-plugin-renaming Change-Id: I1a943cc64730ea67f464c3804370dad46411f8a2 --- neutron/plugins/nicira/NeutronPlugin.py | 28 +++---------------- neutron/plugins/nicira/check_nsx_config.py | 4 +-- neutron/plugins/nicira/common/nsx_utils.py | 21 ++++++++++++++ .../nicira/{nvp_cluster.py => nsx_cluster.py} | 7 ++--- neutron/tests/unit/nicira/test_nvp_sync.py | 4 +-- neutron/tests/unit/nicira/test_nvplib.py | 6 ++-- neutron/tests/unit/nicira/test_nvpopts.py | 8 +++--- 7 files changed, 39 insertions(+), 39 deletions(-) rename neutron/plugins/nicira/{nvp_cluster.py => nsx_cluster.py} (97%) diff --git a/neutron/plugins/nicira/NeutronPlugin.py b/neutron/plugins/nicira/NeutronPlugin.py index cd459d289..26edc9b8c 100644 --- a/neutron/plugins/nicira/NeutronPlugin.py +++ b/neutron/plugins/nicira/NeutronPlugin.py @@ -75,7 +75,6 @@ from neutron.plugins.nicira import dhcpmeta_modes from neutron.plugins.nicira.extensions import maclearning as mac_ext from neutron.plugins.nicira.extensions import nvp_networkgw as networkgw from neutron.plugins.nicira.extensions import nvp_qos as ext_qos -from neutron.plugins.nicira import nvp_cluster from neutron.plugins.nicira import NvpApiClient from neutron.plugins.nicira import nvplib @@ -100,26 +99,6 @@ class NetworkTypes: BRIDGE = 'bridge' -def create_nvp_cluster(cluster_opts, concurrent_connections, - nsx_gen_timeout): - cluster = nvp_cluster.NVPCluster(**cluster_opts) - - def _ctrl_split(x, y): - return (x, int(y), True) - - api_providers = [_ctrl_split(*ctrl.split(':')) - for ctrl in cluster.nsx_controllers] - cluster.api_client = NvpApiClient.NVPApiHelper( - api_providers, cluster.nsx_user, cluster.nsx_password, - request_timeout=cluster.req_timeout, - http_timeout=cluster.http_timeout, - retries=cluster.retries, - redirects=cluster.redirects, - concurrent_connections=concurrent_connections, - nvp_gen_timeout=nsx_gen_timeout) - return cluster - - class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin, agentschedulers_db.DhcpAgentSchedulerDbMixin, db_base_plugin_v2.NeutronDbPluginV2, @@ -195,9 +174,10 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin, neutron_extensions.append_api_extensions_path([NVP_EXT_PATH]) self.nvp_opts = cfg.CONF.NSX self.nvp_sync_opts = cfg.CONF.NSX_SYNC - self.cluster = create_nvp_cluster(cfg.CONF, - self.nvp_opts.concurrent_connections, - self.nvp_opts.nsx_gen_timeout) + self.cluster = nsx_utils.create_nsx_cluster( + cfg.CONF, + self.nvp_opts.concurrent_connections, + self.nvp_opts.nsx_gen_timeout) self.base_binding_dict = { pbin.VIF_TYPE: pbin.VIF_TYPE_OVS, diff --git a/neutron/plugins/nicira/check_nsx_config.py b/neutron/plugins/nicira/check_nsx_config.py index 9da30a9fa..ce5e3a906 100644 --- a/neutron/plugins/nicira/check_nsx_config.py +++ b/neutron/plugins/nicira/check_nsx_config.py @@ -23,7 +23,7 @@ from oslo.config import cfg from neutron.common import config from neutron.plugins.nicira.common import config as nsx_config # noqa -from neutron.plugins.nicira import NeutronPlugin +from neutron.plugins.nicira.common import nsx_utils from neutron.plugins.nicira import nvplib config.setup_logging(cfg.CONF) @@ -106,7 +106,7 @@ def main(): print("\tretries: %s" % cfg.CONF.retries) print("\tredirects: %s" % cfg.CONF.redirects) print("\thttp_timeout: %s" % cfg.CONF.http_timeout) - cluster = NeutronPlugin.create_nvp_cluster( + cluster = nsx_utils.create_nsx_cluster( cfg.CONF, cfg.CONF.NSX.concurrent_connections, cfg.CONF.NSX.nsx_gen_timeout) diff --git a/neutron/plugins/nicira/common/nsx_utils.py b/neutron/plugins/nicira/common/nsx_utils.py index adf719768..466dd6366 100644 --- a/neutron/plugins/nicira/common/nsx_utils.py +++ b/neutron/plugins/nicira/common/nsx_utils.py @@ -17,6 +17,8 @@ from neutron.openstack.common import log from neutron.plugins.nicira.dbexts import nicira_db +from neutron.plugins.nicira import nsx_cluster +from neutron.plugins.nicira import NvpApiClient from neutron.plugins.nicira import nvplib @@ -73,3 +75,22 @@ def get_nsx_switch_and_port_id(session, cluster, neutron_port_id): session, neutron_port_id, nvp_switch_id, nvp_port_id) return nvp_switch_id, nvp_port_id + + +def create_nsx_cluster(cluster_opts, concurrent_connections, nsx_gen_timeout): + cluster = nsx_cluster.NSXCluster(**cluster_opts) + + def _ctrl_split(x, y): + return (x, int(y), True) + + api_providers = [_ctrl_split(*ctrl.split(':')) + for ctrl in cluster.nsx_controllers] + cluster.api_client = NvpApiClient.NVPApiHelper( + api_providers, cluster.nsx_user, cluster.nsx_password, + request_timeout=cluster.req_timeout, + http_timeout=cluster.http_timeout, + retries=cluster.retries, + redirects=cluster.redirects, + concurrent_connections=concurrent_connections, + nvp_gen_timeout=nsx_gen_timeout) + return cluster diff --git a/neutron/plugins/nicira/nvp_cluster.py b/neutron/plugins/nicira/nsx_cluster.py similarity index 97% rename from neutron/plugins/nicira/nvp_cluster.py rename to neutron/plugins/nicira/nsx_cluster.py index d3753bbdc..fe0b7def8 100644 --- a/neutron/plugins/nicira/nvp_cluster.py +++ b/neutron/plugins/nicira/nsx_cluster.py @@ -35,11 +35,10 @@ DEPRECATED_ATTRIBUTES = ['metadata_dhcp_host_route', 'nvp_user', 'nvp_password', 'nvp_controllers'] -class NVPCluster(object): - """NVP cluster class. +class NSXCluster(object): + """NSX cluster class. - Encapsulates controller connections and the API client for a NVP cluster. - Accessed within the NvpPluginV2 class. + Encapsulates controller connections and the API client for a NSX cluster. Controller-specific parameters, such as timeouts are stored in the elements of the controllers attribute, which are dicts. diff --git a/neutron/tests/unit/nicira/test_nvp_sync.py b/neutron/tests/unit/nicira/test_nvp_sync.py index 39a70b4c8..1d71a081a 100644 --- a/neutron/tests/unit/nicira/test_nvp_sync.py +++ b/neutron/tests/unit/nicira/test_nvp_sync.py @@ -29,7 +29,7 @@ from neutron import context from neutron.openstack.common import jsonutils as json from neutron.plugins.nicira.common import sync from neutron.plugins.nicira import NeutronPlugin -from neutron.plugins.nicira import nvp_cluster +from neutron.plugins.nicira import nsx_cluster from neutron.plugins.nicira import NvpApiClient from neutron.plugins.nicira import nvplib from neutron.tests import base @@ -274,7 +274,7 @@ class NvpSyncTestCase(base.BaseTestCase): return self.fc.fake_request(*args, **kwargs) self.mock_nvpapi.return_value.request.side_effect = _fake_request - self.fake_cluster = nvp_cluster.NVPCluster( + self.fake_cluster = nsx_cluster.NSXCluster( name='fake-cluster', nsx_controllers=['1.1.1.1:999'], default_tz_uuid=_uuid(), nsx_user='foo', nsx_password='bar') self.fake_cluster.api_client = NvpApiClient.NVPApiHelper( diff --git a/neutron/tests/unit/nicira/test_nvplib.py b/neutron/tests/unit/nicira/test_nvplib.py index 0121f2255..6488d08cf 100644 --- a/neutron/tests/unit/nicira/test_nvplib.py +++ b/neutron/tests/unit/nicira/test_nvplib.py @@ -25,7 +25,7 @@ from neutron.common import exceptions from neutron.plugins.nicira.common import config # noqa from neutron.plugins.nicira.common import exceptions as nvp_exc from neutron.plugins.nicira.common import utils -from neutron.plugins.nicira import nvp_cluster +from neutron.plugins.nicira import nsx_cluster from neutron.plugins.nicira import NvpApiClient from neutron.plugins.nicira import nvplib from neutron.tests import base @@ -55,7 +55,7 @@ class NvplibTestCase(base.BaseTestCase): return self.fc.fake_request(*args, **kwargs) instance.return_value.request.side_effect = _fake_request - self.fake_cluster = nvp_cluster.NVPCluster( + self.fake_cluster = nsx_cluster.NSXCluster( name='fake-cluster', nsx_controllers=['1.1.1.1:999'], default_tz_uuid=_uuid(), nsx_user='foo', nsx_password='bar') self.fake_cluster.api_client = NvpApiClient.NVPApiHelper( @@ -121,7 +121,7 @@ class NvplibNegativeTests(base.BaseTestCase): raise nvplib.NvpApiClient.NvpApiException instance.return_value.request.side_effect = _faulty_request - self.fake_cluster = nvp_cluster.NVPCluster( + self.fake_cluster = nsx_cluster.NSXCluster( name='fake-cluster', nsx_controllers=['1.1.1.1:999'], default_tz_uuid=_uuid(), nsx_user='foo', nsx_password='bar') self.fake_cluster.api_client = NvpApiClient.NVPApiHelper( diff --git a/neutron/tests/unit/nicira/test_nvpopts.py b/neutron/tests/unit/nicira/test_nvpopts.py index aa9c10835..1b4a5212d 100644 --- a/neutron/tests/unit/nicira/test_nvpopts.py +++ b/neutron/tests/unit/nicira/test_nvpopts.py @@ -26,8 +26,8 @@ from neutron.openstack.common import uuidutils from neutron.plugins.nicira.common import config # noqa from neutron.plugins.nicira.common import exceptions from neutron.plugins.nicira.common import sync +from neutron.plugins.nicira import nsx_cluster from neutron.plugins.nicira.nsxlib import lsn as lsnlib -from neutron.plugins.nicira import nvp_cluster from neutron.plugins.nicira import NvpApiClient as nvp_client from neutron.tests import base from neutron.tests.unit.nicira import get_fake_conf @@ -55,14 +55,14 @@ class NSXClusterTest(base.BaseTestCase): 'nsx_controllers': ['1.1.1.1:443']} def test_create_cluster(self): - cluster = nvp_cluster.NVPCluster(**self.cluster_opts) + cluster = nsx_cluster.NSXCluster(**self.cluster_opts) for (k, v) in self.cluster_opts.iteritems(): self.assertEqual(v, getattr(cluster, k)) def test_create_cluster_default_port(self): opts = self.cluster_opts.copy() opts['nsx_controllers'] = ['1.1.1.1'] - cluster = nvp_cluster.NVPCluster(**opts) + cluster = nsx_cluster.NSXCluster(**opts) for (k, v) in self.cluster_opts.iteritems(): self.assertEqual(v, getattr(cluster, k)) @@ -70,7 +70,7 @@ class NSXClusterTest(base.BaseTestCase): opts = self.cluster_opts.copy() opts.pop('default_tz_uuid') self.assertRaises(exceptions.NvpInvalidClusterConfiguration, - nvp_cluster.NVPCluster, **opts) + nsx_cluster.NSXCluster, **opts) class ConfigurationTest(base.BaseTestCase): -- 2.45.2