koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 1 | import os |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 2 | import math |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 3 | import bisect |
koder aka kdanilov | a047e1b | 2015-04-21 23:16:59 +0300 | [diff] [blame] | 4 | import logging |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 5 | |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 6 | try: |
| 7 | import matplotlib.pyplot as plt |
| 8 | except ImportError: |
| 9 | plt = None |
| 10 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 11 | import wally |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 12 | from wally import charts |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 13 | from wally.utils import parse_creds, ssize_to_b |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame^] | 14 | from wally.statistic import round_3_digit, round_deviation |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 15 | from wally.suits.io.results_loader import process_disk_info |
koder aka kdanilov | ea7eac7 | 2015-04-21 21:37:27 +0300 | [diff] [blame] | 16 | from wally.meta_info import total_lab_info, collect_lab_data |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 17 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 18 | |
koder aka kdanilov | a047e1b | 2015-04-21 23:16:59 +0300 | [diff] [blame] | 19 | logger = logging.getLogger("wally.report") |
| 20 | |
| 21 | |
koder aka kdanilov | 209e85d | 2015-04-27 23:11:05 +0300 | [diff] [blame] | 22 | class DiskInfo(object): |
| 23 | def __init__(self): |
| 24 | self.direct_iops_r_max = 0 |
| 25 | self.direct_iops_w_max = 0 |
| 26 | self.rws4k_10ms = 0 |
| 27 | self.rws4k_30ms = 0 |
| 28 | self.rws4k_100ms = 0 |
| 29 | self.bw_write_max = 0 |
| 30 | self.bw_read_max = 0 |
| 31 | |
| 32 | |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 33 | report_funcs = [] |
| 34 | |
| 35 | |
| 36 | def report(name, required_fields): |
| 37 | def closure(func): |
| 38 | report_funcs.append((required_fields.split(","), name, func)) |
| 39 | return func |
| 40 | return closure |
| 41 | |
| 42 | |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 43 | def linearity_report(processed_results, path, lab_info): |
| 44 | names = {} |
| 45 | for tp1 in ('rand', 'seq'): |
| 46 | for oper in ('read', 'write'): |
| 47 | for sync in ('sync', 'direct', 'async'): |
| 48 | sq = (tp1, oper, sync) |
| 49 | name = "{0} {1} {2}".format(*sq) |
| 50 | names["".join(word[0] for word in sq)] = name |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 51 | |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 52 | colors = ['red', 'green', 'blue', 'cyan', |
| 53 | 'magenta', 'black', 'yellow', 'burlywood'] |
| 54 | markers = ['*', '^', 'x', 'o', '+', '.'] |
| 55 | color = 0 |
| 56 | marker = 0 |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 57 | |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 58 | plot_data = {} |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 59 | |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 60 | name_pref = 'linearity_test_rrd' |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 61 | |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 62 | for res in processed_results.values(): |
| 63 | if res.name.startswith(name_pref): |
| 64 | iotime = 1000000. / res.iops |
| 65 | iotime_max = iotime * (1 + res.dev * 3) |
| 66 | bsize = ssize_to_b(res.raw['blocksize']) |
| 67 | plot_data[bsize] = (iotime, iotime_max) |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 68 | |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 69 | min_sz = min(plot_data) |
| 70 | min_iotime, _ = plot_data.pop(min_sz) |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 71 | |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 72 | x = [] |
| 73 | y = [] |
| 74 | e = [] |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 75 | |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 76 | for k, (v, vmax) in sorted(plot_data.items()): |
| 77 | # y.append(math.log10(v - min_iotime)) |
| 78 | # x.append(math.log10(k)) |
| 79 | # e.append(y[-1] - math.log10(vmax - min_iotime)) |
| 80 | y.append(v - min_iotime) |
| 81 | x.append(k) |
| 82 | e.append(y[-1] - (vmax - min_iotime)) |
| 83 | |
| 84 | print e |
| 85 | |
| 86 | tp = 'rrd' |
| 87 | plt.errorbar(x, y, e, linestyle='None', label=names[tp], |
| 88 | color=colors[color], ecolor="black", |
| 89 | marker=markers[marker]) |
| 90 | plt.yscale('log') |
| 91 | plt.xscale('log') |
| 92 | plt.show() |
| 93 | |
| 94 | # ynew = approximate_line(ax, ay, ax, True) |
| 95 | # plt.plot(ax, ynew, color=colors[color]) |
| 96 | # color += 1 |
| 97 | # marker += 1 |
| 98 | # plt.legend(loc=2) |
| 99 | # plt.title("Linearity test by %i dots" % (len(vals))) |
| 100 | |
| 101 | |
| 102 | if plt: |
| 103 | linearity_report = report('linearity', 'linearity_test')(linearity_report) |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 104 | |
| 105 | |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 106 | def render_hdd_html(dest, info, lab_description): |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 107 | very_root_dir = os.path.dirname(os.path.dirname(wally.__file__)) |
| 108 | templ_dir = os.path.join(very_root_dir, 'report_templates') |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 109 | templ_file = os.path.join(templ_dir, "report_hdd.html") |
| 110 | templ = open(templ_file, 'r').read() |
koder aka kdanilov | 209e85d | 2015-04-27 23:11:05 +0300 | [diff] [blame] | 111 | |
koder aka kdanilov | c368eb6 | 2015-04-28 18:22:01 +0300 | [diff] [blame] | 112 | for name, val in info.__dict__.items(): |
koder aka kdanilov | 209e85d | 2015-04-27 23:11:05 +0300 | [diff] [blame] | 113 | if not name.startswith('__'): |
koder aka kdanilov | c368eb6 | 2015-04-28 18:22:01 +0300 | [diff] [blame] | 114 | if val is None: |
| 115 | info.__dict__[name] = '-' |
| 116 | else: |
| 117 | info.__dict__[name] = round_3_digit(val) |
koder aka kdanilov | 209e85d | 2015-04-27 23:11:05 +0300 | [diff] [blame] | 118 | |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame^] | 119 | data = info.__dict__.copy() |
| 120 | for k, v in data.items(): |
| 121 | if v is None: |
| 122 | data[k] = "-" |
| 123 | |
| 124 | report = templ.format(lab_info=lab_description, **data) |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 125 | open(dest, 'w').write(report) |
| 126 | |
| 127 | |
| 128 | def render_ceph_html(dest, info, lab_description): |
| 129 | very_root_dir = os.path.dirname(os.path.dirname(wally.__file__)) |
| 130 | templ_dir = os.path.join(very_root_dir, 'report_templates') |
| 131 | templ_file = os.path.join(templ_dir, "report_ceph.html") |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 132 | templ = open(templ_file, 'r').read() |
koder aka kdanilov | 209e85d | 2015-04-27 23:11:05 +0300 | [diff] [blame] | 133 | |
| 134 | for name, val in info.__dict__.items(): |
| 135 | if not name.startswith('__') and isinstance(val, (int, long, float)): |
| 136 | setattr(info, name, round_3_digit(val)) |
| 137 | |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame^] | 138 | data = info.__dict__.copy() |
| 139 | for k, v in data.items(): |
| 140 | if v is None: |
| 141 | data[k] = "-" |
| 142 | |
| 143 | report = templ.format(lab_info=lab_description, **data) |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 144 | open(dest, 'w').write(report) |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 145 | |
| 146 | |
| 147 | def io_chart(title, concurence, latv, iops_or_bw, iops_or_bw_dev, |
| 148 | legend, fname): |
| 149 | bar_data, bar_dev = iops_or_bw, iops_or_bw_dev |
| 150 | legend = [legend] |
| 151 | |
| 152 | iops_or_bw_per_vm = [] |
| 153 | for i in range(len(concurence)): |
| 154 | iops_or_bw_per_vm.append(iops_or_bw[i] / concurence[i]) |
| 155 | |
| 156 | bar_dev_bottom = [] |
| 157 | bar_dev_top = [] |
| 158 | for i in range(len(bar_data)): |
| 159 | bar_dev_top.append(bar_data[i] + bar_dev[i]) |
| 160 | bar_dev_bottom.append(bar_data[i] - bar_dev[i]) |
| 161 | |
| 162 | latv = [lat / 1000 for lat in latv] |
| 163 | ch = charts.render_vertical_bar(title, legend, [bar_data], [bar_dev_top], |
| 164 | [bar_dev_bottom], file_name=fname, |
Yulia Portnova | 0d1b45f | 2015-04-28 16:51:11 +0300 | [diff] [blame] | 165 | scale_x=concurence, label_x="clients", |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame^] | 166 | label_y=legend[0], |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 167 | lines=[ |
| 168 | (latv, "msec", "rr", "lat"), |
| 169 | (iops_or_bw_per_vm, None, None, |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame^] | 170 | legend[0] + " per client") |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 171 | ]) |
| 172 | return str(ch) |
| 173 | |
| 174 | |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 175 | def make_hdd_plots(processed_results, path): |
| 176 | plots = [ |
| 177 | ('hdd_test_rrd4k', 'rand_read_4k', 'Random read 4k direct IOPS'), |
koder aka kdanilov | ea7eac7 | 2015-04-21 21:37:27 +0300 | [diff] [blame] | 178 | ('hdd_test_rws4k', 'rand_write_4k', 'Random write 4k sync IOPS') |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 179 | ] |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 180 | make_plots(processed_results, path, plots) |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 181 | |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 182 | |
| 183 | def make_ceph_plots(processed_results, path): |
| 184 | plots = [ |
| 185 | ('ceph_test_rrd4k', 'rand_read_4k', 'Random read 4k direct IOPS'), |
| 186 | ('ceph_test_rws4k', 'rand_write_4k', 'Random write 4k sync IOPS'), |
| 187 | ('ceph_test_rrd16m', 'rand_read_16m', 'Random read 16m direct MiBps'), |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame^] | 188 | ('ceph_test_rwd16m', 'rand_write_16m', |
| 189 | 'Random write 16m direct MiBps'), |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 190 | ] |
| 191 | make_plots(processed_results, path, plots) |
| 192 | |
| 193 | |
| 194 | def make_plots(processed_results, path, plots): |
| 195 | for name_pref, fname, desc in plots: |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 196 | chart_data = [] |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 197 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 198 | for res in processed_results.values(): |
| 199 | if res.name.startswith(name_pref): |
| 200 | chart_data.append(res) |
| 201 | |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 202 | if len(chart_data) == 0: |
| 203 | raise ValueError("Can't found any date for " + name_pref) |
| 204 | |
| 205 | use_bw = ssize_to_b(chart_data[0].raw['blocksize']) > 16 * 1024 |
| 206 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 207 | chart_data.sort(key=lambda x: x.raw['concurence']) |
| 208 | |
| 209 | lat = [x.lat for x in chart_data] |
koder aka kdanilov | 209e85d | 2015-04-27 23:11:05 +0300 | [diff] [blame] | 210 | vm_count = x.meta['testnodes_count'] |
| 211 | concurence = [x.raw['concurence'] * vm_count for x in chart_data] |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 212 | |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 213 | if use_bw: |
| 214 | data = [x.bw for x in chart_data] |
| 215 | data_dev = [x.bw * x.dev for x in chart_data] |
| 216 | name = "BW" |
| 217 | else: |
| 218 | data = [x.iops for x in chart_data] |
| 219 | data_dev = [x.iops * x.dev for x in chart_data] |
| 220 | name = "IOPS" |
| 221 | |
| 222 | io_chart(desc, concurence, lat, data, data_dev, name, fname) |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 223 | |
| 224 | |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame^] | 225 | def find_max_where(processed_results, sync_mode, blocksize, rw, iops=True): |
| 226 | result = [0, 0] |
| 227 | attr = 'iops' if iops else 'bw' |
| 228 | for measurement in processed_results.values(): |
| 229 | ok = measurement.raw['sync_mode'] == sync_mode |
| 230 | ok = ok and (measurement.raw['blocksize'] == blocksize) |
| 231 | ok = ok and (measurement.raw['rw'] == rw) |
| 232 | |
| 233 | if ok: |
| 234 | if getattr(measurement, attr) > result[0]: |
| 235 | result = [getattr(measurement, attr), measurement.dev] |
| 236 | return result |
| 237 | |
| 238 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 239 | def get_disk_info(processed_results): |
| 240 | di = DiskInfo() |
| 241 | rws4k_iops_lat_th = [] |
| 242 | |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame^] | 243 | di.direct_iops_w_max = find_max_where(processed_results, |
| 244 | 'd', '4k', 'randwrite') |
| 245 | di.direct_iops_r_max = find_max_where(processed_results, |
| 246 | 'd', '4k', 'randread') |
| 247 | di.bw_write_max = find_max_where(processed_results, |
| 248 | 'd', '16m', 'randwrite', False) |
| 249 | di.bw_read_max = find_max_where(processed_results, |
| 250 | 'd', '16m', 'randread', False) |
| 251 | |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 252 | for res in processed_results.values(): |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame^] | 253 | if res.raw['sync_mode'] == 's' and res.raw['blocksize'] == '4k': |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 254 | if res.raw['rw'] != 'randwrite': |
| 255 | continue |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 256 | rws4k_iops_lat_th.append((res.iops, res.lat, |
| 257 | res.raw['concurence'])) |
| 258 | |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame^] | 259 | di.bw_write_max[0] /= 1000 |
| 260 | di.bw_read_max[0] /= 1000 |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 261 | |
| 262 | rws4k_iops_lat_th.sort(key=lambda (_1, _2, conc): conc) |
| 263 | |
| 264 | latv = [lat for _, lat, _ in rws4k_iops_lat_th] |
| 265 | |
| 266 | for tlatv_ms in [10, 30, 100]: |
| 267 | tlat = tlatv_ms * 1000 |
| 268 | pos = bisect.bisect_left(latv, tlat) |
| 269 | if 0 == pos: |
| 270 | iops3 = 0 |
| 271 | elif pos == len(latv): |
| 272 | iops3 = latv[-1] |
| 273 | else: |
| 274 | lat1 = latv[pos - 1] |
| 275 | lat2 = latv[pos] |
| 276 | |
| 277 | th1 = rws4k_iops_lat_th[pos - 1][2] |
| 278 | th2 = rws4k_iops_lat_th[pos][2] |
| 279 | |
| 280 | iops1 = rws4k_iops_lat_th[pos - 1][0] |
| 281 | iops2 = rws4k_iops_lat_th[pos][0] |
| 282 | |
| 283 | th_lat_coef = (th2 - th1) / (lat2 - lat1) |
| 284 | th3 = th_lat_coef * (tlat - lat1) + th1 |
| 285 | |
| 286 | th_iops_coef = (iops2 - iops1) / (th2 - th1) |
| 287 | iops3 = th_iops_coef * (th3 - th1) + iops1 |
| 288 | setattr(di, 'rws4k_{}ms'.format(tlatv_ms), int(iops3)) |
| 289 | |
| 290 | hdi = DiskInfo() |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame^] | 291 | |
| 292 | def pp(x): |
| 293 | med, dev = round_deviation((x[0], x[1] * x[0])) |
| 294 | # 3 sigma in % |
| 295 | dev = int(float(dev) / med * 100) |
| 296 | return (med, dev) |
| 297 | |
| 298 | hdi.direct_iops_r_max = pp(di.direct_iops_r_max) |
| 299 | hdi.direct_iops_w_max = pp(di.direct_iops_w_max) |
| 300 | hdi.bw_write_max = pp(di.bw_write_max) |
| 301 | hdi.bw_read_max = pp(di.bw_read_max) |
| 302 | |
koder aka kdanilov | c368eb6 | 2015-04-28 18:22:01 +0300 | [diff] [blame] | 303 | hdi.rws4k_10ms = di.rws4k_10ms if 0 != di.rws4k_10ms else None |
| 304 | hdi.rws4k_30ms = di.rws4k_30ms if 0 != di.rws4k_30ms else None |
| 305 | hdi.rws4k_100ms = di.rws4k_100ms if 0 != di.rws4k_100ms else None |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 306 | return hdi |
| 307 | |
| 308 | |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 309 | @report('HDD', 'hdd_test_rrd4k,hdd_test_rws4k') |
koder aka kdanilov | a4a570f | 2015-04-23 22:11:40 +0300 | [diff] [blame] | 310 | def make_hdd_report(processed_results, path, lab_info): |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 311 | make_hdd_plots(processed_results, path) |
koder aka kdanilov | a4a570f | 2015-04-23 22:11:40 +0300 | [diff] [blame] | 312 | di = get_disk_info(processed_results) |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 313 | render_hdd_html(path, di, lab_info) |
| 314 | |
| 315 | |
| 316 | @report('Ceph', 'ceph_test') |
| 317 | def make_ceph_report(processed_results, path, lab_info): |
| 318 | make_ceph_plots(processed_results, path) |
| 319 | di = get_disk_info(processed_results) |
| 320 | render_ceph_html(path, di, lab_info) |
koder aka kdanilov | a4a570f | 2015-04-23 22:11:40 +0300 | [diff] [blame] | 321 | |
| 322 | |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 323 | def make_io_report(results, path, lab_url=None, creds=None): |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 324 | lab_info = None |
koder aka kdanilov | 7e0f7cf | 2015-05-01 17:24:35 +0300 | [diff] [blame^] | 325 | |
koder aka kdanilov | 63e9c5a | 2015-04-28 23:06:07 +0300 | [diff] [blame] | 326 | # if lab_url is not None: |
| 327 | # username, password, tenant_name = parse_creds(creds) |
| 328 | # creds = {'username': username, |
| 329 | # 'password': password, |
| 330 | # "tenant_name": tenant_name} |
| 331 | # try: |
| 332 | # data = collect_lab_data(lab_url, creds) |
| 333 | # lab_info = total_lab_info(data) |
| 334 | # except Exception as exc: |
| 335 | # logger.warning("Can't collect lab data: {0!s}".format(exc)) |
| 336 | |
| 337 | if lab_info is None: |
koder aka kdanilov | 4a510ee | 2015-04-21 18:50:42 +0300 | [diff] [blame] | 338 | lab_info = { |
| 339 | "total_disk": "None", |
| 340 | "total_memory": "None", |
| 341 | "nodes_count": "None", |
| 342 | "processor_count": "None" |
| 343 | } |
koder aka kdanilov | cff7b2e | 2015-04-18 20:48:15 +0300 | [diff] [blame] | 344 | |
koder aka kdanilov | a047e1b | 2015-04-21 23:16:59 +0300 | [diff] [blame] | 345 | try: |
| 346 | processed_results = process_disk_info(results) |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 347 | res_fields = sorted(processed_results.keys()) |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 348 | for fields, name, func in report_funcs: |
koder aka kdanilov | afd9874 | 2015-04-24 01:27:22 +0300 | [diff] [blame] | 349 | for field in fields: |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 350 | pos = bisect.bisect_left(res_fields, field) |
| 351 | |
| 352 | if pos == len(res_fields): |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 353 | break |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 354 | |
koder aka kdanilov | be8f89f | 2015-04-28 14:51:51 +0300 | [diff] [blame] | 355 | if not res_fields[pos].startswith(field): |
koder aka kdanilov | afd9874 | 2015-04-24 01:27:22 +0300 | [diff] [blame] | 356 | break |
| 357 | else: |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 358 | hpath = path.format(name) |
koder aka kdanilov | 63ad206 | 2015-04-27 13:11:40 +0300 | [diff] [blame] | 359 | logger.debug("Generatins report " + name + " into " + hpath) |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 360 | func(processed_results, hpath, lab_info) |
koder aka kdanilov | afd9874 | 2015-04-24 01:27:22 +0300 | [diff] [blame] | 361 | break |
koder aka kdanilov | a4a570f | 2015-04-23 22:11:40 +0300 | [diff] [blame] | 362 | else: |
| 363 | logger.warning("No report generator found for this load") |
koder aka kdanilov | afd9874 | 2015-04-24 01:27:22 +0300 | [diff] [blame] | 364 | |
koder aka kdanilov | a047e1b | 2015-04-21 23:16:59 +0300 | [diff] [blame] | 365 | except Exception as exc: |
koder aka kdanilov | 57ce4db | 2015-04-25 21:25:51 +0300 | [diff] [blame] | 366 | import traceback |
| 367 | traceback.print_exc() |
koder aka kdanilov | ec1b973 | 2015-04-23 20:43:29 +0300 | [diff] [blame] | 368 | logger.error("Failed to generate html report:" + str(exc)) |