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的更多相关文章

  1. 人人都是 API 设计师:我对 RESTful API、GraphQL、RPC API 的思考

    原文地址:梁桂钊的博客 博客地址:http://blog.720ui.com 欢迎关注公众号:「服务端思维」.一群同频者,一起成长,一起精进,打破认知的局限性. 有一段时间没怎么写文章了,今天提笔写一 ...

  2. Omnicore RPC API中文文档

    2019独角兽企业重金招聘Python工程师标准>>> OmniCore是比特币核心的一个分支,它在比特币协议之上实现了一个新的Omni协议层,用于代币发行.众售等应用,USDT就是 ...

  3. supervisord支持扩展(xml RPC API & Third Party Applications and Libraries)

    XML-RPC API Documentation http://www.supervisord.org/api.html Third Party Applications and Libraries ...

  4. [转]BTC RPC API GetTransaction

    本文转自: GetTransaction GetTransaction gettransaction调用获取指定钱包内交易的详细信息.该调用需要节点 启用钱包功能. 参数 TXID:要查看详情的交易I ...

  5. nova event

    nova处理neutron发送过来的event事件.暂时追踪nova event部分代码 tail -f /var/log/nova/nova-api.log  下面就是一个事件  Creating ...

  6. 【转】Git代码提交最佳实践

      GIT Commit Good Practice The following document is based on experience doing code development, bug ...

  7. 以太坊RPC机制与API实例

    上一篇文章介绍了以太坊的基础知识,我们了解了web3.js的调用方式是通过以太坊RPC技术,本篇文章旨在研究如何开发.编译.运行与使用以太坊RPC接口. 关键字:以太坊,RPC,JSON-RPC,cl ...

  8. neutron 的 quota design

    发现, cinder, nova 制实现了, CountableResource. 只有nuetron实现了 TrackedResource 和 CountableResource. I read u ...

  9. neutron qos Quality of Service

    Quality of Service advanced service is designed as a service plugin. The service is decoupled from t ...

随机推荐

  1. Python内置函数之super()

    super(type[,object-or-type]) super()的作用在于类继承方面. 他可以实现不更改类内部代码,但是改变类的父类. 例子: 一般我们继承类的方式: >>> ...

  2. Window10 安装问题汇总

       7月28号之后,由于没有收到windows的升级提醒,所以下载了ISO文件手动进行了升级.      本文就升级过程中遇到的问题进行一下总结:    1.ISO文件名称:cn_windows_1 ...

  3. 关于ViewData,ViewBag,TempData三者学习记录!

    关于ViewData,ViewBag,TempData三者学习分享! 1.ViewData和TempData是字典类型,赋值方式用字典方式,ViewData["Key"] . 2. ...

  4. k8s部署dashborad

    环境: 两台虚拟机, 10.10.20.203 部署docker.etcd.flannel.kube-apiserver.kube-controller-manager.kube-scheduler ...

  5. 刨根问底 HTTP 和 WebSocket 协议(下)

    上篇介绍了HTTP1.1协议的基本内容,这篇文章将继续分析WebSocket协议,然后对这两个进行简单的比较. WebSocket WebSocket协议还很年轻,RFC文档相比HTTP的发布时间也很 ...

  6. .net 字符串驻留

    .net中的string表达的是常量字符串. JIT编译器编译时判断遇到的常量字符串是否在内部散列表中,如果不在,添加进去.当第一次执行到含字符串的方法时,CLR会检查该字符串是否在内部的一个散列表中 ...

  7. ASP.NET动态网站制作(23)-- ADO.NET(2)

    前言:这节课老师请高级班的E老师过来代课,还是接着老师讲的内容继续深入,修改了上节课老师写的部分代码. 内容: 1.数据库本质就是一个软件,这个软件帮助我们把数据有序地存储起来,当我们需要数据的时候帮 ...

  8. 【BZOJ3769】spoj 8549 BST again DP(记忆化搜索?)

    [BZOJ3769]spoj 8549 BST again Description 求有多少棵大小为n的深度为h的二叉树.(树根深度为0:左右子树有别:答案对1000000007取模) Input 第 ...

  9. [转]linux terminal中使用proxy

    转自:http://www.cnblogs.com/JoJosBizarreAdventure/p/5892383.html 在linux terminal中使用代理 方法一: terminal中输入 ...

  10. java并发编程基础---Sky

    1.线程及启动和终止 1.1 线程 -进程/优先级 操作系统调度的最小单元是线程,线程是轻量级进程. 线程优先级由setPriority(int)方法来设置,默认优先级是5,等级1~10.等级越高分的 ...