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,89 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Create a new virtual data center
6
+ #
7
+ # ==== Parameters
8
+ # * options<~Hash>:
9
+ # * name<~String> - The name of the data center
10
+ # * region<~String> - The physical location where the data center will be created ("de/fkb", "de/fra", or "us/las")
11
+ # * description<~String> - An optional description for the data center, e.g. staging, production.
12
+ #
13
+ # ==== Returns
14
+ # * response<~Excon::Response>:
15
+ # * body<~Hash>:
16
+ # * id<~String> - The resource's unique identifier
17
+ # * type<~String> - The type of the requested resource
18
+ # * href<~String> - URL to the object’s representation (absolute path)
19
+ # * metadata<~Hash> - A hash containing the resource's metadata
20
+ # * createdDate<~String> - The date the resource was created
21
+ # * createdBy<~String> - The user who created the resource
22
+ # * etag<~String> - The etag for the resource
23
+ # * lastModifiedDate<~String> - The last time the resource has been modified
24
+ # * lastModifiedBy<~String> - The user who last modified the resource
25
+ # * state<~String> - Data center state (AVAILABLE, BUSY, INACTIVE)
26
+ # * properties<~Hash> - A hash containing the resource's properties
27
+ # * name<~String> - The name of the data center
28
+ # * description<~String> - The description of the data center
29
+ # * location<~String> - The location where the data center was provisioned ("de/fkb", "de/fra", or "us/las")
30
+ # * version<~Integer> - The version of the data center
31
+ # * features<~Array> - The features of the data center
32
+ # * entities<~Hash> - A hash containing the datacenter entities
33
+ # * servers<~Hash> - A collection that represents the servers in a data center
34
+ # * volumes<~Hash> - A collection that represents volumes in a data center
35
+ # * loadbalancers<~Hash> - A collection that represents the loadbalancers in a data center
36
+ # * lans<~Hash> - A collection that represents the LANs in a data center
37
+ #
38
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-a-data-center]
39
+ def create_datacenter(options)
40
+ datacenter = {
41
+ :properties => options
42
+ }
43
+
44
+ request(
45
+ :expects => [202],
46
+ :method => 'POST',
47
+ :path => '/datacenters',
48
+ :body => Fog::JSON.encode(datacenter)
49
+ )
50
+ end
51
+ end
52
+
53
+ class Mock
54
+ def create_datacenter(options)
55
+ dc_3_id = Fog::UUID.uuid
56
+ datacenter = {
57
+ 'id'=>dc_3_id,
58
+ 'type'=>'datacenter',
59
+ 'href'=>"https://api.profitbricks.com/rest/v2/datacenters/#{dc_3_id}",
60
+ 'metadata'=>{
61
+ 'createdDate'=>'2016-07-31T15:41:27Z',
62
+ 'createdBy'=>'test@stackpointcloud.com',
63
+ 'etag'=>'5b91832ee85a758568d4523a86bd8702',
64
+ 'lastModifiedDate'=>'2016-07-31T15:41:27Z',
65
+ 'lastModifiedBy'=>'test@stackpointcloud.com',
66
+ 'state'=>'AVAILABLE'
67
+ },
68
+ 'properties'=>{
69
+ 'name'=>'dc_3',
70
+ 'description'=>'testing fog rest implementation',
71
+ 'location'=>'de/fra',
72
+ 'version'=>1,
73
+ 'features'=>[
74
+
75
+ ]
76
+ }
77
+ }
78
+
79
+ self.data[:datacenters]['items'] << datacenter
80
+ response = Excon::Response.new
81
+ response.status = 202
82
+ response.body = datacenter
83
+ response
84
+ end
85
+ end
86
+
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,103 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Adds a Firewall Rule to the NIC
6
+ #
7
+ # ==== Parameters
8
+ # * datacenter_id<~String> - Required, UUID of the virtual data center
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 Firewall Rule
13
+ # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY
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 to the respective
18
+ # IP address of the NIC is allowed. Value null allows all target IPs
19
+ # * portRangeStart<~String> - Defines the start range of the allowed port (from 1 to 65534) if protocol TCP or UDP is chosen.
20
+ # Leave portRangeStart and portRangeEnd value null to allow all ports
21
+ # * portRangeEnd<~String> - Defines the end range of the allowed port (from 1 to 65534) if the protocol TCP or UDP is chosen.
22
+ # Leave portRangeStart and portRangeEnd null to allow all ports
23
+ # * icmpType<~String> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. Value null allows all types
24
+ # * icmpCode<~String> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. Value null allows all codes
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
+ # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY
42
+ # * sourceMac<~String> - Only traffic originating from the respective MAC address is allowed.
43
+ # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address
44
+ # * sourceIp<~String> - Only traffic originating from the respective IPv4 address is allowed. Value null allows all source IPs
45
+ # * targetIp<~String> - In case the target NIC has multiple IP addresses, only traffic directed
46
+ # to the respective IP address of the NIC is allowed. Value null allows all target IPs
47
+ # * icmpCode<~String> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen. Value null allows all codes
48
+ # * icmpType<~String> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen. Value null allows all types
49
+ # * portRangeStart<~String> - Defines the start range of the allowed port (from 1 to 65534) if protocol TCP or UDP is chosen.
50
+ # Leave portRangeStart and portRangeEnd value null to allow all ports
51
+ # * portRangeEnd<~String> - Defines the end range of the allowed port (from 1 to 65534) if the protocol TCP or UDP is chosen.
52
+ # Leave portRangeStart and portRangeEnd null to allow all ports
53
+ #
54
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-firewall-rule]
55
+ def create_firewall_rule(datacenter_id, server_id, nic_id, options={})
56
+ firewall_rule = {
57
+ :properties => options
58
+ }
59
+
60
+ request(
61
+ :expects => [202],
62
+ :method => 'POST',
63
+ :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}/firewallrules",
64
+ :body => Fog::JSON.encode(firewall_rule)
65
+ )
66
+ rescue => error
67
+ Fog::Errors::NotFound.new(error)
68
+ end
69
+ end
70
+
71
+ class Mock
72
+ def create_firewall_rule(datacenter_id, server_id, nic_id, options={})
73
+ response = Excon::Response.new
74
+ response.status = 202
75
+
76
+ firewall_rule_id = Fog::UUID.uuid
77
+ firewall_rule = {
78
+ 'id' => firewall_rule_id,
79
+ 'type' => 'nic',
80
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}/firewallrules/#{firewall_rule_id}",
81
+ 'metadata' => {
82
+ 'createdDate' => '2015-03-18T19:00:51Z',
83
+ 'createdBy' => 'test@stackpointcloud.com',
84
+ 'etag' => 'faa67fbacb1c0e2e02cf9650657251f2',
85
+ 'lastModifiedDate' => '2015-03-18T19:00:51Z',
86
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
87
+ 'state' => 'AVAILABLE'
88
+ },
89
+ 'properties' => options,
90
+ 'datacenter_id' => datacenter_id,
91
+ 'server_id' => server_id,
92
+ 'nic_id' => nic_id,
93
+ }
94
+
95
+ self.data[:firewall_rules]['items'] << firewall_rule
96
+ response.body = firewall_rule
97
+
98
+ response
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,81 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Creates a LAN within a data center
6
+ #
7
+ # ==== Parameters
8
+ # * properties<~Hash>:
9
+ # * location<~String> - Required - This must be one of the locations: us/las, de/fra, de/fkb
10
+ # * size<~Integer> - Required - The desired size of the IP block
11
+ # * name<~String> - A descriptive name for the IP block
12
+ #
13
+ # ==== Returns
14
+ # * response<~Excon::Response>:
15
+ # * body<~Hash>:
16
+ # * id<~String> - The resource's unique identifier
17
+ # * type<~String> - The type of the created resource
18
+ # * href<~String> - URL to the object’s representation (absolute path)
19
+ # * metadata<~Hash> - Hash containing the IP Block metadata
20
+ # * createdDate<~String> - The date the resource was created
21
+ # * createdBy<~String> - The user who created the resource
22
+ # * etag<~String> - The etag for the resource
23
+ # * lastModifiedDate<~String> - The last time the resource has been modified
24
+ # * lastModifiedBy<~String> - The user who last modified the resource
25
+ # * state<~String> - IP Block state
26
+ # * properties<~Hash> - Hash containing the IP Block properties
27
+ # * ips<~Array> - A collection of IPs associated with the IP Block
28
+ # * location<~String> - Location the IP block resides in
29
+ # * size<~Integer> - Number of IP addresses in the block
30
+ # * name<~String> - A descriptive name given to the IP block
31
+ #
32
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-ip-block]
33
+ def create_ip_block(options = {})
34
+ ip_block = {
35
+ :properties => options
36
+ }
37
+
38
+ request(
39
+ :expects => [202],
40
+ :method => 'POST',
41
+ :path => "/ipblocks",
42
+ :body => Fog::JSON.encode(ip_block)
43
+ )
44
+ rescue => error
45
+ Fog::Errors::NotFound.new(error)
46
+ end
47
+ end
48
+
49
+ class Mock
50
+ def create_ip_block(options = {})
51
+ ipb_3_id = Fog::UUID.uuid
52
+ ip_block = {
53
+ 'id' => ipb_3_id,
54
+ 'type' => 'ipblock',
55
+ 'href' => "https://api.profitbricks.com/rest/v2/ipblocks/#{ipb_3_id}",
56
+ 'metadata' => {
57
+ 'createdDate' => '2016-07-31T15:41:27Z',
58
+ 'createdBy' => 'test@stackpointcloud.com',
59
+ 'etag' => '5b91832ee85a758568d4523a86bd8702',
60
+ 'lastModifiedDate' => '2016-07-31T15:41:27Z',
61
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
62
+ 'state' => 'AVAILABLE'
63
+ },
64
+ 'properties' => {
65
+ 'ips' => ["777.777.777.777", "888.888.888.888", "999.999.999.999"],
66
+ 'location' => options[:location],
67
+ 'size' => options[:size],
68
+ 'name' => options[:name]
69
+ }
70
+ }
71
+
72
+ self.data[:ip_blocks]['items'] << ip_block
73
+ response = Excon::Response.new
74
+ response.status = 202
75
+ response.body = ip_block
76
+ response
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,160 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Creates a LAN within a data center
6
+ #
7
+ # ==== Parameters
8
+ # * datacenter_id<~String> - Required - UUID of virtual data center
9
+ # * properties<~Hash>:
10
+ # * name<~String> - The name of the LAN
11
+ # * public<~Integer> - Boolean indicating if the LAN faces the public Internet or not
12
+ # * entities<~Hash>:
13
+ # * nics<~Array> - A collection of NICs associated with the LAN
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
+ # * items<~Hash> - Collection of individual lan objects
22
+ # * id<~String> - The resource's unique identifier
23
+ # * type<~String> - The type of the created resource
24
+ # * href<~String> - URL to the object’s representation (absolute path)
25
+ # * metadata<~Hash> - Hash containing the LAN metadata
26
+ # * createdDate<~String> - The date the resource was created
27
+ # * createdBy<~String> - The user who created the resource
28
+ # * etag<~String> - The etag for the resource
29
+ # * lastModifiedDate<~String> - The last time the resource has been modified
30
+ # * lastModifiedBy<~String> - The user who last modified the resource
31
+ # * state<~String> - LAN state
32
+ # * properties<~Hash> - Hash containing the LAN properties
33
+ # * name<~String> - The name of the LAN
34
+ # * public<~Boolean> - Boolean indicating if the LAN faces the public Internet or not
35
+ # * entities<~Hash> - Hash containing the LAN entities
36
+ # * nics<~Hash> - Hash containing the NIC properties
37
+ # * id<~String> - The resource's unique identifier
38
+ # * type<~String> - The type of the created resource
39
+ # * href<~String> - URL to the object’s representation (absolute path)
40
+ # * items<~Hash> - Collection of individual nic objects
41
+ # * id<~String> - The resource's unique identifier
42
+ # * type<~String> - The type of the created resource
43
+ # * href<~String> - URL to the object’s representation (absolute path)
44
+ # * metadata<~Hash> - Hash containing the NIC metadata
45
+ # * createdDate<~String> - The date the resource was created
46
+ # * createdBy<~String> - The user who created the resource
47
+ # * etag<~String> - The etag for the resource
48
+ # * lastModifiedDate<~String> - The last time the resource has been modified
49
+ # * lastModifiedBy<~String> - The user who last modified the resource
50
+ # * state<~String> - NIC state
51
+ # * properties<~Hash> - Hash containing the NIC properties
52
+ # * name<~String> - The name of the NIC
53
+ # * mac<~String> - The MAC address of the NIC
54
+ # * ips<~Array> - IPs assigned to the NIC represented as a collection
55
+ # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not
56
+ # * lan<~Integer> - The LAN ID the NIC sits on
57
+ # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value
58
+ # * entities<~Hash> - Hash containing the NIC entities
59
+ # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection
60
+ # * id<~String> - The resource's unique identifier
61
+ # * type<~String> - The type of the resource
62
+ # * href<~String> - URL to the object’s representation (absolute path)
63
+ # * items<~Array> - Collection of individual firewall rules objects
64
+ # * id<~String> - The resource's unique identifier
65
+ # * type<~String> - The type of the resource
66
+ # * href<~String> - URL to the object’s representation (absolute path)
67
+ # * metadata<~Hash> - Hash containing the Firewall Rule metadata
68
+ # * createdDate<~String> - The date the resource was created
69
+ # * createdBy<~String> - The user who created the resource
70
+ # * etag<~String> - The etag for the resource
71
+ # * lastModifiedDate<~String> - The last time the resource has been modified
72
+ # * lastModifiedBy<~String> - The user who last modified the resource
73
+ # * state<~String> - Firewall Rule state
74
+ # * properties<~Hash> - Hash containing the Firewall Rule properties
75
+ # * name<~String> - The name of the Firewall Rule
76
+ # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY
77
+ # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed.
78
+ # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address
79
+ # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed.
80
+ # Value null allows all source IPs
81
+ # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed
82
+ # to the respective IP address of the NIC is allowed. Value null allows all target IPs
83
+ # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen.
84
+ # Value null allows all codes.
85
+ # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen.
86
+ # Value null allows all types
87
+ # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534)
88
+ # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd
89
+ # value null to allow all ports
90
+ # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534)
91
+ # if the protocol TCP or UDP is chosen. Leave portRangeStart and
92
+ # portRangeEnd value null to allow all ports
93
+ #
94
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-lan]
95
+ def create_lan(datacenter_id, properties={}, entities={})
96
+ lan = {
97
+ :properties => properties,
98
+ :entities => entities
99
+ }
100
+
101
+ request(
102
+ :expects => [202],
103
+ :method => 'POST',
104
+ :path => "/datacenters/#{datacenter_id}/lans",
105
+ :body => Fog::JSON.encode(lan)
106
+ )
107
+ rescue => error
108
+ Fog::Errors::NotFound.new(error)
109
+ end
110
+ end
111
+
112
+ class Mock
113
+ def create_lan(datacenter_id, properties={}, entities={})
114
+ response = Excon::Response.new
115
+ response.status = 202
116
+
117
+ if datacenter = self.data[:datacenters]['items'].find {
118
+ |attrib| attrib['id'] == datacenter_id
119
+ }
120
+ datacenter['version'] += 1
121
+ else
122
+ raise Fog::Errors::NotFound.new('Data center resource could not be found')
123
+ end
124
+
125
+ lan = {
126
+ 'id' => '10',
127
+ 'type' => 'nic',
128
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/lans/10",
129
+ 'metadata' => {
130
+ 'createdDate' => '2015-03-18T19:00:51Z',
131
+ 'createdBy' => 'test@stackpointcloud.com',
132
+ 'etag' => 'faa67fbacb1c0e2e02cf9650657251f1',
133
+ 'lastModifiedDate' => '2015-03-18T19:00:51Z',
134
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
135
+ 'state' => 'AVAILABLE'
136
+ },
137
+ 'properties' => {
138
+ 'name' => properties[:name],
139
+ 'public' => properties[:public]
140
+ },
141
+ 'entities' => {
142
+ 'nics' => {
143
+ 'id' => '10/nics',
144
+ 'type' => 'collection',
145
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/lans/10/nics",
146
+ 'items' => [ ]
147
+ }
148
+ },
149
+ 'datacenter_id' => datacenter_id
150
+ }
151
+
152
+ self.data[:lans]['items'] << lan
153
+
154
+ response.body = lan
155
+ response
156
+ end
157
+ end
158
+ end
159
+ end
160
+ end
@@ -0,0 +1,87 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Creates a load balancer within the data center. Load balancers can be used for public or private IP traffic
6
+ #
7
+ # ==== Parameters
8
+ # * datacenter_id<~String> - Required, UUID of the virtual data center
9
+ # * properties<~Hash>:
10
+ # * name<~String> - Required - The name of the load balancer
11
+ # * ip<~String> - IPv4 address of the load balancer. All attached NICs will inherit this IP
12
+ # * dhcp<~Boolean> - Indicates if the load balancer will reserve an IP using DHCP
13
+ # * entities<~Hash>
14
+ # * balancednics<~Array> - List of NICs taking part in load-balancing. All balanced nics inherit the IP of the loadbalancer.
15
+ # See the NIC section for attribute definitions
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 Load Balancer 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> - Load Balancer state
30
+ # * properties<~Hash> - Hash containing the Load Balancer properties
31
+ # * name<~String> - The name of the Load Balancer
32
+ # * ip<~String> - Pv4 address of the Load Balancer. All attached NICs will inherit this IP
33
+ # * dhcp<~Boolean> - Indicates if the Load Balancer will reserve an IP using DHCP
34
+ # * entities<~Integer> - Hash containing the Load Balancer entities
35
+ # * balancednics<~Hash> - List of NICs taking part in load-balancing. All balanced nics inherit the IP of the loadbalancer.
36
+ # See the NIC section for attribute definitions
37
+ #
38
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-load-balancer]
39
+ def create_load_balancer(datacenter_id, properties={}, entities={})
40
+ load_balancer = {
41
+ :properties => properties,
42
+ :entities => entities
43
+ }
44
+
45
+ request(
46
+ :expects => [202],
47
+ :method => 'POST',
48
+ :path => "/datacenters/#{datacenter_id}/loadbalancers",
49
+ :body => Fog::JSON.encode(load_balancer)
50
+ )
51
+ rescue => error
52
+ Fog::Errors::NotFound.new(error)
53
+ end
54
+ end
55
+
56
+ class Mock
57
+ def create_load_balancer(datacenter_id, properties={}, entities={})
58
+ response = Excon::Response.new
59
+ response.status = 202
60
+
61
+ load_balancer_id = Fog::UUID.uuid
62
+ load_balancer = {
63
+ 'id' => load_balancer_id,
64
+ 'type' => 'nic',
65
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}",
66
+ 'metadata' => {
67
+ 'createdDate' => '2015-03-18T19:00:51Z',
68
+ 'createdBy' => 'test@stackpointcloud.com',
69
+ 'etag' => 'faa67fbacb1c0e2e02cf9650657251f2',
70
+ 'lastModifiedDate' => '2015-03-18T19:00:51Z',
71
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
72
+ 'state' => 'AVAILABLE'
73
+ },
74
+ 'properties' => properties,
75
+ 'entities' => entities,
76
+ 'datacenter_id' => datacenter_id
77
+ }
78
+
79
+ self.data[:load_balancers]['items'] << load_balancer
80
+ response.body = load_balancer
81
+
82
+ response
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end