zonify 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/zonify +9 -7
- data/lib/zonify.rb +12 -2
- 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: fcf4c8219b20ead0a338ce0e054a0234f6338879
|
4
|
+
data.tar.gz: 3ea23ee06e011b347bd7302e25c29eb5613cc846
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd90e1d3932b8fc53746d8d8c1623ca3efe9f7549dc012cc60d9f65cb78e248e8f7cee3db9feae787a23630ad7d592d8e8037e91f660d1fc03458ecdf59e7d47
|
7
|
+
data.tar.gz: f966e6595527331405f6137696104ccc208844ef1be35b144c1b11f475b61d65020813fff92f7f68e6e292b909a043e924cc8a9ee0993f07cb87346e49b0c66a
|
data/bin/zonify
CHANGED
@@ -14,8 +14,8 @@ require 'zonify'
|
|
14
14
|
|
15
15
|
class CLIAWS
|
16
16
|
attr_reader :options
|
17
|
-
def initialize(access=nil, secret=nil)
|
18
|
-
@options =
|
17
|
+
def initialize(access=nil, secret=nil, options={})
|
18
|
+
@options = options
|
19
19
|
env_adapter
|
20
20
|
auth = { :aws_access_key_id => (access or ENV['AWS_ACCESS_KEY']),
|
21
21
|
:aws_secret_access_key => (secret or ENV['AWS_SECRET_KEY']) }
|
@@ -149,11 +149,12 @@ def main
|
|
149
149
|
end
|
150
150
|
#confirm = [ARGV.delete("-c"), ARGV.delete("--confirm")].any?
|
151
151
|
confirm = false
|
152
|
-
quiet = (ARGV.delete(
|
153
|
-
netlogging = (ARGV.delete(
|
154
|
-
norm = (ARGV.delete(
|
155
|
-
ARGV.delete(
|
156
|
-
use_iam_profile = ARGV.delete(
|
152
|
+
quiet = (ARGV.delete('-q') or ARGV.delete('--quiet'))
|
153
|
+
netlogging = (ARGV.delete('-n') or ARGV.delete('--net'))
|
154
|
+
norm = (ARGV.delete('--srv-singleton') or not
|
155
|
+
ARGV.delete('--no-srv-singleton'))
|
156
|
+
use_iam_profile = ARGV.delete('--use-iam-profile')
|
157
|
+
reverse_public_ip = ARGV.delete('--reverse-public-ip')
|
157
158
|
zone = nil
|
158
159
|
while i = ARGV.index('--zone')
|
159
160
|
raise 'Zone already set...' if zone
|
@@ -162,6 +163,7 @@ def main
|
|
162
163
|
ARGV.delete_at(i)
|
163
164
|
end
|
164
165
|
aws = CLIAWS.new
|
166
|
+
aws.options[:reverse] = true if reverse_public_ip
|
165
167
|
aws.options[:use_iam_profile] = true if use_iam_profile
|
166
168
|
aws.options[:zone] = zone if zone
|
167
169
|
types = nil
|
data/lib/zonify.rb
CHANGED
@@ -19,6 +19,7 @@ class AWS
|
|
19
19
|
def create(options)
|
20
20
|
options_ec2 = options.merge( :provider=>'AWS',
|
21
21
|
:connection_options=>{:nonblock=>false} )
|
22
|
+
options_ec2.delete(:reverse)
|
22
23
|
options_ec2.delete(:zone)
|
23
24
|
ec2 = Proc.new{|| Fog::Compute.new(options_ec2) }
|
24
25
|
options_elb = options_ec2.dup.delete_if{|k, _| k == :provider }
|
@@ -37,8 +38,12 @@ class AWS
|
|
37
38
|
@ec2_proc = opts[:ec2_proc]
|
38
39
|
@elb_proc = opts[:elb_proc]
|
39
40
|
@r53_proc = opts[:r53_proc]
|
41
|
+
@reverse = opts[:reverse]
|
40
42
|
@zone = opts[:zone]
|
41
43
|
end
|
44
|
+
def reverse_public_ip?
|
45
|
+
!!@reverse
|
46
|
+
end
|
42
47
|
def ec2
|
43
48
|
@ec2 ||= @ec2_proc.call
|
44
49
|
end
|
@@ -113,7 +118,12 @@ class AWS
|
|
113
118
|
end
|
114
119
|
def instances
|
115
120
|
ec2.servers.inject({}) do |acc, i|
|
116
|
-
dns =
|
121
|
+
dns = if reverse_public_ip? and not i.public_ip_address.nil?
|
122
|
+
pub = i.public_ip_address
|
123
|
+
dns = "ec2-#{pub.gsub(".", "-")}.compute-1.amazonaws.com"
|
124
|
+
else
|
125
|
+
i.dns_name or i.private_dns_name
|
126
|
+
end
|
117
127
|
# The default hostname for EC2 instances is derived from their internal
|
118
128
|
# DNS entry.
|
119
129
|
terminal_states = %w| terminated shutting-down |
|
@@ -502,7 +512,7 @@ extend self
|
|
502
512
|
end
|
503
513
|
def sorted_hash(h)
|
504
514
|
result = ::YAML::quick_emit(h.object_id, {}) do |out|
|
505
|
-
out.map
|
515
|
+
out.map do |map|
|
506
516
|
h.keys.sort_by{|k| k.to_s }.each{|k| map.add(k, h[k]) }
|
507
517
|
end
|
508
518
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zonify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Dusek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog
|