Fix NVP plugin not notifying metadata access network to DHCP agent

Bug 1133395

Due to recent changes in notification logic between Quantum and the DHCP
agent, the notifier the NVP plugin previously used for metadata access
network was not working anymore and needed to be replaced

Change-Id: Ifa0ea55116cf5ef6d546d28ca52e643987b3e5a0
This commit is contained in:
Salvatore Orlando 2013-02-26 17:57:55 +01:00
parent 578f7fa572
commit 2acc26f922
3 changed files with 26 additions and 41 deletions

View File

@ -18,12 +18,13 @@
# @author: Salvatore Orlando, VMware # @author: Salvatore Orlando, VMware
import netaddr import netaddr
from oslo.config import cfg
from quantum.api.rpc.agentnotifiers import dhcp_rpc_agent_api
from quantum.api.v2 import attributes from quantum.api.v2 import attributes
from quantum.common import constants from quantum.common import constants
from quantum.common import exceptions as q_exc from quantum.common import exceptions as q_exc
from quantum.db import l3_db from quantum.db import l3_db
from quantum.openstack.common import cfg
from quantum.openstack.common import log as logging from quantum.openstack.common import log as logging
from quantum.openstack.common.notifier import api as notifier_api from quantum.openstack.common.notifier import api as notifier_api
from quantum.plugins.nicira.nicira_nvp_plugin.common import (exceptions from quantum.plugins.nicira.nicira_nvp_plugin.common import (exceptions
@ -81,14 +82,13 @@ class NvpMetadataAccess(object):
{'subnet': subnet_data}) {'subnet': subnet_data})
self.add_router_interface(ctx_elevated, router_id, self.add_router_interface(ctx_elevated, router_id,
{'subnet_id': meta_sub['id']}) {'subnet_id': meta_sub['id']})
# We need to send a notification to the dhcp agent in order if cfg.CONF.dhcp_agent_notification:
# to start the metadata agent proxy # We need to send a notification to the dhcp agent in
# Note: the publisher id is the same used in the api module # order to start the metadata agent proxy
notifier_api.notify(context, dhcp_notifier = dhcp_rpc_agent_api.DhcpAgentNotifyAPI()
notifier_api.publisher_id('network'), dhcp_notifier.notify(ctx_elevated,
'network.create.end', {'network': meta_net},
notifier_api.CONF.default_notification_level, 'network.create.end')
{'network': meta_net})
def _destroy_metadata_access_network(self, context, router_id, ports): def _destroy_metadata_access_network(self, context, router_id, ports):
@ -105,15 +105,13 @@ class NvpMetadataAccess(object):
ctx_elevated, router_id, {'port_id': meta_port['id']}) ctx_elevated, router_id, {'port_id': meta_port['id']})
# Remove network (this will remove the subnet too) # Remove network (this will remove the subnet too)
self.delete_network(ctx_elevated, meta_net_id) self.delete_network(ctx_elevated, meta_net_id)
# We need to send a notification to the dhcp agent in order if cfg.CONF.dhcp_agent_notification:
# to stop the metadata agent proxy # We need to send a notification to the dhcp agent in
# Note: the publisher id is the same used in the api module # order to stop the metadata agent proxy
notifier_api.notify( dhcp_notifier = dhcp_rpc_agent_api.DhcpAgentNotifyAPI()
context, dhcp_notifier.notify(ctx_elevated,
notifier_api.publisher_id('network'), {'network': {'id': meta_net_id}},
'network.delete.end', 'network.delete.end')
notifier_api.CONF.default_notification_level,
{'network_id': meta_net_id})
def _handle_metadata_access_network(self, context, router_id): def _handle_metadata_access_network(self, context, router_id):
if not cfg.CONF.NVP.enable_metadata_access_network: if not cfg.CONF.NVP.enable_metadata_access_network:

View File

@ -274,19 +274,7 @@ class TestNiciraL3NatTestCase(test_l3_plugin.L3NatDBTestCase,
def test_router_add_interface_subnet_with_metadata_access(self): def test_router_add_interface_subnet_with_metadata_access(self):
self._nvp_metadata_setup() self._nvp_metadata_setup()
notifications = ['router.create.start', self.test_router_add_interface_subnet()
'router.create.end',
'network.create.start',
'network.create.end',
'subnet.create.start',
'subnet.create.end',
'router.interface.create',
'network.create.end',
'router.interface.create',
'router.interface.delete',
'router.interface.delete',
'network.delete.end']
self.test_router_add_interface_subnet(exp_notifications=notifications)
self._nvp_metadata_teardown() self._nvp_metadata_teardown()
def test_router_add_interface_port_with_metadata_access(self): def test_router_add_interface_port_with_metadata_access(self):

View File

@ -633,16 +633,15 @@ class L3NatDBTestCase(L3NatTestCaseBase):
fip['floatingip']['router_id'], None, fip['floatingip']['router_id'], None,
expected_code=exc.HTTPConflict.code) expected_code=exc.HTTPConflict.code)
def test_router_add_interface_subnet(self, exp_notifications=None): def test_router_add_interface_subnet(self):
if not exp_notifications: exp_notifications = ['router.create.start',
exp_notifications = ['router.create.start', 'router.create.end',
'router.create.end', 'network.create.start',
'network.create.start', 'network.create.end',
'network.create.end', 'subnet.create.start',
'subnet.create.start', 'subnet.create.end',
'subnet.create.end', 'router.interface.create',
'router.interface.create', 'router.interface.delete']
'router.interface.delete']
with self.router() as r: with self.router() as r:
with self.subnet() as s: with self.subnet() as s:
body = self._router_interface_action('add', body = self._router_interface_action('add',