From 1cf701ff6090bf48dc4870bfffce4ddb00734f30 Mon Sep 17 00:00:00 2001 From: Bahtiar `kalkin-` Gadimov Date: Fri, 2 Sep 2016 19:21:04 +0200 Subject: [PATCH] qvm-block extend use qubes.utils.parse_size --- qubes/tools/qvm_block.py | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/qubes/tools/qvm_block.py b/qubes/tools/qvm_block.py index 5affef4b..1c295cef 100644 --- a/qubes/tools/qvm_block.py +++ b/qubes/tools/qvm_block.py @@ -24,12 +24,12 @@ from __future__ import print_function -import re import sys import qubes import qubes.exc import qubes.tools +import qubes.utils def prepare_table(vd_list, full=False): @@ -175,24 +175,7 @@ def extend_volumes(args): ''' volume = args.volume app = args.app - try: - size = int(args.size.strip()) - except ValueError: - if re.match(r'^(\d+[kgm])$', args.size.strip(), re.IGNORECASE): - size = int(args.size.strip()[:-1]) - factor = args.size.strip()[-1:] - elif re.match(r'^(\d+[kgm][B])$', args.size.strip(), re.IGNORECASE): - size = int(args.size.strip()[:-2]) - factor = args.size.strip()[-2:-1] - else: - print("Unknown size %s" % args.size, file=sys.stderr) - sys.exit(1) - if factor == "K": - size *= 1000 - elif factor == "M": - size *= 1000 * 1000 - elif factor == "G": - size *= 1000 * 1000 * 1000 + size = qubes.utils.parse_size(args.size) pool = app.get_pool(volume.pool) pool.resize(volume, volume.size+size) app.save()