[PATCH V3 0/3] Support ppc64 isos in Templates

V3: - Modify test cases V2: - Sort UI list of remote distros - Change names of Fedora distros - Allow ISOs of similar architectures but with different names to be displayed, like (amd64 and x86_64) V1: If Kimchi server is running in a PPC machine, the guests should be PPC. Currently, when user tries to create a template, only x86 isos are showed to user. This patch filters the ISOs, and also, adds ARCH to UI. -- 1.8.5.3

If Kimchi is running in a PPC machine, user can create a template that uses a remote x86_64 iso. Adding an os_arch field to the distro so we can filter distros on systems with other architectures. This prevents a user from creating unusable templates. This patch also changes the name field of Fedora distros. Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com> --- src/distros.d/debian.json | 1 + src/distros.d/fedora.json | 30 +++++++++++++++++++++++++++--- src/distros.d/gentoo.json | 1 + src/distros.d/opensuse.json | 1 + src/distros.d/ubuntu.json | 2 ++ 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/distros.d/debian.json b/src/distros.d/debian.json index 0a00ae0..0754cf3 100644 --- a/src/distros.d/debian.json +++ b/src/distros.d/debian.json @@ -2,6 +2,7 @@ { "name": "debian-Wheezy", "os_distro": "debian", + "os_arch": "x86_64", "os_version": "7.2.0", "path": "http://cdimage.debian.org/debian-cd/7.2.0-live/amd64/iso-hybrid/debian-live-..." } diff --git a/src/distros.d/fedora.json b/src/distros.d/fedora.json index b4a82eb..cba0fe0 100644 --- a/src/distros.d/fedora.json +++ b/src/distros.d/fedora.json @@ -1,20 +1,44 @@ [ { - "name": "fedora-18", + "name": "Fedora 18", "os_distro": "fedora", + "os_arch": "x86_64", "os_version": "18", "path": "http://fedora.mirrors.tds.net/pub/fedora/releases/18/Live/x86_64/Fedora-18-x..." }, { - "name": "fedora-19", + "name": "Fedora 19", "os_distro": "fedora", + "os_arch": "x86_64", "os_version": "19", "path": "http://fedora.mirrors.tds.net/pub/fedora/releases/19/Live/x86_64/Fedora-Live..." }, { - "name": "fedora-20", + "name": "Fedora 20", "os_distro": "fedora", + "os_arch": "x86_64", "os_version": "20", "path": "http://fedora.mirrors.tds.net/pub/fedora/releases/20/Live/x86_64/Fedora-Live..." + }, + { + "name": "Fedora 18 (PPC64)", + "os_distro": "fedora", + "os_arch": "ppc64", + "os_version": "18", + "path": "http://mirrors.kernel.org/fedora-secondary/releases/18/Fedora/ppc64/iso/Fedo..." + }, + { + "name": "Fedora 19 (PPC64)", + "os_distro": "fedora", + "os_arch": "ppc64", + "os_version": "19", + "path": "http://mirrors.kernel.org/fedora-secondary/releases/19/Fedora/ppc64/iso/Fedo..." + }, + { + "name": "Fedora 20 (PPC64)", + "os_distro": "fedora", + "os_arch": "ppc64", + "os_version": "20", + "path": "http://mirrors.kernel.org/fedora-secondary/releases/20/Fedora/ppc64/iso/Fedo..." } ] diff --git a/src/distros.d/gentoo.json b/src/distros.d/gentoo.json index dffeadf..fa5e55b 100644 --- a/src/distros.d/gentoo.json +++ b/src/distros.d/gentoo.json @@ -2,6 +2,7 @@ { "name": "gentoo-20131010", "os_distro": "gentoo", + "os_arch": "x86_64", "os_version": "20131010", "path": "http://distfiles.gentoo.org/releases/amd64/autobuilds/current-iso/install-am..." } diff --git a/src/distros.d/opensuse.json b/src/distros.d/opensuse.json index ff03f41..315cf78 100644 --- a/src/distros.d/opensuse.json +++ b/src/distros.d/opensuse.json @@ -2,6 +2,7 @@ { "name": "opensuse-12.3", "os_distro": "opensuse", + "os_arch": "x86_64", "os_version": "12.3", "path": "http://suse.mirrors.tds.net/pub/opensuse/distribution/12.3/iso/openSUSE-12.3..." } diff --git a/src/distros.d/ubuntu.json b/src/distros.d/ubuntu.json index 4ad6a19..fbd931a 100644 --- a/src/distros.d/ubuntu.json +++ b/src/distros.d/ubuntu.json @@ -2,12 +2,14 @@ { "name": "Ubuntu 13.04 (Raring Ringtail)", "os_distro": "ubuntu", + "os_arch": "x86_64", "os_version": "13.04", "path": "http://ubuntu-releases.cs.umn.edu/13.04/ubuntu-13.04-desktop-amd64.iso" }, { "name": "Ubuntu 13.10 (Saucy Salamander)", "os_distro": "ubuntu", + "os_arch": "x86_64", "os_version": "13.10", "path": "http://ubuntu-releases.cs.umn.edu/13.10/ubuntu-13.10-desktop-amd64.iso" } -- 1.8.5.3

This patch includes distro test in PPC environment and fixes problems due to new Fedora distro names, encoding the name. Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- tests/test_model.py | 1 + tests/test_rest.py | 33 +++++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/tests/test_model.py b/tests/test_model.py index 9df4994..f849039 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -892,6 +892,7 @@ class ModelTests(unittest.TestCase): self.assertIn('name', distro) self.assertIn('os_distro', distro) self.assertIn('os_version', distro) + self.assertIn('os_arch', distro) self.assertIn('path', distro) @unittest.skipUnless(utils.running_as_root(), 'Must be run as root') diff --git a/tests/test_rest.py b/tests/test_rest.py index e5f50ae..1d1a109 100644 --- a/tests/test_rest.py +++ b/tests/test_rest.py @@ -25,6 +25,7 @@ import random import shutil import time import unittest +import urllib2 from functools import partial @@ -1423,13 +1424,33 @@ class RestTests(unittest.TestCase): self.assertIn('os_version', distro) self.assertIn('path', distro) - ident = "fedora-19" - resp = self.request('/config/distros/%s' % ident).read() + # Test in X86 + ident = "Fedora 19" + resp = self.request('/config/distros/%s' % urllib2.quote(ident)).read() distro = json.loads(resp) - self.assertEquals(distro['name'], ident) - self.assertEquals(distro['os_distro'], "fedora") - self.assertEquals(distro['os_version'], "19") - self.assertIn('path', distro) + if os.uname()[4] in ['x86_64', 'amd64']: + self.assertEquals(distro['name'], ident) + self.assertEquals(distro['os_distro'], "fedora") + self.assertEquals(distro['os_version'], "19") + self.assertEquals(distro['os_arch'], "x86_64") + self.assertIn('path', distro) + else: + # Distro not found error + self.assertIn('KCHDISTRO0001E',distro.get('reason')) + + # Test in PPC + ident = "Fedora 20 (PPC64)" + resp = self.request('/config/distros/%s' % urllib2.quote(ident)).read() + distro = json.loads(resp) + if os.uname()[4] == 'ppc64': + self.assertEquals(distro['name'], ident) + self.assertEquals(distro['os_distro'], "fedora") + self.assertEquals(distro['os_version'], "20") + self.assertEquals(distro['os_arch'], "ppc64") + self.assertIn('path', distro) + else: + # Distro not found error + self.assertIn('KCHDISTRO0001E',distro.get('reason')) def test_debugreports(self): resp = request(host, port, '/debugreports') -- 1.8.5.3

This patch filters remote isos that should be showed to user by the system architecture. The UI now shows the architecture of the remote iso and sort the names of the distros. If host architecture is not found, all remote ISOs will be showed. Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com> --- src/kimchi/distroloader.py | 10 +++++++++- src/kimchi/model/config.py | 2 +- ui/pages/template-add.html.tmpl | 8 ++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/kimchi/distroloader.py b/src/kimchi/distroloader.py index daa5d5b..142cab6 100644 --- a/src/kimchi/distroloader.py +++ b/src/kimchi/distroloader.py @@ -28,6 +28,11 @@ from kimchi.exception import NotFoundError, OperationFailed from kimchi.utils import kimchi_log +ARCHS = {'x86_64': ['x86_64', 'amd64', 'i686', 'x86', 'i386'], + 'amd64': ['x86_64', 'amd64', 'i686', 'x86', 'i386'], + 'ppc64': ['ppc', 'ppc64']} + + class DistroLoader(object): def __init__(self, location=None): @@ -49,9 +54,12 @@ class DistroLoader(object): raise OperationFailed("KCHDL0002E", msg_args) def get(self): + arch_list = ARCHS.get(os.uname()[4]) all_json_files = glob.glob("%s/%s" % (self.location, "*.json")) distros = [] for f in all_json_files: distros.extend(self._get_json_info(f)) - return dict([(distro['name'], distro) for distro in distros]) + # Return all remote ISOs arch not found + return dict([(distro['name'], distro) for distro in distros if \ + (arch_list is None or distro['os_arch'] in arch_list)]) diff --git a/src/kimchi/model/config.py b/src/kimchi/model/config.py index e201737..5c90f0d 100644 --- a/src/kimchi/model/config.py +++ b/src/kimchi/model/config.py @@ -91,7 +91,7 @@ class DistrosModel(object): self.distros = distroloader.get() def get_list(self): - return self.distros.keys() + return sorted(self.distros.keys()) class DistroModel(object): diff --git a/ui/pages/template-add.html.tmpl b/ui/pages/template-add.html.tmpl index edce8d2..5c66753 100644 --- a/ui/pages/template-add.html.tmpl +++ b/ui/pages/template-add.html.tmpl @@ -158,11 +158,15 @@ <div class="iso-info-item" title="{os_distro}"> $_("OS: "){os_distro} </div> - </div> - <div class="iso-info-col"> <div class="iso-info-item" title="{os_version}"> $_("Version: "){os_version} </div> + + </div> + <div class="iso-info-col"> + <div class="iso-info-item" title="{os_arch}"> + $_("Arch: "){os_arch} + </div> </div> </div> </div> -- 1.8.5.3

Reviewed-by: Crístian Viana <vianac@linux.vnet.ibm.com> Am 06-03-2014 13:07, schrieb Rodrigo Trujillo:
V3: - Modify test cases
V2: - Sort UI list of remote distros - Change names of Fedora distros - Allow ISOs of similar architectures but with different names to be displayed, like (amd64 and x86_64)
V1: If Kimchi server is running in a PPC machine, the guests should be PPC. Currently, when user tries to create a template, only x86 isos are showed to user. This patch filters the ISOs, and also, adds ARCH to UI.
participants (3)
-
Aline Manera
-
Crístian Viana
-
Rodrigo Trujillo