# @author: Salvatore Orlando, VMware
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.common import constants
from quantum.common import exceptions as q_exc
from quantum.db import l3_db
-from quantum.openstack.common import cfg
from quantum.openstack.common import log as logging
from quantum.openstack.common.notifier import api as notifier_api
from quantum.plugins.nicira.nicira_nvp_plugin.common import (exceptions
{'subnet': subnet_data})
self.add_router_interface(ctx_elevated, router_id,
{'subnet_id': meta_sub['id']})
- # We need to send a notification to the dhcp agent in order
- # to start the metadata agent proxy
- # Note: the publisher id is the same used in the api module
- notifier_api.notify(context,
- notifier_api.publisher_id('network'),
- 'network.create.end',
- notifier_api.CONF.default_notification_level,
- {'network': meta_net})
+ if cfg.CONF.dhcp_agent_notification:
+ # We need to send a notification to the dhcp agent in
+ # order to start the metadata agent proxy
+ dhcp_notifier = dhcp_rpc_agent_api.DhcpAgentNotifyAPI()
+ dhcp_notifier.notify(ctx_elevated,
+ {'network': meta_net},
+ 'network.create.end')
def _destroy_metadata_access_network(self, context, router_id, ports):
ctx_elevated, router_id, {'port_id': meta_port['id']})
# Remove network (this will remove the subnet too)
self.delete_network(ctx_elevated, meta_net_id)
- # We need to send a notification to the dhcp agent in order
- # to stop the metadata agent proxy
- # Note: the publisher id is the same used in the api module
- notifier_api.notify(
- context,
- notifier_api.publisher_id('network'),
- 'network.delete.end',
- notifier_api.CONF.default_notification_level,
- {'network_id': meta_net_id})
+ if cfg.CONF.dhcp_agent_notification:
+ # We need to send a notification to the dhcp agent in
+ # order to stop the metadata agent proxy
+ dhcp_notifier = dhcp_rpc_agent_api.DhcpAgentNotifyAPI()
+ dhcp_notifier.notify(ctx_elevated,
+ {'network': {'id': meta_net_id}},
+ 'network.delete.end')
def _handle_metadata_access_network(self, context, router_id):
if not cfg.CONF.NVP.enable_metadata_access_network:
def test_router_add_interface_subnet_with_metadata_access(self):
self._nvp_metadata_setup()
- notifications = ['router.create.start',
- '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.test_router_add_interface_subnet()
self._nvp_metadata_teardown()
def test_router_add_interface_port_with_metadata_access(self):
fip['floatingip']['router_id'], None,
expected_code=exc.HTTPConflict.code)
- def test_router_add_interface_subnet(self, exp_notifications=None):
- if not exp_notifications:
- exp_notifications = ['router.create.start',
- 'router.create.end',
- 'network.create.start',
- 'network.create.end',
- 'subnet.create.start',
- 'subnet.create.end',
- 'router.interface.create',
- 'router.interface.delete']
+ def test_router_add_interface_subnet(self):
+ exp_notifications = ['router.create.start',
+ 'router.create.end',
+ 'network.create.start',
+ 'network.create.end',
+ 'subnet.create.start',
+ 'subnet.create.end',
+ 'router.interface.create',
+ 'router.interface.delete']
with self.router() as r:
with self.subnet() as s:
body = self._router_interface_action('add',