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.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/.travis.yml +11 -4
  4. data/README.md +8 -5
  5. data/Rakefile +1 -1
  6. data/examples/pb_demo.rb +49 -49
  7. data/fog-profitbricks.gemspec +4 -5
  8. data/gemfiles/Gemfile.1.9.2+ +1 -0
  9. data/lib/fog/bin/profitbricks.rb +5 -5
  10. data/lib/fog/profitbricks.rb +3 -3
  11. data/lib/fog/profitbricks/compute.rb +209 -204
  12. data/lib/fog/profitbricks/helpers/compute/data_helper.rb +1 -1
  13. data/lib/fog/profitbricks/models/compute/datacenter.rb +1 -1
  14. data/lib/fog/profitbricks/models/compute/datacenters.rb +6 -7
  15. data/lib/fog/profitbricks/models/compute/firewall_rule.rb +2 -2
  16. data/lib/fog/profitbricks/models/compute/firewall_rules.rb +5 -8
  17. data/lib/fog/profitbricks/models/compute/flavors.rb +1 -4
  18. data/lib/fog/profitbricks/models/compute/image.rb +4 -0
  19. data/lib/fog/profitbricks/models/compute/images.rb +2 -5
  20. data/lib/fog/profitbricks/models/compute/ip_block.rb +1 -1
  21. data/lib/fog/profitbricks/models/compute/ip_blocks.rb +3 -8
  22. data/lib/fog/profitbricks/models/compute/lan.rb +1 -1
  23. data/lib/fog/profitbricks/models/compute/lans.rb +4 -7
  24. data/lib/fog/profitbricks/models/compute/load_balancer.rb +6 -7
  25. data/lib/fog/profitbricks/models/compute/load_balancers.rb +5 -9
  26. data/lib/fog/profitbricks/models/compute/locations.rb +2 -5
  27. data/lib/fog/profitbricks/models/compute/nic.rb +6 -3
  28. data/lib/fog/profitbricks/models/compute/nics.rb +2 -5
  29. data/lib/fog/profitbricks/models/compute/regions.rb +1 -4
  30. data/lib/fog/profitbricks/models/compute/request.rb +0 -1
  31. data/lib/fog/profitbricks/models/compute/requests.rb +2 -4
  32. data/lib/fog/profitbricks/models/compute/server.rb +10 -13
  33. data/lib/fog/profitbricks/models/compute/servers.rb +3 -6
  34. data/lib/fog/profitbricks/models/compute/snapshot.rb +2 -2
  35. data/lib/fog/profitbricks/models/compute/snapshots.rb +3 -6
  36. data/lib/fog/profitbricks/models/compute/volume.rb +11 -9
  37. data/lib/fog/profitbricks/models/compute/volumes.rb +3 -6
  38. data/lib/fog/profitbricks/requests/compute/associate_nic_to_load_balancer.rb +26 -13
  39. data/lib/fog/profitbricks/requests/compute/attach_cdrom.rb +25 -16
  40. data/lib/fog/profitbricks/requests/compute/attach_volume.rb +25 -16
  41. data/lib/fog/profitbricks/requests/compute/create_datacenter.rb +22 -23
  42. data/lib/fog/profitbricks/requests/compute/create_firewall_rule.rb +24 -26
  43. data/lib/fog/profitbricks/requests/compute/create_flavor.rb +34 -34
  44. data/lib/fog/profitbricks/requests/compute/create_ip_block.rb +18 -20
  45. data/lib/fog/profitbricks/requests/compute/create_lan.rb +151 -150
  46. data/lib/fog/profitbricks/requests/compute/create_load_balancer.rb +67 -26
  47. data/lib/fog/profitbricks/requests/compute/create_nic.rb +24 -26
  48. data/lib/fog/profitbricks/requests/compute/create_server.rb +70 -61
  49. data/lib/fog/profitbricks/requests/compute/create_volume.rb +122 -122
  50. data/lib/fog/profitbricks/requests/compute/create_volume_snapshot.rb +42 -45
  51. data/lib/fog/profitbricks/requests/compute/delete_datacenter.rb +34 -36
  52. data/lib/fog/profitbricks/requests/compute/delete_firewall_rule.rb +8 -11
  53. data/lib/fog/profitbricks/requests/compute/delete_image.rb +7 -9
  54. data/lib/fog/profitbricks/requests/compute/delete_ip_block.rb +8 -10
  55. data/lib/fog/profitbricks/requests/compute/delete_lan.rb +7 -9
  56. data/lib/fog/profitbricks/requests/compute/delete_load_balancer.rb +8 -10
  57. data/lib/fog/profitbricks/requests/compute/delete_nic.rb +7 -10
  58. data/lib/fog/profitbricks/requests/compute/delete_server.rb +6 -10
  59. data/lib/fog/profitbricks/requests/compute/delete_snapshot.rb +7 -10
  60. data/lib/fog/profitbricks/requests/compute/delete_volume.rb +36 -38
  61. data/lib/fog/profitbricks/requests/compute/detach_cdrom.rb +11 -13
  62. data/lib/fog/profitbricks/requests/compute/detach_volume.rb +16 -13
  63. data/lib/fog/profitbricks/requests/compute/get_all_datacenters.rb +1 -1
  64. data/lib/fog/profitbricks/requests/compute/get_all_firewall_rules.rb +6 -7
  65. data/lib/fog/profitbricks/requests/compute/get_all_flavors.rb +72 -72
  66. data/lib/fog/profitbricks/requests/compute/get_all_images.rb +62 -62
  67. data/lib/fog/profitbricks/requests/compute/get_all_ip_blocks.rb +5 -5
  68. data/lib/fog/profitbricks/requests/compute/get_all_lans.rb +113 -113
  69. data/lib/fog/profitbricks/requests/compute/get_all_load_balanced_nics.rb +15 -9
  70. data/lib/fog/profitbricks/requests/compute/get_all_load_balancers.rb +9 -9
  71. data/lib/fog/profitbricks/requests/compute/get_all_locations.rb +6 -6
  72. data/lib/fog/profitbricks/requests/compute/get_all_nic.rb +94 -94
  73. data/lib/fog/profitbricks/requests/compute/get_all_requests.rb +38 -38
  74. data/lib/fog/profitbricks/requests/compute/get_all_servers.rb +8 -9
  75. data/lib/fog/profitbricks/requests/compute/get_all_snapshots.rb +4 -4
  76. data/lib/fog/profitbricks/requests/compute/get_all_volumes.rb +71 -71
  77. data/lib/fog/profitbricks/requests/compute/get_attached_cdrom.rb +11 -11
  78. data/lib/fog/profitbricks/requests/compute/get_attached_volume.rb +16 -11
  79. data/lib/fog/profitbricks/requests/compute/get_datacenter.rb +4 -6
  80. data/lib/fog/profitbricks/requests/compute/get_firewall_rule.rb +8 -11
  81. data/lib/fog/profitbricks/requests/compute/get_flavor.rb +9 -9
  82. data/lib/fog/profitbricks/requests/compute/get_image.rb +7 -9
  83. data/lib/fog/profitbricks/requests/compute/get_ip_block.rb +8 -10
  84. data/lib/fog/profitbricks/requests/compute/get_lan.rb +7 -10
  85. data/lib/fog/profitbricks/requests/compute/get_load_balanced_nic.rb +16 -12
  86. data/lib/fog/profitbricks/requests/compute/get_load_balancer.rb +7 -9
  87. data/lib/fog/profitbricks/requests/compute/get_location.rb +7 -9
  88. data/lib/fog/profitbricks/requests/compute/get_nic.rb +8 -11
  89. data/lib/fog/profitbricks/requests/compute/get_request.rb +55 -57
  90. data/lib/fog/profitbricks/requests/compute/get_request_status.rb +44 -46
  91. data/lib/fog/profitbricks/requests/compute/get_server.rb +7 -10
  92. data/lib/fog/profitbricks/requests/compute/get_snapshot.rb +7 -9
  93. data/lib/fog/profitbricks/requests/compute/get_volume.rb +7 -9
  94. data/lib/fog/profitbricks/requests/compute/list_attached_cdroms.rb +8 -8
  95. data/lib/fog/profitbricks/requests/compute/list_attached_volumes.rb +18 -8
  96. data/lib/fog/profitbricks/requests/compute/reboot_server.rb +7 -11
  97. data/lib/fog/profitbricks/requests/compute/remove_nic_association.rb +9 -11
  98. data/lib/fog/profitbricks/requests/compute/restore_volume_snapshot.rb +15 -17
  99. data/lib/fog/profitbricks/requests/compute/start_server.rb +7 -11
  100. data/lib/fog/profitbricks/requests/compute/stop_server.rb +7 -11
  101. data/lib/fog/profitbricks/requests/compute/update_datacenter.rb +20 -15
  102. data/lib/fog/profitbricks/requests/compute/update_firewall_rule.rb +9 -11
  103. data/lib/fog/profitbricks/requests/compute/update_image.rb +15 -15
  104. data/lib/fog/profitbricks/requests/compute/update_lan.rb +6 -8
  105. data/lib/fog/profitbricks/requests/compute/update_load_balancer.rb +10 -12
  106. data/lib/fog/profitbricks/requests/compute/update_nic.rb +10 -12
  107. data/lib/fog/profitbricks/requests/compute/update_server.rb +10 -13
  108. data/lib/fog/profitbricks/requests/compute/update_snapshot.rb +10 -13
  109. data/lib/fog/profitbricks/requests/compute/update_volume.rb +10 -13
  110. data/lib/fog/profitbricks/version.rb +1 -1
  111. data/spec/minitest_helper.rb +1 -3
  112. data/tests/helpers/formats_helper.rb +8 -8
  113. data/tests/profitbricks/models/compute/compute_tests.rb +529 -0
  114. data/tests/profitbricks/requests/compute/composite_create_tests.rb +16 -83
  115. data/tests/profitbricks/requests/compute/flavor_tests.rb +1 -4
  116. data/tests/profitbricks/requests/compute/location_tests.rb +14 -17
  117. data/tests/profitbricks/requests/compute/nic_tests.rb +60 -70
  118. data/tests/profitbricks/requests/compute/request_tests.rb +1 -3
  119. data/tests/profitbricks/requests/compute/server_tests.rb +163 -161
  120. 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
- :expects => [202],
52
- :method => 'POST',
53
- :path => "/datacenters/#{datacenter_id}/volumes/#{volume_id}/create-snapshot",
54
- :headers => { "Content-Type" => "application/x-www-form-urlencoded" },
55
- :body => URI.encode_www_form(body)
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, volume_id, options={})
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 = self.data[:datacenters]['items'].find {
68
- |attrib| attrib['id'] == datacenter_id
69
- }
63
+ if datacenter = data[:datacenters]['items'].find do |attrib|
64
+ attrib['id'] == datacenter_id
65
+ end
70
66
  else
71
- raise Fog::Errors::NotFound.new('Data center resource could not be found')
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
- 'id' => '3d52b13d-bec4-49de-ad05-fd2f8c687be7',
76
- 'type' => 'snapshot',
77
- 'href' => 'https =>//api.profitbricks.com/rest/v2/snapshots/3d52b13d-bec4-49de-ad05-fd2f8c687be7',
78
- 'metadata' => {
79
- 'createdDate' => '2016-08-07T22:28:39Z',
80
- 'createdBy' => 'test@stackpointcloud.com',
81
- 'etag' => '83ad78a4757ab0d9bdeaebc3a6485dcf',
82
- 'lastModifiedDate' => '2016-08-07T22:28:39Z',
83
- 'lastModifiedBy' => 'test@stackpointcloud.com',
84
- 'state' => 'AVAILABLE'
85
- },
86
- 'properties' => {
87
- 'name' => options[:name],
88
- 'description' => options[:description],
89
- 'location' => 'us/las',
90
- 'size' => 6,
91
- 'cpuHotPlug' => 'true',
92
- 'cpuHotUnplug' => 'false',
93
- 'ramHotPlug' => 'false',
94
- 'ramHotUnplug' => 'false',
95
- 'nicHotPlug' => 'false',
96
- 'nicHotUnplug' => 'false',
97
- 'discVirtioHotPlug' => 'false',
98
- 'discVirtioHotUnplug' => 'false',
99
- 'discScsiHotPlug' => 'false',
100
- 'discScsiHotUnplug' => 'false',
101
- 'licenceType' => 'LINUX'
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
- self.data[:snapshots]['items'] << snapshot
102
+ data[:snapshots]['items'] << snapshot
106
103
 
107
104
  response.body = snapshot
108
105
  response
@@ -1,43 +1,41 @@
1
1
  module Fog
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
- rescue => error
22
- Fog::Errors::NotFound.new(error)
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
- class Mock
27
- def delete_datacenter(datacenter_id)
28
- response = Excon::Response.new
29
- response.status = 202
24
+ class Mock
25
+ def delete_datacenter(datacenter_id)
26
+ response = Excon::Response.new
27
+ response.status = 202
30
28
 
31
- if dc = self.data[:datacenters]["items"].find {
32
- |datacenter| datacenter["id"] == datacenter_id
33
- }
34
- else
35
- raise Fog::Errors::NotFound.new("The requested resource could not be found")
36
- end
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
- response
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
- :expects => [202],
21
- :method => 'DELETE',
22
- :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}/firewallrules/#{firewall_rule_id}"
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 = self.data[:firewall_rules]["items"].find {
35
- |attribute| attribute["datacenter_id"] == datacenter_id && attribute["server_id"] == server_id && attribute["nic_id"] == nic_id && attribute["id"] == firewall_rule_id
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.new("The requested firewall rule resource could not be found")
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
- :expects => [202],
18
- :method => 'DELETE',
19
- :path => "/images/#{image_id}"
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 = self.data[:images]["items"].find {
32
- |image| image["id"] == image_id
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.new("The requested resource could not be found")
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
- :expects => [202],
18
- :method => 'DELETE',
19
- :path => "/ipblocks/#{ip_block_id}"
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 = self.data[:ip_blocks]["items"].find {
32
- |attribute| attribute["id"] == ip_block_id
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.new("The requested IP Block could not be found")
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
- :expects => [202],
19
- :method => 'DELETE',
20
- :path => "/datacenter/#{datacenter_id}/lans/#{lan_id}"
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 = self.data[:lans]["items"].find {
33
- |attribute| attribute["datacenter_id"] == datacenter_id && attribute["id"] == lan_id
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.new("The requested lan could not be found")
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
- :expects => [202],
19
- :method => 'DELETE',
20
- :path => "/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}"
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 = self.data[:load_balancers]["items"].find {
33
- |attribute| attribute["datacenter_id"] == datacenter_id && attribute["id"] == load_balancer_id
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.new("The requested resource could not be found")
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
- :expects => [202],
20
- :method => 'DELETE',
21
- :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}"
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 = self.data[:nics]["items"].find {
34
- |attribute| attribute["datacenter_id"] == datacenter_id && attribute["server_id"] == server_id && attribute["id"] == nic_id
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.new("The requested nic resource could not be found")
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 = self.data[:servers]['items'].find {
32
- |attrib| attrib['datacenter_id'] == datacenter_id && attrib['id'] == server_id
33
- }
34
- self.data[:servers].delete(server)
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.new(
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
- :expects => [202],
17
- :method => 'DELETE',
18
- :path => "/snapshots/#{snapshot_id}"
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 = self.data[:snapshots]['items'].find {
32
- |attrib| attrib['id'] == snapshot_id
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.new('The requested resource could not be found')
32
+ raise Fog::Errors::NotFound, 'The requested resource could not be found'
36
33
  end
37
34
 
38
35
  response