elastip 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/exe/elastip +10 -4
- data/lib/elastip.rb +9 -5
- data/lib/elastip/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff1d5f3740ed41c6d7eaa06ed7197172b48808cb
|
4
|
+
data.tar.gz: 9afd039f16780c72d0023d2d3955d2ccaaea29f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48343542e107537447a62042cef0f2e2765e61699556b4733c5c672a622b636d44cdb16d979be149426801938afe5d4771574f7f7b8b7b18e2d13a0cce74aaba
|
7
|
+
data.tar.gz: 7779d9a8e8e86ee34d1943d6b028c1eafd5673cba116dd78fac40aeac5fff166593b1d821b25951beae292f5faffe7f92898f9e353fd2a91e1acfd2f88b6c147
|
data/README.md
CHANGED
@@ -29,6 +29,14 @@ $> elastip 'pr*ject\d+' staging
|
|
29
29
|
10.0.15.42
|
30
30
|
```
|
31
31
|
|
32
|
+
If you want to also list the non Healthy instances (the red ones for instance), you can add the --all option
|
33
|
+
|
34
|
+
```
|
35
|
+
$> elastip project_name production --all
|
36
|
+
10.0.15.12
|
37
|
+
10.0.15.16
|
38
|
+
```
|
39
|
+
|
32
40
|
You got the idea. You can then use it directly in an alias doing `ssh ec2-user@$(elastip project-name production)`
|
33
41
|
|
34
42
|
|
data/exe/elastip
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
begin
|
4
|
+
Object.const_get('Elastip')
|
5
|
+
rescue NameError
|
6
|
+
require 'bundler/setup'
|
7
|
+
end
|
4
8
|
|
5
|
-
|
9
|
+
require 'elastip'
|
6
10
|
|
11
|
+
project, env, options = ARGV
|
12
|
+
options ||= []
|
7
13
|
if !project or !env
|
8
|
-
abort "Usage: elastip <project name regexp> <environnement (e.g staging production)
|
14
|
+
abort "Usage: elastip <project name regexp> <environnement (e.g staging production)> [--all]\n" \
|
9
15
|
"Example: elastip 'my_pro*ect' production"
|
10
16
|
end
|
11
17
|
|
12
|
-
puts Elastip::Elastip.new(project, env).ip.join("\n")
|
18
|
+
puts Elastip::Elastip.new(project, env, options).ip.join("\n")
|
data/lib/elastip.rb
CHANGED
@@ -5,16 +5,19 @@ require 'aws-sdk'
|
|
5
5
|
|
6
6
|
module Elastip
|
7
7
|
class Elastip
|
8
|
-
def initialize(project, env)
|
8
|
+
def initialize(project, env, options=[])
|
9
9
|
abort "You need to specify a project and an environnement (e.g staging,production)" if !project or !env
|
10
10
|
@project_re = Regexp.new(project)
|
11
11
|
@env = env
|
12
|
+
@all = options.include?('--all')
|
12
13
|
end
|
13
14
|
|
14
15
|
def ip
|
15
16
|
active_envs = environments.map do |env|
|
16
|
-
if
|
17
|
-
env[:
|
17
|
+
if @project_re =~ env[:application_name].downcase && env[:environment_name].include?(@env)
|
18
|
+
if @all || env[:health] == 'Green'
|
19
|
+
env[:environment_name]
|
20
|
+
end
|
18
21
|
end
|
19
22
|
end.compact
|
20
23
|
|
@@ -22,8 +25,9 @@ module Elastip
|
|
22
25
|
|
23
26
|
target_instances = active_envs.map do |active|
|
24
27
|
instance = instances.find{|x| x[:tags].any?{|y| active == y[:value] } && x[:state][:name] != 'terminated'}
|
25
|
-
{instance: active, ip: instance[:private_ip_address]}
|
26
|
-
end
|
28
|
+
{instance: active, ip: instance[:private_ip_address]} if instance
|
29
|
+
end.compact
|
30
|
+
STDERR.puts target_instances.inspect
|
27
31
|
target_instances.map{|x| x[:ip]}
|
28
32
|
end
|
29
33
|
|
data/lib/elastip/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pcboy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|