fog-profitbricks 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/.rubocop.yml +21 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +25 -0
- data/CONTRIBUTING.md +18 -0
- data/CONTRIBUTORS.md +2 -0
- data/Gemfile +4 -0
- data/LICENSE.md +20 -0
- data/README.md +29 -0
- data/Rakefile +21 -0
- data/examples/pb_demo.rb +53 -0
- data/fog-profitbricks.gemspec +31 -0
- data/gemfiles/Gemfile.1.8.7 +7 -0
- data/gemfiles/Gemfile.1.9.2+ +6 -0
- data/lib/fog/bin/profitbricks.rb +29 -0
- data/lib/fog/profitbricks.rb +13 -0
- data/lib/fog/profitbricks/compute.rb +215 -0
- data/lib/fog/profitbricks/core.rb +18 -0
- data/lib/fog/profitbricks/models/compute/datacenter.rb +59 -0
- data/lib/fog/profitbricks/models/compute/datacenters.rb +24 -0
- data/lib/fog/profitbricks/models/compute/flavor.rb +27 -0
- data/lib/fog/profitbricks/models/compute/flavors.rb +24 -0
- data/lib/fog/profitbricks/models/compute/image.rb +30 -0
- data/lib/fog/profitbricks/models/compute/images.rb +23 -0
- data/lib/fog/profitbricks/models/compute/interface.rb +64 -0
- data/lib/fog/profitbricks/models/compute/interfaces.rb +24 -0
- data/lib/fog/profitbricks/models/compute/region.rb +15 -0
- data/lib/fog/profitbricks/models/compute/regions.rb +24 -0
- data/lib/fog/profitbricks/models/compute/server.rb +107 -0
- data/lib/fog/profitbricks/models/compute/servers.rb +23 -0
- data/lib/fog/profitbricks/models/compute/volume.rb +74 -0
- data/lib/fog/profitbricks/models/compute/volumes.rb +24 -0
- data/lib/fog/profitbricks/parsers/base.rb +49 -0
- data/lib/fog/profitbricks/parsers/compute/clear_data_center.rb +22 -0
- data/lib/fog/profitbricks/parsers/compute/connect_storage_to_server.rb +22 -0
- data/lib/fog/profitbricks/parsers/compute/create_data_center.rb +22 -0
- data/lib/fog/profitbricks/parsers/compute/create_nic.rb +22 -0
- data/lib/fog/profitbricks/parsers/compute/create_server.rb +22 -0
- data/lib/fog/profitbricks/parsers/compute/create_storage.rb +22 -0
- data/lib/fog/profitbricks/parsers/compute/delete_data_center.rb +20 -0
- data/lib/fog/profitbricks/parsers/compute/delete_nic.rb +22 -0
- data/lib/fog/profitbricks/parsers/compute/delete_server.rb +22 -0
- data/lib/fog/profitbricks/parsers/compute/delete_storage.rb +22 -0
- data/lib/fog/profitbricks/parsers/compute/disconnect_storage_from_server.rb +22 -0
- data/lib/fog/profitbricks/parsers/compute/get_all_data_centers.rb +26 -0
- data/lib/fog/profitbricks/parsers/compute/get_all_images.rb +30 -0
- data/lib/fog/profitbricks/parsers/compute/get_all_nic.rb +30 -0
- data/lib/fog/profitbricks/parsers/compute/get_all_servers.rb +56 -0
- data/lib/fog/profitbricks/parsers/compute/get_all_storages.rb +33 -0
- data/lib/fog/profitbricks/parsers/compute/get_data_center.rb +23 -0
- data/lib/fog/profitbricks/parsers/compute/get_data_center_state.rb +20 -0
- data/lib/fog/profitbricks/parsers/compute/get_image.rb +26 -0
- data/lib/fog/profitbricks/parsers/compute/get_nic.rb +27 -0
- data/lib/fog/profitbricks/parsers/compute/get_server.rb +55 -0
- data/lib/fog/profitbricks/parsers/compute/get_storage.rb +30 -0
- data/lib/fog/profitbricks/parsers/compute/reset_server.rb +20 -0
- data/lib/fog/profitbricks/parsers/compute/set_internet_access.rb +22 -0
- data/lib/fog/profitbricks/parsers/compute/update_data_center.rb +22 -0
- data/lib/fog/profitbricks/parsers/compute/update_nic.rb +22 -0
- data/lib/fog/profitbricks/parsers/compute/update_server.rb +22 -0
- data/lib/fog/profitbricks/parsers/compute/update_storage.rb +22 -0
- data/lib/fog/profitbricks/requests/compute/clear_data_center.rb +53 -0
- data/lib/fog/profitbricks/requests/compute/connect_storage_to_server.rb +85 -0
- data/lib/fog/profitbricks/requests/compute/create_data_center.rb +64 -0
- data/lib/fog/profitbricks/requests/compute/create_flavor.rb +40 -0
- data/lib/fog/profitbricks/requests/compute/create_nic.rb +81 -0
- data/lib/fog/profitbricks/requests/compute/create_server.rb +107 -0
- data/lib/fog/profitbricks/requests/compute/create_storage.rb +98 -0
- data/lib/fog/profitbricks/requests/compute/delete_data_center.rb +62 -0
- data/lib/fog/profitbricks/requests/compute/delete_nic.rb +66 -0
- data/lib/fog/profitbricks/requests/compute/delete_server.rb +66 -0
- data/lib/fog/profitbricks/requests/compute/delete_storage.rb +66 -0
- data/lib/fog/profitbricks/requests/compute/disconnect_storage_from_server.rb +78 -0
- data/lib/fog/profitbricks/requests/compute/get_all_data_centers.rb +32 -0
- data/lib/fog/profitbricks/requests/compute/get_all_flavors.rb +77 -0
- data/lib/fog/profitbricks/requests/compute/get_all_images.rb +67 -0
- data/lib/fog/profitbricks/requests/compute/get_all_locations.rb +44 -0
- data/lib/fog/profitbricks/requests/compute/get_all_nic.rb +55 -0
- data/lib/fog/profitbricks/requests/compute/get_all_servers.rb +58 -0
- data/lib/fog/profitbricks/requests/compute/get_all_storages.rb +58 -0
- data/lib/fog/profitbricks/requests/compute/get_data_center.rb +40 -0
- data/lib/fog/profitbricks/requests/compute/get_data_center_state.rb +43 -0
- data/lib/fog/profitbricks/requests/compute/get_flavor.rb +82 -0
- data/lib/fog/profitbricks/requests/compute/get_image.rb +71 -0
- data/lib/fog/profitbricks/requests/compute/get_location.rb +48 -0
- data/lib/fog/profitbricks/requests/compute/get_nic.rb +65 -0
- data/lib/fog/profitbricks/requests/compute/get_server.rb +100 -0
- data/lib/fog/profitbricks/requests/compute/get_storage.rb +65 -0
- data/lib/fog/profitbricks/requests/compute/reset_server.rb +51 -0
- data/lib/fog/profitbricks/requests/compute/set_internet_access.rb +61 -0
- data/lib/fog/profitbricks/requests/compute/start_server.rb +59 -0
- data/lib/fog/profitbricks/requests/compute/stop_server.rb +59 -0
- data/lib/fog/profitbricks/requests/compute/update_data_center.rb +55 -0
- data/lib/fog/profitbricks/requests/compute/update_nic.rb +76 -0
- data/lib/fog/profitbricks/requests/compute/update_server.rb +81 -0
- data/lib/fog/profitbricks/requests/compute/update_storage.rb +75 -0
- data/lib/fog/profitbricks/version.rb +5 -0
- data/spec/minitest_helper.rb +33 -0
- data/tests/helper.rb +19 -0
- data/tests/helpers/formats_helper.rb +23 -0
- data/tests/helpers/mock_helper.rb +8 -0
- data/tests/profitbricks/requests/compute/flavor_tests.rb +43 -0
- data/tests/profitbricks/requests/compute/image_tests.rb +50 -0
- data/tests/profitbricks/requests/compute/interface_tests.rb +101 -0
- data/tests/profitbricks/requests/compute/location_tests.rb +33 -0
- data/tests/profitbricks/requests/compute/server_tests.rb +246 -0
- metadata +293 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class ProfitBricks
|
|
4
|
+
class Real
|
|
5
|
+
require 'fog/profitbricks/parsers/compute/create_storage'
|
|
6
|
+
|
|
7
|
+
# Create new virtual storage
|
|
8
|
+
#
|
|
9
|
+
# ==== Parameters
|
|
10
|
+
# * dataCenterId<~String> - Required, UUID of virtual data center
|
|
11
|
+
# * size<~Integer> - Required, size of virtual storage
|
|
12
|
+
# * options<~Hash>:
|
|
13
|
+
# * storageName<~String> - Optional, name of the new virtual storage
|
|
14
|
+
# * mountImageId<~String> - Optional, UUID of image
|
|
15
|
+
# * profitBricksImagePassword<~String> - Optional,
|
|
16
|
+
#
|
|
17
|
+
# ==== Returns
|
|
18
|
+
# * response<~Excon::Response>:
|
|
19
|
+
# * body<~Hash>:
|
|
20
|
+
# * createStorageResponse<~Hash>:
|
|
21
|
+
# * requestId<~String> - ID of request
|
|
22
|
+
# * dataCenterId<~String> - UUID of virtual data center
|
|
23
|
+
# * dataCenterVersion<~Integer> - Version of the virtual data center
|
|
24
|
+
# * storageId<~String> - UUID of the new virtual storage
|
|
25
|
+
#
|
|
26
|
+
# {ProfitBricks API Documentation}[http://www.profitbricks.com/apidoc/CreateStorage.html]
|
|
27
|
+
def create_storage(data_center_id, size, options={})
|
|
28
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope {
|
|
29
|
+
|xml| xml[:ws].createStorage {
|
|
30
|
+
xml.request {
|
|
31
|
+
xml.dataCenterId(data_center_id)
|
|
32
|
+
xml.size(size)
|
|
33
|
+
options.each { |key, value| xml.send(key, value) }
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
request(
|
|
39
|
+
:expects => [200],
|
|
40
|
+
:method => 'POST',
|
|
41
|
+
:body => soap_envelope.to_xml,
|
|
42
|
+
:parser =>
|
|
43
|
+
Fog::Parsers::Compute::ProfitBricks::CreateStorage.new
|
|
44
|
+
)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
class Mock
|
|
49
|
+
def create_storage(data_center_id, size, options={})
|
|
50
|
+
response = Excon::Response.new
|
|
51
|
+
response.status = 200
|
|
52
|
+
|
|
53
|
+
if data_center = self.data[:datacenters].find {
|
|
54
|
+
|attrib| attrib['dataCenterId'] == data_center_id
|
|
55
|
+
}
|
|
56
|
+
data_center['dataCenterVersion'] += 1
|
|
57
|
+
else
|
|
58
|
+
raise Fog::Errors::NotFound.new('Data center resource could not be found')
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
if image = self.data[:images].find {
|
|
62
|
+
|attrib| attrib['imageId'] == options['mountImageId']
|
|
63
|
+
}
|
|
64
|
+
mount_image = {
|
|
65
|
+
'imageId' => options['mountImageId'],
|
|
66
|
+
'imageName' => image['imageName']
|
|
67
|
+
}
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
storage_id = Fog::UUID.uuid
|
|
71
|
+
storage = {
|
|
72
|
+
'dataCenterId' => data_center_id,
|
|
73
|
+
'dataCenterVersion' => data_center['dataCenterVersion'],
|
|
74
|
+
'storageId' => storage_id,
|
|
75
|
+
'size' => size,
|
|
76
|
+
'storageName' => options['storageName'] || '',
|
|
77
|
+
'mountImage' => mount_image || {},
|
|
78
|
+
'provisioningState' => 'AVAILABLE',
|
|
79
|
+
'creationTime' => Time.now,
|
|
80
|
+
'lastModificationTime' => Time.now,
|
|
81
|
+
'profitBricksImagePassword' => options['profitBricksImagePassword'] || ''
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
self.data[:volumes] << storage
|
|
85
|
+
response.body = {
|
|
86
|
+
'createStorageResponse' => {
|
|
87
|
+
'requestId' => Fog::Mock::random_numbers(7),
|
|
88
|
+
'dataCenterId' => Fog::UUID.uuid,
|
|
89
|
+
'dataCenterVersion' => 1,
|
|
90
|
+
'storageId' => storage_id
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
response
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class ProfitBricks
|
|
4
|
+
class Real
|
|
5
|
+
require 'fog/profitbricks/parsers/compute/delete_data_center'
|
|
6
|
+
|
|
7
|
+
# Delete virtual data center
|
|
8
|
+
#
|
|
9
|
+
# ==== Parameters
|
|
10
|
+
# * dataCenterId<~String> - UUID of the virtual data center
|
|
11
|
+
#
|
|
12
|
+
# ==== Returns
|
|
13
|
+
# * response<~Excon::Response>:
|
|
14
|
+
# * body<~Hash>:
|
|
15
|
+
# * deleteDataCenterResponse<~Hash>:
|
|
16
|
+
# * requestId<~String> - ID of request
|
|
17
|
+
# * dataCenterId<~String> - UUID of virtual data center
|
|
18
|
+
# * dataCenterVersion<~Integer> - Version of the virtual data center
|
|
19
|
+
#
|
|
20
|
+
# {ProfitBricks API Documentation}[http://www.profitbricks.com/apidoc/DeleteDataCenter.html]
|
|
21
|
+
def delete_data_center(data_center_id)
|
|
22
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope {
|
|
23
|
+
|xml| xml[:ws].deleteDataCenter {
|
|
24
|
+
xml.dataCenterId(data_center_id)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
request(
|
|
29
|
+
:expects => [200],
|
|
30
|
+
:method => 'POST',
|
|
31
|
+
:body => soap_envelope.to_xml,
|
|
32
|
+
:parser =>
|
|
33
|
+
Fog::Parsers::Compute::ProfitBricks::DeleteDataCenter.new
|
|
34
|
+
)
|
|
35
|
+
rescue Excon::Errors::InternalServerError => error
|
|
36
|
+
Fog::Errors::NotFound.new(error)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
class Mock
|
|
41
|
+
def delete_data_center(data_center_id)
|
|
42
|
+
response = Excon::Response.new
|
|
43
|
+
response.status = 200
|
|
44
|
+
|
|
45
|
+
if data_center = self.data[:datacenters].find {
|
|
46
|
+
|attrib| attrib['dataCenterId'] == data_center_id
|
|
47
|
+
}
|
|
48
|
+
self.data[:datacenters].delete(data_center)
|
|
49
|
+
else
|
|
50
|
+
raise Fog::Errors::NotFound.new('The requested resource could not be found')
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
response.body = { 'deleteDataCenterResponse' => {
|
|
54
|
+
'requestId' => data_center['requestId']
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
response
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class ProfitBricks
|
|
4
|
+
class Real
|
|
5
|
+
require 'fog/profitbricks/parsers/compute/delete_nic'
|
|
6
|
+
|
|
7
|
+
# Delete virtual network interface
|
|
8
|
+
#
|
|
9
|
+
# ==== Parameters
|
|
10
|
+
# * nicId<~String> - UUID of the virtual network interface
|
|
11
|
+
#
|
|
12
|
+
# ==== Returns
|
|
13
|
+
# * response<~Excon::Response>:
|
|
14
|
+
# * body<~Hash>:
|
|
15
|
+
# * deleteNicResponse<~Hash>:
|
|
16
|
+
# * requestId<~String> - ID of request
|
|
17
|
+
# * dataCenterId<~String> - UUID of virtual data center
|
|
18
|
+
# * dataCenterVersion<~Integer> - Version of the virtual data center
|
|
19
|
+
#
|
|
20
|
+
# {ProfitBricks API Documentation}[http://www.profitbricks.com/apidoc/DeleteNic.html]
|
|
21
|
+
def delete_nic(nic_id)
|
|
22
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope {
|
|
23
|
+
|xml| xml[:ws].deleteNic {
|
|
24
|
+
xml.nicId(nic_id)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
request(
|
|
29
|
+
:expects => [200],
|
|
30
|
+
:method => 'POST',
|
|
31
|
+
:body => soap_envelope.to_xml,
|
|
32
|
+
:parser =>
|
|
33
|
+
Fog::Parsers::Compute::ProfitBricks::DeleteNic.new
|
|
34
|
+
)
|
|
35
|
+
rescue Excon::Errors::InternalServerError => error
|
|
36
|
+
Fog::Errors::NotFound.new(error)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
class Mock
|
|
41
|
+
def delete_nic(nic_id)
|
|
42
|
+
response = Excon::Response.new
|
|
43
|
+
response.status = 200
|
|
44
|
+
|
|
45
|
+
if nic = self.data[:interfaces].find {
|
|
46
|
+
|attrib| attrib['nicId'] == nic_id
|
|
47
|
+
}
|
|
48
|
+
self.data[:interfaces].delete(nic)
|
|
49
|
+
else
|
|
50
|
+
raise Fog::Errors::NotFound.new(
|
|
51
|
+
'The requested NIC could not be found'
|
|
52
|
+
)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
response.body = { 'deleteNicResponse' => {
|
|
56
|
+
'requestId' => Fog::Mock::random_numbers(7),
|
|
57
|
+
'dataCenterId' => Fog::UUID.uuid,
|
|
58
|
+
'dataCenterVersion' => 1,
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
response
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class ProfitBricks
|
|
4
|
+
class Real
|
|
5
|
+
require 'fog/profitbricks/parsers/compute/delete_server'
|
|
6
|
+
|
|
7
|
+
# Delete virtual server
|
|
8
|
+
#
|
|
9
|
+
# ==== Parameters
|
|
10
|
+
# * serverId<~String> - UUID of the virtual server
|
|
11
|
+
#
|
|
12
|
+
# ==== Returns
|
|
13
|
+
# * response<~Excon::Response>:
|
|
14
|
+
# * body<~Hash>:
|
|
15
|
+
# * deleteServerResponse<~Hash>:
|
|
16
|
+
# * requestId<~String> - ID of request
|
|
17
|
+
# * dataCenterId<~String> - UUID of virtual data center
|
|
18
|
+
# * dataCenterVersion<~Integer> - Version of the virtual data center
|
|
19
|
+
#
|
|
20
|
+
# {ProfitBricks API Documentation}[http://www.profitbricks.com/apidoc/DeleteServer.html]
|
|
21
|
+
def delete_server(server_id)
|
|
22
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope {
|
|
23
|
+
|xml| xml[:ws].deleteServer {
|
|
24
|
+
xml.serverId(server_id)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
request(
|
|
29
|
+
:expects => [200],
|
|
30
|
+
:method => 'POST',
|
|
31
|
+
:body => soap_envelope.to_xml,
|
|
32
|
+
:parser =>
|
|
33
|
+
Fog::Parsers::Compute::ProfitBricks::DeleteServer.new
|
|
34
|
+
)
|
|
35
|
+
rescue Excon::Errors::InternalServerError => error
|
|
36
|
+
Fog::Errors::NotFound.new(error)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
class Mock
|
|
41
|
+
def delete_server(server_id)
|
|
42
|
+
|
|
43
|
+
if server = self.data[:servers].find {
|
|
44
|
+
|attrib| attrib['serverId'] == server_id
|
|
45
|
+
}
|
|
46
|
+
self.data[:servers].delete(server)
|
|
47
|
+
else
|
|
48
|
+
raise Fog::Errors::NotFound.new(
|
|
49
|
+
'The requested server resource could not be found'
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
response = Excon::Response.new
|
|
54
|
+
response.status = 200
|
|
55
|
+
response.body = { 'deleteServerResponse' => {
|
|
56
|
+
'requestId' => Fog::Mock::random_numbers(7),
|
|
57
|
+
'dataCenterId' => Fog::UUID.uuid,
|
|
58
|
+
'dataCenterVersion' => 1,
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
response
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class ProfitBricks
|
|
4
|
+
class Real
|
|
5
|
+
require 'fog/profitbricks/parsers/compute/delete_storage'
|
|
6
|
+
|
|
7
|
+
# Delete a virtual storage
|
|
8
|
+
#
|
|
9
|
+
# ==== Parameters
|
|
10
|
+
# * storageId<~String> -
|
|
11
|
+
#
|
|
12
|
+
# ==== Returns
|
|
13
|
+
# * response<~Excon::Response>:
|
|
14
|
+
# * body<~Hash>:
|
|
15
|
+
# * deleteStorageResponse<~Hash>:
|
|
16
|
+
# * requestId<~String> - ID of request
|
|
17
|
+
# * dataCenterId<~String> - UUID of virtual data center
|
|
18
|
+
# * dataCenterVersion<~Integer> - Version of the virtual data center
|
|
19
|
+
#
|
|
20
|
+
# {ProfitBricks API Documentation}[http://www.profitbricks.com/apidoc/DeleteStorage.html]
|
|
21
|
+
def delete_storage(storage_id)
|
|
22
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope {
|
|
23
|
+
|xml| xml[:ws].deleteStorage {
|
|
24
|
+
xml.storageId(storage_id)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
request(
|
|
29
|
+
:expects => [200],
|
|
30
|
+
:method => 'POST',
|
|
31
|
+
:body => soap_envelope.to_xml,
|
|
32
|
+
:parser =>
|
|
33
|
+
Fog::Parsers::Compute::ProfitBricks::DeleteStorage.new
|
|
34
|
+
)
|
|
35
|
+
rescue Excon::Errors::InternalServerError => error
|
|
36
|
+
Fog::Errors::NotFound.new(error)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
class Mock
|
|
41
|
+
def delete_storage(storage_id)
|
|
42
|
+
response = Excon::Response.new
|
|
43
|
+
response.status = 200
|
|
44
|
+
|
|
45
|
+
if storage = self.data[:volumes].find {
|
|
46
|
+
|attrib| attrib['storageId'] == storage_id
|
|
47
|
+
}
|
|
48
|
+
self.data[:volumes].delete(storage)
|
|
49
|
+
else
|
|
50
|
+
raise Fog::Errors::NotFound.new(
|
|
51
|
+
'The requested resource could not be found'
|
|
52
|
+
)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
response.body = { 'deleteStorageResponse' => {
|
|
56
|
+
'requestId' => Fog::Mock::random_numbers(7),
|
|
57
|
+
'dataCenterId' => Fog::UUID.uuid,
|
|
58
|
+
'dataCenterVersion' => 3
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
response
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class ProfitBricks
|
|
4
|
+
class Real
|
|
5
|
+
require 'fog/profitbricks/parsers/compute/disconnect_storage_from_server'
|
|
6
|
+
|
|
7
|
+
# Disconnect virtual storage
|
|
8
|
+
#
|
|
9
|
+
# ==== Parameters
|
|
10
|
+
# * serverId<~String> - UUID of virtual server
|
|
11
|
+
# * storageId<~String> - UUID of virtual storage
|
|
12
|
+
#
|
|
13
|
+
# ==== Returns
|
|
14
|
+
# * response<~Excon::Response>:
|
|
15
|
+
# * body<~Hash>:
|
|
16
|
+
# * disconnectStorageToServerResponse<~Hash>:
|
|
17
|
+
# * requestId<~String> - ID of request
|
|
18
|
+
# * dataCenterId<~String> - UUID of virtual data center
|
|
19
|
+
# * dataCenterVersion<~Integer> - Version of the virtual data center
|
|
20
|
+
#
|
|
21
|
+
# {ProfitBricks API Documentation}[http://www.profitbricks.com/apidoc/DisconnectStorage.html]
|
|
22
|
+
def disconnect_storage_from_server(storage_id, server_id)
|
|
23
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope {
|
|
24
|
+
|xml| xml[:ws].disconnectStorageFromServer {
|
|
25
|
+
xml.serverId(server_id)
|
|
26
|
+
xml.storageId(storage_id)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
request(
|
|
31
|
+
:expects => [200],
|
|
32
|
+
:method => 'POST',
|
|
33
|
+
:body => soap_envelope.to_xml,
|
|
34
|
+
:parser =>
|
|
35
|
+
Fog::Parsers::Compute::ProfitBricks::DisconnectStorageFromServer.new
|
|
36
|
+
)
|
|
37
|
+
rescue Excon::Errors::InternalServerError => error
|
|
38
|
+
Fog::Errors::NotFound.new(error)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
class Mock
|
|
43
|
+
def disconnect_storage_from_server(storage_id, server_id)
|
|
44
|
+
|
|
45
|
+
if storage = self.data[:volumes].find {
|
|
46
|
+
|attrib| attrib['storageId'] == storage_id
|
|
47
|
+
}
|
|
48
|
+
else
|
|
49
|
+
raise Fog::Errors::NotFound.new(
|
|
50
|
+
'The requested storage resource could not be found'
|
|
51
|
+
)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
if server = self.data[:servers].find {
|
|
55
|
+
|attrib| attrib['serverId'] == server_id
|
|
56
|
+
}['connectedStorages'].delete(storage)
|
|
57
|
+
else
|
|
58
|
+
raise Fog::Errors::NotFound.new(
|
|
59
|
+
'The requested server resource could not be found'
|
|
60
|
+
)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
response = Excon::Response.new
|
|
64
|
+
response.status = 200
|
|
65
|
+
response.body =
|
|
66
|
+
{ 'disconnectStorageFromServerResponse' =>
|
|
67
|
+
{
|
|
68
|
+
'requestId' => Fog::Mock::random_numbers(7),
|
|
69
|
+
'dataCenterId' => Fog::UUID.uuid,
|
|
70
|
+
'dataCenterVersion' => 1
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
response
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class ProfitBricks
|
|
4
|
+
class Real
|
|
5
|
+
require "fog/profitbricks/parsers/compute/get_all_data_centers"
|
|
6
|
+
def get_all_data_centers
|
|
7
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope do |xml|
|
|
8
|
+
xml[:ws].getAllDataCenters
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
request(
|
|
12
|
+
:expects => [200],
|
|
13
|
+
:method => "POST",
|
|
14
|
+
:body => soap_envelope.to_xml,
|
|
15
|
+
:parser => Fog::Parsers::Compute::ProfitBricks::GetAllDataCenters.new
|
|
16
|
+
)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class Mock
|
|
21
|
+
def get_all_data_centers
|
|
22
|
+
response = Excon::Response.new
|
|
23
|
+
response.status = 200
|
|
24
|
+
response.body = {
|
|
25
|
+
"getAllDataCentersResponse" => self.data[:datacenters]
|
|
26
|
+
}
|
|
27
|
+
response
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|