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
@@ -5,8 +5,8 @@ module Profitbricks
5
5
  #
6
6
  # @return [Boolean] true on success, false otherwise
7
7
  def delete
8
- response = Profitbricks.request :delete_storage, "<storageId>#{self.id}</storageId>"
9
- return true if response.to_hash[:delete_storage_response][:return]
8
+ Profitbricks.request :delete_storage, storage_id: self.id
9
+ return true
10
10
  end
11
11
 
12
12
  # Connects a virtual storage device to an existing server.
@@ -18,11 +18,9 @@ module Profitbricks
18
18
  # @return [Boolean] true on success, false otherwise
19
19
  def connect(options = {})
20
20
  raise ArgumentError.new(":bus_type has to be either 'IDE' or 'VIRTIO'") if options[:bus_type] and !['IDE', 'VIRTIO'].include? options[:bus_type]
21
- xml = "<arg0>"
22
- xml += get_xml_and_update_attributes options.merge(:storage_id => self.id), [:server_id, :storage_id, :bus_type, :device_number]
23
- xml += "</arg0>"
24
- response = Profitbricks.request :connect_storage_to_server, xml
25
- return true if response.to_hash[:connect_storage_to_server_response][:return]
21
+ response = Profitbricks.request :connect_storage_to_server, options.merge(:storage_id => self.id)
22
+ update_attributes_from_hash options
23
+ return true
26
24
  end
27
25
 
28
26
  # Disconnects a virtual storage device from a connected server.
@@ -31,9 +29,8 @@ module Profitbricks
31
29
  # @option options [:server_id] Identifier of the connected virtual server (required)
32
30
  # @return [Boolean] true on success, false otherwise
33
31
  def disconnect(options = {})
34
- response = Profitbricks.request :disconnect_storage_from_server,
35
- "<storageId>#{self.id}</storageId><serverId>#{options[:server_id]}</serverId>"
36
- return true if response.to_hash[:disconnect_storage_from_server_response][:return]
32
+ Profitbricks.request :disconnect_storage_from_server, storage_id: self.id, server_id: options[:server_id]
33
+ return true
37
34
  end
38
35
 
39
36
  # Updates parameters of an existing virtual storage device.
@@ -44,11 +41,10 @@ module Profitbricks
44
41
  # @option options [:mount_image_id] Specifies the image to be assigned to the storage by its ID. Either choose a HDD or a CD-ROM/DVD (ISO) image
45
42
  # @return [Boolean] true on success, false otherwise
46
43
  def update(options = {})
47
- xml = "<arg0>"
48
- xml += get_xml_and_update_attributes options.merge(:storage_id => self.id), [:storage_id, :name, :size, :mount_image_id]
49
- xml += "</arg0>"
50
- response = Profitbricks.request :update_storage, xml
51
- return true if response.to_hash[:update_storage_response][:return]
44
+ update_attributes_from_hash options
45
+ options[:storage_name] = options.delete :name if options[:name]
46
+ Profitbricks.request :update_storage, options.merge(:storage_id => self.id)
47
+ return true
52
48
  end
53
49
 
54
50
  class << self
@@ -60,14 +56,13 @@ module Profitbricks
60
56
  # @option options [:data_center_id] Defines the data center wherein the storage is to be created. If left empty, the storage will be created in a new data center
61
57
  # @option options [:name] Name of the storage to be created
62
58
  # @option options [:mount_image_id] Specifies the image to be assigned to the storage by its ID. Either choose a HDD or a CD-ROM/DVD (ISO) image
59
+ # @option options [:profit_bricks_image_password] Sets the VM image root login password to the specified value. Only supported for generic Profitbricks HDD images. User images are expected to be preconfigured with a password. If no password is supplied, one is automatically created. Please see error codes for password syntax rules.]
63
60
  # @return [Storage] The created Storage
64
61
  def create(options = {})
65
62
  raise ArgumentError.new("You must provide a :data_center_id") if options[:data_center_id].nil?
66
- xml = "<arg0>"
67
- xml += get_xml_and_update_attributes options, [:data_center_id, :name, :size, :mount_image_id]
68
- xml += "</arg0>"
69
- response = Profitbricks.request :create_storage, xml
70
- self.find(:id => response.to_hash[:create_storage_return][:return][:storage_id])
63
+ options[:storage_name] = options.delete :name if options[:name]
64
+ response = Profitbricks.request :create_storage, options
65
+ self.find(:id => response[:storage_id])
71
66
  end
72
67
 
73
68
  # Finds a storage device
@@ -77,8 +72,8 @@ module Profitbricks
77
72
  # @return [Storage]
78
73
  def find(options = {})
79
74
  raise "Unable to locate the storage named '#{options[:name]}'" unless options[:id]
80
- response = Profitbricks.request :get_storage, "<storageId>#{options[:id]}</storageId>"
81
- Profitbricks::Storage.new(response.to_hash[:get_storage_response][:return])
75
+ response = Profitbricks.request :get_storage, storage_id: options[:id]
76
+ Profitbricks::Storage.new(response)
82
77
  end
83
78
  end
84
79
  end
@@ -2,16 +2,16 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "profitbricks"
5
- s.version = "0.9.8.20130501204252"
5
+ s.version = "1.0.0.20130618221547"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Dominik Sander"]
9
- s.date = "2013-05-01"
9
+ s.date = "2013-06-18"
10
10
  s.description = "A Ruby client for the ProfitBricks API."
11
11
  s.email = ["git@dsander.de"]
12
12
  s.executables = ["profitbricks"]
13
13
  s.extra_rdoc_files = ["CHANGELOG.md", "Manifest.txt", "README.md"]
14
- s.files = [".autotest", ".rspec", ".travis.yml", "CHANGELOG.md", "Gemfile", "Gemfile.lock", "Manifest.txt", "README.md", "Rakefile", "bin/profitbricks", "examples/create_datacenter.rb", "lib/profitbricks.rb", "lib/profitbricks/cli.rb", "lib/profitbricks/config.rb", "lib/profitbricks/data_center.rb", "lib/profitbricks/extensions.rb", "lib/profitbricks/firewall.rb", "lib/profitbricks/image.rb", "lib/profitbricks/ip_block.rb", "lib/profitbricks/load_balancer.rb", "lib/profitbricks/model.rb", "lib/profitbricks/nic.rb", "lib/profitbricks/profitbricks.rb", "lib/profitbricks/rule.rb", "lib/profitbricks/server.rb", "lib/profitbricks/storage.rb", "profitbricks.gemspec", "spec/fixtures/activate_firewalls/success.json", "spec/fixtures/activate_firewalls/success.xml", "spec/fixtures/activate_load_balancing_on_servers/success.json", "spec/fixtures/activate_load_balancing_on_servers/success.xml", "spec/fixtures/add_firewall_rules_to_load_balancer/success.json", "spec/fixtures/add_firewall_rules_to_load_balancer/success.xml", "spec/fixtures/add_firewall_rules_to_nic/success.json", "spec/fixtures/add_firewall_rules_to_nic/success.xml", "spec/fixtures/add_public_ip_to_nic/success.json", "spec/fixtures/add_public_ip_to_nic/success.xml", "spec/fixtures/clear_data_center/success.json", "spec/fixtures/clear_data_center/success.xml", "spec/fixtures/connect_storage_to_server/success.json", "spec/fixtures/connect_storage_to_server/success.xml", "spec/fixtures/create_data_center/success.json", "spec/fixtures/create_data_center/success.xml", "spec/fixtures/create_load_balancer/success.json", "spec/fixtures/create_load_balancer/success.xml", "spec/fixtures/create_nic/success.json", "spec/fixtures/create_nic/success.xml", "spec/fixtures/create_server/minimal.json", "spec/fixtures/create_server/minimal.xml", "spec/fixtures/create_storage/success.json", "spec/fixtures/create_storage/success.xml", "spec/fixtures/deactivate_firewalls/success.json", "spec/fixtures/deactivate_firewalls/success.xml", "spec/fixtures/deactivate_load_balancing_on_servers/success.json", "spec/fixtures/deactivate_load_balancing_on_servers/success.xml", "spec/fixtures/delete_data_center/success.json", "spec/fixtures/delete_data_center/success.xml", "spec/fixtures/delete_firewalls/success.json", "spec/fixtures/delete_firewalls/success.xml", "spec/fixtures/delete_load_balancer/success.json", "spec/fixtures/delete_load_balancer/success.xml", "spec/fixtures/delete_nic/success.json", "spec/fixtures/delete_nic/success.xml", "spec/fixtures/delete_server/success.json", "spec/fixtures/delete_server/success.xml", "spec/fixtures/delete_storage/failture.json", "spec/fixtures/delete_storage/failture.xml", "spec/fixtures/delete_storage/success.json", "spec/fixtures/delete_storage/success.xml", "spec/fixtures/deregister_servers_on_load_balancer/success.json", "spec/fixtures/deregister_servers_on_load_balancer/success.xml", "spec/fixtures/disconnect_storage_from_server/failture.json", "spec/fixtures/disconnect_storage_from_server/failture.xml", "spec/fixtures/disconnect_storage_from_server/success.json", "spec/fixtures/disconnect_storage_from_server/success.xml", "spec/fixtures/get_all_data_centers/empty.json", "spec/fixtures/get_all_data_centers/empty.xml", "spec/fixtures/get_all_data_centers/test_datacenter.json", "spec/fixtures/get_all_data_centers/test_datacenter.xml", "spec/fixtures/get_all_images/success.json", "spec/fixtures/get_all_images/success.xml", "spec/fixtures/get_all_public_ip_blocks/success.json", "spec/fixtures/get_all_public_ip_blocks/success.xml", "spec/fixtures/get_data_center/create.json", "spec/fixtures/get_data_center/create.xml", "spec/fixtures/get_data_center/firewall.json", "spec/fixtures/get_data_center/firewall.xml", "spec/fixtures/get_data_center/two_servers_with_storage.json", "spec/fixtures/get_data_center/two_servers_with_storage.xml", "spec/fixtures/get_data_center_state/in_process.json", "spec/fixtures/get_data_center_state/in_process.xml", "spec/fixtures/get_data_center_state/success.json", "spec/fixtures/get_data_center_state/success.xml", "spec/fixtures/get_firewall/success.json", "spec/fixtures/get_firewall/success.xml", "spec/fixtures/get_image/success.json", "spec/fixtures/get_image/success.xml", "spec/fixtures/get_load_balancer/success.json", "spec/fixtures/get_load_balancer/success.xml", "spec/fixtures/get_nic/success.json", "spec/fixtures/get_nic/success.xml", "spec/fixtures/get_nic/two_ips.json", "spec/fixtures/get_nic/two_ips.xml", "spec/fixtures/get_server/after_create.json", "spec/fixtures/get_server/after_create.xml", "spec/fixtures/get_server/connected_storage.json", "spec/fixtures/get_server/connected_storage.xml", "spec/fixtures/get_storage/success.json", "spec/fixtures/get_storage/success.xml", "spec/fixtures/reboot_server/success.json", "spec/fixtures/reboot_server/success.xml", "spec/fixtures/register_servers_on_load_balancer/success.json", "spec/fixtures/register_servers_on_load_balancer/success.xml", "spec/fixtures/release_public_ip_block/success.json", "spec/fixtures/release_public_ip_block/success.xml", "spec/fixtures/remove_firewall_rules/success.json", "spec/fixtures/remove_firewall_rules/success.xml", "spec/fixtures/remove_public_ip_from_nic/success.json", "spec/fixtures/remove_public_ip_from_nic/success.xml", "spec/fixtures/reserve_public_ip_block/success.json", "spec/fixtures/reserve_public_ip_block/success.xml", "spec/fixtures/set_image_os_type/success.json", "spec/fixtures/set_image_os_type/success.xml", "spec/fixtures/set_internet_access/success.json", "spec/fixtures/set_internet_access/success.xml", "spec/fixtures/update_data_center/success.json", "spec/fixtures/update_data_center/success.xml", "spec/fixtures/update_load_balancer/success.json", "spec/fixtures/update_load_balancer/success.xml", "spec/fixtures/update_nic/success.json", "spec/fixtures/update_nic/success.xml", "spec/fixtures/update_server/basic.json", "spec/fixtures/update_server/basic.xml", "spec/fixtures/update_storage/success.json", "spec/fixtures/update_storage/success.xml", "spec/profitbricks/cli_spec.rb", "spec/profitbricks/data_center_spec.rb", "spec/profitbricks/firewall_spec.rb", "spec/profitbricks/image_spec.rb", "spec/profitbricks/ip_block_spec.rb", "spec/profitbricks/load_balancer_spec.rb", "spec/profitbricks/model_spec.rb", "spec/profitbricks/nic_spec.rb", "spec/profitbricks/server_spec.rb", "spec/profitbricks/storage_spec.rb", "spec/spec_helper.rb", ".gemtest"]
14
+ s.files = [".autotest", ".rspec", ".travis.yml", "CHANGELOG.md", "Gemfile", "Gemfile.lock", "Guardfile", "Manifest.txt", "README.md", "Rakefile", "bin/profitbricks", "examples/create_datacenter.rb", "lib/profitbricks.rb", "lib/profitbricks/cli.rb", "lib/profitbricks/config.rb", "lib/profitbricks/data_center.rb", "lib/profitbricks/extensions.rb", "lib/profitbricks/firewall.rb", "lib/profitbricks/image.rb", "lib/profitbricks/ip_block.rb", "lib/profitbricks/load_balancer.rb", "lib/profitbricks/model.rb", "lib/profitbricks/nic.rb", "lib/profitbricks/profitbricks.rb", "lib/profitbricks/rule.rb", "lib/profitbricks/server.rb", "lib/profitbricks/storage.rb", "profitbricks.gemspec", "spec/fixtures/activate_firewalls/success.json", "spec/fixtures/activate_firewalls/success.xml", "spec/fixtures/activate_load_balancing_on_servers/success.json", "spec/fixtures/activate_load_balancing_on_servers/success.xml", "spec/fixtures/add_firewall_rules_to_load_balancer/success.json", "spec/fixtures/add_firewall_rules_to_load_balancer/success.xml", "spec/fixtures/add_firewall_rules_to_nic/success.json", "spec/fixtures/add_firewall_rules_to_nic/success.xml", "spec/fixtures/add_public_ip_to_nic/success.json", "spec/fixtures/add_public_ip_to_nic/success.xml", "spec/fixtures/clear_data_center/success.json", "spec/fixtures/clear_data_center/success.xml", "spec/fixtures/connect_storage_to_server/success.json", "spec/fixtures/connect_storage_to_server/success.xml", "spec/fixtures/create_data_center/success.json", "spec/fixtures/create_data_center/success.xml", "spec/fixtures/create_load_balancer/success.json", "spec/fixtures/create_load_balancer/success.xml", "spec/fixtures/create_nic/success.json", "spec/fixtures/create_nic/success.xml", "spec/fixtures/create_server/minimal.json", "spec/fixtures/create_server/minimal.xml", "spec/fixtures/create_storage/success.json", "spec/fixtures/create_storage/success.xml", "spec/fixtures/deactivate_firewalls/success.json", "spec/fixtures/deactivate_firewalls/success.xml", "spec/fixtures/deactivate_load_balancing_on_servers/success.json", "spec/fixtures/deactivate_load_balancing_on_servers/success.xml", "spec/fixtures/delete_data_center/success.json", "spec/fixtures/delete_data_center/success.xml", "spec/fixtures/delete_firewalls/success.json", "spec/fixtures/delete_firewalls/success.xml", "spec/fixtures/delete_load_balancer/success.json", "spec/fixtures/delete_load_balancer/success.xml", "spec/fixtures/delete_nic/success.json", "spec/fixtures/delete_nic/success.xml", "spec/fixtures/delete_server/success.json", "spec/fixtures/delete_server/success.xml", "spec/fixtures/delete_storage/failture.json", "spec/fixtures/delete_storage/failture.xml", "spec/fixtures/delete_storage/success.json", "spec/fixtures/delete_storage/success.xml", "spec/fixtures/deregister_servers_on_load_balancer/success.json", "spec/fixtures/deregister_servers_on_load_balancer/success.xml", "spec/fixtures/disconnect_storage_from_server/failture.json", "spec/fixtures/disconnect_storage_from_server/failture.xml", "spec/fixtures/disconnect_storage_from_server/success.json", "spec/fixtures/disconnect_storage_from_server/success.xml", "spec/fixtures/get_all_data_centers/empty.json", "spec/fixtures/get_all_data_centers/empty.xml", "spec/fixtures/get_all_data_centers/test_datacenter.json", "spec/fixtures/get_all_data_centers/test_datacenter.xml", "spec/fixtures/get_all_images/success.json", "spec/fixtures/get_all_images/success.xml", "spec/fixtures/get_all_public_ip_blocks/success.json", "spec/fixtures/get_all_public_ip_blocks/success.xml", "spec/fixtures/get_data_center/create.json", "spec/fixtures/get_data_center/create.xml", "spec/fixtures/get_data_center/firewall.json", "spec/fixtures/get_data_center/firewall.xml", "spec/fixtures/get_data_center/two_servers_with_storage.json", "spec/fixtures/get_data_center/two_servers_with_storage.xml", "spec/fixtures/get_data_center_state/in_process.json", "spec/fixtures/get_data_center_state/in_process.xml", "spec/fixtures/get_data_center_state/success.json", "spec/fixtures/get_data_center_state/success.xml", "spec/fixtures/get_firewall/success.json", "spec/fixtures/get_firewall/success.xml", "spec/fixtures/get_image/success.json", "spec/fixtures/get_image/success.xml", "spec/fixtures/get_load_balancer/success.json", "spec/fixtures/get_load_balancer/success.xml", "spec/fixtures/get_nic/success.json", "spec/fixtures/get_nic/success.xml", "spec/fixtures/get_nic/two_ips.json", "spec/fixtures/get_nic/two_ips.xml", "spec/fixtures/get_server/after_create.json", "spec/fixtures/get_server/after_create.xml", "spec/fixtures/get_server/connected_storage.json", "spec/fixtures/get_server/connected_storage.xml", "spec/fixtures/get_server/two_nics.json", "spec/fixtures/get_server/two_nics.xml", "spec/fixtures/get_storage/mount_image.json", "spec/fixtures/get_storage/mount_image.xml", "spec/fixtures/get_storage/success.json", "spec/fixtures/get_storage/success.xml", "spec/fixtures/power_off_server/success.json", "spec/fixtures/power_off_server/success.xml", "spec/fixtures/reboot_server/success.json", "spec/fixtures/reboot_server/success.xml", "spec/fixtures/register_servers_on_load_balancer/success.json", "spec/fixtures/register_servers_on_load_balancer/success.xml", "spec/fixtures/release_public_ip_block/success.json", "spec/fixtures/release_public_ip_block/success.xml", "spec/fixtures/remove_firewall_rules/success.json", "spec/fixtures/remove_firewall_rules/success.xml", "spec/fixtures/remove_public_ip_from_nic/success.json", "spec/fixtures/remove_public_ip_from_nic/success.xml", "spec/fixtures/reserve_public_ip_block/success.json", "spec/fixtures/reserve_public_ip_block/success.xml", "spec/fixtures/reset_server/success.json", "spec/fixtures/reset_server/success.xml", "spec/fixtures/set_image_os_type/success.json", "spec/fixtures/set_image_os_type/success.xml", "spec/fixtures/set_internet_access/success.json", "spec/fixtures/set_internet_access/success.xml", "spec/fixtures/shutdown_server/success.json", "spec/fixtures/shutdown_server/success.xml", "spec/fixtures/start_server/success.json", "spec/fixtures/start_server/success.xml", "spec/fixtures/update_data_center/success.json", "spec/fixtures/update_data_center/success.xml", "spec/fixtures/update_load_balancer/success.json", "spec/fixtures/update_load_balancer/success.xml", "spec/fixtures/update_nic/success.json", "spec/fixtures/update_nic/success.xml", "spec/fixtures/update_server/basic.json", "spec/fixtures/update_server/basic.xml", "spec/fixtures/update_storage/success.json", "spec/fixtures/update_storage/success.xml", "spec/live/data_center_spec.rb", "spec/live/server_spec.rb", "spec/profitbricks/cli_spec.rb", "spec/profitbricks/data_center_spec.rb", "spec/profitbricks/firewall_spec.rb", "spec/profitbricks/image_spec.rb", "spec/profitbricks/ip_block_spec.rb", "spec/profitbricks/load_balancer_spec.rb", "spec/profitbricks/model_spec.rb", "spec/profitbricks/nic_spec.rb", "spec/profitbricks/server_spec.rb", "spec/profitbricks/storage_spec.rb", "spec/spec_helper.rb"]
15
15
  s.homepage = "http://github.com/dsander/profitbricks"
16
16
  s.rdoc_options = ["--main", "README.md"]
17
17
  s.require_paths = ["lib"]
@@ -23,16 +23,16 @@ Gem::Specification.new do |s|
23
23
  s.specification_version = 4
24
24
 
25
25
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
- s.add_runtime_dependency(%q<savon>, ["= 1.2.0"])
26
+ s.add_runtime_dependency(%q<savon>, ["= 2.2.0"])
27
27
  s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
28
28
  s.add_development_dependency(%q<hoe>, ["~> 3.6"])
29
29
  else
30
- s.add_dependency(%q<savon>, ["= 1.2.0"])
30
+ s.add_dependency(%q<savon>, ["= 2.2.0"])
31
31
  s.add_dependency(%q<rdoc>, ["~> 4.0"])
32
32
  s.add_dependency(%q<hoe>, ["~> 3.6"])
33
33
  end
34
34
  else
35
- s.add_dependency(%q<savon>, ["= 1.2.0"])
35
+ s.add_dependency(%q<savon>, ["= 2.2.0"])
36
36
  s.add_dependency(%q<rdoc>, ["~> 4.0"])
37
37
  s.add_dependency(%q<hoe>, ["~> 3.6"])
38
38
  end
@@ -0,0 +1 @@
1
+ {"get_server_response":{"return":{"data_center_id":"d71fd545-90f5-1356-f878-5b0f86bc2cdc","data_center_version":"6","server_id":"238cb83e-72f5-4f58-a234-53cd68ca9db2","server_name":"test","cores":"1","ram":"512","internet_access":true,"ips":["46.16.73.167","10.14.38.11"],"connected_storages":{"bus_type":"IDE","device_number":"1","size":"25","storage_id":"80dc2e63-8d99-4341-b319-fb0dcea9e6de"},"nics":[{"data_center_id":"d71fd545-90f5-1356-f878-5b0f86bc2cdc","data_center_version":"6","nic_id":"4741a556-f57f-4c8f-8995-72f8c0407f8a","lan_id":"4","internet_access":true,"server_id":"238cb83e-72f5-4f58-a234-53cd68ca9db2","ips":"46.16.73.167","mac_address":"02:01:e0:37:03:40","firewall":{"active":false,"firewall_id":"f875a084-c30e-ee35-1a5d-2867c0f699ee","nic_id":"4741a556-f57f-4c8f-8995-72f8c0407f8a","provisioning_state":"AVAILABLE"}},{"data_center_id":"d71fd545-90f5-1356-f878-5b0f86bc2cdc","data_center_version":"6","nic_id":"50a3b28c-1ca0-caf4-b60e-37710586e95d","nic_name":"eth1","lan_id":"1","internet_access":false,"server_id":"238cb83e-72f5-4f58-a234-53cd68ca9db2","ips":"10.14.38.11","mac_address":"02:01:1b:fd:8c:11","firewall":{"active":false,"firewall_id":"801e2834-49bc-f9f0-7aa1-7cb466bc6b24","nic_id":"50a3b28c-1ca0-caf4-b60e-37710586e95d","provisioning_state":"AVAILABLE"}}],"provisioning_state":"AVAILABLE","virtual_machine_state":"RUNNING","creation_time":"2013-05-21T11:19:22.465Z","last_modification_time":"2013-05-22T16:56:38.086Z","os_type":"UNKNOWN","availability_zone":"AUTO"},"@xmlns:ns2":"http://ws.api.profitbricks.com/"}}
@@ -0,0 +1 @@
1
+ <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:getServerResponse xmlns:ns2="http://ws.api.profitbricks.com/"><return><dataCenterId>d71fd545-90f5-1356-f878-5b0f86bc2cdc</dataCenterId><dataCenterVersion>6</dataCenterVersion><serverId>238cb83e-72f5-4f58-a234-53cd68ca9db2</serverId><serverName>test</serverName><cores>1</cores><ram>512</ram><internetAccess>true</internetAccess><ips>46.16.73.167</ips><ips>10.14.38.11</ips><connectedStorages><busType>IDE</busType><deviceNumber>1</deviceNumber><size>25</size><storageId>80dc2e63-8d99-4341-b319-fb0dcea9e6de</storageId></connectedStorages><nics><dataCenterId>d71fd545-90f5-1356-f878-5b0f86bc2cdc</dataCenterId><dataCenterVersion>6</dataCenterVersion><nicId>4741a556-f57f-4c8f-8995-72f8c0407f8a</nicId><lanId>4</lanId><internetAccess>true</internetAccess><serverId>238cb83e-72f5-4f58-a234-53cd68ca9db2</serverId><ips>46.16.73.167</ips><macAddress>02:01:e0:37:03:40</macAddress><firewall><active>false</active><firewallId>f875a084-c30e-ee35-1a5d-2867c0f699ee</firewallId><nicId>4741a556-f57f-4c8f-8995-72f8c0407f8a</nicId><provisioningState>AVAILABLE</provisioningState></firewall></nics><nics><dataCenterId>d71fd545-90f5-1356-f878-5b0f86bc2cdc</dataCenterId><dataCenterVersion>6</dataCenterVersion><nicId>50a3b28c-1ca0-caf4-b60e-37710586e95d</nicId><nicName>eth1</nicName><lanId>1</lanId><internetAccess>false</internetAccess><serverId>238cb83e-72f5-4f58-a234-53cd68ca9db2</serverId><ips>10.14.38.11</ips><macAddress>02:01:1b:fd:8c:11</macAddress><firewall><active>false</active><firewallId>801e2834-49bc-f9f0-7aa1-7cb466bc6b24</firewallId><nicId>50a3b28c-1ca0-caf4-b60e-37710586e95d</nicId><provisioningState>AVAILABLE</provisioningState></firewall></nics><provisioningState>AVAILABLE</provisioningState><virtualMachineState>RUNNING</virtualMachineState><creationTime>2013-05-21T11:19:22.465Z</creationTime><lastModificationTime>2013-05-22T16:56:38.086Z</lastModificationTime><osType>UNKNOWN</osType><availabilityZone>AUTO</availabilityZone></return></ns2:getServerResponse></S:Body></S:Envelope>
@@ -0,0 +1,21 @@
1
+ {
2
+ "get_storage_response": {
3
+ "@xmlns:ns2": "http://ws.api.profitbricks.com/",
4
+ "return": {
5
+ "creation_time": "2013-05-27T16:20:24.166Z",
6
+ "data_center_id": "ba0fe96f-394e-af75-358e-27ed949edf9e",
7
+ "data_center_version": "2",
8
+ "last_modification_time": "2013-05-27T16:20:24.166Z",
9
+ "mount_image": {
10
+ "image_id": "9a91d341-92ff-11e2-8358-0025901dfe2a",
11
+ "image_name": "Ubuntu-12.04-LTS-server-amd64-03.21.13.img"
12
+ },
13
+ "os_type": "OTHER",
14
+ "provisioning_state": "AVAILABLE",
15
+ "server_ids": "83c716cd-8471-7030-d6ee-1066855657b5",
16
+ "size": "10",
17
+ "storage_id": "0e3f262c-c014-d66e-0f81-9faac27c41c8",
18
+ "storage_name": "Storage 1"
19
+ }
20
+ }
21
+ }
@@ -0,0 +1 @@
1
+ <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:getStorageResponse xmlns:ns2="http://ws.api.profitbricks.com/"><return><dataCenterId>ba0fe96f-394e-af75-358e-27ed949edf9e</dataCenterId><dataCenterVersion>2</dataCenterVersion><storageId>0e3f262c-c014-d66e-0f81-9faac27c41c8</storageId><size>10</size><storageName>Storage 1</storageName><mountImage><imageId>9a91d341-92ff-11e2-8358-0025901dfe2a</imageId><imageName>Ubuntu-12.04-LTS-server-amd64-03.21.13.img</imageName></mountImage><serverIds>83c716cd-8471-7030-d6ee-1066855657b5</serverIds><provisioningState>AVAILABLE</provisioningState><creationTime>2013-05-27T16:20:24.166Z</creationTime><lastModificationTime>2013-05-27T16:20:24.166Z</lastModificationTime><osType>OTHER</osType></return></ns2:getStorageResponse></S:Body></S:Envelope>
@@ -0,0 +1 @@
1
+ {"power_off_server_response":{"return":{"request_id":"50055"},"@xmlns:ns2":"http://ws.api.profitbricks.com/"}}
@@ -0,0 +1 @@
1
+ <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:powerOffServerResponse xmlns:ns2="http://ws.api.profitbricks.com/"><return><requestId>50055</requestId></return></ns2:powerOffServerResponse></S:Body></S:Envelope>
@@ -0,0 +1 @@
1
+ {"reset_server_response":{"return":{"request_id":"50053"},"@xmlns:ns2":"http://ws.api.profitbricks.com/"}}
@@ -0,0 +1 @@
1
+ <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:resetServerResponse xmlns:ns2="http://ws.api.profitbricks.com/"><return><requestId>50053</requestId></return></ns2:resetServerResponse></S:Body></S:Envelope>
@@ -0,0 +1 @@
1
+ {"shutdown_server_response":{"return":{"request_id":"50056"},"@xmlns:ns2":"http://ws.api.profitbricks.com/"}}
@@ -0,0 +1 @@
1
+ <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:shutdownServerResponse xmlns:ns2="http://ws.api.profitbricks.com/"><return><requestId>50056</requestId></return></ns2:shutdownServerResponse></S:Body></S:Envelope>
@@ -0,0 +1 @@
1
+ {"start_server_response":{"return":{"request_id":"50054"},"@xmlns:ns2":"http://ws.api.profitbricks.com/"}}
@@ -0,0 +1 @@
1
+ <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:startServerResponse xmlns:ns2="http://ws.api.profitbricks.com/"><return><requestId>50054</requestId></return></ns2:startServerResponse></S:Body></S:Envelope>
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe Profitbricks::DataCenter do
4
+ before(:all) do
5
+ Profitbricks.configure do |config|
6
+ config.username = ENV['PROFITBRICKS_USER']
7
+ config.password = ENV['PROFITBRICKS_PASSWORD']
8
+ end
9
+ begin
10
+ $dc = DataCenter.find(name: 'PB_live_test_DC')
11
+ $dc.delete
12
+ $dc.wait_for_provisioning
13
+ rescue
14
+ end
15
+ end
16
+ it "should create a new DataCenter" do
17
+ $dc = DataCenter.create(:name => 'PB_live_test_DC')
18
+ $dc.name.should == 'PB_live_test_DC'
19
+ $dc.version.should == 1
20
+ $dc.provisioned?.should == true
21
+ end
22
+
23
+ it "should return all DataCenters" do
24
+ DataCenter.all.length.should == 1
25
+ end
26
+
27
+ it "should be found by name" do
28
+ DataCenter.find(name: 'PB_live_test_DC').id.should == $dc.id
29
+ end
30
+
31
+ it "should be renamed" do
32
+ $dc.rename 'PB_live_test_DC-2'
33
+ $dc.reload
34
+ $dc.name.should == 'PB_live_test_DC-2'
35
+ $dc.version.should == 2
36
+ end
37
+
38
+ it "should be cleared" do
39
+ $dc.clear
40
+ $dc.servers.should == []
41
+ $dc.storages.should == []
42
+ end
43
+
44
+ it "should delete a the DataCenter" do
45
+ $dc.delete
46
+ end
47
+ end
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ describe Profitbricks::Server do
4
+ before(:all) do
5
+ Profitbricks.configure do |config|
6
+ config.username = ENV['PROFITBRICKS_USER']
7
+ config.password = ENV['PROFITBRICKS_PASSWORD']
8
+ end
9
+ begin
10
+ $dc = DataCenter.find(name: 'PB_live_test_DC')
11
+ $dc.clear
12
+ rescue
13
+ $dc = DataCenter.create(:name => 'PB_live_test_DC')
14
+ end
15
+ end
16
+
17
+ it "should first wait until the DataCenter is provisioned" do
18
+ $dc.wait_for_provisioning
19
+ $dc.provisioned?.should == true
20
+ end
21
+
22
+ it "should create a new Server" do
23
+ $server = $dc.create_server(cores: 1, ram: 256, name: 'PB_live_test_SERVER')
24
+ $server.cores.should == 1
25
+ $server.ram.should == 256
26
+ $server.name.should == 'PB_live_test_SERVER'
27
+ $server.provisioning_state.should == 'INACTIVE'
28
+ $server.running?.should == false
29
+ end
30
+
31
+ it "should wait untill it is running" do
32
+ $server.wait_for_running
33
+ $server.running?.should == true
34
+ end
35
+
36
+ it "should be updated" do
37
+ $server.update(ram: 512)
38
+ $server.wait_for_provisioning
39
+ # Looking at a potential API Bug here need to investigate further and write a bug report
40
+ $dc.wait_for_provisioning
41
+ 100.times do |i|
42
+ $server = Server.find(id: $server.id)
43
+ if $server.ram != 512
44
+ puts "Nope, not yet"
45
+ sleep 10
46
+ else
47
+ puts "Got it after #{i*10} seconds"
48
+ break
49
+ end
50
+ end
51
+ $server.ram.should == 512
52
+ $server.running?.should == true
53
+ end
54
+
55
+ it "should be deleted" do
56
+ $server.delete.should == true
57
+ end
58
+ end
@@ -2,8 +2,11 @@ require 'spec_helper'
2
2
  require 'profitbricks/cli'
3
3
 
4
4
  describe Profitbricks::CLI do
5
- include Savon::Spec::Macros
5
+ include Savon::SpecHelper
6
6
 
7
+ before(:all) { savon.mock! }
8
+ after(:all) { savon.unmock! }
9
+
7
10
  before(:all) do
8
11
  ENV['PROFITBRICKS_USER'] = 'bogus'
9
12
  ENV['PROFITBRICKS_PASSWORD'] = 'bogus'
@@ -21,7 +24,11 @@ describe Profitbricks::CLI do
21
24
  end
22
25
 
23
26
  it "should display the help message" do
24
- cli.run(["-h bogus"]).should == -1
27
+ cli.run(["-h"]).should == -1
28
+ end
29
+
30
+ it "should enable debugging" do
31
+ cli.run(["-d"]).should == -1
25
32
  end
26
33
 
27
34
  it "should abort with a invalid class" do
@@ -53,14 +60,14 @@ describe Profitbricks::CLI do
53
60
  end
54
61
 
55
62
  it "should get all data centers" do
56
- savon.expects(:get_all_data_centers).returns(:test_datacenter)
57
- savon.expects(:get_data_center).returns(:two_servers_with_storage)
63
+ savon.expects(:get_all_data_centers).with(message: {}).returns(f :get_all_data_centers, :test_datacenter)
64
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
58
65
  cli.run(%w(data_center all)).should == 0
59
66
  end
60
67
 
61
68
  it "should update a server" do
62
- savon.expects(:get_server).returns(:after_create)
63
- savon.expects(:update_server).returns(:basic)
69
+ savon.expects(:get_server).with(message: {server_id: '1234-123'}).returns(f :get_server, :after_create)
70
+ savon.expects(:update_server).with(message: {arg0: {server_id: 'b7a5f3d1-324a-4490-aa8e-56cdec436e3f', server_name: 'meme', ram: 256, cores: 1}}).returns(f :update_server, :basic)
64
71
  cli.run(%w(server update id=1234-123 name=meme ram=256 cores=1)).should == 0
65
72
  end
66
73
  end
@@ -1,11 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Profitbricks::DataCenter 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 datacenter" do
7
- savon.expects(:create_data_center).returns(:success)
8
- savon.expects(:get_data_center).returns(:create)
10
+ savon.expects(:create_data_center).with(message: {data_center_name: 'Test2'}).returns(f :create_data_center, :success)
11
+ savon.expects(:get_data_center).with(message: {data_center_id: "a897fbd7-9f24-4eed-bd56-cadae6117755"}).returns(f :get_data_center, :create)
9
12
  dc = DataCenter.create(:name => 'Test2')
10
13
  dc.name.should == 'Test2'
11
14
  dc.id.should == "b3eebede-5c78-417c-b1bc-ff5de01a0602"
@@ -13,20 +16,20 @@ describe Profitbricks::DataCenter do
13
16
  end
14
17
 
15
18
  it "should get a list of all datacenters" do
16
- savon.expects(:get_all_data_centers).returns(:test_datacenter)
17
- savon.expects(:get_data_center).returns(:two_servers_with_storage)
19
+ savon.expects(:get_all_data_centers).with(message: {}).returns(f :get_all_data_centers, :test_datacenter)
20
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
18
21
  Profitbricks::DataCenter.all().count.should == 1
19
22
  end
20
23
 
21
24
  it "should handle an empty list of datacenters correctly" do
22
- savon.expects(:get_all_data_centers).returns(:empty)
25
+ savon.expects(:get_all_data_centers).with(message: {}).returns(f :get_all_data_centers, :empty)
23
26
  Profitbricks::DataCenter.all().count.should == 0
24
27
  end
25
28
 
26
29
  it "should find a datacenter with a given name" do
27
- savon.expects(:get_all_data_centers).returns(:test_datacenter)
28
- savon.expects(:get_data_center).returns(:two_servers_with_storage)
29
- savon.expects(:get_data_center).returns(:two_servers_with_storage)
30
+ savon.expects(:get_all_data_centers).with(message: {}).returns(f :get_all_data_centers, :test_datacenter)
31
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
32
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
30
33
  dc = Profitbricks::DataCenter.find(:name => 'Test')
31
34
  dc.name.should == "Test"
32
35
  dc.id.should == "b3eebede-5c78-417c-b1bc-ff5de01a0602"
@@ -38,66 +41,88 @@ describe Profitbricks::DataCenter do
38
41
  end
39
42
 
40
43
  it "should reload a datacenter" do
41
- savon.expects(:get_all_data_centers).returns(:test_datacenter)
42
- savon.expects(:get_data_center).returns(:two_servers_with_storage)
43
- savon.expects(:get_data_center).returns(:two_servers_with_storage)
44
+ savon.expects(:get_all_data_centers).with(message: {}).returns(f :get_all_data_centers, :test_datacenter)
45
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
46
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
44
47
  dc = Profitbricks::DataCenter.find(:name => 'Test')
45
- savon.expects(:get_data_center).returns(:two_servers_with_storage)
48
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
46
49
  dc.reload.should == true
47
50
  end
48
51
 
49
52
  it "should update its provisioning_state" do
50
- savon.expects(:get_data_center).returns(:two_servers_with_storage)
51
- savon.expects(:get_data_center_state).returns(:success)
53
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
54
+ savon.expects(:get_data_center_state).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center_state, :success)
52
55
  dc = Profitbricks::DataCenter.find(:id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
53
56
  dc.update_state().should == 'AVAILABLE'
54
57
  dc.provisioning_state.should == 'AVAILABLE'
55
58
  end
56
59
 
57
60
  it "should return true on provisioned?" do
58
- savon.expects(:get_data_center).returns(:two_servers_with_storage)
61
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
59
62
  dc = Profitbricks::DataCenter.find(:id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
60
- savon.expects(:get_data_center_state).returns(:success)
61
- savon.expects(:get_data_center).returns(:two_servers_with_storage)
63
+ savon.expects(:get_data_center_state).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center_state, :success)
64
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
62
65
  dc.provisioned?.should == true
63
66
  end
64
67
 
65
68
  it "should wait for provisioning to finish" do
66
- savon.expects(:get_data_center).returns(:two_servers_with_storage)
69
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
67
70
  dc = Profitbricks::DataCenter.find(:id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
68
- savon.expects(:get_data_center_state).returns(:success)
69
- savon.expects(:get_data_center).returns(:two_servers_with_storage)
71
+ savon.expects(:get_data_center_state).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center_state, :success)
72
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
70
73
  dc.wait_for_provisioning
71
74
  end
72
75
 
76
+ let(:rename_message) { {arg0: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602', data_center_name: 'Test2'}} }
73
77
  it "should rename a datacenter" do
74
- savon.expects(:get_data_center).returns(:two_servers_with_storage)
75
- savon.expects(:update_data_center).returns(:success)
78
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
79
+ savon.expects(:update_data_center).with(message: rename_message).returns(f :update_data_center, :success)
76
80
  dc = Profitbricks::DataCenter.find(:id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
77
81
  dc.rename("Test2")
78
82
  dc.name.should == 'Test2'
79
83
  end
80
84
 
81
85
  it "should rename a datacenter via setter" do
82
- savon.expects(:get_data_center).returns(:two_servers_with_storage)
83
- savon.expects(:update_data_center).returns(:success)
86
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
87
+ savon.expects(:update_data_center).with(message: rename_message).returns(f :update_data_center, :success)
84
88
  dc = Profitbricks::DataCenter.find(:id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
85
89
  dc.name = "Test2"
86
90
  dc.name.should == 'Test2'
87
91
  end
88
92
 
89
93
  it "should clear the datacenter" do
90
- savon.expects(:get_data_center).returns(:two_servers_with_storage)
91
- savon.expects(:clear_data_center).returns(:success)
94
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
95
+ savon.expects(:clear_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :clear_data_center, :success)
92
96
  dc = Profitbricks::DataCenter.find(:id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
93
97
  dc.clear
94
98
  dc.servers.count.should == 0
95
99
  end
96
100
 
97
101
  it "should delete a datacenter" do
98
- savon.expects(:get_data_center).returns(:two_servers_with_storage)
99
- savon.expects(:delete_data_center).returns(:success)
102
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
103
+ savon.expects(:delete_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :delete_data_center, :success)
100
104
  dc = Profitbricks::DataCenter.find(:id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
101
105
  dc.delete.should == true
102
106
  end
107
+
108
+ it "should call Server.create correctly via the create_server helper" do
109
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
110
+ dc = Profitbricks::DataCenter.find(:id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
111
+ Server.should_receive(:create).with(:data_center_id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
112
+ dc.create_server({})
113
+ end
114
+
115
+ it "should call Storage.create correctly via the create_storage helper" do
116
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
117
+ dc = Profitbricks::DataCenter.find(:id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
118
+ Storage.should_receive(:create).with(:data_center_id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
119
+ dc.create_storage({})
120
+ end
121
+
122
+ it "should call LoadBalancer.create correctly via the create_load_balancer helper" do
123
+ savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
124
+ dc = Profitbricks::DataCenter.find(:id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
125
+ LoadBalancer.should_receive(:create).with(:data_center_id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
126
+ dc.create_load_balancer({})
127
+ end
103
128
  end