From 87bfac4ebf7969319d34e1c2562c3179739bd868 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Tue, 19 May 2015 10:41:07 +0000 Subject: morph deploy: Allow overriding UPGRADE in definition or on command line Concievably, you may want to force a cluster to behave as an upgrade regardless of whether --upgrade is set or not. This would allow two use cases that are not currently possible: 1. To force a cluster to be upgrade-only, which would make our instructions for the upgrade-devel.morph cluster simpler. 2. To allow a cluster to deploy then immediately upgrade. One potential use for this would be to create a disk image with multiple versions on it. This also works as a work-around for --upgrade implying UPGRADE=yes for subsystem deployments, but that should be fixed separately. Change-Id: I2ec4b880fc9bce37adee9df67696f088c76650f4 --- morphlib/plugins/deploy_plugin.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'morphlib/plugins') diff --git a/morphlib/plugins/deploy_plugin.py b/morphlib/plugins/deploy_plugin.py index 7ab2e64b..cca95e69 100644 --- a/morphlib/plugins/deploy_plugin.py +++ b/morphlib/plugins/deploy_plugin.py @@ -65,6 +65,12 @@ def configuration_for_system(system_id, vars_from_commandline, return final_env +def determine_if_upgrade(deploy_env, upgrade_config): + if 'UPGRADE' not in deploy_env: + return upgrade_config + return deploy_env['UPGRADE'].lower() in ('1', 'true', 'yes') + + def deployment_type_and_location(system_id, config, is_upgrade): '''Get method and location for deploying a given system. @@ -493,12 +499,13 @@ class DeployPlugin(cliapp.Plugin): final_env = configuration_for_system( system_id, env_vars, deploy_defaults, deploy_params) - is_upgrade = ('yes' if self.app.settings['upgrade'] - else 'no') - final_env['UPGRADE'] = is_upgrade + is_upgrade = determine_if_upgrade( + deploy_env=final_env, + upgrade_config=self.app.settings['upgrade']) + final_env['UPGRADE'] = ('yes' if is_upgrade else 'no') deployment_type, location = deployment_type_and_location( - system_id, final_env, self.app.settings['upgrade']) + system_id, final_env, is_upgrade) components = self._sanitise_morphology_paths( deploy_params.get('partial-deploy-components', []), sb) -- cgit v1.2.1