diff options
author | Samuel Munilla <smunilla@redhat.com> | 2016-01-29 14:27:34 -0500 |
---|---|---|
committer | Samuel Munilla <smunilla@redhat.com> | 2016-02-12 08:33:35 -0500 |
commit | 140bafa78659ccbe32e282638641d7896214d8cb (patch) | |
tree | 0be9f21938844cd1fd5365a056b93137c9ed2fc8 /utils/src | |
parent | 2fd931794bf82cf3e11ad9267df9e0885dde7b1d (diff) | |
download | openshift-140bafa78659ccbe32e282638641d7896214d8cb.tar.gz openshift-140bafa78659ccbe32e282638641d7896214d8cb.tar.bz2 openshift-140bafa78659ccbe32e282638641d7896214d8cb.tar.xz openshift-140bafa78659ccbe32e282638641d7896214d8cb.zip |
a-o-i: Prompts to allow minor upgrades
Updates to the upgrade command to allow the user to select a minor
upgrade.
Diffstat (limited to 'utils/src')
-rw-r--r-- | utils/src/ooinstall/cli_installer.py | 30 | ||||
-rw-r--r-- | utils/src/ooinstall/openshift_ansible.py | 12 |
2 files changed, 32 insertions, 10 deletions
diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index 3046d4d58..e1047e700 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -722,14 +722,30 @@ def upgrade(ctx): click.echo("No hosts defined in: %s" % oo_cfg.config_path) sys.exit(1) - # Update config to reflect the version we're targetting, we'll write - # to disk once ansible completes successfully, not before. old_variant = oo_cfg.settings['variant'] old_version = oo_cfg.settings['variant_version'] - if oo_cfg.settings['variant'] == 'enterprise': - oo_cfg.settings['variant'] = 'openshift-enterprise' - version = find_variant(oo_cfg.settings['variant'])[1] - oo_cfg.settings['variant_version'] = version.name + + + message = """ + This tool will help you upgrade your existing OpenShift installation. +""" + click.echo(message) + click.echo("Version {} found. Do you want to update to the latest version of {} " \ + "or migrate to the next major release?".format(old_version, old_version)) + resp = click.prompt("(1) Update to latest {} (2) Migrate to next relese".format(old_version)) + + if resp == "2": + # TODO: Make this a lot more flexible + new_version = "3.1" + # Update config to reflect the version we're targetting, we'll write + # to disk once ansible completes successfully, not before. + if oo_cfg.settings['variant'] == 'enterprise': + oo_cfg.settings['variant'] = 'openshift-enterprise' + version = find_variant(oo_cfg.settings['variant'])[1] + oo_cfg.settings['variant_version'] = version.name + else: + new_version = old_version + click.echo("Openshift will be upgraded from %s %s to %s %s on the following hosts:\n" % ( old_variant, old_version, oo_cfg.settings['variant'], oo_cfg.settings['variant_version'])) @@ -743,7 +759,7 @@ def upgrade(ctx): click.echo("Upgrade cancelled.") sys.exit(0) - retcode = openshift_ansible.run_upgrade_playbook(verbose) + retcode = openshift_ansible.run_upgrade_playbook(old_version, new_version, verbose) if retcode > 0: click.echo("Errors encountered during upgrade, please check %s." % oo_cfg.settings['ansible_log_path']) diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index 042ce1023..ec49c9601 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -237,11 +237,17 @@ def run_uninstall_playbook(verbose=False): return run_ansible(playbook, inventory_file, facts_env, verbose) -def run_upgrade_playbook(verbose=False): +def run_upgrade_playbook(old_version, new_version, verbose=False): # TODO: do not hardcode the upgrade playbook, add ability to select the # right playbook depending on the type of upgrade. - playbook = os.path.join(CFG.settings['ansible_playbook_directory'], - 'playbooks/byo/openshift-cluster/upgrades/v3_0_to_v3_1/upgrade.yml') + old_version = old_version.replace('.', '_') + new_version = old_version.replace('.', '_') + if old_version == new_version: + playbook = os.path.join(CFG.settings['ansible_playbook_directory'], + '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)) # TODO: Upgrade inventory for upgrade? inventory_file = generate_inventory(CFG.hosts) facts_env = os.environ.copy() |