Merge "Remove hard dependency on novaclient"

This commit is contained in:
Jenkins 2014-05-21 13:59:17 +00:00 committed by Gerrit Code Review
commit 90ab6717f0
2 changed files with 14 additions and 11 deletions

View File

@ -27,7 +27,6 @@ from neutron.api.v2 import attributes
from neutron.api.v2 import resource as wsgi_resource
from neutron.common import constants as const
from neutron.common import exceptions
from neutron.notifiers import nova
from neutron.openstack.common import log as logging
from neutron.openstack.common.notifier import api as notifier_api
from neutron import policy
@ -77,6 +76,8 @@ class Controller(object):
agent_notifiers.get(const.AGENT_TYPE_DHCP) or
dhcp_rpc_agent_api.DhcpAgentNotifyAPI()
)
if cfg.CONF.notify_nova_on_port_data_changes:
from neutron.notifiers import nova
self._nova_notifier = nova.Notifier()
self._member_actions = member_actions
self._primary_key = self._get_primary_key()
@ -296,6 +297,10 @@ class Controller(object):
else:
self._dhcp_agent_notifier.notify(context, data, methodname)
def _send_nova_notification(self, action, orig, returned):
if hasattr(self, '_nova_notifier'):
self._nova_notifier.send_network_change(action, orig, returned)
def index(self, request, **kwargs):
"""Returns a list of the requested entity."""
parent_id = kwargs.get(self._parent_id_name)
@ -446,11 +451,10 @@ class Controller(object):
else:
kwargs.update({self._resource: body})
obj = obj_creator(request.context, **kwargs)
self._nova_notifier.send_network_change(
action, {}, {self._resource: obj})
return notify({self._resource: self._view(
request.context, obj)})
self._send_nova_notification(action, {},
{self._resource: obj})
return notify({self._resource: self._view(request.context,
obj)})
def delete(self, request, id, **kwargs):
"""Deletes the specified entity."""
@ -484,7 +488,7 @@ class Controller(object):
notifier_api.CONF.default_notification_level,
{self._resource + '_id': id})
result = {self._resource: self._view(request.context, obj)}
self._nova_notifier.send_network_change(action, {}, result)
self._send_nova_notification(action, {}, result)
self._send_dhcp_notification(request.context,
result,
notifier_method)
@ -545,8 +549,7 @@ class Controller(object):
self._send_dhcp_notification(request.context,
result,
notifier_method)
self._nova_notifier.send_network_change(
action, orig_object_copy, result)
self._send_nova_notification(action, orig_object_copy, result)
return result
@staticmethod

View File

@ -33,7 +33,6 @@ from neutron.db import sqlalchemyutils
from neutron.extensions import l3
from neutron import manager
from neutron import neutron_plugin_base_v2
from neutron.notifiers import nova
from neutron.openstack.common import excutils
from neutron.openstack.common import log as logging
from neutron.openstack.common import uuidutils
@ -238,6 +237,7 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
def __init__(self):
db.configure_db()
if cfg.CONF.notify_nova_on_port_status_changes:
from neutron.notifiers import nova
# NOTE(arosen) These event listners are here to hook into when
# port status changes and notify nova about their change.
self.nova_notifier = nova.Notifier()