Repository: deis/deis

Issue:
`deis layers:update` not implemented
We had intended to have this in there, but missed it. It's doubly important now for the vagrant workflow (see #232), so we can do:

``` console
$ deis layers:update dev1 runtime --ssh-user=vagrant
```



Discussion:

Resolving patch:
diff --git a/client/deis.py b/client/deis.py
--- a/client/deis.py
+++ b/client/deis.py
@@ -1277,22 +1277,33 @@ def layers_create(self, args):
         """
         Create a layer of nodes
 
-        Usage: deis layers:create <formation> <id> <flavor> [--proxy --runtime] [options]
-
-        SSH Options:
+        Usage: deis layers:create <formation> <id> <flavor> [options]
 
+        Options:
+        --proxy=<yn>                    layer can be used for proxy [default: y]
+        --runtime=<yn>                  layer can be used for runtime [default: y]
         --ssh_username=USERNAME         username for ssh connections [default: ubuntu]
         --ssh_private_key=PRIVATE_KEY   private key for ssh comm (default: auto-gen)
         --ssh_public_key=PUBLIC_KEY     public key for ssh comm (default: auto-gen)
+        --ssh_port=<port>               port number for ssh comm (default: 22)
 
         """
         formation = args.get('<formation>')
         body = {'id': args['<id>'], 'flavor': args['<flavor>']}
-        for opt in ('--formation', '--proxy', '--runtime',
-                    '--ssh_username', '--ssh_private_key', '--ssh_public_key'):
+        for opt in ('--formation', '--ssh_username', '--ssh_private_key',
+                    '--ssh_public_key'):
             o = args.get(opt)
             if o:
                 body.update({opt.strip('-'): o})
+        o = args.get('--ssh_port')
+        if o:
+            body.update({'ssh_port': int(o)})
+        for opt in ('--proxy', '--runtime'):
+            o = args.get(opt)
+            if o and o.lower() in ['n', 'no', 'f', 'false', '0', 'off']:
+                body.update({opt.strip('-'): False})
+            else:
+                body.update({opt.strip('-'): True})
         sys.stdout.write("Creating {} layer... ".format(args['<id>']))
         sys.stdout.flush()
         try:
@@ -1365,6 +1376,51 @@ def layers_list(self, args):
         else:
             raise ResponseError(response)
 
+    def layers_update(self, args):
+        """
+        Create a layer of nodes
+
+        Usage: deis layers:update <formation> <id> [options]
+
+        Options:
+
+        --proxy=<yn>                    layer can be used for proxy [default: y]
+        --runtime=<yn>                  layer can be used for runtime [default: y]
+        --ssh_username=USERNAME         username for ssh connections [default: ubuntu]
+        --ssh_private_key=PRIVATE_KEY   private key for ssh comm (default: auto-gen)
+        --ssh_public_key=PUBLIC_KEY     public key for ssh comm (default: auto-gen)
+        --ssh_port=<port>               port number for ssh comm (default: 22)
+
+        """
+        formation = args.get('<formation>')
+        layer = args['<id>']  # noqa
+        body = {'id': args['<id>']}
+        for opt in ('--ssh_username', '--ssh_private_key', '--ssh_public_key',
+                    '--ssh_port'):
+            o = args.get(opt)
+            if o:
+                body.update({opt.strip('-'): o})
+        o = args.get('--ssh_port')
+        if o:
+            body.update({'ssh_port': int(o)})
+        for opt in ('--proxy', '--runtime'):
+            o = args.get(opt)
+            if o is not None:
+                if o.lower() in ['n', 'no', 'f', 'false', '0', 'off']:
+                    body.update({opt.strip('-'): False})
+                else:
+                    body.update({opt.strip('-'): True})
+        sys.stdout.write("Updating {} layer... ".format(args['<id>']))
+        sys.stdout.flush()
+        response = self._dispatch(
+            'patch', "/api/formations/{formation}/layers/{layer}".format(**locals()),
+            json.dumps(body))
+        if response.status_code == requests.codes.ok:  # @UndefinedVariable
+            print('done.')
+            print(json.dumps(response.json(), indent=2))
+        else:
+            raise ResponseError(response)
+
     def nodes(self, args):
         """
         Valid commands for nodes:


Test patch: