def load_global_config(self): """ Load global configure in the path DTS_ROOT_PAHT/conf. """ conf = VirtConf(VIRTCONF) conf.load_virt_config(self.virt_type) global_conf = conf.get_virt_config() for param in global_conf: for key in param.keys(): if self.find_option_index(key) is None: self.__save_local_config(key, param[key])
def load_config(self): try: self.vm_confs = {} conf = VirtConf(CONFIG_ROOT_PATH + 'scene/' + self.name + '.cfg') self.sections = conf.virt_conf.get_sections() for vm in self.sections: conf.load_virt_config(vm) vm_conf = conf.get_virt_config() self.vm_confs[vm] = vm_conf except: raise VirtConfigParseException
def VM(dut, vm_name, suite_name): conf = VirtConf(CONFIG_ROOT_PATH + os.sep + suite_name + '.cfg') conf.load_virt_config(vm_name) local_conf = conf.get_virt_config() # Default virt_type is 'KVM' virt_type = 'KVM' for param in local_conf: if 'virt_type' in param.keys(): virt_type = param['virt_type'][0]['virt_type'] if virt_type == 'KVM': return QEMUKvm(dut, vm_name, suite_name) elif virt_type == 'LIBVIRT': return LibvirtKvm(dut, vm_name, suite_name) else: raise Exception("Virt type %s is not supported!" % virt_type)
def load_local_config(self, suite_name): """ Load local configure in the path DTS_ROOT_PATH/conf. """ # load local configuration by suite and vm name conf = VirtConf(CONFIG_ROOT_PATH + suite_name + '.cfg') conf.load_virt_config(self.vm_name) local_conf = conf.get_virt_config() # replace global configurations with local configurations for param in local_conf: if 'mem' in param.keys(): self.__save_local_config('mem', param['mem']) continue if 'cpu' in param.keys(): self.__save_local_config('cpu', param['cpu']) continue # save local configurations for key in param.keys(): self.__save_local_config(key, param[key])
def load_local_config(self, suite_name): """ Load local configure in the path DTS_ROOT_PATH/conf. """ # load local configuration by suite and vm name try: conf = VirtConf(CONFIG_ROOT_PATH + os.sep + suite_name + '.cfg') conf.load_virt_config(self.vm_name) self.local_conf = conf.get_virt_config() except: # when met exception in load VM config # just leave local conf untouched pass # replace global configurations with local configurations for param in self.local_conf: if 'virt_type' in param.keys(): # param 'virt_type' is for virt_base only continue # save local configurations for key in param.keys(): self.__save_local_config(key, param[key])