def vc_agent(setup_platform): """ Gets the a volttron central proxy agent to test with. The return value is a tuple with the 0th position the instances of the proxy vc agent. The 1st position will be the identity of the vcp agent that vc should use as its identity for talking with the vcp instances. . note:: Please note that the agent is merely a proxy (mock) type of vc agent. :param setup_platform: :return: """ assert setup_platform.instance_name is not None setup_platform.allow_all_connections() gevent.sleep(5) add_volttron_central(setup_platform) agent = setup_platform.dynamic_agent vcp_identity = None look_for_identity = setup_platform.instance_name + ".platform.agent" print("looking for identity: {}".format(look_for_identity)) print("peerlist: {}".format( agent.vip.peerlist().get(timeout=STANDARD_GET_TIMEOUT))) for peer in agent.vip.peerlist().get(timeout=STANDARD_GET_TIMEOUT): # For vcp in this context there are two interfaces to the the connect. # the first is platform.agent and the second is <instancename>.platform.agent. if peer == look_for_identity: vcp_identity = peer break if vcp_identity is None: pytest.fail("vcp_identity was not connected to the instance.") gevent.sleep(5) yield agent, vcp_identity
def both_with_vc_vcp(request): """ Adds the volttron-central-address and volttron-central-serverkey to the main instance configuration file before starting the platform """ p = PlatformWrapper() if request.param[1] == 'local': start_wrapper_platform(p, with_http=True, add_local_vc_address=True) else: start_wrapper_platform(p, with_http=True) if request.param[0] == 'vcp-first': vcp_uuid = add_volttron_central_platform(p) vc_uuid = add_volttron_central(p) else: vc_uuid = add_volttron_central(p) vcp_uuid = add_volttron_central_platform(p) # Give the agents a chance to do stuff. note might take up to 10 sec # if the vcp is started first. gevent.sleep(10) yield p p.shutdown_platform()
def multi_messagebus_vc_vcp(volttron_multi_messagebus): vcp_instance, vc_instance = volttron_multi_messagebus() assert vcp_instance.instance_name != vc_instance.instance_name # Handles both connections to zmq as well as connections to rmq bus. vc_instance.allow_all_connections() vcp_uuid = add_volttron_central_platform(vcp_instance) vc_uuid = add_volttron_central(vc_instance) assert vcp_uuid assert vc_uuid print("VC LIST AGENTS: {}".format(vc_instance.list_agents())) print("VCP LIST AGENTS: {}".format(vcp_instance.list_agents())) # Update vcp_config store to add the volttron-central-address from vc to the # config store config = jsonapi.dumps({'volttron-central-address': vc_instance.bind_web_address}) # capabilities = {'edit_config_store': {'identity': VOLTTRON_CENTRAL_PLATFORM}} # vcp_instance.add_capabilities(vcp_instance.dynamic_agent.core.publickey, capabilities) vcp_instance.dynamic_agent.vip.rpc.call(CONFIGURATION_STORE, "manage_store", VOLTTRON_CENTRAL_PLATFORM, "config", config, "json").get() # "manage_store", opts.identity, opts.name, file_contents, config_type = opts.config_type yield vcp_instance, vc_instance, vcp_uuid vcp_instance.remove_agent(vcp_uuid) vc_instance.remove_agent(vc_uuid)
def vc_vcp_platforms(): """ This method returns two distinct platforms one vc and one vcp. When they are returned they should be registered together. This method will yield the two platforms as a tuple and then after the module is finished executing the cleanup of both will happen. """ vc = PlatformWrapper() vcp = PlatformWrapper() # VC is setup to allow all connections vc.allow_all_connections() start_wrapper_platform(vc, with_http=True) start_wrapper_platform(vcp, volttron_central_address=vc.vip_address, volttron_central_serverkey=vc.serverkey) vc_uuid = add_volttron_central(vc) vcp_uuid = add_volttron_central_platform(vcp) # Sleep so we know we are registered gevent.sleep(15) yield vc, vcp vc.shutdown_platform() vcp.shutdown_platform()
def vc_vcp_platforms(request): vc = PlatformWrapper() vcp = PlatformWrapper() # VC is setup to allow all connections vc.allow_all_connections() start_wrapper_platform(vc, with_http=True) if request.param == 'use-http': start_wrapper_platform(vcp, volttron_central_address=vc.bind_web_address) else: start_wrapper_platform(vcp, volttron_central_address=vc.vip_address, volttron_central_serverkey=vc.serverkey) vcp_uuid = add_volttron_central_platform(vcp) vc_uuid = add_volttron_central(vc) # Give the agents a chance to do stuff. Can take up to 10 seconds to # reconnect with vc. gevent.sleep(10) yield vc, vcp vc.shutdown_platform() vcp.shutdown_platform()
def multi_messagebus_vc_vcp(volttron_multi_messagebus): vcp_instance, vc_instance = volttron_multi_messagebus assert vcp_instance.instance_name != vc_instance.instance_name # Handles both connections to zmq as well as connections to rmq bus. vc_instance.allow_all_connections() if vc_instance.messagebus == 'rmq': if vcp_instance.messagebus == 'rmq': os.environ[ 'REQUESTS_CA_BUNDLE'] = vcp_instance.certsobj.remote_cert_bundle_file( ) else: os.environ[ 'REQUESTS_CA_BUNDLE'] = vc_instance.certsobj.remote_cert_bundle_file( ) vcp_uuid = add_volttron_central_platform(vcp_instance) vc_uuid = add_volttron_central(vc_instance) assert vcp_uuid assert vc_uuid print("VC LIST AGENTS: {}".format(vc_instance.list_agents())) print("VCP LIST AGENTS: {}".format(vcp_instance.list_agents())) # Update vcp_config store to add the volttron-central-address from vc to the # config store config = jsonapi.dumps( {'volttron-central-address': vc_instance.bind_web_address}) vcp_instance.dynamic_agent.vip.rpc.call(CONFIGURATION_STORE, "manage_store", VOLTTRON_CENTRAL_PLATFORM, "config", config, "json").get() # "manage_store", opts.identity, opts.name, file_contents, config_type = opts.config_type yield vcp_instance, vc_instance, vcp_uuid vcp_instance.remove_agent(vcp_uuid) vc_instance.remove_agent(vc_uuid)