From 864dff6aa72615a85e3c7180cfd65cacb66867da Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Fri, 29 Aug 2014 23:18:45 +0100 Subject: Add `morph upgrade` command, deprecate `morph deploy --upgrade` The arguments to `morph deploy` can get quite long, any way we can make it shorter and clearer is useful. We can also avoid having the strange --no-upgrade flag in future. --- morphlib/plugins/deploy_plugin.py | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'morphlib/plugins/deploy_plugin.py') diff --git a/morphlib/plugins/deploy_plugin.py b/morphlib/plugins/deploy_plugin.py index b55478ad..f3e43fa8 100644 --- a/morphlib/plugins/deploy_plugin.py +++ b/morphlib/plugins/deploy_plugin.py @@ -32,12 +32,15 @@ class DeployPlugin(cliapp.Plugin): group_deploy = 'Deploy Options' self.app.settings.boolean(['upgrade'], 'specify that you want to upgrade an ' - 'existing cluster of systems rather than do ' - 'an initial deployment', + 'existing cluster. Deprecated: use the ' + '`morph upgrade` command instead', group=group_deploy) self.app.add_subcommand( 'deploy', self.deploy, arg_synopsis='CLUSTER [DEPLOYMENT...] [SYSTEM.KEY=VALUE]') + self.app.add_subcommand( + 'upgrade', self.upgrade, + arg_synopsis='CLUSTER [DEPLOYMENT...] [SYSTEM.KEY=VALUE]') def disable(self): pass @@ -300,8 +303,8 @@ class DeployPlugin(cliapp.Plugin): if cluster_morphology['kind'] != 'cluster': raise cliapp.AppException( - "Error: morph deploy is only supported for cluster" - " morphologies.") + "Error: morph deployment commands are only supported for " + "cluster morphologies.") # parse the rest of the args all_subsystems = set() @@ -432,6 +435,25 @@ class DeployPlugin(cliapp.Plugin): finally: self.app.status_prefix = old_status_prefix + def upgrade(self, args): + '''Upgrade an existing set of instances using built images. + + See `morph help deploy` for documentation. + + ''' + + if not args: + raise cliapp.AppException( + 'Too few arguments to upgrade command (see `morph help ' + 'deploy`)') + + if self.app.settings['upgrade']: + raise cliapp.AppException( + 'Running `morph upgrade --upgrade` does not make sense.') + + self.app.settings['upgrade'] = True + self.deploy(args) + def check_deploy(self, root_repo_dir, ref, deployment_type, location, env): # Run optional write check extension. These are separate from the write # extension because it may be several minutes before the write -- cgit v1.2.1