diff --git a/config.yaml b/config.yaml index 6e117643..55d23637 100755 --- a/config.yaml +++ b/config.yaml @@ -376,6 +376,12 @@ options: namespace will be rescheduled only to L3 agents running in the 'dvr_snat' mode, while l3 agents in the 'dvr' mode will only host qrouter and fip namespaces. + router-scheduler-driver: + type: string + default: 'neutron.scheduler.l3_agent_scheduler.AZLeastRoutersScheduler' + description: | + The driver to use for router scheduling. In case of distributed routers + this will affect snat namespace scheduling. allow-automatic-dhcp-failover: type: boolean default: True diff --git a/hooks/neutron_api_context.py b/hooks/neutron_api_context.py index 5ba66c7c..7569674e 100644 --- a/hooks/neutron_api_context.py +++ b/hooks/neutron_api_context.py @@ -522,6 +522,9 @@ class NeutronCCContext(context.NeutronContext): 'neutron.scheduler.dhcp_agent_scheduler.AZAwareWeightScheduler' ) ctxt['dhcp_load_type'] = config('dhcp-load-type') + # AZLeastRoutersScheduler inherits from LeastRoutersScheduler and + # is available as of mitaka. + ctxt['router_scheduler_driver'] = config('router-scheduler-driver') extension_drivers = [] if config('enable-ml2-port-security'): diff --git a/templates/mitaka/neutron.conf b/templates/mitaka/neutron.conf index c59e7407..13745052 100644 --- a/templates/mitaka/neutron.conf +++ b/templates/mitaka/neutron.conf @@ -32,6 +32,9 @@ allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} network_scheduler_driver = {{ network_scheduler_driver }} dhcp_load_type = {{ dhcp_load_type }} {% endif -%} +{% if router_scheduler_driver -%} +router_scheduler_driver = {{ router_scheduler_driver }} +{% endif -%} {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} diff --git a/templates/newton/neutron.conf b/templates/newton/neutron.conf index 4aa662bb..b2a2a1af 100644 --- a/templates/newton/neutron.conf +++ b/templates/newton/neutron.conf @@ -32,6 +32,9 @@ allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} network_scheduler_driver = {{ network_scheduler_driver }} dhcp_load_type = {{ dhcp_load_type }} {% endif -%} +{% if router_scheduler_driver -%} +router_scheduler_driver = {{ router_scheduler_driver }} +{% endif -%} {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} diff --git a/templates/ocata/neutron.conf b/templates/ocata/neutron.conf index 59f3584e..5bdd15fc 100644 --- a/templates/ocata/neutron.conf +++ b/templates/ocata/neutron.conf @@ -35,6 +35,9 @@ allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} network_scheduler_driver = {{ network_scheduler_driver }} dhcp_load_type = {{ dhcp_load_type }} {% endif -%} +{% if router_scheduler_driver -%} +router_scheduler_driver = {{ router_scheduler_driver }} +{% endif -%} {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} diff --git a/templates/pike/neutron.conf b/templates/pike/neutron.conf index 291b1ad0..d6b0337b 100644 --- a/templates/pike/neutron.conf +++ b/templates/pike/neutron.conf @@ -35,6 +35,9 @@ allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} network_scheduler_driver = {{ network_scheduler_driver }} dhcp_load_type = {{ dhcp_load_type }} {% endif -%} +{% if router_scheduler_driver -%} +router_scheduler_driver = {{ router_scheduler_driver }} +{% endif -%} {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} diff --git a/templates/queens/neutron.conf b/templates/queens/neutron.conf index d81bba55..bb5c14d4 100644 --- a/templates/queens/neutron.conf +++ b/templates/queens/neutron.conf @@ -35,6 +35,9 @@ allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} network_scheduler_driver = {{ network_scheduler_driver }} dhcp_load_type = {{ dhcp_load_type }} {% endif -%} +{% if router_scheduler_driver -%} +router_scheduler_driver = {{ router_scheduler_driver }} +{% endif -%} {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} diff --git a/templates/rocky/neutron.conf b/templates/rocky/neutron.conf index 5cc1ff2d..3801f98e 100644 --- a/templates/rocky/neutron.conf +++ b/templates/rocky/neutron.conf @@ -35,6 +35,9 @@ allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} network_scheduler_driver = {{ network_scheduler_driver }} dhcp_load_type = {{ dhcp_load_type }} {% endif -%} +{% if router_scheduler_driver -%} +router_scheduler_driver = {{ router_scheduler_driver }} +{% endif -%} {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} diff --git a/templates/train/neutron.conf b/templates/train/neutron.conf index 330ac238..1c614e57 100644 --- a/templates/train/neutron.conf +++ b/templates/train/neutron.conf @@ -35,6 +35,9 @@ allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} network_scheduler_driver = {{ network_scheduler_driver }} dhcp_load_type = {{ dhcp_load_type }} {% endif -%} +{% if router_scheduler_driver -%} +router_scheduler_driver = {{ router_scheduler_driver }} +{% endif -%} {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} diff --git a/templates/ussuri/neutron.conf b/templates/ussuri/neutron.conf index 30e77477..78820b28 100644 --- a/templates/ussuri/neutron.conf +++ b/templates/ussuri/neutron.conf @@ -35,6 +35,9 @@ allow_automatic_dhcp_failover = {{ allow_automatic_dhcp_failover }} network_scheduler_driver = {{ network_scheduler_driver }} dhcp_load_type = {{ dhcp_load_type }} {% endif -%} +{% if router_scheduler_driver -%} +router_scheduler_driver = {{ router_scheduler_driver }} +{% endif -%} {% if neutron_bind_port -%} bind_port = {{ neutron_bind_port }} diff --git a/unit_tests/test_neutron_api_context.py b/unit_tests/test_neutron_api_context.py index 51d1f336..0193615b 100644 --- a/unit_tests/test_neutron_api_context.py +++ b/unit_tests/test_neutron_api_context.py @@ -527,6 +527,9 @@ class NeutronCCContextTest(CharmTestCase): 'neutron.scheduler.dhcp_agent_scheduler' '.AZAwareWeightScheduler'), 'dhcp_load_type': 'networks', + 'router_scheduler_driver': ( + 'neutron.scheduler.l3_agent_scheduler' + '.AZLeastRoutersScheduler'), } napi_ctxt = context.NeutronCCContext() self.maxDiff = None