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,124 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Adds a NIC to the target server
6
+ #
7
+ # ==== Parameters
8
+ # * datacenter_id<~String> - Required, UUID of the virtual data center
9
+ # * server_id<~String> - Required, UUID of the server
10
+ # * options<~Hash>:
11
+ # * name<~String> - The name of the NIC.
12
+ # * ips<~Array> - IPs assigned to the NIC. This can be a collection (string)
13
+ # * dhcp<~Boolean> - Set to FALSE if you wish to disable DHCP on the NIC. Default: TRUE
14
+ # * lan<~Integer> - Required, The LAN ID the NIC will sit on. If the LAN ID does not exist it will be created.
15
+ # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a TRUE value
16
+ # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection
17
+ #
18
+ # ==== Returns
19
+ # * response<~Excon::Response>:
20
+ # * body<~Hash>:
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 NIC 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> - NIC state
31
+ # * properties<~Hash> - Hash containing the NIC properties
32
+ # * name<~String> - The name of the NIC
33
+ # * mac<~String> - The MAC address of the NIC
34
+ # * ips<~Array> - IPs assigned to the NIC represented as a collection
35
+ # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not
36
+ # * lan<~Integer> - The LAN ID the NIC sits on
37
+ # * firewallActive<~Boolean> - Once a firewall rule is added, this will reflect a true value
38
+ # * entities<~Hash> - Hash containing the NIC entities
39
+ # * firewallrules<~Hash> - A list of firewall rules associated to the NIC represented as a collection
40
+ # * id<~String> - The resource's unique identifier
41
+ # * type<~String> - The type of the resource
42
+ # * href<~String> - URL to the object’s representation (absolute path)
43
+ # * items<~Array> - Collection of individual firewall rules objects
44
+ # * id<~String> - The resource's unique identifier
45
+ # * type<~String> - The type of the resource
46
+ # * href<~String> - URL to the object’s representation (absolute path)
47
+ # * metadata<~Hash> - Hash containing the Firewall Rule metadata
48
+ # * createdDate<~String> - The date the resource was created
49
+ # * createdBy<~String> - The user who created the resource
50
+ # * etag<~String> - The etag for the resource
51
+ # * lastModifiedDate<~String> - The last time the resource has been modified
52
+ # * lastModifiedBy<~String> - The user who last modified the resource
53
+ # * state<~String> - Firewall Rule state
54
+ # * properties<~Hash> - Hash containing the Firewall Rule properties
55
+ # * name<~String> - The name of the Firewall Rule
56
+ # * protocol<~String> - The protocol for the rule: TCP, UDP, ICMP, ANY
57
+ # * sourceMac<~Array> - Only traffic originating from the respective MAC address is allowed.
58
+ # Valid format: aa:bb:cc:dd:ee:ff. Value null allows all source MAC address
59
+ # * sourceIp<~Boolean> - Only traffic originating from the respective IPv4 address is allowed.
60
+ # Value null allows all source IPs
61
+ # * targetIp<~Integer> - In case the target NIC has multiple IP addresses, only traffic directed
62
+ # to the respective IP address of the NIC is allowed. Value null allows all target IPs
63
+ # * icmpCode<~Boolean> - Defines the allowed code (from 0 to 254) if protocol ICMP is chosen.
64
+ # Value null allows all codes.
65
+ # * icmpType<~Boolean> - Defines the allowed type (from 0 to 254) if the protocol ICMP is chosen.
66
+ # Value null allows all types
67
+ # * portRangeStart<~Boolean> - Defines the start range of the allowed port (from 1 to 65534)
68
+ # if protocol TCP or UDP is chosen. Leave portRangeStart and portRangeEnd
69
+ # value null to allow all ports
70
+ # * portRangeEnd<~Boolean> - Defines the end range of the allowed port (from 1 to 65534)
71
+ # if the protocol TCP or UDP is chosen. Leave portRangeStart and
72
+ # portRangeEnd value null to allow all ports
73
+ #
74
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-a-nic]
75
+ def create_nic(datacenter_id, server_id, options={}, entities={})
76
+ nic = {
77
+ :properties => options,
78
+ :entities => entities
79
+ }
80
+
81
+ request(
82
+ :expects => [202],
83
+ :method => 'POST',
84
+ :path => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics",
85
+ :body => Fog::JSON.encode(nic)
86
+ )
87
+ rescue => error
88
+ Fog::Errors::NotFound.new(error)
89
+ end
90
+ end
91
+
92
+ class Mock
93
+ def create_nic(datacenter_id, server_id, options={}, entities={})
94
+ response = Excon::Response.new
95
+ response.status = 202
96
+
97
+ nic_id = Fog::UUID.uuid
98
+ nic = {
99
+ 'id' => nic_id,
100
+ 'type' => 'nic',
101
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}",
102
+ 'metadata' => {
103
+ 'createdDate' => '2015-03-18T19:00:51Z',
104
+ 'createdBy' => 'test@stackpointcloud.com',
105
+ 'etag' => 'faa67fbacb1c0e2e02cf9650657251f2',
106
+ 'lastModifiedDate' => '2015-03-18T19:00:51Z',
107
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
108
+ 'state' => 'AVAILABLE'
109
+ },
110
+ 'properties' => options,
111
+ 'entities' => entities,
112
+ 'datacenter_id' => datacenter_id,
113
+ 'server_id' => server_id
114
+ }
115
+
116
+ self.data[:nics]['items'] << nic
117
+ response.body = nic
118
+
119
+ response
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,257 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Creates a server within an existing data center.
6
+ # Additional properties such as specifying a boot volume and
7
+ # connecting the server to an existing LAN can be configured.
8
+ #
9
+ # ==== Parameters
10
+ # * datacenter_id<~String> - Required - UUID of virtual data center
11
+ # * properties<~Hash>: - A hash containing the server properties
12
+ # * name<~String> - Required - The hostname of the server
13
+ # * cores<~Integer> - Required - The total number of cores for the server
14
+ # * ram<~Integer> - Required - The amount of memory for the server in MB, e.g. 2048.
15
+ # Size must be specified in multiples of 256 MB with a minimum of 256 MB;
16
+ # however, if ramHotPlug is set to TRUE then a minimum of 1024 MB nust be used
17
+ # * availabilityZone<~String> - The availability zone for the server (AUTO, ZONE_1, ZONE_2)
18
+ # * bootCdrom<~Hash> - Reference to a CD-ROM used for booting. If not 'null' then bootVolume has to be 'null'
19
+ # * bootVolume<~Hash> - Reference to a Volume used for booting. If not 'null’ then bootCdrom has to be 'null’
20
+ # * cpuFamily<~String> - Type of CPU assigned ("AMD_OPTERON" or "INTEL_XEON")
21
+ # * entities<~Hash>: - A hash containing the server entities
22
+ # * cdroms<~Hash> - A collection of cdroms attached to the server
23
+ # * volumes<~Hash> - A collection of volumes attached to the server
24
+ # * nics<~Hash> - A collection of NICs attached to the server
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 requested resource
31
+ # * href<~String> - URL to the object’s representation (absolute path)
32
+ # * metadata<~Hash> - A hash containing the server metadata
33
+ # * createdDate<~String> - The date the resource was created
34
+ # * createdBy<~String> - The user who created the resource
35
+ # * etag<~String> - The etag
36
+ # * lastModifiedDate<~String> - The last modified time for the resource
37
+ # * lastModifiedBy<~String> - The user who last modified the resource
38
+ # * state<~String> - Status of the virtual Machine
39
+ # * properties<~Hash> - A hash containing the server properties
40
+ # * name<~String> - The name of the server
41
+ # * cores<~Integer> - The number of cores for the server
42
+ # * ram<~Integer> - The amount of memory on the server (in megabytes)
43
+ # * availabilityZone<~String> - The availability zone for the server
44
+ # * vmState<~String> - The current state of the instance
45
+ # * bootCdrom<~Hash> - Reference to a CD-ROM used for booting. If not 'null' then bootVolume has to be 'null'.
46
+ # * bootVolume<~Hash> - Reference to a Volume used for booting. If not ‘null’ then bootCdrom has to be ‘null’
47
+ # * id<~String> - The resource's unique identifier
48
+ # * type<~String> - The type of the requested resource
49
+ # * href<~String> - URL to the object’s representation (absolute path)
50
+ # * metadata<~Hash> - Hash containing the volume metadata
51
+ # * createdDate<~String> - The date the resource was created
52
+ # * createdBy<~String> - The user who created the resource
53
+ # * etag<~String> - The etag for the resource
54
+ # * lastModifiedDate<~String> - The last time the resource has been modified
55
+ # * lastModifiedBy<~String> - The user who last modified the resource
56
+ # * state<~String> - Volume state
57
+ # * properties<~Hash> - Hash containing the volume properties
58
+ # * name<~String> - The name of the volume.
59
+ # * type<~String> - The volume type, HDD or SSD.
60
+ # * size<~Integer> - The size of the volume in GB.
61
+ # * image<~String> - The image or snapshot ID.
62
+ # * imagePassword<~String> - Indicates if a password is set on the image.
63
+ # * sshKeys<~String> - SSH keys
64
+ # * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO.
65
+ # * licenceType<~String> - Volume licence type. ( WINDOWS, LINUX, OTHER, UNKNOWN)
66
+ # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required)
67
+ # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required)
68
+ # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required)
69
+ # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required)
70
+ # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required)
71
+ # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required)
72
+ # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required)
73
+ # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required)
74
+ # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required)
75
+ # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required)
76
+ # * deviceNumber<~Integer> - The LUN ID of the storage volume
77
+ # * cpuFamily<~String> - Type of CPU assigned
78
+ # * entities<~Hash> - A hash containing the server entities
79
+ # * cdroms<~Hash> - A collection of cdroms 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 cd rom resources
84
+ # * volumes<~Hash> - A collection of volumes 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> - The array containing individual volume resources (see bootVolume for detailed structure)
89
+ # * nics<~Hash> - A collection of NICs attached to the server
90
+ # * id<~String> - The resource's unique identifier
91
+ # * type<~String> - The type of the requested resource
92
+ # * href<~String> - URL to the object’s representation (absolute path)
93
+ # * items<~Array> - An array containing individual NIC resources
94
+ # * id<~String> - The resource's unique identifier
95
+ # * type<~String> - The type of the requested resource
96
+ # * href<~String> - URL to the object’s representation (absolute path)
97
+ # * metadata<~Hash> - A hash containing the nic metadata
98
+ # * createdDate<~String> - The date the resource was created
99
+ # * createdBy<~String> - The user who created the resource
100
+ # * etag<~String> - The etag for the resource
101
+ # * lastModifiedDate<~String> - The last time the resource has been modified
102
+ # * lastModifiedBy<~String> - The user who last modified the resource
103
+ # * state<~String> - NIC state
104
+ # * properties<~Hash> - A hash containing the nic properties
105
+ # * name<~String> - The name of the NIC
106
+ # * mac<~String> - The MAC address of the NIC
107
+ # * ips<~Array> - IPs assigned to the NIC represented as a collection
108
+ # * dhcp<~Boolean> - Boolean value that indicates if the NIC is using DHCP or not
109
+ # * lan<~integer> - The LAN ID the NIC sits on
110
+ # * firewallActive<~Boolean> - Once you add a firewall rule this will reflect a true value
111
+ # * entities<~Hash> - A hash containing the nic entities
112
+ # * firewallrules<~hash> - A list of firewall rules associated to the NIC represented as a collection
113
+ # * id<~String> - The resource's unique identifier
114
+ # * type<~String> - The type of the requested resource
115
+ # * href<~String> - URL to the object’s representation (absolute path)
116
+ # * items<~Array> - An array of individual firewall rules associated to the NIC
117
+ #
118
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-a-server]
119
+ def create_server(datacenter_id, properties={}, entities={})
120
+ server = {
121
+ :properties => properties,
122
+ :entities => entities
123
+ }
124
+
125
+ request(
126
+ :expects => [202],
127
+ :method => 'POST',
128
+ :path => "/datacenters/#{datacenter_id}/servers",
129
+ :body => Fog::JSON.encode(server)
130
+ )
131
+ rescue => error
132
+ Fog::Errors::NotFound.new(error)
133
+ end
134
+ end
135
+
136
+ class Mock
137
+ def create_server(datacenter_id, properties={}, entities={})
138
+ server_id = Fog::UUID.uuid
139
+ volume_id = entities[:volumes]['items'][0]['id']
140
+
141
+ server = {
142
+ 'id' => server_id,
143
+ 'type' => 'server',
144
+ 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}",
145
+ 'metadata' => {
146
+ 'createdDate' => '2014-10-20T21:20:46Z',
147
+ 'createdBy' => 'test@stackpointcloud.com',
148
+ 'etag' => '0018832d7a7ba455db74ac41ae9f11fe',
149
+ 'lastModifiedDate' => '2015-03-18T21:31:10Z',
150
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
151
+ 'state' => 'AVAILABLE'
152
+ },
153
+ 'properties' => {
154
+ 'name' => properties[:name],
155
+ 'cores' => properties[:cores],
156
+ 'ram' => properties[:ram],
157
+ 'availabilityZone' => properties[:availabilityZone],
158
+ 'vmState' => 'RUNNING',
159
+ 'cpuFamily' => properties[:cpuFamily]
160
+ },
161
+ 'entities' => {
162
+ 'volumes' => {
163
+ 'id' => "#{server_id}/volumes",
164
+ 'type' => 'collection',
165
+ 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/volumes",
166
+ 'items' =>
167
+ [
168
+ {
169
+ 'id' => volume_id,
170
+ 'type' => 'volume',
171
+ 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/volumes/#{volume_id}",
172
+ 'metadata' => {
173
+ 'createdDate' => '2015-03-18T19=>00=>51Z',
174
+ 'createdBy' => 'test@stackpointcloud.com',
175
+ 'etag' => 'c4a2fde6ba91a038ff953b939cc21efe',
176
+ 'lastModifiedDate' => '2015-03-18T19=>00=>51Z',
177
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
178
+ 'state' => 'AVAILABLE'
179
+ },
180
+ 'properties' => {
181
+ 'name' => 'FogRestTestVolume',
182
+ 'type' => 'HDD',
183
+ 'size' => 5,
184
+ 'image' => '4f363db0-4955-11e4-b362-52540066fee9',
185
+ 'bus' => 'VIRTIO',
186
+ 'licenceType' => 'OTHER',
187
+ 'cpuHotPlug' => 'true',
188
+ 'cpuHotUnplug' => 'false',
189
+ 'ramHotPlug' => 'false',
190
+ 'ramHotUnplug' => 'false',
191
+ 'nicHotPlug' => 'true',
192
+ 'nicHotUnplug' => 'true',
193
+ 'discVirtioHotPlug' => 'true',
194
+ 'discVirtioHotUnplug' => 'true',
195
+ 'discScsiHotPlug' => 'false',
196
+ 'discScsiHotUnplug' => 'false',
197
+ 'deviceNumber' => 1
198
+ }
199
+ }
200
+ ]
201
+ },
202
+ 'cdroms' => {
203
+ 'id' => "#{server_id}/cdroms",
204
+ 'type' => 'collection',
205
+ 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/cdroms",
206
+ 'items' =>
207
+ [
208
+ {
209
+ 'id' => 'dfcb40db-28b5-11e6-9336-52540005ab80',
210
+ 'type' => 'image',
211
+ 'href' => 'https=>//api.profitbricks.com/rest/v2/images/dfcb40db-28b5-11e6-9336-52540005ab80',
212
+ 'metadata' => {
213
+ 'createdDate' => '2016-06-02T11:33:49Z',
214
+ 'createdBy' => 'System',
215
+ 'etag' => '9909709d99655c6f31aca789998d7d89',
216
+ 'lastModifiedDate' => '2016-06-02T11:33:49Z',
217
+ 'lastModifiedBy' => 'System',
218
+ 'state' => 'AVAILABLE'
219
+ },
220
+ 'properties' => {
221
+ 'name' => 'CentOS-6.8-x86_64-netinstall.iso',
222
+ 'description' => '',
223
+ 'location' => 'us/las',
224
+ 'size' => 0.23,
225
+ 'cpuHotPlug' => 'true',
226
+ 'cpuHotUnplug' => 'false',
227
+ 'ramHotPlug' => 'true',
228
+ 'ramHotUnplug' => 'false',
229
+ 'nicHotPlug' => 'true',
230
+ 'nicHotUnplug' => 'true',
231
+ 'discVirtioHotPlug' => 'true',
232
+ 'discVirtioHotUnplug' => 'true',
233
+ 'discScsiHotPlug' => 'false',
234
+ 'discScsiHotUnplug' => 'false',
235
+ 'licenceType' => 'LINUX',
236
+ 'imageType' => 'CDROM',
237
+ 'public' => 'true'
238
+ }
239
+ }
240
+ ]
241
+ }
242
+ },
243
+ 'datacenter_id' => datacenter_id
244
+ }
245
+
246
+ self.data[:servers]['items'] << server
247
+
248
+ response = Excon::Response.new
249
+ response.status = 202
250
+ response.body = server
251
+
252
+ response
253
+ end
254
+ end
255
+ end
256
+ end
257
+ end
@@ -0,0 +1,133 @@
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks
4
+ class Real
5
+ # Creates a volume within the data center. This will NOT attach the volume to a server.
6
+ #
7
+ # ==== Parameters
8
+ # * datacenter_id<~String> - Required, UUID of virtual data center
9
+ # * options<~Hash>:
10
+ # * name<~String> - The name of the volume
11
+ # * size<~Integer> - Required, the size of the volume in GB
12
+ # * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO.
13
+ # * image<~String> - Required**, the image or snapshot ID
14
+ # * type<~String> - The volume type, HDD or SSD
15
+ # * licenceType<~String> - Required**, the licence type of the volume. Options: LINUX, WINDOWS, UNKNOWN, OTHER
16
+ # * imagePassword<~String> - One-time password is set on the Image for the appropriate account.
17
+ # This field may only be set in creation requests. When reading, it always returns null.
18
+ # Password has to contain 8-50 characters.
19
+ # Only these characters are allowed: [abcdefghjkmnpqrstuvxABCDEFGHJKLMNPQRSTUVX23456789]
20
+ # * sshKeys<~String> - SSH keys to allow access to the volume via SSH
21
+ #
22
+ # ** Either the image or the licenceType parameters need to be provided.
23
+ # licenceType is required, but if image is supplied, it will already have a licenceType set.
24
+ #
25
+ # ==== Returns
26
+ # * response<~Excon::Response>:
27
+ # * body<~Hash>:
28
+ # * id<~String> - The resource's unique identifier
29
+ # * type<~String> - The type of the created resource
30
+ # * href<~String> - URL to the object's representation (absolute path)
31
+ # * metadata<~Hash> - Hash containing the volume metadata
32
+ # * createdDate<~String> - The date the resource was created
33
+ # * createdBy<~String> - The user who created the resource
34
+ # * etag<~String> - The etag for the resource
35
+ # * lastModifiedDate<~String> - The last time the resource has been modified
36
+ # * lastModifiedBy<~String> - The user who last modified the resource
37
+ # * state<~String> - Volume state
38
+ # * properties<~Hash> - Hash containing the volume properties
39
+ # * name<~String> - The name of the volume.
40
+ # * type<~String> - The volume type, HDD or SSD.
41
+ # * size<~Integer> - The size of the volume in GB.
42
+ # * image<~String> - The image or snapshot ID.
43
+ # * imagePassword<~String> - Indicates if a password is set on the image.
44
+ # * sshKeys<~String> - SSH keys
45
+ # * bus<~String> - The bus type of the volume (VIRTIO or IDE). Default: VIRTIO.
46
+ # * licenceType<~String> - Volume licence type. ( WINDOWS, LINUX, OTHER, UNKNOWN)
47
+ # * cpuHotPlug<~Boolean> - This volume is capable of CPU hot plug (no reboot required)
48
+ # * cpuHotUnplug<~Boolean> - This volume is capable of CPU hot unplug (no reboot required)
49
+ # * ramHotPlug<~Boolean> - This volume is capable of memory hot plug (no reboot required)
50
+ # * ramHotUnplug<~Boolean> - This volume is capable of memory hot unplug (no reboot required)
51
+ # * nicHotPlug<~Boolean> - This volume is capable of nic hot plug (no reboot required)
52
+ # * nicHotUnplug<~Boolean> - This volume is capable of nic hot unplug (no reboot required)
53
+ # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot plug (no reboot required)
54
+ # * discVirtioHotPlug<~Boolean> - This volume is capable of Virt-IO drive hot unplug (no reboot required)
55
+ # * discScsiHotPlug<~Boolean> - This volume is capable of Scsi drive hot plug (no reboot required)
56
+ # * discScsiHotUnplug<~Boolean> - This volume is capable of Scsi drive hot unplug (no reboot required)
57
+ # * deviceNumber<~Integer> - The LUN ID of the volume volume
58
+ #
59
+ # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#create-volume]
60
+ def create_volume(datacenter_id, options={})
61
+ volume = {
62
+ :properties => options
63
+ }
64
+
65
+ request(
66
+ :expects => [202],
67
+ :method => 'POST',
68
+ :path => "/datacenters/#{datacenter_id}/volumes",
69
+ :body => Fog::JSON.encode(volume)
70
+ )
71
+ rescue => error
72
+ Fog::Errors::NotFound.new(error)
73
+ end
74
+ end
75
+
76
+ class Mock
77
+ def create_volume(datacenter_id, options={})
78
+ response = Excon::Response.new
79
+ response.status = 202
80
+
81
+ if datacenter = self.data[:datacenters]['items'].find {
82
+ |attrib| attrib['id'] == datacenter_id
83
+ }
84
+ datacenter['properties']['version'] += 1
85
+ else
86
+ raise Fog::Errors::NotFound.new('Data center resource could not be found')
87
+ end
88
+
89
+ volume_id = Fog::UUID.uuid
90
+
91
+ volume = {
92
+ 'id' => volume_id,
93
+ 'type' => 'volume',
94
+ 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter['id']}/volumes/#{volume_id}",
95
+ 'metadata' => {
96
+ 'createdDate' => '2015-03-18T19=>00=>51Z',
97
+ 'createdBy' => 'test@stackpointcloud.com',
98
+ 'etag' => 'c4a2fde6ba91a038ff953b939cc21efe',
99
+ 'lastModifiedDate' => '2015-03-18T19=>00=>51Z',
100
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
101
+ 'state' => 'AVAILABLE'
102
+ },
103
+ 'properties' => {
104
+ 'name' => options[:name],
105
+ 'type' => options[:type],
106
+ 'size' => options[:size],
107
+ 'image' => options[:image],
108
+ 'bus' => 'VIRTIO',
109
+ 'licenceType' => 'OTHER',
110
+ 'cpuHotPlug' => 'true',
111
+ 'cpuHotUnplug' => 'false',
112
+ 'ramHotPlug' => 'false',
113
+ 'ramHotUnplug' => 'false',
114
+ 'nicHotPlug' => 'true',
115
+ 'nicHotUnplug' => 'true',
116
+ 'discVirtioHotPlug' => 'true',
117
+ 'discVirtioHotUnplug' => 'true',
118
+ 'discScsiHotPlug' => 'false',
119
+ 'discScsiHotUnplug' => 'false',
120
+ 'deviceNumber' => 1
121
+ },
122
+ 'datacenter_id' => datacenter['id']
123
+ }
124
+
125
+ self.data[:volumes]['items'] << volume
126
+
127
+ response.body = volume
128
+ response
129
+ end
130
+ end
131
+ end
132
+ end
133
+ end