fog-profitbricks 2.0.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.travis.yml +11 -4
- data/README.md +8 -5
- data/Rakefile +1 -1
- data/examples/pb_demo.rb +49 -49
- data/fog-profitbricks.gemspec +4 -5
- data/gemfiles/Gemfile.1.9.2+ +1 -0
- data/lib/fog/bin/profitbricks.rb +5 -5
- data/lib/fog/profitbricks.rb +3 -3
- data/lib/fog/profitbricks/compute.rb +209 -204
- data/lib/fog/profitbricks/helpers/compute/data_helper.rb +1 -1
- data/lib/fog/profitbricks/models/compute/datacenter.rb +1 -1
- data/lib/fog/profitbricks/models/compute/datacenters.rb +6 -7
- data/lib/fog/profitbricks/models/compute/firewall_rule.rb +2 -2
- data/lib/fog/profitbricks/models/compute/firewall_rules.rb +5 -8
- data/lib/fog/profitbricks/models/compute/flavors.rb +1 -4
- data/lib/fog/profitbricks/models/compute/image.rb +4 -0
- data/lib/fog/profitbricks/models/compute/images.rb +2 -5
- data/lib/fog/profitbricks/models/compute/ip_block.rb +1 -1
- data/lib/fog/profitbricks/models/compute/ip_blocks.rb +3 -8
- data/lib/fog/profitbricks/models/compute/lan.rb +1 -1
- data/lib/fog/profitbricks/models/compute/lans.rb +4 -7
- data/lib/fog/profitbricks/models/compute/load_balancer.rb +6 -7
- data/lib/fog/profitbricks/models/compute/load_balancers.rb +5 -9
- data/lib/fog/profitbricks/models/compute/locations.rb +2 -5
- data/lib/fog/profitbricks/models/compute/nic.rb +6 -3
- data/lib/fog/profitbricks/models/compute/nics.rb +2 -5
- data/lib/fog/profitbricks/models/compute/regions.rb +1 -4
- data/lib/fog/profitbricks/models/compute/request.rb +0 -1
- data/lib/fog/profitbricks/models/compute/requests.rb +2 -4
- data/lib/fog/profitbricks/models/compute/server.rb +10 -13
- data/lib/fog/profitbricks/models/compute/servers.rb +3 -6
- data/lib/fog/profitbricks/models/compute/snapshot.rb +2 -2
- data/lib/fog/profitbricks/models/compute/snapshots.rb +3 -6
- data/lib/fog/profitbricks/models/compute/volume.rb +11 -9
- data/lib/fog/profitbricks/models/compute/volumes.rb +3 -6
- data/lib/fog/profitbricks/requests/compute/associate_nic_to_load_balancer.rb +26 -13
- data/lib/fog/profitbricks/requests/compute/attach_cdrom.rb +25 -16
- data/lib/fog/profitbricks/requests/compute/attach_volume.rb +25 -16
- data/lib/fog/profitbricks/requests/compute/create_datacenter.rb +22 -23
- data/lib/fog/profitbricks/requests/compute/create_firewall_rule.rb +24 -26
- data/lib/fog/profitbricks/requests/compute/create_flavor.rb +34 -34
- data/lib/fog/profitbricks/requests/compute/create_ip_block.rb +18 -20
- data/lib/fog/profitbricks/requests/compute/create_lan.rb +151 -150
- data/lib/fog/profitbricks/requests/compute/create_load_balancer.rb +67 -26
- data/lib/fog/profitbricks/requests/compute/create_nic.rb +24 -26
- data/lib/fog/profitbricks/requests/compute/create_server.rb +70 -61
- data/lib/fog/profitbricks/requests/compute/create_volume.rb +122 -122
- data/lib/fog/profitbricks/requests/compute/create_volume_snapshot.rb +42 -45
- data/lib/fog/profitbricks/requests/compute/delete_datacenter.rb +34 -36
- data/lib/fog/profitbricks/requests/compute/delete_firewall_rule.rb +8 -11
- data/lib/fog/profitbricks/requests/compute/delete_image.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/delete_ip_block.rb +8 -10
- data/lib/fog/profitbricks/requests/compute/delete_lan.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/delete_load_balancer.rb +8 -10
- data/lib/fog/profitbricks/requests/compute/delete_nic.rb +7 -10
- data/lib/fog/profitbricks/requests/compute/delete_server.rb +6 -10
- data/lib/fog/profitbricks/requests/compute/delete_snapshot.rb +7 -10
- data/lib/fog/profitbricks/requests/compute/delete_volume.rb +36 -38
- data/lib/fog/profitbricks/requests/compute/detach_cdrom.rb +11 -13
- data/lib/fog/profitbricks/requests/compute/detach_volume.rb +16 -13
- data/lib/fog/profitbricks/requests/compute/get_all_datacenters.rb +1 -1
- data/lib/fog/profitbricks/requests/compute/get_all_firewall_rules.rb +6 -7
- data/lib/fog/profitbricks/requests/compute/get_all_flavors.rb +72 -72
- data/lib/fog/profitbricks/requests/compute/get_all_images.rb +62 -62
- data/lib/fog/profitbricks/requests/compute/get_all_ip_blocks.rb +5 -5
- data/lib/fog/profitbricks/requests/compute/get_all_lans.rb +113 -113
- data/lib/fog/profitbricks/requests/compute/get_all_load_balanced_nics.rb +15 -9
- data/lib/fog/profitbricks/requests/compute/get_all_load_balancers.rb +9 -9
- data/lib/fog/profitbricks/requests/compute/get_all_locations.rb +6 -6
- data/lib/fog/profitbricks/requests/compute/get_all_nic.rb +94 -94
- data/lib/fog/profitbricks/requests/compute/get_all_requests.rb +38 -38
- data/lib/fog/profitbricks/requests/compute/get_all_servers.rb +8 -9
- data/lib/fog/profitbricks/requests/compute/get_all_snapshots.rb +4 -4
- data/lib/fog/profitbricks/requests/compute/get_all_volumes.rb +71 -71
- data/lib/fog/profitbricks/requests/compute/get_attached_cdrom.rb +11 -11
- data/lib/fog/profitbricks/requests/compute/get_attached_volume.rb +16 -11
- data/lib/fog/profitbricks/requests/compute/get_datacenter.rb +4 -6
- data/lib/fog/profitbricks/requests/compute/get_firewall_rule.rb +8 -11
- data/lib/fog/profitbricks/requests/compute/get_flavor.rb +9 -9
- data/lib/fog/profitbricks/requests/compute/get_image.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/get_ip_block.rb +8 -10
- data/lib/fog/profitbricks/requests/compute/get_lan.rb +7 -10
- data/lib/fog/profitbricks/requests/compute/get_load_balanced_nic.rb +16 -12
- data/lib/fog/profitbricks/requests/compute/get_load_balancer.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/get_location.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/get_nic.rb +8 -11
- data/lib/fog/profitbricks/requests/compute/get_request.rb +55 -57
- data/lib/fog/profitbricks/requests/compute/get_request_status.rb +44 -46
- data/lib/fog/profitbricks/requests/compute/get_server.rb +7 -10
- data/lib/fog/profitbricks/requests/compute/get_snapshot.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/get_volume.rb +7 -9
- data/lib/fog/profitbricks/requests/compute/list_attached_cdroms.rb +8 -8
- data/lib/fog/profitbricks/requests/compute/list_attached_volumes.rb +18 -8
- data/lib/fog/profitbricks/requests/compute/reboot_server.rb +7 -11
- data/lib/fog/profitbricks/requests/compute/remove_nic_association.rb +9 -11
- data/lib/fog/profitbricks/requests/compute/restore_volume_snapshot.rb +15 -17
- data/lib/fog/profitbricks/requests/compute/start_server.rb +7 -11
- data/lib/fog/profitbricks/requests/compute/stop_server.rb +7 -11
- data/lib/fog/profitbricks/requests/compute/update_datacenter.rb +20 -15
- data/lib/fog/profitbricks/requests/compute/update_firewall_rule.rb +9 -11
- data/lib/fog/profitbricks/requests/compute/update_image.rb +15 -15
- data/lib/fog/profitbricks/requests/compute/update_lan.rb +6 -8
- data/lib/fog/profitbricks/requests/compute/update_load_balancer.rb +10 -12
- data/lib/fog/profitbricks/requests/compute/update_nic.rb +10 -12
- data/lib/fog/profitbricks/requests/compute/update_server.rb +10 -13
- data/lib/fog/profitbricks/requests/compute/update_snapshot.rb +10 -13
- data/lib/fog/profitbricks/requests/compute/update_volume.rb +10 -13
- data/lib/fog/profitbricks/version.rb +1 -1
- data/spec/minitest_helper.rb +1 -3
- data/tests/helpers/formats_helper.rb +8 -8
- data/tests/profitbricks/models/compute/compute_tests.rb +529 -0
- data/tests/profitbricks/requests/compute/composite_create_tests.rb +16 -83
- data/tests/profitbricks/requests/compute/flavor_tests.rb +1 -4
- data/tests/profitbricks/requests/compute/location_tests.rb +14 -17
- data/tests/profitbricks/requests/compute/nic_tests.rb +60 -70
- data/tests/profitbricks/requests/compute/request_tests.rb +1 -3
- data/tests/profitbricks/requests/compute/server_tests.rb +163 -161
- metadata +5 -18
@@ -1,43 +1,43 @@
|
|
1
1
|
module Fog
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
2
|
+
module Compute
|
3
|
+
class ProfitBricks
|
4
|
+
class Real
|
5
|
+
# Retrieves a list of requests
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# * None
|
9
|
+
#
|
10
|
+
# ==== Returns
|
11
|
+
# * response<~Excon::Response>:
|
12
|
+
# * body<~Hash>:
|
13
|
+
# * id<~String> - The resource's unique identifier
|
14
|
+
# * type<~String> - The type of the resource
|
15
|
+
# * href<~String> - URL to the object’s representation (absolute path)
|
16
|
+
# * items<~Hash> - Collection of individual request objects
|
17
|
+
# * id<~String> - The resource's unique identifier
|
18
|
+
# * type<~String> - The type of the resource
|
19
|
+
# * href<~String> - URL to the object’s representation (absolute path)
|
20
|
+
#
|
21
|
+
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-requests]
|
22
|
+
def get_all_requests
|
23
|
+
request(
|
24
|
+
:expects => [200],
|
25
|
+
:method => 'GET',
|
26
|
+
:path => "/requests"
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
class Mock
|
32
|
+
def get_all_requests
|
33
|
+
requests = data[:requests]
|
34
|
+
response = Excon::Response.new
|
35
|
+
response.status = 200
|
36
|
+
response.body = requests
|
37
37
|
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
38
|
+
response
|
41
39
|
end
|
40
|
+
end
|
42
41
|
end
|
43
|
-
end
|
42
|
+
end
|
43
|
+
end
|
@@ -105,27 +105,26 @@ module Fog
|
|
105
105
|
#
|
106
106
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-servers]
|
107
107
|
def get_all_servers(datacenter_id)
|
108
|
-
|
109
108
|
request(
|
110
|
-
|
111
|
-
|
112
|
-
|
109
|
+
:expects => [200],
|
110
|
+
:method => 'GET',
|
111
|
+
:path => "/datacenters/#{datacenter_id}/servers?depth=5"
|
113
112
|
)
|
114
113
|
end
|
115
114
|
end
|
116
115
|
|
117
116
|
class Mock
|
118
117
|
def get_all_servers(datacenter_id)
|
119
|
-
if servs =
|
120
|
-
|
121
|
-
|
118
|
+
if servs = data[:servers]['items'].select do |attrib|
|
119
|
+
attrib['datacenter_id'] == datacenter_id
|
120
|
+
end
|
122
121
|
else
|
123
|
-
raise Fog::Errors::NotFound
|
122
|
+
raise Fog::Errors::NotFound, 'Server resource could not be found'
|
124
123
|
end
|
125
124
|
|
126
125
|
response = Excon::Response.new
|
127
126
|
response.status = 200
|
128
|
-
response.body =
|
127
|
+
response.body = data[:servers]
|
129
128
|
response
|
130
129
|
end
|
131
130
|
end
|
@@ -45,9 +45,9 @@ module Fog
|
|
45
45
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-snapshots]
|
46
46
|
def get_all_snapshots
|
47
47
|
request(
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
:expects => [200],
|
49
|
+
:method => 'GET',
|
50
|
+
:path => "/snapshots?depth=5"
|
51
51
|
)
|
52
52
|
end
|
53
53
|
end
|
@@ -56,7 +56,7 @@ module Fog
|
|
56
56
|
def get_all_snapshots
|
57
57
|
response = Excon::Response.new
|
58
58
|
response.status = 200
|
59
|
-
response.body =
|
59
|
+
response.body = data[:snapshots]
|
60
60
|
|
61
61
|
response
|
62
62
|
end
|
@@ -1,78 +1,78 @@
|
|
1
1
|
module Fog
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
2
|
+
module Compute
|
3
|
+
class ProfitBricks
|
4
|
+
class Real
|
5
|
+
# Retrieve a list of all volumes
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# * datacenter_id - UUID of the datacenter which contains the volumes
|
9
|
+
#
|
10
|
+
# ==== Returns
|
11
|
+
# * response<~Excon::Response>:
|
12
|
+
# * body<~Hash>:
|
13
|
+
# * id<~String> - Id of the requested resource
|
14
|
+
# * type<~String> - type of the requested resource
|
15
|
+
# * href<~String> - url to the requested resource
|
16
|
+
# * items<~Array>
|
17
|
+
# * id<~String> - The resource's unique identifier
|
18
|
+
# * type<~String> - The type of the requested resource
|
19
|
+
# * href<~String> - URL to the object’s representation (absolute path)
|
20
|
+
# * metadata<~Hash> - Hash containing the volume metadata
|
21
|
+
# * createdDate<~String> - The date the resource was created
|
22
|
+
# * createdBy<~String> - The user who created the resource
|
23
|
+
# * etag<~String> - The etag for the resource
|
24
|
+
# * lastModifiedDate<~String> - The last time the resource has been modified
|
25
|
+
# * lastModifiedBy<~String> - The user who last modified the resource
|
26
|
+
# * state<~String> - Volume state
|
27
|
+
# * properties<~Hash> - Hash containing the volume properties
|
28
|
+
# * name<~String> - The name of the volume.
|
29
|
+
# * type<~String> - The volume type, HDD or SSD.
|
30
|
+
# * size<~Integer> - The size of the volume in GB.
|
31
|
+
# * image<~String> - The image or snapshot ID.
|
32
|
+
# * imagePassword<~Boolean> - Indicates if a password is set on the image.
|
33
|
+
# * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO.
|
34
|
+
# * licenceType<~String> - Volume licence type. ( WINDOWS, LINUX, OTHER, UNKNOWN)
|
35
|
+
# * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required)
|
36
|
+
# * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required)
|
37
|
+
# * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required)
|
38
|
+
# * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required)
|
39
|
+
# * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required)
|
40
|
+
# * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required)
|
41
|
+
# * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required)
|
42
|
+
# * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required)
|
43
|
+
# * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required)
|
44
|
+
# * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required)
|
45
|
+
# * deviceNumber<~Integer> - The LUN ID of the storage volume
|
46
|
+
#
|
47
|
+
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-volumes]
|
48
|
+
def get_all_volumes(datacenter_id)
|
49
|
+
request(
|
50
|
+
:expects => [200],
|
51
|
+
:method => 'GET',
|
52
|
+
:path => "/datacenters/#{datacenter_id}/volumes?depth=5"
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
class Mock
|
58
|
+
def get_all_volumes(datacenter_id)
|
59
|
+
volumes = data[:volumes]
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
61
|
+
if vlms = data[:volumes]['items'].select do |attrib|
|
62
|
+
attrib['datacenter_id'] == datacenter_id
|
63
|
+
end
|
64
|
+
else
|
65
|
+
raise Fog::Errors::NotFound, 'Volume resource could not be found'
|
66
|
+
end
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
volumes['items'] = vlms
|
69
|
+
response = Excon::Response.new
|
70
|
+
response.status = 200
|
71
|
+
response.body = data[:volumes]
|
72
72
|
|
73
|
-
|
74
|
-
end
|
75
|
-
end
|
73
|
+
response
|
76
74
|
end
|
75
|
+
end
|
77
76
|
end
|
78
|
-
end
|
77
|
+
end
|
78
|
+
end
|
@@ -44,27 +44,27 @@ module Fog
|
|
44
44
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#retrieve-attached-cd-rom]
|
45
45
|
def get_attached_cdrom(datacenter_id, server_id, cdrom_image_id)
|
46
46
|
request(
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
:expects => [200],
|
48
|
+
:method => 'GET',
|
49
|
+
:path => "/datacenters/#{datacenter_id}/servers/#{server_id}/cdroms/#{cdrom_image_id}?depth=1"
|
50
50
|
)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
class Mock
|
55
55
|
def get_attached_cdrom(datacenter_id, server_id, cdrom_image_id)
|
56
|
-
if server =
|
57
|
-
|
58
|
-
|
56
|
+
if server = data[:servers]['items'].find do |serv|
|
57
|
+
serv['datacenter_id'] == datacenter_id && serv['id'] == server_id
|
58
|
+
end
|
59
59
|
else
|
60
|
-
raise Fog::Errors::NotFound
|
60
|
+
raise Fog::Errors::NotFound, "The server resource could not be found"
|
61
61
|
end
|
62
62
|
|
63
|
-
if cdrom = server['entities']['cdroms']['items'].find
|
64
|
-
|
65
|
-
|
63
|
+
if cdrom = server['entities']['cdroms']['items'].find do |cd|
|
64
|
+
cd['id'] == cdrom_image_id
|
65
|
+
end
|
66
66
|
else
|
67
|
-
raise Fog::Errors::NotFound
|
67
|
+
raise Fog::Errors::NotFound, "The attached volume resource could not be found"
|
68
68
|
end
|
69
69
|
|
70
70
|
response = Excon::Response.new
|
@@ -45,27 +45,32 @@ module Fog
|
|
45
45
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#retrieve-an-attached-volume]
|
46
46
|
def get_attached_volume(datacenter_id, server_id, volume_id)
|
47
47
|
request(
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
:expects => [200],
|
49
|
+
:method => 'GET',
|
50
|
+
:path => "/datacenters/#{datacenter_id}/servers/#{server_id}/volumes/#{volume_id}?depth=1"
|
51
51
|
)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
55
|
class Mock
|
56
56
|
def get_attached_volume(datacenter_id, server_id, volume_id)
|
57
|
-
if server =
|
58
|
-
|
59
|
-
|
57
|
+
if server = data[:servers]['items'].find do |serv|
|
58
|
+
serv['datacenter_id'] == datacenter_id && serv['id'] == server_id
|
59
|
+
end
|
60
60
|
else
|
61
|
-
raise Fog::Errors::NotFound
|
61
|
+
raise Fog::Errors::NotFound, "The server resource could not be found"
|
62
62
|
end
|
63
63
|
|
64
|
-
if
|
65
|
-
|
66
|
-
|
64
|
+
if server['entities']
|
65
|
+
volume = server['entities']['volumes']['items'].find do |vlm|
|
66
|
+
vlm['id'] == volume_id
|
67
|
+
end
|
68
|
+
elsif server['volumes']
|
69
|
+
volume = server['volumes']['items'].find do |vlm|
|
70
|
+
vlm['id'] == volume_id
|
71
|
+
end
|
67
72
|
else
|
68
|
-
raise Fog::Errors::NotFound
|
73
|
+
raise Fog::Errors::NotFound, "The attached volume resource could not be found"
|
69
74
|
end
|
70
75
|
|
71
76
|
response = Excon::Response.new
|
@@ -40,18 +40,16 @@ module Fog
|
|
40
40
|
:method => "GET",
|
41
41
|
:path => "/datacenters/#{datacenter_id}?depth=5"
|
42
42
|
)
|
43
|
-
rescue => error
|
44
|
-
Fog::Errors::NotFound.new(error)
|
45
43
|
end
|
46
44
|
end
|
47
45
|
|
48
46
|
class Mock
|
49
47
|
def get_datacenter(datacenter_id)
|
50
|
-
if dc =
|
51
|
-
|
52
|
-
|
48
|
+
if dc = data[:datacenters]["items"].find do |datacenter|
|
49
|
+
datacenter["id"] == datacenter_id
|
50
|
+
end
|
53
51
|
else
|
54
|
-
raise
|
52
|
+
raise Excon::Error::HTTPStatus, "The requested resource could not be found"
|
55
53
|
end
|
56
54
|
|
57
55
|
response = Excon::Response.new
|
@@ -41,23 +41,20 @@ module Fog
|
|
41
41
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#get-firewall-rule]
|
42
42
|
def get_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id)
|
43
43
|
request(
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
:expects => [200],
|
45
|
+
:method => "GET",
|
46
|
+
:path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}/firewallrules/#{firewall_rule_id}?depth=5"
|
47
47
|
)
|
48
|
-
rescue => error
|
49
|
-
Fog::Errors::NotFound.new(error)
|
50
48
|
end
|
51
|
-
|
52
49
|
end
|
53
50
|
|
54
51
|
class Mock
|
55
52
|
def get_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id)
|
56
|
-
if firewall_rule =
|
57
|
-
|
58
|
-
|
53
|
+
if firewall_rule = data[:firewall_rules]['items'].find do |fwr|
|
54
|
+
fwr["datacenter_id"] == datacenter_id && fwr["server_id"] == server_id && fwr["nic_id"] == nic_id && fwr["id"] == firewall_rule_id
|
55
|
+
end
|
59
56
|
else
|
60
|
-
raise Fog::Errors::NotFound
|
57
|
+
raise Fog::Errors::NotFound, "The requested resource could not be found"
|
61
58
|
end
|
62
59
|
|
63
60
|
response = Excon::Response.new
|
@@ -68,4 +65,4 @@ module Fog
|
|
68
65
|
end
|
69
66
|
end
|
70
67
|
end
|
71
|
-
end
|
68
|
+
end
|
@@ -34,27 +34,27 @@ module Fog
|
|
34
34
|
{
|
35
35
|
"flavorId" => "0052db40-f1dd-4ecf-a711-5980081b7059",
|
36
36
|
"flavorName" => "Extra Large",
|
37
|
-
"ram" =>
|
37
|
+
"ram" => 14_336,
|
38
38
|
"cores" => 8
|
39
39
|
},
|
40
40
|
{
|
41
41
|
"flavorId" => "8b2b835d-be09-48cf-aae2-7e35aafe92d6",
|
42
42
|
"flavorName" => "Memory Intensive Small",
|
43
|
-
"ram" =>
|
43
|
+
"ram" => 16_384,
|
44
44
|
"cores" => 2
|
45
45
|
},
|
46
46
|
{
|
47
47
|
"flavorId" => "45c28f8b-6a67-4f69-8c94-231d371da2b6",
|
48
48
|
"flavorName" => "Memory Intensive Medium",
|
49
|
-
"ram" =>
|
49
|
+
"ram" => 28_672,
|
50
50
|
"cores" => 4
|
51
51
|
},
|
52
52
|
{
|
53
53
|
"flavorId" => "1d22436d-d958-4151-b144-43a8e180c4c4",
|
54
54
|
"flavorName" => "Memory Intensive Large",
|
55
|
-
"ram" =>
|
55
|
+
"ram" => 57_344,
|
56
56
|
"cores" => 8
|
57
|
-
}
|
57
|
+
}
|
58
58
|
].find { |flavor| flavor["flavorId"] == flavor_id } || raise(Fog::Errors::NotFound)
|
59
59
|
}
|
60
60
|
response
|
@@ -66,11 +66,11 @@ module Fog
|
|
66
66
|
response = Excon::Response.new
|
67
67
|
response.status = 200
|
68
68
|
|
69
|
-
if flavor =
|
70
|
-
|
71
|
-
|
69
|
+
if flavor = data[:flavors].find do |attrib|
|
70
|
+
attrib["flavorId"] == flavor_id
|
71
|
+
end
|
72
72
|
else
|
73
|
-
raise Fog::Errors::NotFound
|
73
|
+
raise Fog::Errors::NotFound, "The requested flavor could not be found"
|
74
74
|
end
|
75
75
|
|
76
76
|
response.body = { "getFlavorResponse" => flavor }
|