From c0891486ab65a0540f8ab2fda0fc26d855a24c9b Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sun, 20 Oct 2024 15:33:46 +0900 Subject: [PATCH] Fix inconsistent parameter type and default value type Make sure default value of list options are lists. Change-Id: I759cde796229bb7886160761233679ec886131d8 --- octavia/common/config.py | 6 +++--- octavia/compute/drivers/nova_driver.py | 2 +- octavia/tests/functional/api/v2/test_load_balancer.py | 4 ++-- octavia/tests/unit/common/test_validate.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/octavia/common/config.py b/octavia/common/config.py index a414b737ec..b26ffcdd63 100644 --- a/octavia/common/config.py +++ b/octavia/common/config.py @@ -462,12 +462,12 @@ controller_worker_opts = [ help=_('The timezone to use in the Amphora as represented in ' '/usr/share/zoneinfo.')), cfg.ListOpt('amp_boot_network_list', - default='', + default=[], help=_('List of networks to attach to the Amphorae. ' 'All networks defined in the list will ' 'be attached to each amphora.')), cfg.ListOpt('amp_secgroup_list', - default='', + default=[], help=_('List of security groups to attach to the Amphora.')), cfg.StrOpt('client_ca', default='/etc/octavia/certs/ca_01.pem', @@ -888,7 +888,7 @@ driver_agent_opts = [ default=60, help=_('The time, in seconds, to wait for provider agents ' 'to shutdown after the exit event has been set.')), - cfg.ListOpt('enabled_provider_agents', default='', + cfg.ListOpt('enabled_provider_agents', default=[], help=_('List of enabled provider agents. The driver-agent ' 'will launch these agents at startup.')) ] diff --git a/octavia/compute/drivers/nova_driver.py b/octavia/compute/drivers/nova_driver.py index 47070e03dc..8f901b59c4 100644 --- a/octavia/compute/drivers/nova_driver.py +++ b/octavia/compute/drivers/nova_driver.py @@ -232,7 +232,7 @@ class VirtualMachineManager(compute_base.ComputeBase): net_id = interface.net_id # Pick the first fixed_ip if this is a boot network or if # there are no boot networks configured (use default network) - if net_id in boot_networks or not boot_networks: + if not boot_networks or net_id in boot_networks: lb_network_ip = interface.fixed_ips[0]['ip_address'] break try: diff --git a/octavia/tests/functional/api/v2/test_load_balancer.py b/octavia/tests/functional/api/v2/test_load_balancer.py index 05cc993914..77696e2553 100644 --- a/octavia/tests/functional/api/v2/test_load_balancer.py +++ b/octavia/tests/functional/api/v2/test_load_balancer.py @@ -881,7 +881,7 @@ class TestLoadBalancer(base.BaseAPITest): def test_create_with_allowed_network_id(self): network_id = uuidutils.generate_uuid() - self.conf.config(group="networking", valid_vip_networks=network_id) + self.conf.config(group="networking", valid_vip_networks=[network_id]) subnet = network_models.Subnet(id=uuidutils.generate_uuid(), network_id=network_id, ip_version=4) @@ -905,7 +905,7 @@ class TestLoadBalancer(base.BaseAPITest): def test_create_with_disallowed_network_id(self): network_id1 = uuidutils.generate_uuid() network_id2 = uuidutils.generate_uuid() - self.conf.config(group="networking", valid_vip_networks=network_id1) + self.conf.config(group="networking", valid_vip_networks=[network_id1]) subnet = network_models.Subnet(id=uuidutils.generate_uuid(), network_id=network_id2, ip_version=4) diff --git a/octavia/tests/unit/common/test_validate.py b/octavia/tests/unit/common/test_validate.py index f2f7674217..0e56d66d6c 100644 --- a/octavia/tests/unit/common/test_validate.py +++ b/octavia/tests/unit/common/test_validate.py @@ -357,8 +357,8 @@ class TestValidations(base.TestCase): net_id1 = uuidutils.generate_uuid() net_id2 = uuidutils.generate_uuid() net_id3 = uuidutils.generate_uuid() - valid_net_ids = ",".join((net_id1, net_id2)) - self.conf.config(group="networking", valid_vip_networks=valid_net_ids) + self.conf.config(group="networking", + valid_vip_networks=[net_id1, net_id2]) validate.network_allowed_by_config(net_id1) validate.network_allowed_by_config(net_id2) self.assertRaises(