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
@@ -42,67 +42,64 @@ module Fog
|
|
42
42
|
# * licenceType<~String> - The snapshot's licence type: LINUX, WINDOWS, or UNKNOWN
|
43
43
|
#
|
44
44
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-volume-snapshot]
|
45
|
-
def create_volume_snapshot(datacenter_id, volume_id, options={})
|
46
|
-
if options[:name]
|
47
|
-
body = [["name", options[:name]]]
|
48
|
-
end
|
45
|
+
def create_volume_snapshot(datacenter_id, volume_id, options = {})
|
46
|
+
body = [["name", options[:name]]] if options[:name]
|
49
47
|
|
50
48
|
request(
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
49
|
+
:expects => [202],
|
50
|
+
:method => 'POST',
|
51
|
+
:path => "/datacenters/#{datacenter_id}/volumes/#{volume_id}/create-snapshot",
|
52
|
+
:headers => { "Content-Type" => "application/x-www-form-urlencoded" },
|
53
|
+
:body => URI.encode_www_form(body)
|
56
54
|
)
|
57
|
-
rescue => error
|
58
|
-
Fog::Errors::NotFound.new(error)
|
59
55
|
end
|
60
56
|
end
|
61
57
|
|
62
58
|
class Mock
|
63
|
-
def create_volume_snapshot(datacenter_id,
|
59
|
+
def create_volume_snapshot(datacenter_id, _volume_id, options = {})
|
64
60
|
response = Excon::Response.new
|
65
61
|
response.status = 202
|
66
62
|
|
67
|
-
if datacenter =
|
68
|
-
|
69
|
-
|
63
|
+
if datacenter = data[:datacenters]['items'].find do |attrib|
|
64
|
+
attrib['id'] == datacenter_id
|
65
|
+
end
|
70
66
|
else
|
71
|
-
raise
|
67
|
+
raise Excon::Error::HTTPStatus, 'Data center resource could not be found'
|
72
68
|
end
|
73
69
|
|
70
|
+
snapshot_id = Fog::UUID.uuid
|
74
71
|
snapshot = {
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
72
|
+
'id' => snapshot_id,
|
73
|
+
'type' => 'snapshot',
|
74
|
+
'href' => "https =>//api.profitbricks.com/rest/v2/snapshots/#{snapshot_id}",
|
75
|
+
'metadata' => {
|
76
|
+
'createdDate' => '2016-08-07T22:28:39Z',
|
77
|
+
'createdBy' => 'test@stackpointcloud.com',
|
78
|
+
'etag' => '83ad78a4757ab0d9bdeaebc3a6485dcf',
|
79
|
+
'lastModifiedDate' => '2016-08-07T22:28:39Z',
|
80
|
+
'lastModifiedBy' => 'test@stackpointcloud.com',
|
81
|
+
'state' => 'AVAILABLE'
|
82
|
+
},
|
83
|
+
'properties' => {
|
84
|
+
'name' => options[:name],
|
85
|
+
'description' => options[:description],
|
86
|
+
'location' => 'us/las',
|
87
|
+
'size' => 6,
|
88
|
+
'cpuHotPlug' => 'true',
|
89
|
+
'cpuHotUnplug' => 'false',
|
90
|
+
'ramHotPlug' => 'false',
|
91
|
+
'ramHotUnplug' => 'false',
|
92
|
+
'nicHotPlug' => 'true',
|
93
|
+
'nicHotUnplug' => 'true',
|
94
|
+
'discVirtioHotPlug' => 'true',
|
95
|
+
'discVirtioHotUnplug' => 'true',
|
96
|
+
'discScsiHotPlug' => 'false',
|
97
|
+
'discScsiHotUnplug' => 'false',
|
98
|
+
'licenceType' => 'OTHER'
|
99
|
+
}
|
103
100
|
}
|
104
101
|
|
105
|
-
|
102
|
+
data[:snapshots]['items'] << snapshot
|
106
103
|
|
107
104
|
response.body = snapshot
|
108
105
|
response
|
@@ -1,43 +1,41 @@
|
|
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
|
-
end
|
24
|
-
end
|
2
|
+
module Compute
|
3
|
+
class ProfitBricks
|
4
|
+
class Real
|
5
|
+
# Delete virtual data center
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# * datacenter_id<~String> - The UUID of the data center
|
9
|
+
#
|
10
|
+
# ==== Returns
|
11
|
+
# * response<~Excon::Response> - No response parameters
|
12
|
+
# (HTTP/1.1 202 Accepted)
|
13
|
+
#
|
14
|
+
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-a-data-center]
|
15
|
+
def delete_datacenter(datacenter_id)
|
16
|
+
request(
|
17
|
+
:expects => [202],
|
18
|
+
:method => 'DELETE',
|
19
|
+
:path => "/datacenters/#{datacenter_id}"
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
class Mock
|
25
|
+
def delete_datacenter(datacenter_id)
|
26
|
+
response = Excon::Response.new
|
27
|
+
response.status = 202
|
30
28
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
29
|
+
if dc = data[:datacenters]["items"].find do |datacenter|
|
30
|
+
datacenter["id"] == datacenter_id
|
31
|
+
end
|
32
|
+
else
|
33
|
+
raise Excon::Error::HTTPStatus, "The requested resource could not be found"
|
34
|
+
end
|
37
35
|
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
36
|
+
response
|
41
37
|
end
|
38
|
+
end
|
42
39
|
end
|
40
|
+
end
|
43
41
|
end
|
@@ -17,12 +17,10 @@ module Fog
|
|
17
17
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-firewall-rule]
|
18
18
|
def delete_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id)
|
19
19
|
request(
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
:expects => [202],
|
21
|
+
:method => 'DELETE',
|
22
|
+
:path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}/firewallrules/#{firewall_rule_id}"
|
23
23
|
)
|
24
|
-
rescue => error
|
25
|
-
Fog::Errors::NotFound.new(error)
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
@@ -31,12 +29,11 @@ module Fog
|
|
31
29
|
response = Excon::Response.new
|
32
30
|
response.status = 202
|
33
31
|
|
34
|
-
if firewall_rule =
|
35
|
-
|
36
|
-
|
37
|
-
}
|
32
|
+
if firewall_rule = data[:firewall_rules]["items"].find do |attribute|
|
33
|
+
attribute["datacenter_id"] == datacenter_id && attribute["server_id"] == server_id && attribute["nic_id"] == nic_id && attribute["id"] == firewall_rule_id
|
34
|
+
end
|
38
35
|
else
|
39
|
-
raise Fog::Errors::NotFound
|
36
|
+
raise Fog::Errors::NotFound, "The requested firewall rule resource could not be found"
|
40
37
|
end
|
41
38
|
|
42
39
|
response
|
@@ -44,4 +41,4 @@ module Fog
|
|
44
41
|
end
|
45
42
|
end
|
46
43
|
end
|
47
|
-
end
|
44
|
+
end
|
@@ -14,12 +14,10 @@ module Fog
|
|
14
14
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-image]
|
15
15
|
def delete_image(image_id)
|
16
16
|
request(
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
:expects => [202],
|
18
|
+
:method => 'DELETE',
|
19
|
+
:path => "/images/#{image_id}"
|
20
20
|
)
|
21
|
-
rescue => error
|
22
|
-
Fog::Errors::NotFound.new(error)
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
@@ -28,11 +26,11 @@ module Fog
|
|
28
26
|
response = Excon::Response.new
|
29
27
|
response.status = 202
|
30
28
|
|
31
|
-
if img =
|
32
|
-
|
33
|
-
|
29
|
+
if img = data[:images]["items"].find do |image|
|
30
|
+
image["id"] == image_id
|
31
|
+
end
|
34
32
|
else
|
35
|
-
raise Fog::Errors::NotFound
|
33
|
+
raise Fog::Errors::NotFound, "The requested resource could not be found"
|
36
34
|
end
|
37
35
|
|
38
36
|
response
|
@@ -14,12 +14,10 @@ module Fog
|
|
14
14
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-ip-block]
|
15
15
|
def delete_ip_block(ip_block_id)
|
16
16
|
request(
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
:expects => [202],
|
18
|
+
:method => 'DELETE',
|
19
|
+
:path => "/ipblocks/#{ip_block_id}"
|
20
20
|
)
|
21
|
-
rescue => error
|
22
|
-
Fog::Errors::NotFound.new(error)
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
@@ -28,11 +26,11 @@ module Fog
|
|
28
26
|
response = Excon::Response.new
|
29
27
|
response.status = 202
|
30
28
|
|
31
|
-
if ip_block =
|
32
|
-
|
33
|
-
|
29
|
+
if ip_block = data[:ip_blocks]["items"].find do |attribute|
|
30
|
+
attribute["id"] == ip_block_id
|
31
|
+
end
|
34
32
|
else
|
35
|
-
raise Fog::Errors::NotFound
|
33
|
+
raise Fog::Errors::NotFound, "The requested IP Block could not be found"
|
36
34
|
end
|
37
35
|
|
38
36
|
response
|
@@ -40,4 +38,4 @@ module Fog
|
|
40
38
|
end
|
41
39
|
end
|
42
40
|
end
|
43
|
-
end
|
41
|
+
end
|
@@ -15,12 +15,10 @@ module Fog
|
|
15
15
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-lan]
|
16
16
|
def delete_lan(datacenter_id, lan_id)
|
17
17
|
request(
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
:expects => [202],
|
19
|
+
:method => 'DELETE',
|
20
|
+
:path => "/datacenters/#{datacenter_id}/lans/#{lan_id}"
|
21
21
|
)
|
22
|
-
rescue => error
|
23
|
-
Fog::Errors::NotFound.new(error)
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
@@ -29,11 +27,11 @@ module Fog
|
|
29
27
|
response = Excon::Response.new
|
30
28
|
response.status = 202
|
31
29
|
|
32
|
-
if lan =
|
33
|
-
|
34
|
-
|
30
|
+
if lan = data[:lans]["items"].find do |attribute|
|
31
|
+
attribute["datacenter_id"] == datacenter_id && attribute["id"] == lan_id
|
32
|
+
end
|
35
33
|
else
|
36
|
-
raise Fog::Errors::NotFound
|
34
|
+
raise Fog::Errors::NotFound, "The requested lan could not be found"
|
37
35
|
end
|
38
36
|
|
39
37
|
response
|
@@ -15,12 +15,10 @@ module Fog
|
|
15
15
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-load-balancer]
|
16
16
|
def delete_load_balancer(datacenter_id, load_balancer_id)
|
17
17
|
request(
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
:expects => [202],
|
19
|
+
:method => 'DELETE',
|
20
|
+
:path => "/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}"
|
21
21
|
)
|
22
|
-
rescue => error
|
23
|
-
Fog::Errors::NotFound.new(error)
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
@@ -29,11 +27,11 @@ module Fog
|
|
29
27
|
response = Excon::Response.new
|
30
28
|
response.status = 202
|
31
29
|
|
32
|
-
if lb =
|
33
|
-
|
34
|
-
|
30
|
+
if lb = data[:load_balancers]["items"].find do |attribute|
|
31
|
+
attribute["datacenter_id"] == datacenter_id && attribute["id"] == load_balancer_id
|
32
|
+
end
|
35
33
|
else
|
36
|
-
raise Fog::Errors::NotFound
|
34
|
+
raise Fog::Errors::NotFound, "The requested resource could not be found"
|
37
35
|
end
|
38
36
|
|
39
37
|
response
|
@@ -41,4 +39,4 @@ module Fog
|
|
41
39
|
end
|
42
40
|
end
|
43
41
|
end
|
44
|
-
end
|
42
|
+
end
|
@@ -16,12 +16,10 @@ module Fog
|
|
16
16
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-a-nic]
|
17
17
|
def delete_nic(datacenter_id, server_id, nic_id)
|
18
18
|
request(
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
:expects => [202],
|
20
|
+
:method => 'DELETE',
|
21
|
+
:path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}"
|
22
22
|
)
|
23
|
-
rescue => error
|
24
|
-
Fog::Errors::NotFound.new(error)
|
25
23
|
end
|
26
24
|
end
|
27
25
|
|
@@ -30,12 +28,11 @@ module Fog
|
|
30
28
|
response = Excon::Response.new
|
31
29
|
response.status = 202
|
32
30
|
|
33
|
-
if nic =
|
34
|
-
|
35
|
-
|
36
|
-
}
|
31
|
+
if nic = data[:nics]["items"].find do |attribute|
|
32
|
+
attribute["datacenter_id"] == datacenter_id && attribute["server_id"] == server_id && attribute["id"] == nic_id
|
33
|
+
end
|
37
34
|
else
|
38
|
-
raise Fog::Errors::NotFound
|
35
|
+
raise Fog::Errors::NotFound, "The requested nic resource could not be found"
|
39
36
|
end
|
40
37
|
|
41
38
|
response
|
@@ -21,21 +21,17 @@ module Fog
|
|
21
21
|
:method => 'DELETE',
|
22
22
|
:path => "/datacenters/#{datacenter_id}/servers/#{server_id}"
|
23
23
|
)
|
24
|
-
rescue => error
|
25
|
-
Fog::Errors::NotFound.new(error)
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
29
27
|
class Mock
|
30
28
|
def delete_server(datacenter_id, server_id)
|
31
|
-
if server =
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
if server = data[:servers]['items'].find do |attrib|
|
30
|
+
attrib['datacenter_id'] == datacenter_id && attrib['id'] == server_id
|
31
|
+
end
|
32
|
+
data[:servers].delete(server)
|
35
33
|
else
|
36
|
-
raise Fog::Errors::NotFound
|
37
|
-
'The requested server resource could not be found'
|
38
|
-
)
|
34
|
+
raise Fog::Errors::NotFound, 'The requested server resource could not be found'
|
39
35
|
end
|
40
36
|
|
41
37
|
response = Excon::Response.new
|
@@ -45,4 +41,4 @@ module Fog
|
|
45
41
|
end
|
46
42
|
end
|
47
43
|
end
|
48
|
-
end
|
44
|
+
end
|
@@ -13,13 +13,10 @@ module Fog
|
|
13
13
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-snapshot]
|
14
14
|
def delete_snapshot(snapshot_id)
|
15
15
|
request(
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
:expects => [202],
|
17
|
+
:method => 'DELETE',
|
18
|
+
:path => "/snapshots/#{snapshot_id}"
|
19
19
|
)
|
20
|
-
rescue => error
|
21
|
-
puts error
|
22
|
-
Fog::Errors::NotFound.new(error)
|
23
20
|
end
|
24
21
|
end
|
25
22
|
|
@@ -28,11 +25,11 @@ module Fog
|
|
28
25
|
response = Excon::Response.new
|
29
26
|
response.status = 202
|
30
27
|
|
31
|
-
if snapshot =
|
32
|
-
|
33
|
-
|
28
|
+
if snapshot = data[:snapshots]['items'].find do |attrib|
|
29
|
+
attrib['id'] == snapshot_id
|
30
|
+
end
|
34
31
|
else
|
35
|
-
raise Fog::Errors::NotFound
|
32
|
+
raise Fog::Errors::NotFound, 'The requested resource could not be found'
|
36
33
|
end
|
37
34
|
|
38
35
|
response
|