diff --git a/config.yaml b/config.yaml index 9515fc11..552b8b81 100755 --- a/config.yaml +++ b/config.yaml @@ -726,3 +726,9 @@ options: The size in bits of the prefix for the IPv6 reverse lookup (PTR) zones. . NOTE: Use only when "reverse-dns-lookup" option is set to "True". + dhcp-load-type: + type: string + default: 'networks' + description: | + Sets the resource type used in weight calculations during + AZ-aware scheduling (networks, subnets or ports). diff --git a/hooks/neutron_api_context.py b/hooks/neutron_api_context.py index 84293d20..73144f60 100644 --- a/hooks/neutron_api_context.py +++ b/hooks/neutron_api_context.py @@ -400,6 +400,7 @@ class NeutronCCContext(context.NeutronContext): config('allow-automatic-l3agent-failover') ctxt['allow_automatic_dhcp_failover'] = \ config('allow-automatic-dhcp-failover') + ctxt['dhcp_agents_per_network'] = config('dhcp-agents-per-network') ctxt['tenant_network_types'] = self.neutron_tenant_network_types ctxt['overlay_network_type'] = self.neutron_overlay_network_type @@ -472,6 +473,13 @@ class NeutronCCContext(context.NeutronContext): if related_units(rid): enable_dns_extension_driver = True + # AZAwareWeightScheduler inherits from WeightScheduler and is + # available as of mitaka + ctxt['network_scheduler_driver'] = ( + 'neutron.scheduler.dhcp_agent_scheduler.AZAwareWeightScheduler' + ) + ctxt['dhcp_load_type'] = config('dhcp-load-type') + extension_drivers = [] if config('enable-ml2-port-security'): extension_drivers.append(EXTENSION_DRIVER_PORT_SECURITY) diff --git a/templates/mitaka/neutron.conf b/templates/mitaka/neutron.conf index 426157bc..79fabf20 100644 --- a/templates/mitaka/neutron.conf +++ b/templates/mitaka/neutron.conf @@ -28,6 +28,10 @@ min_l3_agents_per_router = {{ min_l3_agents_per_router }} allow_automatic_l3agent_failover = {{ allow_automatic_l3agent_failover }} allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} +{% if network_scheduler_driver -%} +network_scheduler_driver = {{ network_scheduler_driver }} +dhcp_load_type = {{ dhcp_load_type }} +{% endif -%} {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} diff --git a/templates/newton/neutron.conf b/templates/newton/neutron.conf index c5eed6da..c07e31f6 100644 --- a/templates/newton/neutron.conf +++ b/templates/newton/neutron.conf @@ -28,6 +28,10 @@ min_l3_agents_per_router = {{ min_l3_agents_per_router }} allow_automatic_l3agent_failover = {{ allow_automatic_l3agent_failover }} allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} +{% if network_scheduler_driver -%} +network_scheduler_driver = {{ network_scheduler_driver }} +dhcp_load_type = {{ dhcp_load_type }} +{% endif -%} {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} diff --git a/templates/ocata/neutron.conf b/templates/ocata/neutron.conf index 0690132b..ee56509f 100644 --- a/templates/ocata/neutron.conf +++ b/templates/ocata/neutron.conf @@ -28,6 +28,10 @@ min_l3_agents_per_router = {{ min_l3_agents_per_router }} allow_automatic_l3agent_failover = {{ allow_automatic_l3agent_failover }} allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} +{% if network_scheduler_driver -%} +network_scheduler_driver = {{ network_scheduler_driver }} +dhcp_load_type = {{ dhcp_load_type }} +{% endif -%} {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} diff --git a/templates/pike/neutron.conf b/templates/pike/neutron.conf index 0b39633e..afbc5ba9 100644 --- a/templates/pike/neutron.conf +++ b/templates/pike/neutron.conf @@ -28,6 +28,10 @@ min_l3_agents_per_router = {{ min_l3_agents_per_router }} allow_automatic_l3agent_failover = {{ allow_automatic_l3agent_failover }} allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} +{% if network_scheduler_driver -%} +network_scheduler_driver = {{ network_scheduler_driver }} +dhcp_load_type = {{ dhcp_load_type }} +{% endif -%} {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} diff --git a/templates/queens/neutron.conf b/templates/queens/neutron.conf index 1e2df990..acf2e890 100644 --- a/templates/queens/neutron.conf +++ b/templates/queens/neutron.conf @@ -28,6 +28,10 @@ min_l3_agents_per_router = {{ min_l3_agents_per_router }} allow_automatic_l3agent_failover = {{ allow_automatic_l3agent_failover }} allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} +{% if network_scheduler_driver -%} +network_scheduler_driver = {{ network_scheduler_driver }} +dhcp_load_type = {{ dhcp_load_type }} +{% endif -%} {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} diff --git a/templates/rocky/neutron.conf b/templates/rocky/neutron.conf index 83bd8b00..6412e358 100644 --- a/templates/rocky/neutron.conf +++ b/templates/rocky/neutron.conf @@ -26,6 +26,13 @@ max_l3_agents_per_router = {{ max_l3_agents_per_router }} min_l3_agents_per_router = {{ min_l3_agents_per_router }} {% endif -%} +allow_automatic_l3agent_failover = {{ allow_automatic_l3agent_failover }} +allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} +{% if network_scheduler_driver -%} +network_scheduler_driver = {{ network_scheduler_driver }} +dhcp_load_type = {{ dhcp_load_type }} +{% endif -%} + {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} {% else -%} diff --git a/unit_tests/test_neutron_api_context.py b/unit_tests/test_neutron_api_context.py index 98977477..fee65b94 100644 --- a/unit_tests/test_neutron_api_context.py +++ b/unit_tests/test_neutron_api_context.py @@ -492,6 +492,10 @@ class NeutronCCContextTest(CharmTestCase): 'vni_ranges': '1001:2000', 'extension_drivers': 'port_security', 'service_plugins': 'router,firewall,lbaas,vpnaas,metering', + 'network_scheduler_driver': ( + 'neutron.scheduler.dhcp_agent_scheduler' + '.AZAwareWeightScheduler'), + 'dhcp_load_type': 'networks', } napi_ctxt = context.NeutronCCContext() self.maxDiff = None