profitbricks 0.9.9 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -2
  3. data/Gemfile.lock +19 -22
  4. data/Guardfile +9 -0
  5. data/Manifest.txt +15 -0
  6. data/README.md +1 -1
  7. data/Rakefile +13 -5
  8. data/lib/profitbricks.rb +7 -5
  9. data/lib/profitbricks/data_center.rb +19 -20
  10. data/lib/profitbricks/extensions.rb +0 -3
  11. data/lib/profitbricks/firewall.rb +14 -20
  12. data/lib/profitbricks/image.rb +4 -6
  13. data/lib/profitbricks/ip_block.rb +5 -6
  14. data/lib/profitbricks/load_balancer.rb +23 -48
  15. data/lib/profitbricks/model.rb +8 -35
  16. data/lib/profitbricks/nic.rb +17 -22
  17. data/lib/profitbricks/profitbricks.rb +35 -27
  18. data/lib/profitbricks/rule.rb +2 -2
  19. data/lib/profitbricks/server.rb +96 -18
  20. data/lib/profitbricks/storage.rb +17 -22
  21. data/profitbricks.gemspec +6 -6
  22. data/spec/fixtures/get_server/two_nics.json +1 -0
  23. data/spec/fixtures/get_server/two_nics.xml +1 -0
  24. data/spec/fixtures/get_storage/mount_image.json +21 -0
  25. data/spec/fixtures/get_storage/mount_image.xml +1 -0
  26. data/spec/fixtures/power_off_server/success.json +1 -0
  27. data/spec/fixtures/power_off_server/success.xml +1 -0
  28. data/spec/fixtures/reset_server/success.json +1 -0
  29. data/spec/fixtures/reset_server/success.xml +1 -0
  30. data/spec/fixtures/shutdown_server/success.json +1 -0
  31. data/spec/fixtures/shutdown_server/success.xml +1 -0
  32. data/spec/fixtures/start_server/success.json +1 -0
  33. data/spec/fixtures/start_server/success.xml +1 -0
  34. data/spec/live/data_center_spec.rb +47 -0
  35. data/spec/live/server_spec.rb +58 -0
  36. data/spec/profitbricks/cli_spec.rb +13 -6
  37. data/spec/profitbricks/data_center_spec.rb +54 -29
  38. data/spec/profitbricks/firewall_spec.rb +17 -11
  39. data/spec/profitbricks/image_spec.rb +8 -5
  40. data/spec/profitbricks/ip_block_spec.rb +8 -5
  41. data/spec/profitbricks/load_balancer_spec.rb +23 -16
  42. data/spec/profitbricks/model_spec.rb +10 -13
  43. data/spec/profitbricks/nic_spec.rb +16 -13
  44. data/spec/profitbricks/server_spec.rb +117 -11
  45. data/spec/profitbricks/storage_spec.rb +22 -13
  46. data/spec/spec_helper.rb +10 -23
  47. metadata +19 -5
  48. data/.gemtest +0 -0
@@ -1,37 +1,40 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Profitbricks::Storage do
4
- include Savon::Spec::Macros
4
+ include Savon::SpecHelper
5
+
6
+ before(:all) { savon.mock! }
7
+ after(:all) { savon.unmock! }
5
8
 
6
9
  it "should create a new server with minimal arguments" do
7
- savon.expects(:create_storage).with("<arg0><dataCenterId>b3eebede-5c78-417c-b1bc-ff5de01a0602</dataCenterId><size>5</size><storageName>Test Storage</storageName></arg0>").returns(:success)
8
- savon.expects(:get_storage).with('<storageId>f55952bc-da27-4e29-af89-ed212ea28e11</storageId>').returns(:success)
10
+ savon.expects(:create_storage).with(message: {arg0: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602', size: 5, storage_name: 'Test Storage'}}).returns(f :create_storage, :success)
11
+ savon.expects(:get_storage).with(message: {storage_id: 'f55952bc-da27-4e29-af89-ed212ea28e11'}).returns(f :get_storage, :success)
9
12
  storage = Storage.create(:size => 5, :name => "Test Storage", :data_center_id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
10
13
  storage.name.should == "Test Storage"
11
14
  storage.size.should == 5
12
15
  end
13
16
 
14
17
  it "should be connectable to a server" do
15
- savon.expects(:get_storage).returns(:success)
16
- savon.expects(:connect_storage_to_server).returns(:success)
17
- savon.expects(:get_server).returns(:connected_storage)
18
+ savon.expects(:get_storage).with(message: {storage_id: 'f55952bc-da27-4e29-af89-ed212ea28e11'}).returns(f :get_storage, :success)
19
+ savon.expects(:connect_storage_to_server).with(message: {arg0: {storage_id: 'f55952bc-da27-4e29-af89-ed212ea28e11', server_id: '4cb6550f-3777-4818-8f4c-51233162a980', bus_type: 'VIRTIO'}}).returns(f :connect_storage_to_server, :success)
20
+ savon.expects(:get_server).with(message: {server_id: '4cb6550f-3777-4818-8f4c-51233162a980'}).returns(f :get_server, :connected_storage)
18
21
  storage = Storage.find(:id => "f55952bc-da27-4e29-af89-ed212ea28e11")
19
22
  storage.connect(:server_id => "4cb6550f-3777-4818-8f4c-51233162a980", :bus_type => "VIRTIO").should == true
20
23
  s = Server.find(:id => "4cb6550f-3777-4818-8f4c-51233162a980")
21
24
  # FIXME
22
- s.connected_storages[:storage_name].should == "Test Storage"
25
+ s.connected_storages.first.name.should == "Test Storage"
23
26
  end
24
27
 
25
28
  it "should be disconnectable from a server" do
26
- savon.expects(:get_storage).returns(:success)
27
- savon.expects(:disconnect_storage_from_server).returns(:success)
29
+ savon.expects(:get_storage).with(message: {storage_id: 'f55952bc-da27-4e29-af89-ed212ea28e11'}).returns(f :get_storage, :success)
30
+ savon.expects(:disconnect_storage_from_server).with(message: {storage_id: 'f55952bc-da27-4e29-af89-ed212ea28e11', server_id: '4cb6550f-3777-4818-8f4c-51233162a980'}).returns(f :disconnect_storage_from_server ,:success)
28
31
  storage = Storage.find(:id => "f55952bc-da27-4e29-af89-ed212ea28e11")
29
32
  storage.disconnect(:server_id => "4cb6550f-3777-4818-8f4c-51233162a980").should == true
30
33
  end
31
34
 
32
35
  it "should be updated" do
33
- savon.expects(:get_storage).returns(:success)
34
- savon.expects(:update_storage).returns(:success)
36
+ savon.expects(:get_storage).with(message: {storage_id: 'f55952bc-da27-4e29-af89-ed212ea28e11'}).returns(f :get_storage, :success)
37
+ savon.expects(:update_storage).with(message: {arg0: {storage_id: 'f55952bc-da27-4e29-af89-ed212ea28e11', size: 10, storage_name: 'Updated'}}).returns(f :update_storage, :success)
35
38
  storage = Storage.find(:id => "f55952bc-da27-4e29-af89-ed212ea28e11")
36
39
  storage.update(:name => "Updated", :size => 10).should == true
37
40
  storage.name.should == "Updated"
@@ -39,9 +42,15 @@ describe Profitbricks::Storage do
39
42
  end
40
43
 
41
44
  it "should be deleted" do
42
- savon.expects(:get_storage).with('<storageId>f55952bc-da27-4e29-af89-ed212ea28e11</storageId>').returns(:success)
43
- savon.expects(:delete_storage).with('<storageId>f55952bc-da27-4e29-af89-ed212ea28e11</storageId>').returns(:success)
45
+ savon.expects(:get_storage).with(message: {storage_id: 'f55952bc-da27-4e29-af89-ed212ea28e11'}).returns(f :get_storage, :success)
46
+ savon.expects(:delete_storage).with(message: {storage_id: 'f55952bc-da27-4e29-af89-ed212ea28e11'}).returns(f :delete_storage, :success)
44
47
  storage = Storage.find(:id => "f55952bc-da27-4e29-af89-ed212ea28e11")
45
48
  storage.delete.should == true
46
49
  end
50
+
51
+ it "should correctly declare the mount_image attribute" do
52
+ savon.expects(:get_storage).with(message: {storage_id: "0e3f262c-c014-d66e-0f81-9faac27c41c8"}).returns(f :get_storage, :mount_image)
53
+ storage = Storage.find(:id => "0e3f262c-c014-d66e-0f81-9faac27c41c8")
54
+ storage.mount_image.class.should == Image
55
+ end
47
56
  end
@@ -7,46 +7,33 @@
7
7
  require "bundler"
8
8
  Bundler.require(:default, :development)
9
9
 
10
+ require "savon/mock/spec_helper"
11
+
10
12
  if ENV['COVERAGE']
11
13
  require 'simplecov'
12
14
  SimpleCov.start
13
- end
14
-
15
- require 'coveralls'
16
- Coveralls.wear!
17
-
18
- Savon.configure do |config|
19
- config.log = false
15
+ else
16
+ require 'coveralls'
17
+ Coveralls.wear!
20
18
  end
21
19
 
22
20
  RSpec.configure do |config|
23
21
  config.treat_symbols_as_metadata_keys_with_true_values = true
24
22
  config.run_all_when_everything_filtered = true
25
23
  config.filter_run :focus
26
- config.include Savon::Spec::Macros
24
+ config.mock_with :rspec
27
25
  end
28
26
 
29
-
30
- Savon::Spec::Fixture.path = File.expand_path("../fixtures", __FILE__)
27
+ def f method, response
28
+ File.read File.join(File.expand_path("../fixtures", __FILE__), method.to_s, "#{response.to_s}.xml")
29
+ end
31
30
 
32
31
  require 'profitbricks'
33
32
 
34
- Savon.configure do |config|
35
- config.log = false
36
- config.log_level = :error
37
- end
38
33
  HTTPI.log = false
39
- client = Savon::Client.new do |wsdl, http|
40
- wsdl.endpoint = "https://api.profitbricks.com/1.1"
41
- wsdl.document = "https://api.profitbricks.com/1.1/wsdl"
42
- if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby' && !ENV['SSL_CERT_DIR']
43
- puts "Warning: SSL certificate verification has been disabled"
44
- http.auth.ssl.verify_mode = :none
45
- end
46
- end
47
34
 
48
35
  Profitbricks.configure do |config|
49
36
  config.username = "none"
50
37
  config.password = "none"
38
+ config.polling_interval = 0.1
51
39
  end
52
- Profitbricks.client = client
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: profitbricks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.9
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Sander
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-01 00:00:00.000000000 Z
11
+ date: 2013-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.0
19
+ version: 2.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.0
26
+ version: 2.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rdoc
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -67,6 +67,7 @@ files:
67
67
  - CHANGELOG.md
68
68
  - Gemfile
69
69
  - Gemfile.lock
70
+ - Guardfile
70
71
  - Manifest.txt
71
72
  - README.md
72
73
  - Rakefile
@@ -168,8 +169,14 @@ files:
168
169
  - spec/fixtures/get_server/after_create.xml
169
170
  - spec/fixtures/get_server/connected_storage.json
170
171
  - spec/fixtures/get_server/connected_storage.xml
172
+ - spec/fixtures/get_server/two_nics.json
173
+ - spec/fixtures/get_server/two_nics.xml
174
+ - spec/fixtures/get_storage/mount_image.json
175
+ - spec/fixtures/get_storage/mount_image.xml
171
176
  - spec/fixtures/get_storage/success.json
172
177
  - spec/fixtures/get_storage/success.xml
178
+ - spec/fixtures/power_off_server/success.json
179
+ - spec/fixtures/power_off_server/success.xml
173
180
  - spec/fixtures/reboot_server/success.json
174
181
  - spec/fixtures/reboot_server/success.xml
175
182
  - spec/fixtures/register_servers_on_load_balancer/success.json
@@ -182,10 +189,16 @@ files:
182
189
  - spec/fixtures/remove_public_ip_from_nic/success.xml
183
190
  - spec/fixtures/reserve_public_ip_block/success.json
184
191
  - spec/fixtures/reserve_public_ip_block/success.xml
192
+ - spec/fixtures/reset_server/success.json
193
+ - spec/fixtures/reset_server/success.xml
185
194
  - spec/fixtures/set_image_os_type/success.json
186
195
  - spec/fixtures/set_image_os_type/success.xml
187
196
  - spec/fixtures/set_internet_access/success.json
188
197
  - spec/fixtures/set_internet_access/success.xml
198
+ - spec/fixtures/shutdown_server/success.json
199
+ - spec/fixtures/shutdown_server/success.xml
200
+ - spec/fixtures/start_server/success.json
201
+ - spec/fixtures/start_server/success.xml
189
202
  - spec/fixtures/update_data_center/success.json
190
203
  - spec/fixtures/update_data_center/success.xml
191
204
  - spec/fixtures/update_load_balancer/success.json
@@ -196,6 +209,8 @@ files:
196
209
  - spec/fixtures/update_server/basic.xml
197
210
  - spec/fixtures/update_storage/success.json
198
211
  - spec/fixtures/update_storage/success.xml
212
+ - spec/live/data_center_spec.rb
213
+ - spec/live/server_spec.rb
199
214
  - spec/profitbricks/cli_spec.rb
200
215
  - spec/profitbricks/data_center_spec.rb
201
216
  - spec/profitbricks/firewall_spec.rb
@@ -207,7 +222,6 @@ files:
207
222
  - spec/profitbricks/server_spec.rb
208
223
  - spec/profitbricks/storage_spec.rb
209
224
  - spec/spec_helper.rb
210
- - .gemtest
211
225
  homepage: http://github.com/dsander/profitbricks
212
226
  licenses: []
213
227
  metadata: {}
data/.gemtest DELETED
File without changes