1515Common commands:
1616
1717 create create a new container formation
18+ info print a represenation of the formation
1819 scale scale container types (web=2, worker=1)
19- rotate rotate in fresh backends, proxies or containers
20- balance rebalance and converge the container formation
20+ balance rebalance the container formation
21+ converge force-converge all nodes in the formation
22+ calculate recalculate and update the formation databag
2123 destroy destroy a container formation
2224
2325Use `deis help [subcommand]` to learn about these subcommands:
2729 nodes manage nodes of all types
2830 containers manage the containers running on backends
2931
30- flavors create and manage node flavors
31- providers create and manage cloud provider credentials
32+ providers manage cloud provider credentials
33+ flavors manage node flavors on a provider
34+ keys manage ssh keys
3235
33- config list, set and unset environment variables for a formation
34- builds list and manage git-push builds for a formation
35- releases list and show a formation's release history
36+ config manage environment variables for a formation
37+ builds manage git-push builds for a formation
38+ releases manage a formation's release history
3639
3740Use `git push deis master` to deploy to the container formation.
3841
@@ -73,14 +76,17 @@ def __init__(self):
7376 self .cookies .load ()
7477 self .cookies .clear_expired_cookies ()
7578
76- def _get_formation (self ):
77- # TODO: determine the user's current formation from files in .git
78- # in the current working directory.
79+ def git_root (self ):
7980 try :
8081 git_root = subprocess .check_output (
81- ['git' , 'rev-parse' , '--show-toplevel' ]).strip ('\n ' )
82+ ['git' , 'rev-parse' , '--show-toplevel' ],
83+ stderr = subprocess .PIPE ).strip ('\n ' )
8284 except subprocess .CalledProcessError :
8385 raise EnvironmentError ('Current directory is not a git repository' )
86+ return git_root
87+
88+ def get_formation (self ):
89+ git_root = self .git_root ()
8490 # try to match a deis remote
8591 remotes = subprocess .check_output (['git' , 'remote' , '-v' ],
8692 cwd = git_root )
@@ -94,7 +100,7 @@ def _get_formation(self):
94100 raise EnvironmentError ('Could not parse: {url}' .format (** locals ()))
95101 return m .groupdict ()['formation' ]
96102
97- formation = property (_get_formation )
103+ formation = property (get_formation )
98104
99105 def request (self , * args , ** kwargs ):
100106 for cookie in self .cookies :
@@ -240,6 +246,7 @@ def auth_register(self, args):
240246 print
241247 self .providers_discover ({})
242248 print
249+ print 'Use `deis create --flavor=ec2-us-east-1` to create a new formation'
243250 else :
244251 print ('Registration failed' , response .content )
245252 return False
@@ -307,7 +314,7 @@ def builds_create(self, args):
307314 # url / sha / slug_size / procfile / checksum
308315 j = json .loads (data )
309316 response = self ._dispatch ('post' ,
310- '/formations/{}/builds' .format (formation ),
317+ '/api/ formations/{}/builds' .format (formation ),
311318 body = json .dumps (j ))
312319 if response .status_code == requests .codes .created : # @UndefinedVariable
313320 print ('Build created.' )
@@ -321,7 +328,7 @@ def builds_list(self, args):
321328 formation = args .get ('--formation' )
322329 if not formation :
323330 formation = self ._session .formation
324- response = self ._dispatch ('get' , '/formations/{}/builds' .format (formation ))
331+ response = self ._dispatch ('get' , '/api/ formations/{}/builds' .format (formation ))
325332 if response .status_code == requests .codes .ok : # @UndefinedVariable
326333 print ('=== {0}' .format (formation ))
327334 data = response .json ()
@@ -532,6 +539,11 @@ def formations_create(self, args):
532539 Usage: deis formations:create [--id=<id> --flavor=<flavor>]
533540 """
534541 body = {}
542+ try :
543+ self ._session .git_root () # check for a git repository
544+ except EnvironmentError :
545+ print 'No git repository found, use `git init` to create one'
546+ return
535547 for opt in ('--id' ,):
536548 o = args .get (opt )
537549 if o :
@@ -858,6 +870,12 @@ def layers_scale(self, args):
858870 else :
859871 print ('Error!' , response .text )
860872
873+ def nodes (self , args ):
874+ """
875+ Nodes help would be nice
876+ """
877+ return self .nodes_list (args )
878+
861879 def nodes_info (self , args ):
862880 """
863881 Usage: deis nodes:info <node>
@@ -869,12 +887,6 @@ def nodes_info(self, args):
869887 else :
870888 print ('Error!' , response .text )
871889
872- def nodes (self , args ):
873- """
874- Nodes help would be nice
875- """
876- return self .nodes_list (args )
877-
878890 def nodes_list (self , args ):
879891 """
880892 List nodes for this formation.
@@ -1008,7 +1020,7 @@ def releases_list(self, args):
10081020 formation = args .get ('--formation' )
10091021 if not formation :
10101022 formation = self ._session .formation
1011- response = self ._dispatch ('get' , '/formations/{}/release' .format (formation ))
1023+ response = self ._dispatch ('get' , '/api/ formations/{}/release' .format (formation ))
10121024 if response .status_code == requests .codes .ok : # @UndefinedVariable
10131025 print ('=== {0}' .format (formation ))
10141026 data = response .json ()
@@ -1040,6 +1052,7 @@ def main():
10401052 'converge' : 'formations:converge' ,
10411053 'destroy' : 'formations:destroy' ,
10421054 'scale' : 'containers:scale' ,
1055+ 'ps' : 'containers:list' ,
10431056 }
10441057 # lookup cmd shortcut
10451058 if cmd in shortcuts :
@@ -1067,11 +1080,9 @@ def main():
10671080 # dispatch the CLI command
10681081 try :
10691082 method (args )
1070- except EnvironmentError as e :
1071- if e .message .startswith ('Could not find deis remote' ):
1072- print 'Could not find git remote for deis'
1073- raise DocoptExit ()
1074- raise e
1083+ except EnvironmentError :
1084+ print 'Could not find git remote for deis'
1085+ raise DocoptExit ()
10751086
10761087
10771088if __name__ == '__main__' :
0 commit comments