Calling an @RPC method on a remote platform

时间:2017-08-30 20:51:36

标签: volttron

I have platform A and platform B and I want to call an RPC method on platform A from platform B. Note I've read this question already: In VOLTTRON, how to use VIP to get agents talk across remote platform instances? I feel like this might be outdated since it doesn't mention anything about the known hosts file and the new volttron-ctl auth add interface. Also do I still have to include that massive url mentioned in the comments with the serverkey, secretkey parameters? I also read the SimpleForwarder source code: https://github.com/VOLTTRON/volttron/blob/5cc71e9982338e242bf801da372aa66ed14abbd9/examples/SimpleForwarder/simpleforwarder/simpleforwarder.py The url for the vip connection in this example is: "destination-vip": "ipc://@/tmp/v4home/run/vip.socket", But this doesn't match the answers provided in the stack overflow question. http://volttron.readthedocs.io/en/4.1/core_services/messagebus/VIP/VIP-Authentication.html This section in the documentation gives some information about how to authenticate over vip, but what steps are needed with this to call an RPC in an agent on the other platform? Can someone clarify what is the updated way to do this (for volttron 4.1), hopefully step by step?

1 个答案:

答案 0 :(得分:2)

在远程代理上调用RPC调用与在另一个平台上执行pub / sub非常相似。对于一个工作示例,您可以咨询在远程历史数据库上调用RPC方法的DataMover代理。

首先,如果它位于已知的hosts文件中,它将获取目标的serverkey:

hosts = KnownHostsStore()
serverkey = hosts.serverkey(destination_vip)

如果没有,它将从代理配置文件中获取它。

然后,它的historian_setup方法使用vip agent utils中的building_agent方法通过传入address,serverkey,public和secret密钥来创建到另一个平台的链接,这样您就不必构造URL。 / p>

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)

此过程的步骤如下:

  1. 启动PlatformA并运行TargetAgent。
  2. 使用:vctl auth serverkey
  3. 检索PlatformA的serverkey
  4. 启动PlatformB
  5. 将PlatformA添加到PlatformB上的已知主机:vctl add-known-host --host tcp://tcp://xxx.xxx.xxx.xxx:YYYY --serverkey SERVERKEY_FOR_A 要么 使用步骤2中的serverkey配置PlatformB上的SendingAgent,PlatformA的目标VIP地址(tcp://xxx.xxx.xxx.xxx:YYYY)

  6. 在PlatformB上安装SendingAgent

  7. 使用以下内容检索SendingAgent的公钥:vctl auth publickey
  8. 使用:vctl auth add
  9. 将SendingAgent的凭据添加到PlatformA

    SendingAgent现在应该能够在TargetAgent上调用RPC方法