Generic Resources RPC
This patch adds Generic Resource RPC from agent to server. Change-Id: I0ac8a009e781b6edb283d8634b1a2f047db092dc
This commit is contained in:
1 parent
dc80243888
commit
2d38c742e8
4 files changed
+77
-1
No files matched your search
Executable
+71
@@ -0,0 +1,71 @@
|
||||
# Copyright (c) 2015 Mellanox Technologies, Ltd
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_log import helpers as log_helpers
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
|
||||
from neutron.api.rpc.callbacks import registry
|
||||
from neutron.common import constants
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.common import topics
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ResourcesServerRpcApi(object):
|
||||
"""Agent-side RPC (stub) for agent-to-plugin interaction.
|
||||
|
||||
This class implements the client side of an rpc interface. The server side
|
||||
can be found below: ResourcesServerRpcCallback. For more information on
|
||||
changing rpc interfaces, see doc/source/devref/rpc_api.rst.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
target = oslo_messaging.Target(
|
||||
topic=topics.PLUGIN, version='1.0',
|
||||
namespace=constants.RPC_NAMESPACE_RESOURCES)
|
||||
self.client = n_rpc.get_client(target)
|
||||
|
||||
@log_helpers.log_method_call
|
||||
def get_info(self, context, resource_type, resource_id):
|
||||
cctxt = self.client.prepare()
|
||||
#TODO(Qos): add deserialize version object
|
||||
return cctxt.call(context, 'get_info',
|
||||
resource_type=resource_type, resource_id=resource_id)
|
||||
|
||||
|
||||
class ResourcesServerRpcCallback(object):
|
||||
"""Plugin-side RPC (implementation) for agent-to-plugin interaction.
|
||||
|
||||
This class implements the server side of an rpc interface. The client side
|
||||
can be found above: ResourcesServerRpcApi. For more information on
|
||||
changing rpc interfaces, see doc/source/devref/rpc_api.rst.
|
||||
"""
|
||||
|
||||
# History
|
||||
# 1.0 Initial version
|
||||
|
||||
target = oslo_messaging.Target(
|
||||
version='1.0', namespace=constants.RPC_NAMESPACE_RESOURCES)
|
||||
|
||||
def get_info(self, context, resource_type, resource_id):
|
||||
kwargs = {'context': context}
|
||||
#TODO(Qos): add serialize version object
|
||||
return registry.get_info(
|
||||
resource_type,
|
||||
resource_id,
|
||||
**kwargs)
|
||||
@@ -174,6 +174,8 @@ RPC_NAMESPACE_SECGROUP = None
|
||||
RPC_NAMESPACE_DVR = None
|
||||
# RPC interface for reporting state back to the plugin
|
||||
RPC_NAMESPACE_STATE = None
|
||||
# RPC interface for agent to plugin resources API
|
||||
RPC_NAMESPACE_RESOURCES = None
|
||||
|
||||
# Default network MTU value when not configured
|
||||
DEFAULT_NETWORK_MTU = 0
|
||||
@@ -19,6 +19,7 @@ PORT = 'port'
|
||||
SECURITY_GROUP = 'security_group'
|
||||
L2POPULATION = 'l2population'
|
||||
DVR = 'dvr'
|
||||
RESOURCES = 'resources'
|
||||
|
||||
CREATE = 'create'
|
||||
DELETE = 'delete'
|
||||
|
||||
@@ -31,6 +31,7 @@ from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
|
||||
from neutron.api.rpc.handlers import dhcp_rpc
|
||||
from neutron.api.rpc.handlers import dvr_rpc
|
||||
from neutron.api.rpc.handlers import metadata_rpc
|
||||
from neutron.api.rpc.handlers import resources_rpc
|
||||
from neutron.api.rpc.handlers import securitygroups_rpc
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.callbacks import events
|
||||
@@ -150,7 +151,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
dvr_rpc.DVRServerRpcCallback(),
|
||||
dhcp_rpc.DhcpRpcCallback(),
|
||||
agents_db.AgentExtRpcCallback(),
|
||||
metadata_rpc.MetadataRpcCallback()
|
||||
metadata_rpc.MetadataRpcCallback(),
|
||||
resources_rpc.ResourcesServerRpcCallback()
|
||||
]
|
||||
|
||||
def _setup_dhcp(self):
|
||||
|
||||
Reference in new issue
Block a user