summaryrefslogtreecommitdiffstats
path: root/utils/src/ooinstall
diff options
context:
space:
mode:
Diffstat (limited to 'utils/src/ooinstall')
-rw-r--r--utils/src/ooinstall/cli_installer.py2
-rw-r--r--utils/src/ooinstall/oo_config.py27
-rw-r--r--utils/src/ooinstall/openshift_ansible.py20
-rw-r--r--utils/src/ooinstall/variants.py44
4 files changed, 44 insertions, 49 deletions
diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py
index 7e5ad4144..b70bd1817 100644
--- a/utils/src/ooinstall/cli_installer.py
+++ b/utils/src/ooinstall/cli_installer.py
@@ -501,7 +501,7 @@ def get_variant_and_version(multi_master=False):
i = 1
combos = get_variant_version_combos()
- for (variant, version) in combos:
+ for (variant, _) in combos:
message = "%s\n(%s) %s" % (message, i, variant.description)
i = i + 1
message = "%s\n" % message
diff --git a/utils/src/ooinstall/oo_config.py b/utils/src/ooinstall/oo_config.py
index 64eb340f3..cf14105af 100644
--- a/utils/src/ooinstall/oo_config.py
+++ b/utils/src/ooinstall/oo_config.py
@@ -1,5 +1,7 @@
# pylint: disable=bad-continuation,missing-docstring,no-self-use,invalid-name,too-many-instance-attributes,too-few-public-methods
+from __future__ import (absolute_import, print_function)
+
import os
import sys
import logging
@@ -50,7 +52,7 @@ Error loading config. {}.
See https://docs.openshift.com/enterprise/latest/install_config/install/quick_install.html#defining-an-installation-configuration-file
for information on creating a configuration file or delete {} and re-run the installer.
"""
- print message.format(error, path)
+ print(message.format(error, path))
class OOConfigFileError(Exception):
@@ -103,7 +105,7 @@ class Host(object):
# If the property is defined (not None or False), export it:
if getattr(self, prop):
d[prop] = getattr(self, prop)
- for variable, value in self.other_variables.iteritems():
+ for variable, value in self.other_variables.items():
d[variable] = value
return d
@@ -256,16 +258,16 @@ class OOConfig(object):
# Parse the hosts into DTO objects:
for host in host_list:
host['other_variables'] = {}
- for variable, value in host.iteritems():
+ for variable, value in host.items():
if variable not in HOST_VARIABLES_BLACKLIST:
host['other_variables'][variable] = value
self.deployment.hosts.append(Host(**host))
# Parse the roles into Objects
- for name, variables in role_list.iteritems():
+ for name, variables in role_list.items():
self.deployment.roles.update({name: Role(name, variables)})
- except IOError, ferr:
+ except IOError as ferr:
raise OOConfigFileError('Cannot open config file "{}": {}'.format(ferr.filename,
ferr.strerror))
except yaml.scanner.ScannerError:
@@ -354,14 +356,13 @@ class OOConfig(object):
self.settings['ansible_inventory_path'] = \
'{}/hosts'.format(os.path.dirname(self.config_path))
- # pylint: disable=consider-iterating-dictionary
- # Disabled because we shouldn't alter the container we're
- # iterating over
- #
# clean up any empty sets
- for setting in self.settings.keys():
+ empty_keys = []
+ for setting in self.settings:
if not self.settings[setting]:
- self.settings.pop(setting)
+ empty_keys.append(setting)
+ for key in empty_keys:
+ self.settings.pop(key)
installer_log.debug("Updated OOConfig settings: %s", self.settings)
@@ -410,7 +411,7 @@ class OOConfig(object):
for host in self.deployment.hosts:
p_settings['deployment']['hosts'].append(host.to_dict())
- for name, role in self.deployment.roles.iteritems():
+ for name, role in self.deployment.roles.items():
p_settings['deployment']['roles'][name] = role.variables
for setting in self.deployment.variables:
@@ -424,7 +425,7 @@ class OOConfig(object):
if self.settings['ansible_inventory_directory'] != self._default_ansible_inv_dir():
p_settings['ansible_inventory_directory'] = self.settings['ansible_inventory_directory']
except KeyError as e:
- print "Error persisting settings: {}".format(e)
+ print("Error persisting settings: {}".format(e))
sys.exit(0)
return p_settings
diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py
index f542fb376..113aca0e1 100644
--- a/utils/src/ooinstall/openshift_ansible.py
+++ b/utils/src/ooinstall/openshift_ansible.py
@@ -1,5 +1,7 @@
# pylint: disable=bad-continuation,missing-docstring,no-self-use,invalid-name,global-statement,global-variable-not-assigned
+from __future__ import (absolute_import, print_function)
+
import socket
import subprocess
import sys
@@ -107,12 +109,12 @@ def write_inventory_vars(base_inventory, lb):
global CFG
base_inventory.write('\n[OSEv3:vars]\n')
- for variable, value in CFG.settings.iteritems():
+ for variable, value in CFG.settings.items():
inventory_var = VARIABLES_MAP.get(variable, None)
if inventory_var and value:
base_inventory.write('{}={}\n'.format(inventory_var, value))
- for variable, value in CFG.deployment.variables.iteritems():
+ for variable, value in CFG.deployment.variables.items():
inventory_var = VARIABLES_MAP.get(variable, variable)
if value:
base_inventory.write('{}={}\n'.format(inventory_var, value))
@@ -152,11 +154,11 @@ def write_inventory_vars(base_inventory, lb):
"'baseurl': '{}', "
"'enabled': 1, 'gpgcheck': 0}}]\n".format(os.environ['OO_INSTALL_PUDDLE_REPO']))
- for name, role_obj in CFG.deployment.roles.iteritems():
+ for name, role_obj in CFG.deployment.roles.items():
if role_obj.variables:
group_name = ROLES_TO_GROUPS_MAP.get(name, name)
base_inventory.write("\n[{}:vars]\n".format(group_name))
- for variable, value in role_obj.variables.iteritems():
+ for variable, value in role_obj.variables.items():
inventory_var = VARIABLES_MAP.get(variable, variable)
if value:
base_inventory.write('{}={}\n'.format(inventory_var, value))
@@ -193,7 +195,7 @@ def write_host(host, role, inventory, schedulable=None):
facts += ' {}={}'.format(HOST_VARIABLES_MAP.get(prop), getattr(host, prop))
if host.other_variables:
- for variable, value in host.other_variables.iteritems():
+ for variable, value in host.other_variables.items():
facts += " {}={}".format(variable, value)
if host.node_labels and role == 'node':
@@ -212,7 +214,7 @@ def write_host(host, role, inventory, schedulable=None):
if os.geteuid() != 0:
no_pwd_sudo = subprocess.call(['sudo', '-n', 'echo', 'openshift'])
if no_pwd_sudo == 1:
- print 'The atomic-openshift-installer requires sudo access without a password.'
+ print('The atomic-openshift-installer requires sudo access without a password.')
sys.exit(1)
facts += ' ansible_become=yes'
@@ -245,9 +247,9 @@ def load_system_facts(inventory_file, os_facts_path, env_vars, verbose=False):
installer_log.debug("Going to try to read this file: %s", CFG.settings['ansible_callback_facts_yaml'])
try:
callback_facts = yaml.safe_load(callback_facts_file)
- except yaml.YAMLError, exc:
- print "Error in {}".format(CFG.settings['ansible_callback_facts_yaml']), exc
- print "Try deleting and rerunning the atomic-openshift-installer"
+ except yaml.YAMLError as exc:
+ print("Error in {}".format(CFG.settings['ansible_callback_facts_yaml']), exc)
+ print("Try deleting and rerunning the atomic-openshift-installer")
sys.exit(1)
return callback_facts, 0
diff --git a/utils/src/ooinstall/variants.py b/utils/src/ooinstall/variants.py
index 39772bb2e..a45be98bf 100644
--- a/utils/src/ooinstall/variants.py
+++ b/utils/src/ooinstall/variants.py
@@ -38,32 +38,24 @@ class Variant(object):
# WARNING: Keep the versions ordered, most recent first:
-OSE = Variant('openshift-enterprise', 'OpenShift Container Platform',
- [
- Version('3.4', 'openshift-enterprise'),
- ]
-)
-
-REG = Variant('openshift-enterprise', 'Registry',
- [
- Version('3.4', 'openshift-enterprise', 'registry'),
- ]
-)
-
-origin = Variant('origin', 'OpenShift Origin',
- [
- Version('1.4', 'origin'),
- ]
-)
-
-LEGACY = Variant('openshift-enterprise', 'OpenShift Container Platform',
- [
- Version('3.3', 'openshift-enterprise'),
- Version('3.2', 'openshift-enterprise'),
- Version('3.1', 'openshift-enterprise'),
- Version('3.0', 'openshift-enterprise'),
- ]
-)
+OSE = Variant('openshift-enterprise', 'OpenShift Container Platform', [
+ Version('3.4', 'openshift-enterprise'),
+])
+
+REG = Variant('openshift-enterprise', 'Registry', [
+ Version('3.4', 'openshift-enterprise', 'registry'),
+])
+
+origin = Variant('origin', 'OpenShift Origin', [
+ Version('1.4', 'origin'),
+])
+
+LEGACY = Variant('openshift-enterprise', 'OpenShift Container Platform', [
+ Version('3.3', 'openshift-enterprise'),
+ Version('3.2', 'openshift-enterprise'),
+ Version('3.1', 'openshift-enterprise'),
+ Version('3.0', 'openshift-enterprise'),
+])
# Ordered list of variants we can install, first is the default.
SUPPORTED_VARIANTS = (OSE, REG, origin, LEGACY)