awful 0.0.39 → 0.0.40

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff4da95e3c0f20638173ed7fb22ee8e55708ff6c
4
- data.tar.gz: a8f8d60efa566e0575c56be0c07ba6f8ad7451de
3
+ metadata.gz: cff7a37a1cddab21100015c4de83e509aea63008
4
+ data.tar.gz: 3fb74a3ece147fe4b09dcdf39a440286b782e27a
5
5
  SHA512:
6
- metadata.gz: 2908b7accf1edae0464a5fa48859559911db58ec7dcac5fbc901d06fa3367a619ce3309e0da7f90a92d04bdb8652d70ad0659b4f31bcfa292a31156462bbb9f3
7
- data.tar.gz: 5870345390e1c1bf2a9df53c20ac899e28336a0833ff09fbde0de70d683a6b53fd9d62b2b52dc7578a8a5417b5e296e57d4aa2abf2ad90c0e202178604699eaa
6
+ metadata.gz: e8f2490caa2984334e6fe299e2cd12bea7f311e6cd4a183792992115b89f225d26e65c1755a043f01bc83efd011921f18ea02c01fc21b1dec699e37f60aa6876
7
+ data.tar.gz: 6d1575b950379b68bcf4d04fe73a16d7544d983b45aa1c05af6f3e495c3cda887604d83392da766518c51510dbbdd2ad78e084ba8589d76b606446f2694cc9bf
data/bin/r53 ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby
2
+ #-*- mode: ruby; -*-
3
+
4
+ require 'awful'
5
+ require 'awful/route53'
6
+
7
+ Awful::Route53.start(ARGV)
@@ -8,8 +8,8 @@ module Awful
8
8
  method_option :long, aliases: '-l', default: false, desc: 'Long listing'
9
9
  def ls(name = /./)
10
10
  fields = options[:long] ?
11
- ->(i) { [ tag_name(i) || '-', i.instance_id, i.instance_type, i.virtualization_type, i.placement.availability_zone, i.state.name,
12
- i.security_groups.map(&:group_name).join(','), i.private_ip_address, i.public_ip_address ] } :
11
+ ->(i) { [ (tag_name(i) || '-').slice(0..40), i.instance_id, i.instance_type, i.virtualization_type, i.placement.availability_zone, i.state.name,
12
+ i.security_groups.map(&:group_name).join(',').slice(0..30), i.private_ip_address, i.public_ip_address ] } :
13
13
  ->(i) { [ tag_name(i) || i.instance_id ] }
14
14
 
15
15
  ec2.describe_instances.map(&:reservations).flatten.map(&:instances).flatten.select do |instance|
@@ -0,0 +1,65 @@
1
+ module Awful
2
+
3
+ class Route53 < Cli
4
+
5
+ no_commands do
6
+ def route53
7
+ @route53 ||= Aws::Route53::Client.new
8
+ end
9
+
10
+ def get_zone_by_name(name)
11
+ if name.match(/^Z[A-Z0-9]{13}$/) # id is 14 char upcase string starting with Z
12
+ name
13
+ else
14
+ matches = route53.list_hosted_zones.hosted_zones.select do |zone|
15
+ zone.name.match(name)
16
+ end
17
+ case matches.size
18
+ when 0
19
+ say "no hosted zones matching #{name}", :red
20
+ exit
21
+ when 1
22
+ matches.first.id
23
+ else
24
+ say "ambiguous hosted zone, matches: #{matches.map(&:name).join(', ')}", :yellow
25
+ exit
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ desc 'ls [NAME]', 'list hosted zones'
32
+ method_option :long, aliases: '-l', default: false, desc: 'Long listing'
33
+ def ls(name = /./)
34
+ route53.list_hosted_zones.hosted_zones.select do |zone|
35
+ zone.name.match(name)
36
+ end.tap do |list|
37
+ if options[:long]
38
+ print_table list.map { |z| [z.name, z.id, z.resource_record_set_count, z.config.comment] }
39
+ else
40
+ puts list.map(&:name)
41
+ end
42
+ end
43
+ end
44
+
45
+ desc 'records ZONE', 'list records for given ZONE'
46
+ method_option :long, aliases: '-l', default: false, desc: 'Long listing'
47
+ def records(zone)
48
+ route53.list_resource_record_sets(hosted_zone_id: get_zone_by_name(zone)).resource_record_sets.tap do |records|
49
+ if options[:long]
50
+ records.map do |r|
51
+ dns_name = r.alias_target.nil? ? [] : ['ALIAS ' + r.alias_target.dns_name]
52
+ values = r.resource_records.map(&:value)
53
+ [r.name, r.type, (dns_name + values).join(', ')]
54
+ end.tap do |list|
55
+ print_table list.sort
56
+ end
57
+ else
58
+ puts records.map(&:name).sort
59
+ end
60
+ end
61
+ end
62
+
63
+ end
64
+
65
+ end
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = "0.0.39"
2
+ VERSION = "0.0.40"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.39
4
+ version: 0.0.40
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ric Lister
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-18 00:00:00.000000000 Z
11
+ date: 2015-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -93,6 +93,7 @@ executables:
93
93
  - ec2
94
94
  - elb
95
95
  - lc
96
+ - r53
96
97
  - rds
97
98
  - route
98
99
  - s3
@@ -118,6 +119,7 @@ files:
118
119
  - bin/ec2
119
120
  - bin/elb
120
121
  - bin/lc
122
+ - bin/r53
121
123
  - bin/rds
122
124
  - bin/route
123
125
  - bin/s3
@@ -136,6 +138,7 @@ files:
136
138
  - lib/awful/elb.rb
137
139
  - lib/awful/launch_config.rb
138
140
  - lib/awful/rds.rb
141
+ - lib/awful/route53.rb
139
142
  - lib/awful/route_table.rb
140
143
  - lib/awful/s3.rb
141
144
  - lib/awful/security_group.rb