diff options
Diffstat (limited to 'utils/src')
-rw-r--r-- | utils/src/ooinstall/cli_installer.py | 38 | ||||
-rw-r--r-- | utils/src/ooinstall/oo_config.py | 9 | ||||
-rw-r--r-- | utils/src/ooinstall/openshift_ansible.py | 9 |
3 files changed, 37 insertions, 19 deletions
diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index 9839bf447..f09f90288 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -138,9 +138,10 @@ http://docs.openshift.com/enterprise/latest/architecture/infrastructure_componen host_props['containerized'] = False if oo_cfg.settings['variant_version'] != '3.0': - rpm_or_container = click.prompt('Will this host be RPM or Container based (rpm/container)?', - type=click.Choice(['rpm', 'container']), - default='rpm') + rpm_or_container = \ + click.prompt('Will this host be RPM or Container based (rpm/container)?', + type=click.Choice(['rpm', 'container']), + default='rpm') if rpm_or_container == 'container': host_props['containerized'] = True @@ -281,7 +282,8 @@ hostname. host_props['connect_to'] = click.prompt('Enter hostname or IP address', value_proc=validate_prompt_lb) - install_haproxy = click.confirm('Should the reference haproxy load balancer be installed on this host?') + install_haproxy = \ + click.confirm('Should the reference haproxy load balancer be installed on this host?') host_props['preconfigured'] = not install_haproxy host_props['master'] = False host_props['node'] = False @@ -375,7 +377,8 @@ def check_hosts_config(oo_cfg, unattended): sys.exit(1) elif len(master_lb) == 1: if master_lb[0].master or master_lb[0].node: - click.echo('ERROR: The Master load balancer is configured as a master or node. Please correct this.') + click.echo('ERROR: The Master load balancer is configured as a master or node. ' \ + 'Please correct this.') sys.exit(1) else: message = """ @@ -525,18 +528,27 @@ Add new nodes here def get_installed_hosts(hosts, callback_facts): installed_hosts = [] + + # count nativeha lb as an installed host + try: + first_master = next(host for host in hosts if host.master) + lb_hostname = callback_facts[first_master.connect_to]['master'].get('cluster_hostname', '') + lb_host = next(host for host in hosts if host.connect_to == lb_hostname) + installed_hosts.append(lb_host) + except KeyError: + pass + + for host in hosts: - if host.connect_to in callback_facts.keys() and ( - ('common' in callback_facts[host.connect_to].keys() and - callback_facts[host.connect_to]['common'].get('version', '') and - callback_facts[host.connect_to]['common'].get('version', '') != 'None') \ - or - ('master' in callback_facts[host.connect_to].keys() and - callback_facts[host.connect_to]['master'].get('cluster_method', '') == 'native') - ): + if host.connect_to in callback_facts.keys() and is_installed_host(host, callback_facts): installed_hosts.append(host) return installed_hosts +def is_installed_host(host, callback_facts): + return 'common' in callback_facts[host.connect_to].keys() and \ + callback_facts[host.connect_to]['common'].get('version', '') and \ + callback_facts[host.connect_to]['common'].get('version', '') != 'None' + # pylint: disable=too-many-branches # This pylint error will be corrected shortly in separate PR. def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force, verbose): diff --git a/utils/src/ooinstall/oo_config.py b/utils/src/ooinstall/oo_config.py index 4861b1b1b..b1af21773 100644 --- a/utils/src/ooinstall/oo_config.py +++ b/utils/src/ooinstall/oo_config.py @@ -147,7 +147,8 @@ class OOConfig(object): raise OOConfigFileError('Cannot open config file "{}": {}'.format(ferr.filename, ferr.strerror)) except yaml.scanner.ScannerError: - raise OOConfigFileError('Config file "{}" is not a valid YAML document'.format(self.config_path)) + raise OOConfigFileError( + 'Config file "{}" is not a valid YAML document'.format(self.config_path)) def _upgrade_legacy_config(self): new_hosts = [] @@ -180,7 +181,8 @@ class OOConfig(object): if not os.path.exists(self.settings['ansible_inventory_directory']): os.makedirs(self.settings['ansible_inventory_directory']) if 'ansible_plugins_directory' not in self.settings: - self.settings['ansible_plugins_directory'] = resource_filename(__name__, 'ansible_plugins') + self.settings['ansible_plugins_directory'] = \ + resource_filename(__name__, 'ansible_plugins') if 'version' not in self.settings: self.settings['version'] = 'v1' @@ -191,7 +193,8 @@ class OOConfig(object): if 'ansible_ssh_user' not in self.settings: self.settings['ansible_ssh_user'] = '' - self.settings['ansible_inventory_path'] = '{}/hosts'.format(self.settings['ansible_inventory_directory']) + self.settings['ansible_inventory_path'] = \ + '{}/hosts'.format(self.settings['ansible_inventory_directory']) # clean up any empty sets for setting in self.settings.keys(): diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index 9d82f4f0e..f2c7289fa 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -113,9 +113,11 @@ def write_inventory_vars(base_inventory, multiple_masters, proxy): if multiple_masters and proxy is not None: base_inventory.write('openshift_master_cluster_method=native\n') base_inventory.write("openshift_master_cluster_hostname={}\n".format(proxy.hostname)) - base_inventory.write("openshift_master_cluster_public_hostname={}\n".format(proxy.public_hostname)) + base_inventory.write( + "openshift_master_cluster_public_hostname={}\n".format(proxy.public_hostname)) if CFG.settings.get('master_routingconfig_subdomain', False): - base_inventory.write("osm_default_subdomain={}\n".format(CFG.settings['master_routingconfig_subdomain'])) + base_inventory.write( + "osm_default_subdomain={}\n".format(CFG.settings['master_routingconfig_subdomain'])) @@ -247,7 +249,8 @@ def run_upgrade_playbook(old_version, new_version, verbose=False): 'playbooks/byo/openshift-cluster/upgrades/v{}_minor/upgrade.yml'.format(new_version)) else: playbook = os.path.join(CFG.settings['ansible_playbook_directory'], - 'playbooks/byo/openshift-cluster/upgrades/v{}_to_v{}/upgrade.yml'.format(old_version, new_version)) + 'playbooks/byo/openshift-cluster/upgrades/v{}_to_v{}/upgrade.yml'.format(old_version, + new_version)) # TODO: Upgrade inventory for upgrade? inventory_file = generate_inventory(CFG.hosts) facts_env = os.environ.copy() |