Neutron RPC API Layer
Client Side
Here is an example of an rpc client definition:
import oslo_messaging from neutron.common import rpc as n_rpc class ClientAPI(object):
"""Client side RPC interface definition. API version history:
1.0 - Initial version
1.1 - Added my_remote_method_2
""" def __init__(self, topic):
target = oslo_messaging.Target(topic=topic, version='1.0')
self.client = n_rpc.get_client(target) def my_remote_method(self, context, arg1, arg2):
cctxt = self.client.prepare()
return cctxt.call(context, 'my_remote_method', arg1=arg1, arg2=arg2) def my_remote_method_2(self, context, arg1):
cctxt = self.client.prepare(version='1.1')
return cctxt.call(context, 'my_remote_method_2', arg1=arg1)
my_remote_method 在v1中,
my_remote_method_2 v1.1中,当调用这个api是,其指定了server端至少实现了v1.1
Server Side
The server side of an rpc interface looks like this:
import oslo_messaging
class ServerAPI(object):
target = oslo_messaging.Target(version='1.1')
def my_remote_method(self, context, arg1, arg2):
return 'foo'
def my_remote_method_2(self, context, arg1):
return 'bar'
server端说明了支持v1.1
Versioning
rpc interfaces change必须向后兼容。server必须在同一大版本下支持旧的client。
Example Change
比如说my_remote_method_2里增加一个参数,该参数必须有个default值向后兼容,升级小版本
server side code would look like this:
import oslo_messaging
class ServerAPI(object):
target = oslo_messaging.Target(version='1.2')
def my_remote_method(self, context, arg1, arg2):
return 'foo'
def my_remote_method_2(self, context, arg1, arg2=None):
if not arg2:
# Deal with the fact that arg2 was not specified if needed.
return 'bar'
The client must also specify that version ‘1.2’ is required for this method call to be successful.
import oslo_messaging from neutron.common import rpc as n_rpc class ClientAPI(object):
"""Client side RPC interface definition. API version history:
1.0 - Initial version
1.1 - Added my_remote_method_2
1.2 - Added arg2 to my_remote_method_2
""" def __init__(self, topic):
target = oslo_messaging.Target(topic=topic, version='1.0')
self.client = n_rpc.get_client(target) def my_remote_method(self, context, arg1, arg2):
cctxt = self.client.prepare()
return cctxt.call(context, 'my_remote_method', arg1=arg1, arg2=arg2) def my_remote_method_2(self, context, arg1, arg2):
cctxt = self.client.prepare(version='1.2')
return cctxt.call(context, 'my_remote_method_2',
arg1=arg1, arg2=arg2)
Example: DHCP
The DHCP agent includes a client API, neutron.agent.dhcp.agent.DhcpPluginAPI.
The server side is defined in neutron.api.rpc.handlers.dhcp_rpc.DhcpRpcCallback.
Similarly, there is an RPC interface defined that allows the Neutron plugin to remotely invoke methods in the DHCP agent.
The client side is defined in neutron.api.rpc.agentnotifiers.dhcp_rpc_agent_api.DhcpAgentNotifyApi.
The server side of this interface that runs in the DHCP agent is neutron.agent.dhcp.agent.DhcpAgent.
http://docs.openstack.org/developer/neutron/devref/rpc_api.html
Neutron RPC API Layer的更多相关文章
- 人人都是 API 设计师:我对 RESTful API、GraphQL、RPC API 的思考
原文地址:梁桂钊的博客 博客地址:http://blog.720ui.com 欢迎关注公众号:「服务端思维」.一群同频者,一起成长,一起精进,打破认知的局限性. 有一段时间没怎么写文章了,今天提笔写一 ...
- Omnicore RPC API中文文档
2019独角兽企业重金招聘Python工程师标准>>> OmniCore是比特币核心的一个分支,它在比特币协议之上实现了一个新的Omni协议层,用于代币发行.众售等应用,USDT就是 ...
- supervisord支持扩展(xml RPC API & Third Party Applications and Libraries)
XML-RPC API Documentation http://www.supervisord.org/api.html Third Party Applications and Libraries ...
- [转]BTC RPC API GetTransaction
本文转自: GetTransaction GetTransaction gettransaction调用获取指定钱包内交易的详细信息.该调用需要节点 启用钱包功能. 参数 TXID:要查看详情的交易I ...
- nova event
nova处理neutron发送过来的event事件.暂时追踪nova event部分代码 tail -f /var/log/nova/nova-api.log 下面就是一个事件 Creating ...
- 【转】Git代码提交最佳实践
GIT Commit Good Practice The following document is based on experience doing code development, bug ...
- 以太坊RPC机制与API实例
上一篇文章介绍了以太坊的基础知识,我们了解了web3.js的调用方式是通过以太坊RPC技术,本篇文章旨在研究如何开发.编译.运行与使用以太坊RPC接口. 关键字:以太坊,RPC,JSON-RPC,cl ...
- neutron 的 quota design
发现, cinder, nova 制实现了, CountableResource. 只有nuetron实现了 TrackedResource 和 CountableResource. I read u ...
- neutron qos Quality of Service
Quality of Service advanced service is designed as a service plugin. The service is decoupled from t ...
随机推荐
- O(n)求素数,求欧拉函数,求莫比乌斯函数,求对mod的逆元,各种求
筛素数 void shai() { no[1]=true;no[0]=true; for(int i=2;i<=r;i++) { if(!no[i]) p[++p[0]]=i; int j=1, ...
- executable null\bin\winutils.exe in the Hadoop binaries.
在windows 使用eclipse远程调用hadoop集群时抛出下面异常 executable null\bin\winutils.exe in the Hadoop binaries. 这个问题 ...
- window mysql安装步骤
window安装mysql(本人系统win10 64位 安装mysql-5.7.10-winx64) 1. 官网下载mysql zip安装包,然后解压到你想安装的目录,假设解压的目录是P:\mysql ...
- 给定一个字符串s,你可以从中删除一些字符,使得剩下的串是一个回文串。如何删除才能使得回文串最长呢? 输出需要删除的字符个数。
// ConsoleApplication1.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include<iostream> ...
- onInterceptTouchEvent和onTouchEvent调用时序(转)
onInterceptTouchEvent和onTouchEvent调用时序 onInterceptTouchEvent()是ViewGroup的一个方法,目的是在系统向该ViewGroup及其各个c ...
- 【v2.x OGE教程 11】 动画编辑器帮助文档
] 动画编辑器帮助文档 版本号 日期 作者 说明 1.0 2014-9-3 橙子游戏 文档创建 一.简单介绍 动画编辑器用于游戏动画的可视化编辑,支持序列帧动画和关键帧动画.通过解析生成的 ...
- 基于SqlDependency的Asp.net数据缓存
首先,确保目标数据库的is_broker_enabled已经enabled. SELECT name, is_broker_enabled FROM sys.databases 如果不是enabled ...
- CAFFE学习笔记(二)Caffe_Example之测试mnist
这一次的博客将接着上一次的内容,简单讲解一下如何使用训练后的网络lenet_iter_5000.caffemodel与lenet_iter_10000.caffemodel. 1.在网络训练完毕后,将 ...
- Ogbect对象转换为泛型对象
相信很多人都自己写个这个转换的方法,再次附上我自己的写转换方法仅供参考. T t = BeanUtil.dbObject2Bean(obj, tClass); public static <T& ...
- zabbix server 端安装
1.系统环境 [root@crazy-acong ~]# cat /etc/redhat-release CentOS release 6.6 (Final) [root@crazy-acong ~] ...