From aaf0114df1c4e09ee5cc57386479903a08774e03 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 6 Feb 2020 15:13:08 +0100 Subject: [PATCH] add image format option --- uncloud/hack/main.py | 1 + uncloud/hack/vm.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/uncloud/hack/main.py b/uncloud/hack/main.py index 9607ec2..a0c3ca6 100644 --- a/uncloud/hack/main.py +++ b/uncloud/hack/main.py @@ -30,6 +30,7 @@ arg_parser.add_argument('--list-vms', action='store_true') arg_parser.add_argument('--memory', help="Size of memory (GB)", type=int) arg_parser.add_argument('--cores', help="Amount of CPU cores", type=int) arg_parser.add_argument('--image', help="Path (under hackprefix) to OS image") +arg_parser.add_argument('--image-format', help="Image format: qcow2 or raw", choices=['raw', 'qcow2']) arg_parser.add_argument('--uuid', help="VM UUID") arg_parser.add_argument('--no-db', help="Disable connection to etcd. For local testing only!", action='store_true') diff --git a/uncloud/hack/vm.py b/uncloud/hack/vm.py index d86941b..b38d563 100755 --- a/uncloud/hack/vm.py +++ b/uncloud/hack/vm.py @@ -59,18 +59,23 @@ class VM(object): self.uuid = self.config.arguments['uuid'] self.memory = self.config.arguments['memory'] or '1024M' self.cores = self.config.arguments['cores'] or 1 + if self.config.arguments['image']: self.image = os.path.join(self.hackprefix, self.config.arguments['image']) else: self.image = None + if self.config.arguments['image_format']: + self.image_format=self.config.arguments['image_format'] + else: + self.image_format='qcow2' + # External components. self.vmm = VMM(vmm_backend=self.hackprefix) self.mac = MAC(self.config) # Harcoded & generated values. self.owner = 'uncoud' - self.image_format='qcow2' self.accel = 'kvm' self.threads = 1 self.ifup = os.path.join(self.hackprefix, "ifup.sh")