fog-profitbricks 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,82 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class ProfitBricks
|
4
|
+
class Real
|
5
|
+
def get_flavor(flavor_id)
|
6
|
+
response = Excon::Response.new
|
7
|
+
response.status = 200
|
8
|
+
response.body = {
|
9
|
+
"getFlavorResponse" => [
|
10
|
+
{
|
11
|
+
"flavorId" => "00db4c8f-5e83-49b0-a70b-ac4aad786163",
|
12
|
+
"flavorName" => "Micro",
|
13
|
+
"ram" => 1024,
|
14
|
+
"cores" => 1
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"flavorId" => "dc64957b-be9d-431e-91cd-9e217f94d3de",
|
18
|
+
"flavorName" => "Small",
|
19
|
+
"ram" => 2048,
|
20
|
+
"cores" => 1
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"flavorId" => "b37d000e-b347-4592-b572-df13ef8f68e1",
|
24
|
+
"flavorName" => "Medium",
|
25
|
+
"ram" => 4096,
|
26
|
+
"cores" => 2
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"flavorId" => "a5a4389f-54b6-4f47-b6e8-1c5c55976b94",
|
30
|
+
"flavorName" => "Large",
|
31
|
+
"ram" => 7168,
|
32
|
+
"cores" => 4
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"flavorId" => "0052db40-f1dd-4ecf-a711-5980081b7059",
|
36
|
+
"flavorName" => "Extra Large",
|
37
|
+
"ram" => 14336,
|
38
|
+
"cores" => 8
|
39
|
+
},
|
40
|
+
{
|
41
|
+
"flavorId" => "8b2b835d-be09-48cf-aae2-7e35aafe92d6",
|
42
|
+
"flavorName" => "Memory Intensive Small",
|
43
|
+
"ram" => 16384,
|
44
|
+
"cores" => 2
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"flavorId" => "45c28f8b-6a67-4f69-8c94-231d371da2b6",
|
48
|
+
"flavorName" => "Memory Intensive Medium",
|
49
|
+
"ram" => 28672,
|
50
|
+
"cores" => 4
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"flavorId" => "1d22436d-d958-4151-b144-43a8e180c4c4",
|
54
|
+
"flavorName" => "Memory Intensive Large",
|
55
|
+
"ram" => 57344,
|
56
|
+
"cores" => 8
|
57
|
+
},
|
58
|
+
].find { |flavor| flavor["flavorId"] == flavor_id } || raise(Fog::Errors::NotFound)
|
59
|
+
}
|
60
|
+
response
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class Mock
|
65
|
+
def get_flavor(flavor_id)
|
66
|
+
response = Excon::Response.new
|
67
|
+
response.status = 200
|
68
|
+
|
69
|
+
if flavor = self.data[:flavors].find {
|
70
|
+
|attrib| attrib["flavorId"] == flavor_id
|
71
|
+
}
|
72
|
+
else
|
73
|
+
raise Fog::Errors::NotFound.new("The requested flavor could not be found")
|
74
|
+
end
|
75
|
+
|
76
|
+
response.body = { "getFlavorResponse" => flavor }
|
77
|
+
response
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class ProfitBricks
|
4
|
+
class Real
|
5
|
+
require "fog/profitbricks/parsers/compute/get_image"
|
6
|
+
|
7
|
+
# Displays a list of all available images.
|
8
|
+
#
|
9
|
+
# ==== Parameters
|
10
|
+
# * imageId<~String> - Name of the new virtual data center
|
11
|
+
#
|
12
|
+
# ==== Returns
|
13
|
+
# * response<~Excon::Response>:
|
14
|
+
# * body<~Hash>:
|
15
|
+
# * getAllImagesResponse<~Hash>:
|
16
|
+
# * imageId<~String> - Identifer of the image
|
17
|
+
# * imageName<~String> - Name of the image
|
18
|
+
# * imageSize<~Integer> - Size of the image (in MB?)
|
19
|
+
# * imageType<~String> - Image type HDD or CD-ROM/DVD (ISO) image
|
20
|
+
# * writeable<~String> - Image is writable (TRUE/FALSE)
|
21
|
+
# * bootable<~String> - Image is bootable
|
22
|
+
# * cpuHotplug<~String> -Image supports CPU Hot-Plugging
|
23
|
+
# * cpuHotUnplug<~String> -
|
24
|
+
# * ramHotPlug<~String> - Image supports memory Hot-Plugging
|
25
|
+
# * ramHotUnPlug<~String> -
|
26
|
+
# * discVirtioHotPlug<~String> -
|
27
|
+
# * discVirtioHotUnplug<~String> -
|
28
|
+
# * nicHotPlug<~String> -
|
29
|
+
# * nicHotUnplug<~String> -
|
30
|
+
# * serverIds<~String> - List all servers by ID on which the image is used
|
31
|
+
# * location<~String> - Location where the image has been uploaded
|
32
|
+
# * osType<~String> - OS type of an image (WINDOWS, LINUX, OTHER, UNKNOWN)
|
33
|
+
# * public<~String> - Shows if image is publicly available or private
|
34
|
+
#
|
35
|
+
# {ProfitBricks API Documentation}[http://www.profitbricks.com/apidoc/APIDocumentation.html?GetImages.html]
|
36
|
+
def get_image(image_id)
|
37
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope do |xml|
|
38
|
+
xml[:ws].getImage {
|
39
|
+
xml.imageId(image_id)
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
request(
|
44
|
+
:expects => [200],
|
45
|
+
:method => "POST",
|
46
|
+
:body => soap_envelope.to_xml,
|
47
|
+
:parser => Fog::Parsers::Compute::ProfitBricks::GetImage.new
|
48
|
+
)
|
49
|
+
rescue Excon::Errors::InternalServerError => error
|
50
|
+
Fog::Errors::NotFound.new(error)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Mock
|
55
|
+
def get_image(image_id)
|
56
|
+
if data_center = self.data[:images].find {
|
57
|
+
|attrib| attrib["imageId"] == image_id
|
58
|
+
}
|
59
|
+
else
|
60
|
+
raise Fog::Errors::NotFound.new("The requested resource could not be found")
|
61
|
+
end
|
62
|
+
|
63
|
+
response = Excon::Response.new
|
64
|
+
response.status = 200
|
65
|
+
response.body = { "getImageResponse" => data_center }
|
66
|
+
response
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class ProfitBricks
|
4
|
+
class Real
|
5
|
+
def get_location(location_id)
|
6
|
+
response = Excon::Response.new
|
7
|
+
response.status = 200
|
8
|
+
response.body = {
|
9
|
+
"getLocationResponse" => [
|
10
|
+
{
|
11
|
+
"locationId" => "c0420cc0-90e8-4f4b-8860-df0a07d18047",
|
12
|
+
"locationName" => "de/fkb",
|
13
|
+
"country" => "DEU"
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"locationId" => "68c4099a-d9d8-4683-bdc2-12789aacfa2a",
|
17
|
+
"locationName" => "de/fra",
|
18
|
+
"country" => "DEU"
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"locationId" => "e102ba74-6764-47f3-8896-246141da8ada",
|
22
|
+
"locationName" => "us/las",
|
23
|
+
"country" => "USA"
|
24
|
+
}
|
25
|
+
].find { |location| location["locationId"] == location_id } || raise(Fog::Errors::NotFound)
|
26
|
+
}
|
27
|
+
response
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Mock
|
32
|
+
def get_location(location_id)
|
33
|
+
if location = self.data[:regions].find {
|
34
|
+
|attrib| attrib["locationId"] == location_id
|
35
|
+
}
|
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 = { "getLocationResponse" => location }
|
43
|
+
response
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class ProfitBricks
|
4
|
+
class Real
|
5
|
+
require "fog/profitbricks/parsers/compute/get_nic"
|
6
|
+
|
7
|
+
# Return virtual NIC information
|
8
|
+
#
|
9
|
+
# ==== Parameters
|
10
|
+
# * N/A
|
11
|
+
#
|
12
|
+
# ==== Returns
|
13
|
+
# * response<~Excon::Response>:
|
14
|
+
# * body<~Hash>:
|
15
|
+
# * getNicResponse<~Hash>:
|
16
|
+
# * nicId<~String> - UUID of the network interface
|
17
|
+
# * nicName<~String> - Name of the network interface
|
18
|
+
# * lanId<~Integer> -
|
19
|
+
# * internetAccess<~Boolean> -
|
20
|
+
# * serverId<~String> -
|
21
|
+
# * ips<~String> -
|
22
|
+
# * macAddress<~String> -
|
23
|
+
# * firewall<~Hash>:
|
24
|
+
# * ...
|
25
|
+
# * dhcpActive<~Boolean> -
|
26
|
+
# * gatewayIp<~String> -
|
27
|
+
# * provisioningState<~String> - INACTIVE, INPROCESS, AVAILABLE, DELETED, ERROR
|
28
|
+
#
|
29
|
+
# {ProfitBricks API Documentation}[http://www.profitbricks.com/apidoc/GetNIC.html]
|
30
|
+
def get_nic(nic_id)
|
31
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope do |xml|
|
32
|
+
xml[:ws].getNic {
|
33
|
+
xml.nicId(nic_id)
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
request(
|
38
|
+
:expects => [200],
|
39
|
+
:method => "POST",
|
40
|
+
:body => soap_envelope.to_xml,
|
41
|
+
:parser => Fog::Parsers::Compute::ProfitBricks::GetNic.new
|
42
|
+
)
|
43
|
+
rescue Excon::Errors::InternalServerError => error
|
44
|
+
Fog::Errors::NotFound.new(error)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class Mock
|
49
|
+
def get_nic(nic_id)
|
50
|
+
if nic = self.data[:interfaces].find {
|
51
|
+
|attrib| attrib["nicId"] == nic_id
|
52
|
+
}
|
53
|
+
else
|
54
|
+
raise Fog::Errors::NotFound.new("The requested resource could not be found")
|
55
|
+
end
|
56
|
+
|
57
|
+
response = Excon::Response.new
|
58
|
+
response.status = 200
|
59
|
+
response.body = { "getNicResponse" => nic }
|
60
|
+
response
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class ProfitBricks
|
4
|
+
class Real
|
5
|
+
require "fog/profitbricks/parsers/compute/get_server"
|
6
|
+
|
7
|
+
# Create new virtual server
|
8
|
+
#
|
9
|
+
# ==== Parameters
|
10
|
+
# * serverId<~String> - UUID of a virtual server
|
11
|
+
#
|
12
|
+
# ==== Returns
|
13
|
+
# * response<~Excon::Response>:
|
14
|
+
# * body<~Hash>:
|
15
|
+
# * getServerResponse<~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
|
+
# * serverId<~String> - UUID of the new virtual server
|
20
|
+
# * serverName<~String> -
|
21
|
+
# * cores<~Integer> -
|
22
|
+
# * ram<~Integer> -
|
23
|
+
# * internetAccess<~String> -
|
24
|
+
# * ips<~String> -
|
25
|
+
# * connectedStorages<~Array>:
|
26
|
+
# * bootDevice<~Integer> -
|
27
|
+
# * busType<~String> - VIRTIO|IDE
|
28
|
+
# * deviceNumber<~Integer> -
|
29
|
+
# * size<~Integer> -
|
30
|
+
# * storageId<~String> -
|
31
|
+
# * storageName<~String> -
|
32
|
+
# * nics<~Array>:
|
33
|
+
# * dataCenterId<~String> -
|
34
|
+
# * dataCenterVersion<~Integer> -
|
35
|
+
# * nicId<~String> -
|
36
|
+
# * lanId<~Integer> -
|
37
|
+
# * internetAccess<~String> -
|
38
|
+
# * serverId<~String> -
|
39
|
+
# * ips<~String> -
|
40
|
+
# * macAddress<~String> -
|
41
|
+
# * firewall<~Hash>:
|
42
|
+
# * active<~String> -
|
43
|
+
# * firewallId<~String> -
|
44
|
+
# * nicId<~String> -
|
45
|
+
# * provisioningState<~String> -
|
46
|
+
# * dhcpActive<~String> -
|
47
|
+
# * provisioningState<~String> -
|
48
|
+
# * provisioningState<~String> -
|
49
|
+
# * virtualMachineState<~String> -
|
50
|
+
# * creationTime<~Time> -
|
51
|
+
# * lastModificationTime<~Time> -
|
52
|
+
# * osType<~String> -
|
53
|
+
# * availabilityZone<~String> -
|
54
|
+
# * cpuHotPlug<~String> -
|
55
|
+
# * ramHotPlug<~String> -
|
56
|
+
# * nicHotPlug<~String> -
|
57
|
+
# * nicHotUnPlug<~String> -
|
58
|
+
# * discVirtioHotPlug<~String> -
|
59
|
+
# * discVirtioHotUnPlug<~String> -
|
60
|
+
#
|
61
|
+
# {ProfitBricks API Documentation}[http://www.profitbricks.com/apidoc/APIDocumentation.html?getServer.html]
|
62
|
+
def get_server(server_id)
|
63
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope do |xml|
|
64
|
+
xml[:ws].getServer {
|
65
|
+
xml.serverId(server_id)
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
request(
|
70
|
+
:expects => [200],
|
71
|
+
:method => "POST",
|
72
|
+
:body => soap_envelope.to_xml,
|
73
|
+
:parser => Fog::Parsers::Compute::ProfitBricks::GetServer.new
|
74
|
+
)
|
75
|
+
rescue Excon::Errors::InternalServerError => error
|
76
|
+
Fog::Errors::NotFound.new(error)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
class Mock
|
81
|
+
def get_server(server_id)
|
82
|
+
|
83
|
+
if server = self.data[:servers].find {
|
84
|
+
|attrib| attrib["serverId"] == server_id
|
85
|
+
}
|
86
|
+
else
|
87
|
+
raise Fog::Errors::NotFound.new("The server resource could not be found")
|
88
|
+
end
|
89
|
+
|
90
|
+
server["requestId"] = Fog::Mock::random_numbers(7)
|
91
|
+
|
92
|
+
response = Excon::Response.new
|
93
|
+
response.status = 200
|
94
|
+
response.body = { "getServerResponse" => server }
|
95
|
+
response
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class ProfitBricks
|
4
|
+
class Real
|
5
|
+
require "fog/profitbricks/parsers/compute/get_storage"
|
6
|
+
|
7
|
+
# Returns all virtual storage information
|
8
|
+
#
|
9
|
+
# ==== Parameters
|
10
|
+
# * N/A
|
11
|
+
#
|
12
|
+
# ==== Returns
|
13
|
+
# * response<~Excon::Response>:
|
14
|
+
# * body<~Hash>:
|
15
|
+
# * getStorage<~Hash>:
|
16
|
+
# * dataCenterId<~String> - UUID of the virtual data center
|
17
|
+
# * dataCenterVersion<~Integer> - Version of the virtual data center
|
18
|
+
# * storageId<~String> - UUID of the virtual storage
|
19
|
+
# * size<~Integer> - Size of the virtual storage in GB
|
20
|
+
# * storageName<~String> - Name of the virtual storage
|
21
|
+
# * mountImage<~Hash>:
|
22
|
+
# * imageId<~String> -
|
23
|
+
# * imageName<~String> -
|
24
|
+
# * serverIds<~String> - List of servers connected to the virtual storage by UUID
|
25
|
+
# * provisioningState<~String> - Current provisioning state of virtual storage
|
26
|
+
# * creationTime<~Time> - Time when virtual storage was created
|
27
|
+
# * lastModificationTime<~Time> - Time when the virtual storage was last modified
|
28
|
+
#
|
29
|
+
# {ProfitBricks API Documentation}[http://www.profitbricks.com/apidoc/GetStorage.html]
|
30
|
+
def get_storage(storage_id)
|
31
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope do |xml|
|
32
|
+
xml[:ws].getStorage {
|
33
|
+
xml.storageId(storage_id)
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
request(
|
38
|
+
:expects => [200],
|
39
|
+
:method => "POST",
|
40
|
+
:body => soap_envelope.to_xml,
|
41
|
+
:parser => Fog::Parsers::Compute::ProfitBricks::GetStorage.new
|
42
|
+
)
|
43
|
+
rescue Excon::Errors::InternalServerError => error
|
44
|
+
Fog::Errors::NotFound.new(error)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class Mock
|
49
|
+
def get_storage(storage_id)
|
50
|
+
if storage = self.data[:volumes].find {
|
51
|
+
|attrib| attrib["storageId"] == storage_id
|
52
|
+
}
|
53
|
+
else
|
54
|
+
raise Fog::Errors::NotFound.new("The requested resource could not be found")
|
55
|
+
end
|
56
|
+
|
57
|
+
response = Excon::Response.new
|
58
|
+
response.status = 200
|
59
|
+
response.body = { "getStorageResponse" => storage }
|
60
|
+
response
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class ProfitBricks
|
4
|
+
class Real
|
5
|
+
require "fog/profitbricks/parsers/compute/reset_server"
|
6
|
+
|
7
|
+
# Reset specified virtual server
|
8
|
+
#
|
9
|
+
# ==== Parameters
|
10
|
+
# * serverId<~String> - UUID of a virtual server
|
11
|
+
#
|
12
|
+
# ==== Returns
|
13
|
+
# * response<~Excon::Response>:
|
14
|
+
# * body<~Hash>:
|
15
|
+
# * resetServerResponse<~Hash>:
|
16
|
+
# * requestId<~String> - ID of request
|
17
|
+
#
|
18
|
+
# {ProfitBricks API Documentation}[http://www.profitbricks.com/apidoc/ResetServer.html]
|
19
|
+
def reset_server(server_id)
|
20
|
+
soap_envelope = Fog::ProfitBricks.construct_envelope do |xml|
|
21
|
+
xml[:ws].resetServer {
|
22
|
+
xml.serverId(server_id)
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
request(
|
27
|
+
:expects => [200],
|
28
|
+
:method => "POST",
|
29
|
+
:body => soap_envelope.to_xml,
|
30
|
+
:parser => Fog::Parsers::Compute::ProfitBricks::ResetServer.new
|
31
|
+
)
|
32
|
+
rescue Excon::Errors::InternalServerError => error
|
33
|
+
Fog::Errors::NotFound.new(error)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class Mock
|
38
|
+
def reset_server(server_id)
|
39
|
+
response = Excon::Response.new
|
40
|
+
response.status = 200
|
41
|
+
response.body = {
|
42
|
+
"resetServerResponse" => {
|
43
|
+
"requestId" => Fog::Mock::random_numbers(7)
|
44
|
+
}
|
45
|
+
}
|
46
|
+
response
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|