Calling an @RPC method on a remote platform

106 views Asked by At

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

There are 1 answers

1
Jereme Haack On BEST ANSWER

Calling an RPC call on a remote agent is very similar to performing pub/sub on another platform. For a working example, you can consult the DataMover agent which calls an RPC method on a remote historian.

First it gets the serverkey for the destination if it's in the known hosts file:

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

If not, it will get it from the agent configuration file.

Then, its historian_setup method uses the building_agent method in vip agent utils to create a link to the other platform by passing in address, serverkey, public, and secret key so you don't have to construct the 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)

Then when it does a publish it calls:

  self._target_platform.vip.rpc.call(
                self.destination_historian_identity, 'insert',
                to_send).get(timeout=10)

Steps for this process are:

  1. Start PlatformA with TargetAgent running.
  2. Retrieve serverkey for PlatformA with: vctl auth serverkey
  3. Start PlatformB
  4. Add PlatformA to known hosts on PlatformB: vctl add-known-host --host tcp://tcp://xxx.xxx.xxx.xxx:YYYY --serverkey SERVERKEY_FOR_A or Configure SendingAgent on PlatformB with serverkey from step 2, destination VIP address for PlatformA (tcp://xxx.xxx.xxx.xxx:YYYY)

  5. Install SendingAgent on PlatformB

  6. Retrieve the public key for SendingAgent with: vctl auth publickey
  7. Add SendingAgent's credentials to PlatformA with: vctl auth add

SendingAgent should now be able to call RPC methods on TargetAgent