fog 0.3.33 → 0.3.34

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  *.sw?
4
4
  .bundle
5
5
  .DS_Store
6
+ _site/*
6
7
  coverage
7
8
  doc/*
8
9
  rdoc
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fog (0.3.33)
4
+ fog (0.3.34)
5
5
  builder
6
- excon (>= 0.3.3)
6
+ excon (>= 0.3.6)
7
7
  formatador (>= 0.0.16)
8
8
  json
9
9
  mime-types
@@ -15,7 +15,7 @@ GEM
15
15
  remote: http://rubygems.org/
16
16
  specs:
17
17
  builder (3.0.0)
18
- excon (0.3.3)
18
+ excon (0.3.6)
19
19
  formatador (0.0.16)
20
20
  gestalt (0.0.11)
21
21
  formatador (>= 0.0.12)
@@ -35,7 +35,7 @@ PLATFORMS
35
35
 
36
36
  DEPENDENCIES
37
37
  builder
38
- excon (>= 0.3.3)
38
+ excon (>= 0.3.6)
39
39
  fog!
40
40
  formatador (>= 0.0.16)
41
41
  json
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
7
7
  ## If your rubyforge_project name is different, then edit it and comment out
8
8
  ## the sub! line in the Rakefile
9
9
  s.name = 'fog'
10
- s.version = '0.3.33'
11
- s.date = '2010-12-22'
10
+ s.version = '0.3.34'
11
+ s.date = '2010-12-23'
12
12
  s.rubyforge_project = 'fog'
13
13
 
14
14
  ## Make sure your summary is short. The description may be as long
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
43
43
  ## List your runtime dependencies here. Runtime dependencies are those
44
44
  ## that are needed for an end user to actually USE your code.
45
45
  s.add_dependency('builder')
46
- s.add_dependency('excon', '>=0.3.3')
46
+ s.add_dependency('excon', '>=0.3.6')
47
47
  s.add_dependency('formatador', '>=0.0.16')
48
48
  s.add_dependency('json')
49
49
  s.add_dependency('mime-types')
data/lib/fog.rb CHANGED
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), 'fog', 'core')
3
3
  module Fog
4
4
 
5
5
  unless const_defined?(:VERSION)
6
- VERSION = '0.3.33'
6
+ VERSION = '0.3.34'
7
7
  end
8
8
 
9
9
  end
@@ -58,7 +58,7 @@ module Fog
58
58
  body << "#{key}=#{CGI.escape(value.to_s).gsub(/\+/, '%20')}&"
59
59
  end
60
60
  end
61
- string_to_sign = "POST\n#{options[:host]}\n#{options[:path]}\n" << body.chop
61
+ string_to_sign = "POST\n#{options[:host]}:#{options[:port]}\n#{options[:path]}\n" << body.chop
62
62
  signed_string = options[:hmac].sign(string_to_sign)
63
63
  body << "Signature=#{CGI.escape(Base64.encode64(signed_string).chomp!).gsub(/\+/, '%20')}"
64
64
 
@@ -205,6 +205,7 @@ module Fog
205
205
  :hmac => @hmac,
206
206
  :host => @host,
207
207
  :path => @path,
208
+ :port => @port,
208
209
  :version => '2010-08-31'
209
210
  }
210
211
  )
@@ -82,6 +82,7 @@ module Fog
82
82
  :hmac => @hmac,
83
83
  :host => @host,
84
84
  :path => @path,
85
+ :port => @port,
85
86
  :version => '2009-11-25'
86
87
  }
87
88
  )
@@ -81,6 +81,7 @@ module Fog
81
81
  :hmac => @hmac,
82
82
  :host => @host,
83
83
  :path => @path,
84
+ :port => @port,
84
85
  :version => '2010-05-08'
85
86
  }
86
87
  )
@@ -140,6 +140,7 @@ module Fog
140
140
  :hmac => @hmac,
141
141
  :host => @host,
142
142
  :path => @path,
143
+ :port => @port,
143
144
  :version => '2009-04-15'
144
145
  }
145
146
  )
@@ -5,25 +5,27 @@ module Fog
5
5
  requires :zerigo_email, :zerigo_token
6
6
  recognizes :timeout, :persistent
7
7
 
8
- # model_path 'fog/zerigo/models/dns'
9
- # model :server
10
- # collection :servers
8
+ model_path 'fog/zerigo/models/dns'
9
+ model :record
10
+ collection :records
11
+ model :zone
12
+ collection :zones
11
13
 
12
14
  request_path 'fog/zerigo/requests/dns'
13
- request :list_zones
15
+ request :count_hosts
14
16
  request :count_zones
15
- request :get_zone
16
- request :get_zone_stats
17
+ request :create_host
17
18
  request :create_zone
18
- request :update_zone
19
+ request :delete_host
19
20
  request :delete_zone
20
- request :list_hosts
21
21
  request :find_hosts
22
- request :count_hosts
23
22
  request :get_host
24
- request :create_host
23
+ request :get_zone
24
+ request :get_zone_stats
25
+ request :list_zones
26
+ request :list_hosts
25
27
  request :update_host
26
- request :delete_host
28
+ request :update_zone
27
29
 
28
30
  class Mock
29
31
 
@@ -0,0 +1,54 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Zerigo
5
+ class DNS
6
+
7
+ class Record < Fog::Model
8
+
9
+ identity :id
10
+
11
+ attribute :created_at, :aliases => 'created-at'
12
+ attribute :ip, :aliases => 'data'
13
+ attribute :domain, :aliases => 'fqdn'
14
+ attribute :name, :aliases => 'hostname'
15
+ attribute :notes
16
+ attribute :priority
17
+ attribute :ttl
18
+ attribute :type, :aliases => 'host-type'
19
+ attribute :updated_at, :aliases => 'updated-at'
20
+ attribute :zone_id, :aliases => 'zone-id'
21
+
22
+ def destroy
23
+ requires :identity
24
+ connection.delete_host(identity)
25
+ true
26
+ end
27
+
28
+ def zone
29
+ @zone
30
+ end
31
+
32
+ def save
33
+ requires :zone, :type, :ip
34
+ options = {}
35
+ options[:hostname] = name if name
36
+ options[:notes] = notes if notes
37
+ options[:priority] = priority if priority
38
+ options[:ttl] = ttl if ttl
39
+ data = connection.create_host(@zone.id, type, ip, options)
40
+ merge_attributes(data.body)
41
+ true
42
+ end
43
+
44
+ private
45
+
46
+ def zone=(new_zone)
47
+ @zone = new_zone
48
+ end
49
+
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,41 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/zerigo/models/dns/record'
3
+
4
+ module Fog
5
+ module Zerigo
6
+ class DNS
7
+
8
+ class Records < Fog::Collection
9
+
10
+ attribute :zone
11
+
12
+ model Fog::Zerigo::DNS::Record
13
+
14
+ def all
15
+ requires :zone
16
+ parent = zone.collection.get(zone.identity)
17
+ if parent
18
+ merge_attributes(parent.records.attributes)
19
+ load(parent.records.map {|record| record.attributes})
20
+ else
21
+ nil
22
+ end
23
+ end
24
+
25
+ def get(record_id)
26
+ data = connection.get_host(record_id).body
27
+ new(data)
28
+ rescue Excon::Errors::NotFound
29
+ nil
30
+ end
31
+
32
+ def new(attributes = {})
33
+ requires :zone
34
+ super({ :zone => zone }.merge!(attributes))
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,82 @@
1
+ require 'fog/core/model'
2
+ require 'fog/zerigo/models/dns/records'
3
+
4
+ module Fog
5
+ module Zerigo
6
+ class DNS
7
+
8
+ class Zone < Fog::Model
9
+
10
+ identity :id
11
+
12
+ attribute :created_at, :aliases => 'created-at'
13
+ attribute :domain
14
+ attribute :ttl, :aliases => 'default-ttl'
15
+ attribute :type, :aliases => 'ns-type'
16
+ attribute :updated_at, :aliases => 'updated-at'
17
+
18
+ # <custom-nameservers>ns1.example.com,ns2.example.com</custom-nameservers>
19
+ # <custom-ns type="boolean">true</custom-ns>
20
+ # <hostmaster>dnsadmin@example.com</hostmaster>
21
+ # <notes nil="true"/>
22
+ # <ns1 nil="true"/>
23
+ # <nx-ttl nil="true"></nx-ttl>
24
+ # <slave-nameservers nil="true"/>
25
+ # <tag-list>one two</tag-list>
26
+ # <hosts-count>1</hosts-count>
27
+
28
+ def initialize(attributes={})
29
+ self.type ||= 'pri_sec'
30
+ self.ttl ||= 3600
31
+ super
32
+ end
33
+
34
+ def destroy
35
+ requires :identity
36
+ connection.delete_zone(identity)
37
+ true
38
+ end
39
+
40
+ def records
41
+ @records ||= begin
42
+ Fog::Zerigo::DNS::Records.new(
43
+ :zone => self,
44
+ :connection => connection
45
+ )
46
+ end
47
+ end
48
+
49
+ def nameservers
50
+ [
51
+ 'a.ns.zerigo.net',
52
+ 'b.ns.zerigo.net',
53
+ 'c.ns.zerigo.net',
54
+ 'd.ns.zerigo.net',
55
+ 'e.ns.zerigo.net'
56
+ ]
57
+ end
58
+
59
+ def save
60
+ requires :domain, :type, :ttl
61
+ options = {}
62
+ # * options<~Hash> - optional paramaters
63
+ # * ns1<~String> - required if ns_type == sec
64
+ # * nx_ttl<~Integer> -
65
+ # * slave_nameservers<~String> - required if ns_type == pri
66
+ # * axfr_ips<~String> - comma-separated list of IPs or IP blocks allowed to perform AXFRs
67
+ # * custom_nameservers<~String> - comma-separated list of custom nameservers
68
+ # * custom_ns<~String> - indicates if vanity (custom) nameservers are enabled for this domain
69
+ # * hostmaster<~String> - email of the DNS administrator or hostmaster
70
+ # * notes<~String> - notes about the domain
71
+ # * restrict_axfr<~String> - indicates if AXFR transfers should be restricted to IPs in axfr-ips
72
+ # * tag_list<~String> - List of all tags associated with this domain
73
+ data = connection.create_zone(domain, ttl, type, options)
74
+ merge_attributes(data.body)
75
+ true
76
+ end
77
+
78
+ end
79
+
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,30 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/zerigo/models/dns/zone'
3
+
4
+ module Fog
5
+ module Zerigo
6
+ class DNS
7
+
8
+ class Zones < Fog::Collection
9
+
10
+ model Fog::Zerigo::DNS::Zone
11
+
12
+ def all
13
+ data = connection.list_zones.body['zones']
14
+ load(data)
15
+ end
16
+
17
+ def get(zone_id)
18
+ data = connection.get_zone(zone_id).body
19
+ zone = new(data)
20
+ zone.records.load(data['hosts'])
21
+ zone
22
+ rescue Excon::Errors::Forbidden
23
+ nil
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+ end
30
+ end
@@ -31,7 +31,7 @@ module Fog
31
31
  # * 'updated-at'<~String>
32
32
  # * 'zone-id'<~String>
33
33
  # * 'status'<~Integer> - 201 if successful
34
- def create_host( zone_id, host_type, data, options = {} )
34
+ def create_host(zone_id, host_type, data, options = {})
35
35
 
36
36
  optional_tags= ''
37
37
  options.each { |option, value|
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog
3
3
  version: !ruby/object:Gem::Version
4
- hash: 81
4
+ hash: 87
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 33
10
- version: 0.3.33
9
+ - 34
10
+ version: 0.3.34
11
11
  platform: ruby
12
12
  authors:
13
13
  - geemus (Wesley Beary)
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-22 00:00:00 -08:00
18
+ date: 2010-12-23 00:00:00 -08:00
19
19
  default_executable: fog
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -38,12 +38,12 @@ dependencies:
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- hash: 21
41
+ hash: 31
42
42
  segments:
43
43
  - 0
44
44
  - 3
45
- - 3
46
- version: 0.3.3
45
+ - 6
46
+ version: 0.3.6
47
47
  type: :runtime
48
48
  name: excon
49
49
  prerelease: false
@@ -842,6 +842,10 @@ files:
842
842
  - lib/fog/zerigo.rb
843
843
  - lib/fog/zerigo/bin.rb
844
844
  - lib/fog/zerigo/dns.rb
845
+ - lib/fog/zerigo/models/dns/record.rb
846
+ - lib/fog/zerigo/models/dns/records.rb
847
+ - lib/fog/zerigo/models/dns/zone.rb
848
+ - lib/fog/zerigo/models/dns/zones.rb
845
849
  - lib/fog/zerigo/parsers/dns/count_hosts.rb
846
850
  - lib/fog/zerigo/parsers/dns/count_zones.rb
847
851
  - lib/fog/zerigo/parsers/dns/create_host.rb