@@ -1028,6 +1028,8 @@ def get_dokku_command(inst_id, cmd):
10281028 return 'ssh {}@{} {}' .format (config ['deploy_user' ], instance .public_dns_name , cmd )
10291029
10301030def do_ssh (inst_id ):
1031+ if inst_id == None :
1032+ inst_id = get_info (None , None )[0 ]['instance_id' ]
10311033 local (get_ssh_command (inst_id ))
10321034
10331035def dokku (inst_id , cmd ):
@@ -1037,24 +1039,28 @@ def get_info(app_name, env_name):
10371039 ec2 = boto .connect_ec2 ()
10381040 elb = boto .connect_elb ()
10391041 lb = None
1042+ app = App (env_name , app_name )
10401043 try :
10411044 lbresult = elb .get_all_load_balancers (load_balancer_names = ['{}-{}' .format (env_name , app_name )])
10421045 lb = lbresult [0 ] if len (lbresult ) > 0 else None
10431046 except boto .exception .BotoServerError :
10441047 pass
10451048 if lb is None :
1046- instances = ec2 .get_only_instances (filters = {'tag:Name ' : '{}/{}' .format (env_name , app_name ),
1049+ instances = ec2 .get_only_instances (filters = {'tag:app ' : '{}/{}' .format (app . env_name , app . repo . name ),
10471050 'tag:deployed' : 'true' ,
10481051 'instance-state-name' : 'running' })
1049- if len (instances ) > 0 :
1050- for instance in instances :
1051- print '-----> Instance {}' .format (instance .id )
1052- print ' DNS: {}' .format (instance .public_dns_name )
1053- print ' SSH: {}' .format (get_ssh_command (instance .id ))
1054- return
1055- else :
1052+ datas = [{'instance_id' : instance .id ,
1053+ 'public_dns_name' : instance .public_dns_name ,
1054+ 'ssh_command' : get_ssh_command (instance .id )} for instance in instances ]
1055+ for data in datas :
1056+ print '-----> Instance {}' .format (data ['instance_id' ])
1057+ print ' DNS: {}' .format (data ['public_dns_name' ])
1058+ print ' SSH: {}' .format (data ['ssh_command' ])
1059+ if len (datas ) == 0 :
10561060 print 'No deployment found'
10571061 sys .exit (1 )
1062+ else :
1063+ return datas
10581064 print '-----> Load Balancer'
10591065 print ' Name: {}' .format (lb .name )
10601066 print ' DNS: {}' .format (lb .dns_name )
0 commit comments