summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam@afuera.me.uk>2014-08-29 23:18:45 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-09-01 10:35:16 +0100
commit864dff6aa72615a85e3c7180cfd65cacb66867da (patch)
tree8ba3dea5b0ba8143afda9b549a1f0e232cbbddf7
parent5c90ccfd74d28d817fab50079f0233cd8a555d3a (diff)
downloadmorph-864dff6aa72615a85e3c7180cfd65cacb66867da.tar.gz
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.
-rwxr-xr-xmorphlib/exts/rawdisk.check4
-rw-r--r--morphlib/plugins/deploy_plugin.py30
-rw-r--r--yarns/deployment.yarn2
-rw-r--r--yarns/implementations.yarn2
4 files changed, 30 insertions, 8 deletions
diff --git a/morphlib/exts/rawdisk.check b/morphlib/exts/rawdisk.check
index 5e75abe2..acdc4de1 100755
--- a/morphlib/exts/rawdisk.check
+++ b/morphlib/exts/rawdisk.check
@@ -46,7 +46,7 @@ class RawdiskCheckExtension(morphlib.writeexts.WriteExtension):
else:
if os.path.exists(location):
raise cliapp.AppException(
- 'Target %s already exists. Pass --upgrade if you want to '
- 'update an existing image.' % location)
+ 'Target %s already exists. Use `morph upgrade` if you '
+ 'want to update an existing image.' % location)
RawdiskCheckExtension().run()
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
diff --git a/yarns/deployment.yarn b/yarns/deployment.yarn
index 4039d551..40b50432 100644
--- a/yarns/deployment.yarn
+++ b/yarns/deployment.yarn
@@ -7,7 +7,7 @@ Morph Deployment Tests
WHEN the user checks out the system branch called master
AND the user attempts to deploy the system systems/test-system.morph in branch master
THEN morph failed
- AND the deploy error message includes the string "morph deploy is only supported for cluster morphologies"
+ AND the deploy error message includes the string "morph deployment commands are only supported for cluster morphologies"
FINALLY the git server is shut down
SCENARIO deploying a cluster morphology as a tarfile
diff --git a/yarns/implementations.yarn b/yarns/implementations.yarn
index 422c2eea..52eee01d 100644
--- a/yarns/implementations.yarn
+++ b/yarns/implementations.yarn
@@ -692,7 +692,7 @@ them, so they can be added to the end of the implements section.
IMPLEMENTS WHEN the user (attempts to upgrade|upgrades) the (system|cluster) (\S+) in branch (\S+)( with options (.*))?
cd "$DATADIR/workspace/$MATCH_4"
- set -- deploy --upgrade "$MATCH_3"
+ set -- upgrade "$MATCH_3"
if [ "$MATCH_5" != '' ]; then
# eval used so word splitting in the text is preserved
eval set -- '"$@"' $MATCH_6