From 7c256d98890d425ac80063959a21117311399385 Mon Sep 17 00:00:00 2001 From: Marco Mariani <marco.mariani@nexedi.com> Date: Fri, 18 Jan 2013 11:27:17 +0100 Subject: [PATCH] only match major release number in debian --- CHANGES.txt | 1 + slapos/grid/networkcache.py | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 15b907783..3fbf38e95 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,7 @@ Changes 0.33.x (unreleased) ------------------- + * networkcache: only match major release number in debian [Marco Mariani] * slapproxy: Filter by instance_guid, allow computer partition renames and change of software_type and requested_state [Marco Mariani] * slapproxy: Stop instance even if buildout/reporting is wrong [Cedric de Saint Martin] diff --git a/slapos/grid/networkcache.py b/slapos/grid/networkcache.py index 4458dca6d..c106b441c 100644 --- a/slapos/grid/networkcache.py +++ b/slapos/grid/networkcache.py @@ -12,10 +12,11 @@ # ############################################################################## -import shutil -import traceback +import ast import json import platform +import shutil +import traceback try: try: @@ -47,6 +48,18 @@ def fallback_call(function): return wrapper +def debianize(os): + # return only the major release number in case of debian + distname, version, id_ = os + if distname == 'debian': + version = version.split('.')[0] + return distname, version, id_ + + +def os_matches(os1, os2): + return debianize(os1) == debianize(os2) + + @fallback_call def download_network_cached(cache_url, dir_url, software_url, software_root, key, path, logger, signature_certificate_list, @@ -85,7 +98,8 @@ def download_network_cached(cache_url, dir_url, software_url, software_root, tags = json.loads(json_information) if tags.get('machine') != platform.machine(): continue - if tags.get('os') != str(platform.linux_distribution()): + if not os_matches(ast.literal_eval(tags.get('os')), + platform.linux_distribution()): continue if tags.get('software_url') != software_url: continue -- 2.30.9