[PATCH] Add os_arch field to distros

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. Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com> --- src/distros.d/debian.json | 1 + src/distros.d/fedora.json | 3 +++ src/distros.d/gentoo.json | 1 + src/distros.d/opensuse.json | 1 + src/distros.d/ubuntu.json | 2 ++ src/kimchi/distroloader.py | 3 ++- 6 files changed, 10 insertions(+), 1 deletion(-) 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..d78205b 100644 --- a/src/distros.d/fedora.json +++ b/src/distros.d/fedora.json @@ -2,18 +2,21 @@ { "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", "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", "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..." } 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" } diff --git a/src/kimchi/distroloader.py b/src/kimchi/distroloader.py index 98fd764..d8e76bf 100644 --- a/src/kimchi/distroloader.py +++ b/src/kimchi/distroloader.py @@ -51,9 +51,10 @@ class DistroLoader(object): raise OperationFailed(msg) def get(self): + arch = 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 dict([(distro['name'], distro) for distro in distros if distro['os_arch'] == arch]) -- 1.8.5.3

Am 05-02-2014 19:51, schrieb Christy Perez:
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. Does this prevent a user running on an x86_64 host from creating an x86 guest?

On Wed, 2014-02-05 at 21:38 -0200, Crístian Viana wrote:
Am 05-02-2014 19:51, schrieb Christy Perez:
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. Does this prevent a user running on an x86_64 host from creating an x86 guest?
Yes. I guess the best is create a dictionary with all architectures supported. So, the distroloader.py should be also, like: diff --git a/src/kimchi/distroloader.py b/src/kimchi/distroloader.py index 98fd764..d8e76bf 100644 --- a/src/kimchi/distroloader.py +++ b/src/kimchi/distroloader.py @@ -51,9 +51,10 @@ class DistroLoader(object): raise OperationFailed(msg) def get(self): + arch = {'x86_64': ['x86_64', 'amd64', 'i686', 'x86'], 'amd64': ['x86_64', 'amd64', 'i686', 'x86']} 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 dict([(distro['name'], distro) for distro in distros if distro['os_arch'] in arch[os.uname()[4]]]) May be this can dictionary or map should be added in src/kimchi/utils.py and the compatibility returned by a function. In addition, the arch of Debian, Ubuntu and Gentoo entries should be 'amd64' instead of 'x86_64'. Best regards, Paulo.
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel

Thanks Paulo, Crístian See replies below. On Thu, 2014-02-06 at 10:45 -0200, Paulo Ricardo Paz Vital wrote:
On Wed, 2014-02-05 at 21:38 -0200, Crístian Viana wrote:
Am 05-02-2014 19:51, schrieb Christy Perez:
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. Does this prevent a user running on an x86_64 host from creating an x86 guest?
Yes. I guess the best is create a dictionary with all architectures supported. So, the distroloader.py should be also, like:
diff --git a/src/kimchi/distroloader.py b/src/kimchi/distroloader.py index 98fd764..d8e76bf 100644 --- a/src/kimchi/distroloader.py +++ b/src/kimchi/distroloader.py @@ -51,9 +51,10 @@ class DistroLoader(object): raise OperationFailed(msg)
def get(self): + arch = {'x86_64': ['x86_64', 'amd64', 'i686', 'x86'], 'amd64': ['x86_64', 'amd64', 'i686', 'x86']} 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 dict([(distro['name'], distro) for distro in distros if distro['os_arch'] in arch[os.uname()[4]]])
May be this can dictionary or map should be added in src/kimchi/utils.py and the compatibility returned by a function. I'll change it to do that.
In addition, the arch of Debian, Ubuntu and Gentoo entries should be 'amd64' instead of 'x86_64'.
Ok, will do that too. It works well with your "in arch" dictionary check. Thanks!
Best regards, Paulo.
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel

Reviewed-By: Ramon Medeiros <ramonn@br.ibm.com> -- Ramon Nunes Medeiros Software Engineer - Linux Technology Center Brazil IBM Systems & Technology Group Phone : +55 19 2132 7878 ramonn@br.ibm.com
participants (4)
-
Christy Perez
-
Crístian Viana
-
Paulo Ricardo Paz Vital
-
Ramon Medeiros