[PATCH 1/2 V2] Set qcow2 as default disk format in new templates

Users are allowed to provide disk format when creating a new Template. However this is optional. This option sets qcow2 as default disk format for every new Template created. Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- src/kimchi/osinfo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/kimchi/osinfo.py b/src/kimchi/osinfo.py index 3c31346..ede2541 100644 --- a/src/kimchi/osinfo.py +++ b/src/kimchi/osinfo.py @@ -33,7 +33,8 @@ SUPPORTED_ARCHS = {'x86': ('i386', 'i686', 'x86_64'), 'ppc64le': ('ppc64le')} -common_spec = {'cpus': 1, 'memory': 1024, 'disks': [{'index': 0, 'size': 10}], +common_spec = {'cpus': 1, 'memory': 1024, 'disks': [{'index': 0, 'size': 10, + 'format': 'qcow2'}], 'cdrom_bus': 'ide', 'cdrom_index': 2, 'mouse_bus': 'ps2'} -- 2.1.0

This patch adds two tests to check if templates are being created with default disk format value (qcow2) or if the template is being created correctly with the format value passed. Template update tests already exist. Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- tests/test_template.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_template.py b/tests/test_template.py index 4446025..23a24fb 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -86,6 +86,9 @@ class TemplateTests(unittest.TestCase): tmpl = json.loads(self.request('/templates/test').read()) self.assertEquals(sorted(tmpl.keys()), sorted(keys)) + # Verify if default disk format was configured + self.assertEquals(tmpl['disks'][0]['format'], 'qcow2') + # Clone a template resp = self.request('/templates/test/clone', '{}', 'POST') self.assertEquals(303, resp.status) @@ -113,6 +116,15 @@ class TemplateTests(unittest.TestCase): self.assertEquals(201, resp.status) os.remove('/tmp/mock.img') + # Test disk format + t = {'name': 'test-format', 'cdrom': '/tmp/mock.iso', + 'disks': [{'index': 0, 'size': 10, 'format': 'vmdk'}]} + req = json.dumps(t) + resp = self.request('/templates', req, 'POST') + self.assertEquals(201, resp.status) + tmpl = json.loads(self.request('/templates/test-format').read()) + self.assertEquals(tmpl['disks'][0]['format'], 'vmdk') + def test_customized_tmpl(self): # Create a template t = {'name': 'test', 'cdrom': '/tmp/mock.iso'} -- 2.1.0

Reviewed-by: Aline Manera <alinefm@linux.vnet.ibm.com> On 16/04/2015 15:54, Rodrigo Trujillo wrote:
This patch adds two tests to check if templates are being created with default disk format value (qcow2) or if the template is being created correctly with the format value passed. Template update tests already exist.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- tests/test_template.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/tests/test_template.py b/tests/test_template.py index 4446025..23a24fb 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -86,6 +86,9 @@ class TemplateTests(unittest.TestCase): tmpl = json.loads(self.request('/templates/test').read()) self.assertEquals(sorted(tmpl.keys()), sorted(keys))
+ # Verify if default disk format was configured + self.assertEquals(tmpl['disks'][0]['format'], 'qcow2') + # Clone a template resp = self.request('/templates/test/clone', '{}', 'POST') self.assertEquals(303, resp.status) @@ -113,6 +116,15 @@ class TemplateTests(unittest.TestCase): self.assertEquals(201, resp.status) os.remove('/tmp/mock.img')
+ # Test disk format + t = {'name': 'test-format', 'cdrom': '/tmp/mock.iso', + 'disks': [{'index': 0, 'size': 10, 'format': 'vmdk'}]} + req = json.dumps(t) + resp = self.request('/templates', req, 'POST') + self.assertEquals(201, resp.status) + tmpl = json.loads(self.request('/templates/test-format').read()) + self.assertEquals(tmpl['disks'][0]['format'], 'vmdk') + def test_customized_tmpl(self): # Create a template t = {'name': 'test', 'cdrom': '/tmp/mock.iso'}

Reviewed-by: Aline Manera <alinefm@linux.vnet.ibm.com> On 16/04/2015 15:54, Rodrigo Trujillo wrote:
Users are allowed to provide disk format when creating a new Template. However this is optional. This option sets qcow2 as default disk format for every new Template created.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- src/kimchi/osinfo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/kimchi/osinfo.py b/src/kimchi/osinfo.py index 3c31346..ede2541 100644 --- a/src/kimchi/osinfo.py +++ b/src/kimchi/osinfo.py @@ -33,7 +33,8 @@ SUPPORTED_ARCHS = {'x86': ('i386', 'i686', 'x86_64'), 'ppc64le': ('ppc64le')}
-common_spec = {'cpus': 1, 'memory': 1024, 'disks': [{'index': 0, 'size': 10}], +common_spec = {'cpus': 1, 'memory': 1024, 'disks': [{'index': 0, 'size': 10, + 'format': 'qcow2'}], 'cdrom_bus': 'ide', 'cdrom_index': 2, 'mouse_bus': 'ps2'}
participants (2)
-
Aline Manera
-
Rodrigo Trujillo