owssh 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/owssh.rb +8 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9073124d247d3d0cc868605fdd04e38e23a4e30a
4
- data.tar.gz: 5b265edf9b5a0a1e373e090ff82893fd0b499ac4
3
+ metadata.gz: 89e29716edeb3b2a79485f179a8cb20b47ad55dd
4
+ data.tar.gz: c804fca44ae34a035bf0cd4ca7ffdcee96f772f4
5
5
  SHA512:
6
- metadata.gz: 0e6510435b1edea2595fdf5310d42e994cdd8d5db5f00f03658615489cffba3a33346563708d4ee38d3a8192df2084fb715a9b02a4046848e68e76e30f9a6dd0
7
- data.tar.gz: 3794121b2db1b4192f44600c500a8d54dfca94b0e7414acc0168a19c6bdafb0196f3e639178ccdd5b70a4fa8e7fb26a42953d22247f4a1884ce4e59b5036eaf0
6
+ metadata.gz: 4e10bc353e45f2459bc6a44831acceac5dc0a9b03a533ec8b0f8a0917d8fce2db1a6713d1162481770e3d6a58c0dc8e201102adeb1e7d3e96f921de9f13682e0
7
+ data.tar.gz: f2d4ac0f1d5d2e3a775a47ec39354a3c60a335e9fc1da3389f7e8e8d6303b64780dfa6a2919410349cc607e37bff4f94a42c10d35a15683686f6d7cfa27ed363
data/lib/owssh.rb CHANGED
@@ -25,15 +25,16 @@ class Owssh
25
25
  my_instances = {}
26
26
  instances_json = JSON.parse(`AWS_CONFIG_FILE=#{$aws_config_file} aws --profile #{$aws_profile} opsworks describe-instances --stack-id #{id}`)
27
27
  instances_json['Instances'].each do |instance|
28
- pub_ip = instance['ElasticIp'] || instance['PublicIp'] || "DOWN"
28
+ pub_ip = instance['ElasticIp'] || instance['PublicIp'] || "N/A"
29
29
  priv_ip = instance['PrivateIp'] || "N/A"
30
+ status = instance['Status']
30
31
  match = instance['Hostname'].match(/(.*)\d+/) rescue nil
31
32
  if !match.nil? then
32
33
  type = match[1].to_s
33
34
  else
34
35
  type = "N/A"
35
36
  end
36
- my_instances[instance['Hostname'].to_s] = { "PUB_IP" => pub_ip.to_s, "PRIV_IP" => priv_ip.to_s, "TYPE" => type }
37
+ my_instances[instance['Hostname'].to_s] = { "PUB_IP" => pub_ip.to_s, "PRIV_IP" => priv_ip.to_s, "TYPE" => type, "STATUS" => status }
37
38
  end
38
39
  my_instances
39
40
  end
@@ -45,6 +46,7 @@ class Owssh
45
46
  column('Public IP', :width => 15, :align => 'right')
46
47
  column('Private IP', :width => 15, :align => 'right')
47
48
  column('Type', :width => 16)
49
+ column('Status', :width => 8)
48
50
  end
49
51
  instances.each do |instance_name, data|
50
52
  row do
@@ -52,6 +54,7 @@ class Owssh
52
54
  column(data['PUB_IP'])
53
55
  column(data['PRIV_IP'])
54
56
  column(data['TYPE'])
57
+ column(data['STATUS'])
55
58
  end
56
59
  end
57
60
  end
@@ -155,13 +158,13 @@ class Owssh
155
158
  # SSH to first instance of certain type
156
159
  $first_instance = ""
157
160
  $instances.each do |instance_name, data|
158
- unless (instance_name =~ /#{ARGV[1].to_s}(.*)/).nil? || data["PUB_IP"] == "DOWN"
161
+ unless (instance_name =~ /#{ARGV[1].to_s}(.*)/).nil? || data["STATUS"] == ( "stopped" || "pending" || "requested" || "pending" )
159
162
  $first_instance = instance_name
160
163
  break
161
164
  end
162
165
  end
163
166
  if $first_instance == "" then
164
- puts "Could not find host with name or type of '#{ARGV[1]}'"
167
+ puts "Could not find valid host with name or type of '#{ARGV[1]}'"
165
168
  exit
166
169
  else
167
170
  if ARGV[2].nil? then
@@ -174,7 +177,7 @@ class Owssh
174
177
  end
175
178
  else
176
179
  puts "I don't quite understand what you're asking me to do..."
177
- puts " Try running owssh with no arguments for help!"
180
+ puts " Try running 'owssh help' for help!"
178
181
  exit
179
182
  end
180
183
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: owssh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Hutchins