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,70 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Update a load balancer
6
+ #
7
+ # ==== Parameters
8
+ # * datacenter_id<~String> - Required - UUID of the NIC
9
+ # * load_balancer_id<~String> - Required - UUID of the load balancer
10
+ # * options<~Hash>:
11
+ # * name<~String> - The name of the Load Balancer
12
+ # * ip<~String> - The IP of the Load Balancer
13
+ # * dhcp<~Boolean> - Indicates if the loadbalancer will reserve an IP using DHCP
14
+ #
15
+ # ==== Returns
16
+ # * response<~Excon::Response>:
17
+ # * body<~Hash>:
18
+ # * id<~String> - The resource's unique identifier
19
+ # * type<~String> - The type of the created resource
20
+ # * href<~String> - URL to the object’s representation (absolute path)
21
+ # * metadata<~Hash> - Hash containing the Load Balancer metadata
22
+ # * createdDate<~String> - The date the resource was created
23
+ # * createdBy<~String> - The user who created the resource
24
+ # * etag<~String> - The etag for the resource
25
+ # * lastModifiedDate<~String> - The last time the resource has been modified
26
+ # * lastModifiedBy<~String> - The user who last modified the resource
27
+ # * state<~String> - Load Balancer state
28
+ # * properties<~Hash> - Hash containing the Load Balancer properties
29
+ # * name<~String> - The name of the Load Balancer
30
+ # * ip<~String> - Pv4 address of the Load Balancer. All attached NICs will inherit this IP
31
+ # * dhcp<~Boolean> - Indicates if the Load Balancer will reserve an IP using DHCP
32
+ # * entities<~Integer> - Hash containing the Load Balancer entities
33
+ # * balancednics<~Hash> - List of NICs taking part in load-balancing. All balanced nics inherit the IP of the loadbalancer.
34
+ # See the NIC section for attribute definitions
35
+ #
36
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-load-balancer]
37
+ def update_load_balancer(datacenter_id, load_balancer_id, options={})
38
+ request(
39
+ :expects => [202],
40
+ :method => 'PATCH',
41
+ :path => "/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}",
42
+ :body => Fog::JSON.encode(options)
43
+ )
44
+ rescue => error
45
+ Fog::Errors::NotFound.new(error)
46
+ end
47
+ end
48
+
49
+ class Mock
50
+ def update_load_balancer(datacenter_id, load_balancer_id, options={})
51
+ if load_balancer = self.data[:load_balancers]['items'].find {
52
+ |attribute| attribute["datacenter_id"] == datacenter_id && attribute["id"] == load_balancer_id
53
+ }
54
+ options.each do |key, value|
55
+ load_balancer[key] = value
56
+ end
57
+ else
58
+ raise Fog::Errors::NotFound.new('The requested resource could not be found')
59
+ end
60
+
61
+ response = Excon::Response.new
62
+ response.status = 202
63
+ response.body = load_balancer
64
+
65
+ response
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,107 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Update a virtual NIC
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
+ # * options<~Hash>:
12
+ # * name<~String> - The name of the NIC
13
+ # * ips<~Array> - IPs assigned to the NIC represented as a collection
14
+ # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not
15
+ # * lan<~Integer> - The LAN ID the NIC sits on
16
+ #
17
+ # ==== Returns
18
+ # * response<~Excon::Response>:
19
+ # * body<~Hash>:
20
+ # * id<~String> - The resource's unique identifier
21
+ # * type<~String> - The type of the created resource
22
+ # * href<~String> - URL to the object’s representation (absolute path)
23
+ # * metadata<~Hash> - Hash containing the NIC metadata
24
+ # * createdDate<~String> - The date the resource was created
25
+ # * createdBy<~String> - The user who created the resource
26
+ # * etag<~String> - The etag for the resource
27
+ # * lastModifiedDate<~String> - The last time the resource has been modified
28
+ # * lastModifiedBy<~String> - The user who last modified the resource
29
+ # * state<~String> - NIC state
30
+ # * properties<~Hash> - Hash containing the NIC properties
31
+ # * name<~String> - The name of the NIC
32
+ # * mac<~String> - The MAC address of the NIC
33
+ # * ips<~Array> - IPs assigned to the NIC represented as a collection
34
+ # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not
35
+ # * lan<~Integer> - The LAN ID the NIC sits on
36
+ # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value
37
+ # * entities<~Hash> - Hash containing the NIC entities
38
+ # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection
39
+ # * id<~String> - The resource's unique identifier
40
+ # * type<~String> - The type of the resource
41
+ # * href<~String> - URL to the object’s representation (absolute path)
42
+ # * items<~Array> - Collection of individual firewall rules objects
43
+ # * id<~String> - The resource's unique identifier
44
+ # * type<~String> - The type of the resource
45
+ # * href<~String> - URL to the object’s representation (absolute path)
46
+ # * metadata<~Hash> - Hash containing the Firewall Rule metadata
47
+ # * createdDate<~String> - The date the resource was created
48
+ # * createdBy<~String> - The user who created the resource
49
+ # * etag<~String> - The etag for the resource
50
+ # * lastModifiedDate<~String> - The last time the resource has been modified
51
+ # * lastModifiedBy<~String> - The user who last modified the resource
52
+ # * state<~String> - Firewall Rule state
53
+ # * properties<~Hash> - Hash containing the Firewall Rule properties
54
+ # * name<~String> - The name of the Firewall Rule
55
+ # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY
56
+ # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed.
57
+ # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address
58
+ # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed.
59
+ # Value null allows all source IPs
60
+ # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed
61
+ # to the respective IP address of the NIC is allowed. Value null allows all target IPs
62
+ # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen.
63
+ # Value null allows all codes.
64
+ # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen.
65
+ # Value null allows all types
66
+ # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534)
67
+ # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd
68
+ # value null to allow all ports
69
+ # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534)
70
+ # if the protocol TCP or UDP is chosen. Leave portRangeStart and
71
+ # portRangeEnd value null to allow all ports
72
+ #
73
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-a-nic]
74
+ def update_nic(datacenter_id, server_id, nic_id, options={})
75
+ request(
76
+ :expects => [202],
77
+ :method => 'PATCH',
78
+ :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}",
79
+ :body => Fog::JSON.encode(options)
80
+ )
81
+ rescue => error
82
+ Fog::Errors::NotFound.new(error)
83
+ end
84
+ end
85
+
86
+ class Mock
87
+ def update_nic(datacenter_id, server_id, nic_id, options={})
88
+ if nic = self.data[:nics]['items'].find {
89
+ |attribute| attribute["datacenter_id"] == datacenter_id && attribute["server_id"] == server_id && attribute["id"] == nic_id
90
+ }
91
+ options.each do |key, value|
92
+ nic[key] = value
93
+ end
94
+ else
95
+ raise Fog::Errors::NotFound.new('The requested resource could not be found')
96
+ end
97
+
98
+ response = Excon::Response.new
99
+ response.status = 202
100
+ response.body = nic
101
+
102
+ response
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,147 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Update the attributes of an existing virtual server
6
+ #
7
+ # ==== Parameters
8
+ # * datacenter_id<~String> - Required - UUID of the virtual data center
9
+ # * server_id<~String> - Required - UUID of the virtual server
10
+ # * properties<~Hash>: - A hash containing the server properties
11
+ # * name<~String> - Required - The hostname of the server
12
+ # * cores<~Integer> - Required - The total number of cores for the server
13
+ # * ram<~Integer> - Required - The amount of memory for the server in MB, e.g. 2048.
14
+ # Size must be specified in multiples of 256 MB with a minimum of 256 MB;
15
+ # however, if ramHotPlug is set to TRUE then a minimum of 1024 MB nust be used
16
+ # * availabilityZone<~String> - The availability zone for the server (AUTO, ZONE_1, ZONE_2)
17
+ # * bootCdrom<~Hash> - Reference to a CD-ROM used for booting. If not 'null' then bootVolume has to be 'null'
18
+ # * bootVolume<~Hash> - Reference to a Volume used for booting. If not 'null’ then bootCdrom has to be 'null’
19
+ # * cpuFamily<~String> - Type of CPU assigned ("AMD_OPTERON" or "INTEL_XEON")
20
+ #
21
+ # ==== Returns
22
+ # * response<~Excon::Response>:
23
+ # * body<~Hash>:
24
+ # * id<~String> - The resource's unique identifier
25
+ # * type<~String> - The type of the requested resource
26
+ # * href<~String> - URL to the object’s representation (absolute path)
27
+ # * metadata<~Hash> - A hash containing the server metadata
28
+ # * createdDate<~String> - The date the resource was created
29
+ # * createdBy<~String> - The user who created the resource
30
+ # * etag<~String> - The etag
31
+ # * lastModifiedDate<~String> - The last modified time for the resource
32
+ # * lastModifiedBy<~String> - The user who last modified the resource
33
+ # * state<~String> - Status of the virtual Machine
34
+ # * properties<~Hash> - A hash containing the server properties
35
+ # * name<~String> - The name of the server
36
+ # * cores<~Integer> - The number of cores for the server
37
+ # * ram<~Integer> - The amount of memory on the server (in megabytes)
38
+ # * availabilityZone<~String> - The availability zone for the server
39
+ # * vmState<~String> - The current state of the instance
40
+ # * bootCdrom<~Hash> - Reference to a CD-ROM used for booting. If not 'null' then bootVolume has to be 'null'.
41
+ # * bootVolume<~Hash> - Reference to a Volume used for booting. If not ‘null’ then bootCdrom has to be ‘null’
42
+ # * id<~String> - The resource's unique identifier
43
+ # * type<~String> - The type of the requested resource
44
+ # * href<~String> - URL to the object’s representation (absolute path)
45
+ # * metadata<~Hash> - Hash containing the volume metadata
46
+ # * createdDate<~String> - The date the resource was created
47
+ # * createdBy<~String> - The user who created the resource
48
+ # * etag<~String> - The etag for the resource
49
+ # * lastModifiedDate<~String> - The last time the resource has been modified
50
+ # * lastModifiedBy<~String> - The user who last modified the resource
51
+ # * state<~String> - Volume state
52
+ # * properties<~Hash> - Hash containing the volume properties
53
+ # * name<~String> - The name of the volume.
54
+ # * type<~String> - The volume type, HDD or SSD.
55
+ # * size<~Integer> - The size of the volume in GB.
56
+ # * image<~String> - The image or snapshot ID.
57
+ # * imagePassword<~String> - Indicates if a password is set on the image.
58
+ # * sshKeys<~String> - SSH keys
59
+ # * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO.
60
+ # * licenceType<~String> - Volume licence type. ( WINDOWS, LINUX, OTHER, UNKNOWN)
61
+ # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required)
62
+ # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required)
63
+ # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required)
64
+ # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required)
65
+ # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required)
66
+ # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required)
67
+ # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required)
68
+ # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required)
69
+ # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required)
70
+ # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required)
71
+ # * deviceNumber<~Integer> - The LUN ID of the storage volume
72
+ # * cpuFamily<~String> - Type of CPU assigned
73
+ # * entities<~Hash> - A hash containing the server entities
74
+ # * cdroms<~Hash> - A collection of cdroms attached to the server
75
+ # * id<~String> - The resource's unique identifier
76
+ # * type<~String> - The type of the requested resource
77
+ # * href<~String> - URL to the object’s representation (absolute path)
78
+ # * items<~Array> - The array containing individual cd rom resources
79
+ # * volumes<~Hash> - A collection of volumes attached to the server
80
+ # * id<~String> - The resource's unique identifier
81
+ # * type<~String> - The type of the requested resource
82
+ # * href<~String> - URL to the object’s representation (absolute path)
83
+ # * items<~Array> - The array containing individual volume resources (see bootVolume for detailed structure)
84
+ # * nics<~Hash> - A collection of NICs attached to the server
85
+ # * id<~String> - The resource's unique identifier
86
+ # * type<~String> - The type of the requested resource
87
+ # * href<~String> - URL to the object’s representation (absolute path)
88
+ # * items<~Array> - An array containing individual NIC resources
89
+ # * id<~String> - The resource's unique identifier
90
+ # * type<~String> - The type of the requested resource
91
+ # * href<~String> - URL to the object’s representation (absolute path)
92
+ # * metadata<~Hash> - A hash containing the nic metadata
93
+ # * createdDate<~String> - The date the resource was created
94
+ # * createdBy<~String> - The user who created the resource
95
+ # * etag<~String> - The etag for the resource
96
+ # * lastModifiedDate<~String> - The last time the resource has been modified
97
+ # * lastModifiedBy<~String> - The user who last modified the resource
98
+ # * state<~String> - NIC state
99
+ # * properties<~Hash> - A hash containing the nic properties
100
+ # * name<~String> - The name of the NIC
101
+ # * mac<~String> - The MAC address of the NIC
102
+ # * ips<~Array> - IPs assigned to the NIC represented as a collection
103
+ # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not
104
+ # * lan<~integer> - The LAN ID the NIC sits on
105
+ # * firewallActive<~Boolean> - Once you add a firewall rule this will reflect a true value
106
+ # * entities<~Hash> - A hash containing the nic entities
107
+ # * firewallrules<~hash> - A list of firewall rules associated to the NIC represented as a collection
108
+ # * id<~String> - The resource's unique identifier
109
+ # * type<~String> - The type of the requested resource
110
+ # * href<~String> - URL to the object’s representation (absolute path)
111
+ # * items<~Array> - An array of individual firewall rules associated to the NIC
112
+ #
113
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-a-server]
114
+ def update_server(datacenter_id, server_id, properties={})
115
+ request(
116
+ :expects => [202],
117
+ :method => 'PATCH',
118
+ :path => "/datacenters/#{datacenter_id}/servers/#{server_id}",
119
+ :body => Fog::JSON.encode(properties)
120
+ )
121
+ rescue => error
122
+ Fog::Errors::NotFound.new(error)
123
+ end
124
+ end
125
+
126
+ class Mock
127
+ def update_server(datacenter_id, server_id, properties={})
128
+
129
+ if server = self.data[:servers]['items'].find {
130
+ |attrib| attrib['id'] == server_id
131
+ }
132
+ properties.each do |key, value|
133
+ server[key] = value
134
+ end
135
+ else
136
+ raise Fog::Errors::NotFound.new('The requested server resource could not be found')
137
+ end
138
+
139
+ response = Excon::Response.new
140
+ response.status = 202
141
+ response.body = server
142
+ response
143
+ end
144
+ end
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,90 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Update an existing snapshot
6
+ #
7
+ # ==== Parameters
8
+ # * snapshot_id<~String> - Required, UUID of the snapshot
9
+ # * options<~Hash>:
10
+ # * name<~String> - The name of the snapshot
11
+ # * description<~String> - The description of the snapshot
12
+ # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required)
13
+ # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required)
14
+ # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required)
15
+ # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required)
16
+ # * nicHotPlug<~Boolean> - This volume is capable of NIC hot plug (no reboot required)
17
+ # * nicHotUnplug<~Boolean> - This volume is capable of NIC hot unplug (no reboot required)
18
+ # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required)
19
+ # * discVirtioHotUnplug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required)
20
+ # * discScsiHotPlug<~Boolean> - This volume is capable of SCSI drive hot plug (no reboot required)
21
+ # * discScsiHotUnplug<~Boolean> - This volume is capable of SCSI drive hot unplug (no reboot required)
22
+ # * licencetype<~String> - The snapshot's licence type: LINUX, WINDOWS, or UNKNOWN.
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> - A hash containing the resource's 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> - Snapshot state (AVAILABLE, BUSY, INACTIVE)
37
+ # * properties<~Hash> - A hash containing the resource's properties
38
+ # * name<~String> - The name of the snapshot
39
+ # * description<~String> - The description of the snapshot
40
+ # * location<~String> - The snapshot's location ("de/fkb", "de/fra", or "us/las")
41
+ # * version<~Integer> - The version of the data center
42
+ # * size<~Integer> - The size of the snapshot in GB
43
+ # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required)
44
+ # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required)
45
+ # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required)
46
+ # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required)
47
+ # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required)
48
+ # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required)
49
+ # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required)
50
+ # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required)
51
+ # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required)
52
+ # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required)
53
+ # * licencetype<~String> - The snapshot's licence type: LINUX, WINDOWS, or UNKNOWN.
54
+ #
55
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-snapshot]
56
+ def update_snapshot(snapshot_id, options={})
57
+ request(
58
+ :expects => [202],
59
+ :method => 'PATCH',
60
+ :path => "/snapshots/#{snapshot_id}",
61
+ :body => Fog::JSON.encode(options)
62
+ )
63
+ rescue => error
64
+ Fog::Errors::NotFound.new(error)
65
+ end
66
+ end
67
+
68
+ class Mock
69
+ def update_snapshot(snapshot_id, options={})
70
+ if snapshot = self.data[:snapshots]['items'].find {
71
+ |snpsht| snpsht["id"] == snapshot_id
72
+ }
73
+ options.each do |key, value|
74
+ snapshot[key] = value
75
+ end
76
+ else
77
+ raise Fog::Errors::NotFound.new('The requested resource could not be found')
78
+ end
79
+
80
+ response = Excon::Response.new
81
+ response.status = 202
82
+ response.body = snapshot
83
+
84
+ response
85
+ end
86
+ end
87
+
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,82 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Update a virtual storage
6
+ #
7
+ # ==== Parameters
8
+ # * datacenter_id<~String> - Required, UUID of virtual data center
9
+ # * volume_id<~String> - Required, UUID of volume
10
+ # * options<~Hash>:
11
+ # * name<~String> - The name of the volume
12
+ # * size<~Integer> - Required, the size of the volume in GB
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 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<~String> - Indicates if a password is set on the image.
33
+ # * sshKeys<~String> - SSH keys
34
+ # * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO.
35
+ # * licenceType<~String> - Volume licence type. ( WINDOWS, LINUX, OTHER, UNKNOWN)
36
+ # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required)
37
+ # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required)
38
+ # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required)
39
+ # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required)
40
+ # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required)
41
+ # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required)
42
+ # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required)
43
+ # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required)
44
+ # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required)
45
+ # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required)
46
+ # * deviceNumber<~Integer> - The LUN ID of the volume volume
47
+ #
48
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#update-volume]
49
+ def update_volume(datacenter_id, volume_id, options={})
50
+ request(
51
+ :expects => [202],
52
+ :method => 'PATCH',
53
+ :path => "/datacenters/#{datacenter_id}/volumes/#{volume_id}",
54
+ :body => Fog::JSON.encode(options)
55
+ )
56
+ rescue => error
57
+ Fog::Errors::NotFound.new(error)
58
+ end
59
+ end
60
+
61
+ class Mock
62
+ def update_volume(datacenter_id, volume_id, options={})
63
+
64
+ if volume = self.data[:volumes]['items'].find {
65
+ |vlm| vlm["id"] == volume_id && vlm["datacenter_id"] == datacenter_id
66
+ }
67
+ volume['name'] = options[:name]
68
+ volume['size'] = options[:size]
69
+ else
70
+ raise Fog::Errors::NotFound.new('The requested resource could not be found')
71
+ end
72
+
73
+ response = Excon::Response.new
74
+ response.status = 202
75
+ response.body = volume
76
+
77
+ response
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end