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
@@ -103,23 +103,20 @@ module Fog
|
|
103
103
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#retrieve-a-server]
|
104
104
|
def get_server(datacenter_id, server_id)
|
105
105
|
request(
|
106
|
-
|
107
|
-
|
108
|
-
|
106
|
+
:expects => [200],
|
107
|
+
:method => "GET",
|
108
|
+
:path => "/datacenters/#{datacenter_id}/servers/#{server_id}?depth=5"
|
109
109
|
)
|
110
|
-
rescue => error
|
111
|
-
Fog::Errors::NotFound.new(error)
|
112
110
|
end
|
113
111
|
end
|
114
112
|
|
115
113
|
class Mock
|
116
114
|
def get_server(datacenter_id, server_id)
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
}
|
115
|
+
if server = data[:servers]['items'].find do |serv|
|
116
|
+
serv['datacenter_id'] == datacenter_id && serv['id'] == server_id
|
117
|
+
end
|
121
118
|
else
|
122
|
-
raise Fog::Errors::NotFound
|
119
|
+
raise Fog::Errors::NotFound, "The server resource could not be found"
|
123
120
|
end
|
124
121
|
|
125
122
|
response = Excon::Response.new
|
@@ -41,22 +41,20 @@ module Fog
|
|
41
41
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#get-snapshot]
|
42
42
|
def get_snapshot(snapshot_id)
|
43
43
|
request(
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
:expects => [200],
|
45
|
+
:method => "GET",
|
46
|
+
:path => "/snapshots/#{snapshot_id}"
|
47
47
|
)
|
48
|
-
rescue => error
|
49
|
-
Fog::Errors::NotFound.new(error)
|
50
48
|
end
|
51
49
|
end
|
52
50
|
|
53
51
|
class Mock
|
54
52
|
def get_snapshot(snapshot_id)
|
55
|
-
if snapshot =
|
56
|
-
|
57
|
-
|
53
|
+
if snapshot = data[:snapshots]['items'].find do |attrib|
|
54
|
+
attrib["id"] == snapshot_id
|
55
|
+
end
|
58
56
|
else
|
59
|
-
raise
|
57
|
+
raise Excon::Error::HTTPStatus, "The requested resource could not be found"
|
60
58
|
end
|
61
59
|
|
62
60
|
response = Excon::Response.new
|
@@ -44,22 +44,20 @@ module Fog
|
|
44
44
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#get-volume]
|
45
45
|
def get_volume(datacenter_id, volume_id)
|
46
46
|
request(
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
:expects => [200],
|
48
|
+
:method => "GET",
|
49
|
+
:path => "/datacenters/#{datacenter_id}/volumes/#{volume_id}"
|
50
50
|
)
|
51
|
-
rescue => error
|
52
|
-
Fog::Errors::NotFound.new(error)
|
53
51
|
end
|
54
52
|
end
|
55
53
|
|
56
54
|
class Mock
|
57
55
|
def get_volume(datacenter_id, volume_id)
|
58
|
-
if volume =
|
59
|
-
|
60
|
-
|
56
|
+
if volume = data[:volumes]['items'].find do |vlm|
|
57
|
+
vlm["id"] == volume_id && vlm["datacenter_id"] == datacenter_id
|
58
|
+
end
|
61
59
|
else
|
62
|
-
raise
|
60
|
+
raise Excon::Error::HTTPStatus, "The requested resource could not be found"
|
63
61
|
end
|
64
62
|
|
65
63
|
response = Excon::Response.new
|
@@ -47,25 +47,25 @@ module Fog
|
|
47
47
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-attached-cd-roms]
|
48
48
|
def list_attached_cdroms(datacenter_id, server_id)
|
49
49
|
request(
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
:expects => [200],
|
51
|
+
:method => 'GET',
|
52
|
+
:path => "/datacenters/#{datacenter_id}/servers/#{server_id}/cdroms?depth=1"
|
53
53
|
)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
class Mock
|
58
58
|
def list_attached_cdroms(datacenter_id, server_id)
|
59
|
-
if server =
|
60
|
-
|
61
|
-
|
59
|
+
if server = data[:servers]['items'].find do |serv|
|
60
|
+
serv['datacenter_id'] == datacenter_id && serv['id'] == server_id
|
61
|
+
end
|
62
62
|
else
|
63
|
-
raise Fog::Errors::NotFound
|
63
|
+
raise Fog::Errors::NotFound, "The server resource could not be found"
|
64
64
|
end
|
65
65
|
|
66
66
|
response = Excon::Response.new
|
67
67
|
response.status = 200
|
68
|
-
response.body =
|
68
|
+
response.body = data[:images]
|
69
69
|
response
|
70
70
|
end
|
71
71
|
end
|
@@ -48,25 +48,35 @@ module Fog
|
|
48
48
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#list-attached-volumes]
|
49
49
|
def list_attached_volumes(datacenter_id, server_id)
|
50
50
|
request(
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
:expects => [200],
|
52
|
+
:method => 'GET',
|
53
|
+
:path => "/datacenters/#{datacenter_id}/servers/#{server_id}/volumes?depth=1"
|
54
54
|
)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
class Mock
|
59
59
|
def list_attached_volumes(datacenter_id, server_id)
|
60
|
-
if server =
|
61
|
-
|
62
|
-
|
60
|
+
if server = data[:servers]['items'].find do |serv|
|
61
|
+
serv['datacenter_id'] == datacenter_id && serv['id'] == server_id
|
62
|
+
end
|
63
63
|
else
|
64
|
-
raise Fog::Errors::NotFound
|
64
|
+
raise Fog::Errors::NotFound, "The server resource could not be found"
|
65
65
|
end
|
66
66
|
|
67
67
|
response = Excon::Response.new
|
68
68
|
response.status = 200
|
69
|
-
response.body
|
69
|
+
response.body = if server['entities'] && server['entities']['volumes']
|
70
|
+
server['entities']['volumes']
|
71
|
+
else
|
72
|
+
{
|
73
|
+
'id' => "#{server_id}/volumes",
|
74
|
+
'type' => 'collection',
|
75
|
+
'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/volumes",
|
76
|
+
'items' => []
|
77
|
+
}
|
78
|
+
end
|
79
|
+
|
70
80
|
response
|
71
81
|
end
|
72
82
|
end
|
@@ -17,24 +17,20 @@ module Fog
|
|
17
17
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#reboot-a-server]
|
18
18
|
def reboot_server(datacenter_id, server_id)
|
19
19
|
request(
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
:expects => [202],
|
21
|
+
:method => 'POST',
|
22
|
+
:path => "/datacenters/#{datacenter_id}/servers/#{server_id}/reboot"
|
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 reboot_server(datacenter_id, server_id)
|
31
|
-
if server =
|
32
|
-
|
33
|
-
|
29
|
+
if server = data[:servers]['items'].find do |attrib|
|
30
|
+
attrib['datacenter_id'] == datacenter_id && attrib['id'] == server_id
|
31
|
+
end
|
34
32
|
else
|
35
|
-
raise Fog::Errors::NotFound
|
36
|
-
'The requested server resource could not be found'
|
37
|
-
)
|
33
|
+
raise Fog::Errors::NotFound, 'The requested server resource could not be found'
|
38
34
|
end
|
39
35
|
|
40
36
|
response = Excon::Response.new
|
@@ -16,22 +16,20 @@ module Fog
|
|
16
16
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#remove-a-nic-association]
|
17
17
|
def remove_nic_association(datacenter_id, load_balancer_id, nic_id)
|
18
18
|
request(
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
:expects => [202],
|
20
|
+
:method => 'DELETE',
|
21
|
+
:path => "/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}/balancednics/#{nic_id}"
|
22
22
|
)
|
23
|
-
rescue => error
|
24
|
-
Fog::Errors::NotFound.new(error)
|
25
23
|
end
|
26
24
|
end
|
27
25
|
|
28
26
|
class Mock
|
29
|
-
def remove_nic_association(datacenter_id, load_balancer_id,
|
30
|
-
if load_balancer =
|
31
|
-
|
32
|
-
|
27
|
+
def remove_nic_association(datacenter_id, load_balancer_id, _nic_id)
|
28
|
+
if load_balancer = data[:load_balancers]['items'].find do |lb|
|
29
|
+
lb["datacenter_id"] == datacenter_id && lb["id"] == load_balancer_id
|
30
|
+
end
|
33
31
|
else
|
34
|
-
raise Fog::Errors::NotFound
|
32
|
+
raise Fog::Errors::NotFound, "The requested resource could not be found"
|
35
33
|
end
|
36
34
|
|
37
35
|
response = Excon::Response.new
|
@@ -41,4 +39,4 @@ module Fog
|
|
41
39
|
end
|
42
40
|
end
|
43
41
|
end
|
44
|
-
end
|
42
|
+
end
|
@@ -21,36 +21,34 @@ module Fog
|
|
21
21
|
# * Connection<~String>
|
22
22
|
#
|
23
23
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-volume-snapshot]
|
24
|
-
def restore_volume_snapshot(datacenter_id, volume_id, options={})
|
24
|
+
def restore_volume_snapshot(datacenter_id, volume_id, options = {})
|
25
25
|
request(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
:expects => [202],
|
27
|
+
:method => 'POST',
|
28
|
+
:path => "/datacenters/#{datacenter_id}/volumes/#{volume_id}/restore-snapshot",
|
29
|
+
:headers => { "Content-Type" => "application/x-www-form-urlencoded" },
|
30
|
+
:body => URI.encode_www_form("snapshotId" => options[:snapshot_id])
|
31
31
|
)
|
32
|
-
rescue => error
|
33
|
-
Fog::Errors::NotFound.new(error)
|
34
32
|
end
|
35
33
|
end
|
36
34
|
|
37
35
|
class Mock
|
38
|
-
def restore_volume_snapshot(datacenter_id, volume_id,
|
36
|
+
def restore_volume_snapshot(datacenter_id, volume_id, _options = {})
|
39
37
|
response = Excon::Response.new
|
40
38
|
response.status = 202
|
41
39
|
|
42
|
-
if datacenter =
|
43
|
-
|
44
|
-
|
40
|
+
if datacenter = data[:datacenters]['items'].find do |attrib|
|
41
|
+
attrib['id'] == datacenter_id
|
42
|
+
end
|
45
43
|
else
|
46
|
-
raise
|
44
|
+
raise Excon::Error::HTTPStatus, 'Data center resource could not be found'
|
47
45
|
end
|
48
46
|
|
49
|
-
if volume =
|
50
|
-
|
51
|
-
|
47
|
+
if volume = data[:volumes]['items'].find do |attrib|
|
48
|
+
attrib['id'] == volume_id && attrib['datacenter_id'] == datacenter_id
|
49
|
+
end
|
52
50
|
else
|
53
|
-
raise
|
51
|
+
raise Excon::Error::HTTPStatus, 'Volume resource could not be found'
|
54
52
|
end
|
55
53
|
|
56
54
|
response
|
@@ -16,24 +16,20 @@ module Fog
|
|
16
16
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#start-a-server]
|
17
17
|
def start_server(datacenter_id, server_id)
|
18
18
|
request(
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
:expects => [202],
|
20
|
+
:method => 'POST',
|
21
|
+
:path => "/datacenters/#{datacenter_id}/servers/#{server_id}/start"
|
22
22
|
)
|
23
|
-
rescue Excon::Errors::InternalServerError => error
|
24
|
-
Fog::Errors::NotFound.new(error)
|
25
23
|
end
|
26
24
|
end
|
27
25
|
|
28
26
|
class Mock
|
29
27
|
def start_server(datacenter_id, server_id)
|
30
|
-
if server =
|
31
|
-
|
32
|
-
|
28
|
+
if server = data[:servers]['items'].find do |attrib|
|
29
|
+
attrib['datacenter_id'] == datacenter_id && attrib['id'] == server_id
|
30
|
+
end
|
33
31
|
else
|
34
|
-
raise Fog::Errors::NotFound
|
35
|
-
'The requested server resource could not be found'
|
36
|
-
)
|
32
|
+
raise Fog::Errors::NotFound, 'The requested server resource could not be found'
|
37
33
|
end
|
38
34
|
|
39
35
|
server['vm_state'] = 'RUNNING'
|
@@ -17,24 +17,20 @@ module Fog
|
|
17
17
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#stop-a-server]
|
18
18
|
def stop_server(datacenter_id, server_id)
|
19
19
|
request(
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
:expects => [202],
|
21
|
+
:method => 'POST',
|
22
|
+
:path => "/datacenters/#{datacenter_id}/servers/#{server_id}/stop"
|
23
23
|
)
|
24
|
-
rescue Excon::Errors::InternalServerError => error
|
25
|
-
Fog::Errors::NotFound.new(error)
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
29
27
|
class Mock
|
30
28
|
def stop_server(datacenter_id, server_id)
|
31
|
-
if server =
|
32
|
-
|
33
|
-
|
29
|
+
if server = data[:servers]['items'].find do |attrib|
|
30
|
+
attrib['datacenter_id'] == datacenter_id && attrib['id'] == server_id
|
31
|
+
end
|
34
32
|
else
|
35
|
-
raise Fog::Errors::NotFound
|
36
|
-
'The requested server resource could not be found'
|
37
|
-
)
|
33
|
+
raise Fog::Errors::NotFound, 'The requested server resource could not be found'
|
38
34
|
end
|
39
35
|
|
40
36
|
server['vm_state'] = 'SHUTOFF'
|
@@ -35,30 +35,35 @@ module Fog
|
|
35
35
|
# * lans<~Hash> - A collection that represents the LANs in a data center
|
36
36
|
#
|
37
37
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-a-data-center]
|
38
|
-
def update_datacenter(datacenter_id, options={})
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
rescue => error
|
46
|
-
Fog::Errors::NotFound.new(error)
|
38
|
+
def update_datacenter(datacenter_id, options = {})
|
39
|
+
request(
|
40
|
+
:expects => [202],
|
41
|
+
:method => 'PATCH',
|
42
|
+
:path => "/datacenters/#{datacenter_id}",
|
43
|
+
:body => Fog::JSON.encode(options)
|
44
|
+
)
|
47
45
|
end
|
48
46
|
end
|
49
47
|
|
50
48
|
class Mock
|
51
|
-
def update_datacenter(datacenter_id, options={})
|
52
|
-
if dc =
|
53
|
-
|
54
|
-
|
49
|
+
def update_datacenter(datacenter_id, options = {})
|
50
|
+
if dc = data[:datacenters]["items"].find do |datacenter|
|
51
|
+
datacenter["id"] == datacenter_id
|
52
|
+
end
|
55
53
|
options.each do |key, value|
|
56
54
|
dc[key] = value
|
57
55
|
end
|
58
56
|
|
59
|
-
dc['properties']['version']
|
57
|
+
dc['properties']['version'] += 1 if dc['properties']
|
58
|
+
dc['version'] += 1 if dc['version']
|
59
|
+
|
60
|
+
dc['properties']['name'] += ' - updated' if dc['properties']
|
61
|
+
dc['name'] += ' - updated' if dc['name']
|
62
|
+
dc['properties']['description'] += ' - updated' if dc['properties']
|
63
|
+
dc['description'] += ' - updated' if dc['description']
|
64
|
+
|
60
65
|
else
|
61
|
-
raise
|
66
|
+
raise Excon::Error::HTTPStatus, "The requested resource could not be found"
|
62
67
|
end
|
63
68
|
|
64
69
|
response = Excon::Response.new
|
@@ -53,26 +53,24 @@ module Fog
|
|
53
53
|
# {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-firewall-rule]
|
54
54
|
def update_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id, options = {})
|
55
55
|
request(
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
:expects => [202],
|
57
|
+
:method => 'PATCH',
|
58
|
+
:path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}/firewallrules/#{firewall_rule_id}",
|
59
|
+
:body => Fog::JSON.encode(options)
|
60
60
|
)
|
61
|
-
rescue => error
|
62
|
-
Fog::Errors::NotFound.new(error)
|
63
61
|
end
|
64
62
|
end
|
65
63
|
|
66
64
|
class Mock
|
67
65
|
def update_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id, options = {})
|
68
|
-
if firewall_rule =
|
69
|
-
|
70
|
-
|
66
|
+
if firewall_rule = data[:firewall_rules]['items'].find do |attribute|
|
67
|
+
attribute["datacenter_id"] == datacenter_id && attribute["server_id"] == server_id && attribute["nic_id"] == nic_id && attribute["id"] == firewall_rule_id
|
68
|
+
end
|
71
69
|
options.each do |key, value|
|
72
70
|
firewall_rule[key] = value
|
73
71
|
end
|
74
72
|
else
|
75
|
-
raise Fog::Errors::NotFound
|
73
|
+
raise Fog::Errors::NotFound, 'The requested resource could not be found'
|
76
74
|
end
|
77
75
|
|
78
76
|
response = Excon::Response.new
|
@@ -84,4 +82,4 @@ module Fog
|
|
84
82
|
end
|
85
83
|
end
|
86
84
|
end
|
87
|
-
end
|
85
|
+
end
|