fog-core 1.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +15 -0
  2. data/lib/fog/account.rb +25 -0
  3. data/lib/fog/billing.rb +23 -0
  4. data/lib/fog/cdn.rb +23 -0
  5. data/lib/fog/compute.rb +80 -0
  6. data/lib/fog/compute/models/server.rb +104 -0
  7. data/lib/fog/core.rb +51 -0
  8. data/lib/fog/core/attributes.rb +227 -0
  9. data/lib/fog/core/class_from_string.rb +26 -0
  10. data/lib/fog/core/collection.rb +161 -0
  11. data/lib/fog/core/connection.rb +72 -0
  12. data/lib/fog/core/credentials.rb +70 -0
  13. data/lib/fog/core/current_machine.rb +34 -0
  14. data/lib/fog/core/deprecated_connection_accessors.rb +41 -0
  15. data/lib/fog/core/deprecation.rb +23 -0
  16. data/lib/fog/core/errors.rb +118 -0
  17. data/lib/fog/core/hmac.rb +35 -0
  18. data/lib/fog/core/logger.rb +44 -0
  19. data/lib/fog/core/mock.rb +115 -0
  20. data/lib/fog/core/model.rb +80 -0
  21. data/lib/fog/core/provider.rb +34 -0
  22. data/lib/fog/core/scp.rb +96 -0
  23. data/lib/fog/core/service.rb +223 -0
  24. data/lib/fog/core/ssh.rb +137 -0
  25. data/lib/fog/core/time.rb +32 -0
  26. data/lib/fog/core/uuid.rb +23 -0
  27. data/lib/fog/core/wait_for.rb +15 -0
  28. data/lib/fog/core/wait_for_defaults.rb +21 -0
  29. data/lib/fog/dns.rb +40 -0
  30. data/lib/fog/identity.rb +28 -0
  31. data/lib/fog/image.rb +23 -0
  32. data/lib/fog/metering.rb +25 -0
  33. data/lib/fog/monitoring.rb +24 -0
  34. data/lib/fog/network.rb +28 -0
  35. data/lib/fog/orchestration.rb +25 -0
  36. data/lib/fog/schema/data_validator.rb +154 -0
  37. data/lib/fog/storage.rb +80 -0
  38. data/lib/fog/support.rb +26 -0
  39. data/lib/fog/test_helpers.rb +12 -0
  40. data/lib/fog/test_helpers/collection_helper.rb +102 -0
  41. data/lib/fog/test_helpers/compute/flavors_helper.rb +34 -0
  42. data/lib/fog/test_helpers/compute/server_helper.rb +27 -0
  43. data/lib/fog/test_helpers/compute/servers_helper.rb +12 -0
  44. data/lib/fog/test_helpers/formats_helper.rb +99 -0
  45. data/lib/fog/test_helpers/helper.rb +25 -0
  46. data/lib/fog/test_helpers/mock_helper.rb +107 -0
  47. data/lib/fog/test_helpers/model_helper.rb +35 -0
  48. data/lib/fog/test_helpers/responds_to_helper.rb +13 -0
  49. data/lib/fog/test_helpers/succeeds_helper.rb +11 -0
  50. data/lib/fog/version.rb +3 -0
  51. data/lib/fog/volume.rb +25 -0
  52. data/lib/fog/vpn.rb +25 -0
  53. data/lib/tasks/test_task.rb +46 -0
  54. metadata +267 -0
@@ -0,0 +1,35 @@
1
+ def model_tests(collection, params = {}, mocks_implemented = true)
2
+
3
+ tests('success') do
4
+
5
+ @instance = collection.new(params)
6
+
7
+ tests("#save").succeeds do
8
+ pending if Fog.mocking? && !mocks_implemented
9
+ @instance.save
10
+ end
11
+
12
+ if block_given?
13
+ yield
14
+ end
15
+
16
+ tests("#destroy").succeeds do
17
+ pending if Fog.mocking? && !mocks_implemented
18
+ @instance.destroy
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+
25
+ # Generates a unique identifier with a random differentiator.
26
+ # Useful when rapidly re-running tests, so we don't have to wait
27
+ # serveral minutes for deleted objects to disappear from the API
28
+ # E.g. 'fog-test-1234'
29
+ def uniq_id(base_name = 'fog-test')
30
+ # random_differentiator
31
+ suffix = rand(65536).to_s(16).rjust(4, '0')
32
+ [base_name, suffix] * '-'
33
+ end
34
+
35
+
@@ -0,0 +1,13 @@
1
+ module Shindo
2
+ class Tests
3
+
4
+ def responds_to(method_names)
5
+ for method_name in [*method_names]
6
+ tests("#respond_to?(:#{method_name})").returns(true) do
7
+ @instance.respond_to?(method_name)
8
+ end
9
+ end
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module Shindo
2
+ class Tests
3
+
4
+ def succeeds
5
+ test('succeeds') do
6
+ !!instance_eval(&Proc.new)
7
+ end
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Fog
2
+ VERSION = "1.21.0"
3
+ end
@@ -0,0 +1,25 @@
1
+ module Fog
2
+ module Volume
3
+
4
+ def self.[](provider)
5
+ self.new(:provider => provider)
6
+ end
7
+
8
+ def self.new(attributes)
9
+ attributes = attributes.dup # Prevent delete from having side effects
10
+ provider = attributes.delete(:provider).to_s.downcase.to_sym
11
+ if self.providers.include?(provider)
12
+ require "fog/#{provider}/volume"
13
+ return Fog::Volume.const_get(Fog.providers[provider]).new(attributes)
14
+ end
15
+
16
+ raise ArgumentError.new("#{provider} has no identity service")
17
+ end
18
+
19
+ def self.providers
20
+ Fog.services[:volume]
21
+ end
22
+
23
+ end
24
+ end
25
+
@@ -0,0 +1,25 @@
1
+ module Fog
2
+ module VPN
3
+
4
+ def self.[](provider)
5
+ self.new(:provider => provider)
6
+ end
7
+
8
+ def self.new(attributes)
9
+ attributes = attributes.dup
10
+ provider = attributes.delete(:provider).to_s.downcase.to_sym
11
+
12
+ if provider == :stormondemand
13
+ require 'fog/storm_on_demand/vpn'
14
+ Fog::VPN::StormOnDemand.new(attributes)
15
+ else
16
+ raise ArgumentError.new("#{provider} has no vpn service")
17
+ end
18
+ end
19
+
20
+ def self.providers
21
+ Fog.services[:vpn]
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,46 @@
1
+ require "rake"
2
+ require "rake/tasklib"
3
+
4
+ module Fog
5
+ module Rake
6
+ class TestTask < ::Rake::TaskLib
7
+
8
+ def initialize
9
+ desc "Run the mocked tests"
10
+ task :test do
11
+ ::Rake::Task[:mock_tests].invoke
12
+ end
13
+
14
+ task :mock_tests do
15
+ tests(true)
16
+ end
17
+
18
+ task :real_tests do
19
+ tests(false)
20
+ end
21
+ end
22
+
23
+ def tests(mocked)
24
+ Formatador.display_line
25
+ start = Time.now.to_i
26
+ threads = []
27
+ Thread.main[:results] = []
28
+ Fog.providers.each do |key, value|
29
+ threads << Thread.new do
30
+ Thread.main[:results] << {
31
+ :provider => value,
32
+ :success => sh("export FOG_MOCK=#{mocked} && bundle exec shindont +#{key}")
33
+ }
34
+ end
35
+ end
36
+ threads.each do |thread|
37
+ thread.join
38
+ end
39
+ Formatador.display_table(Thread.main[:results].sort {|x,y| x[:provider] <=> y[:provider]})
40
+ Formatador.display_line("[bold]FOG_MOCK=#{mocked}[/] tests completed in [bold]#{Time.now.to_i - start}[/] seconds")
41
+ Formatador.display_line
42
+ end
43
+
44
+ end
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,267 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fog-core
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.21.0
5
+ platform: ruby
6
+ authors:
7
+ - Evan Light
8
+ - Wesley Beary
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-02-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: builder
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ! '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ! '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: excon
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 0.31.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: 0.31.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: formatador
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: 0.2.0
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 0.2.0
56
+ - !ruby/object:Gem::Dependency
57
+ name: mime-types
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: net-scp
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: '1.1'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: '1.1'
84
+ - !ruby/object:Gem::Dependency
85
+ name: net-ssh
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: 2.1.3
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: 2.1.3
98
+ - !ruby/object:Gem::Dependency
99
+ name: rake
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: yard
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: thor
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ! '>='
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ - !ruby/object:Gem::Dependency
141
+ name: shindo
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ~>
145
+ - !ruby/object:Gem::Version
146
+ version: 0.3.4
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ~>
152
+ - !ruby/object:Gem::Version
153
+ version: 0.3.4
154
+ - !ruby/object:Gem::Dependency
155
+ name: pry
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ! '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ! '>='
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ - !ruby/object:Gem::Dependency
169
+ name: coveralls
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ! '>='
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ type: :development
176
+ prerelease: false
177
+ version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ description: Shared classes and tests for fog providers and services.
183
+ email:
184
+ - evan@tripledogdare.net
185
+ - geemus@gmail.com
186
+ executables: []
187
+ extensions: []
188
+ extra_rdoc_files: []
189
+ files:
190
+ - lib/fog/account.rb
191
+ - lib/fog/billing.rb
192
+ - lib/fog/cdn.rb
193
+ - lib/fog/compute.rb
194
+ - lib/fog/compute/models/server.rb
195
+ - lib/fog/core.rb
196
+ - lib/fog/core/attributes.rb
197
+ - lib/fog/core/class_from_string.rb
198
+ - lib/fog/core/collection.rb
199
+ - lib/fog/core/connection.rb
200
+ - lib/fog/core/credentials.rb
201
+ - lib/fog/core/current_machine.rb
202
+ - lib/fog/core/deprecated_connection_accessors.rb
203
+ - lib/fog/core/deprecation.rb
204
+ - lib/fog/core/errors.rb
205
+ - lib/fog/core/hmac.rb
206
+ - lib/fog/core/logger.rb
207
+ - lib/fog/core/mock.rb
208
+ - lib/fog/core/model.rb
209
+ - lib/fog/core/provider.rb
210
+ - lib/fog/core/scp.rb
211
+ - lib/fog/core/service.rb
212
+ - lib/fog/core/ssh.rb
213
+ - lib/fog/core/time.rb
214
+ - lib/fog/core/uuid.rb
215
+ - lib/fog/core/wait_for.rb
216
+ - lib/fog/core/wait_for_defaults.rb
217
+ - lib/fog/dns.rb
218
+ - lib/fog/identity.rb
219
+ - lib/fog/image.rb
220
+ - lib/fog/metering.rb
221
+ - lib/fog/monitoring.rb
222
+ - lib/fog/network.rb
223
+ - lib/fog/orchestration.rb
224
+ - lib/fog/schema/data_validator.rb
225
+ - lib/fog/storage.rb
226
+ - lib/fog/support.rb
227
+ - lib/fog/test_helpers.rb
228
+ - lib/fog/test_helpers/collection_helper.rb
229
+ - lib/fog/test_helpers/compute/flavors_helper.rb
230
+ - lib/fog/test_helpers/compute/server_helper.rb
231
+ - lib/fog/test_helpers/compute/servers_helper.rb
232
+ - lib/fog/test_helpers/formats_helper.rb
233
+ - lib/fog/test_helpers/helper.rb
234
+ - lib/fog/test_helpers/mock_helper.rb
235
+ - lib/fog/test_helpers/model_helper.rb
236
+ - lib/fog/test_helpers/responds_to_helper.rb
237
+ - lib/fog/test_helpers/succeeds_helper.rb
238
+ - lib/fog/version.rb
239
+ - lib/fog/volume.rb
240
+ - lib/fog/vpn.rb
241
+ - lib/tasks/test_task.rb
242
+ homepage: ''
243
+ licenses:
244
+ - MIT
245
+ metadata: {}
246
+ post_install_message:
247
+ rdoc_options: []
248
+ require_paths:
249
+ - lib
250
+ required_ruby_version: !ruby/object:Gem::Requirement
251
+ requirements:
252
+ - - ! '>='
253
+ - !ruby/object:Gem::Version
254
+ version: '0'
255
+ required_rubygems_version: !ruby/object:Gem::Requirement
256
+ requirements:
257
+ - - ! '>='
258
+ - !ruby/object:Gem::Version
259
+ version: '0'
260
+ requirements: []
261
+ rubyforge_project:
262
+ rubygems_version: 2.2.2
263
+ signing_key:
264
+ specification_version: 4
265
+ summary: Shared classes and tests for fog providers and services.
266
+ test_files: []
267
+ has_rdoc: