fog-oneandone 1.0 → 1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +3 -1
  3. data/Rakefile +24 -0
  4. data/examples/example_app.rb +39 -12
  5. data/fog-oneandone.gemspec +2 -1
  6. data/lib/oneandone/compute.rb +103 -16
  7. data/lib/oneandone/models/compute/baremetal_model.rb +15 -0
  8. data/lib/oneandone/models/compute/baremetal_models.rb +24 -0
  9. data/lib/oneandone/models/compute/block_storage.rb +100 -0
  10. data/lib/oneandone/models/compute/block_storages.rb +24 -0
  11. data/lib/oneandone/models/compute/firewall.rb +0 -15
  12. data/lib/oneandone/models/compute/image.rb +6 -1
  13. data/lib/oneandone/models/compute/public_ip.rb +2 -1
  14. data/lib/oneandone/models/compute/recovery_appliance.rb +18 -0
  15. data/lib/oneandone/models/compute/recovery_appliances.rb +24 -0
  16. data/lib/oneandone/models/compute/server.rb +44 -105
  17. data/lib/oneandone/models/compute/server_appliance.rb +25 -0
  18. data/lib/oneandone/models/compute/server_appliances.rb +24 -0
  19. data/lib/oneandone/models/compute/ssh_key.rb +67 -0
  20. data/lib/oneandone/models/compute/ssh_keys.rb +24 -0
  21. data/lib/oneandone/requests/compute/add_block_storage_server.rb +61 -0
  22. data/lib/oneandone/requests/compute/add_ports.rb +1 -1
  23. data/lib/oneandone/requests/compute/create_block_storage.rb +80 -0
  24. data/lib/oneandone/requests/compute/create_image.rb +9 -3
  25. data/lib/oneandone/requests/compute/create_server.rb +11 -5
  26. data/lib/oneandone/requests/compute/create_ssh_key.rb +74 -0
  27. data/lib/oneandone/requests/compute/delete_block_storage.rb +51 -0
  28. data/lib/oneandone/requests/compute/delete_ssh_key.rb +51 -0
  29. data/lib/oneandone/requests/compute/get_baremetal_model.rb +42 -0
  30. data/lib/oneandone/requests/compute/get_block_storage.rb +50 -0
  31. data/lib/oneandone/requests/compute/get_block_storage_server.rb +50 -0
  32. data/lib/oneandone/requests/compute/get_recovery_appliance.rb +41 -0
  33. data/lib/oneandone/requests/compute/get_ssh_key.rb +50 -0
  34. data/lib/oneandone/requests/compute/list_baremetal_models.rb +49 -0
  35. data/lib/oneandone/requests/compute/list_block_storages.rb +56 -0
  36. data/lib/oneandone/requests/compute/list_recovery_appliances.rb +47 -0
  37. data/lib/oneandone/requests/compute/list_ssh_keys.rb +56 -0
  38. data/lib/oneandone/requests/compute/remove_block_storage_server.rb +50 -0
  39. data/lib/oneandone/requests/compute/update_block_storage.rb +80 -0
  40. data/lib/oneandone/requests/compute/update_ssh_key.rb +78 -0
  41. data/tests/oneandone/test_block_storages.rb +82 -0
  42. data/tests/oneandone/test_firewalls.rb +5 -16
  43. data/tests/oneandone/test_recovery_appliances.rb +34 -0
  44. data/tests/oneandone/test_server_appliances.rb +34 -0
  45. data/tests/oneandone/test_ssh_keys.rb +82 -0
  46. metadata +58 -13
  47. data/lib/oneandone/requests/compute/remove_firewall_ip.rb +0 -60
@@ -0,0 +1,24 @@
1
+ require_relative 'block_storage'
2
+
3
+ module Fog
4
+ module Compute
5
+ class OneAndOne
6
+ class BlockStorages < Fog::Collection
7
+ model Fog::Compute::OneAndOne::BlockStorage
8
+
9
+ def all
10
+ response = service.list_block_storages
11
+ load(response.body)
12
+ end
13
+
14
+ def get(id)
15
+ response = service.get_block_storage(id)
16
+ new(response.body)
17
+ rescue Excon::Errors::NotFound
18
+ nil
19
+ end
20
+
21
+ end # BlockStorages
22
+ end # OneAndOne
23
+ end # Compute
24
+ end # Fog
@@ -60,21 +60,6 @@ module Fog
60
60
  end
61
61
 
62
62
 
63
- def remove_ip(options = {})
64
-
65
- requires :id
66
-
67
- response = service.remove_firewall_ip(firewall_id: id,
68
- ip_id: options[:ip_id])
69
-
70
- # Merge Attributes
71
- merge_attributes(response.body)
72
-
73
- true
74
-
75
- end
76
-
77
-
78
63
  def add_rules(options = {})
79
64
 
80
65
  requires :id
@@ -16,6 +16,10 @@ module Fog
16
16
  attribute :frequency
17
17
  attribute :num_images
18
18
  attribute :creation_date
19
+ attribute :source
20
+ attribute :url
21
+ attribute :os_id
22
+ attribute :type
19
23
 
20
24
 
21
25
  def save
@@ -24,7 +28,8 @@ module Fog
24
28
 
25
29
  # Perform Request
26
30
  response = service.create_image(name: name, description: description,
27
- server_id: server_id, frequency: frequency, num_images: num_images)
31
+ server_id: server_id, frequency: frequency, num_images: num_images,
32
+ source: source, url: url, os_id: os_id, type: type)
28
33
 
29
34
  # Merge Attributes
30
35
  merge_attributes(response.body)
@@ -14,7 +14,8 @@ module Fog
14
14
  attribute :assigned_to
15
15
  attribute :state
16
16
  attribute :creation_date
17
-
17
+ attribute :is_dhcp
18
+
18
19
 
19
20
  def save
20
21
 
@@ -0,0 +1,18 @@
1
+ module Fog
2
+ module Compute
3
+ class OneAndOne
4
+ class RecoveryAppliance < Fog::Model
5
+
6
+ # Declare Model Attributes
7
+ identity :id
8
+
9
+ attribute :name
10
+ attribute :os_family
11
+ attribute :os
12
+ attribute :os_version
13
+ attribute :os_architecture
14
+
15
+ end # RecoveryAppliance
16
+ end # OneAndOne
17
+ end # Compute
18
+ end # Fog
@@ -0,0 +1,24 @@
1
+ require_relative 'recovery_appliance'
2
+
3
+ module Fog
4
+ module Compute
5
+ class OneAndOne
6
+ class RecoveryAppliances < Fog::Collection
7
+ model Fog::Compute::OneAndOne::RecoveryAppliance
8
+
9
+ def all
10
+ response = service.list_recovery_appliances
11
+ load(response.body)
12
+ end
13
+
14
+ def get(id)
15
+ response = service.get_recovery_appliance(id)
16
+ new(response.body)
17
+ rescue Excon::Errors::NotFound
18
+ nil
19
+ end
20
+
21
+ end # RecoveryAppliances
22
+ end # OneAndOne
23
+ end # Compute
24
+ end # Fog
@@ -10,6 +10,8 @@ module Fog
10
10
  identity :id
11
11
 
12
12
  attribute :name
13
+ attribute :server_type
14
+ attribute :baremetal_model_id
13
15
  attribute :description
14
16
  attribute :rsa_key
15
17
  attribute :fixed_instance_id
@@ -21,6 +23,8 @@ module Fog
21
23
  attribute :datacenter_id
22
24
  attribute :creation_date
23
25
  attribute :first_password
26
+ attribute :ipv6_range
27
+ attribute :hostname
24
28
  attribute :status
25
29
  attribute :hardware
26
30
  attribute :image
@@ -37,9 +41,11 @@ module Fog
37
41
  attribute :alerts
38
42
  attribute :monitoring_policy
39
43
  attribute :private_networks
44
+ attribute :public_key
40
45
 
41
46
 
42
47
  def save
48
+ server_type ||= 'cloud'
43
49
 
44
50
  requires :name, :appliance_id
45
51
 
@@ -48,6 +54,8 @@ module Fog
48
54
  requires :ram, :vcore, :cores_per_processor, :hdds
49
55
  end
50
56
 
57
+ requires :baremetal_model_id if server_type == 'baremetal'
58
+
51
59
  # Perform Request
52
60
  response = service.create_server(name: name, description: description,
53
61
  rsa_key: rsa_key, fixed_instance_id: fixed_instance_id,
@@ -55,111 +63,94 @@ module Fog
55
63
  appliance_id: appliance_id, hdds: hdds, datacenter_id: datacenter_id,
56
64
  password: password, power_on: power_on, firewall_id: firewall_id,
57
65
  ip_id: ip_id, load_balancer_id: load_balancer_id,
58
- monitoring_policy_id: monitoring_policy_id)
66
+ monitoring_policy_id: monitoring_policy_id, public_key: public_key,
67
+ server_type: server_type, baremetal_model_id: baremetal_model_id)
59
68
 
60
69
  # Merge Attributes
61
70
  merge_attributes(response.body)
62
71
 
63
72
  true
64
-
65
73
  end
66
74
 
67
-
68
75
  def update(options = {})
69
-
70
76
  requires :id
71
77
 
72
78
  response = service.update_server(server_id: id, name: options[:name],
73
- description: options[:description])
79
+ description: options[:description])
74
80
 
75
81
  # Merge Attributes
76
82
  merge_attributes(response.body)
77
83
 
78
84
  true
79
-
80
85
  end
81
86
 
82
-
83
87
  def update_hardware(options = {})
84
-
85
88
  requires :id
86
89
 
87
90
  response = service.update_hardware(server_id: id,
88
- fixed_instance_id: options[:fixed_instance_id],
89
- vcore: options[:vcore], ram: options[:ram],
90
- cores_per_processor: options[:cores_per_processor])
91
+ fixed_instance_id: options[:fixed_instance_id],
92
+ vcore: options[:vcore],
93
+ ram: options[:ram],
94
+ cores_per_processor: options[:cores_per_processor])
91
95
 
92
96
  # Merge Attributes
93
97
  merge_attributes(response.body)
94
98
 
95
99
  true
96
-
97
100
  end
98
101
 
99
-
100
102
  def add_hdds(options = {})
101
-
102
103
  requires :id
103
104
 
104
105
  response = service.add_hdds(server_id: id,
105
- hdds: options[:hdds])
106
+ hdds: options[:hdds])
106
107
 
107
108
  # Merge Attributes
108
109
  merge_attributes(response.body)
109
110
 
110
111
  true
111
-
112
112
  end
113
113
 
114
-
115
114
  def delete_hdd(options = {})
116
-
117
115
  requires :id
118
116
 
119
117
  response = service.delete_hdd(server_id: id,
120
- hdd_id: options[:hdd_id])
118
+ hdd_id: options[:hdd_id])
121
119
 
122
120
  # Merge Attributes
123
121
  merge_attributes(response.body)
124
122
 
125
123
  true
126
-
127
124
  end
128
125
 
129
-
130
126
  def resize_hdd(options = {})
131
-
132
127
  requires :id
133
128
 
134
129
  response = service.update_hdd(server_id: id,
135
- hdd_id: options[:hdd_id], size: options[:size])
130
+ hdd_id: options[:hdd_id],
131
+ size: options[:size])
136
132
 
137
133
  # Merge Attributes
138
134
  merge_attributes(response.body)
139
135
 
140
136
  true
141
-
142
137
  end
143
138
 
144
-
145
139
  def install_image(options = {})
146
-
147
140
  requires :id
148
141
 
149
142
  response = service.install_server_image(server_id: id,
150
- image_id: options[:image_id], password: options[:password],
151
- firewall_id: options[:firewall_id])
143
+ image_id: options[:image_id],
144
+ password: options[:password],
145
+ firewall_id: options[:firewall_id])
152
146
 
153
147
  # Merge Attributes
154
148
  merge_attributes(response.body)
155
149
 
156
150
  true
157
-
158
151
  end
159
152
 
160
-
161
153
  def add_ip
162
-
163
154
  requires :id
164
155
 
165
156
  response = service.add_server_ip(server_id: id)
@@ -168,134 +159,111 @@ module Fog
168
159
  merge_attributes(response.body)
169
160
 
170
161
  true
171
-
172
162
  end
173
163
 
174
-
175
164
  def delete_ip(options = {})
176
-
177
165
  requires :id
178
166
 
179
167
  response = service.delete_server_ip(server_id: id,
180
- ip_id: options[:ip_id])
168
+ ip_id: options[:ip_id])
181
169
 
182
170
  # Merge Attributes
183
171
  merge_attributes(response.body)
184
172
 
185
173
  true
186
-
187
174
  end
188
175
 
189
-
190
176
  def add_firewall(options = {})
191
-
192
177
  requires :id
193
178
 
194
179
  response = service.add_firewall(server_id: id,
195
- ip_id: options[:ip_id], firewall_id: options[:firewall_id])
180
+ ip_id: options[:ip_id],
181
+ firewall_id:options[:firewall_id])
196
182
 
197
183
  # Merge Attributes
198
184
  merge_attributes(response.body)
199
185
 
200
186
  true
201
-
202
187
  end
203
188
 
204
-
205
189
  def remove_firewall(options = {})
206
-
207
190
  requires :id
208
191
 
209
192
  response = service.remove_firewall(server_id: id,
210
- ip_id: options[:ip_id])
193
+ ip_id: options[:ip_id])
211
194
 
212
195
  # Merge Attributes
213
196
  merge_attributes(response.body)
214
197
 
215
198
  true
216
-
217
199
  end
218
200
 
219
-
220
201
  def add_load_balancer(options = {})
221
-
222
202
  requires :id
223
203
 
224
204
  response = service.add_load_balancer(server_id: id,
225
- ip_id: options[:ip_id],
226
- load_balancer_id: options[:load_balancer_id])
205
+ ip_id: options[:ip_id],
206
+ load_balancer_id: options[:load_balancer_id])
227
207
 
228
208
  # Merge Attributes
229
209
  merge_attributes(response.body)
230
210
 
231
211
  true
232
-
233
212
  end
234
213
 
235
-
236
214
  def remove_load_balancer(options = {})
237
-
238
215
  requires :id
239
216
 
240
217
  response = service.remove_load_balancer(server_id: id,
241
- ip_id: options[:ip_id],
242
- load_balancer_id: options[:load_balancer_id])
218
+ ip_id: options[:ip_id],
219
+ load_balancer_id: options[:load_balancer_id])
243
220
 
244
221
  # Merge Attributes
245
222
  merge_attributes(response.body)
246
223
 
247
224
  true
248
-
249
225
  end
250
226
 
251
-
252
227
  def on
253
-
254
228
  requires :id
255
229
 
256
230
  response = service.change_status(server_id: id,
257
- action: 'POWER_ON', method: 'SOFTWARE')
231
+ action: 'POWER_ON',
232
+ method: 'SOFTWARE')
258
233
 
259
234
  # Merge Attributes
260
235
  merge_attributes(response.body)
261
236
 
262
237
  true
263
-
264
238
  end
265
239
 
266
-
267
240
  def off
268
-
269
241
  requires :id
270
242
 
271
243
  response = service.change_status(server_id: id,
272
- action: 'POWER_OFF', method: 'SOFTWARE')
244
+ action: 'POWER_OFF',
245
+ method: 'SOFTWARE')
273
246
 
274
247
  # Merge Attributes
275
248
  merge_attributes(response.body)
276
249
 
277
250
  true
278
-
279
251
  end
280
252
 
281
-
282
253
  def reboot
283
-
284
254
  requires :id
285
255
 
286
256
  response = service.change_status(server_id: id,
287
- action: 'REBOOT', method: 'SOFTWARE')
257
+ action: 'REBOOT',
258
+ method: 'SOFTWARE')
288
259
 
289
260
  # Merge Attributes
290
261
  merge_attributes(response.body)
291
262
 
292
263
  true
293
-
294
264
  end
295
265
 
296
-
297
266
  def load_dvd(options = {})
298
-
299
267
  requires :id
300
268
 
301
269
  response = service.load_dvd(server_id: id, dvd_id: options[:dvd_id])
@@ -304,12 +272,9 @@ module Fog
304
272
  merge_attributes(response.body)
305
273
 
306
274
  true
307
-
308
275
  end
309
276
 
310
-
311
277
  def eject_dvd
312
-
313
278
  requires :id
314
279
 
315
280
  response = service.eject_dvd(server_id: id)
@@ -318,42 +283,33 @@ module Fog
318
283
  merge_attributes(response.body)
319
284
 
320
285
  true
321
-
322
286
  end
323
287
 
324
-
325
288
  def add_private_network(options = {})
326
-
327
289
  requires :id
328
290
 
329
291
  response = service.add_private_network(server_id: id,
330
- private_network_id: options[:private_network_id])
292
+ private_network_id: options[:private_network_id])
331
293
 
332
294
  # Merge Attributes
333
295
  merge_attributes(response.body)
334
296
 
335
297
  true
336
-
337
298
  end
338
299
 
339
-
340
300
  def remove_private_network(options = {})
341
-
342
301
  requires :id
343
302
 
344
303
  response = service.remove_private_network(server_id: id,
345
- private_network_id: options[:private_network_id])
304
+ private_network_id: options[:private_network_id])
346
305
 
347
306
  # Merge Attributes
348
307
  merge_attributes(response.body)
349
308
 
350
309
  true
351
-
352
310
  end
353
311
 
354
-
355
312
  def create_snapshot
356
-
357
313
  requires :id
358
314
 
359
315
  response = service.create_snapshot(server_id: id)
@@ -362,73 +318,56 @@ module Fog
362
318
  merge_attributes(response.body)
363
319
 
364
320
  true
365
-
366
321
  end
367
322
 
368
-
369
323
  def restore_snapshot(options = {})
370
-
371
324
  requires :id
372
325
 
373
326
  response = service.restore_snapshot(server_id: id,
374
- snapshot_id: options[:snapshot_id])
327
+ snapshot_id: options[:snapshot_id])
375
328
 
376
329
  # Merge Attributes
377
330
  merge_attributes(response.body)
378
331
 
379
332
  true
380
-
381
333
  end
382
334
 
383
-
384
335
  def delete_snapshot(options = {})
385
-
386
336
  requires :id
387
337
 
388
338
  response = service.delete_snapshot(server_id: id,
389
- snapshot_id: options[:snapshot_id])
339
+ snapshot_id: options[:snapshot_id])
390
340
 
391
341
  # Merge Attributes
392
342
  merge_attributes(response.body)
393
343
 
394
344
  true
395
-
396
345
  end
397
346
 
398
-
399
347
  def clone(options = {})
400
-
401
348
  requires :id
402
349
 
403
350
  response = service.clone_server(server_id: id, name: options[:name],
404
- datacenter_id: options[:datacenter_id])
351
+ datacenter_id: options[:datacenter_id])
405
352
 
406
353
  # Merge Attributes
407
354
  merge_attributes(response.body)
408
355
 
409
356
  true
410
-
411
357
  end
412
358
 
413
-
414
359
  def destroy
415
-
416
360
  requires :id
417
361
 
418
362
  service.delete_server(id)
419
-
420
- true
421
363
 
364
+ true
422
365
  end
423
366
 
424
-
425
367
  def ready?
426
-
427
- (GOOD_STATES.include? status['state']) && (status['percent'] == nil)
428
-
368
+ (GOOD_STATES.include? status['state']) && status['percent'].nil?
429
369
  end
430
-
431
370
  end # Server
432
371
  end # OneAndOne
433
372
  end # Compute
434
- end # Fog
373
+ end # Fog