Merge "Move process_ha_router_added/removed from HA agent to router"
This commit is contained in:
commit
807b74dc0c
@ -306,7 +306,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback,
|
||||
self.process_router_add(ri)
|
||||
|
||||
if ri.is_ha:
|
||||
self.process_ha_router_added(ri)
|
||||
ri.initialize(self.process_monitor, self.enqueue_state_change)
|
||||
|
||||
def _router_removed(self, router_id):
|
||||
ri = self.router_info.get(router_id)
|
||||
@ -319,7 +319,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback,
|
||||
adv_svc.AdvancedService.before_router_removed, ri)
|
||||
|
||||
if ri.is_ha:
|
||||
self.process_ha_router_removed(ri)
|
||||
ri.terminate(self.process_monitor)
|
||||
|
||||
ri.router['gw_port'] = None
|
||||
ri.router[l3_constants.INTERFACE_KEY] = []
|
||||
@ -340,13 +340,6 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback,
|
||||
self.plugin_rpc.update_floatingip_statuses(
|
||||
self.context, ri.router_id, fip_statuses)
|
||||
|
||||
def _process_ha_router(self, ri):
|
||||
if ri.is_ha:
|
||||
if ri.ha_port:
|
||||
ri.spawn_keepalived()
|
||||
else:
|
||||
ri.disable_keepalived()
|
||||
|
||||
@common_utils.exception_logger()
|
||||
def process_router(self, ri):
|
||||
# TODO(mrsmith) - we shouldn't need to check here
|
||||
@ -361,8 +354,9 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback,
|
||||
# Process static routes for router
|
||||
ri.routes_updated()
|
||||
|
||||
# Enable or disable keepalived for ha routers
|
||||
self._process_ha_router(ri)
|
||||
# If process_router was called during a create or update
|
||||
if ri.is_ha and ri.ha_port:
|
||||
ri.enable_keepalived()
|
||||
|
||||
# Update ex_gw_port and enable_snat on the router info cache
|
||||
ri.ex_gw_port = ex_gw_port
|
||||
|
@ -22,8 +22,7 @@ import webob
|
||||
|
||||
from neutron.agent.linux import keepalived
|
||||
from neutron.agent.linux import utils as agent_utils
|
||||
from neutron.common import constants as l3_constants
|
||||
from neutron.i18n import _LE, _LI
|
||||
from neutron.i18n import _LI
|
||||
from neutron.notifiers import batch_notifier
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -150,25 +149,3 @@ class AgentMixin(object):
|
||||
def _init_ha_conf_path(self):
|
||||
ha_full_path = os.path.dirname("/%s/" % self.conf.ha_confs_path)
|
||||
agent_utils.ensure_dir(ha_full_path)
|
||||
|
||||
def process_ha_router_added(self, ri):
|
||||
ha_port = ri.router.get(l3_constants.HA_INTERFACE_KEY)
|
||||
if not ha_port:
|
||||
LOG.error(_LE('Unable to process HA router %s without ha port'),
|
||||
ri.router_id)
|
||||
return
|
||||
|
||||
ri._set_subnet_info(ha_port)
|
||||
ri.ha_port = ha_port
|
||||
ri._init_keepalived_manager(self.process_monitor)
|
||||
ri.ha_network_added(ha_port['network_id'],
|
||||
ha_port['id'],
|
||||
ha_port['ip_cidr'],
|
||||
ha_port['mac_address'])
|
||||
|
||||
ri.update_initial_state(self.enqueue_state_change)
|
||||
ri.spawn_state_change_monitor(self.process_monitor)
|
||||
|
||||
def process_ha_router_removed(self, ri):
|
||||
ri.destroy_state_change_monitor(self.process_monitor)
|
||||
ri.ha_network_removed()
|
||||
|
@ -73,6 +73,28 @@ class HaRouter(router.RouterInfo):
|
||||
LOG.error(_LE('Error while writing HA state for %s'),
|
||||
self.router_id)
|
||||
|
||||
def initialize(self, process_monitor, state_change_callback):
|
||||
ha_port = self.router.get(n_consts.HA_INTERFACE_KEY)
|
||||
if not ha_port:
|
||||
LOG.error(_LE('Unable to process HA router %s without HA port'),
|
||||
self.router_id)
|
||||
return
|
||||
|
||||
self._set_subnet_info(ha_port)
|
||||
self.ha_port = ha_port
|
||||
self._init_keepalived_manager(process_monitor)
|
||||
self.ha_network_added(ha_port['network_id'],
|
||||
ha_port['id'],
|
||||
ha_port['ip_cidr'],
|
||||
ha_port['mac_address'])
|
||||
self.update_initial_state(state_change_callback)
|
||||
self.spawn_state_change_monitor(process_monitor)
|
||||
|
||||
def terminate(self, process_monitor):
|
||||
self.destroy_state_change_monitor(process_monitor)
|
||||
self.ha_network_removed()
|
||||
self.disable_keepalived()
|
||||
|
||||
def _init_keepalived_manager(self, process_monitor):
|
||||
self.keepalived_manager = keepalived.KeepalivedManager(
|
||||
self.router['id'],
|
||||
@ -103,7 +125,7 @@ class HaRouter(router.RouterInfo):
|
||||
|
||||
config.add_instance(instance)
|
||||
|
||||
def spawn_keepalived(self):
|
||||
def enable_keepalived(self):
|
||||
self.keepalived_manager.spawn()
|
||||
|
||||
def disable_keepalived(self):
|
||||
|
Loading…
Reference in New Issue
Block a user