summaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
Diffstat (limited to 'roles')
-rwxr-xr-xroles/openshift_facts/library/openshift_facts.py35
1 files changed, 25 insertions, 10 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py
index 9754687cf..a28b58e85 100755
--- a/roles/openshift_facts/library/openshift_facts.py
+++ b/roles/openshift_facts/library/openshift_facts.py
@@ -7,7 +7,13 @@
"""Ansible module for retrieving and setting openshift related facts"""
-import ConfigParser
+try:
+ # python2
+ import ConfigParser
+except ImportError:
+ # python3
+ import configparser as ConfigParser
+
import copy
import io
import os
@@ -202,9 +208,9 @@ def query_metadata(metadata_url, headers=None, expect_json=False):
if info['status'] != 200:
raise OpenShiftFactsMetadataUnavailableError("Metadata unavailable")
if expect_json:
- return module.from_json(result.read())
+ return module.from_json(to_native(result.read()))
else:
- return [line.strip() for line in result.readlines()]
+ return [to_native(line.strip()) for line in result.readlines()]
def walk_metadata(metadata_url, headers=None, expect_json=False):
@@ -312,7 +318,7 @@ def normalize_aws_facts(metadata, facts):
):
int_info = dict()
var_map = {'ips': 'local-ipv4s', 'public_ips': 'public-ipv4s'}
- for ips_var, int_var in var_map.iteritems():
+ for ips_var, int_var in iteritems(var_map):
ips = interface.get(int_var)
if isinstance(ips, basestring):
int_info[ips_var] = [ips]
@@ -832,23 +838,29 @@ def set_version_facts_if_unset(facts):
version_gte_3_1_1_or_1_1_1 = LooseVersion(version) >= LooseVersion('1.1.1')
version_gte_3_2_or_1_2 = LooseVersion(version) >= LooseVersion('1.2.0')
version_gte_3_3_or_1_3 = LooseVersion(version) >= LooseVersion('1.3.0')
+ version_gte_3_4_or_1_4 = LooseVersion(version) >= LooseVersion('1.4.0')
else:
version_gte_3_1_or_1_1 = LooseVersion(version) >= LooseVersion('3.0.2.905')
version_gte_3_1_1_or_1_1_1 = LooseVersion(version) >= LooseVersion('3.1.1')
version_gte_3_2_or_1_2 = LooseVersion(version) >= LooseVersion('3.1.1.901')
version_gte_3_3_or_1_3 = LooseVersion(version) >= LooseVersion('3.3.0')
+ version_gte_3_4_or_1_4 = LooseVersion(version) >= LooseVersion('3.4.0')
else:
version_gte_3_1_or_1_1 = True
version_gte_3_1_1_or_1_1_1 = True
version_gte_3_2_or_1_2 = True
- version_gte_3_3_or_1_3 = False
+ version_gte_3_3_or_1_3 = True
+ version_gte_3_4_or_1_4 = False
facts['common']['version_gte_3_1_or_1_1'] = version_gte_3_1_or_1_1
facts['common']['version_gte_3_1_1_or_1_1_1'] = version_gte_3_1_1_or_1_1_1
facts['common']['version_gte_3_2_or_1_2'] = version_gte_3_2_or_1_2
facts['common']['version_gte_3_3_or_1_3'] = version_gte_3_3_or_1_3
+ facts['common']['version_gte_3_4_or_1_4'] = version_gte_3_4_or_1_4
- if version_gte_3_3_or_1_3:
+ if version_gte_3_4_or_1_4:
+ examples_content_version = 'v1.4'
+ elif version_gte_3_3_or_1_3:
examples_content_version = 'v1.3'
elif version_gte_3_2_or_1_2:
examples_content_version = 'v1.2'
@@ -931,7 +943,7 @@ def set_sdn_facts_if_unset(facts, system_facts):
# default MTU if interface MTU cannot be detected
facts['node']['sdn_mtu'] = '1450'
- for val in system_facts.itervalues():
+ for val in itervalues(system_facts):
if isinstance(val, dict) and 'mtu' in val:
mtu = val['mtu']
@@ -1358,7 +1370,7 @@ def merge_facts(orig, new, additive_facts_to_overwrite, protected_facts_to_overw
'image_policy_config']
facts = dict()
- for key, value in orig.iteritems():
+ for key, value in iteritems(orig):
# Key exists in both old and new facts.
if key in new:
if key in inventory_json_facts:
@@ -2112,7 +2124,7 @@ class OpenShiftFacts(object):
facts_to_set[self.role] = facts
if openshift_env != {} and openshift_env != None:
- for fact, value in openshift_env.iteritems():
+ for fact, value in iteritems(openshift_env):
oo_env_facts = dict()
current_level = oo_env_facts
keys = self.split_openshift_env_fact_keys(fact, openshift_env_structures)[1:]
@@ -2170,7 +2182,7 @@ class OpenShiftFacts(object):
facts (dict): facts to clean
"""
facts_to_remove = []
- for fact, value in facts.iteritems():
+ for fact, value in iteritems(facts):
if isinstance(facts[fact], dict):
facts[fact] = self.remove_empty_facts(facts[fact])
else:
@@ -2301,6 +2313,9 @@ def main():
from ansible.module_utils.basic import *
from ansible.module_utils.facts import *
from ansible.module_utils.urls import *
+from ansible.module_utils.six import iteritems, itervalues
+from ansible.module_utils._text import to_native
+from ansible.module_utils.six import b
if __name__ == '__main__':
main()