summaryrefslogtreecommitdiffstats
path: root/utils/src
diff options
context:
space:
mode:
authorBrenton Leanhardt <bleanhar@redhat.com>2015-11-05 13:37:51 -0500
committerBrenton Leanhardt <bleanhar@redhat.com>2015-11-05 15:14:11 -0500
commit837ea49bba342aa1fa87736947979ee5235da727 (patch)
tree5f102876ea812b07eee2ab5c02123226e709d423 /utils/src
parenta552645b05d4af2180596fb01837d0f1062b3ac5 (diff)
downloadopenshift-837ea49bba342aa1fa87736947979ee5235da727.tar.gz
openshift-837ea49bba342aa1fa87736947979ee5235da727.tar.bz2
openshift-837ea49bba342aa1fa87736947979ee5235da727.tar.xz
openshift-837ea49bba342aa1fa87736947979ee5235da727.zip
Bug 1278244 - Previously there was no way to add a node in unattended mode
TODO: We desparately need tests cases for: - interactive with no config file - interactive with config file and all installed hosts - interactive with config file and no installed hosts - interactive with config file and some installed some uninstalled hosts - unattended with config file and all installed hosts (with and without --force) - unattended with config file and no installed hosts (with and without --force) - unattended with config file and some installed some uninstalled hosts (with and without --force)
Diffstat (limited to 'utils/src')
-rw-r--r--utils/src/ooinstall/cli_installer.py69
1 files changed, 44 insertions, 25 deletions
diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py
index ff740e426..9bf3bc714 100644
--- a/utils/src/ooinstall/cli_installer.py
+++ b/utils/src/ooinstall/cli_installer.py
@@ -331,7 +331,22 @@ def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force):
# Check if master or nodes already have something installed
installed_hosts = get_installed_hosts(oo_cfg.hosts, callback_facts)
if len(installed_hosts) > 0:
- # present a message listing already installed hosts
+ click.echo('Installed environment detected.')
+ # This check has to happen before we start removing hosts later in this method
+ if not force:
+ if not unattended:
+ click.echo('By default the installer only adds new nodes to an installed environment.')
+ response = click.prompt('Do you want to (1) only add additional nodes or ' \
+ '(2) perform a clean install?', type=int)
+ # TODO: this should be reworked with error handling.
+ # Click can certainly do this for us.
+ # This should be refactored as soon as we add a 3rd option.
+ if response == 1:
+ force = False
+ if response == 2:
+ force = True
+
+ # present a message listing already installed hosts and remove hosts if needed
for host in installed_hosts:
if host.master:
click.echo("{} is already an OpenShift Master".format(host))
@@ -343,33 +358,37 @@ def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force):
# anything.
if not force:
hosts_to_run_on.remove(host)
- for new_host in set(hosts_to_run_on) - set(installed_hosts):
- click.echo("{} is currently uninstalled".format(new_host))
- # for unattended either continue if they force install or exit if they didn't
- if unattended:
- if not force:
- click.echo('Installed environment detected and no additional nodes specified: ' \
- 'aborting. If you want a fresh install, use --force')
- sys.exit(1)
- # for attended ask the user what to do
+
+ # Handle the cases where we know about uninstalled systems
+ new_hosts = set(hosts_to_run_on) - set(installed_hosts)
+ if len(new_hosts) > 0:
+ for new_host in new_hosts:
+ click.echo("{} is currently uninstalled".format(new_host))
+
+ # Fall through
+ click.echo('Adding additional nodes...')
else:
- click.echo('Installed environment detected and no additional nodes specified. ')
- response = click.prompt('Do you want to (1) add more nodes or ' \
- '(2) perform a clean install?', type=int)
- if response == 1: # add more nodes
- new_nodes = collect_new_nodes()
-
- hosts_to_run_on.extend(new_nodes)
- oo_cfg.hosts.extend(new_nodes)
-
- openshift_ansible.set_config(oo_cfg)
- callback_facts, error = openshift_ansible.default_facts(oo_cfg.hosts)
- if error:
- click.echo("There was a problem fetching the required information. " \
- "See {} for details.".format(oo_cfg.settings['ansible_log_path']))
+ if unattended:
+ if not force:
+ click.echo('Installed environment detected and no additional nodes specified: ' \
+ 'aborting. If you want a fresh install, use --force')
sys.exit(1)
else:
- pass # proceeding as normal should do a clean install
+ if not force:
+ new_nodes = collect_new_nodes()
+
+ hosts_to_run_on.extend(new_nodes)
+ oo_cfg.hosts.extend(new_nodes)
+
+ openshift_ansible.set_config(oo_cfg)
+ click.echo('Gathering information from hosts...')
+ callback_facts, error = openshift_ansible.default_facts(oo_cfg.hosts)
+ if error:
+ click.echo("There was a problem fetching the required information. " \
+ "See {} for details.".format(oo_cfg.settings['ansible_log_path']))
+ sys.exit(1)
+ else:
+ pass # proceeding as normal should do a clean install
return hosts_to_run_on, callback_facts