1111Shortcut commands:
1212
1313 create create a new container formation
14- info print a represenation of the formation
14+ info print a representation of the formation
1515 scale scale container types (web=2, worker=1)
1616 balance rebalance the container formation
1717 converge force-converge all nodes in the formation
2323 formations manage container formations
2424 layers manage layers of nodes
2525 nodes manage nodes of all types
26- containers manage the containers running on backends
26+ containers manage runtime containers
2727
2828 providers manage cloud provider credentials
2929 flavors manage node flavors on a provider
@@ -372,7 +372,7 @@ def builds_list(self, args):
372372 formation = self ._session .formation
373373 response = self ._dispatch ('get' , "/api/formations/{}/builds" .format (formation ))
374374 if response .status_code == requests .codes .ok : # @UndefinedVariable
375- print ("=== {}" .format (formation ))
375+ print ("=== {} Builds " .format (formation ))
376376 data = response .json ()
377377 for item in data ['results' ]:
378378 print ("{0[uuid]:<23} {0[created]}" .format (item ))
@@ -404,7 +404,7 @@ def config_list(self, args):
404404 if response .status_code == requests .codes .ok : # @UndefinedVariable
405405 config = response .json ()
406406 values = json .loads (config ['values' ])
407- print ("=== {}" .format (formation ))
407+ print ("=== {} Config " .format (formation ))
408408 items = values .items ()
409409 if len (items ) == 0 :
410410 print ('No configuration' )
@@ -495,12 +495,14 @@ def containers_list(self, args):
495495 procfile = databag ['release' ]['build' ].get ('procfile' , {})
496496 if response .status_code == requests .codes .ok : # @UndefinedVariable
497497 data = response .json ()
498+ print ("=== {} Containers" .format (formation ))
498499 c_map = {}
499500 for item in data ['results' ]:
500501 c_map .setdefault (item ['type' ], []).append (item )
502+ print
501503 for c_type in c_map .keys ():
502504 command = procfile .get (c_type , '<none>' )
503- print ("=== {c_type}: `{command}`" .format (** locals ()))
505+ print ("--- {c_type}: `{command}`" .format (** locals ()))
504506 for c in c_map [c_type ]:
505507 print ("{type}.{num} up {created}" .format (** c ))
506508 print
@@ -522,12 +524,13 @@ def containers_scale(self, args):
522524 for type_num in args .get ('<type=num>' ):
523525 typ , count = type_num .split ('=' )
524526 body .update ({typ : int (count )})
527+ print ('Scaling containers... but first, coffee!' )
525528 response = self ._dispatch ('post' ,
526529 "/api/formations/{}/scale/containers" .format (formation ),
527530 json .dumps (body ))
528531 if response .status_code == requests .codes .ok : # @UndefinedVariable
529- databag = json . loads ( response . content )
530- print ( json . dumps ( databag , indent = 2 ) )
532+ print '...done'
533+ self . containers_list ({} )
531534 else :
532535 print ('Error!' , response .text )
533536
@@ -603,8 +606,12 @@ def flavors_list(self, args):
603606 response = self ._dispatch ('get' , '/api/flavors' )
604607 if response .status_code == requests .codes .ok : # @UndefinedVariable
605608 data = response .json ()
609+ if data ['count' ] == 0 :
610+ print 'No flavors found'
611+ return
612+ print ("=== {owner} Flavors" .format (** data ['results' ][0 ]))
606613 for item in data ['results' ]:
607- print ("{0[id]:<23 }" .format (item ))
614+ print ("{id}: params => {params }" .format (** item ))
608615 else :
609616 print ('Error!' , response .text )
610617
@@ -628,9 +635,9 @@ def formations_create(self, args):
628635 """
629636 Create a new formation
630637
638+ If no ID is provided, one will be generated automatically.
631639 Providing a flavor automatically create a default runtime
632- and proxy layer. If no ID is provided, one will be
633- generated automatically.
640+ and proxy layer.
634641
635642 Usage: deis formations:create [--id=<id> --flavor=<flavor>]
636643 """
@@ -683,7 +690,15 @@ def formations_info(self, args):
683690 formation = self ._session .formation
684691 response = self ._dispatch ('get' , "/api/formations/{}" .format (formation ))
685692 if response .status_code == requests .codes .ok : # @UndefinedVariable
686- print (json .dumps (response .json (), indent = 2 ))
693+ data = response .json ()
694+ print ("=== {} Formation" .format (formation ))
695+ print
696+ args = {'<formation>' : data ['id' ]}
697+ self .layers_list (args )
698+ print
699+ self .nodes_list (args )
700+ print
701+ self .containers_list (args )
687702 else :
688703 print ('Error!' , response .text )
689704
@@ -696,8 +711,15 @@ def formations_list(self, args):
696711 response = self ._dispatch ('get' , '/api/formations' )
697712 if response .status_code == requests .codes .ok : # @UndefinedVariable
698713 data = response .json ()
714+ if data ['count' ] == 0 :
715+ print 'No flavors found'
716+ return
717+ print ("=== {owner} Formations" .format (** data ['results' ][0 ]))
699718 for item in data ['results' ]:
700- print ("{0[id]:<23}" .format (item ))
719+ formation = item ['id' ]
720+ layers = json .loads (item .get ('layers' , {}))
721+ containers = json .loads (item .get ('containers' , {}))
722+ print ("{formation}: layers => {layers} containers => {containers}" .format (** locals ()))
701723 else :
702724 print ('Error!' , response .text )
703725
@@ -864,7 +886,7 @@ def keys_list(self, args):
864886 if data ['count' ] == 0 :
865887 print 'No keys found'
866888 return
867- print ("=== {0[' owner'] } Keys" .format (data ['results' ][0 ]))
889+ print ("=== {owner} Keys" .format (** data ['results' ][0 ]))
868890 for key in data ['results' ]:
869891 public = key ['public' ]
870892 print ("{0} {1}...{2}" .format (
@@ -974,11 +996,11 @@ def layers_list(self, args):
974996 response = self ._dispatch ('get' ,
975997 "/api/formations/{}/layers" .format (formation ))
976998 if response .status_code == requests .codes .ok : # @UndefinedVariable
977- print ("=== {}" .format (formation ))
999+ print ("=== {} Layers " .format (formation ))
9781000 data = response .json ()
979- format_str = "{0[id]} => {0[ run_list] }"
1001+ format_str = "{id}: run_list => {run_list}"
9801002 for item in data ['results' ]:
981- print (format_str .format (item ))
1003+ print (format_str .format (** item ))
9821004 else :
9831005 print ('Error!' , response .text )
9841006
@@ -1046,11 +1068,11 @@ def nodes_list(self, args):
10461068 response = self ._dispatch ('get' ,
10471069 "/api/formations/{}/nodes" .format (formation ))
10481070 if response .status_code == requests .codes .ok : # @UndefinedVariable
1049- print ("=== {}" .format (formation ))
1071+ print ("=== {} Nodes " .format (formation ))
10501072 data = response .json ()
1051- format_str = "{0[id]:<23 } {0[layer]} {0[ provider_id] } {0[ fqdn] }"
1073+ format_str = "{id } {provider_id} {fqdn}"
10521074 for item in data ['results' ]:
1053- print (format_str .format (item ))
1075+ print (format_str .format (** item ))
10541076 else :
10551077 print ('Error!' , response .text )
10561078
@@ -1185,8 +1207,14 @@ def providers_list(self, args):
11851207 response = self ._dispatch ('get' , '/api/providers' )
11861208 if response .status_code == requests .codes .ok : # @UndefinedVariable
11871209 data = response .json ()
1210+ if data ['count' ] == 0 :
1211+ print 'No providers found'
1212+ return
1213+ print ("=== {owner} Providers" .format (** data ['results' ][0 ]))
11881214 for item in data ['results' ]:
1189- print (item ['id' ])
1215+ creds = json .loads (item ['creds' ])
1216+ creds .pop ('secret_key' )
1217+ print ("{} => {}" .format (item ['id' ], creds ))
11901218 else :
11911219 print ('Error!' , response .text )
11921220
0 commit comments