fog 0.3.31 → 0.3.32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/.document +3 -0
  2. data/.gitignore +10 -0
  3. data/Gemfile.lock +1 -4
  4. data/README.rdoc +29 -37
  5. data/Rakefile +5 -25
  6. data/bin/fog +1 -3
  7. data/examples/dns_methods.rb +389 -0
  8. data/examples/storage.rb +103 -0
  9. data/fog.gemspec +4 -778
  10. data/lib/fog.rb +5 -66
  11. data/lib/fog/aws.rb +3 -0
  12. data/lib/fog/aws/bin.rb +7 -2
  13. data/lib/fog/aws/cdn.rb +2 -2
  14. data/lib/fog/aws/compute.rb +2 -2
  15. data/lib/fog/aws/dns.rb +101 -0
  16. data/lib/fog/aws/elb.rb +2 -2
  17. data/lib/fog/aws/iam.rb +2 -2
  18. data/lib/fog/aws/models/compute/image.rb +1 -0
  19. data/lib/fog/aws/models/compute/server.rb +1 -1
  20. data/lib/fog/aws/models/compute/servers.rb +1 -13
  21. data/lib/fog/aws/parsers/compute/describe_images.rb +36 -34
  22. data/lib/fog/aws/parsers/dns/change_resource_record_sets.rb +26 -0
  23. data/lib/fog/aws/parsers/dns/create_hosted_zone.rb +55 -0
  24. data/lib/fog/aws/parsers/dns/delete_hosted_zone.rb +25 -0
  25. data/lib/fog/aws/parsers/dns/get_change.rb +26 -0
  26. data/lib/fog/aws/parsers/dns/get_hosted_zone.rb +43 -0
  27. data/lib/fog/aws/parsers/dns/list_hosted_zones.rb +35 -0
  28. data/lib/fog/aws/parsers/dns/list_resource_record_sets.rb +46 -0
  29. data/lib/fog/aws/requests/compute/describe_images.rb +1 -0
  30. data/lib/fog/aws/requests/dns/change_resource_record_sets.rb +90 -0
  31. data/lib/fog/aws/requests/dns/create_hosted_zone.rb +68 -0
  32. data/lib/fog/aws/requests/dns/delete_hosted_zone.rb +48 -0
  33. data/lib/fog/aws/requests/dns/get_change.rb +47 -0
  34. data/lib/fog/aws/requests/dns/get_hosted_zone.rb +51 -0
  35. data/lib/fog/aws/requests/dns/list_hosted_zones.rb +63 -0
  36. data/lib/fog/aws/requests/dns/list_resource_record_sets.rb +68 -0
  37. data/lib/fog/aws/requests/storage/get_object_url.rb +2 -2
  38. data/lib/fog/aws/requests/storage/put_object_url.rb +2 -2
  39. data/lib/fog/aws/requests/storage/sync_clock.rb +28 -0
  40. data/lib/fog/aws/simpledb.rb +2 -2
  41. data/lib/fog/aws/storage.rb +5 -3
  42. data/lib/fog/bluebox.rb +2 -0
  43. data/lib/fog/bluebox/compute.rb +2 -2
  44. data/lib/fog/brightbox.rb +2 -0
  45. data/lib/fog/brightbox/compute.rb +2 -2
  46. data/lib/fog/core.rb +21 -1
  47. data/lib/fog/core/bin.rb +3 -1
  48. data/lib/fog/core/compute.rb +1 -0
  49. data/lib/fog/core/credentials.rb +72 -50
  50. data/lib/fog/core/deprecation.rb +11 -5
  51. data/lib/fog/core/mock.rb +34 -0
  52. data/lib/fog/core/model.rb +9 -1
  53. data/lib/fog/core/service.rb +40 -26
  54. data/lib/fog/core/storage.rb +1 -0
  55. data/lib/fog/core/time.rb +21 -0
  56. data/lib/fog/core/wait_for.rb +17 -0
  57. data/lib/fog/go_grid.rb +2 -0
  58. data/lib/fog/go_grid/compute.rb +2 -2
  59. data/lib/fog/google.rb +2 -0
  60. data/lib/fog/google/requests/storage/get_bucket.rb +6 -5
  61. data/lib/fog/google/requests/storage/get_object_url.rb +4 -4
  62. data/lib/fog/google/requests/storage/put_object_url.rb +4 -4
  63. data/lib/fog/google/storage.rb +4 -3
  64. data/lib/fog/linode.rb +3 -0
  65. data/lib/fog/linode/bin.rb +5 -3
  66. data/lib/fog/linode/compute.rb +6 -2
  67. data/lib/fog/linode/dns.rb +80 -0
  68. data/lib/fog/linode/requests/dns/domain_create.rb +52 -0
  69. data/lib/fog/linode/requests/dns/domain_delete.rb +35 -0
  70. data/lib/fog/linode/requests/dns/domain_list.rb +50 -0
  71. data/lib/fog/linode/requests/dns/domain_resource_create.rb +53 -0
  72. data/lib/fog/linode/requests/dns/domain_resource_delete.rb +36 -0
  73. data/lib/fog/linode/requests/dns/domain_resource_list.rb +48 -0
  74. data/lib/fog/linode/requests/dns/domain_resource_update.rb +54 -0
  75. data/lib/fog/linode/requests/dns/domain_update.rb +48 -0
  76. data/lib/fog/local.rb +2 -0
  77. data/lib/fog/local/storage.rb +3 -3
  78. data/lib/fog/new_servers.rb +2 -0
  79. data/lib/fog/new_servers/compute.rb +2 -2
  80. data/lib/fog/rackspace.rb +2 -0
  81. data/lib/fog/rackspace/cdn.rb +2 -2
  82. data/lib/fog/rackspace/compute.rb +2 -2
  83. data/lib/fog/rackspace/storage.rb +2 -2
  84. data/lib/fog/slicehost.rb +3 -0
  85. data/lib/fog/slicehost/bin.rb +2 -0
  86. data/lib/fog/slicehost/compute.rb +2 -2
  87. data/lib/fog/slicehost/dns.rb +84 -0
  88. data/lib/fog/slicehost/parsers/dns/create_record.rb +26 -0
  89. data/lib/fog/slicehost/parsers/dns/create_zone.rb +26 -0
  90. data/lib/fog/slicehost/parsers/dns/get_record.rb +26 -0
  91. data/lib/fog/slicehost/parsers/dns/get_records.rb +30 -0
  92. data/lib/fog/slicehost/parsers/dns/get_zone.rb +26 -0
  93. data/lib/fog/slicehost/parsers/dns/get_zones.rb +30 -0
  94. data/lib/fog/slicehost/requests/compute/create_slice.rb +2 -2
  95. data/lib/fog/slicehost/requests/compute/delete_slice.rb +3 -17
  96. data/lib/fog/slicehost/requests/dns/create_record.rb +61 -0
  97. data/lib/fog/slicehost/requests/dns/create_zone.rb +54 -0
  98. data/lib/fog/slicehost/requests/dns/delete_record.rb +31 -0
  99. data/lib/fog/slicehost/requests/dns/delete_zone.rb +31 -0
  100. data/lib/fog/slicehost/requests/dns/get_record.rb +40 -0
  101. data/lib/fog/slicehost/requests/dns/get_records.rb +41 -0
  102. data/lib/fog/slicehost/requests/dns/get_zone.rb +40 -0
  103. data/lib/fog/slicehost/requests/dns/get_zones.rb +38 -0
  104. data/lib/fog/terremark.rb +2 -0
  105. data/lib/fog/terremark/ecloud.rb +2 -4
  106. data/lib/fog/vcloud.rb +4 -2
  107. data/lib/fog/vcloud/bin.rb +3 -1
  108. data/lib/fog/vcloud/mock_data_classes.rb +77 -11
  109. data/lib/fog/vcloud/terremark/ecloud.rb +22 -7
  110. data/lib/fog/vcloud/terremark/ecloud/models/backup_internet_service.rb +60 -0
  111. data/lib/fog/vcloud/terremark/ecloud/models/backup_internet_services.rb +36 -0
  112. data/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb +28 -13
  113. data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +2 -2
  114. data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +1 -1
  115. data/lib/fog/vcloud/terremark/ecloud/models/network.rb +4 -1
  116. data/lib/fog/vcloud/terremark/ecloud/models/server.rb +5 -5
  117. data/lib/fog/vcloud/terremark/ecloud/models/vdc.rb +6 -2
  118. data/lib/fog/vcloud/terremark/ecloud/requests/add_backup_internet_service.rb +111 -0
  119. data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +2 -4
  120. data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +1 -3
  121. data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +39 -27
  122. data/lib/fog/vcloud/terremark/ecloud/requests/configure_network.rb +1 -2
  123. data/lib/fog/vcloud/terremark/ecloud/requests/configure_network_ip.rb +21 -6
  124. data/lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb +2 -1
  125. data/lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb +34 -17
  126. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb +12 -10
  127. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb +15 -10
  128. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +1 -12
  129. data/lib/fog/zerigo.rb +15 -0
  130. data/lib/fog/zerigo/bin.rb +25 -0
  131. data/lib/fog/zerigo/dns.rb +96 -0
  132. data/lib/fog/zerigo/parsers/dns/count_hosts.rb +24 -0
  133. data/lib/fog/zerigo/parsers/dns/count_zones.rb +24 -0
  134. data/lib/fog/zerigo/parsers/dns/create_host.rb +26 -0
  135. data/lib/fog/zerigo/parsers/dns/create_zone.rb +26 -0
  136. data/lib/fog/zerigo/parsers/dns/find_hosts.rb +30 -0
  137. data/lib/fog/zerigo/parsers/dns/get_host.rb +26 -0
  138. data/lib/fog/zerigo/parsers/dns/get_zone.rb +56 -0
  139. data/lib/fog/zerigo/parsers/dns/get_zone_stats.rb +26 -0
  140. data/lib/fog/zerigo/parsers/dns/list_hosts.rb +30 -0
  141. data/lib/fog/zerigo/parsers/dns/list_zones.rb +30 -0
  142. data/lib/fog/zerigo/requests/dns/count_hosts.rb +36 -0
  143. data/lib/fog/zerigo/requests/dns/count_zones.rb +36 -0
  144. data/lib/fog/zerigo/requests/dns/create_host.rb +70 -0
  145. data/lib/fog/zerigo/requests/dns/create_zone.rb +97 -0
  146. data/lib/fog/zerigo/requests/dns/delete_host.rb +32 -0
  147. data/lib/fog/zerigo/requests/dns/delete_zone.rb +33 -0
  148. data/lib/fog/zerigo/requests/dns/find_hosts.rb +63 -0
  149. data/lib/fog/zerigo/requests/dns/get_host.rb +47 -0
  150. data/lib/fog/zerigo/requests/dns/get_zone.rb +57 -0
  151. data/lib/fog/zerigo/requests/dns/get_zone_stats.rb +44 -0
  152. data/lib/fog/zerigo/requests/dns/list_hosts.rb +48 -0
  153. data/lib/fog/zerigo/requests/dns/list_zones.rb +53 -0
  154. data/lib/fog/zerigo/requests/dns/update_host.rb +60 -0
  155. data/lib/fog/zerigo/requests/dns/update_zone.rb +78 -0
  156. data/spec/spec_helper.rb +0 -5
  157. data/spec/vcloud/spec_helper.rb +3 -2
  158. data/spec/vcloud/terremark/ecloud/models/backup_internet_service_spec.rb +49 -0
  159. data/spec/vcloud/terremark/ecloud/models/backup_internet_services_spec.rb +29 -0
  160. data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +32 -13
  161. data/spec/vcloud/terremark/ecloud/models/network_spec.rb +7 -4
  162. data/spec/vcloud/terremark/ecloud/models/server_spec.rb +20 -0
  163. data/spec/vcloud/terremark/ecloud/requests/add_backup_internet_service_spec.rb +60 -0
  164. data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +3 -0
  165. data/spec/vcloud/terremark/ecloud/requests/configure_network_ip_spec.rb +55 -0
  166. data/spec/vcloud/terremark/ecloud/requests/delete_vapp_spec.rb +9 -0
  167. data/spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb +60 -14
  168. data/spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb +2 -0
  169. data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +3 -3
  170. data/tests/aws/requests/compute/image_tests.rb +15 -14
  171. data/tests/aws/requests/dns/dns_tests.rb +276 -0
  172. data/tests/brightbox/requests/compute/account_tests.rb +20 -9
  173. data/tests/brightbox/requests/compute/api_client_tests.rb +12 -4
  174. data/tests/brightbox/requests/compute/cloud_ip_tests.rb +20 -6
  175. data/tests/brightbox/requests/compute/image_tests.rb +9 -4
  176. data/tests/brightbox/requests/compute/interface_tests.rb +8 -2
  177. data/tests/brightbox/requests/compute/server_tests.rb +17 -5
  178. data/tests/brightbox/requests/compute/server_type_tests.rb +8 -4
  179. data/tests/brightbox/requests/compute/user_tests.rb +13 -5
  180. data/tests/brightbox/requests/compute/zone_tests.rb +8 -4
  181. data/tests/core/attribute_tests.rb +45 -0
  182. data/tests/helper.rb +0 -2
  183. data/tests/linode/requests/dns/dns_tests.rb +262 -0
  184. data/tests/rackspace/requests/compute/address_tests.rb +1 -1
  185. data/tests/rackspace/requests/compute/image_tests.rb +1 -1
  186. data/tests/slicehost/requests/dns_tests/dns_tests.rb +279 -0
  187. data/tests/zerigo/helper.rb +0 -0
  188. data/tests/zerigo/requests/dns/dns_tests.rb +374 -0
  189. metadata +280 -36
  190. data/spec/compact_progress_bar_formatter.rb +0 -195
  191. data/spec/core/attributes_spec.rb +0 -52
  192. data/spec/lorem.txt +0 -1
@@ -1,8 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
2
2
  require 'fog/core/bin'
3
3
 
4
- Fog.bin = true
5
-
6
4
  __DIR__ = File.dirname(__FILE__)
7
5
 
8
6
  $LOAD_PATH.unshift __DIR__ unless
@@ -0,0 +1,262 @@
1
+ Shindo.tests('Linode::dns | DNS requests', ['linode', 'dns']) do
2
+
3
+ @domain = ''
4
+ @new_zones = []
5
+ @new_records =[]
6
+
7
+ def generate_unique_domain( with_trailing_dot = false)
8
+ #get time (with 1/100th of sec accuracy)
9
+ #want unique domain name and if provider is fast, this can be called more than once per second
10
+ time= (Time.now.to_f * 100).to_i
11
+ domain = 'test-' + time.to_s + '.com'
12
+ if with_trailing_dot
13
+ domain+= '.'
14
+ end
15
+
16
+ domain
17
+ end
18
+
19
+ tests( 'success') do
20
+
21
+ test('get current zone count') do
22
+ pending if Fog.mocking?
23
+
24
+ @org_zone_count= 0
25
+ response = Linode[:dns].domain_list()
26
+ if response.status == 200
27
+ zones = response.body['DATA']
28
+ @org_zone_count = zones.count
29
+ end
30
+
31
+ response.status == 200
32
+ end
33
+
34
+ test('create zone - simple') do
35
+ pending if Fog.mocking?
36
+
37
+ type = 'master'
38
+ domain= generate_unique_domain
39
+ options = { :SOA_email => "netops@#{domain}", :description => "Sample-Domain Inc", :status => 0}
40
+ response = Linode[:dns].domain_create( domain, type, options)
41
+ if response.status == 200
42
+ @master_zone_id = response.body['DATA']['DomainID']
43
+ @new_zones << @master_zone_id
44
+ end
45
+
46
+ response.status == 200
47
+ end
48
+
49
+ test('create zone - set all parameters') do
50
+ pending if Fog.mocking?
51
+
52
+ type = 'slave'
53
+ @domain= generate_unique_domain
54
+ options = { :SOA_email => "netops@#{@domain}", :refresh_sec => 14400, :retry_sec => 3600,
55
+ :expire_sec => 604800, :ttl_sec => 28800, :status => 0, :master_ips => '1.2.3.4;2.3.4.5' }
56
+ response = Linode[:dns].domain_create( @domain, type, options)
57
+ if response.status == 200
58
+ @slave_zone_id = response.body['DATA']['DomainID']
59
+ @new_zones << @slave_zone_id
60
+ end
61
+
62
+ response.status == 200
63
+ end
64
+
65
+ test("get zone #{@slave_zone_id} - check all parameters for #{@domain}") do
66
+ pending if Fog.mocking?
67
+
68
+ result= false
69
+
70
+ response = Linode[:dns].domain_list( @slave_zone_id)
71
+ if response.status == 200
72
+ zones = response.body['DATA']
73
+ num_zones = zones.count
74
+ if num_zones == 1
75
+ zone= zones[0]
76
+ if (zone['SOA_EMAIL'] == "netops@#{@domain}") and (zone['REFRESH_SEC'] == 14400) and
77
+ (zone['RETRY_SEC'] == 3600) and (zone['EXPIRE_SEC'] == 604800) and (zone['TTL_SEC'] == 28800) and
78
+ (zone['STATUS'] == 0) and (zone['DOMAIN'] == @domain) and (zone['TYPE'] == 'slave')
79
+ (zone['MASTER_IPS'] == '1.2.3.4;2.3.4.5')
80
+ result= true
81
+ end
82
+ end
83
+ end
84
+
85
+ result
86
+ end
87
+
88
+ test("update zone #{@slave_zone_id}- update TTL parameter") do
89
+ pending if Fog.mocking?
90
+
91
+ result= false
92
+
93
+ options = { :ttl_sec => 14400 }
94
+ response = Linode[:dns].domain_update( @slave_zone_id, options)
95
+ if response.status == 200
96
+ result= true
97
+ end
98
+
99
+ result
100
+ end
101
+
102
+ test("get zone #{@slave_zone_id} - check TTL parameters") do
103
+ pending if Fog.mocking?
104
+
105
+ result= false
106
+
107
+ response = Linode[:dns].domain_list( @slave_zone_id)
108
+ if response.status == 200
109
+ zones = response.body['DATA']
110
+ num_zones = zones.count
111
+ if num_zones == 1
112
+ zone= zones[0]
113
+ if (zone['TTL_SEC'] == 14400)
114
+ result= true
115
+ end
116
+ end
117
+ end
118
+
119
+ result
120
+ end
121
+
122
+ test('create record - simple A record') do
123
+ pending if Fog.mocking?
124
+
125
+ host= 'www.' + @domain
126
+ options = { :name => host, :target => '4.5.6.7', :ttl_sec => 3600 }
127
+ response = Linode[:dns].domain_resource_create( @master_zone_id, 'A', options)
128
+ if response.status == 200
129
+ record_id = response.body['DATA']['ResourceID']
130
+ @new_records << record_id
131
+ end
132
+
133
+ response.status == 200
134
+ end
135
+
136
+ test('create record - CNAME record') do
137
+ pending if Fog.mocking?
138
+
139
+ host= 'mail'
140
+ options = { :name => host, :target => 'www.' + @domain }
141
+ response = Linode[:dns].domain_resource_create( @master_zone_id, 'CNAME', options)
142
+ if response.status == 200
143
+ record_id = response.body['DATA']['ResourceID']
144
+ @new_records << record_id
145
+ end
146
+
147
+ response.status == 200
148
+ end
149
+
150
+ test('create record - NS record') do
151
+ pending if Fog.mocking?
152
+
153
+ options = { :name => @domain, :target => 'ns.' + @domain}
154
+ response = Linode[:dns].domain_resource_create( @master_zone_id, 'NS', options)
155
+ if response.status == 200
156
+ record_id = response.body['DATA']['ResourceID']
157
+ @new_records << record_id
158
+ end
159
+
160
+ response.status == 200
161
+ end
162
+
163
+ test('create record - MX record') do
164
+ pending if Fog.mocking?
165
+
166
+ options = { :target => 'mail.' + @domain, :ttl_sec => 7200, :priority => 5 }
167
+ response = Linode[:dns].domain_resource_create( @master_zone_id, 'MX', options)
168
+ if response.status == 200
169
+ @record_id = response.body['DATA']['ResourceID']
170
+ @new_records << @record_id
171
+ end
172
+
173
+ response.status == 200
174
+ end
175
+
176
+ test("get record #{@record_id} - verify all parameters") do
177
+ pending if Fog.mocking?
178
+
179
+ result= false
180
+
181
+ domain= 'mail.' + @domain
182
+ response = Linode[:dns].domain_resource_list(@master_zone_id, @record_id)
183
+ if response.status == 200
184
+
185
+ records= response.body['DATA']
186
+ if records.count == 1
187
+ record = records[0]
188
+ if (record['TYPE'] == 'MX') and (record['PRIORITY'] == 5) and (record['TTL_SEC'] == 7200) and
189
+ (record['TARGET'] == domain)
190
+ result= true
191
+ end
192
+ end
193
+
194
+ end
195
+
196
+ result
197
+ end
198
+
199
+ test("update record #{@record_id} - change target") do
200
+ pending if Fog.mocking?
201
+
202
+ options = { :target => 'mail2.' + @domain }
203
+ response = Linode[:dns].domain_resource_update( @master_zone_id, @record_id, options)
204
+
205
+ response.status == 200
206
+ end
207
+
208
+ test("get record #{@record_id} - verify target changed") do
209
+ pending if Fog.mocking?
210
+
211
+ result= false
212
+
213
+ domain= 'mail2.' + @domain
214
+ response = Linode[:dns].domain_resource_list(@master_zone_id, @record_id)
215
+ if response.status == 200
216
+
217
+ records= response.body['DATA']
218
+ if records.count == 1
219
+ record = records[0]
220
+ if record['TARGET'] == domain
221
+ result= true
222
+ end
223
+ end
224
+
225
+ end
226
+
227
+ result
228
+
229
+ end
230
+
231
+ test("delete #{@new_records.count} records created") do
232
+ pending if Fog.mocking?
233
+
234
+ result= true
235
+ @new_records.each { |record_id|
236
+ response = Linode[:dns].domain_resource_delete( @master_zone_id, record_id)
237
+ if response.status != 200
238
+ result= false;
239
+ end
240
+ }
241
+ result
242
+ end
243
+
244
+ test("delete #{@new_zones.count} zones created") do
245
+ pending if Fog.mocking?
246
+
247
+ result= true
248
+ @new_zones.each { |zone_id|
249
+ response = Linode[:dns].domain_delete( zone_id)
250
+ if response.status != 200
251
+ result= false;
252
+ end
253
+ }
254
+ result
255
+ end
256
+
257
+ end
258
+
259
+ tests( 'failure') do
260
+ end
261
+
262
+ end
@@ -2,7 +2,7 @@ Shindo.tests('Rackspace::Compute | address requests', ['rackspace']) do
2
2
 
3
3
  tests('success') do
4
4
 
5
- @server = Rackspace[:compute].servers.create(:flavor_id => 1, :image_id => 19, :name => 'foglistaddresses')
5
+ @server = Rackspace[:compute].servers.create(:flavor_id => 1, :image_id => 19)
6
6
 
7
7
  tests("#list_addresses(#{@server.id})").formats({'addresses' => {'private' => [String], 'public' => [String]}}) do
8
8
  Rackspace[:compute].list_addresses(@server.id).body
@@ -14,7 +14,7 @@ Shindo.tests('Rackspace::Compute | image requests', ['rackspace']) do
14
14
 
15
15
  tests('success') do
16
16
 
17
- @server = Rackspace[:compute].servers.create(:flavor_id => 1, :image_id => 19, :name => 'foggetserverdetails')
17
+ @server = Rackspace[:compute].servers.create(:flavor_id => 1, :image_id => 19)
18
18
  @server.wait_for { ready? }
19
19
  @image_id = nil
20
20
 
@@ -0,0 +1,279 @@
1
+ Shindo.tests('Slicehost::dns | DNS requests', ['slicehost', 'dns']) do
2
+
3
+ @domain = ''
4
+ @new_zones = []
5
+ @new_records =[]
6
+
7
+ def generate_unique_domain( with_trailing_dot = false)
8
+ #get time (with 1/100th of sec accuracy)
9
+ #want unique domain name and if provider is fast, this can be called more than once per second
10
+ time= (Time.now.to_f * 100).to_i
11
+ domain = 'test-' + time.to_s + '.com'
12
+ if with_trailing_dot
13
+ domain+= '.'
14
+ end
15
+
16
+ domain
17
+ end
18
+
19
+ tests( 'success') do
20
+
21
+ test('get current zone count') do
22
+ pending if Fog.mocking?
23
+
24
+ @org_zone_count= 0
25
+ response = Slicehost[:dns].get_zones()
26
+ if response.status == 200
27
+ zones = response.body['zones']
28
+ @org_zone_count = zones.count
29
+ end
30
+
31
+ response.status == 200
32
+ end
33
+
34
+ test('create zone - simple') do
35
+ pending if Fog.mocking?
36
+
37
+ domain = generate_unique_domain( true)
38
+ response = Slicehost[:dns].create_zone(domain)
39
+ if response.status == 201
40
+ zone_id = response.body['id']
41
+ @new_zones << zone_id
42
+ end
43
+
44
+ response.status == 201
45
+ end
46
+
47
+ test('create zone - set all parameters') do
48
+ pending if Fog.mocking?
49
+
50
+ options = { :ttl => 1800, :active => 'N' }
51
+ @domain= generate_unique_domain( true)
52
+ response = Slicehost[:dns].create_zone( @domain, options)
53
+ if response.status == 201
54
+ @zone_id = response.body['id']
55
+ @new_zones << @zone_id
56
+ end
57
+
58
+ response.status == 201
59
+ end
60
+
61
+ test("get zone #{@zone_id} - check all parameters for #{@domain}") do
62
+ pending if Fog.mocking?
63
+
64
+ result= false
65
+
66
+ response = Slicehost[:dns].get_zone( @zone_id)
67
+ if response.status == 200
68
+ zone = response.body
69
+ if (zone['origin'] == @domain) and (zone['ttl'] == 1800) and
70
+ (zone['active'] == 'N')
71
+ result= true;
72
+ end
73
+ end
74
+
75
+ result
76
+ end
77
+
78
+ test('get zones - make sure total count is correct') do
79
+ pending if Fog.mocking?
80
+
81
+ result= false
82
+
83
+ response = Slicehost[:dns].get_zones()
84
+ if response.status == 200
85
+ zones = response.body['zones']
86
+ if (@org_zone_count+2) == zones.count
87
+ result= true;
88
+ end
89
+ end
90
+
91
+ result
92
+ end
93
+
94
+ test('get zones - check all parameters for a zone') do
95
+ pending if Fog.mocking?
96
+
97
+ result= false
98
+
99
+ response = Slicehost[:dns].get_zones()
100
+ if response.status == 200
101
+ zones = response.body['zones']
102
+ zones.each { |zone|
103
+ if zone['id'] == @new_zones[1]
104
+ if (zone['origin'] == 'sub.' + @domain) and (zone['ttl'] == 1800) and
105
+ (zone['active'] == 'N')
106
+ result= true;
107
+ end
108
+ end
109
+ }
110
+ if (@org_zone_count+2) == zones.count
111
+ result= true;
112
+ end
113
+ end
114
+
115
+ result
116
+ end
117
+
118
+ test('create record - simple A record') do
119
+ pending if Fog.mocking?
120
+
121
+ host= 'www.' + @domain
122
+ zone_id= @new_zones[1]
123
+ response = Slicehost[:dns].create_record( 'A', zone_id, host, '1.2.3.4')
124
+ if response.status == 201
125
+ record_id = response.body['id']
126
+ @new_records << record_id
127
+ end
128
+
129
+ response.status == 201
130
+ end
131
+
132
+ test('create record - A record - all parameters set') do
133
+ pending if Fog.mocking?
134
+
135
+ host= 'ftp.' + @domain
136
+ zone_id= @new_zones[1]
137
+ options = { :ttl => 3600, :active => 'N'}
138
+ response = Slicehost[:dns].create_record( 'A', zone_id, host, '1.2.3.4', options)
139
+ if response.status == 201
140
+ record_id = response.body['id']
141
+ @new_records << record_id
142
+ end
143
+
144
+ response.status == 201
145
+ end
146
+
147
+ test('create record - CNAME record') do
148
+ pending if Fog.mocking?
149
+
150
+ zone_id= @new_zones[1]
151
+ response = Slicehost[:dns].create_record( 'CNAME', zone_id, 'mail', @domain)
152
+ if response.status == 201
153
+ record_id = response.body['id']
154
+ @new_records << record_id
155
+ end
156
+
157
+ response.status == 201
158
+ end
159
+
160
+ test('create record - NS record') do
161
+ pending if Fog.mocking?
162
+
163
+ ns_domain = 'ns.' + @domain
164
+ zone_id= @new_zones[1]
165
+ options = { :ttl => 3600, :active => 'N'}
166
+ response = Slicehost[:dns].create_record( 'NS', zone_id, @domain, ns_domain, options)
167
+ if response.status == 201
168
+ record_id = response.body['id']
169
+ @new_records << record_id
170
+ end
171
+
172
+ response.status == 201
173
+ end
174
+
175
+ test('create record - MX record') do
176
+ pending if Fog.mocking?
177
+
178
+ mail_domain = 'mail.' + @domain
179
+ zone_id= @new_zones[1]
180
+ options = { :ttl => 3600, :active => 'N', :aux => '10'}
181
+ response = Slicehost[:dns].create_record( 'MX', zone_id, @domain, mail_domain, options)
182
+ if response.status == 201
183
+ @record_id = response.body['id']
184
+ @new_records << @record_id
185
+ end
186
+
187
+ response.status == 201
188
+ end
189
+
190
+ test("get record #{@record_id} - verify all parameters") do
191
+ pending if Fog.mocking?
192
+
193
+ result= false
194
+
195
+ response = Slicehost[:dns].get_record(@record_id)
196
+ if response.status == 200
197
+ mail_domain = 'mail.' + @domain
198
+ record = response.body['records'][0]
199
+ if (record['record-type'] == 'MX') and (record['name'] == @domain) and
200
+ (record['data'] == mail_domain) and (record['ttl'] == 3600) and (record['active'] == 'N') and
201
+ (record['aux'] == "10")
202
+ result= true
203
+ end
204
+ end
205
+
206
+ result
207
+ end
208
+
209
+ test('get records - verify all parameters for one record') do
210
+ pending if Fog.mocking?
211
+
212
+ result= false
213
+
214
+ response = Slicehost[:dns].get_records()
215
+ if response.status == 200
216
+ records = response.body['records']
217
+
218
+ #find mx record
219
+ records.each {|record|
220
+ if record['record-type'] == 'MX'
221
+
222
+ mail_domain = 'mail.' + @domain
223
+ if (record['record-type'] == 'MX') and (record['name'] == @domain) and
224
+ (record['data'] == mail_domain) and (record['ttl'] == 3600) and (record['active'] == 'N') and
225
+ (record['aux'] == "10")
226
+ result= true
227
+ break
228
+ end
229
+
230
+ end
231
+ }
232
+ end
233
+
234
+ result
235
+ end
236
+
237
+ test("delete #{@new_records.count} records created") do
238
+ pending if Fog.mocking?
239
+
240
+ result= true
241
+ @new_records.each { |record_id|
242
+ response = Slicehost[:dns].delete_record( record_id)
243
+ if response.status != 200
244
+ result= false;
245
+ end
246
+ }
247
+ result
248
+ end
249
+
250
+ test("delete #{@new_zones.count} zones created") do
251
+ pending if Fog.mocking?
252
+
253
+ result= true
254
+
255
+ @new_zones.each { |zone_id|
256
+ response = Slicehost[:dns].delete_zone( zone_id)
257
+ if response.status != 200
258
+ result= false;
259
+ end
260
+ }
261
+
262
+ result
263
+ end
264
+
265
+ end
266
+
267
+
268
+ tests( 'failure') do
269
+
270
+ #create a zone with invalid parameters
271
+ #get zonfo info with invalid zone id
272
+ #delete a zone with an invalid zone id
273
+
274
+ tests('#create_zone') do
275
+ end
276
+
277
+ end
278
+
279
+ end