59 lines
1.8 KiB
Python
59 lines
1.8 KiB
Python
# copyright: Canonical
|
|
import os
|
|
import subprocess
|
|
from uuid import uuid4
|
|
|
|
from loguru import logger as log
|
|
from tqdm import tqdm
|
|
|
|
from definitions import INST_STO_ROOT, RANDOM_FILES, SAMPLES, TEST_FILES
|
|
|
|
if __name__ == "__main__":
|
|
for path, data in SAMPLES.items():
|
|
log.info(f"processing {path}")
|
|
os.makedirs(INST_STO_ROOT + path, exist_ok=True)
|
|
for x in tqdm(range(data["number"])):
|
|
subprocess.run(
|
|
[
|
|
"dd",
|
|
"if=/dev/urandom",
|
|
f"of={INST_STO_ROOT+path}/{x}",
|
|
f"bs={int(data['size']*1000)}",
|
|
"count=1",
|
|
],
|
|
capture_output=True,
|
|
# shell=True,
|
|
)
|
|
|
|
for path, data in SAMPLES.items():
|
|
log.info(f"processing RANDOM {path}")
|
|
os.makedirs(INST_STO_ROOT + "Rand", exist_ok=True)
|
|
for x in tqdm(range(data["number"])):
|
|
subprocess.run(
|
|
[
|
|
"dd",
|
|
"if=/dev/urandom",
|
|
f"of={INST_STO_ROOT}Rand/{uuid4()}",
|
|
f"bs={int(data['size']*1000)}",
|
|
"count=1",
|
|
],
|
|
capture_output=True,
|
|
# shell=True,
|
|
)
|
|
|
|
for path, data in TEST_FILES.items():
|
|
log.info(f"processing tests {path}")
|
|
os.makedirs(INST_STO_ROOT + "test", exist_ok=True)
|
|
for x in tqdm(range(data["number"])):
|
|
subprocess.run(
|
|
[
|
|
"dd",
|
|
"if=/dev/urandom",
|
|
f"of={INST_STO_ROOT}test/{uuid4()}",
|
|
f"bs={int(data['size']*1000)}",
|
|
"count=1",
|
|
],
|
|
capture_output=True,
|
|
# shell=True,
|
|
)
|