Revision eea28492 snf-tools/synnefo_tools/burnin/common.py
b/snf-tools/synnefo_tools/burnin/common.py | ||
---|---|---|
45 | 45 |
from tempfile import NamedTemporaryFile |
46 | 46 |
from os import urandom |
47 | 47 |
from sys import stderr |
48 |
from string import ascii_letters |
|
48 | 49 |
|
49 | 50 |
from kamaki.clients.cyclades import CycladesClient, CycladesNetworkClient |
50 | 51 |
from kamaki.clients.astakos import AstakosClient, parse_endpoints |
... | ... | |
313 | 314 |
f = NamedTemporaryFile() |
314 | 315 |
Ki = size / 8 |
315 | 316 |
c = ['|', '/', '-', '\\'] |
316 |
stderr.write('Create file %s ' % f.name) |
|
317 |
stderr.write('\tCreate file %s ' % f.name)
|
|
317 | 318 |
for i, bytes in enumerate([b * Ki for b in range(size / Ki)]): |
318 | 319 |
f.seek(bytes) |
319 | 320 |
f.write(urandom(Ki)) |
... | ... | |
325 | 326 |
f.seek(0) |
326 | 327 |
return f |
327 | 328 |
|
329 |
def _create_boring_file(self, num_of_blocks): |
|
330 |
"""Create a file with some blocks being the same""" |
|
331 |
|
|
332 |
def chargen(): |
|
333 |
"""10 + 2 * 26 + 26 = 88""" |
|
334 |
while True: |
|
335 |
for CH in xrange(10): |
|
336 |
yield '%s' % CH |
|
337 |
for CH in ascii_letters: |
|
338 |
yield CH |
|
339 |
for CH in '~!@#$%^&*()_+`-=:";|<>?,./': |
|
340 |
yield CH |
|
341 |
|
|
342 |
c = ['|', '/', '-', '\\'] |
|
343 |
tmpFile = NamedTemporaryFile() |
|
344 |
stderr.write('\tCreate file %s ' % tmpFile.name) |
|
345 |
block_size = 4 * 1024 * 1024 |
|
346 |
chars, i = chargen(), 0 |
|
347 |
while num_of_blocks: |
|
348 |
fslice = 3 if num_of_blocks > 3 else num_of_blocks |
|
349 |
tmpFile.write(fslice * block_size * chars.next()) |
|
350 |
num_of_blocks -= fslice |
|
351 |
stderr.write('\b' + c[i % 4]) |
|
352 |
stderr.flush() |
|
353 |
i += 1 |
|
354 |
tmpFile.seek(0) |
|
355 |
stderr.write('\n') |
|
356 |
stderr.flush() |
|
357 |
return tmpFile |
|
358 |
|
|
328 | 359 |
def _get_uuid_of_system_user(self): |
329 | 360 |
"""Get the uuid of the system user |
330 | 361 |
|
Also available in: Unified diff