From 7eefcf8a04251da4d10deb936273847d47ccb609 Mon Sep 17 00:00:00 2001 From: Andrew Butcher Date: Thu, 22 Oct 2015 16:48:24 -0400 Subject: Move version greater_than_fact into openshift_facts --- roles/openshift_facts/library/openshift_facts.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'roles/openshift_facts/library') diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 3570de693..d0388e6fe 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -20,6 +20,7 @@ EXAMPLES = ''' import ConfigParser import copy import os +from ansible.runner.filter_plugins.core import version_compare from distutils.util import strtobool @@ -501,7 +502,12 @@ def set_deployment_facts_if_unset(facts): if deployment_type in ['enterprise', 'online']: data_dir = '/var/lib/openshift' facts['common']['data_dir'] = data_dir - facts['common']['version'] = get_openshift_version() + facts['common']['version'] = version = get_openshift_version() + if deployment_type == 'origin': + version_gt_3_1_or_1_1 = version_compare(version, '1.0.6', '>') + else: + version_gt_3_1_or_1_1 = version_compare(version, '3.0.2', '>') + facts['common']['version_greater_than_3_1_or_1_1'] = version_gt_3_1_or_1_1 for role in ('master', 'node'): if role in facts: @@ -632,7 +638,7 @@ def get_openshift_version(): Returns: version: the current openshift version """ - version = '' + version = None if os.path.isfile('/usr/bin/openshift'): _, output, _ = module.run_command(['/usr/bin/openshift', 'version']) -- cgit v1.2.3 From 05458ecde01c9c1ade9d1a5216bc7621a92b9d6f Mon Sep 17 00:00:00 2001 From: Andrew Butcher Date: Mon, 26 Oct 2015 09:00:59 -0400 Subject: Use standard library for version comparison. --- roles/openshift_facts/library/openshift_facts.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'roles/openshift_facts/library') diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index d0388e6fe..ece272c78 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -20,8 +20,8 @@ EXAMPLES = ''' import ConfigParser import copy import os -from ansible.runner.filter_plugins.core import version_compare from distutils.util import strtobool +from distutils.version import LooseVersion def hostname_valid(hostname): @@ -503,10 +503,13 @@ def set_deployment_facts_if_unset(facts): data_dir = '/var/lib/openshift' facts['common']['data_dir'] = data_dir facts['common']['version'] = version = get_openshift_version() - if deployment_type == 'origin': - version_gt_3_1_or_1_1 = version_compare(version, '1.0.6', '>') + if version is not None: + if deployment_type == 'origin': + version_gt_3_1_or_1_1 = LooseVersion(version) > LooseVersion('1.0.6') + else: + version_gt_3_1_or_1_1 = LooseVersion(version) > LooseVersion('3.0.2') else: - version_gt_3_1_or_1_1 = version_compare(version, '3.0.2', '>') + version_gt_3_1_or_1_1 = True facts['common']['version_greater_than_3_1_or_1_1'] = version_gt_3_1_or_1_1 for role in ('master', 'node'): -- cgit v1.2.3