fog-profitbricks 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +24 -0
  3. data/.rubocop.yml +21 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +25 -0
  7. data/CONTRIBUTING.md +18 -0
  8. data/CONTRIBUTORS.md +2 -0
  9. data/Gemfile +4 -0
  10. data/LICENSE.md +20 -0
  11. data/README.md +29 -0
  12. data/Rakefile +21 -0
  13. data/examples/pb_demo.rb +53 -0
  14. data/fog-profitbricks.gemspec +31 -0
  15. data/gemfiles/Gemfile.1.8.7 +7 -0
  16. data/gemfiles/Gemfile.1.9.2+ +6 -0
  17. data/lib/fog/bin/profitbricks.rb +29 -0
  18. data/lib/fog/profitbricks.rb +13 -0
  19. data/lib/fog/profitbricks/compute.rb +215 -0
  20. data/lib/fog/profitbricks/core.rb +18 -0
  21. data/lib/fog/profitbricks/models/compute/datacenter.rb +59 -0
  22. data/lib/fog/profitbricks/models/compute/datacenters.rb +24 -0
  23. data/lib/fog/profitbricks/models/compute/flavor.rb +27 -0
  24. data/lib/fog/profitbricks/models/compute/flavors.rb +24 -0
  25. data/lib/fog/profitbricks/models/compute/image.rb +30 -0
  26. data/lib/fog/profitbricks/models/compute/images.rb +23 -0
  27. data/lib/fog/profitbricks/models/compute/interface.rb +64 -0
  28. data/lib/fog/profitbricks/models/compute/interfaces.rb +24 -0
  29. data/lib/fog/profitbricks/models/compute/region.rb +15 -0
  30. data/lib/fog/profitbricks/models/compute/regions.rb +24 -0
  31. data/lib/fog/profitbricks/models/compute/server.rb +107 -0
  32. data/lib/fog/profitbricks/models/compute/servers.rb +23 -0
  33. data/lib/fog/profitbricks/models/compute/volume.rb +74 -0
  34. data/lib/fog/profitbricks/models/compute/volumes.rb +24 -0
  35. data/lib/fog/profitbricks/parsers/base.rb +49 -0
  36. data/lib/fog/profitbricks/parsers/compute/clear_data_center.rb +22 -0
  37. data/lib/fog/profitbricks/parsers/compute/connect_storage_to_server.rb +22 -0
  38. data/lib/fog/profitbricks/parsers/compute/create_data_center.rb +22 -0
  39. data/lib/fog/profitbricks/parsers/compute/create_nic.rb +22 -0
  40. data/lib/fog/profitbricks/parsers/compute/create_server.rb +22 -0
  41. data/lib/fog/profitbricks/parsers/compute/create_storage.rb +22 -0
  42. data/lib/fog/profitbricks/parsers/compute/delete_data_center.rb +20 -0
  43. data/lib/fog/profitbricks/parsers/compute/delete_nic.rb +22 -0
  44. data/lib/fog/profitbricks/parsers/compute/delete_server.rb +22 -0
  45. data/lib/fog/profitbricks/parsers/compute/delete_storage.rb +22 -0
  46. data/lib/fog/profitbricks/parsers/compute/disconnect_storage_from_server.rb +22 -0
  47. data/lib/fog/profitbricks/parsers/compute/get_all_data_centers.rb +26 -0
  48. data/lib/fog/profitbricks/parsers/compute/get_all_images.rb +30 -0
  49. data/lib/fog/profitbricks/parsers/compute/get_all_nic.rb +30 -0
  50. data/lib/fog/profitbricks/parsers/compute/get_all_servers.rb +56 -0
  51. data/lib/fog/profitbricks/parsers/compute/get_all_storages.rb +33 -0
  52. data/lib/fog/profitbricks/parsers/compute/get_data_center.rb +23 -0
  53. data/lib/fog/profitbricks/parsers/compute/get_data_center_state.rb +20 -0
  54. data/lib/fog/profitbricks/parsers/compute/get_image.rb +26 -0
  55. data/lib/fog/profitbricks/parsers/compute/get_nic.rb +27 -0
  56. data/lib/fog/profitbricks/parsers/compute/get_server.rb +55 -0
  57. data/lib/fog/profitbricks/parsers/compute/get_storage.rb +30 -0
  58. data/lib/fog/profitbricks/parsers/compute/reset_server.rb +20 -0
  59. data/lib/fog/profitbricks/parsers/compute/set_internet_access.rb +22 -0
  60. data/lib/fog/profitbricks/parsers/compute/update_data_center.rb +22 -0
  61. data/lib/fog/profitbricks/parsers/compute/update_nic.rb +22 -0
  62. data/lib/fog/profitbricks/parsers/compute/update_server.rb +22 -0
  63. data/lib/fog/profitbricks/parsers/compute/update_storage.rb +22 -0
  64. data/lib/fog/profitbricks/requests/compute/clear_data_center.rb +53 -0
  65. data/lib/fog/profitbricks/requests/compute/connect_storage_to_server.rb +85 -0
  66. data/lib/fog/profitbricks/requests/compute/create_data_center.rb +64 -0
  67. data/lib/fog/profitbricks/requests/compute/create_flavor.rb +40 -0
  68. data/lib/fog/profitbricks/requests/compute/create_nic.rb +81 -0
  69. data/lib/fog/profitbricks/requests/compute/create_server.rb +107 -0
  70. data/lib/fog/profitbricks/requests/compute/create_storage.rb +98 -0
  71. data/lib/fog/profitbricks/requests/compute/delete_data_center.rb +62 -0
  72. data/lib/fog/profitbricks/requests/compute/delete_nic.rb +66 -0
  73. data/lib/fog/profitbricks/requests/compute/delete_server.rb +66 -0
  74. data/lib/fog/profitbricks/requests/compute/delete_storage.rb +66 -0
  75. data/lib/fog/profitbricks/requests/compute/disconnect_storage_from_server.rb +78 -0
  76. data/lib/fog/profitbricks/requests/compute/get_all_data_centers.rb +32 -0
  77. data/lib/fog/profitbricks/requests/compute/get_all_flavors.rb +77 -0
  78. data/lib/fog/profitbricks/requests/compute/get_all_images.rb +67 -0
  79. data/lib/fog/profitbricks/requests/compute/get_all_locations.rb +44 -0
  80. data/lib/fog/profitbricks/requests/compute/get_all_nic.rb +55 -0
  81. data/lib/fog/profitbricks/requests/compute/get_all_servers.rb +58 -0
  82. data/lib/fog/profitbricks/requests/compute/get_all_storages.rb +58 -0
  83. data/lib/fog/profitbricks/requests/compute/get_data_center.rb +40 -0
  84. data/lib/fog/profitbricks/requests/compute/get_data_center_state.rb +43 -0
  85. data/lib/fog/profitbricks/requests/compute/get_flavor.rb +82 -0
  86. data/lib/fog/profitbricks/requests/compute/get_image.rb +71 -0
  87. data/lib/fog/profitbricks/requests/compute/get_location.rb +48 -0
  88. data/lib/fog/profitbricks/requests/compute/get_nic.rb +65 -0
  89. data/lib/fog/profitbricks/requests/compute/get_server.rb +100 -0
  90. data/lib/fog/profitbricks/requests/compute/get_storage.rb +65 -0
  91. data/lib/fog/profitbricks/requests/compute/reset_server.rb +51 -0
  92. data/lib/fog/profitbricks/requests/compute/set_internet_access.rb +61 -0
  93. data/lib/fog/profitbricks/requests/compute/start_server.rb +59 -0
  94. data/lib/fog/profitbricks/requests/compute/stop_server.rb +59 -0
  95. data/lib/fog/profitbricks/requests/compute/update_data_center.rb +55 -0
  96. data/lib/fog/profitbricks/requests/compute/update_nic.rb +76 -0
  97. data/lib/fog/profitbricks/requests/compute/update_server.rb +81 -0
  98. data/lib/fog/profitbricks/requests/compute/update_storage.rb +75 -0
  99. data/lib/fog/profitbricks/version.rb +5 -0
  100. data/spec/minitest_helper.rb +33 -0
  101. data/tests/helper.rb +19 -0
  102. data/tests/helpers/formats_helper.rb +23 -0
  103. data/tests/helpers/mock_helper.rb +8 -0
  104. data/tests/profitbricks/requests/compute/flavor_tests.rb +43 -0
  105. data/tests/profitbricks/requests/compute/image_tests.rb +50 -0
  106. data/tests/profitbricks/requests/compute/interface_tests.rb +101 -0
  107. data/tests/profitbricks/requests/compute/location_tests.rb +33 -0
  108. data/tests/profitbricks/requests/compute/server_tests.rb +246 -0
  109. metadata +293 -0
@@ -0,0 +1,5 @@
1
+ module Fog
2
+ module ProfitBricks
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,33 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/autorun'
3
+ require 'turn'
4
+
5
+ Turn.config do |c|
6
+ # use one of output formats:
7
+ # :outline - turn's original case/test outline mode [default]
8
+ # :progress - indicates progress with progress bar
9
+ # :dotted - test/unit's traditional dot-progress mode
10
+ # :pretty - new pretty reporter
11
+ # :marshal - dump output as YAML (normal run mode only)
12
+ # :cue - interactive testing
13
+ # c.format = :outline
14
+ # turn on invoke/execute tracing, enable full backtrace
15
+ c.trace = 20
16
+ # use humanized test names (works only with :outline format)
17
+ c.natural = true
18
+ end
19
+
20
+ if ENV['COVERAGE']
21
+ require 'coveralls'
22
+ require 'simplecov'
23
+
24
+ SimpleCov.start do
25
+ add_filter '/spec/'
26
+ end
27
+ end
28
+
29
+ require File.join(File.dirname(__FILE__), '../lib/fog/profitbricks')
30
+
31
+ if ENV['COVERAGE']
32
+ Coveralls.wear!
33
+ end
@@ -0,0 +1,19 @@
1
+ ENV['FOG_RC'] = ENV['FOG_RC'] || File.expand_path('~/.fog', __FILE__)
2
+ ENV['FOG_CREDENTIAL'] = ENV['FOG_CREDENTIAL'] || 'default'
3
+
4
+ ## From fog-core
5
+ require 'fog/test_helpers/formats_helper'
6
+ require 'fog/test_helpers/succeeds_helper'
7
+
8
+ require 'fog/profitbricks'
9
+
10
+ Excon.defaults.merge!(:debug_request => true, :debug_response => true)
11
+
12
+ # This overrides the default 600 seconds timeout during live test runs
13
+ if Fog.mocking?
14
+ FOG_TESTING_TIMEOUT = ENV['FOG_TEST_TIMEOUT'] || 2000
15
+ Fog.timeout = 2000
16
+ Fog::Logger.warning "Setting default fog timeout to #{Fog.timeout} seconds"
17
+ else
18
+ FOG_TESTING_TIMEOUT = Fog.timeout
19
+ end
@@ -0,0 +1,23 @@
1
+ # format related hackery
2
+ # allows both true.is_a?(Fog::Boolean) and false.is_a?(Fog::Boolean)
3
+ # allows both nil.is_a?(Fog::Nullable::String) and ''.is_a?(Fog::Nullable::String)
4
+ module Fog
5
+ module Boolean; end
6
+ module Nullable
7
+ module Boolean; end
8
+ module Integer; end
9
+ module String; end
10
+ module Time; end
11
+ module Float; end
12
+ module Hash; end
13
+ module Array; end
14
+ end
15
+ end
16
+ [FalseClass, TrueClass].each {|klass| klass.send(:include, Fog::Boolean)}
17
+ [FalseClass, TrueClass, NilClass, Fog::Boolean].each {|klass| klass.send(:include, Fog::Nullable::Boolean)}
18
+ [NilClass, String].each {|klass| klass.send(:include, Fog::Nullable::String)}
19
+ [NilClass, Time].each {|klass| klass.send(:include, Fog::Nullable::Time)}
20
+ [Integer, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Integer)}
21
+ [Float, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Float)}
22
+ [Hash, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Hash)}
23
+ [Array, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Array)}
@@ -0,0 +1,8 @@
1
+ Fog.mock! if ENV["FOG_MOCK"] == "true"
2
+
3
+ if Fog.mock?
4
+ Fog.credentials = {
5
+ :profitbricks_username => "username",
6
+ :profitbricks_password => "abc123xyz"
7
+ }.merge(Fog.credentials)
8
+ end
@@ -0,0 +1,43 @@
1
+ Shindo.tests('Fog::Compute[:profitbricks] | flavor request', ['profitbricks', 'compute']) do
2
+
3
+ @flavor_format = {
4
+ 'flavorId' => String,
5
+ 'flavorName' => String,
6
+ 'ram' => Integer,
7
+ 'cores' => Integer
8
+ }
9
+
10
+ service = Fog::Compute[:profitbricks]
11
+
12
+ tests('success') do
13
+
14
+ # Not yet implemented
15
+ # tests('#create_flavor').formats(@flavor_format) do
16
+ # puts '#create_flavor'
17
+ # data = service.create_flavor('FogFlavorTest', 4096, 2)
18
+ # data.body['createFlavorResponse']
19
+ # end
20
+
21
+ tests('#get_all_flavors').formats(@flavor_format) do
22
+ # puts '#get_all_flavors'
23
+ data = service.get_all_flavors
24
+ @flavor_id = data.body['getAllFlavorsResponse'][0]['flavorId']
25
+ data.body['getAllFlavorsResponse'][0]
26
+ end
27
+
28
+ tests('#get_flavor').formats(@flavor_format) do
29
+ # puts '#get_flavor'
30
+ data = service.get_flavor(@flavor_id)
31
+ data.body['getFlavorResponse']
32
+ end
33
+
34
+ end
35
+
36
+ tests('failure') do
37
+ tests('#get_flavor').raises(Fog::Errors::NotFound) do
38
+ # puts '#get_flavor'
39
+ data = service.get_flavor('00000000-0000-0000-0000-000000000000')
40
+ data.body['getRegionResponse']
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,50 @@
1
+ Shindo.tests('Fog::Compute[:profitbricks] | image request', ['profitbricks', 'compute']) do
2
+
3
+ @image_format = {
4
+ 'imageId' => String,
5
+ 'imageName' => String,
6
+ 'imageType' => String,
7
+ 'imageSize' => Integer,
8
+ 'bootable' => String,
9
+ 'cpuHotPlug' => String,
10
+ 'cpuHotUnPlug' => String,
11
+ 'ramHotPlug' => String,
12
+ 'ramHotUnPlug' => String,
13
+ 'discVirtioHotPlug' => String,
14
+ 'discVirtioHotUnPlug' => String,
15
+ 'nicHotPlug' => String,
16
+ 'nicHotUnPlug' => String,
17
+ 'osType' => String,
18
+ 'serverIds' => Fog::Nullable::String,
19
+ 'writeable' => String,
20
+ 'location' => String,
21
+ 'public' => String,
22
+ }
23
+
24
+ service = Fog::Compute[:profitbricks]
25
+
26
+ Excon.defaults[:connection_timeout] = 120
27
+
28
+ tests('success') do
29
+ tests('#get_all_images').formats(@image_format) do
30
+ # puts '#get_all_images'
31
+ data = service.get_all_images
32
+ @image_id = data.body['getAllImagesResponse'][0]['imageId']
33
+ data.body['getAllImagesResponse'][0]
34
+ end
35
+
36
+ tests('#get_image').formats(@image_format) do
37
+ # puts '#get_image'
38
+ data = service.get_image(@image_id)
39
+ data.body['getImageResponse']
40
+ end
41
+
42
+ end
43
+
44
+ tests('failure') do
45
+ tests('#get_image').raises(Fog::Errors::NotFound) do
46
+ # puts '#get_image'
47
+ service.get_image('00000000-0000-0000-0000-000000000000')
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,101 @@
1
+ Shindo.tests('Fog::Compute[:profitbricks] | nic request', ['profitbricks', 'compute']) do
2
+
3
+ @nic_format = {
4
+ 'nicId' => String,
5
+ 'lanId' => Integer,
6
+ 'nicName' => 'FogNic',
7
+ 'internetAccess' => String,
8
+ 'ip' => Fog::Nullable::String,
9
+ 'macAddress' => String,
10
+ 'firewall' => Fog::Nullable::Hash,
11
+ 'dhcpActive' => String,
12
+ 'provisioningState' => 'AVAILABLE' || 'INPROCESS',
13
+ }
14
+
15
+ @minimal_format = {
16
+ 'requestId' => String,
17
+ 'dataCenterId' => String,
18
+ 'dataCenterVersion' => Integer
19
+ }
20
+
21
+ service = Fog::Compute[:profitbricks]
22
+
23
+ tests('success') do
24
+
25
+ Excon.defaults[:connection_timeout] = 200
26
+
27
+ tests('#create_data_center') do
28
+ # puts '#create_data_center'
29
+ data = service.create_data_center('FogDataCenter', 'us/las')
30
+ @data_center_id = data.body['createDataCenterResponse']['dataCenterId']
31
+ data.body['createDataCenterResponse']
32
+ end
33
+
34
+ tests('#get_all_images') do
35
+ # puts '#get_all_images'
36
+ data = service.get_all_images.body['getAllImagesResponse'].find { |image|
37
+ image['location'] == 'us/las' &&
38
+ image['imageType'] == 'HDD' &&
39
+ image['osType'] == 'LINUX'
40
+ }
41
+ @image_id = data['imageId']
42
+ end
43
+
44
+ tests('#create_server').succeeds do
45
+ # puts '#create_server'
46
+ data = service.create_server(@data_center_id, 1, 512, {
47
+ 'serverName' => 'FogServer' })
48
+ @server_id = data.body['createServerResponse']['serverId']
49
+ service.servers.get(@server_id).wait_for { ready? }
50
+ data.body['createServerResponse']
51
+ end
52
+
53
+ tests('#create_nic').formats(@minimal_format) do
54
+ # puts '#create_nic'
55
+ data = service.create_nic(@server_id, 1, { 'nicName' => 'FogNic' })
56
+ @nic_id = data.body['createNicResponse']['nicId']
57
+ service.interfaces.get(@nic_id).wait_for { ready? }
58
+ data.body['createNicResponse']
59
+ end
60
+
61
+ tests('#get_all_nic').formats(@nic_format) do
62
+ # puts '#get_all_nic'
63
+ data = service.get_all_nic
64
+ data.body['getAllNicResponse'].find { |nic| nic['nicId'] == @nic_id }
65
+ end
66
+
67
+ tests('#get_nic').formats(@nic_format) do
68
+ # puts '#get_nic'
69
+ service.get_nic(@nic_id).body['getNicResponse']
70
+ end
71
+
72
+ tests('#update_nic').formats(@minimal_format) do
73
+ # puts '#update_nic'
74
+ data = service.update_nic(@nic_id, { 'nicName' => 'FogNicRename' })
75
+ data.body['updateNicResponse']
76
+ end
77
+
78
+ tests('#set_internet_access').formats(@minimal_format) do
79
+ # puts '#set_internet_access'
80
+ data = service.set_internet_access(@data_center_id, @lan_id, true)
81
+ data.body['setInternetAccessResponse']
82
+ end
83
+
84
+ tests('#delete_nic').formats(@minimal_format) do
85
+ # puts '#delete_nic'
86
+ data = service.delete_nic(@nic_id)
87
+ data.body['deleteNicResponse']
88
+ end
89
+
90
+ tests('#delete_server').formats(@minimal_format) do
91
+ # puts '#delete_server'
92
+ data = service.delete_server(@server_id)
93
+ data.body['deleteServerResponse']
94
+ end
95
+
96
+ tests('#delete_data_center') do
97
+ # puts '#delete_data_center'
98
+ service.delete_data_center(@data_center_id)
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,33 @@
1
+ Shindo.tests('Fog::Compute[:profitbricks] | location request', ['profitbricks', 'compute']) do
2
+
3
+ @location_format = {
4
+ 'locationId' => String,
5
+ 'locationName' => String,
6
+ 'country' => String
7
+ }
8
+
9
+ service = Fog::Compute[:profitbricks]
10
+
11
+ tests('success') do
12
+ tests('#get_all_locations').formats(@location_format) do
13
+ # puts '#get_all_regions'
14
+ data = service.get_all_locations
15
+ @location_id = data.body['getAllLocationsResponse'][0]['locationId']
16
+ data.body['getAllLocationsResponse'][0]
17
+ end
18
+
19
+ tests('#get_location').formats(@location_format) do
20
+ # puts '#get_location'
21
+ data = service.get_location(@location_id)
22
+ data.body['getLocationResponse']
23
+ end
24
+
25
+ end
26
+
27
+ tests('failure') do
28
+ tests('#get_location').raises(Fog::Errors::NotFound) do
29
+ # puts '#get_location'
30
+ data = service.get_location('00000000-0000-0000-0000-000000000000')
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,246 @@
1
+ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'compute']) do
2
+
3
+ @data_center_format = {
4
+ 'requestId' => String,
5
+ 'dataCenterId' => String,
6
+ 'dataCenterName' => String,
7
+ 'dataCenterVersion' => Integer,
8
+ 'provisioningState' => 'AVAILABLE',
9
+ 'location' => String
10
+ }
11
+
12
+ @server_format = {
13
+ 'serverId' => String,
14
+ 'serverName' => 'FogServer',
15
+ 'cores' => Integer,
16
+ 'ram' => Integer,
17
+ 'internetAccess' => String,
18
+ 'connectedStorages' => Fog::Nullable::Array,
19
+ 'nics' => Fog::Nullable::Array,
20
+ 'provisioningState' => 'AVAILABLE',
21
+ 'virtualMachineState' => 'RUNNING',
22
+ 'creationTime' => Time,
23
+ 'lastModificationTime' => Time,
24
+ 'osType' => String,
25
+ 'availabilityZone' => 'AUTO' || 'ZONE_1' || 'ZONE_2',
26
+ }
27
+
28
+ @storage_format = {
29
+ 'dataCenterId' => String,
30
+ 'dataCenterVersion' => Integer,
31
+ 'storageId' => String,
32
+ 'size' => Integer,
33
+ 'storageName' => String,
34
+ 'mountImage' => Hash,
35
+ 'provisioningState' => 'AVAILABLE',
36
+ 'creationTime' => Time,
37
+ 'lastModificationTime' => Time
38
+ }
39
+
40
+ @minimal_format = {
41
+ 'requestId' => String,
42
+ 'dataCenterId' => String,
43
+ 'dataCenterVersion' => Integer
44
+ }
45
+
46
+ service = Fog::Compute[:profitbricks]
47
+
48
+ tests('success') do
49
+
50
+ Excon.defaults[:connection_timeout] = 500
51
+
52
+ tests('#create_data_center').formats(@minimal_format.merge('location' => String)) do
53
+ # puts '#create_data_center'
54
+ data = service.create_data_center('FogDataCenter', 'us/las')
55
+ @data_center_id = data.body['createDataCenterResponse']['dataCenterId']
56
+ service.datacenters.get(@data_center_id).wait_for { ready? }
57
+ data.body['createDataCenterResponse']
58
+ end
59
+
60
+ tests('#get_data_center').formats(@data_center_format) do
61
+ # puts '#get_data_center'
62
+ data = service.get_data_center(@data_center_id)
63
+ data.body['getDataCenterResponse']
64
+ end
65
+
66
+ tests('#get_all_data_centers').formats({
67
+ 'dataCenterId' => String,
68
+ 'dataCenterName' => String,
69
+ 'dataCenterVersion' => Integer
70
+ }) do
71
+ # puts '#get_all_data_centers'
72
+ data = service.get_all_data_centers
73
+ data.body['getAllDataCentersResponse'].find { |dc|
74
+ dc['dataCenterId'] == @data_center_id
75
+ }
76
+ end
77
+
78
+ tests('#update_data_center').formats(@minimal_format) do
79
+ # puts '#update_data_center'
80
+ data = service.update_data_center(
81
+ @data_center_id, { 'dataCenterName' => 'FogDataCenterRename' }
82
+ )
83
+ data.body['updateDataCenterResponse']
84
+ end
85
+
86
+ tests('#get_all_images') do
87
+ # puts '#get_all_images'
88
+ data = service.get_all_images.body['getAllImagesResponse'].find { |image|
89
+ image['location'] == 'us/las' &&
90
+ image['imageType'] == 'HDD' &&
91
+ image['osType'] == 'LINUX'
92
+ }
93
+ @image_id = data['imageId']
94
+ end
95
+
96
+ tests('#create_storage') do
97
+ # puts '#create_storage'
98
+ data = service.create_storage(
99
+ @data_center_id, 5, {
100
+ 'storageName' => 'FogVolume',
101
+ 'mountImageId' => @image_id
102
+ }
103
+ )
104
+ @storage_id = data.body['createStorageResponse']['storageId']
105
+ service.volumes.get(@storage_id).wait_for { ready? }
106
+ data.body['createStorageResponse']
107
+ end
108
+
109
+ tests('#get_storage').formats(@storage_format) do
110
+ # puts '#get_storage'
111
+ data = service.get_storage(@storage_id).body['getStorageResponse']
112
+ end
113
+
114
+ tests('#get_all_storages').formats(@storage_format) do
115
+ # puts '#get_all_storages'
116
+ data = service.get_all_storages
117
+ data.body['getAllStoragesResponse'].find {
118
+ |storage| storage['storageId'] == @storage_id
119
+ }
120
+ end
121
+
122
+ tests('#update_storage').formats(@minimal_format) do
123
+ # puts '#update_storage'
124
+ service.update_storage(@storage_id, { 'size' => 6 }).body['updateStorageResponse']
125
+ end
126
+
127
+ tests('#create_server').formats(@minimal_format.merge('serverId' => String)) do
128
+ # puts '#create_server'
129
+ data = service.create_server(@data_center_id, 1, 512, {
130
+ 'serverName' => 'FogServer',
131
+ 'bootFromStorageId' => @storage_id
132
+ })
133
+ @server_id = data.body['createServerResponse']['serverId']
134
+ service.servers.get(@server_id).wait_for { ready? }
135
+ data.body['createServerResponse']
136
+ end
137
+
138
+ tests('#get_all_servers').formats(@server_format.merge(
139
+ 'dataCenterId' => String, 'dataCenterVersion' => Integer
140
+ )) do
141
+ # puts '#get_all_servers'
142
+ data = service.get_all_servers
143
+ data.body['getAllServersResponse'].find {
144
+ |server| server['serverId'] == @server_id
145
+ }
146
+ end
147
+
148
+ tests('#get_server').formats(@server_format.merge(@minimal_format)) do
149
+ # puts '#get_server'
150
+ data = service.get_server(@server_id)
151
+ data.body['getServerResponse']
152
+ end
153
+
154
+ tests('#update_server').formats(@minimal_format) do
155
+ # puts '#update_server'
156
+ data = service.update_server(@server_id, { 'serverName' => 'FogServerRename' })
157
+ service.servers.get(@server_id).wait_for { ready? }
158
+ data.body['updateServerResponse']
159
+ end
160
+
161
+ tests('#connect_storage_to_server').formats(@minimal_format) do
162
+ # puts '#connect_storage_to_server'
163
+ service.connect_storage_to_server(@storage_id, @server_id).body['connectStorageToServerResponse']
164
+ end
165
+
166
+ tests('#stop_server').succeeds do
167
+ # puts '#stop_server'
168
+ service.stop_server(@server_id)
169
+ end
170
+
171
+ tests('#start_server').succeeds do
172
+ # puts '#start_server'
173
+ service.start_server(@server_id)
174
+ end
175
+
176
+ tests('#reset_server').succeeds do
177
+ # puts '#reset_server'
178
+ service.reset_server(@server_id)
179
+ end
180
+
181
+ tests('#disconnect_storage_from_server').formats(@minimal_format) do
182
+ # puts '#disconnect_storage_from_server'
183
+ service.disconnect_storage_from_server(@storage_id, @server_id).body['disconnectStorageFromServerResponse']
184
+ end
185
+
186
+ tests('#delete_storage').formats(@minimal_format) do
187
+ # puts '#delete_storage'
188
+ data = service.delete_storage(@storage_id)
189
+ data.body['deleteStorageResponse']
190
+ end
191
+
192
+ tests('#delete_server').formats(@minimal_format) do
193
+ # puts '#delete_server'
194
+ data = service.delete_server(@server_id)
195
+ data.body['deleteServerResponse']
196
+ end
197
+
198
+ tests('#clear_data_center').formats(@minimal_format) do
199
+ data = service.clear_data_center(@data_center_id)
200
+ data.body['clearDataCenterResponse']
201
+ end
202
+
203
+ tests('#delete_data_center').formats({'requestId' => String}) do
204
+ # puts '#delete_data_center'
205
+ service.delete_data_center(@data_center_id).body['deleteDataCenterResponse']
206
+ end
207
+ end
208
+
209
+ tests('failure') do
210
+
211
+ tests('#get_data_center').raises(Fog::Errors::NotFound) do
212
+ # puts '#get_data_center'
213
+ service.get_data_center('00000000-0000-0000-0000-000000000000')
214
+ end
215
+
216
+ tests('#update_data_center').raises(Fog::Errors::NotFound) do
217
+ # puts '#update_data_center'
218
+ service.update_data_center('00000000-0000-0000-0000-000000000000',
219
+ { 'dataCenterName' => 'FogTestDCRename' })
220
+ end
221
+
222
+ tests('#delete_data_center').raises(Fog::Errors::NotFound) do
223
+ # puts '#delete_data_center'
224
+ service.delete_data_center('00000000-0000-0000-0000-000000000000')
225
+ end
226
+ tests('#create_storage').raises(ArgumentError) do
227
+ # puts '#create_storage'
228
+ service.create_storage
229
+ end
230
+
231
+ tests('#get_storage').raises(Fog::Errors::NotFound) do
232
+ # puts '#get_storage'
233
+ service.get_storage('00000000-0000-0000-0000-000000000000')
234
+ end
235
+
236
+ tests('#update_storage').raises(Fog::Errors::NotFound) do
237
+ # puts '#update_storage'
238
+ service.update_storage('00000000-0000-0000-0000-000000000000')
239
+ end
240
+
241
+ tests('#delete_storage').raises(Fog::Errors::NotFound) do
242
+ # puts '#delete_storage'
243
+ service.delete_storage('00000000-0000-0000-0000-000000000000')
244
+ end
245
+ end
246
+ end