def start_ipmi(conf_file=config.infrasim_default_config): try: with open(conf_file, 'r') as f_yml: conf = yaml_load(f_yml) node = CNode(node_info=conf) if "name" in conf: node.set_node_name(conf["name"]) node.init() bmc = CBMC(conf.get('bmc', {})) node_name = conf["name"] if "name" in conf else "node-0" bmc.set_task_name("{}-bmc".format(node_name)) bmc.set_log_path(os.path.join(config.infrasim_log_dir, node_name, "openipmi.log")) bmc.set_type(conf["type"]) bmc.enable_sol(False) bmc.set_workspace(node.workspace.get_workspace()) bmc.init() bmc.precheck() cmd = bmc.get_commandline() logger.debug(cmd) run_command(cmd + " &", True, None, None) logger.info("bmc start") except CommandRunFailed as e: logger.error(e.value) raise e except ArgsNotCorrect as e: logger.error(e.value) raise e except InfraSimError as e: logger.error(e.value) raise e
def start_ipmi(conf_file=config.infrasim_default_config): try: with open(conf_file, 'r') as f_yml: conf = yaml_load(f_yml) node = CNode(node_info=conf) if "name" in conf: node.set_node_name(conf["name"]) node.init() bmc = CBMC(conf.get('bmc', {})) node_name = conf["name"] if "name" in conf else "node-0" bmc.set_task_name("{}-bmc".format(node_name)) bmc.set_log_path( os.path.join(config.infrasim_log_dir, node_name, "openipmi.log")) bmc.set_type(conf["type"]) bmc.enable_sol(False) bmc.set_workspace(node.workspace.get_workspace()) bmc.init() bmc.precheck() cmd = bmc.get_commandline() logger.debug(cmd) run_command(cmd + " &", True, None, None) logger.info("bmc start") except CommandRunFailed as e: logger.error(e.value) raise e except ArgsNotCorrect as e: logger.error(e.value) raise e except InfraSimError as e: logger.error(e.value) raise e
def start_socat(conf_file=config.infrasim_default_config): try: with open(conf_file, 'r') as f_yml: conf = yaml_load(f_yml) node = CNode(conf) if "name" in conf: node.set_node_name(conf["name"]) node.init() socat = CSocat() # Read SOL device, serial port from conf # and set to socat if "sol_device" in conf: socat.set_sol_device(conf["sol_device"]) if "serial_socket" in conf: socat.set_socket_serial(conf["serial_socket"]) socat.set_workspace(node.workspace.get_workspace()) socat.init() socat.precheck() cmd = socat.get_commandline() run_command(cmd + " &", True, None, None) time.sleep(3) logger.info("socat start") except CommandRunFailed as e: logger.error(e.value) raise e except InfraSimError as e: logger.error(e.value) raise e
def stop_qemu(conf_file=config.infrasim_default_config): try: with open(conf_file, 'r') as f_yml: conf = yaml_load(f_yml) compute = CCompute(conf["compute"]) node_name = conf["name"] if "name" in conf else "node-0" logger_qemu = infrasim_log.get_logger(LoggerType.qemu.value, node_name) # Set attributes compute.logger = infrasim_log.get_logger(LoggerType.model.value, node_name) compute.set_task_name("{}-node".format(node_name)) compute.set_log_path(os.path.join(config.infrasim_log_dir, node_name, "qemu.log")) compute.set_workspace(os.path.join(config.infrasim_home, node_name)) compute.set_type(conf["type"]) # Set interface if "type" not in conf: raise ArgsNotCorrect("Can't get infrasim type") else: compute.set_type(conf['type']) if "serial_socket" in conf: compute.set_socket_serial(conf["serial_socket"]) if "bmc_connection_port" in conf: compute.set_port_qemu_ipmi(conf["bmc_connection_port"]) compute.init() compute.terminate() logger_qemu.info("qemu stopped") except InfraSimError as e: logger_qemu.exception(e.value) raise e
def tearDownClass(cls): with open(cls.TMP_CONF_FILE, "r") as yml_file: node_info = yaml_load(yml_file) node = CNode(node_info) node.init() node.stop() if os.path.exists(cls.TMP_CONF_FILE): os.unlink(cls.TMP_CONF_FILE) workspace = os.path.join(config.infrasim_home, "test") if os.path.exists(workspace): shutil.rmtree(workspace)
def tearDownClass(cls): cls.channel.close() cls.ssh.close() with open(cls.TMP_CONF_FILE, "r") as yml_file: node_info = yaml_load(yml_file) ipmiconsole.stop(node_info["name"]) node = CNode(node_info) node.init() node.stop() if os.path.exists(cls.TMP_CONF_FILE): os.unlink(cls.TMP_CONF_FILE) workspace = os.path.join(config.infrasim_home, "test") if os.path.exists(workspace): shutil.rmtree(workspace)
def stop_qemu(conf_file=config.infrasim_default_config): try: with open(conf_file, 'r') as f_yml: conf = yaml_load(f_yml) compute = CCompute(conf["compute"]) node_name = conf["name"] if "name" in conf else "node-0" logger_qemu = infrasim_log.get_logger(LoggerType.qemu.value, node_name) # Set attributes compute.logger = infrasim_log.get_logger(LoggerType.model.value, node_name) compute.set_task_name("{}-node".format(node_name)) compute.set_log_path( os.path.join(config.infrasim_log_dir, node_name, "qemu.log")) compute.set_workspace(os.path.join(config.infrasim_home, node_name)) compute.set_type(conf["type"]) # Set interface if "type" not in conf: raise ArgsNotCorrect("Can't get infrasim type") else: compute.set_type(conf['type']) if "serial_socket" in conf: compute.set_socket_serial(conf["serial_socket"]) if "bmc_connection_port" in conf: compute.set_port_qemu_ipmi(conf["bmc_connection_port"]) compute.init() compute.terminate() logger_qemu.info("qemu stopped") except InfraSimError as e: logger_qemu.exception(e.value) raise e
def start_qemu(conf_file=config.infrasim_default_config): try: with open(conf_file, 'r') as f_yml: conf = yaml_load(f_yml) compute = CCompute(conf["compute"]) node_name = conf["name"] if "name" in conf else "node-0" logger_qemu = infrasim_log.get_logger(LoggerType.qemu.value, node_name) workspace = os.path.join(config.infrasim_home, node_name) if not os.path.isdir(workspace): os.mkdir(workspace) path_log = os.path.join(config.infrasim_log_dir, node_name) compute.logger = infrasim_log.get_logger(LoggerType.model.value, node_name) if not os.path.isdir(path_log): os.mkdir(path_log) sol_enabled = conf["sol_enable"] if "sol_enable" in conf else True compute.netns = conf.get("namespace") # Set attributes compute.enable_sol(sol_enabled) compute.set_task_name("{}-node".format(node_name)) compute.set_log_path(os.path.join(path_log, "qemu.log")) compute.set_workspace(workspace) compute.set_type(conf["type"]) # Set interface if "type" not in conf: raise ArgsNotCorrect("Can't get infrasim type") else: compute.set_type(conf['type']) if "serial_socket" in conf: compute.set_socket_serial(conf["serial_socket"]) if "bmc_connection_port" in conf: compute.set_port_qemu_ipmi(conf["bmc_connection_port"]) if "monitor" not in conf: b_enable_monitor = True else: b_enable_monitor = conf["monitor"].get("enable", True) if not isinstance(b_enable_monitor, bool): raise ArgsNotCorrect("[Monitor] Invalid setting") if b_enable_monitor: compute.enable_qemu_monitor() compute.init() compute.precheck() compute.run() logger_qemu.info("qemu start") return except InfraSimError as e: logger_qemu.exception(e.value) raise e
def start_qemu(conf_file=config.infrasim_default_config): try: with open(conf_file, 'r') as f_yml: conf = yaml_load(f_yml) compute = CCompute(conf["compute"]) node_name = conf["name"] if "name" in conf else "node-0" logger_qemu = infrasim_log.get_logger( LoggerType.qemu.value, node_name) workspace = os.path.join(config.infrasim_home, node_name) if not os.path.isdir(workspace): os.mkdir(workspace) path_log = os.path.join(config.infrasim_log_dir, node_name) compute.logger = infrasim_log.get_logger(LoggerType.model.value, node_name) if not os.path.isdir(path_log): os.mkdir(path_log) sol_enabled = conf["sol_enable"] if "sol_enable" in conf else True compute.netns = conf.get("namespace") # Set attributes compute.enable_sol(sol_enabled) compute.set_task_name("{}-node".format(node_name)) compute.set_log_path(os.path.join(path_log, "qemu.log")) compute.set_workspace(workspace) compute.set_type(conf["type"]) # Set interface if "type" not in conf: raise ArgsNotCorrect("Can't get infrasim type") else: compute.set_type(conf['type']) if "serial_socket" in conf: compute.set_socket_serial(conf["serial_socket"]) if "bmc_connection_port" in conf: compute.set_port_qemu_ipmi(conf["bmc_connection_port"]) if "monitor" not in conf: b_enable_monitor = True else: b_enable_monitor = conf["monitor"].get("enable", True) if not isinstance(b_enable_monitor, bool): raise ArgsNotCorrect("[Monitor] Invalid setting") if b_enable_monitor: compute.enable_qemu_monitor() compute.init() compute.precheck() compute.run() logger_qemu.info("qemu start") return except InfraSimError as e: logger_qemu.exception(e.value) raise e