fog-profitbricks 2.0.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,43 +1,43 @@
1
1
  module Fog
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
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
- class Mock
32
- def get_all_requests
33
- requests = self.data[:requests]
34
- response = Excon::Response.new
35
- response.status = 200
36
- response.body = requests
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
- response
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
- :expects => [200],
111
- :method => 'GET',
112
- :path => "/datacenters/#{datacenter_id}/servers?depth=5"
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 = self.data[:servers]['items'].select {
120
- |attrib| attrib['datacenter_id'] == datacenter_id
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.new('Server resource could not be found')
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 = self.data[:servers]
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
- :expects => [200],
49
- :method => 'GET',
50
- :path => "/snapshots?depth=5"
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 = self.data[:snapshots]
59
+ response.body = data[:snapshots]
60
60
 
61
61
  response
62
62
  end
@@ -1,78 +1,78 @@
1
1
  module Fog
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
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
- class Mock
58
- def get_all_volumes(datacenter_id)
59
- volumes = self.data[:volumes]
57
+ class Mock
58
+ def get_all_volumes(datacenter_id)
59
+ volumes = data[:volumes]
60
60
 
61
- if vlms = self.data[:volumes]['items'].select {
62
- |attrib| attrib['datacenter_id'] == datacenter_id
63
- }
64
- else
65
- raise Fog::Errors::NotFound.new('Volume resource could not be found')
66
- end
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
- volumes['items'] = vlms
69
- response = Excon::Response.new
70
- response.status = 200
71
- response.body = self.data[:volumes]
68
+ volumes['items'] = vlms
69
+ response = Excon::Response.new
70
+ response.status = 200
71
+ response.body = data[:volumes]
72
72
 
73
- response
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
- :expects => [200],
48
- :method => 'GET',
49
- :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/cdroms/#{cdrom_image_id}?depth=1"
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 = self.data[:servers]['items'].find {
57
- |serv| serv['datacenter_id'] == datacenter_id && serv['id'] == server_id
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.new("The server resource could not be found")
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
- |cd| cd['id'] == cdrom_image_id
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.new("The attached volume resource could not be found")
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
- :expects => [200],
49
- :method => 'GET',
50
- :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/volumes/#{volume_id}?depth=1"
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 = self.data[:servers]['items'].find {
58
- |serv| serv['datacenter_id'] == datacenter_id && serv['id'] == server_id
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.new("The server resource could not be found")
61
+ raise Fog::Errors::NotFound, "The server resource could not be found"
62
62
  end
63
63
 
64
- if volume = server['entities']['volumes']['items'].find {
65
- |vlm| vlm['id'] == volume_id
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.new("The attached volume resource could not be found")
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 = self.data[:datacenters]["items"].find {
51
- |datacenter| datacenter["id"] == datacenter_id
52
- }
48
+ if dc = data[:datacenters]["items"].find do |datacenter|
49
+ datacenter["id"] == datacenter_id
50
+ end
53
51
  else
54
- raise Fog::Errors::NotFound.new("The requested resource could not be found")
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
- :expects => [200],
45
- :method => "GET",
46
- :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}/firewallrules/#{firewall_rule_id}?depth=5"
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 = self.data[:firewall_rules]['items'].find {
57
- |fwr| fwr["datacenter_id"] == datacenter_id && fwr["server_id"] == server_id && fwr["nic_id"] == nic_id && fwr["id"] == firewall_rule_id
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.new("The requested resource could not be found")
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" => 14336,
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" => 16384,
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" => 28672,
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" => 57344,
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 = self.data[:flavors].find {
70
- |attrib| attrib["flavorId"] == flavor_id
71
- }
69
+ if flavor = data[:flavors].find do |attrib|
70
+ attrib["flavorId"] == flavor_id
71
+ end
72
72
  else
73
- raise Fog::Errors::NotFound.new("The requested flavor could not be found")
73
+ raise Fog::Errors::NotFound, "The requested flavor could not be found"
74
74
  end
75
75
 
76
76
  response.body = { "getFlavorResponse" => flavor }