fog-softlayer 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,629 @@
1
+ #
2
+ # Author:: Matheus Francisco Barra Mina (<mfbmina@gmail.com>)
3
+ # © Copyright IBM Corporation 2015.
4
+ #
5
+ # LICENSE: MIT (http://opensource.org/licenses/MIT)
6
+ #
7
+ module Fog
8
+ module Compute
9
+ class Softlayer
10
+ class Mock
11
+ # Gets all Bare Metal upgrade item prices
12
+ # @param [Integer] id
13
+ # @return [Excon::Response]
14
+ def get_bare_metal_upgrade_item_prices(id)
15
+ response = Excon::Response.new
16
+ found = self.get_bare_metal_servers.body.map{|server| server['id']}.include?(id.to_s)
17
+ unless found
18
+ response.status = 404
19
+ response.body = {
20
+ "error" => "Unable to find object with id of '#{id}'.",
21
+ "code" => "SoftLayer_Exception_ObjectNotFound"
22
+ }
23
+ else
24
+ response.status = 200
25
+ response.body = get_upgrade_item_prices
26
+ end
27
+ response
28
+ end
29
+ end
30
+
31
+ class Real
32
+ def get_bare_metal_upgrade_item_prices(id)
33
+ request(:hardware_server, "#{id}/getUpgradeItemPrices")
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ module Fog
41
+ module Compute
42
+ class Softlayer
43
+ class Mock
44
+ def get_upgrade_options
45
+ [
46
+ {
47
+ "currentPriceFlag"=>true,
48
+ "id"=>342,
49
+ "itemId"=>249,
50
+ "laborFee"=>"0",
51
+ "locationGroupId"=>nil,
52
+ "onSaleFlag"=>nil,
53
+ "oneTimeFee"=>"0",
54
+ "quantity"=>nil,
55
+ "recurringFee"=>"0",
56
+ "setupFee"=>"0",
57
+ "sort"=>0,
58
+ "accountRestrictions"=>[],
59
+ "categories"=>[
60
+ {
61
+ "categoryCode"=>"bandwidth",
62
+ "id"=>10,
63
+ "name"=>"Public Bandwidth",
64
+ "quantityLimit"=>0}
65
+ ],
66
+ "item"=>{
67
+ "capacity"=>"20000",
68
+ "description"=>"20000 GB Bandwidth",
69
+ "id"=>249,
70
+ "itemTaxCategoryId"=>166,
71
+ "keyName"=>"BANDWIDTH_20000_GB",
72
+ "softwareDescriptionId"=>nil,
73
+ "units"=>"GB",
74
+ "upgradeItemId"=>nil,
75
+ "attributes"=>[],
76
+ "requirements"=>[]
77
+ }
78
+ },
79
+ {
80
+ "currentPriceFlag"=>false,
81
+ "id"=>125,
82
+ "itemId"=>97,
83
+ "laborFee"=>"0",
84
+ "locationGroupId"=>nil,
85
+ "onSaleFlag"=>nil,
86
+ "oneTimeFee"=>"0",
87
+ "quantity"=>nil,
88
+ "recurringFee"=>"2000",
89
+ "setupFee"=>"0",
90
+ "sort"=>5,
91
+ "accountRestrictions"=>[],
92
+ "categories"=>[
93
+ {
94
+ "categoryCode"=>"bandwidth",
95
+ "id"=>10,
96
+ "name"=>"Public Bandwidth",
97
+ "quantityLimit"=>0}
98
+ ],
99
+ "item"=>{
100
+ "description"=>"Unlimited Bandwidth (100 Mbps Uplink)",
101
+ "id"=>97,
102
+ "itemTaxCategoryId"=>166,
103
+ "keyName"=>"BANDWIDTH_UNLIMITED_100_MBPS_UPLINK",
104
+ "softwareDescriptionId"=>nil,
105
+ "upgradeItemId"=>nil,
106
+ "attributes"=>[],
107
+ "requirements"=>[
108
+ {
109
+ "id"=>4,
110
+ "itemId"=>97,
111
+ "requiredItemId"=>187,
112
+ "item"=>{
113
+ "capacity"=>"100",
114
+ "description"=>"100 Mbps Public & Private Network Uplinks",
115
+ "id"=>187,
116
+ "itemTaxCategoryId"=>166,
117
+ "keyName"=>"100_MBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS",
118
+ "softwareDescriptionId"=>nil,
119
+ "units"=>"Mbps",
120
+ "upgradeItemId"=>188,
121
+ "attributes"=>[]
122
+ }
123
+ }
124
+ ]
125
+
126
+ }
127
+ },
128
+ {
129
+ "currentPriceFlag"=>true,
130
+ "hourlyRecurringFee"=>"0",
131
+ "id"=>273,
132
+ "itemId"=>187,
133
+ "laborFee"=>"0",
134
+ "locationGroupId"=>nil,
135
+ "onSaleFlag"=>nil,
136
+ "oneTimeFee"=>"0",
137
+ "quantity"=>nil,
138
+ "recurringFee"=>"0",
139
+ "setupFee"=>"0",
140
+ "sort"=>2,
141
+ "accountRestrictions"=>[],
142
+ "categories"=>[
143
+ {
144
+ "categoryCode"=>"port_speed",
145
+ "id"=>26,
146
+ "name"=>"Uplink Port Speeds",
147
+ "quantityLimit"=>0}
148
+ ],
149
+ "item"=>{
150
+ "capacity"=>"100",
151
+ "description"=>"100 Mbps Public & Private Network Uplinks",
152
+ "id"=>187,
153
+ "itemTaxCategoryId"=>166,
154
+ "keyName"=>"100_MBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS",
155
+ "softwareDescriptionId"=>nil,
156
+ "units"=>"Mbps",
157
+ "upgradeItemId"=>188,
158
+ "attributes"=>[]
159
+ }
160
+ },
161
+ {
162
+ "currentPriceFlag"=>false,
163
+ "hourlyRecurringFee"=>".04",
164
+ "id"=>274,
165
+ "itemId"=>188,
166
+ "laborFee"=>"0",
167
+ "locationGroupId"=>nil,
168
+ "onSaleFlag"=>nil,
169
+ "oneTimeFee"=>"0",
170
+ "quantity"=>nil,
171
+ "recurringFee"=>"20",
172
+ "setupFee"=>"0",
173
+ "sort"=>3,
174
+ "accountRestrictions"=>[],
175
+ "categories"=>[
176
+ {
177
+ "categoryCode"=>"port_speed",
178
+ "id"=>26,
179
+ "name"=>"Uplink Port Speeds",
180
+ "quantityLimit"=>0}
181
+ ],
182
+ "item"=>{
183
+ "capacity"=>"1000",
184
+ "description"=>"1 Gbps Public & Private Network Uplinks",
185
+ "id"=>188,
186
+ "itemTaxCategoryId"=>166,
187
+ "keyName"=>"1_GBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS",
188
+ "softwareDescriptionId"=>nil,
189
+ "units"=>"Mbps",
190
+ "upgradeItemId"=>nil,
191
+ "attributes"=>[]
192
+ }
193
+ },
194
+ {
195
+ "currentPriceFlag"=>false,
196
+ "hourlyRecurringFee"=>"0",
197
+ "id"=>272,
198
+ "itemId"=>186,
199
+ "laborFee"=>"0",
200
+ "locationGroupId"=>nil,
201
+ "onSaleFlag"=>nil,
202
+ "oneTimeFee"=>"0",
203
+ "quantity"=>nil,
204
+ "recurringFee"=>"0",
205
+ "setupFee"=>"0",
206
+ "sort"=>5,
207
+ "accountRestrictions"=>[],
208
+ "categories"=>[
209
+ {
210
+ "categoryCode"=>"port_speed",
211
+ "id"=>26,
212
+ "name"=>"Uplink Port Speeds",
213
+ "quantityLimit"=>0}
214
+ ],
215
+ "item"=>{
216
+ "capacity"=>"10",
217
+ "description"=>"10 Mbps Public & Private Network Uplinks",
218
+ "id"=>186,
219
+ "itemTaxCategoryId"=>166,
220
+ "keyName"=>"10_MBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS",
221
+ "softwareDescriptionId"=>nil,
222
+ "units"=>"Mbps",
223
+ "upgradeItemId"=>187,
224
+ "attributes"=>[]
225
+ }
226
+ },
227
+ {
228
+ "currentPriceFlag"=>false,
229
+ "hourlyRecurringFee"=>".02",
230
+ "id"=>21509,
231
+ "itemId"=>4332,
232
+ "laborFee"=>"0",
233
+ "locationGroupId"=>nil,
234
+ "onSaleFlag"=>nil,
235
+ "oneTimeFee"=>"0",
236
+ "quantity"=>nil,
237
+ "recurringFee"=>"10",
238
+ "setupFee"=>"0",
239
+ "sort"=>11,
240
+ "accountRestrictions"=>[],
241
+ "categories"=>[
242
+ {
243
+ "categoryCode"=>"port_speed",
244
+ "id"=>26,
245
+ "name"=>"Uplink Port Speeds",
246
+ "quantityLimit"=>0}
247
+ ],
248
+ "item"=>{
249
+ "capacity"=>"10",
250
+ "description"=>"10 Mbps Redundant Public & Private Network Uplinks",
251
+ "id"=>4332,
252
+ "itemTaxCategoryId"=>166,
253
+ "keyName"=>"10_MBPS_REDUNDANT_PUBLIC_PRIVATE_NETWORK_UPLINKS",
254
+ "softwareDescriptionId"=>nil,
255
+ "units"=>"Mbps",
256
+ "upgradeItemId"=>4336,
257
+ "attributes"=>[
258
+ {
259
+ "id"=>831,
260
+ "itemAttributeTypeId"=>2,
261
+ "itemId"=>4332,
262
+ "value"=>"1",
263
+ "attributeType"=>{
264
+ "keyName"=>"DUAL_PATH_NETWORK",
265
+ "name"=>"Dual-Path Networking"},
266
+ "attributeTypeKeyName"=>"DUAL_PATH_NETWORK"}
267
+ ]
268
+
269
+ }
270
+ },
271
+ {
272
+ "currentPriceFlag"=>false,
273
+ "hourlyRecurringFee"=>".03",
274
+ "id"=>21513,
275
+ "itemId"=>4336,
276
+ "laborFee"=>"0",
277
+ "locationGroupId"=>nil,
278
+ "onSaleFlag"=>nil,
279
+ "oneTimeFee"=>"0",
280
+ "quantity"=>nil,
281
+ "recurringFee"=>"20",
282
+ "setupFee"=>"0",
283
+ "sort"=>12,
284
+ "accountRestrictions"=>[],
285
+ "categories"=>[
286
+ {
287
+ "categoryCode"=>"port_speed",
288
+ "id"=>26,
289
+ "name"=>"Uplink Port Speeds",
290
+ "quantityLimit"=>0}
291
+ ],
292
+ "item"=>{
293
+ "capacity"=>"100",
294
+ "description"=>"100 Mbps Redundant Public & Private Network Uplinks",
295
+ "id"=>4336,
296
+ "itemTaxCategoryId"=>166,
297
+ "keyName"=>"100_MBPS_REDUNDANT_PUBLIC_PRIVATE_NETWORK_UPLINKS",
298
+ "softwareDescriptionId"=>nil,
299
+ "units"=>"Mbps",
300
+ "upgradeItemId"=>1284,
301
+ "attributes"=>[
302
+ {
303
+ "id"=>1000,
304
+ "itemAttributeTypeId"=>2,
305
+ "itemId"=>4336,
306
+ "value"=>"1",
307
+ "attributeType"=>{
308
+ "keyName"=>"DUAL_PATH_NETWORK",
309
+ "name"=>"Dual-Path Networking"},
310
+ "attributeTypeKeyName"=>"DUAL_PATH_NETWORK"}
311
+ ]
312
+
313
+ }
314
+ },
315
+ {
316
+ "currentPriceFlag"=>false,
317
+ "hourlyRecurringFee"=>".05",
318
+ "id"=>2314,
319
+ "itemId"=>1284,
320
+ "laborFee"=>"0",
321
+ "locationGroupId"=>nil,
322
+ "onSaleFlag"=>nil,
323
+ "oneTimeFee"=>"0",
324
+ "quantity"=>nil,
325
+ "recurringFee"=>"40",
326
+ "setupFee"=>"0",
327
+ "sort"=>13,
328
+ "accountRestrictions"=>[],
329
+ "categories"=>[
330
+ {
331
+ "categoryCode"=>"port_speed",
332
+ "id"=>26,
333
+ "name"=>"Uplink Port Speeds",
334
+ "quantityLimit"=>0}
335
+ ],
336
+ "item"=>{
337
+ "capacity"=>"1000",
338
+ "description"=>"1 Gbps Redundant Public & Private Network Uplinks",
339
+ "id"=>1284,
340
+ "itemTaxCategoryId"=>166,
341
+ "keyName"=>"1_GBPS_REDUNDANT_PUBLIC_PRIVATE_NETWORK_UPLINKS",
342
+ "softwareDescriptionId"=>nil,
343
+ "units"=>"Mbps",
344
+ "upgradeItemId"=>nil,
345
+ "attributes"=>[
346
+ {
347
+ "id"=>8,
348
+ "itemAttributeTypeId"=>2,
349
+ "itemId"=>1284,
350
+ "value"=>"1",
351
+ "attributeType"=>{
352
+ "keyName"=>"DUAL_PATH_NETWORK",
353
+ "name"=>"Dual-Path Networking"},
354
+ "attributeTypeKeyName"=>"DUAL_PATH_NETWORK"}
355
+ ]
356
+
357
+ }
358
+ },
359
+ {
360
+ "currentPriceFlag"=>false,
361
+ "hourlyRecurringFee"=>".04",
362
+ "id"=>21141,
363
+ "itemId"=>4263,
364
+ "laborFee"=>"0",
365
+ "locationGroupId"=>nil,
366
+ "onSaleFlag"=>nil,
367
+ "oneTimeFee"=>"0",
368
+ "quantity"=>nil,
369
+ "recurringFee"=>"20",
370
+ "setupFee"=>"0",
371
+ "sort"=>33,
372
+ "accountRestrictions"=>[],
373
+ "categories"=>[
374
+ {
375
+ "categoryCode"=>"port_speed",
376
+ "id"=>26,
377
+ "name"=>"Uplink Port Speeds",
378
+ "quantityLimit"=>0}
379
+ ],
380
+ "item"=>{
381
+ "capacity"=>"1000",
382
+ "description"=>"1 Gbps Dual Public & Private Network Uplinks (Unbonded)",
383
+ "id"=>4263,
384
+ "itemTaxCategoryId"=>166,
385
+ "keyName"=>"1_GBPS_DUAL_PUBLIC_PRIVATE_NETWORK_UPLINKS_UNBONDED",
386
+ "softwareDescriptionId"=>nil,
387
+ "units"=>"Mbps",
388
+ "upgradeItemId"=>nil,
389
+ "attributes"=>[
390
+ {
391
+ "id"=>1241,
392
+ "itemAttributeTypeId"=>2,
393
+ "itemId"=>4263,
394
+ "value"=>"1",
395
+ "attributeType"=>{
396
+ "keyName"=>"DUAL_PATH_NETWORK",
397
+ "name"=>"Dual-Path Networking"},
398
+ "attributeTypeKeyName"=>"DUAL_PATH_NETWORK"},
399
+ {
400
+ "id"=>649,
401
+ "itemAttributeTypeId"=>78,
402
+ "itemId"=>4263,
403
+ "value"=>"1",
404
+ "attributeType"=>{
405
+ "keyName"=>"NON_LACP",
406
+ "name"=>"Non Link Aggregation Control Protocol (Unbonded)"},
407
+ "attributeTypeKeyName"=>"NON_LACP"}
408
+ ]
409
+
410
+ }
411
+ },
412
+ {
413
+ "currentPriceFlag"=>false,
414
+ "hourlyRecurringFee"=>"0",
415
+ "id"=>40640,
416
+ "itemId"=>5118,
417
+ "laborFee"=>"0",
418
+ "locationGroupId"=>nil,
419
+ "onSaleFlag"=>nil,
420
+ "oneTimeFee"=>"0",
421
+ "quantity"=>nil,
422
+ "recurringFee"=>"0",
423
+ "setupFee"=>"0",
424
+ "sort"=>34,
425
+ "accountRestrictions"=>[],
426
+ "categories"=>[
427
+ {
428
+ "categoryCode"=>"port_speed",
429
+ "id"=>26,
430
+ "name"=>"Uplink Port Speeds",
431
+ "quantityLimit"=>0}
432
+ ],
433
+ "item"=>{
434
+ "capacity"=>"100",
435
+ "description"=>"100 Mbps Dual Public & Private Network Uplinks (Unbonded)",
436
+ "id"=>5118,
437
+ "itemTaxCategoryId"=>166,
438
+ "keyName"=>"100_MBPS_DUAL_PUBLIC_PRIVATE_NETWORK_UPLINKS_UNBONDED",
439
+ "softwareDescriptionId"=>nil,
440
+ "units"=>"Mbps",
441
+ "upgradeItemId"=>nil,
442
+ "attributes"=>[
443
+ {
444
+ "id"=>1508,
445
+ "itemAttributeTypeId"=>2,
446
+ "itemId"=>5118,
447
+ "value"=>"1",
448
+ "attributeType"=>{
449
+ "keyName"=>"DUAL_PATH_NETWORK",
450
+ "name"=>"Dual-Path Networking"},
451
+ "attributeTypeKeyName"=>"DUAL_PATH_NETWORK"},
452
+ {
453
+ "id"=>1506,
454
+ "itemAttributeTypeId"=>78,
455
+ "itemId"=>5118,
456
+ "value"=>"1",
457
+ "attributeType"=>{
458
+ "keyName"=>"NON_LACP",
459
+ "name"=>"Non Link Aggregation Control Protocol (Unbonded)"},
460
+ "attributeTypeKeyName"=>"NON_LACP"}
461
+ ]
462
+
463
+ }
464
+ },
465
+ {
466
+ "currentPriceFlag"=>true,
467
+ "id"=>20,
468
+ "itemId"=>14,
469
+ "laborFee"=>"0",
470
+ "locationGroupId"=>nil,
471
+ "onSaleFlag"=>nil,
472
+ "oneTimeFee"=>"0",
473
+ "quantity"=>nil,
474
+ "recurringFee"=>"0",
475
+ "setupFee"=>"0",
476
+ "sort"=>0,
477
+ "accountRestrictions"=>[],
478
+ "categories"=>[
479
+ {
480
+ "categoryCode"=>"disk0",
481
+ "id"=>4,
482
+ "name"=>"First Hard Drive",
483
+ "quantityLimit"=>0}
484
+ ],
485
+ "item"=>{
486
+ "capacity"=>"500",
487
+ "description"=>"500 GB SATA II",
488
+ "id"=>14,
489
+ "itemTaxCategoryId"=>166,
490
+ "keyName"=>"HARD_DRIVE_500GB_SATA_II",
491
+ "softwareDescriptionId"=>nil,
492
+ "units"=>"GB",
493
+ "upgradeItemId"=>nil,
494
+ "attributes"=>[]
495
+ }
496
+ },
497
+ {
498
+ "currentPriceFlag"=>true,
499
+ "id"=>637,
500
+ "itemId"=>104,
501
+ "laborFee"=>"0",
502
+ "locationGroupId"=>nil,
503
+ "onSaleFlag"=>nil,
504
+ "oneTimeFee"=>"0",
505
+ "quantity"=>nil,
506
+ "recurringFee"=>"0",
507
+ "setupFee"=>"0",
508
+ "sort"=>0,
509
+ "accountRestrictions"=>[],
510
+ "categories"=>[
511
+ {
512
+ "categoryCode"=>"ram",
513
+ "id"=>3,
514
+ "name"=>"RAM",
515
+ "quantityLimit"=>0}
516
+ ],
517
+ "item"=>{
518
+ "capacity"=>"2",
519
+ "description"=>"2 GB DDR2 667",
520
+ "id"=>104,
521
+ "itemTaxCategoryId"=>166,
522
+ "keyName"=>"RAM_2_GB_DDR2_667_NON_REG",
523
+ "softwareDescriptionId"=>nil,
524
+ "units"=>"GB",
525
+ "upgradeItemId"=>nil,
526
+ "attributes"=>[]
527
+ }
528
+ },
529
+ {
530
+ "currentPriceFlag"=>false,
531
+ "id"=>1028,
532
+ "itemId"=>106,
533
+ "laborFee"=>"0",
534
+ "locationGroupId"=>nil,
535
+ "onSaleFlag"=>nil,
536
+ "oneTimeFee"=>"0",
537
+ "quantity"=>nil,
538
+ "recurringFee"=>"28",
539
+ "setupFee"=>"0",
540
+ "sort"=>0,
541
+ "accountRestrictions"=>[],
542
+ "categories"=>[
543
+ {
544
+ "categoryCode"=>"ram",
545
+ "id"=>3,
546
+ "name"=>"RAM",
547
+ "quantityLimit"=>0}
548
+ ],
549
+ "item"=>{
550
+ "capacity"=>"4",
551
+ "description"=>"4 GB DDR2 667",
552
+ "id"=>106,
553
+ "itemTaxCategoryId"=>166,
554
+ "keyName"=>"RAM_4_GB_DDR2_667_NON_REG",
555
+ "softwareDescriptionId"=>nil,
556
+ "units"=>"GB",
557
+ "upgradeItemId"=>nil,
558
+ "attributes"=>[]
559
+ }
560
+ },
561
+ {
562
+ "currentPriceFlag"=>true,
563
+ "hourlyRecurringFee"=>"0",
564
+ "id"=>876,
565
+ "itemId"=>487,
566
+ "laborFee"=>"0",
567
+ "locationGroupId"=>nil,
568
+ "onSaleFlag"=>nil,
569
+ "oneTimeFee"=>"0",
570
+ "quantity"=>nil,
571
+ "recurringFee"=>"0",
572
+ "setupFee"=>"0",
573
+ "sort"=>0,
574
+ "accountRestrictions"=>[],
575
+ "categories"=>[
576
+ {
577
+ "categoryCode"=>"disk_controller",
578
+ "id"=>11,
579
+ "name"=>"Disk Controller",
580
+ "quantityLimit"=>0}
581
+ ],
582
+ "item"=>{
583
+ "description"=>"Non-RAID",
584
+ "id"=>487,
585
+ "itemTaxCategoryId"=>166,
586
+ "keyName"=>"DISK_CONTROLLER_NONRAID",
587
+ "softwareDescriptionId"=>nil,
588
+ "upgradeItemId"=>nil,
589
+ "attributes"=>[]
590
+ }
591
+ },
592
+ {
593
+ "currentPriceFlag"=>false,
594
+ "id"=>1268,
595
+ "itemId"=>14,
596
+ "laborFee"=>"0",
597
+ "locationGroupId"=>nil,
598
+ "onSaleFlag"=>nil,
599
+ "oneTimeFee"=>"0",
600
+ "quantity"=>nil,
601
+ "recurringFee"=>"21",
602
+ "setupFee"=>"0",
603
+ "sort"=>0,
604
+ "accountRestrictions"=>[],
605
+ "categories"=>[
606
+ {
607
+ "categoryCode"=>"disk1",
608
+ "id"=>5,
609
+ "name"=>"Second Hard Drive",
610
+ "quantityLimit"=>0}
611
+ ],
612
+ "item"=>{
613
+ "capacity"=>"500",
614
+ "description"=>"500 GB SATA II",
615
+ "id"=>14,
616
+ "itemTaxCategoryId"=>166,
617
+ "keyName"=>"HARD_DRIVE_500GB_SATA_II",
618
+ "softwareDescriptionId"=>nil,
619
+ "units"=>"GB",
620
+ "upgradeItemId"=>nil,
621
+ "attributes"=>[]
622
+ }
623
+ }
624
+ ]
625
+ end
626
+ end
627
+ end
628
+ end
629
+ end