fog 0.3.34 → 0.4.0

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.
Files changed (200) hide show
  1. data/Gemfile.lock +6 -6
  2. data/README.rdoc +26 -7
  3. data/Rakefile +7 -1
  4. data/examples/dns_tests.rb +76 -0
  5. data/examples/{storage.rb → storage_tests.rb} +15 -15
  6. data/fog.gemspec +4 -4
  7. data/lib/fog.rb +1 -1
  8. data/lib/fog/aws.rb +19 -54
  9. data/lib/fog/aws/dns.rb +5 -1
  10. data/lib/fog/aws/models/compute/security_group.rb +128 -0
  11. data/lib/fog/aws/models/dns/record.rb +64 -0
  12. data/lib/fog/aws/models/dns/records.rb +47 -0
  13. data/lib/fog/aws/models/dns/zone.rb +53 -0
  14. data/lib/fog/aws/models/dns/zones.rb +33 -0
  15. data/lib/fog/aws/models/storage/file.rb +14 -2
  16. data/lib/fog/aws/parsers/dns/create_hosted_zone.rb +1 -1
  17. data/lib/fog/aws/parsers/dns/list_hosted_zones.rb +3 -1
  18. data/lib/fog/aws/requests/simpledb/create_domain.rb +1 -0
  19. data/lib/fog/aws/requests/simpledb/delete_attributes.rb +0 -2
  20. data/lib/fog/aws/requests/simpledb/delete_domain.rb +1 -0
  21. data/lib/fog/aws/requests/simpledb/domain_metadata.rb +1 -0
  22. data/lib/fog/aws/requests/simpledb/get_attributes.rb +1 -0
  23. data/lib/fog/aws/requests/simpledb/list_domains.rb +3 -2
  24. data/lib/fog/aws/requests/simpledb/put_attributes.rb +2 -2
  25. data/lib/fog/aws/requests/simpledb/select.rb +1 -0
  26. data/lib/fog/brightbox/compute.rb +9 -0
  27. data/lib/fog/brightbox/models/compute/load_balancer.rb +50 -0
  28. data/lib/fog/brightbox/models/compute/load_balancers.rb +28 -0
  29. data/lib/fog/brightbox/requests/compute/add_nodes_load_balancer.rb +28 -0
  30. data/lib/fog/brightbox/requests/compute/create_load_balancer.rb +27 -0
  31. data/lib/fog/brightbox/requests/compute/destroy_load_balancer.rb +28 -0
  32. data/lib/fog/brightbox/requests/compute/get_load_balancer.rb +28 -0
  33. data/lib/fog/brightbox/requests/compute/list_load_balancers.rb +27 -0
  34. data/lib/fog/brightbox/requests/compute/remove_nodes_load_balancer.rb +28 -0
  35. data/lib/fog/brightbox/requests/compute/update_load_balancer.rb +29 -0
  36. data/lib/fog/core.rb +1 -0
  37. data/lib/fog/core/dns.rb +25 -0
  38. data/lib/fog/core/mock.rb +34 -0
  39. data/lib/fog/google/models/storage/file.rb +14 -2
  40. data/lib/fog/linode/dns.rb +4 -0
  41. data/lib/fog/linode/models/dns/record.rb +69 -0
  42. data/lib/fog/linode/models/dns/records.rb +37 -0
  43. data/lib/fog/linode/models/dns/zone.rb +84 -0
  44. data/lib/fog/linode/models/dns/zones.rb +29 -0
  45. data/lib/fog/linode/requests/dns/domain_create.rb +2 -3
  46. data/lib/fog/linode/requests/dns/domain_resource_create.rb +3 -4
  47. data/lib/fog/linode/requests/dns/domain_resource_list.rb +5 -2
  48. data/lib/fog/linode/requests/dns/domain_resource_update.rb +2 -2
  49. data/lib/fog/linode/requests/dns/domain_update.rb +2 -2
  50. data/lib/fog/rackspace/requests/compute/create_image.rb +1 -1
  51. data/lib/fog/rackspace/requests/compute/create_server.rb +1 -1
  52. data/lib/fog/rackspace/requests/compute/get_flavor_details.rb +19 -1
  53. data/lib/fog/rackspace/requests/compute/list_flavors.rb +14 -1
  54. data/lib/fog/rackspace/requests/compute/list_flavors_detail.rb +14 -1
  55. data/lib/fog/slicehost/bin.rb +1 -1
  56. data/lib/fog/slicehost/dns.rb +4 -0
  57. data/lib/fog/slicehost/models/dns/record.rb +66 -0
  58. data/lib/fog/slicehost/models/dns/records.rb +36 -0
  59. data/lib/fog/slicehost/models/dns/zone.rb +69 -0
  60. data/lib/fog/slicehost/models/dns/zones.rb +28 -0
  61. data/lib/fog/slicehost/requests/dns/create_record.rb +2 -3
  62. data/lib/fog/slicehost/requests/dns/get_record.rb +1 -1
  63. data/lib/fog/vcloud/terremark/ecloud.rb +1 -1
  64. data/lib/fog/zerigo/models/dns/record.rb +14 -3
  65. data/lib/fog/zerigo/models/dns/records.rb +1 -1
  66. data/lib/fog/zerigo/models/dns/zone.rb +7 -1
  67. data/lib/fog/zerigo/models/dns/zones.rb +1 -1
  68. data/spec/spec_helper.rb +0 -24
  69. data/tests/aws/requests/iam/helper.rb +15 -0
  70. data/tests/aws/requests/simpledb/attributes_tests.rb +75 -0
  71. data/tests/aws/requests/simpledb/domain_tests.rb +51 -0
  72. data/tests/aws/requests/simpledb/helper.rb +16 -0
  73. data/tests/compute/helper.rb +36 -0
  74. data/tests/compute/models/flavors_tests.rb +9 -0
  75. data/tests/compute/models/server_tests.rb +9 -0
  76. data/tests/compute/models/servers_tests.rb +9 -0
  77. data/tests/{aws/requests/compute → compute/requests/aws}/address_tests.rb +0 -0
  78. data/tests/{aws/requests/compute → compute/requests/aws}/availability_zone_tests.rb +0 -0
  79. data/tests/{aws → compute/requests/aws}/helper.rb +0 -12
  80. data/tests/{aws/requests/compute → compute/requests/aws}/image_tests.rb +0 -0
  81. data/tests/{aws/requests/compute → compute/requests/aws}/instance_tests.rb +0 -0
  82. data/tests/{aws/requests/compute → compute/requests/aws}/key_pair_tests.rb +0 -0
  83. data/tests/{aws/requests/compute → compute/requests/aws}/region_tests.rb +0 -0
  84. data/tests/{aws/requests/compute → compute/requests/aws}/security_group_tests.rb +0 -0
  85. data/tests/{aws/requests/compute → compute/requests/aws}/snapshot_tests.rb +0 -0
  86. data/tests/{aws/requests/compute → compute/requests/aws}/tag_tests.rb +0 -0
  87. data/tests/{aws/requests/compute → compute/requests/aws}/volume_tests.rb +0 -0
  88. data/tests/{bluebox/requests/compute → compute/requests/bluebox}/block_tests.rb +0 -0
  89. data/tests/{bluebox → compute/requests/bluebox}/helper.rb +0 -0
  90. data/tests/{bluebox/requests/compute → compute/requests/bluebox}/product_tests.rb +0 -0
  91. data/tests/{bluebox/requests/compute → compute/requests/bluebox}/template_tests.rb +0 -0
  92. data/tests/{brightbox/requests/compute → compute/requests/brightbox}/account_tests.rb +0 -0
  93. data/tests/{brightbox/requests/compute → compute/requests/brightbox}/api_client_tests.rb +0 -0
  94. data/tests/{brightbox/requests/compute → compute/requests/brightbox}/cloud_ip_tests.rb +15 -7
  95. data/tests/{brightbox → compute/requests/brightbox}/helper.rb +68 -22
  96. data/tests/{brightbox/requests/compute → compute/requests/brightbox}/image_tests.rb +0 -0
  97. data/tests/{brightbox/requests/compute → compute/requests/brightbox}/interface_tests.rb +0 -0
  98. data/tests/compute/requests/brightbox/load_balancer_tests.rb +74 -0
  99. data/tests/{brightbox/requests/compute → compute/requests/brightbox}/server_tests.rb +1 -0
  100. data/tests/{brightbox/requests/compute → compute/requests/brightbox}/server_type_tests.rb +1 -0
  101. data/tests/{brightbox/requests/compute → compute/requests/brightbox}/user_tests.rb +0 -0
  102. data/tests/{brightbox/requests/compute → compute/requests/brightbox}/zone_tests.rb +1 -0
  103. data/tests/{go_grid/requests/compute → compute/requests/go_grid}/image_tests.rb +0 -0
  104. data/tests/{linode/requests/compute → compute/requests/linode}/datacenter_tests.rb +0 -0
  105. data/tests/{linode/requests/compute → compute/requests/linode}/distribution_tests.rb +0 -0
  106. data/tests/{linode → compute/requests/linode}/helper.rb +0 -0
  107. data/tests/{linode/requests/compute → compute/requests/linode}/linode_tests.rb +0 -0
  108. data/tests/{linode/requests/compute → compute/requests/linode}/linodeplans_tests.rb +0 -0
  109. data/tests/{rackspace/requests/compute → compute/requests/rackspace}/address_tests.rb +0 -0
  110. data/tests/{rackspace/requests/compute → compute/requests/rackspace}/flavor_tests.rb +0 -0
  111. data/tests/{rackspace → compute/requests/rackspace}/helper.rb +0 -0
  112. data/tests/{rackspace/requests/compute → compute/requests/rackspace}/image_tests.rb +7 -9
  113. data/tests/compute/requests/rackspace/resize_tests.rb +33 -0
  114. data/tests/{rackspace/requests/compute → compute/requests/rackspace}/server_tests.rb +0 -0
  115. data/tests/{slicehost/requests/compute → compute/requests/slicehost}/backup_tests.rb +0 -0
  116. data/tests/{slicehost/requests/compute → compute/requests/slicehost}/flavor_tests.rb +0 -0
  117. data/tests/{slicehost/requests/compute → compute/requests/slicehost}/image_tests.rb +0 -0
  118. data/tests/{slicehost/requests/compute → compute/requests/slicehost}/slice_tests.rb +0 -0
  119. data/tests/dns/helper.rb +19 -0
  120. data/tests/dns/models/record_tests.rb +25 -0
  121. data/tests/dns/models/records_tests.rb +25 -0
  122. data/tests/dns/models/zone_tests.rb +13 -0
  123. data/tests/dns/models/zones_tests.rb +13 -0
  124. data/tests/{aws/requests/dns → dns/requests/aws}/dns_tests.rb +0 -0
  125. data/tests/{linode/requests/dns → dns/requests/linode}/dns_tests.rb +0 -0
  126. data/tests/{slicehost/requests/dns_tests → dns/requests/slicehost}/dns_tests.rb +0 -0
  127. data/tests/{zerigo/requests/dns → dns/requests/zerigo}/dns_tests.rb +0 -0
  128. data/tests/helper.rb +1 -100
  129. data/tests/helpers/{collection_tests.rb → collection_helper.rb} +0 -0
  130. data/tests/helpers/compute/{flavors_tests.rb → flavors_helper.rb} +0 -0
  131. data/tests/helpers/compute/{server_tests.rb → server_helper.rb} +0 -0
  132. data/tests/helpers/compute/{servers_tests.rb → servers_helper.rb} +0 -0
  133. data/tests/helpers/formats_helper.rb +68 -0
  134. data/tests/{helper_tests.rb → helpers/formats_helper_tests.rb} +0 -0
  135. data/tests/helpers/{model_tests.rb → model_helper.rb} +0 -0
  136. data/tests/helpers/responds_to_helper.rb +13 -0
  137. data/tests/helpers/succeeds_helper.rb +12 -0
  138. data/tests/storage/helper.rb +16 -0
  139. data/tests/storage/models/directories_tests.rb +13 -0
  140. data/tests/storage/models/directory_test.rb +24 -0
  141. data/tests/storage/models/file_tests.rb +41 -0
  142. data/tests/storage/models/files_tests.rb +26 -0
  143. data/tests/{aws/requests/storage → storage/requests/aws}/bucket_tests.rb +0 -0
  144. data/tests/{aws/requests/storage → storage/requests/aws}/multipart_upload_tests.rb +0 -0
  145. data/tests/{aws/requests/storage → storage/requests/aws}/object_tests.rb +0 -0
  146. data/tests/{google/requests/storage → storage/requests/google}/bucket_tests.rb +0 -0
  147. data/tests/{google/requests/storage → storage/requests/google}/object_tests.rb +0 -0
  148. data/tests/{rackspace/requests/storage → storage/requests/rackspace}/container_tests.rb +0 -0
  149. data/tests/{rackspace/requests/storage → storage/requests/rackspace}/object_tests.rb +0 -0
  150. metadata +195 -224
  151. data/examples/bluebox_create.rb +0 -33
  152. data/examples/dns_methods.rb +0 -389
  153. data/spec/aws/requests/simpledb/batch_put_attributes_spec.rb +0 -31
  154. data/spec/aws/requests/simpledb/create_domain_spec.rb +0 -29
  155. data/spec/aws/requests/simpledb/delete_attributes_spec.rb +0 -39
  156. data/spec/aws/requests/simpledb/delete_domain_spec.rb +0 -28
  157. data/spec/aws/requests/simpledb/domain_metadata_spec.rb +0 -52
  158. data/spec/aws/requests/simpledb/get_attributes_spec.rb +0 -67
  159. data/spec/aws/requests/simpledb/list_domains_spec.rb +0 -30
  160. data/spec/aws/requests/simpledb/put_attributes_spec.rb +0 -49
  161. data/spec/aws/requests/simpledb/select_spec.rb +0 -27
  162. data/tests/aws/models/compute/flavors_tests.rb +0 -5
  163. data/tests/aws/models/compute/server_tests.rb +0 -6
  164. data/tests/aws/models/compute/servers_tests.rb +0 -6
  165. data/tests/aws/models/storage/directories_tests.rb +0 -5
  166. data/tests/aws/models/storage/directory_tests.rb +0 -5
  167. data/tests/aws/models/storage/file_tests.rb +0 -5
  168. data/tests/aws/models/storage/files_tests.rb +0 -5
  169. data/tests/bluebox/models/compute/flavors_tests.rb +0 -5
  170. data/tests/bluebox/models/compute/server_tests.rb +0 -5
  171. data/tests/bluebox/models/compute/servers_tests.rb +0 -6
  172. data/tests/brightbox/models/compute/flavors_tests.rb +0 -5
  173. data/tests/brightbox/models/compute/server_tests.rb +0 -6
  174. data/tests/brightbox/models/compute/servers_tests.rb +0 -6
  175. data/tests/go_grid/helper.rb +0 -0
  176. data/tests/google/models/storage/directories_tests.rb +0 -5
  177. data/tests/google/models/storage/directory_tests.rb +0 -5
  178. data/tests/google/models/storage/file_tests.rb +0 -5
  179. data/tests/google/models/storage/files_tests.rb +0 -5
  180. data/tests/helpers/storage/directories_tests.rb +0 -7
  181. data/tests/helpers/storage/directory_tests.rb +0 -18
  182. data/tests/helpers/storage/file_tests.rb +0 -27
  183. data/tests/helpers/storage/files_tests.rb +0 -13
  184. data/tests/local/models/storage/directories_tests.rb +0 -5
  185. data/tests/local/models/storage/directory_tests.rb +0 -5
  186. data/tests/local/models/storage/file_tests.rb +0 -5
  187. data/tests/local/models/storage/files_tests.rb +0 -5
  188. data/tests/rackspace/models/compute/flavors_tests.rb +0 -5
  189. data/tests/rackspace/models/compute/server_tests.rb +0 -6
  190. data/tests/rackspace/models/compute/servers_tests.rb +0 -6
  191. data/tests/rackspace/models/storage/directories_tests.rb +0 -5
  192. data/tests/rackspace/models/storage/directory_tests.rb +0 -5
  193. data/tests/rackspace/models/storage/file_tests.rb +0 -5
  194. data/tests/rackspace/models/storage/files_tests.rb +0 -5
  195. data/tests/rackspace/requests/compute/resize_tests.rb +0 -47
  196. data/tests/slicehost/helper.rb +0 -1
  197. data/tests/slicehost/models/compute/flavors_tests.rb +0 -5
  198. data/tests/slicehost/models/compute/server_tests.rb +0 -6
  199. data/tests/slicehost/models/compute/servers_tests.rb +0 -6
  200. data/tests/zerigo/helper.rb +0 -0
@@ -25,7 +25,20 @@ module Fog
25
25
  class Mock
26
26
 
27
27
  def list_flavors_detail
28
- Fog::Mock.not_implemented
28
+ response = Excon::Response.new
29
+ response.status = 200
30
+ response.body = {
31
+ 'flavors' => [
32
+ { 'name' => '256 server', 'id' => 1, 'ram' => 256, 'disk' => 10 },
33
+ { 'name' => '512 server', 'id' => 2, 'ram' => 512, 'disk' => 20 },
34
+ { 'name' => '1GB server', 'id' => 3, 'ram' => 1024, 'disk' => 40 },
35
+ { 'name' => '2GB server', 'id' => 4, 'ram' => 2048, 'disk' => 80 },
36
+ { 'name' => '4GB server', 'id' => 5, 'ram' => 4096, 'disk' => 160 },
37
+ { 'name' => '8GB server', 'id' => 6, 'ram' => 8192, 'disk' => 320 },
38
+ { 'name' => '15.5GB server', 'id' => 7, 'ram' => 15872, 'disk' => 620 }
39
+ ]
40
+ }
41
+ response
29
42
  end
30
43
 
31
44
  end
@@ -26,7 +26,7 @@ class Slicehost < Fog::Bin
26
26
  end
27
27
 
28
28
  def services
29
- [:compute]
29
+ [:compute, :dns]
30
30
  end
31
31
 
32
32
  end
@@ -6,6 +6,10 @@ module Fog
6
6
  recognizes :host, :port, :scheme, :persistent
7
7
 
8
8
  model_path 'fog/slicehost/models/dns'
9
+ model :record
10
+ collection :records
11
+ model :zone
12
+ collection :zones
9
13
 
10
14
  request_path 'fog/slicehost/requests/dns'
11
15
  request :create_record
@@ -0,0 +1,66 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Slicehost
5
+ class DNS
6
+
7
+ class Record < Fog::Model
8
+
9
+ identity :id
10
+
11
+ attribute :active
12
+ attribute :ip, :aliases => 'ip'
13
+ attribute :name
14
+ attribute :description, :aliases => 'aux'
15
+ attribute :ttl
16
+ attribute :type, :aliases => 'record_type'
17
+ attribute :zone_id
18
+
19
+ def initialize(attributes={})
20
+ self.active ||= true
21
+ self.ttl ||= 3600
22
+ super
23
+ end
24
+
25
+ def active=(new_active)
26
+ attributes[:active] = case new_active
27
+ when false, 'N'
28
+ false
29
+ when true, 'Y'
30
+ true
31
+ end
32
+ end
33
+
34
+ def destroy
35
+ requires :identity
36
+ connection.delete_record(identity)
37
+ true
38
+ end
39
+
40
+ def zone
41
+ @zone
42
+ end
43
+
44
+ def save
45
+ raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
46
+ requires :ip, :name, :type, :zone
47
+ options = {}
48
+ options[:active] = active ? 'Y' : 'N'
49
+ options[:aux] = description if description
50
+ options[:ttl] = ttl if ttl
51
+ data = connection.create_record(type, zone.id, name, ip, options)
52
+ merge_attributes(data.body)
53
+ true
54
+ end
55
+
56
+ private
57
+
58
+ def zone=(new_zone)
59
+ @zone = new_zone
60
+ end
61
+
62
+ end
63
+
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,36 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/slicehost/models/dns/record'
3
+
4
+ module Fog
5
+ module Slicehost
6
+ class DNS
7
+
8
+ class Records < Fog::Collection
9
+
10
+ attribute :zone
11
+
12
+ model Fog::Slicehost::DNS::Record
13
+
14
+ def all
15
+ requires :zone
16
+ data = connection.get_records.body['records']
17
+ load(data).reject {|record| record.zone_id != zone.id}
18
+ end
19
+
20
+ def get(record_id)
21
+ data = connection.get_record(record_id).body
22
+ new(data)
23
+ rescue Excon::Errors::Forbidden
24
+ nil
25
+ end
26
+
27
+ def new(attributes = {})
28
+ requires :zone
29
+ super({ :zone => zone }.merge!(attributes))
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,69 @@
1
+ require 'fog/core/model'
2
+ require 'fog/slicehost/models/dns/records'
3
+
4
+ module Fog
5
+ module Slicehost
6
+ class DNS
7
+
8
+ class Zone < Fog::Model
9
+
10
+ identity :id
11
+
12
+ attribute :active
13
+ attribute :domain, :aliases => 'origin'
14
+ attribute :ttl
15
+
16
+ def initialize(attributes={})
17
+ self.active ||= true
18
+ self.ttl ||= 3600
19
+ super
20
+ end
21
+
22
+ def active=(new_active)
23
+ attributes[:active] = case new_active
24
+ when false, 'N'
25
+ false
26
+ when true, 'Y'
27
+ true
28
+ end
29
+ end
30
+
31
+ def destroy
32
+ requires :identity
33
+ connection.delete_zone(identity)
34
+ true
35
+ end
36
+
37
+ def records
38
+ @records ||= begin
39
+ Fog::Slicehost::DNS::Records.new(
40
+ :zone => self,
41
+ :connection => connection
42
+ )
43
+ end
44
+ end
45
+
46
+ def nameservers
47
+ [
48
+ 'ns1.slicehost.net',
49
+ 'ns2.slicehost.net',
50
+ 'ns3.slicehost.net'
51
+ ]
52
+ end
53
+
54
+ def save
55
+ raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
56
+ requires :active, :domain, :ttl
57
+ options = {}
58
+ options[:active] = active ? 'Y' : 'N'
59
+ options[:ttl] = ttl
60
+ data = connection.create_zone(domain, options)
61
+ merge_attributes(data.body)
62
+ true
63
+ end
64
+
65
+ end
66
+
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,28 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/slicehost/models/dns/zone'
3
+
4
+ module Fog
5
+ module Slicehost
6
+ class DNS
7
+
8
+ class Zones < Fog::Collection
9
+
10
+ model Fog::Slicehost::DNS::Zone
11
+
12
+ def all
13
+ data = connection.get_zones.body['zones']
14
+ load(data)
15
+ end
16
+
17
+ def get(zone_id)
18
+ data = connection.get_zone(zone_id).body
19
+ new(data)
20
+ rescue Excon::Errors::Forbidden
21
+ nil
22
+ end
23
+
24
+ end
25
+
26
+ end
27
+ end
28
+ end
@@ -24,8 +24,7 @@ module Fog
24
24
  # * 'data'<~String> - as above
25
25
  # * 'active'<~String> - as above
26
26
  # * 'aux'<~String> - as above
27
- def create_record( record_type, zone_id, name, data, options = {})
28
-
27
+ def create_record(record_type, zone_id, name, data, options = {})
29
28
  optional_tags= ''
30
29
  options.each { |option, value|
31
30
  case option
@@ -51,7 +50,7 @@ module Fog
51
50
 
52
51
  class Mock
53
52
 
54
- def create_record( record_type, zone_id, name, data)
53
+ def create_record(record_type, zone_id, name, data)
55
54
  Fog::Mock.not_implemented
56
55
  end
57
56
 
@@ -17,7 +17,7 @@ module Fog
17
17
  # * 'ttl'<~Integer> - time to live in seconds
18
18
  # * 'active'<~String> - whether this record is active or not ('Y' or 'N')
19
19
  # * 'aux'<~String> - extra data required by the record
20
- def get_record( record_id)
20
+ def get_record(record_id)
21
21
  request(
22
22
  :expects => 200,
23
23
  :method => 'GET',
@@ -4,7 +4,7 @@ module Fog
4
4
  class Ecloud < Fog::Vcloud
5
5
 
6
6
  requires :username, :password, :versions_uri
7
- recognizes :version
7
+ recognizes :module, :version
8
8
 
9
9
  model_path 'fog/vcloud/terremark/ecloud/models'
10
10
  model :catalog_item
@@ -12,13 +12,18 @@ module Fog
12
12
  attribute :ip, :aliases => 'data'
13
13
  attribute :domain, :aliases => 'fqdn'
14
14
  attribute :name, :aliases => 'hostname'
15
- attribute :notes
15
+ attribute :description, :aliases => 'notes'
16
16
  attribute :priority
17
17
  attribute :ttl
18
18
  attribute :type, :aliases => 'host-type'
19
19
  attribute :updated_at, :aliases => 'updated-at'
20
20
  attribute :zone_id, :aliases => 'zone-id'
21
21
 
22
+ def initialize(attributes={})
23
+ self.ttl ||= 3600
24
+ super
25
+ end
26
+
22
27
  def destroy
23
28
  requires :identity
24
29
  connection.delete_host(identity)
@@ -33,10 +38,16 @@ module Fog
33
38
  requires :zone, :type, :ip
34
39
  options = {}
35
40
  options[:hostname] = name if name
36
- options[:notes] = notes if notes
41
+ options[:notes] = description if description
37
42
  options[:priority] = priority if priority
38
43
  options[:ttl] = ttl if ttl
39
- data = connection.create_host(@zone.id, type, ip, options)
44
+ data = unless identity
45
+ connection.create_host(@zone.id, type, ip, options)
46
+ else
47
+ options[:host_type] = type
48
+ options[:data] = data
49
+ connection.update_host(identity, options)
50
+ end
40
51
  merge_attributes(data.body)
41
52
  true
42
53
  end
@@ -25,7 +25,7 @@ module Fog
25
25
  def get(record_id)
26
26
  data = connection.get_host(record_id).body
27
27
  new(data)
28
- rescue Excon::Errors::NotFound
28
+ rescue Fog::Service::NotFound
29
29
  nil
30
30
  end
31
31
 
@@ -70,7 +70,13 @@ module Fog
70
70
  # * notes<~String> - notes about the domain
71
71
  # * restrict_axfr<~String> - indicates if AXFR transfers should be restricted to IPs in axfr-ips
72
72
  # * tag_list<~String> - List of all tags associated with this domain
73
- data = connection.create_zone(domain, ttl, type, options)
73
+ data = unless identity
74
+ connection.create_zone(domain, ttl, type, options)
75
+ else
76
+ options[:default_ttl] = ttl
77
+ options[:ns_type] = type
78
+ connection.update_zone(identity, options)
79
+ end
74
80
  merge_attributes(data.body)
75
81
  true
76
82
  end
@@ -19,7 +19,7 @@ module Fog
19
19
  zone = new(data)
20
20
  zone.records.load(data['hosts'])
21
21
  zone
22
- rescue Excon::Errors::Forbidden
22
+ rescue Fog::Service::NotFound
23
23
  nil
24
24
  end
25
25
 
@@ -8,30 +8,6 @@ if ENV["FOG_MOCK"] == "true"
8
8
  Fog.mock!
9
9
  end
10
10
 
11
- def eventually(max_delay = 16, &block)
12
- delays = [0]
13
- delay_step = 1
14
- total = 0
15
- while true
16
- delay = 1
17
- delay_step.times do
18
- delay *= 2
19
- end
20
- delays << delay
21
- delay_step += 1
22
- break if delay >= max_delay
23
- end
24
- delays.each do |delay|
25
- begin
26
- sleep(delay)
27
- yield
28
- break
29
- rescue => error
30
- raise error if delay >= max_delay
31
- end
32
- end
33
- end
34
-
35
11
  unless defined?(GENTOO_AMI)
36
12
  GENTOO_AMI = 'ami-5ee70037'
37
13
  end
@@ -0,0 +1,15 @@
1
+ class AWS
2
+
3
+ module IAM
4
+
5
+ module Formats
6
+
7
+ BASIC = {
8
+ 'RequestId' => String
9
+ }
10
+
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,75 @@
1
+ Shindo.tests('AWS::SimpleDB | attributes requests', ['aws']) do
2
+
3
+ @domain_name = "fog_domain_#{Time.now.to_f.to_s.gsub('.','')}"
4
+
5
+ AWS[:sdb].create_domain(@domain_name)
6
+
7
+ tests('success') do
8
+
9
+ tests("#batch_put_attributes('#{@domain_name}', { 'a' => { 'b' => 'c' }, 'x' => { 'y' => 'z' } }).body").formats(AWS::SimpleDB::Formats::BASIC) do
10
+ AWS[:sdb].batch_put_attributes(@domain_name, { 'a' => { 'b' => 'c' }, 'x' => { 'y' => 'z' } }).body
11
+ end
12
+
13
+ tests("#get_attributes('#{@domain_name}', 'a').body['Attributes']").returns({'b' => ['c']}) do
14
+ attributes = {}
15
+ Fog.wait_for {
16
+ attributes = AWS[:sdb].get_attributes(@domain_name, 'a').body['Attributes']
17
+ attributes != {}
18
+ }
19
+ attributes
20
+ end
21
+
22
+ tests("#get_attributes('#{@domain_name}', 'notanattribute')").succeeds do
23
+ AWS[:sdb].get_attributes(@domain_name, 'notanattribute')
24
+ end
25
+
26
+ tests("#select('select * from #{@domain_name}').body['Items']").returns({ 'a' => { 'b' => ['c'] }, 'x' => { 'y' => ['z'] } }) do
27
+ pending if Fog.mocking?
28
+ AWS[:sdb].select("select * from #{@domain_name}").body['Items']
29
+ end
30
+
31
+ tests("#put_attributes('#{@domain_name}', 'conditional', { 'version' => '1' }).body").formats(AWS::SimpleDB::Formats::BASIC) do
32
+ AWS[:sdb].put_attributes(@domain_name, 'conditional', { 'version' => '1' }).body
33
+ end
34
+
35
+ tests("#put_attributes('#{@domain_name}', 'conditional', { 'version' => '2' }, :expect => { 'version' => '1' }, :replace => ['version']).body").formats(AWS::SimpleDB::Formats::BASIC) do
36
+ AWS[:sdb].put_attributes(@domain_name, 'conditional', { 'version' => '2' }, :expect => { 'version' => '1' }, :replace => ['version']).body
37
+ end
38
+
39
+ tests("#delete_attributes('#{@domain_name}', 'a').body").formats(AWS::SimpleDB::Formats::BASIC) do
40
+ AWS[:sdb].delete_attributes(@domain_name, 'a').body
41
+ end
42
+
43
+ tests("#delete_attributes('#{@domain_name}', 'a').body").succeeds do
44
+ AWS[:sdb].delete_attributes(@domain_name, 'a').body
45
+ end
46
+
47
+ end
48
+
49
+ tests('failure') do
50
+
51
+ tests("#batch_put_attributes('notadomain', { 'a' => { 'b' => 'c' }, 'x' => { 'y' => 'z' } })").raises(Excon::Errors::BadRequest) do
52
+ AWS[:sdb].batch_put_attributes('notadomain', { 'a' => { 'b' => 'c' }, 'x' => { 'y' => 'z' } })
53
+ end
54
+
55
+ tests("#get_attributes('notadomain', 'a')").raises(Excon::Errors::BadRequest) do
56
+ AWS[:sdb].get_attributes('notadomain', 'a')
57
+ end
58
+
59
+ tests("#put_attributes('notadomain', 'conditional', { 'version' => '1' })").raises(Excon::Errors::BadRequest) do
60
+ AWS[:sdb].put_attributes('notadomain', 'foo', { 'version' => '1' })
61
+ end
62
+
63
+ tests("#put_attributes('#{@domain_name}', 'conditional', { 'version' => '2' }, :expect => { 'version' => '1' }, :replace => ['version'])").raises(Excon::Errors::Conflict) do
64
+ AWS[:sdb].put_attributes(@domain_name, 'conditional', { 'version' => '2' }, :expect => { 'version' => '1' }, :replace => ['version'])
65
+ end
66
+
67
+ tests("#delete_attributes('notadomain', 'a')").raises(Excon::Errors::BadRequest) do
68
+ AWS[:sdb].delete_attributes('notadomain', 'a')
69
+ end
70
+
71
+ end
72
+
73
+ AWS[:sdb].delete_domain(@domain_name)
74
+
75
+ end