#
# Enable snat by default on external gateway when available
# enable_snat_by_default = True
+#
+# The network type to use when creating the HA network for an HA router.
+# By default or if empty, the first 'tenant_network_types'
+# is used. This is helpful when the VRRP traffic should use a specific
+# network which not the default one.
+# ha_network_type =
+# Example: ha_network_type = flat
+#
+# The physical network name with which the HA network can be created.
+# ha_network_physical_name =
+# Example: ha_network_physical_name = physnet1
# =========== end of items for l3 extension =======
# =========== items for metadata proxy configuration ==============
from neutron.db import models_v2
from neutron.extensions import l3_ext_ha_mode as l3_ha
from neutron.extensions import portbindings
+from neutron.extensions import providernet
from neutron.i18n import _LI
VR_ID_RANGE = set(range(1, 255))
cfg.StrOpt('l3_ha_net_cidr',
default='169.254.192.0/18',
help=_('Subnet used for the l3 HA admin network.')),
+ cfg.StrOpt('l3_ha_network_type', default='',
+ help=_("The network type to use when creating the HA network "
+ "for an HA router. By default or if empty, the first "
+ "'tenant_network_types' is used. This is helpful when "
+ "the VRRP traffic should use a specific network which "
+ "is not the default one.")),
+ cfg.StrOpt('l3_ha_network_physical_name', default='',
+ help=_("The physical network name with which the HA network "
+ "can be created."))
]
cfg.CONF.register_opts(L3_HA_OPTS)
context.session.add(ha_network)
return ha_network
+ def _add_ha_network_settings(self, network):
+ if cfg.CONF.l3_ha_network_type:
+ network[providernet.NETWORK_TYPE] = cfg.CONF.l3_ha_network_type
+
+ if cfg.CONF.l3_ha_network_physical_name:
+ network[providernet.PHYSICAL_NETWORK] = (
+ cfg.CONF.l3_ha_network_physical_name)
+
def _create_ha_network(self, context, tenant_id):
admin_ctx = context.elevated()
'shared': False,
'admin_state_up': True,
'status': constants.NET_STATUS_ACTIVE}}
+ self._add_ha_network_settings(args['network'])
+
network = self._core_plugin.create_network(admin_ctx, args)
try:
ha_network = self._create_ha_network_tenant_binding(admin_ctx,
from neutron.extensions import l3
from neutron.extensions import l3_ext_ha_mode
from neutron.extensions import portbindings
+from neutron.extensions import providernet
from neutron import manager
from neutron.scheduler import l3_agent_scheduler
from neutron.tests.common import helpers
router = self._create_router(ha=False)
self.assertFalse(router['ha'])
+ def test_add_ha_network_settings(self):
+ cfg.CONF.set_override('l3_ha_network_type', 'abc')
+ cfg.CONF.set_override('l3_ha_network_physical_name', 'def')
+
+ network = {}
+ self.plugin._add_ha_network_settings(network)
+
+ self.assertEqual('abc', network[providernet.NETWORK_TYPE])
+ self.assertEqual('def', network[providernet.PHYSICAL_NETWORK])
+
def test_router_create_with_ha_conf_enabled(self):
cfg.CONF.set_override('l3_ha', True)