From d06218acbe6f5a548a01d2fa9bb836fc74857ac0 Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Tue, 14 Jun 2016 05:41:03 -0700 Subject: [PATCH] Ensure that ListOpt configuration variables are set Ensure that the default value is []. If no default is set then the CFG module assigns the value None. There are some edge cases where a configuration setting has not been set and there is random failure. Ideally we should validate the configurations at boot. But that is another patch set. Change-Id: I402590f8f0dc86e485716fb2f0fa63262dda96c7 --- vmware_nsx/common/config.py | 5 +++++ vmware_nsx/tests/unit/nsx_mh/test_opts.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/vmware_nsx/common/config.py b/vmware_nsx/common/config.py index 6895369c64..6d906585eb 100644 --- a/vmware_nsx/common/config.py +++ b/vmware_nsx/common/config.py @@ -184,6 +184,7 @@ connection_opts = [ help=_('Maximum number of times a redirect response ' 'should be followed')), cfg.ListOpt('nsx_controllers', + default=[], deprecated_name='nvp_controllers', help=_('Comma-separated list of NSX controller ' 'endpoints (:). When port is omitted, ' @@ -249,6 +250,7 @@ nsx_v3_opts = [ secret=True, help=_('Password for the NSX manager')), cfg.ListOpt('nsx_api_managers', + default=[], deprecated_name='nsx_manager', help=_("IP address of one or more NSX managers separated " "by commas. The IP address should be of the form:\n" @@ -446,6 +448,7 @@ nsxv_opts = [ help=_('(Optional) Portgroup MoRef ID for metadata proxy ' 'management network')), cfg.ListOpt('mgt_net_proxy_ips', + default=[], help=_('(Optional) Comma separated list of management network ' 'IP addresses for metadata proxy.')), cfg.StrOpt('mgt_net_proxy_netmask', @@ -455,6 +458,7 @@ nsxv_opts = [ help=_("(Optional) Management network default gateway for " "metadata proxy.")), cfg.ListOpt('nova_metadata_ips', + default=[], help=_("(Optional) IP addresses used by Nova metadata " "service.")), cfg.PortOpt('nova_metadata_port', @@ -510,6 +514,7 @@ nsxv_opts = [ help=_("If True, the server instance will attempt to " "initialize the metadata infrastructure")), cfg.ListOpt('metadata_service_allowed_ports', + default=[], help=_('List of tcp ports, to be allowed access to the ' 'metadata proxy, in addition to the default ' '80,443,8775 tcp ports')), diff --git a/vmware_nsx/tests/unit/nsx_mh/test_opts.py b/vmware_nsx/tests/unit/nsx_mh/test_opts.py index c30439e22b..4a284fb5f8 100644 --- a/vmware_nsx/tests/unit/nsx_mh/test_opts.py +++ b/vmware_nsx/tests/unit/nsx_mh/test_opts.py @@ -126,7 +126,7 @@ class ConfigurationTest(base.BaseTestCase): self.assertEqual(75, cfg.CONF.http_timeout) self.assertEqual(2, cfg.CONF.retries) self.assertEqual(2, cfg.CONF.redirects) - self.assertIsNone(cfg.CONF.nsx_controllers) + self.assertEqual([], cfg.CONF.nsx_controllers) self.assertIsNone(cfg.CONF.default_l3_gw_service_uuid) self.assertIsNone(cfg.CONF.default_l2_gw_service_uuid) self.assertEqual('breth0', cfg.CONF.nsx_default_interface_name)