def precheck(self): # check if qemu-system-x86_64 exists # if self.__qemu_bin is an absolute path, check if it exists if not self.__qemu_bin.startswith("qemu"): try: run_command("which {}".format(self.__qemu_bin)) except CommandRunFailed: self.logger.exception("[Compute] Can not find file {}".format( self.__qemu_bin)) raise CommandNotFound(self.__qemu_bin) # check if smbios exists if not os.path.isfile(self.__smbios): raise ArgsNotCorrect( "[Compute] Target SMBIOS file doesn't exist: {}".format( self.__smbios)) if self.__kernel and os.path.exists(self.__kernel) is False: raise ArgsNotCorrect("[Compute] Kernel {} does not exist.".format( self.__kernel)) if self.__initrd and os.path.exists(self.__initrd) is False: raise ArgsNotCorrect("[Compute] Kernel {} does not exist.".format( self.__initrd)) # check if VNC port is in use if helper.check_if_port_in_use("0.0.0.0", self.__display + 5900): raise ArgsNotCorrect( "[Compute] VNC port {} is already in use.".format( self.__display + 5900)) # check sub-elements for element in self.__element_list: element.precheck() if 'boot' in self.__compute: if 'menu' in self.__compute['boot']: if isinstance(self.__compute['boot']['menu'], str): menu_option = str( self.__compute['boot']['menu']).strip(" ").lower() if menu_option not in ["on", "off"]: msg = "[Compute] Error: illegal config option. " \ "The 'menu' must be either 'on' or 'off'." raise ArgsNotCorrect(msg) elif not isinstance(self.__compute['boot']['menu'], bool): msg = "[Compute] Error: illegal config option. The 'menu' " \ "must be either 'on' or 'off'." raise ArgsNotCorrect(msg) # check kvm enabled is bool if self.__enable_kvm is not True and self.__enable_kvm is not False: raise ArgsNotCorrect( "[Compute] KVM enabled is not a boolean: {}".format( self.__enable_kvm))
def precheck(self): # check if socat exists try: code, socat_cmd = run_command("which socat") self.__bin = socat_cmd.strip(os.linesep) except CommandRunFailed: self.logger.exception("[Socat] Can't find file socat") raise CommandNotFound("socat") if not self.__sol_device: raise ArgsNotCorrect("[Socat] No SOL device is defined") if not self.__socket_serial: raise ArgsNotCorrect( "[Socat] No socket file for serial is defined")
def precheck(self): # check if ipmi_sim exists try: run_command("which {}".format(self.__bin)) except CommandRunFailed: self.logger.exception("[BMC] Cannot find {}".format(self.__bin)) raise CommandNotFound(self.__bin) # check configuration file exists if not os.path.isfile(self.__config_file): raise ArgsNotCorrect( "[BMC] Target config file doesn't exist: {}".format( self.__config_file)) if not os.path.isfile(self.__emu_file): raise ArgsNotCorrect( "[BMC] Target emulation file doesn't exist: {}".format( self.__emu_file)) # check script exists if not os.path.exists(self.__lancontrol_script): raise ArgsNotCorrect( "[BMC] Lan control script {} doesn\'t exist".format( self.__lancontrol_script)) if not os.path.exists(self.__chassiscontrol_script): raise ArgsNotCorrect( "[BMC] Chassis control script {} doesn\'t exist".format( self.__chassiscontrol_script)) if not os.path.exists(self.__startcmd_script): raise ArgsNotCorrect( "[BMC] startcmd script {} doesn\'t exist".format( self.__startcmd_script)) if not os.path.exists(self.__workspace): raise ArgsNotCorrect("[BMC] workspace {} doesn\'t exist".format( self.__workspace)) # check if main channel is included in all lan channels if self.__main_channel not in self.__channels: raise ArgsNotCorrect( "[BMC] main channel {} should be included in channels {}". format(self.__main_channel, self.__channels)) # check if self.__port_qemu_ipmi in use if helper.check_if_port_in_use("0.0.0.0", self.__port_qemu_ipmi): raise ArgsNotCorrect("[BMC] Port {} is already in use.".format( self.__port_qemu_ipmi)) if helper.check_if_port_in_use("0.0.0.0", self.__port_ipmi_console): raise ArgsNotCorrect("[BMC] Port {} is already in use.".format( self.__port_ipmi_console)) # check lan interface exists if self.__lan_interface not in helper.get_all_interfaces(): self.logger.warning( "[BMC] Specified BMC interface {} doesn\'t exist.".format( self.__lan_interface)) # check if lan interface has IP address elif not self.__ipmi_listen_range: self.logger.warning( "[BMC] No IP is found on BMC interface {}.".format( self.__lan_interface)) # check attribute if self.__poweroff_wait < 0: raise ArgsNotCorrect("[BMC] poweroff_wait is expected to be >= 0, " "it's set to {} now".format( self.__poweroff_wait)) if not isinstance(self.__poweroff_wait, int): raise ArgsNotCorrect( "[BMC] poweroff_wait is expected to be integer, " "it's set to {} now".format(self.__poweroff_wait)) if self.__kill_wait < 0: raise ArgsNotCorrect("[BMC] kill_wait is expected to be >= 0, " "it's set to {} now".format(self.__kill_wait)) if not isinstance(self.__kill_wait, int): raise ArgsNotCorrect("[BMC] kill_wait is expected to be integer, " "it's set to {} now".format(self.__kill_wait)) if self.__port_iol < 0: raise ArgsNotCorrect( "[BMC] Port for IOL(IPMI over LAN) is expected " "to be >= 0, it's set to {} now".format(self.__port_iol)) if not isinstance(self.__port_iol, int): raise ArgsNotCorrect( "[BMC] Port for IOL(IPMI over LAN) is expected " "to be integer, it's set to {} now".format(self.__port_iol)) if self.__historyfru < 0: raise ArgsNotCorrect("[BMC] History FRU is expected to be >= 0, " "it's set to {} now".format( self.__historyfru)) if not isinstance(self.__historyfru, int): raise ArgsNotCorrect( "[BMC] History FRU is expected to be integer, " "it's set to {} now".format(self.__historyfru)) self.__check_peer_bmc_info()