fog-profitbricks 0.0.5 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +1465 -4
  4. data/Rakefile +3 -0
  5. data/examples/pb_demo.rb +83 -35
  6. data/fog-profitbricks.gemspec +10 -10
  7. data/gemfiles/Gemfile.1.8.7 +0 -1
  8. data/lib/fog/profitbricks.rb +4 -23
  9. data/lib/fog/profitbricks/compute.rb +1082 -1
  10. data/lib/fog/profitbricks/helpers/compute/data_helper.rb +12 -0
  11. data/lib/fog/profitbricks/models/base.rb +37 -0
  12. data/lib/fog/profitbricks/models/compute/datacenter.rb +64 -0
  13. data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/datacenters.rb +9 -4
  14. data/lib/fog/profitbricks/models/compute/firewall_rule.rb +101 -0
  15. data/lib/fog/profitbricks/models/compute/firewall_rules.rb +40 -0
  16. data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/flavor.rb +0 -0
  17. data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/flavors.rb +0 -0
  18. data/lib/fog/profitbricks/models/compute/image.rb +72 -0
  19. data/lib/fog/profitbricks/models/compute/images.rb +28 -0
  20. data/lib/fog/profitbricks/models/compute/ip_block.rb +58 -0
  21. data/lib/fog/profitbricks/models/compute/ip_blocks.rb +30 -0
  22. data/lib/fog/profitbricks/models/compute/lan.rb +89 -0
  23. data/lib/fog/profitbricks/models/compute/lans.rb +36 -0
  24. data/lib/fog/profitbricks/models/compute/load_balancer.rb +126 -0
  25. data/lib/fog/profitbricks/models/compute/load_balancers.rb +34 -0
  26. data/lib/fog/profitbricks/models/compute/location.rb +18 -0
  27. data/lib/fog/profitbricks/models/compute/locations.rb +28 -0
  28. data/lib/fog/profitbricks/models/compute/nic.rb +111 -0
  29. data/lib/fog/profitbricks/models/compute/nics.rb +38 -0
  30. data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/region.rb +0 -0
  31. data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/regions.rb +0 -0
  32. data/lib/fog/profitbricks/models/compute/request.rb +24 -0
  33. data/lib/fog/profitbricks/models/compute/requests.rb +37 -0
  34. data/lib/fog/profitbricks/models/compute/server.rb +263 -0
  35. data/lib/fog/profitbricks/models/compute/servers.rb +32 -0
  36. data/lib/fog/profitbricks/models/compute/snapshot.rb +81 -0
  37. data/lib/fog/profitbricks/models/compute/snapshots.rb +28 -0
  38. data/lib/fog/profitbricks/models/compute/volume.rb +123 -0
  39. data/lib/fog/profitbricks/models/compute/volumes.rb +33 -0
  40. data/lib/fog/profitbricks/requests/compute/associate_nic_to_load_balancer.rb +104 -0
  41. data/lib/fog/profitbricks/requests/compute/attach_cdrom.rb +88 -0
  42. data/lib/fog/profitbricks/requests/compute/attach_volume.rb +89 -0
  43. data/lib/fog/profitbricks/requests/compute/create_datacenter.rb +89 -0
  44. data/lib/fog/profitbricks/requests/compute/create_firewall_rule.rb +103 -0
  45. data/lib/fog/{compute/profit_bricks/requests → profitbricks/requests/compute}/create_flavor.rb +0 -0
  46. data/lib/fog/profitbricks/requests/compute/create_ip_block.rb +81 -0
  47. data/lib/fog/profitbricks/requests/compute/create_lan.rb +160 -0
  48. data/lib/fog/profitbricks/requests/compute/create_load_balancer.rb +87 -0
  49. data/lib/fog/profitbricks/requests/compute/create_nic.rb +124 -0
  50. data/lib/fog/profitbricks/requests/compute/create_server.rb +257 -0
  51. data/lib/fog/profitbricks/requests/compute/create_volume.rb +133 -0
  52. data/lib/fog/profitbricks/requests/compute/create_volume_snapshot.rb +113 -0
  53. data/lib/fog/profitbricks/requests/compute/delete_datacenter.rb +43 -0
  54. data/lib/fog/profitbricks/requests/compute/delete_firewall_rule.rb +47 -0
  55. data/lib/fog/profitbricks/requests/compute/delete_image.rb +43 -0
  56. data/lib/fog/profitbricks/requests/compute/delete_ip_block.rb +43 -0
  57. data/lib/fog/profitbricks/requests/compute/delete_lan.rb +44 -0
  58. data/lib/fog/profitbricks/requests/compute/delete_load_balancer.rb +44 -0
  59. data/lib/fog/profitbricks/requests/compute/delete_nic.rb +46 -0
  60. data/lib/fog/profitbricks/requests/compute/delete_server.rb +48 -0
  61. data/lib/fog/profitbricks/requests/compute/delete_snapshot.rb +43 -0
  62. data/lib/fog/profitbricks/requests/compute/delete_volume.rb +44 -0
  63. data/lib/fog/profitbricks/requests/compute/detach_cdrom.rb +52 -0
  64. data/lib/fog/profitbricks/requests/compute/detach_volume.rb +53 -0
  65. data/lib/fog/profitbricks/requests/compute/get_all_datacenters.rb +59 -0
  66. data/lib/fog/profitbricks/requests/compute/get_all_firewall_rules.rb +76 -0
  67. data/lib/fog/{compute/profit_bricks/requests → profitbricks/requests/compute}/get_all_flavors.rb +0 -0
  68. data/lib/fog/profitbricks/requests/compute/get_all_images.rb +66 -0
  69. data/lib/fog/profitbricks/requests/compute/get_all_ip_blocks.rb +56 -0
  70. data/lib/fog/profitbricks/requests/compute/get_all_lans.rb +120 -0
  71. data/lib/fog/profitbricks/requests/compute/get_all_load_balanced_nics.rb +100 -0
  72. data/lib/fog/profitbricks/requests/compute/get_all_load_balancers.rb +117 -0
  73. data/lib/fog/profitbricks/requests/compute/get_all_locations.rb +44 -0
  74. data/lib/fog/profitbricks/requests/compute/get_all_nic.rb +102 -0
  75. data/lib/fog/profitbricks/requests/compute/get_all_requests.rb +43 -0
  76. data/lib/fog/profitbricks/requests/compute/get_all_servers.rb +134 -0
  77. data/lib/fog/profitbricks/requests/compute/get_all_snapshots.rb +66 -0
  78. data/lib/fog/profitbricks/requests/compute/get_all_volumes.rb +78 -0
  79. data/lib/fog/profitbricks/requests/compute/get_attached_cdrom.rb +78 -0
  80. data/lib/fog/profitbricks/requests/compute/get_attached_volume.rb +79 -0
  81. data/lib/fog/profitbricks/requests/compute/get_datacenter.rb +65 -0
  82. data/lib/fog/profitbricks/requests/compute/get_firewall_rule.rb +71 -0
  83. data/lib/fog/{compute/profit_bricks/requests → profitbricks/requests/compute}/get_flavor.rb +0 -0
  84. data/lib/fog/profitbricks/requests/compute/get_image.rb +71 -0
  85. data/lib/fog/profitbricks/requests/compute/get_ip_block.rb +58 -0
  86. data/lib/fog/profitbricks/requests/compute/get_lan.rb +120 -0
  87. data/lib/fog/profitbricks/requests/compute/get_load_balanced_nic.rb +99 -0
  88. data/lib/fog/profitbricks/requests/compute/get_load_balancer.rb +116 -0
  89. data/lib/fog/profitbricks/requests/compute/get_location.rb +49 -0
  90. data/lib/fog/profitbricks/requests/compute/get_nic.rb +98 -0
  91. data/lib/fog/profitbricks/requests/compute/get_request.rb +61 -0
  92. data/lib/fog/profitbricks/requests/compute/get_request_status.rb +50 -0
  93. data/lib/fog/profitbricks/requests/compute/get_server.rb +133 -0
  94. data/lib/fog/profitbricks/requests/compute/get_snapshot.rb +70 -0
  95. data/lib/fog/profitbricks/requests/compute/get_volume.rb +73 -0
  96. data/lib/fog/profitbricks/requests/compute/list_attached_cdroms.rb +74 -0
  97. data/lib/fog/profitbricks/requests/compute/list_attached_volumes.rb +75 -0
  98. data/lib/fog/profitbricks/requests/compute/reboot_server.rb +47 -0
  99. data/lib/fog/profitbricks/requests/compute/remove_nic_association.rb +44 -0
  100. data/lib/fog/profitbricks/requests/compute/restore_volume_snapshot.rb +61 -0
  101. data/lib/fog/profitbricks/requests/compute/start_server.rb +49 -0
  102. data/lib/fog/profitbricks/requests/compute/stop_server.rb +50 -0
  103. data/lib/fog/profitbricks/requests/compute/update_datacenter.rb +73 -0
  104. data/lib/fog/profitbricks/requests/compute/update_firewall_rule.rb +87 -0
  105. data/lib/fog/profitbricks/requests/compute/update_image.rb +90 -0
  106. data/lib/fog/profitbricks/requests/compute/update_lan.rb +126 -0
  107. data/lib/fog/profitbricks/requests/compute/update_load_balancer.rb +70 -0
  108. data/lib/fog/profitbricks/requests/compute/update_nic.rb +107 -0
  109. data/lib/fog/profitbricks/requests/compute/update_server.rb +147 -0
  110. data/lib/fog/profitbricks/requests/compute/update_snapshot.rb +90 -0
  111. data/lib/fog/profitbricks/requests/compute/update_volume.rb +82 -0
  112. data/lib/fog/profitbricks/version.rb +1 -1
  113. data/tests/profitbricks/requests/compute/composite_create_tests.rb +241 -0
  114. data/tests/profitbricks/requests/compute/location_tests.rb +24 -12
  115. data/tests/profitbricks/requests/compute/nic_tests.rb +290 -0
  116. data/tests/profitbricks/requests/compute/request_tests.rb +52 -0
  117. data/tests/profitbricks/requests/compute/server_tests.rb +398 -175
  118. metadata +140 -133
  119. data/lib/fog/compute/profit_bricks.rb +0 -217
  120. data/lib/fog/compute/profit_bricks/models/datacenter.rb +0 -60
  121. data/lib/fog/compute/profit_bricks/models/image.rb +0 -27
  122. data/lib/fog/compute/profit_bricks/models/images.rb +0 -22
  123. data/lib/fog/compute/profit_bricks/models/interface.rb +0 -61
  124. data/lib/fog/compute/profit_bricks/models/interfaces.rb +0 -23
  125. data/lib/fog/compute/profit_bricks/models/server.rb +0 -104
  126. data/lib/fog/compute/profit_bricks/models/servers.rb +0 -22
  127. data/lib/fog/compute/profit_bricks/models/volume.rb +0 -71
  128. data/lib/fog/compute/profit_bricks/models/volumes.rb +0 -23
  129. data/lib/fog/compute/profit_bricks/requests/clear_data_center.rb +0 -51
  130. data/lib/fog/compute/profit_bricks/requests/connect_storage_to_server.rb +0 -83
  131. data/lib/fog/compute/profit_bricks/requests/create_data_center.rb +0 -62
  132. data/lib/fog/compute/profit_bricks/requests/create_nic.rb +0 -79
  133. data/lib/fog/compute/profit_bricks/requests/create_server.rb +0 -105
  134. data/lib/fog/compute/profit_bricks/requests/create_storage.rb +0 -96
  135. data/lib/fog/compute/profit_bricks/requests/delete_data_center.rb +0 -60
  136. data/lib/fog/compute/profit_bricks/requests/delete_nic.rb +0 -64
  137. data/lib/fog/compute/profit_bricks/requests/delete_server.rb +0 -64
  138. data/lib/fog/compute/profit_bricks/requests/delete_storage.rb +0 -64
  139. data/lib/fog/compute/profit_bricks/requests/disconnect_storage_from_server.rb +0 -76
  140. data/lib/fog/compute/profit_bricks/requests/get_all_data_centers.rb +0 -31
  141. data/lib/fog/compute/profit_bricks/requests/get_all_images.rb +0 -65
  142. data/lib/fog/compute/profit_bricks/requests/get_all_locations.rb +0 -44
  143. data/lib/fog/compute/profit_bricks/requests/get_all_nic.rb +0 -53
  144. data/lib/fog/compute/profit_bricks/requests/get_all_servers.rb +0 -57
  145. data/lib/fog/compute/profit_bricks/requests/get_all_storages.rb +0 -56
  146. data/lib/fog/compute/profit_bricks/requests/get_data_center.rb +0 -38
  147. data/lib/fog/compute/profit_bricks/requests/get_data_center_state.rb +0 -42
  148. data/lib/fog/compute/profit_bricks/requests/get_image.rb +0 -69
  149. data/lib/fog/compute/profit_bricks/requests/get_location.rb +0 -48
  150. data/lib/fog/compute/profit_bricks/requests/get_nic.rb +0 -63
  151. data/lib/fog/compute/profit_bricks/requests/get_server.rb +0 -98
  152. data/lib/fog/compute/profit_bricks/requests/get_storage.rb +0 -63
  153. data/lib/fog/compute/profit_bricks/requests/reset_server.rb +0 -49
  154. data/lib/fog/compute/profit_bricks/requests/set_internet_access.rb +0 -59
  155. data/lib/fog/compute/profit_bricks/requests/start_server.rb +0 -58
  156. data/lib/fog/compute/profit_bricks/requests/stop_server.rb +0 -58
  157. data/lib/fog/compute/profit_bricks/requests/update_data_center.rb +0 -54
  158. data/lib/fog/compute/profit_bricks/requests/update_nic.rb +0 -74
  159. data/lib/fog/compute/profit_bricks/requests/update_server.rb +0 -79
  160. data/lib/fog/compute/profit_bricks/requests/update_storage.rb +0 -73
  161. data/lib/fog/models/profit_bricks/base.rb +0 -11
  162. data/lib/fog/parsers/compute.rb +0 -37
  163. data/lib/fog/parsers/compute/profit_bricks/base.rb +0 -51
  164. data/lib/fog/parsers/compute/profit_bricks/clear_data_center.rb +0 -22
  165. data/lib/fog/parsers/compute/profit_bricks/connect_storage_to_server.rb +0 -22
  166. data/lib/fog/parsers/compute/profit_bricks/create_data_center.rb +0 -22
  167. data/lib/fog/parsers/compute/profit_bricks/create_nic.rb +0 -22
  168. data/lib/fog/parsers/compute/profit_bricks/create_server.rb +0 -22
  169. data/lib/fog/parsers/compute/profit_bricks/create_storage.rb +0 -22
  170. data/lib/fog/parsers/compute/profit_bricks/delete_data_center.rb +0 -20
  171. data/lib/fog/parsers/compute/profit_bricks/delete_nic.rb +0 -22
  172. data/lib/fog/parsers/compute/profit_bricks/delete_server.rb +0 -22
  173. data/lib/fog/parsers/compute/profit_bricks/delete_storage.rb +0 -22
  174. data/lib/fog/parsers/compute/profit_bricks/disconnect_storage_from_server.rb +0 -22
  175. data/lib/fog/parsers/compute/profit_bricks/get_all_data_centers.rb +0 -26
  176. data/lib/fog/parsers/compute/profit_bricks/get_all_images.rb +0 -30
  177. data/lib/fog/parsers/compute/profit_bricks/get_all_nic.rb +0 -30
  178. data/lib/fog/parsers/compute/profit_bricks/get_all_servers.rb +0 -57
  179. data/lib/fog/parsers/compute/profit_bricks/get_all_storages.rb +0 -33
  180. data/lib/fog/parsers/compute/profit_bricks/get_data_center.rb +0 -23
  181. data/lib/fog/parsers/compute/profit_bricks/get_data_center_state.rb +0 -20
  182. data/lib/fog/parsers/compute/profit_bricks/get_image.rb +0 -26
  183. data/lib/fog/parsers/compute/profit_bricks/get_nic.rb +0 -27
  184. data/lib/fog/parsers/compute/profit_bricks/get_server.rb +0 -57
  185. data/lib/fog/parsers/compute/profit_bricks/get_storage.rb +0 -30
  186. data/lib/fog/parsers/compute/profit_bricks/reset_server.rb +0 -20
  187. data/lib/fog/parsers/compute/profit_bricks/set_internet_access.rb +0 -22
  188. data/lib/fog/parsers/compute/profit_bricks/update_data_center.rb +0 -22
  189. data/lib/fog/parsers/compute/profit_bricks/update_nic.rb +0 -22
  190. data/lib/fog/parsers/compute/profit_bricks/update_server.rb +0 -22
  191. data/lib/fog/parsers/compute/profit_bricks/update_storage.rb +0 -22
  192. data/lib/fog/profitbricks/storage.rb +0 -1
  193. data/tests/profitbricks/requests/compute/image_tests.rb +0 -50
  194. data/tests/profitbricks/requests/compute/interface_tests.rb +0 -101
@@ -0,0 +1,49 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # This will start a server.
6
+ # If the server's public IP was deallocated, then a new IP will be assigned
7
+ #
8
+ # ==== Parameters
9
+ # * datacenter_id<~String> - UUID of the data center
10
+ # * server_id<~String> - UUID of the virtual server
11
+ #
12
+ # ==== Returns
13
+ # * response<~Excon::Response> - No response parameters
14
+ # (HTTP/1.1 202 Accepted)
15
+ #
16
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#start-a-server]
17
+ def start_server(datacenter_id, server_id)
18
+ request(
19
+ :expects => [202],
20
+ :method => 'POST',
21
+ :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/start"
22
+ )
23
+ rescue Excon::Errors::InternalServerError => error
24
+ Fog::Errors::NotFound.new(error)
25
+ end
26
+ end
27
+
28
+ class Mock
29
+ def start_server(datacenter_id, server_id)
30
+ if server = self.data[:servers]['items'].find {
31
+ |attrib| attrib['datacenter_id'] == datacenter_id && attrib['id'] == server_id
32
+ }
33
+ else
34
+ raise Fog::Errors::NotFound.new(
35
+ 'The requested server resource could not be found'
36
+ )
37
+ end
38
+
39
+ server['vm_state'] = 'RUNNING'
40
+ server['state'] = 'AVAILABLE'
41
+
42
+ response = Excon::Response.new
43
+ response.status = 202
44
+ response
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,50 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # This will stop a server.
6
+ # The machine will be forcefully powered off, billing will cease,
7
+ # and the public IP, if one is allocated, will be deallocated
8
+ #
9
+ # ==== Parameters
10
+ # * datacenter_id<~String> - UUID of the data center
11
+ # * server_id<~String> - UUID of the virtual server
12
+ #
13
+ # ==== Returns
14
+ # * response<~Excon::Response> - No response parameters
15
+ # (HTTP/1.1 202 Accepted)
16
+ #
17
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#stop-a-server]
18
+ def stop_server(datacenter_id, server_id)
19
+ request(
20
+ :expects => [202],
21
+ :method => 'POST',
22
+ :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/stop"
23
+ )
24
+ rescue Excon::Errors::InternalServerError => error
25
+ Fog::Errors::NotFound.new(error)
26
+ end
27
+ end
28
+
29
+ class Mock
30
+ def stop_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
+ else
35
+ raise Fog::Errors::NotFound.new(
36
+ 'The requested server resource could not be found'
37
+ )
38
+ end
39
+
40
+ server['vm_state'] = 'SHUTOFF'
41
+ server['state'] = 'INACTIVE'
42
+
43
+ response = Excon::Response.new
44
+ response.status = 202
45
+ response
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,73 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Update an existing virtual data center
6
+ #
7
+ # ==== Parameters
8
+ # * options<~Hash>:
9
+ # * name<~String> - The new name of the data center
10
+ # * description<~String> - The optional description of the data center
11
+ #
12
+ # ==== Returns
13
+ # * response<~Excon::Response>:
14
+ # * body<~Hash>:
15
+ # * id<~String> - The resource's unique identifier
16
+ # * type<~String> - The type of the requested resource
17
+ # * href<~String> - URL to the object’s representation (absolute path)
18
+ # * metadata<~Hash> - A hash containing the resource's metadata
19
+ # * createdDate<~String> - The date the resource was created
20
+ # * createdBy<~String> - The user who created the resource
21
+ # * etag<~String> - The etag for the resource
22
+ # * lastModifiedDate<~String> - The last time the resource has been modified
23
+ # * lastModifiedBy<~String> - The user who last modified the resource
24
+ # * state<~String> - Data center state (AVAILABLE, BUSY, INACTIVE)
25
+ # * properties<~Hash> - A hash containing the resource's properties
26
+ # * name<~String> - The name of the data center
27
+ # * description<~String> - The description of the data center
28
+ # * location<~String> - The location where the data center was provisioned ("de/fkb", "de/fra", or "us/las")
29
+ # * version<~Integer> - The version of the data center
30
+ # * features<~Array> - The features of the data center
31
+ # * entities<~Hash> - A hash containing the datacenter entities
32
+ # * servers<~Hash> - A collection that represents the servers in a data center
33
+ # * volumes<~Hash> - A collection that represents volumes in a data center
34
+ # * loadbalancers<~Hash> - A collection that represents the loadbalancers in a data center
35
+ # * lans<~Hash> - A collection that represents the LANs in a data center
36
+ #
37
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-a-data-center]
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
+ )
45
+ rescue => error
46
+ Fog::Errors::NotFound.new(error)
47
+ end
48
+ end
49
+
50
+ class Mock
51
+ def update_datacenter(datacenter_id, options={})
52
+ if dc = self.data[:datacenters]["items"].find {
53
+ |datacenter| datacenter["id"] == datacenter_id
54
+ }
55
+ options.each do |key, value|
56
+ dc[key] = value
57
+ end
58
+
59
+ dc['properties']['version'] += 1
60
+ else
61
+ raise Fog::Errors::NotFound.new("The requested resource could not be found")
62
+ end
63
+
64
+ response = Excon::Response.new
65
+ response.status = 202
66
+ response.body = dc
67
+
68
+ response
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,87 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Update a Firewall Rule
6
+ #
7
+ # ==== Parameters
8
+ # * datacenter_id<~String> - Required - UUID of the NIC
9
+ # * server_id<~String> - Required - UUID of the server
10
+ # * nic_id<~String> - Required - UUID of the NIC
11
+ # * firewall_rule_id<~String> - Required - UUID of the NIC
12
+ # * options<~Hash>:
13
+ # * name<~String> - The name of the Firewall Rule
14
+ # * sourceMac<~String> - Only traffic originating from the respective MAC address is allowed.
15
+ # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address
16
+ # * sourceIp<~String> - Only traffic originating from the respective IPv4 address is allowed. Value null allows all source IPs
17
+ # * targetIp<~String> - In case the target NIC has multiple IP addresses, only traffic directed
18
+ # to the respective IP address of the NIC is allowed. Value null allows all target IPs
19
+ # * icmpCode<~String> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. Value null allows all codes
20
+ # * icmpType<~String> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. Value null allows all types
21
+ # * portRangeStart<~String> - Defines the start range of the allowed port (from 1 to 65534) if protocol TCP or UDP is chosen.
22
+ # Leave portRangeStart and portRangeEnd value null to allow all ports
23
+ # * portRangeEnd<~String> - Defines the end range of the allowed port (from 1 to 65534) if the protocol TCP or UDP is chosen.
24
+ # Leave portRangeStart and portRangeEnd null to allow all ports
25
+ #
26
+ # ==== Returns
27
+ # * response<~Excon::Response>:
28
+ # * body<~Hash>:
29
+ # * id<~String> - The resource's unique identifier
30
+ # * type<~String> - The type of the created resource
31
+ # * href<~String> - URL to the object’s representation (absolute path)
32
+ # * metadata<~Hash> - Hash containing the Firewall Rule metadata
33
+ # * createdDate<~String> - The date the resource was created
34
+ # * createdBy<~String> - The user who created the resource
35
+ # * etag<~String> - The etag for the resource
36
+ # * lastModifiedDate<~String> - The last time the resource has been modified
37
+ # * lastModifiedBy<~String> - The user who last modified the resource
38
+ # * state<~String> - Firewall Rule state
39
+ # * properties<~Hash> - Hash containing the Firewall Rule properties
40
+ # * name<~String> - The name of the Firewall Rule
41
+ # * sourceMac<~String> - Only traffic originating from the respective MAC address is allowed.
42
+ # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address
43
+ # * sourceIp<~String> - Only traffic originating from the respective IPv4 address is allowed. Value null allows all source IPs
44
+ # * targetIp<~String> - In case the target NIC has multiple IP addresses, only traffic directed
45
+ # to the respective IP address of the NIC is allowed. Value null allows all target IPs
46
+ # * icmpCode<~String> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. Value null allows all codes
47
+ # * icmpType<~String> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. Value null allows all types
48
+ # * portRangeStart<~String> - Defines the start range of the allowed port (from 1 to 65534) if protocol TCP or UDP is chosen.
49
+ # Leave portRangeStart and portRangeEnd value null to allow all ports
50
+ # * portRangeEnd<~String> - Defines the end range of the allowed port (from 1 to 65534) if the protocol TCP or UDP is chosen.
51
+ # Leave portRangeStart and portRangeEnd null to allow all ports
52
+ #
53
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-firewall-rule]
54
+ def update_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id, options = {})
55
+ request(
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
+ )
61
+ rescue => error
62
+ Fog::Errors::NotFound.new(error)
63
+ end
64
+ end
65
+
66
+ class Mock
67
+ def update_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id, options = {})
68
+ if firewall_rule = self.data[:firewall_rules]['items'].find {
69
+ |attribute| attribute["datacenter_id"] == datacenter_id && attribute["server_id"] == server_id && attribute["nic_id"] == nic_id && attribute["id"] == firewall_rule_id
70
+ }
71
+ options.each do |key, value|
72
+ firewall_rule[key] = value
73
+ end
74
+ else
75
+ raise Fog::Errors::NotFound.new('The requested resource could not be found')
76
+ end
77
+
78
+ response = Excon::Response.new
79
+ response.status = 202
80
+ response.body = firewall_rule
81
+
82
+ response
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,90 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Update an existing image
6
+ #
7
+ # ==== Parameters
8
+ # * image_id<~String> - UUID of the image resource
9
+ # * options<~Hash>:
10
+ # * name<~String> - The name of the image
11
+ # * description<~String> - The description of the image
12
+ # * licenceType<~String> - The image's licence type: LINUX, WINDOWS, or UNKNOWN
13
+ # * cpuHotPlug<~String> - This image is capable of CPU hot plug (no reboot required)
14
+ # * cpuHotUnplug<~String> - This image is capable of CPU hot unplug (no reboot required)
15
+ # * ramHotPlug<~String> - This image is capable of memory hot plug (no reboot required)
16
+ # * ramHotUnplug<~String> - This image is capable of memory hot unplug (no reboot required)
17
+ # * nicHotPlug<~String> - This image is capable of nic hot plug (no reboot required)
18
+ # * nicHotUnplug<~String> - This image is capable of nic hot unplug (no reboot required)
19
+ # * discVirtioHotPlug<~String> - This image is capable of Virt-IO drive hot plug (no reboot required)
20
+ # * discVirtioHotUnplug<~String> - This image is capable of Virt-IO drive hot unplug (no reboot required)
21
+ # * discScsiHotPlug<~String> - This image is capable of Scsi drive hot plug (no reboot required)
22
+ # * discScsiHotUnplug<~String> - This image is capable of Scsi drive hot unplug (no reboot required)
23
+ #
24
+ # ==== Returns
25
+ # * response<~Excon::Response>:
26
+ # * body<~Hash>:
27
+ # * id<~String> - The resource's unique identifier
28
+ # * type<~String> - The type of the requested resource
29
+ # * href<~String> - URL to the object’s representation (absolute path)
30
+ # * metadata<~Hash> - Hash containing the image metadata
31
+ # * createdDate<~String> - The date the resource was created
32
+ # * createdBy<~String> - The user who created the resource
33
+ # * etag<~String> - The etag for the resource
34
+ # * lastModifiedDate<~String> - The last time the resource has been modified
35
+ # * lastModifiedBy<~String> - The user who last modified the resource
36
+ # * state<~String> - Volume state
37
+ # * properties<~Hash> - Hash containing the volume properties
38
+ # * name<~String> - The name of the image
39
+ # * description<~String> - The description of the image
40
+ # * location<~String> - The image's location
41
+ # * size<~Integer> - The size of the image in GB
42
+ # * cpuHotPlug<~Boolean> - This image is capable of CPU hot plug (no reboot required)
43
+ # * cpuHotUnplug<~Boolean> - This image is capable of CPU hot unplug (no reboot required)
44
+ # * ramHotPlug<~Boolean> - This image is capable of memory hot plug (no reboot required)
45
+ # * ramHotUnplug<~Boolean> - This image is capable of memory hot unplug (no reboot required)
46
+ # * nicHotPlug<~Boolean> - This image is capable of nic hot plug (no reboot required)
47
+ # * nicHotUnplug<~Boolean> - This image is capable of nic hot unplug (no reboot required)
48
+ # * discVirtioHotPlug<~Boolean> - This image is capable of Virt-IO drive hot plug (no reboot required)
49
+ # * discVirtioHotPlug<~Boolean> - This image is capable of Virt-IO drive hot unplug (no reboot required)
50
+ # * discScsiHotPlug<~Boolean> - This image is capable of Scsi drive hot plug (no reboot required)
51
+ # * discScsiHotUnplug<~Boolean> - This image is capable of Scsi drive hot unplug (no reboot required)
52
+ # * licenceType<~String> - The image's licence type: LINUX, WINDOWS, or UNKNOWN
53
+ # * imageType<~String> - The type of image: HDD, CDROM
54
+ # * public<~String> - Indicates if the image is part of the public repository or not
55
+ #
56
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-image]
57
+ def update_image(image_id, options={})
58
+ request(
59
+ :expects => [202],
60
+ :method => 'PATCH',
61
+ :path => "/images/#{image_id}",
62
+ :body => Fog::JSON.encode(options)
63
+ )
64
+ rescue => error
65
+ Fog::Errors::NotFound.new(error)
66
+ end
67
+ end
68
+
69
+ class Mock
70
+ def update_image(image_id, options={})
71
+ if img = self.data[:images]["items"].find {
72
+ |image| image["id"] == image_id
73
+ }
74
+ img['name'] = options[:name]
75
+ img['description'] = options[:description]
76
+ img['discVirtioHotPlug'] = options[:disc_virtio_hotplug]
77
+ else
78
+ raise Fog::Errors::NotFound.new("The requested resource could not be found")
79
+ end
80
+
81
+ response = Excon::Response.new
82
+ response.status = 202
83
+ response.body = img
84
+
85
+ response
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,126 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Update LAN properties
6
+ #
7
+ # ==== Parameters
8
+ # * datacenter_id<~String> - Required - UUID of the virtual data center
9
+ # * lan_id<~String> - Required - UUID of the LAN
10
+ # * properties<~Hash>:
11
+ # * name<~String> - The name of the LAN
12
+ # * public<~Integer> - Boolean indicating if the LAN faces the public Internet or not
13
+ #
14
+ # ==== Returns
15
+ # * response<~Excon::Response>:
16
+ # * body<~Hash>:
17
+ # * id<~String> - The resource's unique identifier
18
+ # * type<~String> - The type of the created resource
19
+ # * href<~String> - URL to the object’s representation (absolute path)
20
+ # * items<~Hash> - Collection of individual lan objects
21
+ # * id<~String> - The resource's unique identifier
22
+ # * type<~String> - The type of the created resource
23
+ # * href<~String> - URL to the object’s representation (absolute path)
24
+ # * metadata<~Hash> - Hash containing the LAN metadata
25
+ # * createdDate<~String> - The date the resource was created
26
+ # * createdBy<~String> - The user who created the resource
27
+ # * etag<~String> - The etag for the resource
28
+ # * lastModifiedDate<~String> - The last time the resource has been modified
29
+ # * lastModifiedBy<~String> - The user who last modified the resource
30
+ # * state<~String> - LAN state
31
+ # * properties<~Hash> - Hash containing the LAN properties
32
+ # * name<~String> - The name of the LAN
33
+ # * public<~Boolean> - Boolean indicating if the LAN faces the public Internet or not
34
+ # * entities<~Hash> - Hash containing the LAN entities
35
+ # * nics<~Hash> - Hash containing the NIC properties
36
+ # * id<~String> - The resource's unique identifier
37
+ # * type<~String> - The type of the created resource
38
+ # * href<~String> - URL to the object’s representation (absolute path)
39
+ # * items<~Hash> - Collection of individual nic objects
40
+ # * id<~String> - The resource's unique identifier
41
+ # * type<~String> - The type of the created resource
42
+ # * href<~String> - URL to the object’s representation (absolute path)
43
+ # * metadata<~Hash> - Hash containing the NIC metadata
44
+ # * createdDate<~String> - The date the resource was created
45
+ # * createdBy<~String> - The user who created the resource
46
+ # * etag<~String> - The etag for the resource
47
+ # * lastModifiedDate<~String> - The last time the resource has been modified
48
+ # * lastModifiedBy<~String> - The user who last modified the resource
49
+ # * state<~String> - NIC state
50
+ # * properties<~Hash> - Hash containing the NIC properties
51
+ # * name<~String> - The name of the NIC
52
+ # * mac<~String> - The MAC address of the NIC
53
+ # * ips<~Array> - IPs assigned to the NIC represented as a collection
54
+ # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not
55
+ # * lan<~Integer> - The LAN ID the NIC sits on
56
+ # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value
57
+ # * entities<~Hash> - Hash containing the NIC entities
58
+ # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection
59
+ # * id<~String> - The resource's unique identifier
60
+ # * type<~String> - The type of the resource
61
+ # * href<~String> - URL to the object’s representation (absolute path)
62
+ # * items<~Array> - Collection of individual firewall rules objects
63
+ # * id<~String> - The resource's unique identifier
64
+ # * type<~String> - The type of the resource
65
+ # * href<~String> - URL to the object’s representation (absolute path)
66
+ # * metadata<~Hash> - Hash containing the Firewall Rule metadata
67
+ # * createdDate<~String> - The date the resource was created
68
+ # * createdBy<~String> - The user who created the resource
69
+ # * etag<~String> - The etag for the resource
70
+ # * lastModifiedDate<~String> - The last time the resource has been modified
71
+ # * lastModifiedBy<~String> - The user who last modified the resource
72
+ # * state<~String> - Firewall Rule state
73
+ # * properties<~Hash> - Hash containing the Firewall Rule properties
74
+ # * name<~String> - The name of the Firewall Rule
75
+ # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY
76
+ # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed.
77
+ # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address
78
+ # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed.
79
+ # Value null allows all source IPs
80
+ # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed
81
+ # to the respective IP address of the NIC is allowed. Value null allows all target IPs
82
+ # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen.
83
+ # Value null allows all codes.
84
+ # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen.
85
+ # Value null allows all types
86
+ # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534)
87
+ # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd
88
+ # value null to allow all ports
89
+ # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534)
90
+ # if the protocol TCP or UDP is chosen. Leave portRangeStart and
91
+ # portRangeEnd value null to allow all ports
92
+ #
93
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-lan]
94
+ def update_lan(datacenter_id, lan_id, options={})
95
+ request(
96
+ :expects => [202],
97
+ :method => 'PATCH',
98
+ :path => "/datacenters/#{datacenter_id}/lans/#{lan_id}",
99
+ :body => Fog::JSON.encode(options)
100
+ )
101
+ rescue => error
102
+ Fog::Errors::NotFound.new(error)
103
+ end
104
+ end
105
+
106
+ class Mock
107
+ def update_lan(datacenter_id, lan_id, options={})
108
+ if lan = self.data[:lans]['items'].find {
109
+ |attrib| attrib['datacenter_id'] == datacenter_id && attrib['id'] == lan_id
110
+ }
111
+ options.each do |key, value|
112
+ lan[key] = value
113
+ end
114
+ else
115
+ raise Fog::Errors::NotFound.new('The requested LAN resource could not be found')
116
+ end
117
+
118
+ response = Excon::Response.new
119
+ response.status = 202
120
+ response.body = lan
121
+ response
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end