owssh 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/owssh.rb +8 -9
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dbad1df96654c2af9c216fe0af06b623adf63652
4
- data.tar.gz: fa33bd9074851c888457763bf5407ab1005d884e
3
+ metadata.gz: 2df64e2216c65698450a4a8fa57ade6fa4cc7363
4
+ data.tar.gz: 9f77ada909874de1672a6c05399f50c5ac0e4dac
5
5
  SHA512:
6
- metadata.gz: 8406a2465bc01976a8196ecf5a9445a64fdca3e4d18a62f0c5fad16be8caad99fff3c26a539dae4b60998231e4d98ffacc32c9c65761fcfb64d3752392c0c957
7
- data.tar.gz: 4ff18a9b927446a6db604ce44cbc755b25ad1c41e1c88428ab4f74d8fadd86f32dd23534896a14dba90bb2b2d2e8128558a4cb974a04dfb87d556e628b81fe1e
6
+ metadata.gz: ce5d5b484168ce151401e26a4040289e0a541fffb1a7364a6b2e977b5641326ad412e1dc1454b80323246b00500592d24258917941921c12a3edbed34d14d14a
7
+ data.tar.gz: 842a10853d7a5fc135462027530fe63acfb27651dacaaed128e21091cc69fdd4561909cdcb81f9cfa2b13af346ee2f5e34a6e331bafaba42eaf25115fec830b2
data/lib/owssh.rb CHANGED
@@ -130,25 +130,24 @@ class Owssh
130
130
  puts "Please enter an instance name. I.E. rails-app3"
131
131
  exit
132
132
  end
133
- stack_arg = ARGV[0].downcase
134
- instances_json = JSON.parse(`aws opsworks describe-instances --stack-id #{$stacks[stack_arg]}`)
135
- instances_json['Instances'].each do |instance|
136
- $instances["#{instance["Hostname"]}"] = instance["PublicIp"]
137
- end
133
+
134
+ stack_name = ARGV[0].downcase
135
+ $instances = get_instances($stacks[stack_name])
136
+
138
137
  if $instances.has_key?(ARGV[1]) then
139
138
  # Open interactive SSH connnection
140
139
  if ARGV[2].nil? then
141
140
  puts "Opening SSH connection to #{ARGV[1]}..."
142
- exec("ssh -i ~/.ssh/id_rsa_dev ubuntu@#{$instances[ARGV[1].to_s]}")
141
+ exec("ssh -i ~/.ssh/id_rsa_dev ubuntu@#{$instances[ARGV[1].to_s]['PUB_IP']}")
143
142
  elsif ARGV[3].nil? then
144
143
  # Run command through SSH on host
145
144
  puts "Running comand #{ARGV[2]} on host #{ARGV[1]}..."
146
- exec("ssh -i ~/.ssh/id_rsa_dev ubuntu@#{$instances[ARGV[1].to_s]} '#{ARGV[2]}'")
145
+ exec("ssh -i ~/.ssh/id_rsa_dev ubuntu@#{$instances[ARGV[1].to_s]['PUB_IP']} '#{ARGV[2]}'")
147
146
  end
148
147
  else
149
148
  $first_instance = ""
150
149
  $instances.each do |instance_name, data|
151
- unless (instance_name =~ /#{ARGV[1].to_s}(.*)/).nil?
150
+ unless (instance_name =~ /#{ARGV[1].to_s}(.*)/).nil? || data["PublicIp"] == "DOWN"
152
151
  $first_instance = instance_name
153
152
  break
154
153
  end
@@ -162,7 +161,7 @@ class Owssh
162
161
  else
163
162
  puts "Running command '#{ARGV[2]}' on first host of type '#{ARGV[1]}' which is '#{$first_instance}'..."
164
163
  end
165
- exec("ssh -i ~/.ssh/id_rsa_dev ubuntu@#{$instances[$first_instance.to_s]} '#{ARGV[2]}'")
164
+ exec("ssh -i ~/.ssh/id_rsa_dev ubuntu@#{$instances[$first_instance.to_s]['PUB_IP']} '#{ARGV[2]}'")
166
165
  end
167
166
  end
168
167
  else
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.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Hutchins