在远程平台上调用@RPC 方法
Calling an @RPC method on a remote platform
我有平台 A 和平台 B,我想从平台 B 调用平台 A 上的 RPC 方法。注意我已经读过这个问题:
In VOLTTRON, how to use VIP to get agents talk across remote platform instances?
我觉得这可能已经过时了,因为它没有提及任何关于已知主机文件和新的 volttron-ctl auth add 接口的信息。另外,我是否还必须将评论中提到的大量 url 包含在 serverkey、secretkey 参数中?我还阅读了 SimpleForwarder 源代码:
https://github.com/VOLTTRON/volttron/blob/5cc71e9982338e242bf801da372aa66ed14abbd9/examples/SimpleForwarder/simpleforwarder/simpleforwarder.py
本例中 vip 连接的 url 是:
"destination-vip": "ipc://@/tmp/v4home/run/vip.socket",
但这与堆栈溢出问题中提供的答案不符。
http://volttron.readthedocs.io/en/4.1/core_services/messagebus/VIP/VIP-Authentication.html
文档中的这一部分提供了一些有关如何通过 vip 进行身份验证的信息,但是需要执行哪些步骤才能在其他平台上的代理中调用 RPC?有人可以阐明执行此操作的更新方法是什么(对于 volttron 4.1),希望一步一步吗?
在远程代理上调用 RPC 调用与在另一个平台上执行 pub/sub 非常相似。对于一个工作示例,您可以参考 DataMover 代理,它在远程历史记录上调用 RPC 方法。
如果目的地在已知的主机文件中,它首先获取目的地的服务器密钥:
hosts = KnownHostsStore()
serverkey = hosts.serverkey(destination_vip)
如果没有,它将从代理配置文件中获取。
然后,它的historian_setup方法使用vip agent utils中的building_agent方法,通过传入address,serverkey,[=58]创建一个给对方平台的link =], 和密钥所以你不必构造 URL.
self._target_platform = build_agent(address=self.destination_vip,
serverkey=self.destination_serverkey,
publickey=self.core.publickey,
secretkey=self.core.secretkey,
enable_store=False)
然后在发布时调用:
self._target_platform.vip.rpc.call(
self.destination_historian_identity, 'insert',
to_send).get(timeout=10)
此过程的步骤是:
- 使用 TargetAgent 启动 PlatformA 运行。
- 检索 PlatformA 的服务器密钥:
vctl auth serverkey
- 启动平台B
将平台 A 添加到平台 B 上的已知主机:vctl add-known-host --host tcp://tcp://xxx.xxx.xxx.xxx:YYYY --serverkey SERVERKEY_FOR_A
要么
使用步骤 2 中的服务器密钥在 PlatformB 上配置 SendingAgent,PlatformA 的目标 VIP 地址 (tcp://xxx.xxx.xxx.xxx:YYYY)
在 PlatformB 上安装 SendingAgent
- 检索 SendingAgent 的 public 密钥:
vctl auth publickey
- 将 SendingAgent 的凭据添加到平台 A:
vctl auth add
SendingAgent 现在应该能够调用 TargetAgent 上的 RPC 方法
我有平台 A 和平台 B,我想从平台 B 调用平台 A 上的 RPC 方法。注意我已经读过这个问题: In VOLTTRON, how to use VIP to get agents talk across remote platform instances? 我觉得这可能已经过时了,因为它没有提及任何关于已知主机文件和新的 volttron-ctl auth add 接口的信息。另外,我是否还必须将评论中提到的大量 url 包含在 serverkey、secretkey 参数中?我还阅读了 SimpleForwarder 源代码: https://github.com/VOLTTRON/volttron/blob/5cc71e9982338e242bf801da372aa66ed14abbd9/examples/SimpleForwarder/simpleforwarder/simpleforwarder.py 本例中 vip 连接的 url 是: "destination-vip": "ipc://@/tmp/v4home/run/vip.socket", 但这与堆栈溢出问题中提供的答案不符。 http://volttron.readthedocs.io/en/4.1/core_services/messagebus/VIP/VIP-Authentication.html 文档中的这一部分提供了一些有关如何通过 vip 进行身份验证的信息,但是需要执行哪些步骤才能在其他平台上的代理中调用 RPC?有人可以阐明执行此操作的更新方法是什么(对于 volttron 4.1),希望一步一步吗?
在远程代理上调用 RPC 调用与在另一个平台上执行 pub/sub 非常相似。对于一个工作示例,您可以参考 DataMover 代理,它在远程历史记录上调用 RPC 方法。
如果目的地在已知的主机文件中,它首先获取目的地的服务器密钥:
hosts = KnownHostsStore()
serverkey = hosts.serverkey(destination_vip)
如果没有,它将从代理配置文件中获取。
然后,它的historian_setup方法使用vip agent utils中的building_agent方法,通过传入address,serverkey,[=58]创建一个给对方平台的link =], 和密钥所以你不必构造 URL.
self._target_platform = build_agent(address=self.destination_vip,
serverkey=self.destination_serverkey,
publickey=self.core.publickey,
secretkey=self.core.secretkey,
enable_store=False)
然后在发布时调用:
self._target_platform.vip.rpc.call(
self.destination_historian_identity, 'insert',
to_send).get(timeout=10)
此过程的步骤是:
- 使用 TargetAgent 启动 PlatformA 运行。
- 检索 PlatformA 的服务器密钥:
vctl auth serverkey
- 启动平台B
将平台 A 添加到平台 B 上的已知主机:
vctl add-known-host --host tcp://tcp://xxx.xxx.xxx.xxx:YYYY --serverkey SERVERKEY_FOR_A
要么 使用步骤 2 中的服务器密钥在 PlatformB 上配置 SendingAgent,PlatformA 的目标 VIP 地址 (tcp://xxx.xxx.xxx.xxx:YYYY)在 PlatformB 上安装 SendingAgent
- 检索 SendingAgent 的 public 密钥:
vctl auth publickey
- 将 SendingAgent 的凭据添加到平台 A:
vctl auth add
SendingAgent 现在应该能够调用 TargetAgent 上的 RPC 方法