]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
[RM-11115] use the new class for normalized versions
authorAlfredo Deza <adeza@redhat.com>
Tue, 11 Aug 2015 18:19:40 +0000 (14:19 -0400)
committerAlfredo Deza <adeza@redhat.com>
Thu, 13 Aug 2015 12:31:52 +0000 (08:31 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
ceph_deploy/hosts/__init__.py

index 18ec5479f069643f6857e8e7dc58170b2efa1695..17aa99e70750ad31a8fadb6cf36a4decaa31acb3 100644 (file)
@@ -6,6 +6,7 @@ on the type of distribution/version we are dealing with.
 """
 import logging
 from ceph_deploy import exc
+from ceph_deploy.util import versions
 from ceph_deploy.hosts import debian, centos, fedora, suse, remotes, rhel
 from ceph_deploy.connection import get_connection
 
@@ -121,21 +122,6 @@ def _normalized_release(release):
 
         normalized_version.int_major
     """
-    release = release.strip()
-
-    class NormalizedVersion(object):
-        pass
-    v = NormalizedVersion()  # fake object to get nice dotted access
-    v.major, v.minor, v.patch, v.garbage = (release.split('.') + ["0"]*4)[:4]
-    release_map = dict(major=v.major, minor=v.minor, patch=v.patch, garbage=v.garbage)
-
-    # safe int versions that remove non-numerical chars
-    # for example 'rc1' in a version like '1-rc1
-    for name, value in release_map.items():
-        if '-' in value:  # get rid of garbage like -dev1 or -rc1
-            value = value.split('-')[0]
-        value = float(''.join(c for c in value if c.isdigit()) or 0)
-        int_name = "int_%s" % name
-        setattr(v, int_name, value)
-
-    return v
+    # TODO: at some point deprecate this function so that we just
+    # use this class directly (and update every test that calls it
+    return versions.NormalizedVersion(release)