From 6bc4e895b6f3fe8d9e4fed464f930ddc4dd9c48c Mon Sep 17 00:00:00 2001 From: catborise Date: Mon, 29 Apr 2019 14:09:17 +0300 Subject: [PATCH] Add qcow2/qcow extension for vol clone. Make image features additions for only qcow2 images. --- vrtManager/storage.py | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/vrtManager/storage.py b/vrtManager/storage.py index 9d6273a..b0d6b52 100644 --- a/vrtManager/storage.py +++ b/vrtManager/storage.py @@ -230,22 +230,31 @@ class wvmStorage(wvmConnect): %s 0644 - - 1.1 - - - - - """ % (name, size, alloc, vol_fmt, owner['uid'], owner['guid']) + """ % (name, size, alloc, vol_fmt, owner['uid'], owner['guid']) + if vol_fmt == 'qcow2': + xml += """ + 1.1 + + + """ + xml += """ + + """ self._createXML(xml, metadata) + return name def clone_volume(self, name, target_file, vol_fmt=None, metadata=False, owner=owner): - storage_type = self.get_type() - if storage_type == 'dir': - target_file += '.img' vol = self.get_volume(name) if not vol_fmt: vol_fmt = self.get_volume_type(name) + + storage_type = self.get_type() + if storage_type == 'dir': + if vol_fmt in ('qcow', 'qcow2'): + target_file += '.' + vol_fmt + else: + target_file += '.img' + xml = """ %s @@ -258,11 +267,14 @@ class wvmStorage(wvmConnect): %s 0644 - + """ % (target_file, vol_fmt, owner['uid'], owner['guid']) + if vol_fmt == 'qcow2': + xml += """ 1.1 - - - """ % (target_file, vol_fmt, owner['uid'],owner['guid']) + """ + xml += """ + """ self._createXMLFrom(xml, vol, metadata) + return target_file