def _shutdown_platform(): vhome = get_home() if is_volttron_running(vhome): if verbose: print('Shutting down platform...') _cmd(['volttron-ctl', 'shutdown', '--platform']) wait_for_volttron_shutdown(vhome, 45)
def test_zmq_case_web_no_agents(monkeypatch): with create_vcfg_vhome() as vhome: monkeypatch.setenv("VOLTTRON_HOME", vhome) config_path = os.path.join(vhome, "config") message_bus = "zmq" vip_address = "tcp://127.0.0.15" vip_port = "22916" instance_name = "test_zmq" is_web_enabled = "Y" web_protocol = "https" web_port = "8443" gen_web_cert = "Y" new_root_ca = "Y" ca_country = "US" ca_state = "test-state" ca_location = "test-location" ca_organization = "test-org" ca_org_unit = "test-org-unit" is_vc = "N" is_vcp = "N" install_historian = "N" install_driver = "N" install_listener = "N" vcfg_args = "\n".join([ message_bus, vip_address, vip_port, instance_name, is_web_enabled, web_protocol, web_port, gen_web_cert, new_root_ca, ca_country, ca_state, ca_location, ca_organization, ca_org_unit, is_vc, is_vcp, install_historian, install_driver, install_listener ]) with subprocess.Popen(["vcfg", "--vhome", vhome], env=os.environ, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) as vcfg: out, err = vcfg.communicate(vcfg_args) assert os.path.exists(config_path) config = ConfigParser() config.read(config_path) assert config.get('volttron', 'message-bus') == "zmq" assert config.get('volttron', 'vip-address') == "tcp://127.0.0.15:22916" assert config.get('volttron', 'instance-name').strip('"') == "test_zmq" assert config.get('volttron', 'bind-web-address') == "{}{}{}".format( "https://", get_hostname().lower(), ":8443") assert config.get('volttron', 'web-ssl-cert') == os.path.join( vhome, "certificates", "certs", "platform_web-server.crt") assert config.get('volttron', 'web-ssl-key') == os.path.join( vhome, "certificates", "private", "platform_web-server.pem") assert not _is_agent_installed("listener") assert not _is_agent_installed("platform_driver") assert not _is_agent_installed("platform_historian") assert not _is_agent_installed("vc ") assert not _is_agent_installed("vcp") assert not is_volttron_running(vhome)
def test_rmq_case_web_vc_with_agents(monkeypatch): with create_vcfg_vhome() as vhome: monkeypatch.setenv("VOLTTRON_HOME", vhome) monkeypatch.setenv("RABBITMQ_CONF_ENV_FILE", "") config_path = os.path.join(vhome, "config") message_bus = "rmq" instance_name = "test_rmq" vip_address = "tcp://127.0.0.15" vip_port = "22916" is_web_enabled = "Y" web_port = "8443" is_vc = "Y" is_vcp = "Y" install_historian = "Y" install_driver = "Y" install_fake_device = "Y" install_listener = "Y" agent_autostart = "N" create_rmq_volttron_setup(vhome=vhome, env=os.environ, ssl_auth=True, instance_name=instance_name) vcfg_args = "\n".join([ message_bus, vip_address, vip_port, instance_name, is_web_enabled, web_port, is_vc, agent_autostart, is_vcp, agent_autostart, install_historian, agent_autostart, install_driver, install_fake_device, agent_autostart, install_listener, agent_autostart ]) with subprocess.Popen(["vcfg", "--vhome", vhome], env=os.environ, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) as vcfg: out, err = vcfg.communicate(vcfg_args) assert os.path.exists(config_path) config = ConfigParser() config.read(config_path) assert config.get('volttron', 'message-bus') == "rmq" assert config.get('volttron', 'vip-address') == "tcp://127.0.0.15:22916" assert config.get('volttron', 'instance-name').strip('"') == "test_rmq" assert config.get('volttron', 'volttron-central-address') == "{}{}{}".format( "https://", get_hostname(), ":8443") assert config.get('volttron', 'bind-web-address') == "{}{}{}".format( "https://", get_hostname(), ":8443") assert _is_agent_installed("listener") assert _is_agent_installed("platform_driver") assert _is_agent_installed("platform_historian") assert _is_agent_installed("vc ") assert _is_agent_installed("vcp") assert not is_volttron_running(vhome)
def _cleanup_on_exit(): vhome = get_home() retry_attempt = 30 while retry_attempt > 0: if is_volttron_running(vhome): time.sleep(1) retry_attempt -= 1 else: return _shutdown_platform()
def fail_if_instance_running(): home = get_home() if os.path.exists(home) and\ is_volttron_running(home): print(""" The current instance is running. In order to configure an instance it cannot be running. Please execute: volttron-ctl shutdown --platform to stop the instance. """) sys.exit()
def test_zmq_case_no_agents(monkeypatch): with create_vcfg_vhome() as vhome: monkeypatch.setenv("VOLTTRON_HOME", vhome) config_path = os.path.join(vhome, "config") message_bus = "zmq" vip_address = "tcp://127.0.0.15" vip_port = "22916" instance_name = "test_zmq" is_web_enabled = "N" is_vcp = "N" install_historian = "N" install_driver = "N" install_listener = "N" vcfg_args = "\n".join([ message_bus, vip_address, vip_port, instance_name, is_web_enabled, is_vcp, install_historian, install_driver, install_listener ]) with subprocess.Popen(["vcfg", "--vhome", vhome], env=os.environ, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) as vcfg: out, err = vcfg.communicate(vcfg_args) #print("CWD is: {}".format(os.getcwd())) #print("OUT is: {}".format(out)) #print("ERROR is: {}".format(err)) assert os.path.exists(config_path) config = ConfigParser() config.read(config_path) assert config.get('volttron', 'message-bus') == "zmq" assert config.get('volttron', 'vip-address') == "tcp://127.0.0.15:22916" assert config.get('volttron', 'instance-name').strip('"') == "test_zmq" assert not _is_agent_installed("listener") assert not _is_agent_installed("platform_driver") assert not _is_agent_installed("platform_historian") assert not _is_agent_installed("vc ") assert not _is_agent_installed("vcp") assert not is_volttron_running(vhome)