def iothread_id(self): iothreads = self.params['iothreads'] if 'iothreadids' not in self.params: self.params['iothreadids'] = set() ids = self.params['iothreadids'] tid = utils_random.integer(0, iothreads) while tid in ids and len(ids) < iothreads: tid = utils_random.integer(0, iothreads) self.params['iothreadids'].add(tid) return str(tid)
def hexdec(self): min_val = 0 max_val = 9999 only_dec = False if 'pciDomain' in self.node_path: pass elif 'pciBus' in self.node_path: max_val = 99 elif 'pciSlot' in self.node_path: min_val = 1 max_val = 19 elif 'pciFunc' in self.node_path: max_val = 7 elif 'usbAddr' in self.node_path: max_val = 999 only_dec = True elif 'usbClass' in self.node_path: max_val = 99 elif 'usbId' in self.node_path: pass n = utils_random.integer(min_val, max_val) if only_dec: s = str(n) else: s = random.choice([str(n), hex(n)]) return s
def actual_mem_unit(self): maxmem, _ = self.get_max_mem() actmem = utils_random.integer(1, maxmem) unit = 'eib' while actmem <= UNIT_MAP[unit]: unit = random.choice(UNIT_MAP.keys()) actmem /= UNIT_MAP[unit] actmem *= UNIT_MAP[unit] self.params['actmem'] = actmem self.params['actmem_unit'] = unit return str(unit)
def get_max_mem(self): if 'maxmem' in self.params: maxmem = self.params['maxmem'] unit = self.params['maxmem_unit'] else: maxmem = utils_random.integer(1, 10000000) unit = 'eib' while maxmem <= UNIT_MAP[unit]: unit = random.choice(UNIT_MAP.keys()) maxmem /= UNIT_MAP[unit] maxmem *= UNIT_MAP[unit] self.params['maxmem'] = maxmem self.params['maxmem_unit'] = unit return maxmem, unit
def cell_memory(self): maxmem, _ = self.get_max_mem() if 'left_numa_mem' not in self.params: self.params['left_numa_mem'] = maxmem left_mem = self.params['left_numa_mem'] mem = utils_random.integer(1, left_mem) unit = 'eib' while mem <= UNIT_MAP[unit]: unit = random.choice(UNIT_MAP.keys()) mem /= UNIT_MAP[unit] mem *= UNIT_MAP[unit] self.params['left_numa_mem'] -= mem self.params['cell_mem_unit'] = unit #print 'cell', self.params['left_numa_mem'], self.params['cell_mem_unit'] return str(mem / UNIT_MAP[self.params['cell_mem_unit']])
def cur_mem_unit(self): actmem = self.params['actmem'] curmem = utils_random.integer(1, actmem) unit = 'eib' while curmem <= UNIT_MAP[unit]: #print unit, UNIT_MAP.keys() unit = random.choice(UNIT_MAP.keys()) curmem /= UNIT_MAP[unit] curmem *= UNIT_MAP[unit] self.params['curmem'] = curmem self.params['curmem_unit'] = unit #print 'maxmem', self.params['maxmem'], self.params['maxmem_unit'] #print 'actmem', self.params['actmem'], self.params['actmem_unit'] #print 'curmem', self.params['curmem'], self.params['curmem_unit'] return str(unit)
def route_netmask(self): def _ip2int(addr): return struct.unpack("!I", socket.inet_aton(addr))[0] def _int2ip(addr): return socket.inet_ntoa(struct.pack("!I", addr)) address = self.cur_xml.get('address') if ':' in address: return self.go_on() int_addr = _ip2int(address) prefix = utils_random.integer(0, 32) int_nm = (2**prefix - 1) * 2**(32 - prefix) netmask = _int2ip(int_nm) address = _int2ip(int_nm & int_addr) self.cur_xml.set('address', address) return netmask
def iothreads(self): self.params['iothreads'] = utils_random.integer(1, 1000) return str(self.params['iothreads'])
def hyperv_spinlock_retries(self): retries = utils_random.integer(4095, 100000000) return str(retries)
def hostdev_device(self): # TODO: There should be a bug dev = utils_random.integer(0, 99999) return str(dev)
def iothreadpin_iothread(self): iothreads = self.params['iothreads'] iothread = utils_random.integer(0, iothreads) return str(iothread)
def usbport(self): max_val = 999 cnt = utils_random.integer(1, 4) return '.'.join([str(utils_random.integer(0, max_val)) for i in xrange(cnt)])
def numatune_cellid(self): n = utils_random.integer(0, self.params['numa_maxid']) return str(n)
def idmap(self): if self.xml.find('./idmap/uid') is None: return max_vcpu = self.get_max_vcpu() return utils_random.integer(1, max_vcpu)
def current_vcpu(self): max_vcpu = self.get_max_vcpu() cnt = utils_random.integer(1, max_vcpu) return str(cnt)
def numa_cnt(self): max_vcpu = self.get_max_vcpu() return utils_random.integer(1, max_vcpu)
def vcpupin(self): max_vcpu = self.get_max_vcpu() return utils_random.integer(0, max_vcpu)
def usbport(self): max_val = 999 cnt = utils_random.integer(1, 4) return '.'.join( [str(utils_random.integer(0, max_val)) for i in xrange(cnt)])