def stop_qemu(conf_file=VM_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" # Set attributes compute.set_task_name("{}-node".format(node_name)) compute.set_log_path("/var/log/infrasim/{}/qemu.log". format(node_name)) compute.set_workspace("{}/.infrasim/{}". format(os.environ["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_port" in conf: compute.set_port_serial(conf["serial_port"]) if "bmc_connection_port" in conf: compute.set_port_qemu_ipmi(conf["bmc_connection_port"]) compute.init() compute.terminate() logger.info("qemu stopped") except Exception, e: logger.error(e.value) raise e
def start_qemu(conf_file=VM_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" workspace = "{}/.infrasim/{}".format(os.environ["HOME"], node_name) if not os.path.isdir(workspace): os.mkdir(workspace) path_log = "/var/log/infrasim/{}".format(node_name) if not os.path.isdir(path_log): os.mkdir(path_log) # Set attributes compute.set_task_name("{}-node".format(node_name)) compute.set_log_path("/var/log/infrasim/{}/qemu.log". format(node_name)) compute.set_workspace("{}/.infrasim/{}". format(os.environ["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_port" in conf: compute.set_port_serial(conf["serial_port"]) if "bmc_connection_port" in conf: compute.set_port_qemu_ipmi(conf["bmc_connection_port"]) compute.init() compute.precheck() compute.run() logger.info("qemu start") return except CommandRunFailed as e: logger.error(e.value) raise e except ArgsNotCorrect as e: logger.error(e.value) raise e