def collect_all(client, zone, opt=None): flav = getAvailFlav(client) cells = filterAz(client, zone) timeout = processConfig('config', 'timeout') if opt is True: jobs = [] for i, cell in enumerate(cells): cell["queue"] = Queue() p = Process(name=i, target=gather_all_stats, args=(cell["cell"], cell["host_name"], flav, zone, cell["fq_cell"], client, cell["queue"])) jobs.append(p) p.start() for p in jobs: p.join(int(timeout)) if p.is_alive(): p.terminate() return False html_array = [] for cell in cells: html_array.append(cell["queue"].get()) return html_array else: if cell in cells: index_id = cell['cell'].index(opt) a_name = cell['fq_cell'][index_id] c_name = cell['host_name'][index_id] return gather_all_stats(opt, c_name, flav, zone, a_name, client)
def collect_compute(client, zone, target_cell=None): cells = filterAz(client, zone) timeout = processConfig('config', 'timeout') if target_cell is None: jobs = [] for i, cell in enumerate(cells): cell["queue"] = Queue() p = Process(name=i, target=gather_compute_stats, args=(cell["cell"], zone, cell["fq_cell"], client, cell["queue"])) jobs.append(p) p.start() for p in jobs: p.join(int(timeout)) if p.is_alive(): p.terminate() return False html_array = [] for cell in cells: html_array.append(cell["queue"].get()) return html_array else: for cell in cells: if cell["cell"] == target_cell: a_name = cell['fq_cell'] break else: raise Exception("Can't find cell.") return [gather_compute_stats(target_cell, zone, a_name, client)]
def RunCollect(client, zone, opt=None): flav = getAvailFlav(client) cell = filterAz(client, zone) if cell != False: timeout = process_config('config', 'timeout') if opt == True: jobs = [] r_outs = [Queue() for q in range(len(cell[0]))] for z, i in enumerate(cell[0]): # rate limit seems to kick in client = create_connection() p = threading.Thread(name=z, target=computeStats, args=(cell[1][z], flav, zone, i, client, r_outs[z], True)) jobs.append(p) p.start() for p in jobs: p.join(int(timeout)) if p.is_alive(): p.terminate() return False html_array = [] for q in r_outs: html_array.append(q.get()) return html_array else: if opt in cell[1]: index_id = cell[1].index(opt) a_name = cell[0][index_id] return computeStats(opt, flav, zone, a_name, client, r_outs=None, opt=None) else: return False
def RunCollect(client, zone, opt=None): flav = getAvailFlav(client) cell = filterAz(client, zone) timeout = process_config('config', 'timeout') while cell: if opt == True: jobs = [] r_outs = [Queue() for q in range(len(cell) + 1)] for z, i in enumerate(cell[0]): p = Process(name=z, target=computeStats, args=(cell[1][z], cell[2][z], flav, zone, i, client, r_outs[z], True)) jobs.append(p) p.start() for p in jobs: p.join(int(timeout)) if p.is_alive(): p.terminate() return False html_array = [] for q in r_outs: html_array.append(q.get()) return html_array else: if opt in cell[1]: index_id = cell[1].index(opt) a_name = cell[0][index_id] c_name = cell[2][index_id] return computeStats(opt, c_name, flav, zone, a_name, client, r_outs=None, opt=None) else: return False
def collect_data(client, zone, opt=None): vm_flavor = getAvailFlav(client) availability_zone = filterAz(client, zone) timeout = process_config('config', 'timeout') if availability_zone != False: if opt == True: thread_jobs = [] result_queue = [Queue() for q in range(len(availability_zone[0]))] for key, value in enumerate(availability_zone[0]): client = create_connection() work_thread = threading.Thread( name=key, target=computeStats, args=(availability_zone[1][key], vm_flavor, zone, value, client, result_queue[key], True)) thread_jobs.append(work_thread) work_thread.start() for data_thread in thread_jobs: data_thread.join(int(timeout)) if data_thread.is_alive(): data_tread.terminate() return false data_display = [] for rq in result_queue: data_display.append(rq.get()) return data_display else: if opt in cell[1]: index_id = cell[1].index(opt) az_name = cell[0][index_id] return computeStats(opt, flav, zone, az_name, client, r_outs=None, opt=None) else: return False
def RunCollect(client, zone, opt=None): flav = getAvailFlav(client) cell = filterAz(client, zone) timeout = process_config('config', 'timeout') while cell: if opt == True: jobs = [] r_outs = [Queue() for q in range(len(cell) + 1)] for z, i in enumerate(cell[0]): p = Process(name=z, target=computeStats, args=(cell[1][z], cell[2][z], flav, zone, i, client, r_outs[z], True) ) jobs.append(p) p.start() for p in jobs: p.join(int(timeout)) if p.is_alive(): p.terminate() return False html_array = [] for q in r_outs: html_array.append(q.get()) return html_array else: if opt in cell[1]: index_id = cell[1].index(opt) a_name = cell[0][index_id] c_name = cell[2][index_id] return computeStats(opt, c_name, flav, zone, a_name, client, r_outs=None, opt=None) else: return False
def collect_data(client, zone, opt=None): vm_flavor = getAvailFlav(client) availability_zone = filterAz(client, zone) timeout = process_config('config', 'timeout') if availability_zone != False: if opt == True: thread_jobs = [] result_queue = [Queue() for q in range (len(availability_zone[0]))] for key, value in enumerate(availability_zone[0]): client = create_connection() work_thread = threading.Thread(name=key, target=computeStats, args=(availability_zone[1][key], vm_flavor, zone, value, client, result_queue[key], True)) thread_jobs.append(work_thread) work_thread.start() for data_thread in thread_jobs: data_thread.join(int(timeout)) if data_thread.is_alive(): data_tread.terminate() return false data_display = [] for rq in result_queue: data_display.append(rq.get()) return data_display else: if opt in cell[1]: index_id = cell[1].index(opt) az_name = cell[0][index_id] return computeStats(opt, flav, zone, az_name, client, r_outs=None, opt=None) else: return False