Merge "Make DvrServerRpcCallback a separate callback class"

This commit is contained in:
Jenkins 2014-08-29 17:25:26 +00:00 committed by Gerrit Code Review
commit 2da6436ce6
3 changed files with 18 additions and 23 deletions

View File

@ -14,6 +14,7 @@
# under the License. # under the License.
from neutron.common import log from neutron.common import log
from neutron.common import rpc as n_rpc
from neutron.common import topics from neutron.common import topics
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
@ -56,9 +57,14 @@ class DVRServerRpcApiMixin(object):
version=self.DVR_RPC_VERSION) version=self.DVR_RPC_VERSION)
class DVRServerRpcCallbackMixin(object): class DVRServerRpcCallback(n_rpc.RpcCallback):
"""Plugin-side RPC (implementation) for agent-to-plugin interaction.""" """Plugin-side RPC (implementation) for agent-to-plugin interaction."""
# History
# 1.0 Initial version
RPC_API_VERSION = "1.0"
@property @property
def plugin(self): def plugin(self):
if not getattr(self, '_plugin', None): if not getattr(self, '_plugin', None):
@ -68,14 +74,20 @@ class DVRServerRpcCallbackMixin(object):
def get_dvr_mac_address_list(self, context): def get_dvr_mac_address_list(self, context):
return self.plugin.get_dvr_mac_address_list(context) return self.plugin.get_dvr_mac_address_list(context)
def get_dvr_mac_address_by_host(self, context, host): def get_dvr_mac_address_by_host(self, context, **kwargs):
host = kwargs.get('host')
LOG.debug("DVR Agent requests mac_address for host %s", host)
return self.plugin.get_dvr_mac_address_by_host(context, host) return self.plugin.get_dvr_mac_address_by_host(context, host)
def get_ports_on_host_by_subnet(self, context, host, subnet): def get_ports_on_host_by_subnet(self, context, **kwargs):
host = kwargs.get('host')
subnet = kwargs.get('subnet')
LOG.debug("DVR Agent requests list of VM ports on host %s", host)
return self.plugin.get_ports_on_host_by_subnet(context, return self.plugin.get_ports_on_host_by_subnet(context,
host, subnet) host, subnet)
def get_subnet_for_dvr(self, context, subnet): def get_subnet_for_dvr(self, context, **kwargs):
subnet = kwargs.get('subnet')
return self.plugin.get_subnet_for_dvr(context, subnet) return self.plugin.get_subnet_for_dvr(context, subnet)

View File

@ -24,6 +24,7 @@ from sqlalchemy.orm import exc as sa_exc
from neutron.agent import securitygroups_rpc as sg_rpc from neutron.agent import securitygroups_rpc as sg_rpc
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
from neutron.api.rpc.handlers import dhcp_rpc from neutron.api.rpc.handlers import dhcp_rpc
from neutron.api.rpc.handlers import dvr_rpc
from neutron.api.v2 import attributes from neutron.api.v2 import attributes
from neutron.common import constants as const from neutron.common import constants as const
from neutron.common import exceptions as exc from neutron.common import exceptions as exc
@ -135,6 +136,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
def start_rpc_listeners(self): def start_rpc_listeners(self):
self.endpoints = [rpc.RpcCallbacks(self.notifier, self.type_manager), self.endpoints = [rpc.RpcCallbacks(self.notifier, self.type_manager),
dvr_rpc.DVRServerRpcCallback(),
dhcp_rpc.DhcpRpcCallback(), dhcp_rpc.DhcpRpcCallback(),
agents_db.AgentExtRpcCallback()] agents_db.AgentExtRpcCallback()]
self.topic = topics.PLUGIN self.topic = topics.PLUGIN

View File

@ -39,7 +39,6 @@ TAP_DEVICE_PREFIX_LENGTH = 3
class RpcCallbacks(n_rpc.RpcCallback, class RpcCallbacks(n_rpc.RpcCallback,
dvr_rpc.DVRServerRpcCallbackMixin,
sg_db_rpc.SecurityGroupServerRpcCallbackMixin, sg_db_rpc.SecurityGroupServerRpcCallbackMixin,
type_tunnel.TunnelRpcCallbackMixin): type_tunnel.TunnelRpcCallbackMixin):
@ -199,24 +198,6 @@ class RpcCallbacks(n_rpc.RpcCallback,
except exceptions.PortNotFound: except exceptions.PortNotFound:
LOG.debug('Port %s not found during ARP update', port_id) LOG.debug('Port %s not found during ARP update', port_id)
def get_dvr_mac_address_by_host(self, rpc_context, **kwargs):
host = kwargs.get('host')
LOG.debug("DVR Agent requests mac_address for host %s", host)
return super(RpcCallbacks, self).get_dvr_mac_address_by_host(
rpc_context, host)
def get_ports_on_host_by_subnet(self, rpc_context, **kwargs):
host = kwargs.get('host')
subnet = kwargs.get('subnet')
LOG.debug("DVR Agent requests list of VM ports on host %s", host)
return super(RpcCallbacks, self).get_ports_on_host_by_subnet(
rpc_context, host, subnet)
def get_subnet_for_dvr(self, rpc_context, **kwargs):
subnet = kwargs.get('subnet')
return super(RpcCallbacks, self).get_subnet_for_dvr(rpc_context,
subnet)
class AgentNotifierApi(n_rpc.RpcProxy, class AgentNotifierApi(n_rpc.RpcProxy,
dvr_rpc.DVRAgentRpcApiMixin, dvr_rpc.DVRAgentRpcApiMixin,