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,61 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class ProfitBricks
|
|
4
|
+
class Real
|
|
5
|
+
require 'fog/profitbricks/parsers/compute/set_internet_access'
|
|
6
|
+
|
|
7
|
+
# Connect an existing NIC to a public LAN to get internet access
|
|
8
|
+
#
|
|
9
|
+
# ==== Parameters
|
|
10
|
+
# * dataCenterId<~String> -
|
|
11
|
+
# * lanId<~Integer> -
|
|
12
|
+
# * internetAccess<~Boolean> -
|
|
13
|
+
#
|
|
14
|
+
# ==== Returns
|
|
15
|
+
# * response<~Excon::Response>:
|
|
16
|
+
# * body<~Hash>:
|
|
17
|
+
# * setInternetAccessResponse<~Hash>:
|
|
18
|
+
# * requestId<~String> - ID of request
|
|
19
|
+
# * dataCenterId<~String> - UUID of virtual data center
|
|
20
|
+
# * dataCenterVersion<~Integer> - Version of the virtual data center
|
|
21
|
+
#
|
|
22
|
+
# {ProfitBricks API Documentation}[http://www.profitbricks.com/apidoc/SetInternetAccess.html]
|
|
23
|
+
def set_internet_access(data_center_id, lan_id, internet_access)
|
|
24
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope {
|
|
25
|
+
|xml| xml[:ws].setInternetAccess {
|
|
26
|
+
xml.dataCenterId(data_center_id)
|
|
27
|
+
xml.lanId(lan_id)
|
|
28
|
+
xml.internetAccess(internet_access)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
request(
|
|
33
|
+
:expects => [200],
|
|
34
|
+
:method => 'POST',
|
|
35
|
+
:body => soap_envelope.to_xml,
|
|
36
|
+
:parser =>
|
|
37
|
+
Fog::Parsers::Compute::ProfitBricks::SetInternetAccess.new
|
|
38
|
+
)
|
|
39
|
+
rescue Excon::Errors::InternalServerError => error
|
|
40
|
+
Fog::Errors::NotFound.new(error)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
class Mock
|
|
45
|
+
def set_internet_access(data_center_id, lan_id, internet_access)
|
|
46
|
+
response = Excon::Response.new
|
|
47
|
+
response.status = 200
|
|
48
|
+
response.body = {
|
|
49
|
+
'setInternetAccessResponse' =>
|
|
50
|
+
{
|
|
51
|
+
'requestId' => Fog::Mock::random_numbers(7),
|
|
52
|
+
'dataCenterId' => Fog::UUID.uuid,
|
|
53
|
+
'dataCenterVersion' => 1
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
response
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class ProfitBricks
|
|
4
|
+
class Real
|
|
5
|
+
|
|
6
|
+
# Start specified virtual server
|
|
7
|
+
#
|
|
8
|
+
# ==== Parameters
|
|
9
|
+
# * serverId<~String> - UUID of a virtual server
|
|
10
|
+
#
|
|
11
|
+
# ==== Returns
|
|
12
|
+
# * response<~Excon::Response>:
|
|
13
|
+
# * body<~Hash>:
|
|
14
|
+
# * startServerResponse<~Hash>:
|
|
15
|
+
# * requestId<~String> - ID of request
|
|
16
|
+
#
|
|
17
|
+
# {ProfitBricks API Documentation}[http://www.profitbricks.com/apidoc/StartServer.html]
|
|
18
|
+
def start_server(server_id)
|
|
19
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope do |xml|
|
|
20
|
+
xml[:ws].startServer {
|
|
21
|
+
xml.serverId(server_id)
|
|
22
|
+
}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
request(
|
|
26
|
+
:expects => [200],
|
|
27
|
+
:method => "POST",
|
|
28
|
+
:body => soap_envelope.to_xml
|
|
29
|
+
)
|
|
30
|
+
rescue Excon::Errors::InternalServerError => error
|
|
31
|
+
Fog::Errors::NotFound.new(error)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
class Mock
|
|
36
|
+
def start_server(server_id)
|
|
37
|
+
|
|
38
|
+
if server = self.data[:servers].find {
|
|
39
|
+
|attrib| attrib["serverId"] == server_id
|
|
40
|
+
}
|
|
41
|
+
server["machine_state"] = "RUNNING"
|
|
42
|
+
server["provisioning_state"] = "AVAILABLE"
|
|
43
|
+
else
|
|
44
|
+
raise Fog::Errors::NotFound.new("The requested server resource could not be found")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
response = Excon::Response.new
|
|
48
|
+
response.status = 200
|
|
49
|
+
response.body = {
|
|
50
|
+
"startServerResponse" => {
|
|
51
|
+
"requestId" => Fog::Mock::random_numbers(7)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
response
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class ProfitBricks
|
|
4
|
+
class Real
|
|
5
|
+
|
|
6
|
+
# Stop specified virtual server
|
|
7
|
+
#
|
|
8
|
+
# ==== Parameters
|
|
9
|
+
# * serverId<~String> - UUID of a virtual server
|
|
10
|
+
#
|
|
11
|
+
# ==== Returns
|
|
12
|
+
# * response<~Excon::Response>:
|
|
13
|
+
# * body<~Hash>:
|
|
14
|
+
# * stopServerResponse<~Hash>:
|
|
15
|
+
# * requestId<~String> - ID of request
|
|
16
|
+
#
|
|
17
|
+
# {ProfitBricks API Documentation}[http://www.profitbricks.com/apidoc/StopServer.html]
|
|
18
|
+
def stop_server(server_id)
|
|
19
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope do |xml|
|
|
20
|
+
xml[:ws].stopServer {
|
|
21
|
+
xml.serverId(server_id)
|
|
22
|
+
}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
request(
|
|
26
|
+
:expects => [200],
|
|
27
|
+
:method => "POST",
|
|
28
|
+
:body => soap_envelope.to_xml
|
|
29
|
+
)
|
|
30
|
+
rescue Excon::Errors::InternalServerError => error
|
|
31
|
+
Fog::Errors::NotFound.new(error)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
class Mock
|
|
36
|
+
def stop_server(server_id)
|
|
37
|
+
|
|
38
|
+
if server = self.data[:servers].find {
|
|
39
|
+
|attrib| attrib["serverId"] == server_id
|
|
40
|
+
}
|
|
41
|
+
server["machine_state"] = "SHUTOFF"
|
|
42
|
+
server["provisioning_state"] = "INACTIVE"
|
|
43
|
+
else
|
|
44
|
+
raise Fog::Errors::NotFound.new("The requested server resource could not be found")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
response = Excon::Response.new
|
|
48
|
+
response.status = 200
|
|
49
|
+
response.body = {
|
|
50
|
+
"stopServerResponse" => {
|
|
51
|
+
"requestId" => Fog::Mock::random_numbers(7)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
response
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class ProfitBricks
|
|
4
|
+
class Real
|
|
5
|
+
require 'fog/profitbricks/parsers/compute/update_data_center'
|
|
6
|
+
def update_data_center(data_center_id, options={})
|
|
7
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope {
|
|
8
|
+
|xml| xml[:ws].updateDataCenter {
|
|
9
|
+
xml.request {
|
|
10
|
+
xml.dataCenterId(data_center_id)
|
|
11
|
+
options.each { |key, value| xml.send(key, value) }
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
request(
|
|
17
|
+
:expects => [200],
|
|
18
|
+
:method => 'POST',
|
|
19
|
+
:body => soap_envelope.to_xml,
|
|
20
|
+
:parser =>
|
|
21
|
+
Fog::Parsers::Compute::ProfitBricks::UpdateDataCenter.new
|
|
22
|
+
)
|
|
23
|
+
rescue Excon::Errors::InternalServerError => error
|
|
24
|
+
Fog::Errors::NotFound.new(error)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class Mock
|
|
29
|
+
def update_data_center(data_center_id, options={})
|
|
30
|
+
|
|
31
|
+
if data_center = self.data[:datacenters].find {
|
|
32
|
+
|attrib| attrib['dataCenterId'] == data_center_id
|
|
33
|
+
}
|
|
34
|
+
data_center['dataCenterName'] = options['dataCenterName']
|
|
35
|
+
data_center['dataCenterVersion'] += 1
|
|
36
|
+
else
|
|
37
|
+
raise Fog::Errors::NotFound.new('The requested resource could not be found')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
response = Excon::Response.new
|
|
41
|
+
response.status = 200
|
|
42
|
+
response.body = {
|
|
43
|
+
'updateDataCenterResponse' =>
|
|
44
|
+
{
|
|
45
|
+
'requestId' => Fog::Mock::random_numbers(7),
|
|
46
|
+
'dataCenterId' => Fog::UUID.uuid,
|
|
47
|
+
'dataCenterVersion' => 1
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
response
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class ProfitBricks
|
|
4
|
+
class Real
|
|
5
|
+
require 'fog/profitbricks/parsers/compute/update_nic'
|
|
6
|
+
|
|
7
|
+
# Update a virtual NIC
|
|
8
|
+
#
|
|
9
|
+
# ==== Parameters
|
|
10
|
+
# * nicId<~String> - Required,
|
|
11
|
+
# * options<~Hash>:
|
|
12
|
+
# * lanId<~Integer> - Optional,
|
|
13
|
+
# * nicName<~String> - Optional, name of the new virtual network interface
|
|
14
|
+
# * ip<~String> - Optional,
|
|
15
|
+
# * dhcpActive<~Boolean> - Optional,
|
|
16
|
+
#
|
|
17
|
+
# ==== Returns
|
|
18
|
+
# * response<~Excon::Response>:
|
|
19
|
+
# * body<~Hash>:
|
|
20
|
+
# * updateNicResponse<~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
|
+
#
|
|
25
|
+
# {ProfitBricks API Documentation}[http://www.profitbricks.com/apidoc/UpdateNIC.html]
|
|
26
|
+
def update_nic(nic_id, options={})
|
|
27
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope {
|
|
28
|
+
|xml| xml[:ws].updateNic {
|
|
29
|
+
xml.request {
|
|
30
|
+
xml.nicId(nic_id)
|
|
31
|
+
options.each { |key, value| xml.send(key, value) }
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
request(
|
|
37
|
+
:expects => [200],
|
|
38
|
+
:method => 'POST',
|
|
39
|
+
:body => soap_envelope.to_xml,
|
|
40
|
+
:parser =>
|
|
41
|
+
Fog::Parsers::Compute::ProfitBricks::UpdateNic.new
|
|
42
|
+
)
|
|
43
|
+
rescue Excon::Errors::InternalServerError => error
|
|
44
|
+
Fog::Errors::NotFound.new(error)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
class Mock
|
|
49
|
+
def update_nic(nic_id, options={})
|
|
50
|
+
|
|
51
|
+
if nic = self.data[:interfaces].find {
|
|
52
|
+
|attrib| attrib['nicId'] == nic_id
|
|
53
|
+
}
|
|
54
|
+
options.each do |key, value|
|
|
55
|
+
nic[key] = value
|
|
56
|
+
end
|
|
57
|
+
else
|
|
58
|
+
raise Fog::Errors::NotFound.new('The requested NIC could not be found')
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
response = Excon::Response.new
|
|
62
|
+
response.status = 200
|
|
63
|
+
response.body = {
|
|
64
|
+
'updateNicResponse' =>
|
|
65
|
+
{
|
|
66
|
+
'requestId' => Fog::Mock::random_numbers(7),
|
|
67
|
+
'dataCenterId' => Fog::UUID.uuid,
|
|
68
|
+
'dataCenterVersion' => 1
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
response
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class ProfitBricks
|
|
4
|
+
class Real
|
|
5
|
+
require 'fog/profitbricks/parsers/compute/update_server'
|
|
6
|
+
|
|
7
|
+
# Update a virtual server
|
|
8
|
+
#
|
|
9
|
+
# ==== Parameters
|
|
10
|
+
# * serverId<~String> - Required, UUID of virtual server
|
|
11
|
+
# * options<~Hash>:
|
|
12
|
+
# * serverName<~String> - Optional,
|
|
13
|
+
# * cores<~Integer> - Optional,
|
|
14
|
+
# * ram<~Integer> Optional, Memory in MB
|
|
15
|
+
# * bootFromStorageId<~String> - Optional, UUID of boot storage
|
|
16
|
+
# * bootFromImageId<~String> -
|
|
17
|
+
# * osType<~String> - Optional, UNKNOWN, WINDOWS, LINUX, OTHER
|
|
18
|
+
# * availabilityZone<~String> - Optional, AUTO, ZONE_1, ZONE_2
|
|
19
|
+
#
|
|
20
|
+
# ==== Returns
|
|
21
|
+
# * response<~Excon::Response>:
|
|
22
|
+
# * body<~Hash>:
|
|
23
|
+
# * updateServerResponse<~Hash>:
|
|
24
|
+
# * requestId<~String> - ID of request
|
|
25
|
+
# * dataCenterId<~String> - UUID of virtual data center
|
|
26
|
+
# * dataCenterVersion<~Integer> - Version of the virtual data center
|
|
27
|
+
#
|
|
28
|
+
# {ProfitBricks API Documentation}[http://www.profitbricks.com/apidoc/UpdateServer.html]
|
|
29
|
+
def update_server(server_id, options={})
|
|
30
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope {
|
|
31
|
+
|xml| xml[:ws].updateServer {
|
|
32
|
+
xml.request {
|
|
33
|
+
xml.serverId(server_id)
|
|
34
|
+
options.each { |key, value| xml.send(key, value) }
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
request(
|
|
40
|
+
:expects => [200],
|
|
41
|
+
:method => 'POST',
|
|
42
|
+
:body => soap_envelope.to_xml,
|
|
43
|
+
:parser =>
|
|
44
|
+
Fog::Parsers::Compute::ProfitBricks::UpdateServer.new
|
|
45
|
+
)
|
|
46
|
+
rescue Excon::Errors::InternalServerError => error
|
|
47
|
+
Fog::Errors::NotFound.new(error)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class Mock
|
|
52
|
+
def update_server(server_id, options={})
|
|
53
|
+
|
|
54
|
+
if server = self.data[:servers].find {
|
|
55
|
+
|attrib| attrib['serverId'] == server_id
|
|
56
|
+
}
|
|
57
|
+
options.each do |key, value|
|
|
58
|
+
server[key] = value
|
|
59
|
+
end
|
|
60
|
+
else
|
|
61
|
+
raise Fog::Errors::NotFound.new(
|
|
62
|
+
'The requested server resource could not be found'
|
|
63
|
+
)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
response = Excon::Response.new
|
|
67
|
+
response.status = 200
|
|
68
|
+
response.body = {
|
|
69
|
+
'updateServerResponse' =>
|
|
70
|
+
{
|
|
71
|
+
'requestId' => Fog::Mock::random_numbers(7),
|
|
72
|
+
'dataCenterId' => Fog::UUID.uuid,
|
|
73
|
+
'dataCenterVersion' => 1
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
response
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Compute
|
|
3
|
+
class ProfitBricks
|
|
4
|
+
class Real
|
|
5
|
+
require 'fog/profitbricks/parsers/compute/update_storage'
|
|
6
|
+
|
|
7
|
+
# Update a virtual storage
|
|
8
|
+
#
|
|
9
|
+
# ==== Parameters
|
|
10
|
+
# * storageId<~String> - Required, UUID of the virtual storage
|
|
11
|
+
# * options<~Hash>:
|
|
12
|
+
# * size<~Integer> - Optional, size of virtual storage in GB
|
|
13
|
+
# * storageName<~String> - Optional,
|
|
14
|
+
# * mountImageId<~String> - Optional,
|
|
15
|
+
#
|
|
16
|
+
# ==== Returns
|
|
17
|
+
# * response<~Excon::Response>:
|
|
18
|
+
# * body<~Hash>:
|
|
19
|
+
# * updateStorageResponse<~Hash>:
|
|
20
|
+
# * requestId<~String> - ID of request
|
|
21
|
+
# * dataCenterId<~String> - UUID of virtual data center
|
|
22
|
+
# * dataCenterVersion<~Integer> - Version of the virtual data center
|
|
23
|
+
#
|
|
24
|
+
# {ProfitBricks API Documentation}[http://www.profitbricks.com/apidoc/UpdateStorage.html]
|
|
25
|
+
def update_storage(storage_id, options={})
|
|
26
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope {
|
|
27
|
+
|xml| xml[:ws].updateStorage {
|
|
28
|
+
xml.request {
|
|
29
|
+
xml.storageId(storage_id)
|
|
30
|
+
options.each { |key, value| xml.send(key, value) }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
request(
|
|
36
|
+
:expects => [200],
|
|
37
|
+
:method => 'POST',
|
|
38
|
+
:body => soap_envelope.to_xml,
|
|
39
|
+
:parser =>
|
|
40
|
+
Fog::Parsers::Compute::ProfitBricks::UpdateStorage.new
|
|
41
|
+
)
|
|
42
|
+
rescue Excon::Errors::InternalServerError => error
|
|
43
|
+
Fog::Errors::NotFound.new(error)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
class Mock
|
|
48
|
+
def update_storage(storage_id, options={})
|
|
49
|
+
|
|
50
|
+
if storage = self.data[:volumes].find {
|
|
51
|
+
|attrib| attrib['storageId'] == storage_id
|
|
52
|
+
}
|
|
53
|
+
options.each do |key, value|
|
|
54
|
+
storage[key] = value
|
|
55
|
+
end
|
|
56
|
+
else
|
|
57
|
+
raise Fog::Errors::NotFound.new('The requested resource could not be found')
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
response = Excon::Response.new
|
|
61
|
+
response.status = 200
|
|
62
|
+
response.body = {
|
|
63
|
+
'updateStorageResponse' =>
|
|
64
|
+
{
|
|
65
|
+
'requestId' => Fog::Mock::random_numbers(7),
|
|
66
|
+
'dataCenterId' => Fog::UUID.uuid,
|
|
67
|
+
'dataCenterVersion' => 1
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
response
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|