Don't pass namespace name in disable_isolated_metadata_proxy

It's not always possible/convenient to get namespace name
when need to disable some process (like metadata process for stale
router, see related bug). Since namespace name is not required
for process manager to disable process we can remove this parameter
from disable_isolated_metadata_proxy()

Change-Id: I0e0da01d9640aa9920f41989804fc6f320c1c1eb
Related-Bug: #1455042
This commit is contained in:
Oleg Bondarev 2015-05-14 15:03:54 +03:00
parent 5315fc27bd
commit 6deed4363b
5 changed files with 12 additions and 13 deletions

View File

@ -379,7 +379,7 @@ class DhcpAgent(manager.Manager):
def disable_isolated_metadata_proxy(self, network):
metadata_driver.MetadataDriver.destroy_monitored_metadata_proxy(
self._process_monitor, network.id, network.namespace, self.conf)
self._process_monitor, network.id, self.conf)
class DhcpPluginApi(object):

View File

@ -134,7 +134,7 @@ class AgentMixin(object):
else:
LOG.debug('Closing metadata proxy for router %s', router_id)
self.metadata_driver.destroy_monitored_metadata_proxy(
self.process_monitor, ri.router_id, ri.ns_name, self.conf)
self.process_monitor, ri.router_id, self.conf)
def _update_radvd_daemon(self, ri, state):
# Radvd has to be spawned only on the Master HA Router. If there are

View File

@ -116,19 +116,21 @@ class MetadataDriver(object):
uuid = network_id or router_id
callback = cls._get_metadata_proxy_callback(
port, conf, network_id=network_id, router_id=router_id)
pm = cls._get_metadata_proxy_process_manager(uuid, ns_name, conf,
pm = cls._get_metadata_proxy_process_manager(uuid, conf,
ns_name=ns_name,
callback=callback)
pm.enable()
monitor.register(uuid, METADATA_SERVICE_NAME, pm)
@classmethod
def destroy_monitored_metadata_proxy(cls, monitor, uuid, ns_name, conf):
def destroy_monitored_metadata_proxy(cls, monitor, uuid, conf):
monitor.unregister(uuid, METADATA_SERVICE_NAME)
pm = cls._get_metadata_proxy_process_manager(uuid, ns_name, conf)
# No need to pass ns name as it's not needed for disable()
pm = cls._get_metadata_proxy_process_manager(uuid, conf)
pm.disable()
@classmethod
def _get_metadata_proxy_process_manager(cls, router_id, ns_name, conf,
def _get_metadata_proxy_process_manager(cls, router_id, conf, ns_name=None,
callback=None):
return external_process.ProcessManager(
conf=conf,
@ -172,5 +174,4 @@ def before_router_removed(resource, event, l3_agent, **kwargs):
proxy.destroy_monitored_metadata_proxy(l3_agent.process_monitor,
router.router['id'],
router.ns_name,
l3_agent.conf)

View File

@ -567,10 +567,10 @@ class TestDhcpAgentEventHandler(base.BaseTestCase):
)
self.external_process = self.external_process_p.start()
def _process_manager_constructor_call(self):
def _process_manager_constructor_call(self, ns=FAKE_NETWORK_DHCP_NS):
return mock.call(conf=cfg.CONF,
uuid=FAKE_NETWORK_UUID,
namespace=FAKE_NETWORK_DHCP_NS,
namespace=ns,
default_cmd_callback=mock.ANY)
def _enable_dhcp_helper(self, network, enable_isolated_metadata=False,
@ -709,7 +709,7 @@ class TestDhcpAgentEventHandler(base.BaseTestCase):
self.call_driver.assert_called_once_with('disable', fake_network)
if isolated_metadata:
self.external_process.assert_has_calls([
self._process_manager_constructor_call(),
self._process_manager_constructor_call(ns=None),
mock.call().disable()])
else:
self.assertFalse(self.external_process.call_count)
@ -741,7 +741,7 @@ class TestDhcpAgentEventHandler(base.BaseTestCase):
[mock.call.get_network_by_id(fake_network.id)])
if isolated_metadata:
self.external_process.assert_has_calls([
self._process_manager_constructor_call(),
self._process_manager_constructor_call(ns=None),
mock.call().disable()
])
else:
@ -768,7 +768,6 @@ class TestDhcpAgentEventHandler(base.BaseTestCase):
self.dhcp.disable_isolated_metadata_proxy(fake_network)
destroy.assert_called_once_with(self.dhcp._process_monitor,
fake_network.id,
fake_network.namespace,
cfg.CONF)
def _test_metadata_network(self, network):

View File

@ -1974,7 +1974,6 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
if enableflag:
destroy_proxy.assert_called_with(mock.ANY,
router_id,
mock.ANY,
mock.ANY)
else:
self.assertFalse(destroy_proxy.call_count)