route53 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/bin/route53 CHANGED
@@ -5,6 +5,7 @@ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
5
5
 
6
6
  require 'route53'
7
7
  require 'route53/cli'
8
+ require 'route53/version'
8
9
 
9
10
  app = Route53::CLI.new(ARGV, STDIN)
10
11
  app.run
data/lib/route53.rb CHANGED
@@ -1,8 +1,11 @@
1
+
2
+ require 'rubygems'
1
3
  require 'hmac'
2
4
  require 'hmac-sha2'
3
5
  require 'base64'
4
6
  require 'time'
5
7
  require 'net/http'
8
+ require 'net/https'
6
9
  require 'uri'
7
10
  require 'hpricot'
8
11
  require 'builder'
@@ -31,7 +34,8 @@ module Route53
31
34
  puts "Req: #{data}" if type != "GET" && @verbose
32
35
  uri = URI(url)
33
36
  http = Net::HTTP.new(uri.host, uri.port)
34
- http.use_ssl = true
37
+ http.use_ssl = true if uri.scheme == "https"
38
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE if RUBY_VERSION.start_with?("1.8")
35
39
  time = get_date
36
40
  hmac = HMAC::SHA256.new(@secret)
37
41
  hmac.update(time)
@@ -78,7 +82,8 @@ module Route53
78
82
  if @date_stale.nil? || @date_stale < Time.now - 30
79
83
  uri = URI(@endpoint)
80
84
  http = Net::HTTP.new(uri.host, uri.port)
81
- http.use_ssl = true
85
+ http.use_ssl = true if uri.scheme == "https"
86
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE if RUBY_VERSION.start_with?("1.8")
82
87
  resp = nil
83
88
  puts "Making Date Request" if @verbose
84
89
  http.start { |http| resp = http.head('/date') }
data/lib/route53/cli.rb CHANGED
@@ -4,7 +4,6 @@ require 'optparse'
4
4
  require 'ostruct'
5
5
  require 'date'
6
6
  require 'yaml'
7
- require 'route53/version'
8
7
 
9
8
  module Route53
10
9
  class CLI
@@ -60,7 +59,7 @@ module Route53
60
59
  opts.on('-g', '--change', String, "Change a record") { |record| @options.change_record = true }
61
60
 
62
61
  opts.on('--name [NAME]', String, "Specify a name for a record") { |name| @options.name = name }
63
- opts.on('--type [TYPE]', String, "Specify a type for a record") { |type| @options.type = type }
62
+ opts.on('--type [TYPE]', String, "Specify a type for a record") { |dnstype| @options.dnstype = dnstype }
64
63
  opts.on('--ttl [TTL]', String, "Specify a TTL for a record") { |ttl| @options.ttl = ttl }
65
64
  opts.on('--values [VALUE1],[VALUE2],[VALUE3]', Array, "Specify one or multiple values for a record") { |value| @options.values = value }
66
65
 
@@ -143,7 +142,7 @@ module Route53
143
142
  resps = []
144
143
  zones.each do |z|
145
144
  puts "Creating Record"
146
- record = Route53::DNSRecord.new(@options.name,@options.type,@options.ttl,@options.values,z)
145
+ record = Route53::DNSRecord.new(@options.name,@options.dnstype,@options.ttl,@options.values,z)
147
146
  puts "Creating Record #{record}"
148
147
  resps.push(record.create)
149
148
  end
@@ -161,7 +160,7 @@ module Route53
161
160
  zones = conn.get_zones(@options.zone)
162
161
  if zones.size > 0
163
162
  zones.each do |z|
164
- records = z.get_records(@options.type.nil? ? "ANY" : @options.type)
163
+ records = z.get_records(@options.dnstype.nil? ? "ANY" : @options.dnstype)
165
164
  if records.size > 0
166
165
  if records.size > 1
167
166
  records = record_picker(records)
@@ -173,7 +172,7 @@ module Route53
173
172
  puts "Record Deleted." unless resp.error?
174
173
  end
175
174
  else
176
- $stderr.puts "ERROR: Couldn't Find Record for @options.zone of type "+(@options.type.nil? ? "ANY" : @options.type)+"."
175
+ $stderr.puts "ERROR: Couldn't Find Record for @options.zone of type "+(@options.dnstype.nil? ? "ANY" : @options.dnstype)+"."
177
176
  end
178
177
  end
179
178
  else
@@ -185,19 +184,19 @@ module Route53
185
184
  zones = conn.get_zones(@options.zone)
186
185
  if zones.size > 0
187
186
  zones.each do |z|
188
- records = z.get_records(@options.type.nil? ? "ANY" : @options.type)
187
+ records = z.get_records(@options.dnstype.nil? ? "ANY" : @options.dnstype)
189
188
  if records.size > 0
190
189
  if records.size > 1
191
190
  records = record_picker(records,false)
192
191
  end
193
192
  records.each do |r|
194
193
  puts "Modifying Record #{r.name}"
195
- resp = r.update(@options.name,@options.type,@options.ttl,@options.values,comment=nil)
194
+ resp = r.update(@options.name,@options.dnstype,@options.ttl,@options.values,comment=nil)
196
195
  pending_wait(resp)
197
196
  puts "Record Modified." unless resp.error?
198
197
  end
199
198
  else
200
- $stderr.puts "ERROR: Couldn't Find Record for @options.zone of type "+(@options.type.nil? ? "ANY" : @options.type)+"."
199
+ $stderr.puts "ERROR: Couldn't Find Record for @options.zone of type "+(@options.dnstype.nil? ? "ANY" : @options.dnstype)+"."
201
200
  end
202
201
  end
203
202
  else
@@ -210,7 +209,7 @@ module Route53
210
209
  zones.each do |z|
211
210
  puts z
212
211
  if @options.zone
213
- records = z.get_records(@options.type.nil? ? "ANY" : @options.type)
212
+ records = z.get_records(@options.dnstype.nil? ? "ANY" : @options.dnstype)
214
213
  records.each do |r|
215
214
  puts r
216
215
  end
@@ -223,7 +222,7 @@ module Route53
223
222
  puts "You've either elected to run the setup or a configuration file could not be found."
224
223
  puts "Please answer the following prompts."
225
224
  new_config = Hash.new
226
- new_config['access_key'] = get_input(String,"Amazon Access Key",)
225
+ new_config['access_key'] = get_input(String,"Amazon Access Key")
227
226
  new_config['secret_key'] = get_input(String,"Amazon Secret Key")
228
227
  new_config['api'] = get_input(String,"Amazon Route 53 API Version","2010-10-01")
229
228
  new_config['endpoint'] = get_input(String,"Amazon Route 53 Endpoint","https://route53.amazonaws.com/")
@@ -240,7 +239,7 @@ module Route53
240
239
 
241
240
  end
242
241
 
243
- def get_input(type,description,default = nil)
242
+ def get_input(inputtype,description,default = nil)
244
243
  print "#{description}: [#{default}] "
245
244
  STDOUT.flush
246
245
  selection = gets
@@ -248,7 +247,7 @@ module Route53
248
247
  if selection == ""
249
248
  selection = default
250
249
  end
251
- if type == true.class
250
+ if inputtype == true.class
252
251
  selection = (selection == 'Y')
253
252
  end
254
253
  return selection
@@ -1,3 +1,3 @@
1
1
  module Route53
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/route53.gemspec CHANGED
@@ -11,9 +11,8 @@ Gem::Specification.new do |s|
11
11
  s.summary = "Library for Amazon's Route 53 service"
12
12
  s.description = "Provides CRUD and list operations for records and zones as part of Amazon's Route 53 service."
13
13
 
14
- s.required_rubygems_version = ">= 1.3.6"
14
+ s.required_rubygems_version = ">= 1.3.5"
15
15
 
16
- s.add_dependency "bundler", ">= 1.0.0"
17
16
  s.add_dependency "ruby-hmac"
18
17
  s.add_dependency "hpricot"
19
18
  s.add_dependency "builder"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 2
9
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Philip Corliss
@@ -18,7 +18,7 @@ date: 2010-12-09 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: bundler
21
+ name: ruby-hmac
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
@@ -26,14 +26,12 @@ dependencies:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  segments:
29
- - 1
30
- - 0
31
29
  - 0
32
- version: 1.0.0
30
+ version: "0"
33
31
  type: :runtime
34
32
  version_requirements: *id001
35
33
  - !ruby/object:Gem::Dependency
36
- name: ruby-hmac
34
+ name: hpricot
37
35
  prerelease: false
38
36
  requirement: &id002 !ruby/object:Gem::Requirement
39
37
  none: false
@@ -46,7 +44,7 @@ dependencies:
46
44
  type: :runtime
47
45
  version_requirements: *id002
48
46
  - !ruby/object:Gem::Dependency
49
- name: hpricot
47
+ name: builder
50
48
  prerelease: false
51
49
  requirement: &id003 !ruby/object:Gem::Requirement
52
50
  none: false
@@ -58,19 +56,6 @@ dependencies:
58
56
  version: "0"
59
57
  type: :runtime
60
58
  version_requirements: *id003
61
- - !ruby/object:Gem::Dependency
62
- name: builder
63
- prerelease: false
64
- requirement: &id004 !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- segments:
70
- - 0
71
- version: "0"
72
- type: :runtime
73
- version_requirements: *id004
74
59
  description: Provides CRUD and list operations for records and zones as part of Amazon's Route 53 service.
75
60
  email: pcorlis@50projects.com
76
61
  executables:
@@ -81,8 +66,6 @@ extra_rdoc_files: []
81
66
 
82
67
  files:
83
68
  - .gitignore
84
- - Gemfile
85
- - Gemfile.lock
86
69
  - README.markdown
87
70
  - Rakefile
88
71
  - bin/route53
@@ -115,8 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
98
  segments:
116
99
  - 1
117
100
  - 3
118
- - 6
119
- version: 1.3.6
101
+ - 5
102
+ version: 1.3.5
120
103
  requirements: []
121
104
 
122
105
  rubyforge_project:
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source :gemcutter
2
-
3
- # Specify your gem's dependencies in route53.gemspec
4
- gemspec
data/Gemfile.lock DELETED
@@ -1,21 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- route53 (0.1.0)
5
-
6
- GEM
7
- remote: http://rubygems.org/
8
- specs:
9
- builder (3.0.0)
10
- hpricot (0.8.3)
11
- ruby-hmac (0.4.0)
12
-
13
- PLATFORMS
14
- ruby
15
-
16
- DEPENDENCIES
17
- builder
18
- bundler (>= 1.0.0)
19
- hpricot
20
- route53!
21
- ruby-hmac