Class: Fog::Compute::ProfitBricks::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/profitbricks/compute.rb,
lib/fog/profitbricks/requests/compute/get_lan.rb,
lib/fog/profitbricks/requests/compute/get_nic.rb,
lib/fog/profitbricks/requests/compute/get_user.rb,
lib/fog/profitbricks/requests/compute/add_share.rb,
lib/fog/profitbricks/requests/compute/get_group.rb,
lib/fog/profitbricks/requests/compute/get_image.rb,
lib/fog/profitbricks/requests/compute/get_share.rb,
lib/fog/profitbricks/requests/compute/create_lan.rb,
lib/fog/profitbricks/requests/compute/create_nic.rb,
lib/fog/profitbricks/requests/compute/delete_lan.rb,
lib/fog/profitbricks/requests/compute/delete_nic.rb,
lib/fog/profitbricks/requests/compute/get_flavor.rb,
lib/fog/profitbricks/requests/compute/get_server.rb,
lib/fog/profitbricks/requests/compute/get_volume.rb,
lib/fog/profitbricks/requests/compute/update_lan.rb,
lib/fog/profitbricks/requests/compute/update_nic.rb,
lib/fog/profitbricks/requests/compute/create_user.rb,
lib/fog/profitbricks/requests/compute/delete_user.rb,
lib/fog/profitbricks/requests/compute/get_all_nic.rb,
lib/fog/profitbricks/requests/compute/get_request.rb,
lib/fog/profitbricks/requests/compute/stop_server.rb,
lib/fog/profitbricks/requests/compute/update_user.rb,
lib/fog/profitbricks/requests/compute/attach_cdrom.rb,
lib/fog/profitbricks/requests/compute/create_group.rb,
lib/fog/profitbricks/requests/compute/delete_group.rb,
lib/fog/profitbricks/requests/compute/delete_image.rb,
lib/fog/profitbricks/requests/compute/delete_share.rb,
lib/fog/profitbricks/requests/compute/detach_cdrom.rb,
lib/fog/profitbricks/requests/compute/get_all_lans.rb,
lib/fog/profitbricks/requests/compute/get_ip_block.rb,
lib/fog/profitbricks/requests/compute/get_location.rb,
lib/fog/profitbricks/requests/compute/get_snapshot.rb,
lib/fog/profitbricks/requests/compute/start_server.rb,
lib/fog/profitbricks/requests/compute/update_group.rb,
lib/fog/profitbricks/requests/compute/update_image.rb,
lib/fog/profitbricks/requests/compute/update_share.rb,
lib/fog/profitbricks/requests/compute/attach_volume.rb,
lib/fog/profitbricks/requests/compute/create_flavor.rb,
lib/fog/profitbricks/requests/compute/create_server.rb,
lib/fog/profitbricks/requests/compute/create_volume.rb,
lib/fog/profitbricks/requests/compute/delete_server.rb,
lib/fog/profitbricks/requests/compute/delete_volume.rb,
lib/fog/profitbricks/requests/compute/detach_volume.rb,
lib/fog/profitbricks/requests/compute/get_all_users.rb,
lib/fog/profitbricks/requests/compute/reboot_server.rb,
lib/fog/profitbricks/requests/compute/update_server.rb,
lib/fog/profitbricks/requests/compute/update_volume.rb,
lib/fog/profitbricks/requests/compute/get_all_groups.rb,
lib/fog/profitbricks/requests/compute/get_all_images.rb,
lib/fog/profitbricks/requests/compute/get_all_shares.rb,
lib/fog/profitbricks/requests/compute/get_datacenter.rb,
lib/fog/profitbricks/requests/compute/create_ip_block.rb,
lib/fog/profitbricks/requests/compute/delete_ip_block.rb,
lib/fog/profitbricks/requests/compute/delete_snapshot.rb,
lib/fog/profitbricks/requests/compute/get_all_flavors.rb,
lib/fog/profitbricks/requests/compute/get_all_servers.rb,
lib/fog/profitbricks/requests/compute/get_all_volumes.rb,
lib/fog/profitbricks/requests/compute/get_group_users.rb,
lib/fog/profitbricks/requests/compute/update_snapshot.rb,
lib/fog/profitbricks/requests/compute/get_all_requests.rb,
lib/fog/profitbricks/requests/compute/add_user_to_group.rb,
lib/fog/profitbricks/requests/compute/create_datacenter.rb,
lib/fog/profitbricks/requests/compute/delete_datacenter.rb,
lib/fog/profitbricks/requests/compute/get_all_ip_blocks.rb,
lib/fog/profitbricks/requests/compute/get_all_locations.rb,
lib/fog/profitbricks/requests/compute/get_all_resources.rb,
lib/fog/profitbricks/requests/compute/get_all_snapshots.rb,
lib/fog/profitbricks/requests/compute/get_firewall_rule.rb,
lib/fog/profitbricks/requests/compute/get_load_balancer.rb,
lib/fog/profitbricks/requests/compute/update_datacenter.rb,
lib/fog/profitbricks/requests/compute/get_attached_cdrom.rb,
lib/fog/profitbricks/requests/compute/get_request_status.rb,
lib/fog/profitbricks/requests/compute/get_all_datacenters.rb,
lib/fog/profitbricks/requests/compute/get_attached_volume.rb,
lib/fog/profitbricks/requests/compute/create_firewall_rule.rb,
lib/fog/profitbricks/requests/compute/create_load_balancer.rb,
lib/fog/profitbricks/requests/compute/delete_firewall_rule.rb,
lib/fog/profitbricks/requests/compute/delete_load_balancer.rb,
lib/fog/profitbricks/requests/compute/get_resource_by_type.rb,
lib/fog/profitbricks/requests/compute/list_attached_cdroms.rb,
lib/fog/profitbricks/requests/compute/update_firewall_rule.rb,
lib/fog/profitbricks/requests/compute/update_load_balancer.rb,
lib/fog/profitbricks/requests/compute/get_load_balanced_nic.rb,
lib/fog/profitbricks/requests/compute/get_resources_by_type.rb,
lib/fog/profitbricks/requests/compute/list_attached_volumes.rb,
lib/fog/profitbricks/requests/compute/create_volume_snapshot.rb,
lib/fog/profitbricks/requests/compute/get_all_firewall_rules.rb,
lib/fog/profitbricks/requests/compute/get_all_load_balancers.rb,
lib/fog/profitbricks/requests/compute/remove_nic_association.rb,
lib/fog/profitbricks/requests/compute/remove_user_from_group.rb,
lib/fog/profitbricks/requests/compute/restore_volume_snapshot.rb,
lib/fog/profitbricks/requests/compute/get_all_contract_resources.rb,
lib/fog/profitbricks/requests/compute/get_all_load_balanced_nics.rb,
lib/fog/profitbricks/requests/compute/associate_nic_to_load_balancer.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



1270
1271
1272
1273
# File 'lib/fog/profitbricks/compute.rb', line 1270

def initialize(options = {})
  @profitbricks_username = options[:profitbricks_username]
  @profitbricks_password = options[:profitbricks_password]
end

Class Method Details

.dataObject



222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
# File 'lib/fog/profitbricks/compute.rb', line 222

def self.data
  dc1_id   = Fog::UUID.uuid
  dc2_id   = Fog::UUID.uuid
  serv1_id = Fog::UUID.uuid
  vol1_id  = Fog::UUID.uuid
  vol2_id  = Fog::UUID.uuid
  req1_id  = Fog::UUID.uuid
  req2_id  = Fog::UUID.uuid
  nic1_id  = Fog::UUID.uuid
  nic2_id  = Fog::UUID.uuid
  ipb1_id  = Fog::UUID.uuid
  ipb2_id  = Fog::UUID.uuid
  fwr1_id  = Fog::UUID.uuid
  fwr2_id  = Fog::UUID.uuid
  lb1_id   = Fog::UUID.uuid
  lb2_id   = Fog::UUID.uuid

  @data ||= Hash.new do |hash, key|
    hash[key] = {
      :datacenters => {
        "id"    => "datacenters",
        "type"  => "collection",
        "href"  => "https://api.profitbricks.com/rest/v2/datacenters",
        "items" =>
        [
          {
            'id'        => dc1_id,
            'type'      => 'datacenter',
            'href'      => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}",
            'metadata'  => {
              'createdDate' => '2016-07-31T15:41:27Z',
              'createdBy'         => '[email protected]',
              'etag'              => '5b91832ee85a758568d4523a86bd8702',
              'lastModifiedDate'  => '2016-07-31T15:41:27Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'name' => 'dc_1',
              'description' => 'testing fog rest implementation',
              'location'    => 'us/las',
              'version'     => 1,
              'features'    => %w(SSD MULTIPLE_CPU)
            }
          },
          {
            'id'        => dc2_id,
            'type'      => 'datacenter',
            'href'      => "https://api.profitbricks.com/rest/v2/datacenters/#{dc2_id}",
            'metadata'  => {
              'createdDate' => '2016-07-31T15:41:27Z',
              'createdBy'         => '[email protected]',
              'etag'              => '5b91832ee85a758568d4523a86bd8702',
              'lastModifiedDate'  => '2016-07-31T15:41:27Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'name' => 'dc_2',
              'description' => 'testing fog rest implementation',
              'location'    => 'de/fkb',
              'version'     => 1,
              'features'    => %w(SSD MULTIPLE_CPU)
            }
          }
        ]
      },
      :servers => {
        'id'    => 'servers',
        'type'  => 'collection',
        "href"  => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers",
        'items' =>
        [
          {
            'id'    => serv1_id,
            'type'  => 'server',
            'href'  => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}",
            'metadata' => {
              'createdDate'       => '2014-10-20T21:20:46Z',
              'createdBy'         => '[email protected]',
              'etag'              => '0018832d7a7ba455db74ac41ae9f11fe',
              'lastModifiedDate'  => '2015-03-18T21:31:10Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'name'              => 'FogTestServer_1',
              'cores'             => 1,
              'ram'               => 1024,
              'availabilityZone'  => 'AUTO',
              'vmState'           => 'RUNNING',
              'bootVolume'    => {
                'id'          => 'c04a2198-7e60-4bc0-b869-6e9c9dbcb8e1',
                'type'        => 'volume',
                'href'        => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/volumes/c04a2198-7e60-4bc0-b869-6e9c9dbcb8e1",
                'metadata'    => {
                  'createdDate'       => '2014-10-20T21:20:46Z',
                  'createdBy'         => '[email protected]',
                  'etag'              => '7a539b539d8ca9e08c5ac5e63c9c4c8f',
                  'lastModifiedDate'  => '2014-10-20T21:20:46Z',
                  'lastModifiedBy'    => '[email protected]',
                  'state'             => 'AVAILABLE'
                },
                'properties' => {
                  'name'                => 'Storage',
                  'type'                => 'HDD',
                  'size'                => 50,
                  'image'               => '4f363db0-4955-11e4-b362-52540066fee9',
                  'bus'                 => 'VIRTIO',
                  'licenceType'         => 'LINUX',
                  'cpuHotPlug'          => 'true',
                  'cpuHotUnplug'        => 'false',
                  'ramHotPlug'          => 'true',
                  'ramHotUnplug'        => 'false',
                  'nicHotPlug'          => 'true',
                  'nicHotUnplug'        => 'true',
                  'discVirtioHotPlug'   => 'true',
                  'discVirtioHotUnplug' => 'true',
                  'discScsiHotPlug'     => 'false',
                  'discScsiHotUnplug'   => 'false',
                  'deviceNumber'        => 1
                }
              },
              'cpuFamily' => 'AMD_OPTERON'
            },
            'entities' => {
              'cdroms'  => {
                'id'    => "#{serv1_id}/cdroms",
                'type'  => 'collection',
                'href'  => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/cdroms",
                'items' => []
              },
              'volumes' => {
                'id'    => "#{serv1_id}/volumes",
                'type'  => 'collection',
                'href'  => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/volumes",
                'items' =>
                [
                  {
                    'id'          => 'c04a2198-7e60-4bc0-b869-6e9c9dbcb8e1',
                    'type'        => 'volume',
                    'href'        => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/volumes/c04a2198-7e60-4bc0-b869-6e9c9dbcb8e1",
                    'metadata'    => {
                      'createdDate'       => '2014-10-20T21:20:46Z',
                      'createdBy'         => '[email protected]',
                      'etag'              => '7a539b539d8ca9e08c5ac5e63c9c4c8f',
                      'lastModifiedDate'  => '2014-10-20T21:20:46Z',
                      'lastModifiedBy'    => '[email protected]',
                      'state'             => 'AVAILABLE'
                    },
                    'properties' => {
                      'name'                => 'Storage',
                      'type'                => 'HDD',
                      'size'                => 50,
                      'image'               => '4f363db0-4955-11e4-b362-52540066fee9',
                      'bus'                 => 'VIRTIO',
                      'licenceType'         => 'LINUX',
                      'cpuHotPlug'          => 'true',
                      'cpuHotUnplug'        => 'false',
                      'ramHotPlug'          => 'true',
                      'ramHotUnplug'        => 'false',
                      'nicHotPlug'          => 'true',
                      'nicHotUnplug'        => 'true',
                      'discVirtioHotPlug'   => 'true',
                      'discVirtioHotUnplug' => 'true',
                      'discScsiHotPlug'     => 'false',
                      'discScsiHotUnplug'   => 'false',
                      'deviceNumber'        => 1
                    }
                  },
                  {
                    'id'          => '5c4d37ca-d620-4546-8b24-f92e3c608c2c',
                    'type'        => 'volume',
                    'href'        => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/volumes/5c4d37ca-d620-4546-8b24-f92e3c608c2c",
                    'metadata'    => {
                      'createdDate'       => '2015-03-18T21:31:10Z',
                      'createdBy'         => '[email protected]',
                      'etag'              => '0018832d7a7ba455db74ac41ae9f11fe',
                      'lastModifiedDate'  => '2015-03-18T21:31:10Z',
                      'lastModifiedBy'    => '[email protected]',
                      'state'             => 'AVAILABLE'
                    },
                    'properties' => {
                      'name'                => 'Docker Registry Volume',
                      'type'                => 'HDD',
                      'size'                => 50,
                      'bus'                 => 'VIRTIO',
                      'licenceType'         => 'OTHER',
                      'cpuHotPlug'          => 'false',
                      'cpuHotUnplug'        => 'false',
                      'ramHotPlug'          => 'false',
                      'ramHotUnplug'        => 'false',
                      'nicHotPlug'          => 'false',
                      'nicHotUnplug'        => 'false',
                      'discVirtioHotPlug'   => 'false',
                      'discVirtioHotUnplug' => 'false',
                      'discScsiHotPlug'     => 'false',
                      'discScsiHotUnplug'   => 'false',
                      'deviceNumber'        => 2
                    }
                  }
                ]
              },
              'nics'    => {
                'id'    => "#{serv1_id}/nics",
                'type'  => 'collection',
                'href'  => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics",
                'items' =>
                [
                  {
                    'id'          => '01ea3bd9-047c-4941-85cf-ed6b7a2d1d7d',
                    'type'        => 'nic',
                    'href'        => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/01ea3bd9-047c-4941-85cf-ed6b7a2d1d7d",
                    'metadata'    => {
                      'createdDate'       => '2015-02-09T22:46:38Z',
                      'createdBy'         => '[email protected]',
                      'etag'              => 'b4854a82738079d2c7f43b5324bd92e3',
                      'lastModifiedDate'  => '2015-02-09T22:46:38Z',
                      'lastModifiedBy'    => '[email protected]',
                      'state'             => 'AVAILABLE'
                    },
                    'properties' => {
                      'mac'             => '00:02:94:9e:f4:b0',
                      'ips'             => ['210.94.35.77'],
                      'dhcp'            => 'true',
                      'lan'             => 1,
                      'firewallActive'  => 'false'
                    },
                    'entities' => {
                      'firewallrules' => {
                        'id'    => '01ea3bd9-047c-4941-85cf-ed6b7a2d1d7d/firewallrules',
                        'type'  => 'collection',
                        'href'  => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/664f0f1c-7384-462b-8f0c-cfc4c3f6e2a3/nics/01ea3bd9-047c-4941-85cf-ed6b7a2d1d7d/firewallrules",
                        'items' => []
                      }
                    }
                  }
                ]
              }
            },
            'datacenter_id' => dc1_id
          }
        ]
      },
      :locations => {
        "id"    => "locations",
        "type"  => "collection",
        "href"  => "https://api.profitbricks.com/rest/v2/locations",
        "items" =>
        [
          {
            'id'          => 'de/fkb',
            'type'        => 'location',
            'href'        => 'https://api.profitbricks.com/rest/v2/locations/de/fkb',
            'properties'  => {
              'name'      => 'karlsruhe',
              'features'  => %w(SSD MULTIPLE_CPU)
            }
          },
          {
            'id'          => 'de/fra',
            'type'        => 'location',
            'href'        => 'https://api.profitbricks.com/rest/v2/locations/de/fra',
            'properties'  => {
              'name'      => 'frankfurt',
              'features'  => %w(SSD MULTIPLE_CPU)
            }
          },
          {
            'id'          => 'us/las',
            'type'        => 'location',
            'href'        => 'https://api.profitbricks.com/rest/v2/locations/us/las',
            'properties'  => {
              'name'      => 'lasvegas',
              'features'  => %w(SSD MULTIPLE_CPU)
            }
          }
        ]
      },
      :images =>
      {
        "id"    => "images",
        "type"  => "collection",
        "href"  => "https://api.profitbricks.com/rest/v2/images",
        "items" =>
        [
          {
            'id'              => 'dfcb40db-28b5-11e6-9336-52540005ab80',
            'type'            => 'image',
            'href'            => 'https=>//api.profitbricks.com/rest/v2/images/dfcb40db-28b5-11e6-9336-52540005ab80',
            'metadata'        => {
              'createdDate'       => '2016-06-02T11:33:49Z',
              'createdBy'         => 'System',
              'etag'              => '9909709d99655c6f31aca789998d7d89',
              'lastModifiedDate'  => '2016-06-02T11:33:49Z',
              'lastModifiedBy'    => 'System',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'name'                => 'CentOS-6.8-x86_64-netinstall.iso',
              'description'         => '',
              'location'            => 'us/las',
              'size'                => 0.23,
              'cpuHotPlug'          => 'true',
              'cpuHotUnplug'        => 'false',
              'ramHotPlug'          => 'true',
              'ramHotUnplug'        => 'false',
              'nicHotPlug'          => 'true',
              'nicHotUnplug'        => 'true',
              'discVirtioHotPlug'   => 'true',
              'discVirtioHotUnplug' => 'true',
              'discScsiHotPlug'     => 'false',
              'discScsiHotUnplug'   => 'false',
              'licenceType'         => 'LINUX',
              'imageType'           => 'CDROM',
              'public'              => 'true'
            }
          },
          {
            'id'              => 'dfcb40db-28b5-11e6-9336-52540005ab80',
            'type'            => 'image',
            'href'            => 'https=>//api.profitbricks.com/rest/v2/images/dfcb40db-28b5-11e6-9336-52540005ab80',
            'metadata'        => {
              'createdDate'       => '2016-06-02T11:33:49Z',
              'createdBy'         => 'System',
              'etag'              => '9909709d99655c6f31aca789998d7d89',
              'lastModifiedDate'  => '2016-06-02T11:33:49Z',
              'lastModifiedBy'    => 'System',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'name'                => 'CentOS-6.8-x86_64-netinstall.iso',
              'description'         => '',
              'location'            => 'us/las',
              'size'                => 0.23,
              'cpuHotPlug'          => 'true',
              'cpuHotUnplug'        => 'false',
              'ramHotPlug'          => 'true',
              'ramHotUnplug'        => 'false',
              'nicHotPlug'          => 'true',
              'nicHotUnplug'        => 'true',
              'discVirtioHotPlug'   => 'true',
              'discVirtioHotUnplug' => 'true',
              'discScsiHotPlug'     => 'false',
              'discScsiHotUnplug'   => 'false',
              'licenceType'         => 'LINUX',
              'imageType'           => 'HDD',
              'public'              => 'true'
            }
          },
          {
            'id'              => '05cadf29-6c12-11e4-beeb-52540066fee9',
            'type'            => 'image',
            'href'            => 'https=>//api.profitbricks.com/rest/v2/images/05cadf29-6c12-11e4-beeb-52540066fee9',
            'metadata'        => {
              'createdDate'       => '2014-11-14T15:22:19Z',
              'createdBy'         => 'System',
              'etag'              => '957e0eac7456fa7554e73bf0d18860eb',
              'lastModifiedDate'  => '2014-11-14T15=>22=>19Z',
              'lastModifiedBy'    => 'System',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'name'                => 'Microsoft-SQL-2012-Full-trial-english.iso',
              'description'         => '',
              'location'            => 'us/las',
              'size'                => 4,
              'cpuHotPlug'          => 'false',
              'cpuHotUnplug'        => 'false',
              'ramHotPlug'          => 'false',
              'ramHotUnplug'        => 'false',
              'nicHotPlug'          => 'false',
              'nicHotUnplug'        => 'false',
              'discVirtioHotPlug'   => 'false',
              'discVirtioHotUnplug' => 'false',
              'discScsiHotPlug'     => 'false',
              'discScsiHotUnplug'   => 'false',
              'licenceType'         => 'OTHER',
              'imageType'           => 'CDROM',
              'public'              => 'true'
            }
          }
        ]
      },
      :flavors =>
      [
        {
          'flavorId'   => Fog::UUID.uuid,
          'flavorName' => 'Micro',
          'ram'        => 1024,
          'disk'       => 50,
          'cores'      => 1
        },
        {
          'flavorId'   => Fog::UUID.uuid,
          'flavorName' => 'Small',
          'ram'        => 2048,
          'disk'       => 50,
          'cores'      => 1
        }
      ],
      :volumes => {
        "id"    => "#{dc1_id}/volumes",
        "type"  => 'collection',
        "href"  => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/volumes",
        "items" =>
        [
          {
            'id'        => vol1_id,
            'type'      => 'volume',
            'href'      => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/volumes/#{vol1_id}",
            'metadata'  => {
              'createdDate'       => '2015-03-18T19:00:51Z',
              'createdBy'         => '[email protected]',
              'etag'              => 'c4a2fde6ba91a038ff953b939cc21efe',
              'lastModifiedDate'  => '2015-03-18T19=>00=>51Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'name'                => 'master 1 Storage',
              'type'                => 'HDD',
              'size'                => 50,
              'image'               => '681673e7-bfc2-11e4-850c-52540066fee9',
              'bus'                 => 'VIRTIO',
              'licenceType'         => 'OTHER',
              'cpuHotPlug'          => 'true',
              'cpuHotUnplug'        => 'false',
              'ramHotPlug'          => 'false',
              'ramHotUnplug'        => 'false',
              'nicHotPlug'          => 'true',
              'nicHotUnplug'        => 'true',
              'discVirtioHotPlug'   => 'true',
              'discVirtioHotUnplug' => 'true',
              'discScsiHotPlug'     => 'false',
              'discScsiHotUnplug'   => 'false',
              'deviceNumber'        => 1
            },
            'datacenter_id' => dc1_id
          },
          {
            'id'        => vol2_id,
            'type'      => 'volume',
            'href'      => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/volumes/#{vol2_id}",
            'metadata'  => {
              'createdDate'       => '2015-03-18T21:31:10Z',
              'createdBy'         => '[email protected]',
              'etag'              => '0018832d7a7ba455db74ac41ae9f11fe',
              'lastModifiedDate'  => '2015-03-18T21:31:10Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'name'                => 'Docker Registry Volume',
              'type'                => 'HDD',
              'size'                => 50,
              'bus'                 => 'VIRTIO',
              'licenceType'         => 'OTHER',
              'cpuHotPlug'          => 'false',
              'cpuHotUnplug'        => 'false',
              'ramHotPlug'          => 'false',
              'ramHotUnplug'        => 'false',
              'nicHotPlug'          => 'false',
              'nicHotUnplug'        => 'false',
              'discVirtioHotPlug'   => 'false',
              'discVirtioHotUnplug' => 'false',
              'discScsiHotPlug'     => 'false',
              'discScsiHotUnplug'   => 'false',
              'deviceNumber'        => 2
            },
            'datacenter_id' => dc1_id
          }
        ]
      },
      :lans => {
        'id'    => "#{dc1_id}/lans",
        'type'  => 'collection',
        'href'  => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/lans",
        'items' =>
        [
          {
            'id'          => '9',
            'type'        => 'nic',
            'href'        => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/lans/9",
            'metadata'    => {
              'createdDate'       => '2015-03-18T19:00:51Z',
              'createdBy'         => '[email protected]',
              'etag'              => 'faa67fbacb1c0e2e02cf9650657251f1',
              'lastModifiedDate'  => '2015-03-18T19:00:51Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'name'            => 'FogTestLAN_1',
              'public'          => 'true'
            },
            'entities' => {
              'nics' => {
                'id'    => '9/nics',
                'type'  => 'collection',
                'href'  => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/lans/9/nics",
                'items' => []
              }
            },
            'datacenter_id' => dc1_id
          }
        ]
      },
      :nics => {
        'id'    => "#{serv1_id}/nics",
        'type'  => 'collection',
        'href'  => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics",
        'items' =>
        [
          {
            'id'          => nic1_id,
            'type'        => 'nic',
            'href'        => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/#{nic1_id}",
            'metadata'    => {
              'createdDate'       => '2015-03-18T19:00:51Z',
              'createdBy'         => '[email protected]',
              'etag'              => 'faa67fbacb1c0e2e02cf9650657251f1',
              'lastModifiedDate'  => '2015-03-18T19:00:51Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'name'            => 'FogTestNIC_1',
              'mac'             => '02:01:36:5f:09:da',
              'ips'             => ['10.9.194.12'],
              'dhcp'            => 'true',
              'lan'             => 2,
              'firewallActive'  => 'false'
            },
            'entities' => {
              'firewallrules' => {
                'id'    => "#{nic1_id}/firewallrules",
                'type'  => 'collection',
                'href'  => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/#{nic1_id}/firewallrules",
                'items' => []
              }
            },
            'datacenter_id' => dc1_id
          },
          {
            'id'          => nic2_id,
            'type'        => 'nic',
            'href'        => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/#{nic2_id}",
            'metadata'    => {
              'createdDate'       => '2015-03-18T19:00:51Z',
              'createdBy'         => '[email protected]',
              'etag'              => 'faa67fbacb1c0e2e02cf9650657251f1',
              'lastModifiedDate'  => '2015-03-18T19:00:51Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'name'            => 'FogTestNIC_2',
              'mac'             => '03:01:60:bf:d4:8a',
              'ips'             => ['192.96.159.188'],
              'dhcp'            => 'true',
              'lan'             => 1,
              'firewallActive'  => 'false'
            },
            'entities' => {
              'firewallrules' => {
                'id' => 'cf6d01d3-295d-48bd-8d07-568cce63cbbc/firewallrules',
                'type' => 'collection',
                'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/#{nic2_id}/firewallrules",
                'items' => []
              }
            },
            'datacenter_id' => dc1_id
          }
        ]
      },
      :snapshots => {
        'id'    => 'snapshots',
        'type'  => 'collection',
        'href'  => 'https =>//api.profitbricks.com/rest/v2/snapshots',
        'items' =>
        [
          {
            'id'          => '3d52b13d-bec4-49de-ad05-fd2f8c687be6',
            'type'        => 'snapshot',
            'href'        => 'https =>//api.profitbricks.com/rest/v2/snapshots/3d52b13d-bec4-49de-ad05-fd2f8c687be6',
            'metadata'    => {
              'createdDate'       => '2016-08-07T22:28:38Z',
              'createdBy'         => '[email protected]',
              'etag'              => '83ad78a4757ab0d9bdeaebc3a6485dcf',
              'lastModifiedDate'  => '2016-08-07T22:28:38Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'name'                => 'FogTestSnapshot',
              'description'         => 'Testing fog create volume snapshot',
              'location'            => 'de/fkb',
              'size'                => 5,
              'cpuHotPlug'          => 'false',
              'cpuHotUnplug'        => 'false',
              'ramHotPlug'          => 'false',
              'ramHotUnplug'        => 'false',
              'nicHotPlug'          => 'false',
              'nicHotUnplug'        => 'false',
              'discVirtioHotPlug'   => 'false',
              'discVirtioHotUnplug' => 'false',
              'discScsiHotPlug'     => 'false',
              'discScsiHotUnplug'   => 'false',
              'licenceType'         => 'LINUX'
            }
          }
        ]
      },
      :requests => {
        'id'    => 'requests',
        'type'  => 'collection',
        'href'  => 'https=>//api.profitbricks.com/rest/v2/requests',
        'items' =>
        [
          {
            'id'        => req1_id,
            'type'      => 'request',
            'href'      => "https=>//api.profitbricks.com/rest/v2/requests/#{req1_id}",
            'metadata'  => {
              'createdDate'   => '2016-08-07T23:32:17Z',
              'createdBy'     => '[email protected]',
              'etag'          => '37a6259cc0c1dae299a7866489dff0bd',
              'requestStatus' => {
                'id'    => "#{req1_id}/status",
                'type'  => 'request-status',
                'href'  => "https://api.profitbricks.com/rest/v2/requests/#{req1_id}/status"
              }
            },
            'properties' => {
              'method'  => 'POST',
              'headers' => {
                'content-type'        => 'application/x-www-form-urlencoded',
                'connection'          => 'Keep-Alive',
                'host'                => 'api.profitbricks.com',
                'x-forwarded-for'     => '100.00.00.01',
                'content-length'      => '47',
                'x-forwarded-host'    => 'api.profitbricks.com',
                'x-reseller'          => 'pb.domain',
                'user-agent'          => 'fog-core/1.42.0',
                'x-forwarded-server'  => 'my.profitbricks.com'
              },
              'body' => '{\'snapshotId\': \'3d52b13d-bec4-49de-ad05-fd2f8c687be6\'}',
              'url' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/volumes/#{vol1_id}/restore-snapshot"
            }
          },
          {
            'id'        => req2_id,
            'type'      => 'request',
            'href'      => "https=>//api.profitbricks.com/rest/v2/requests/#{req2_id}",
            'metadata'  => {
              'createdDate'   => '2016-08-07T23:32:17Z',
              'createdBy'     => '[email protected]',
              'etag'          => '37a6259cc0c1dae299a7866489dff0bd',
              'requestStatus' => {
                'id'    => "#{req2_id}/status",
                'type'  => 'request-status',
                'href'  => "https://api.profitbricks.com/rest/v2/requests/#{req2_id}/status"
              }
            },
            'properties' => {
              'method'  => 'POST',
              'headers' => {
                'content-type'        => 'application/x-www-form-urlencoded',
                'connection'          => 'Keep-Alive',
                'host'                => 'api.profitbricks.com',
                'x-forwarded-for'     => '100.00.00.01',
                'content-length'      => '47',
                'x-forwarded-host'    => 'api.profitbricks.com',
                'x-reseller'          => 'pb.domain',
                'user-agent'          => 'fog-core/1.42.0',
                'x-forwarded-server'  => 'my.profitbricks.com'
              },
              'body' => '{\'snapshotId\': \'3d52b13d-bec4-49de-ad05-fd2f8c687be6\'}',
              'url' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/volumes/#{vol2_id}/restore-snapshot"
            }
          }
        ]
      },
      :request_status => {
        'id' => "#{req1_id}/status",
        'type' => 'request-status',
        'href' => "https=>//api.profitbricks.com/rest/v2/requests/#{req1_id}/status",
        'metadata' => {
          'status' => 'DONE',
          'message' => 'Request has been successfully executed',
          'etag' => '2ba22e58ca17bb728d522bba36cf8350',
          'targets' =>
          [
            {
              'target' => {
                'id' => '752df03a-b9a6-48ee-b9f5-58433184aa1a',
                'type' => 'volume',
                'href' => 'TO_BE_INJECTED'
              },
              'status' => 'DONE'
            }
          ]
        }
      },
      :ip_blocks => {
        'id' => 'ipblocks',
        'type' => 'collection',
        'href' => 'https://api.profitbricks.com/rest/v2/ipblocks',
        'items' =>
        [
          {
            'id' => ipb1_id,
            'type' => 'ipblock',
            'href' => "https://api.profitbricks.com/rest/v2/ipblocks/#{ipb1_id}",
            'metadata' => {
              'createdDate'       => '2016-07-31T15:41:27Z',
              'createdBy'         => '[email protected]',
              'etag'              => '5b91832ee85a758568d4523a86bd8702',
              'lastModifiedDate'  => '2016-07-31T15:41:27Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'ips'    	  => ["111.111.111.111", "222.222.222.222"],
              'location'  => 'us/las',
              'size'	    => 2,
              'name' => 'Fog test IP Block 1'
            }
          },
          {
            'id' => ipb2_id,
            'type' => 'ipblock',
            'href' => "https://api.profitbricks.com/rest/v2/ipblocks/#{ipb2_id}",
            'metadata' => {
              'createdDate'       => '2016-07-31T15:41:27Z',
              'createdBy'         => '[email protected]',
              'etag'              => '5b91832ee85a758568d4523a86bd8702',
              'lastModifiedDate'  => '2016-07-31T15:41:27Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'ips'    	  => ["333.333.333.333"],
              'location'  => 'us/las',
              'size'	    => 1,
              'name' => 'Fog test IP Block 2'
            }
          }
        ]
      },
      :firewall_rules => {
        'id'    => "#{nic1_id}/firewallrules",
        'type'  => 'collection',
        'href'  => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/#{nic1_id}/firewallrules",
        'items' =>
        [
          {
            'id'    => fwr1_id,
            'type'  => 'firewall-rule',
            'href'  => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/#{nic1_id}/firewallrules/#{fwr1_id}",
            'metadata' => {
              'createdDate'       => '2016-07-31T15:41:27Z',
              'createdBy'         => '[email protected]',
              'etag'              => '5b91832ee85a758568d4523a86bd8703',
              'lastModifiedDate'  => '2016-07-31T15:41:27Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'name'            => 'Fog test Firewall Rule 1',
              'protocol'        => 'TCP',
              'sourceMac'       => 'null',
              'sourceIp'        => 'null',
              'targetIp'        => 'null',
              'icmpCode'        => 'null',
              'icmpType'        => 'null',
              'portRangeStart'  => 22,
              'portRangeEnd'    => 22
            },
            'datacenter_id' => dc1_id,
            'server_id'       => serv1_id,
            'nic_id'          => nic1_id
          },
          {
            'id'    => fwr2_id,
            'type'  => 'firewall-rule',
            'href'  => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/#{nic1_id}/firewallrules/#{fwr2_id}",
            'metadata' => {
              'createdDate'       => '2016-07-31T15:41:27Z',
              'createdBy'         => '[email protected]',
              'etag'              => '5b91832ee85a758568d4523a86bd8701',
              'lastModifiedDate'  => '2016-07-31T15:41:27Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'name'            => 'Fog test Firewall Rule 2',
              'protocol'        => 'TCP',
              'sourceMac'       => 'null',
              'sourceIp'        => 'null',
              'targetIp'        => 'null',
              'icmpCode'        => 'null',
              'icmpType'        => 'null',
              'portRangeStart'  => 24,
              'portRangeEnd'    => 25
            },
            'datacenter_id' => dc1_id,
            'server_id'       => serv1_id,
            'nic_id'          => nic1_id
          }
        ]
      },
      :load_balancers => {
        'id'    => "#{dc1_id}/loadbalancers",
        'type'  => 'collection',
        'href'  => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/loadbalancers",
        'items' =>
        [
          {
            'id'    => lb1_id,
            'type'  => 'loadbalancer',
            'href'  => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/loadbalancers/#{lb1_id}",
            'metadata' => {
              'createdDate'       => '2016-07-31T15:41:27Z',
              'createdBy'         => '[email protected]',
              'etag'              => '5b91832ee85a758568d4523a86bd8723',
              'lastModifiedDate'  => '2016-07-31T15:41:27Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'name'  => 'Fog test Load Balancer 1',
              'ip'    => 'null',
              'dhcp'  => 'true'
            },
            'entities' => {
              'balancednics' => {
                'id'    => "#{lb1_id}/balancednics",
                'type'  => 'collection',
                'href'  => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/loadbalancers/#{lb1_id}/balancednics",
                'items' =>
                [
                  {
                    'id'          => nic1_id,
                    'type'        => 'nic',
                    'href'        => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/#{nic1_id}",
                    'metadata'    => {
                      'createdDate'       => '2015-03-18T19:00:51Z',
                      'createdBy'         => '[email protected]',
                      'etag'              => 'faa67fbacb1c0e2e02cf9650657251f1',
                      'lastModifiedDate'  => '2015-03-18T19:00:51Z',
                      'lastModifiedBy'    => '[email protected]',
                      'state'             => 'AVAILABLE'
                    },
                    'properties' => {
                      'name'            => 'FogTestLoadBalancedNIC_1',
                      'mac'             => '02:01:36:5f:09:da',
                      'ips'             => ['10.9.194.12'],
                      'dhcp'            => 'true',
                      'lan'             => 2,
                      'firewallActive'  => 'false'
                    },
                    'entities' => {
                      'firewallrules' => {
                        'id'    => "#{nic1_id}/firewallrules",
                        'type'  => 'collection',
                        'href'  => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/servers/#{serv1_id}/nics/#{nic1_id}/firewallrules",
                        'items' => []
                      }
                    },
                    'datacenter_id' => dc1_id,
                    'load_balancer_id' => lb1_id
                  }
                ]
              }
            },
            'datacenter_id' => dc1_id
          },
          {
            'id'    => lb2_id,
            'type'  => 'loadbalancer',
            'href'  => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/loadbalancers/#{lb2_id}",
            'metadata' => {
              'createdDate'       => '2016-07-31T15:41:27Z',
              'createdBy'         => '[email protected]',
              'etag'              => '5b91832ee85a758568d4523a86bd8721',
              'lastModifiedDate'  => '2016-07-31T15:41:27Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'INACTIVE'
            },
            'properties' => {
              'name'  => 'Fog test Load Balancer 2',
              'ip'    => 'null',
              'dhcp'  => 'false'
            },
            'entities' => {
              'balancednics' => {
                'id' => "#{lb2_id}/balancednics",
                'type'  => 'collection',
                'href'  => "https://api.profitbricks.com/rest/v2/datacenters/#{dc1_id}/loadbalancers/#{lb2_id}/balancednics",
                'items' => []
              }
            },
            'datacenter_id' => dc1_id
          }
        ]
      },
      :contracts => {
        'type' => 'contract',
        'contractNumber'  => '12345678',
        'owner'  => '[email protected]',
        'status'  => 'BILLABLE',
        'resourceLimits' => {
          'coresPerServer'        => '20',
          'coresPerContract'      => '30',
          'coresProvisioned'      => '0',
          'ramPerServer'          => '204800',
          'ramPerContract'        => '3072000',
          'ramProvisioned'        => '0',
          'hddLimitPerVolume'     => '2048000',
          'hddLimitPerContract'   => '3072000',
          'hddVolumeProvisioned'  => '0',
          'ssdLimitPerVolume'     => '2048000',
          'ssdLimitPerContract'   => '3072000',
          'ssdVolumeProvisioned'  => '0',
          'reservableIps'         => '3',
          'reservedIpsOnContract' => '0',
          'reservedIpsInUse'      => '0',
        }
      },
      :groups => {
        'id'    => "groups",
        'type'  => 'collection',
        'href'  => "https://api.profitbricks.com/cloudapi/v4/um/groups",
        'items' => []
      },
      :shares => {
        'id'    => "059c4d71-f97a-4bfd-b3a5-XXXXXXXXXXXX/shares",
        'type'  => 'collection',
        'href'  => "https://api.profitbricks.com/cloudapi/v4/um/groups/059c4d71-f97a-4bfd-b3a5-XXXXXXXXXXXX/shares",
        'items' => []
      },
      :users => {
        'id'    => "users",
        'type'  => 'collection',
        'href'  => "https://api.profitbricks.com/cloudapi/v4/users",
        'items' => []
      },
      :resources => {
        'id'    => "resources",
        'type'  => 'collection',
        'href'  => "https://api.profitbricks.com/cloudapi/v4/um/resources",
        'items' => [
          {
            'id'        => dc1_id,
            'type'      => 'datacenter',
            'href'      => "https://api.profitbricks.com/cloudapi/v4/um/resources/datacenter/#{dc1_id}",
            'metadata'  => {
              'createdDate' => '2016-07-31T15:41:27Z',
              'createdBy'         => '[email protected]',
              'etag'              => '5b91832ee85a758568d4523a86bd8702',
              'lastModifiedDate'  => '2016-07-31T15:41:27Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'AVAILABLE'
            },
            'entities' => {
              'groups' => {
                'id' => "#{dc1_id}/groups",
                'type' => 'collection',
                'href' => "https://api.profitbricks.com/cloudapi/v4/um/groups",
                'items' => []
              }
            }
          },
          {
            'id'              => 'dfcb40db-28b5-11e6-9336-52540005ab80',
            'type'            => 'image',
            'href'            => 'https://api.profitbricks.com/cloudapi/v4/um/resources/image/dfcb40db-28b5-11e6-9336-52540005ab80',
            'metadata'        => {
              'createdDate'       => '2016-06-02T11:33:49Z',
              'createdBy'         => 'System',
              'etag'              => '9909709d99655c6f31aca789998d7d89',
              'lastModifiedDate'  => '2016-06-02T11:33:49Z',
              'lastModifiedBy'    => 'System',
              'state'             => 'AVAILABLE'
            },
            'entities' => {
              'groups' => {
                'id' => "dfcb40db-28b5-11e6-9336-52540005ab80/groups",
                'type' => 'collection',
                'href' => "https://api.profitbricks.com/cloudapi/v4/um/groups",
                'items' => []
              }
            }
          },
          {
            'id'          => '3d52b13d-bec4-49de-ad05-fd2f8c687be6',
            'type'        => 'snapshot',
            'href'        => 'https://api.profitbricks.com/cloudapi/v4/um/resources/snapshot/3d52b13d-bec4-49de-ad05-fd2f8c687be6',
            'metadata'    => {
              'createdDate'       => '2016-08-07T22:28:38Z',
              'createdBy'         => '[email protected]',
              'etag'              => '83ad78a4757ab0d9bdeaebc3a6485dcf',
              'lastModifiedDate'  => '2016-08-07T22:28:38Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'AVAILABLE'
            },
            'entities' => {
              'groups' => {
                'id' => "3d52b13d-bec4-49de-ad05-fd2f8c687be6/groups",
                'type' => 'collection',
                'href' => "https://api.profitbricks.com/cloudapi/v4/um/groups",
                'items' => []
              }
            }
          },
          {
            'id' => ipb1_id,
            'type' => 'ipblock',
            'href' => "https://api.profitbricks.com/cloudapi/v4/um/resources/ipblock/#{ipb1_id}",
            'metadata' => {
              'createdDate'       => '2016-07-31T15:41:27Z',
              'createdBy'         => '[email protected]',
              'etag'              => '5b91832ee85a758568d4523a86bd8702',
              'lastModifiedDate'  => '2016-07-31T15:41:27Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'AVAILABLE'
            },
            'entities' => {
              'groups' => {
                'id' => "#{ipb1_id}/groups",
                'type' => 'collection',
                'href' => "https://api.profitbricks.com/cloudapi/v4/um/groups",
                'items' => []
              }
            }
          }
        ]
      }
    }
  end
end

.resetObject



1266
1267
1268
# File 'lib/fog/profitbricks/compute.rb', line 1266

def self.reset
  @data = nil
end

Instance Method Details

#add_share(group_id, resource_id, options = {}) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/fog/profitbricks/requests/compute/add_share.rb', line 42

def add_share(group_id, resource_id, options = {})
  response = Excon::Response.new
  response.status = 202

  share = {
    'id' => resource_id,
    'type'      => 'resource',
    'href'      => "https=>//api.profitbricks.com/rest/v4/um/groups/#{group_id}/shares/#{resource_id}",
    'properties' => {
        'editPrivilege'  => options[:editPrivilege],
        'sharePrivilege' => options[:sharePrivilege]
    }
  }

  data[:shares]['items'] << share

  response.body = share
  response
end

#add_user_to_group(group_id, user_id) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/fog/profitbricks/requests/compute/add_user_to_group.rb', line 62

def add_user_to_group(group_id, user_id)
  response = Excon::Response.new
  response.status = 202

  if group = data[:groups]['items'].find do |grp|
    grp["id"] == group_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  if user = data[:users]['items'].find do |usr|
    usr["id"] == user_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  group['users']['items'] << user
  user['groups']['items'] << group

  response.body = user
  response
end

#associate_nic_to_load_balancer(datacenter_id, load_balancer_id, nic_id) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/fog/profitbricks/requests/compute/associate_nic_to_load_balancer.rb', line 84

def associate_nic_to_load_balancer(datacenter_id, load_balancer_id, nic_id)
  if load_balancer = data[:load_balancers]['items'].find do |lb|
    lb["datacenter_id"] == datacenter_id && lb["id"] == load_balancer_id
  end
  else
    raise Fog::Errors::NotFound, "The requested resource could not be found"
  end

  unless load_balancer['entities'] && load_balancer['entities']['balancednics'] && load_balancer['entities']['balancednics']['items']
    nic = data[:nics]['items'].find do |nic|
      nic["datacenter_id"] == datacenter_id && nic["id"] == nic_id
    end

    load_balancer['entities'] = {
      'balancednics' => {
        'id'    => "#{load_balancer_id}/balancednics",
        'type'  => "collection",
        'href'  => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}/balancednics",
        'items' => [nic]
      }
    }
  end

  response        = Excon::Response.new
  response.status = 202
  response.body   = nic
  response
end

#attach_cdrom(datacenter_id, server_id, cdrom_image_id) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/fog/profitbricks/requests/compute/attach_cdrom.rb', line 60

def attach_cdrom(datacenter_id, server_id, cdrom_image_id)
  if cdrom = data[:images]['items'].find do |cd|
    cd["id"] == cdrom_image_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  if server = data[:servers]['items'].find do |serv|
    serv['datacenter_id'] == datacenter_id && serv['id'] == server_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  cdrom['properties'] = {}
  cdrom['properties']['name'] = cdrom['name']

  if server['cdroms'] && server['cdroms']['items']
    server['cdroms']['items'] << cdrom
  else
    server['cdroms'] = {
      'id' => "#{server['id']}/cdroms",
      'type' => 'collection',
      'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{server['datacenter_id']}/servers/#{server['id']}/cdroms",
      'items' => [cdrom]
    }
  end

  response = Excon::Response.new
  response.status = 202
  response.body = cdrom

  response
end

#attach_volume(datacenter_id, server_id, storage_id) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/fog/profitbricks/requests/compute/attach_volume.rb', line 61

def attach_volume(datacenter_id, server_id, storage_id)
  if volume = data[:volumes]['items'].find do |vlm|
    vlm["id"] == storage_id && vlm["datacenter_id"] == datacenter_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  if server = data[:servers]['items'].find do |serv|
    serv['datacenter_id'] == datacenter_id && serv['id'] == server_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  volume['properties'] = {}
  volume['properties']['name'] = volume['name']
  volume['properties']['size'] = volume['size']
  volume['properties']['bus'] = volume['bus']
  volume['properties']['type'] = volume['type']
  volume['properties']['licenceType'] = 'LINUX'

  if server['entities'] && server['entities']['volumes'] && server['entities']['volumes']['items']
    server['entities']['volumes']['items'] << volume
  else
    server['entities'] = {
      'volumes' => {
        'id'    => "#{server_id}/volumes",
        'type'  => 'collection',
        'href'  => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/volumes",
        'items' => [volume]
      }
    }
  end

  response        = Excon::Response.new
  response.status = 202
  response.body   = volume

  response
end

#create_datacenter(options, entities = {}) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/fog/profitbricks/requests/compute/create_datacenter.rb', line 59

def create_datacenter(options, entities={})
  dc = {
    :properties => options,
    :entities => entities
  }

  if dc[:properties][:location] == nil
    raise Excon::Error::HTTPStatus, "Attribute 'location' is required"
  end

  dc_3_id = Fog::UUID.uuid
  dc_4_id = Fog::UUID.uuid
  datacenter = {
    'id' => dc_3_id,
    'type' => 'datacenter',
    'properties' => {
      'name' => dc[:properties][:name],
      'description' => dc[:properties][:description],
      'location' => dc[:properties][:location],
      'version' => 1
    }
  }

  if entities != nil and entities != {}
    datacenter = {
      'id' => dc_4_id,
      'type' => 'datacenter',
      'properties' => {
        'name' => dc[:properties][:name],
        'description' => dc[:properties][:description],
        'location' => dc[:properties][:location],
        'version' => 1
      },
      'entities' => {
        'volumes' => {
          'items' =>
            [
              {
                'type' => 'volume',
                'properties' => {
                  'name' => dc[:entities][:volumes][:items][0][:properties][:name],
                  'type' => dc[:entities][:volumes][:items][0][:properties][:type],
                  'size' => dc[:entities][:volumes][:items][0][:properties][:size],
                  'bus' => dc[:entities][:volumes][:items][0][:properties][:bus],
                  'licenceType' => dc[:entities][:volumes][:items][0][:properties][:licenceType],
                  'availabilityZone' => dc[:entities][:volumes][:items][0][:properties][:availabilityZone]
                }
              }
            ]
        },
        'servers' => {
          'items' =>
            [
              {
                'properties' => {
                  'name' => dc[:entities][:servers][:items][0][:properties][:name],
                  'cores' => dc[:entities][:servers][:items][0][:properties][:cores],
                  'ram' => dc[:entities][:servers][:items][0][:properties][:ram]
                }
              }
            ]
        }
      }
    }
  end

  data[:datacenters]['items'] << datacenter
  response = Excon::Response.new
  response.status = 202
  response.body = datacenter
  response
end

#create_firewall_rule(datacenter_id, server_id, nic_id, options = {}) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/fog/profitbricks/requests/compute/create_firewall_rule.rb', line 70

def create_firewall_rule(datacenter_id, server_id, nic_id, options = {})
  response = Excon::Response.new
  response.status = 202

  properties = {}
  properties['name'] = options[:name]
  properties['protocol'] = options[:protocol]
  properties['source_mac'] = options[:sourceMac]
  properties['port_range_start'] = options[:portRangeStart]
  properties['port_range_end'] = options[:portRangeEnd]

  firewall_rule_id = Fog::UUID.uuid
  firewall_rule = {
    'id' => firewall_rule_id,
    'type'        => 'firewall-rule',
    'href'        => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}/firewallrules/#{firewall_rule_id}",
    'metadata'    => {
      'createdDate' => '2015-03-18T19:00:51Z',
      'createdBy'         => '[email protected]',
      'etag'              => 'faa67fbacb1c0e2e02cf9650657251f2',
      'lastModifiedDate'  => '2015-03-18T19:00:51Z',
      'lastModifiedBy'    => '[email protected]',
      'state'             => 'AVAILABLE'
    },
    'properties' => properties,
    'datacenter_id' => datacenter_id,
    'server_id'     => server_id,
    'nic_id'        => nic_id
  }

  data[:firewall_rules]['items'] << firewall_rule
  response.body = firewall_rule

  response
end

#create_flavor(flavor_name, ram, cores) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/profitbricks/requests/compute/create_flavor.rb', line 22

def create_flavor(flavor_name, ram, cores)
  response = Excon::Response.new
  response.status = 200

  flavor = {
    'id'    => Fog::UUID.uuid,
    'name'  => flavor_name,
    'ram'   => ram,
    'cores' => cores
  }

  data[:flavors] << flavor
  response.body = { 'createFlavorResponse' => flavor }
  response
end

#create_group(options = {}) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/fog/profitbricks/requests/compute/create_group.rb', line 58

def create_group(options = {})
  if options[:name] == nil
    raise Excon::Error::HTTPStatus, "Attribute 'name' is required"
  end

  response = Excon::Response.new
  response.status = 202

  group_id = Fog::UUID.uuid

  group = {
    'id' => group_id,
    'type'      => 'group',
    'href'      => "https=>//api.profitbricks.com/rest/v4/um/groups/#{group_id}",
    'properties' => {
        'name'              => options[:name],
        'createDataCenter'  => options[:createDataCenter],
        'createSnapshot'    => options[:createSnapshot],
        'reserveIp'         => options[:reserveIp],
        'accessActivityLog' => options[:accessActivityLog]
    },
    'entities' => {
      'users' => {
        'id' => "#{group_id}/owns",
        'type' => 'collection',
        'href' => "https://api.profitbricks.com/cloudapi/v4/um/groups/#{group_id}/users",
        'items' => []
      },
      'resources' => {
        'id' => "#{group_id}/resources",
        'type' => 'collection',
        'href' => "https://api.profitbricks.com/cloudapi/v4/um/groups/#{group_id}/resources",
        'items' => []
      }
    }
  }

  data[:groups]['items'] << group

  response.body = group
  response
end

#create_ip_block(options = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/fog/profitbricks/requests/compute/create_ip_block.rb', line 48

def create_ip_block(options = {})
  ipb_3_id = Fog::UUID.uuid
  ip_block = {
    'id' => ipb_3_id,
    'type' => 'ipblock',
    'href' => "https://api.profitbricks.com/rest/v2/ipblocks/#{ipb_3_id}",
    'metadata' => {
      'createdDate' => '2016-07-31T15:41:27Z',
      'createdBy'         => '[email protected]',
      'etag'              => '5b91832ee85a758568d4523a86bd8702',
      'lastModifiedDate'  => '2016-07-31T15:41:27Z',
      'lastModifiedBy'    => '[email protected]',
      'state'             => 'AVAILABLE'
    },
    'properties' => {
      'ips' => ["777.777.777.777", "888.888.888.888"],
      'location' => options[:location],
      'size'	    => options[:size],
      'name' => options[:name]
    }
  }

  data[:ip_blocks]['items'] << ip_block
  response        = Excon::Response.new
  response.status = 202
  response.body   = ip_block
  response
end

#create_lan(datacenter_id, properties = {}, _entities = {}) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/fog/profitbricks/requests/compute/create_lan.rb', line 112

def create_lan(datacenter_id, properties = {}, _entities = {})
  response = Excon::Response.new
  response.status = 202

  if datacenter = data[:datacenters]['items'].find do |attrib|
    attrib['id'] == datacenter_id
  end

    datacenter['properties']['version'] += 1 if datacenter['properties']
    datacenter['version'] += 1 if datacenter['version']

  else
    raise Fog::Errors::NotFound, 'Data center resource could not be found'
  end

  lan = {
    'id' => '10',
    'type'        => 'lan',
    'href'        => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/lans/10",
    'metadata'    => {
      'createdDate' => '2015-03-18T19:00:51Z',
      'createdBy'         => '[email protected]',
      'etag'              => 'faa67fbacb1c0e2e02cf9650657251f1',
      'lastModifiedDate'  => '2015-03-18T19:00:51Z',
      'lastModifiedBy'    => '[email protected]',
      'state'             => 'AVAILABLE'
    },
    'properties' => {
      'name' => properties[:name],
      'public' => properties[:public]
    },
    'entities' => {
      'nics' => {
        'id' => '10/nics',
        'type'  => 'collection',
        'href'  => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/lans/10/nics",
        'items' => []
      }
    },
    'datacenter_id' => datacenter_id
  }

  data[:lans]['items'] << lan

  response.body = lan
  response
end

#create_load_balancer(datacenter_id, properties = {}, entities = {}) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/fog/profitbricks/requests/compute/create_load_balancer.rb', line 55

def create_load_balancer(datacenter_id, properties = {}, entities = {})
  response = Excon::Response.new
  response.status = 202

  load_balancer_id  = Fog::UUID.uuid
  nic_1_id          = Fog::UUID.uuid
  serv_1_id         = Fog::UUID.uuid
  properties[:ip] = '123.456.789'

  load_balancer = {
    'id' => load_balancer_id,
    'type'        => 'loadbalancer',
    'href'        => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/loadbalancers/#{load_balancer_id}",
    'metadata'    => {
      'createdDate' => '2015-03-18T19:00:51Z',
      'createdBy'         => '[email protected]',
      'etag'              => 'faa67fbacb1c0e2e02cf9650657251f2',
      'lastModifiedDate'  => '2015-03-18T19:00:51Z',
      'lastModifiedBy'    => '[email protected]',
      'state'             => 'AVAILABLE'
    },
    'properties'      => properties,
    'entities'        => entities,
    'datacenter_id' => datacenter_id
  }

  data[:load_balancers]['items'] << load_balancer
  response.body = load_balancer

  response
end

#create_nic(datacenter_id, server_id, options = {}, entities = {}) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/fog/profitbricks/requests/compute/create_nic.rb', line 91

def create_nic(datacenter_id, server_id, options = {}, entities = {})
  if options[:lan] == nil
    raise Excon::Error::HTTPStatus, "Attribute 'lan' is required"
  end

  response = Excon::Response.new
  response.status = 202

  nic_id = Fog::UUID.uuid
  nic = {
    'id' => nic_id,
    'type'        => 'nic',
    'href'        => "https://api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}",
    'metadata'    => {
      'createdDate' => '2015-03-18T19:00:51Z',
      'createdBy'         => '[email protected]',
      'etag'              => 'faa67fbacb1c0e2e02cf9650657251f2',
      'lastModifiedDate'  => '2015-03-18T19:00:51Z',
      'lastModifiedBy'    => '[email protected]',
      'state'             => 'AVAILABLE'
    },
    'properties'      => options,
    'entities'        => entities,
    'datacenter_id' => datacenter_id,
    'server_id' => server_id
  }

  data[:nics]['items'] << nic
  response.body = nic

  response
end

#create_server(datacenter_id, properties = {}, entities = {}) ⇒ Object



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/fog/profitbricks/requests/compute/create_server.rb', line 135

def create_server(datacenter_id, properties = {}, entities = {})
  if properties[:cores] == nil
    raise Excon::Error::HTTPStatus, "Attribute 'cores' is required"
  end

  server_id = Fog::UUID.uuid

  volume_id = if entities[:volumes] && entities[:volumes]['items'] && entities[:volumes]['items'][0] && entities[:volumes]['items'][0]['id']
                entities[:volumes]['items'][0]['id']
              else
                Fog::UUID.uuid
              end

  server = {
    'id'    => server_id,
    'type'  => 'server',
    'href'  => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}",
    'datacenter_id' => datacenter_id,
    'metadata' => {
      'createdDate'       => '2014-10-20T21:20:46Z',
      'createdBy'         => '[email protected]',
      'etag'              => '0018832d7a7ba455db74ac41ae9f11fe',
      'lastModifiedDate'  => '2015-03-18T21:31:10Z',
      'lastModifiedBy'    => '[email protected]',
      'state'             => 'AVAILABLE'
    },
    'properties' => {
      'name'              => properties[:name],
      'cores'             => properties[:cores],
      'ram'               => properties[:ram],
      'availabilityZone'  => properties[:availabilityZone],
      'vmState'           => 'RUNNING',
      'cpuFamily' => properties[:cpuFamily],
      'bootVolume' => properties[:bootVolume]
    }
  }

  if entities[:volumes]
    server['entities'] = {
      'volumes' => {
        'id'    => "#{server_id}/volumes",
        'type'  => 'collection',
        'href'  => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/volumes",
        'items' =>
        [
          {
            'id'          => volume_id,
            'type'        => 'volume',
            'href'        => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/volumes/#{volume_id}",
            'metadata'    => {
              'createdDate'       => '2015-03-18T19=>00=>51Z',
              'createdBy'         => '[email protected]',
              'etag'              => 'c4a2fde6ba91a038ff953b939cc21efe',
              'lastModifiedDate'  => '2015-03-18T19=>00=>51Z',
              'lastModifiedBy'    => '[email protected]',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'name'                => 'FogRestTestVolume',
              'type'                => 'HDD',
              'size'                => 5,
              'image'               => '4f363db0-4955-11e4-b362-52540066fee9',
              'bus'                 => 'VIRTIO',
              'licenceType'         => 'OTHER',
              'cpuHotPlug'          => 'true',
              'cpuHotUnplug'        => 'false',
              'ramHotPlug'          => 'false',
              'ramHotUnplug'        => 'false',
              'nicHotPlug'          => 'true',
              'nicHotUnplug'        => 'true',
              'discVirtioHotPlug'   => 'true',
              'discVirtioHotUnplug' => 'true',
              'discScsiHotPlug'     => 'false',
              'discScsiHotUnplug'   => 'false',
              'deviceNumber'        => 1
            }
          }
        ]
      }
    }
  end

  if entities[:cdroms]
    server['entities']['cdroms'] = {
      'id'    => "#{server_id}/cdroms",
      'type'  => 'collection',
      'href'  => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/cdroms",
      'items' =>
      [
        {
          'id'        => 'dfcb40db-28b5-11e6-9336-52540005ab80',
          'type'      => 'image',
          'href'      => 'https=>//api.profitbricks.com/rest/v2/images/dfcb40db-28b5-11e6-9336-52540005ab80',
          'metadata'  => {
            'createdDate'       => '2016-06-02T11:33:49Z',
            'createdBy'         => 'System',
            'etag'              => '9909709d99655c6f31aca789998d7d89',
            'lastModifiedDate'  => '2016-06-02T11:33:49Z',
            'lastModifiedBy'    => 'System',
            'state'             => 'AVAILABLE'
          },
          'properties' => {
            'name'                => 'CentOS-6.8-x86_64-netinstall.iso',
            'description'         => '',
            'location'            => 'us/las',
            'size'                => 0.23,
            'cpuHotPlug'          => 'true',
            'cpuHotUnplug'        => 'false',
            'ramHotPlug'          => 'true',
            'ramHotUnplug'        => 'false',
            'nicHotPlug'          => 'true',
            'nicHotUnplug'        => 'true',
            'discVirtioHotPlug'   => 'true',
            'discVirtioHotUnplug' => 'true',
            'discScsiHotPlug'     => 'false',
            'discScsiHotUnplug'   => 'false',
            'licenceType'         => 'LINUX',
            'imageType'           => 'CDROM',
            'public'              => 'true'
          }
        }
      ]
    }
  end

  data[:servers]['items'] << server

  response = Excon::Response.new
  response.status = 202
  response.body = server

  response
end

#create_user(options = {}) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/fog/profitbricks/requests/compute/create_user.rb', line 50

def create_user(options = {})
  if options[:email] == nil
    raise Excon::Error::HTTPStatus, "Attribute 'email' is required"
  end

  response = Excon::Response.new
  response.status = 202

  user_id = Fog::UUID.uuid

  user = {
    'id' => user_id,
    'type'      => 'user',
    'href'      => "https=>//api.profitbricks.com/rest/v4/um/users/#{user_id}",
    'metadata' => {
        'etag'         => '26a6259cc0c1dae299a5687455dff0ce',
        'creationDate' => '2017-05-22T08:15:55Z',
        'lastLogin'    => '',
    },
    'properties' => {
        'firstname'     => options[:firstname],
        'lastname'      => options[:lastname],
        'email'         => options[:email],
        'password'      => options[:password],
        'administrator' => options[:administrator],
        'forceSecAuth'  => options[:force_sec_auth] || false,
        'secAuthActive'  => options[:sec_auth_active] || false
    },
    'entities' => {
      'owns' => {
        'id' => "#{user_id}/owns",
        'type' => 'collection',
        'href' => "https://api.profitbricks.com/cloudapi/v4/um/users/#{user_id}/owns",
        'items' => []
      },
      'groups' => {
        'id' => "#{user_id}/groups",
        'type' => 'collection',
        'href' => "https://api.profitbricks.com/cloudapi/v4/um/users/#{user_id}/groups",
        'items' => []
      }
    }
  }

  data[:users]['items'] << user

  response.body = user
  response
end

#create_volume(datacenter_id, options = {}) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/fog/profitbricks/requests/compute/create_volume.rb', line 76

def create_volume(datacenter_id, options = {})
  response = Excon::Response.new
  response.status = 202

  if options[:size] == nil
    raise Excon::Error::HTTPStatus, "Attribute 'size' is required"
  end

  if datacenter = data[:datacenters]['items'].find do |attrib|
    attrib['id'] == datacenter_id
  end

    datacenter['version'] += 1 if datacenter['version']
  else
    raise Excon::Error::HTTPStatus, 'Resource does not exist'
  end

  volume_id = Fog::UUID.uuid

  volume = {
    'id' => volume_id,
    'type'      => 'volume',
    'href'      => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter['id']}/volumes/#{volume_id}",
    'metadata'  => {
      'createdDate' => '2015-03-18T19=>00=>51Z',
      'createdBy'         => '[email protected]',
      'etag'              => 'c4a2fde6ba91a038ff953b939cc21efe',
      'lastModifiedDate'  => '2015-03-18T19=>00=>51Z',
      'lastModifiedBy'    => '[email protected]',
      'state'             => 'AVAILABLE'
    },
    'properties' => {
      'name' => options[:name],
      'type'                => options[:type],
      'size'                => options[:size],
      'image'               => options[:image],
      'availabilityZone'    => options[:availabilityZone],
      'bus'                 => 'VIRTIO',
      'licenceType'         => 'OTHER',
      'cpuHotPlug'          => 'true',
      'cpuHotUnplug'        => 'false',
      'ramHotPlug'          => 'false',
      'ramHotUnplug'        => 'false',
      'nicHotPlug'          => 'true',
      'nicHotUnplug'        => 'true',
      'discVirtioHotPlug'   => 'true',
      'discVirtioHotUnplug' => 'true',
      'discScsiHotPlug'     => 'false',
      'discScsiHotUnplug'   => 'false',
      'deviceNumber'        => 1
    },
    'datacenter_id' => datacenter['id']
  }

  data[:volumes]['items'] << volume

  response.body = volume
  response
end

#create_volume_snapshot(datacenter_id, _volume_id, options = {}) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/fog/profitbricks/requests/compute/create_volume_snapshot.rb', line 59

def create_volume_snapshot(datacenter_id, _volume_id, options = {})
  response = Excon::Response.new
  response.status = 202

  if datacenter = data[:datacenters]['items'].find do |attrib|
    attrib['id'] == datacenter_id
  end
  else
    raise Excon::Error::HTTPStatus, 'Data center resource could not be found'
  end

  snapshot_id = Fog::UUID.uuid
  snapshot = {
    'id' => snapshot_id,
    'type'        => 'snapshot',
    'href'        => "https =>//api.profitbricks.com/rest/v2/snapshots/#{snapshot_id}",
    'metadata'    => {
      'createdDate' => '2016-08-07T22:28:39Z',
      'createdBy'         => '[email protected]',
      'etag'              => '83ad78a4757ab0d9bdeaebc3a6485dcf',
      'lastModifiedDate'  => '2016-08-07T22:28:39Z',
      'lastModifiedBy'    => '[email protected]',
      'state'             => 'AVAILABLE'
    },
    'properties' => {
      'name' => options[:name],
      'description'         => options[:description],
      'location'            => 'us/las',
      'size'                => 5,
      'cpuHotPlug'          => 'true',
      'cpuHotUnplug'        => 'false',
      'ramHotPlug'          => 'false',
      'ramHotUnplug'        => 'false',
      'nicHotPlug'          => 'true',
      'nicHotUnplug'        => 'true',
      'discVirtioHotPlug'   => 'true',
      'discVirtioHotUnplug' => 'true',
      'discScsiHotPlug'     => 'false',
      'discScsiHotUnplug'   => 'false',
      'licenceType'         => 'OTHER'
    }
  }

  data[:snapshots]['items'] << snapshot

  response.body = snapshot
  response
end

#dataObject



1275
1276
1277
# File 'lib/fog/profitbricks/compute.rb', line 1275

def data
  self.class.data[@profitbricks_username]
end

#delete_datacenter(datacenter_id) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/profitbricks/requests/compute/delete_datacenter.rb', line 25

def delete_datacenter(datacenter_id)
  response = Excon::Response.new
  response.status = 202

  if dc = data[:datacenters]["items"].find do |datacenter|
    datacenter["id"] == datacenter_id
  end
  else
      raise Excon::Error::HTTPStatus, "The requested resource could not be found"
  end

  response
end

#delete_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fog/profitbricks/requests/compute/delete_firewall_rule.rb', line 28

def delete_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id)
  response = Excon::Response.new
  response.status = 202

  if firewall_rule = data[:firewall_rules]["items"].find do |attribute|
    attribute["datacenter_id"] == datacenter_id && attribute["server_id"] == server_id && attribute["nic_id"] == nic_id && attribute["id"] == firewall_rule_id
  end
  else
    raise Fog::Errors::NotFound, "The requested firewall rule resource could not be found"
  end

  response
end

#delete_group(group_id) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/profitbricks/requests/compute/delete_group.rb', line 27

def delete_group(group_id)
  response = Excon::Response.new
  response.status = 202

  if group = data[:groups]['items'].find do |grp|
    grp['id'] == group_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response
end

#delete_image(image_id) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/profitbricks/requests/compute/delete_image.rb', line 25

def delete_image(image_id)
  response = Excon::Response.new
  response.status = 202

  if img = data[:images]["items"].find do |image|
    image["id"] == image_id
  end
  else
    raise Fog::Errors::NotFound, "The requested resource could not be found"
  end

  response
end

#delete_ip_block(ip_block_id) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/profitbricks/requests/compute/delete_ip_block.rb', line 25

def delete_ip_block(ip_block_id)
  response = Excon::Response.new
  response.status = 202

  if ip_block = data[:ip_blocks]["items"].find do |attribute|
    attribute["id"] == ip_block_id
  end
  else
    raise Fog::Errors::NotFound, "The requested IP Block could not be found"
  end

  response
end

#delete_lan(datacenter_id, lan_id) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/profitbricks/requests/compute/delete_lan.rb', line 26

def delete_lan(datacenter_id, lan_id)
  response = Excon::Response.new
  response.status = 202

  if lan = data[:lans]["items"].find do |attribute|
    attribute["datacenter_id"] == datacenter_id && attribute["id"] == lan_id
  end
  else
    raise Fog::Errors::NotFound, "The requested lan could not be found"
  end

  response
end

#delete_load_balancer(datacenter_id, load_balancer_id) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/profitbricks/requests/compute/delete_load_balancer.rb', line 26

def delete_load_balancer(datacenter_id, load_balancer_id)
  response = Excon::Response.new
  response.status = 202

  if lb = data[:load_balancers]["items"].find do |attribute|
    attribute["datacenter_id"] == datacenter_id && attribute["id"] == load_balancer_id
  end
  else
    raise Fog::Errors::NotFound, "The requested resource could not be found"
  end

  response
end

#delete_nic(datacenter_id, server_id, nic_id) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/profitbricks/requests/compute/delete_nic.rb', line 27

def delete_nic(datacenter_id, server_id, nic_id)
  response = Excon::Response.new
  response.status = 202

  if nic = data[:nics]["items"].find do |attribute|
    attribute["datacenter_id"] == datacenter_id && attribute["server_id"] == server_id && attribute["id"] == nic_id
  end
  else
    raise Fog::Errors::NotFound, "The requested nic resource could not be found"
  end

  response
end

#delete_server(datacenter_id, server_id) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fog/profitbricks/requests/compute/delete_server.rb', line 28

def delete_server(datacenter_id, server_id)
  if server = data[:servers]['items'].find do |attrib|
    attrib['datacenter_id'] == datacenter_id && attrib['id'] == server_id
  end
    data[:servers].delete(server)
  else
    raise Fog::Errors::NotFound, 'The requested server resource could not be found'
  end

  response        = Excon::Response.new
  response.status = 202
  response
end

#delete_share(group_id, resource_id) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/profitbricks/requests/compute/delete_share.rb', line 26

def delete_share(group_id, resource_id)
  response = Excon::Response.new
  response.status = 202

  if share = data[:shares]['items'].find do |shr|
    shr['id'] == resource_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response
end

#delete_snapshot(snapshot_id) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/profitbricks/requests/compute/delete_snapshot.rb', line 24

def delete_snapshot(snapshot_id)
  response = Excon::Response.new
  response.status = 202

  if snapshot = data[:snapshots]['items'].find do |attrib|
    attrib['id'] == snapshot_id
  end
  else
    raise Fog::Errors::NotFound, 'The requested resource could not be found'
  end

  response
end

#delete_user(user_id) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/profitbricks/requests/compute/delete_user.rb', line 27

def delete_user(user_id)
  response = Excon::Response.new
  response.status = 202

  if user = data[:users]['items'].find do |usr|
    usr['id'] == user_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response
end

#delete_volume(datacenter_id, volume_id) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/profitbricks/requests/compute/delete_volume.rb', line 26

def delete_volume(datacenter_id, volume_id)
  response = Excon::Response.new
  response.status = 202

  if vlm = data[:volumes]["items"].find do |volume|
    volume["id"] == volume_id && volume["datacenter_id"] == datacenter_id
  end
  else
    raise Excon::Error::HTTPStatus, "The requested resource could not be found"
  end

  response
end

#detach_cdrom(datacenter_id, server_id, cdrom_id) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fog/profitbricks/requests/compute/detach_cdrom.rb', line 27

def detach_cdrom(datacenter_id, server_id, cdrom_id)
  response = Excon::Response.new
  response.status = 202

  if server = data[:servers]['items'].find do |serv|
    serv['datacenter_id'] == datacenter_id && serv['id'] == server_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  if cdrom = server['cdroms']['items'].find do |cd|
    cd['id'] == cdrom_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response
end

#detach_volume(datacenter_id, server_id, volume_id) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/profitbricks/requests/compute/detach_volume.rb', line 28

def detach_volume(datacenter_id, server_id, volume_id)
  response = Excon::Response.new
  response.status = 202

  if server = data[:servers]['items'].find do |serv|
    serv['datacenter_id'] == datacenter_id && serv['id'] == server_id
  end
  else
    raise Fog::Errors::NotFound, "The server resource could not be found"
  end

  if server['entities']
    volume = server['entities']['volumes']['items'].find do |vlm|
      vlm['id'] == volume_id
    end
  elsif server['volumes']
    volume = server['volumes']['items'].find do |vlm|
      vlm['id'] == volume_id
    end
  else
    raise Fog::Errors::NotFound, "The attached volume resource could not be found"
  end

  response
end

#get_all_contract_resourcesObject



46
47
48
49
50
51
# File 'lib/fog/profitbricks/requests/compute/get_all_contract_resources.rb', line 46

def get_all_contract_resources
  response        = Excon::Response.new
  response.status = 200
  response.body   = data[:contracts]
  response
end

#get_all_datacentersObject



50
51
52
53
54
55
# File 'lib/fog/profitbricks/requests/compute/get_all_datacenters.rb', line 50

def get_all_datacenters
  response        = Excon::Response.new
  response.status = 200
  response.body   = data[:datacenters]
  response
end

#get_all_firewall_rules(datacenter_id, server_id, nic_id) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/fog/profitbricks/requests/compute/get_all_firewall_rules.rb', line 55

def get_all_firewall_rules(datacenter_id, server_id, nic_id)
  firewall_rules = data[:firewall_rules]

  if nics = data[:firewall_rules]['items'].select do |attrib|
    attrib['datacenter_id'] == datacenter_id && attrib['server_id'] == server_id && attrib['nic_id'] == nic_id
  end
  else
    raise Fog::Errors::NotFound, 'The resource could not be found'
  end

  firewall_rules['items'] = nics
  response        = Excon::Response.new
  response.status = 200
  response.body   = firewall_rules

  response
end

#get_all_flavorsObject



65
66
67
68
69
70
71
72
73
# File 'lib/fog/profitbricks/requests/compute/get_all_flavors.rb', line 65

def get_all_flavors
  data = self.data[:flavors]
  response        = Excon::Response.new
  response.status = 200
  response.body   = {
    'getAllFlavorsResponse' => self.data[:flavors]
  }
  response
end

#get_all_groupsObject



52
53
54
55
56
57
58
# File 'lib/fog/profitbricks/requests/compute/get_all_groups.rb', line 52

def get_all_groups
  response        = Excon::Response.new
  response.status = 200
  response.body   = data[:groups]

  response
end

#get_all_imagesObject



57
58
59
60
61
62
# File 'lib/fog/profitbricks/requests/compute/get_all_images.rb', line 57

def get_all_images
  response        = Excon::Response.new
  response.status = 200
  response.body   = data[:images]
  response
end

#get_all_ip_blocksObject



44
45
46
47
48
49
50
51
52
# File 'lib/fog/profitbricks/requests/compute/get_all_ip_blocks.rb', line 44

def get_all_ip_blocks
  ip_blocks = data[:ip_blocks]

  response        = Excon::Response.new
  response.status = 200
  response.body   = ip_blocks

  response
end

#get_all_lans(datacenter_id) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/fog/profitbricks/requests/compute/get_all_lans.rb', line 101

def get_all_lans(datacenter_id)
  lans = data[:lans]

  if lns = data[:lans]['items'].select do |attrib|
    attrib['datacenter_id'] == datacenter_id
  end
  else
    raise Fog::Errors::NotFound, 'The resource could not be found'
  end

  lans['items']   = lns
  response        = Excon::Response.new
  response.status = 200
  response.body   = lans

  response
end

#get_all_load_balanced_nics(datacenter_id, load_balancer_id) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/fog/profitbricks/requests/compute/get_all_load_balanced_nics.rb', line 82

def get_all_load_balanced_nics(datacenter_id, load_balancer_id)
  if load_balancer = data[:load_balancers]['items'].find do |lb|
    lb["datacenter_id"] == datacenter_id && lb["id"] == load_balancer_id
  end
  else
    raise Fog::Errors::NotFound, "The requested resource could not be found"
  end

  load_balanced_nics = nil

  load_balanced_nics = if load_balancer['entities']
                         load_balancer['entities']['balancednics']
                       else
                         load_balancer['balancednics']
                       end

  response        = Excon::Response.new
  response.status = 200
  response.body   = load_balanced_nics
  response
end

#get_all_load_balancers(datacenter_id) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/fog/profitbricks/requests/compute/get_all_load_balancers.rb', line 101

def get_all_load_balancers(datacenter_id)
  if load_balancers = data[:load_balancers]['items'].select do |attrib|
    attrib['datacenter_id'] == datacenter_id
  end
  else
    raise Fog::Errors::NotFound, 'The requested Load Balancer resource could not be found'
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = data[:load_balancers]
  response
end

#get_all_locations(_options = {}) ⇒ Object



35
36
37
38
39
40
# File 'lib/fog/profitbricks/requests/compute/get_all_locations.rb', line 35

def get_all_locations(_options = {})
  response        = Excon::Response.new
  response.status = 200
  response.body   = data[:locations]
  response
end

#get_all_nic(datacenter_id, _server_id) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/fog/profitbricks/requests/compute/get_all_nic.rb', line 82

def get_all_nic(datacenter_id, _server_id)
  interfaces = data[:nics]

  if nics = interfaces['items'].select do |attrib|
    attrib['datacenter_id'] == datacenter_id
  end
  else
    raise Fog::Errors::NotFound, 'The resource could not be found'
  end

  interfaces['items'] = nics
  response        = Excon::Response.new
  response.status = 200
  response.body   = interfaces

  response
end

#get_all_requestsObject



32
33
34
35
36
37
38
39
# File 'lib/fog/profitbricks/requests/compute/get_all_requests.rb', line 32

def get_all_requests
  requests = data[:requests]
  response        = Excon::Response.new
  response.status = 200
  response.body   = requests

  response
end

#get_all_resourcesObject



56
57
58
59
60
61
62
# File 'lib/fog/profitbricks/requests/compute/get_all_resources.rb', line 56

def get_all_resources
  response        = Excon::Response.new
  response.status = 200
  response.body   = data[:resources]

  response
end

#get_all_servers(datacenter_id) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/fog/profitbricks/requests/compute/get_all_servers.rb', line 117

def get_all_servers(datacenter_id)
  if servs = data[:servers]['items'].select do |attrib|
    attrib['datacenter_id'] == datacenter_id
  end
  else
    raise Fog::Errors::NotFound, 'Server resource could not be found'
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = data[:servers]
  response
end

#get_all_shares(group_id) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/fog/profitbricks/requests/compute/get_all_shares.rb', line 36

def get_all_shares(group_id)
  response        = Excon::Response.new
  response.status = 200
  response.body   = data[:shares]

  response
end

#get_all_snapshotsObject



56
57
58
59
60
61
62
# File 'lib/fog/profitbricks/requests/compute/get_all_snapshots.rb', line 56

def get_all_snapshots
  response        = Excon::Response.new
  response.status = 200
  response.body   = data[:snapshots]

  response
end

#get_all_usersObject



60
61
62
63
64
65
66
# File 'lib/fog/profitbricks/requests/compute/get_all_users.rb', line 60

def get_all_users
  response        = Excon::Response.new
  response.status = 200
  response.body   = data[:users]

  response
end

#get_all_volumes(datacenter_id) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/fog/profitbricks/requests/compute/get_all_volumes.rb', line 58

def get_all_volumes(datacenter_id)
  volumes = data[:volumes]

  if vlms = data[:volumes]['items'].select do |attrib|
    attrib['datacenter_id'] == datacenter_id
  end
  else
    raise Fog::Errors::NotFound, 'Volume resource could not be found'
  end

  volumes['items'] = vlms
  response        = Excon::Response.new
  response.status = 200
  response.body   = data[:volumes]

  response
end

#get_attached_cdrom(datacenter_id, server_id, cdrom_image_id) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/fog/profitbricks/requests/compute/get_attached_cdrom.rb', line 55

def get_attached_cdrom(datacenter_id, server_id, cdrom_image_id)
  if server = data[:servers]['items'].find do |serv|
    serv['datacenter_id'] == datacenter_id && serv['id'] == server_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  if cdrom = server['cdroms']['items'].find do |cd|
    cd['id'] == cdrom_image_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = cdrom
  response
end

#get_attached_volume(datacenter_id, server_id, volume_id) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/fog/profitbricks/requests/compute/get_attached_volume.rb', line 56

def get_attached_volume(datacenter_id, server_id, volume_id)
  if server = data[:servers]['items'].find do |serv|
    serv['datacenter_id'] == datacenter_id && serv['id'] == server_id
  end
  else
    raise Fog::Errors::NotFound, "The server resource could not be found"
  end

  if server['entities']
    volume = server['entities']['volumes']['items'].find do |vlm|
      vlm['id'] == volume_id
    end
  elsif server['volumes']
    volume = server['volumes']['items'].find do |vlm|
      vlm['id'] == volume_id
    end
  else
    raise Fog::Errors::NotFound, "The attached volume resource could not be found"
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = volume
  response
end

#get_datacenter(datacenter_id) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fog/profitbricks/requests/compute/get_datacenter.rb', line 47

def get_datacenter(datacenter_id)
  if dc = data[:datacenters]["items"].find do |datacenter|
    datacenter["id"] == datacenter_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = dc
  response
end

#get_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/fog/profitbricks/requests/compute/get_firewall_rule.rb', line 52

def get_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id)
  if firewall_rule = data[:firewall_rules]['items'].find do |fwr|
    fwr["datacenter_id"] == datacenter_id && fwr["server_id"] == server_id && fwr["nic_id"] == nic_id && fwr["id"] == firewall_rule_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = firewall_rule
  response
end

#get_flavor(flavor_id) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/fog/profitbricks/requests/compute/get_flavor.rb', line 65

def get_flavor(flavor_id)
  response        = Excon::Response.new
  response.status = 200

  if flavor = data[:flavors].find do |attrib|
    attrib["flavorId"] == flavor_id
  end
  else
    raise Fog::Errors::NotFound, "The requested flavor could not be found"
  end

  response.body = { "getFlavorResponse" => flavor }
  response
end

#get_group(group_id) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/fog/profitbricks/requests/compute/get_group.rb', line 48

def get_group(group_id)
  if group = data[:groups]['items'].find do |grp|
    grp["id"] == group_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = group
  response
end

#get_group_users(group_id) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/fog/profitbricks/requests/compute/get_group_users.rb', line 60

def get_group_users(group_id)
  if users = data[:groups]['items']['users'].find do |usr|
    usr["groups"]["items"].find do |grp|
      grp["id"] == group_id
    end
  end
  else
    raise Fog::Errors::NotFound, "The requested resource could not be found"
  end

  response        = Excon::Response.new
  response.status = 200
  response.body = users
  response
end

#get_image(image_id) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/fog/profitbricks/requests/compute/get_image.rb', line 53

def get_image(image_id)
  if img = data[:images]["items"].find do |image|
    image["id"] == image_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = img
  response
end

#get_ip_block(ip_block_id) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/profitbricks/requests/compute/get_ip_block.rb', line 40

def get_ip_block(ip_block_id)
  if ip_block = data[:ip_blocks]['items'].find do |ipb|
    ipb["id"] == ip_block_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = ip_block
  response
end

#get_lan(datacenter_id, lan_id) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/fog/profitbricks/requests/compute/get_lan.rb', line 102

def get_lan(datacenter_id, lan_id)
  if lan = data[:lans]['items'].find do |ln|
    ln["datacenter_id"] == datacenter_id && ln["id"] == lan_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = lan
  response
end

#get_load_balanced_nic(datacenter_id, load_balancer_id, _nic_id) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/fog/profitbricks/requests/compute/get_load_balanced_nic.rb', line 79

def get_load_balanced_nic(datacenter_id, load_balancer_id, _nic_id)
  if load_balancer = data[:load_balancers]['items'].find do |lb|
    lb["datacenter_id"] == datacenter_id && lb["id"] == load_balancer_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  load_balanced_nic = nil

  load_balanced_nic = if load_balancer['entities']
                        load_balancer['entities']['balancednics']['items'][0]
                      else
                        load_balancer['balancednics']['items'][0]
                      end

  load_balanced_nic['mac'] = '01:23:45:67:89:00'
  load_balanced_nic['nat'] = false
  load_balanced_nic['firewall_active'] = true
  load_balanced_nic['lan'] = load_balanced_nic[:lan]
  load_balanced_nic['ips'] = load_balanced_nic[:ips]

  response        = Excon::Response.new
  response.status = 200
  response.body   = load_balanced_nic
  response
end

#get_load_balancer(datacenter_id, load_balancer_id) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/fog/profitbricks/requests/compute/get_load_balancer.rb', line 98

def get_load_balancer(datacenter_id, load_balancer_id)
  if load_balancer = data[:load_balancers]['items'].find do |lb|
    lb["datacenter_id"] == datacenter_id && lb["id"] == load_balancer_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = load_balancer
  response
end

#get_location(location_id) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/profitbricks/requests/compute/get_location.rb', line 31

def get_location(location_id)
  if loc = data[:locations]['items'].find do |lo|
    lo["id"] == location_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = loc
  response
end

#get_nic(datacenter_id, server_id, nic_id) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/fog/profitbricks/requests/compute/get_nic.rb', line 79

def get_nic(datacenter_id, server_id, nic_id)
  if nic = data[:nics]['items'].find do |nic|
    nic["id"] == nic_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = nic
  response
end

#get_request(request_id) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/fog/profitbricks/requests/compute/get_request.rb', line 49

def get_request(request_id)
if request = data[:requests]["items"].find do |req|
  req["id"] == request_id
end
else
  raise Excon::Error::HTTPStatus, "Resource does not exist"
end

response        = Excon::Response.new
response.status = 200
response.body   = data[:requests]['items'][0]

response
end

#get_request_status(_request_id) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/fog/profitbricks/requests/compute/get_request_status.rb', line 38

def get_request_status(_request_id)
response        = Excon::Response.new
response.status = 200
response.body   = data[:request_status]

response
end

#get_resource_by_type(resource_type, resource_id) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/fog/profitbricks/requests/compute/get_resource_by_type.rb', line 63

def get_resource_by_type(resource_type, resource_id)
  if resource = data[:resources]['items'].find do |r|
    r["type"] == resource_type && r["id"] == resource_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = resource

  response
end

#get_resources_by_type(resource_type) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fog/profitbricks/requests/compute/get_resources_by_type.rb', line 34

def get_resources_by_type(resource_type)
  if resources = data[:resources]['items'].select {|resource| resource['type'] == resource_type}
    result = data[:resources].dup
    result['items'] = resources
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response = Excon::Response.new
  response.status = 200
  response.body = result
  response
end

#get_server(datacenter_id, server_id) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/fog/profitbricks/requests/compute/get_server.rb', line 114

def get_server(datacenter_id, server_id)
  if server = data[:servers]['items'].find do |serv|
    serv['datacenter_id'] == datacenter_id && serv['id'] == server_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = server
  response
end

#get_share(group_id, resource_id) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/profitbricks/requests/compute/get_share.rb', line 36

def get_share(group_id, resource_id)
  if share = data[:shares]['items'].find do |shr|
    shr["id"] == resource_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = share
  response
end

#get_snapshot(snapshot_id) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/fog/profitbricks/requests/compute/get_snapshot.rb', line 52

def get_snapshot(snapshot_id)
  if snapshot = data[:snapshots]['items'].find do |attrib|
    attrib["id"] == snapshot_id
  end
  else
    raise Excon::Error::HTTPStatus, 'Resource does not exist'
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = snapshot
  response
end

#get_user(user_id) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/fog/profitbricks/requests/compute/get_user.rb', line 56

def get_user(user_id)
  if user = data[:users]['items'].find do |usr|
    usr["id"] == user_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = user
  response
end

#get_volume(datacenter_id, volume_id) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fog/profitbricks/requests/compute/get_volume.rb', line 55

def get_volume(datacenter_id, volume_id)
  if volume = data[:volumes]['items'].find do |vlm|
    vlm["id"] == volume_id && vlm["datacenter_id"] == datacenter_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 200
  response.body   = volume
  response
end

#list_attached_cdroms(datacenter_id, server_id) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/fog/profitbricks/requests/compute/list_attached_cdroms.rb', line 58

def list_attached_cdroms(datacenter_id, server_id)
  if server = data[:servers]['items'].find do |serv|
    serv['datacenter_id'] == datacenter_id && serv['id'] == server_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  data[:images]['items'] = data[:images]['items'].select {|img| img['imageType'] == 'CDROM'}

  response        = Excon::Response.new
  response.status = 200
  response.body   = data[:images]
  response
end

#list_attached_volumes(datacenter_id, server_id) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/fog/profitbricks/requests/compute/list_attached_volumes.rb', line 59

def list_attached_volumes(datacenter_id, server_id)
  if server = data[:servers]['items'].find do |serv|
    serv['datacenter_id'] == datacenter_id && serv['id'] == server_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 200
  response.body = if server['volumes']
                    server['volumes']
                  else
                    {
                      'id' => "#{server_id}/volumes",
                      'type'  => 'collection',
                      'href'  => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/volumes",
                      'items' => []
                    }
                  end

  response
end

#reboot_server(datacenter_id, server_id) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/profitbricks/requests/compute/reboot_server.rb', line 28

def reboot_server(datacenter_id, server_id)
  if server = data[:servers]['items'].find do |attrib|
    attrib['datacenter_id'] == datacenter_id && attrib['id'] == server_id
  end
  else
    raise Fog::Errors::NotFound, 'The requested server resource could not be found'
  end

  response        = Excon::Response.new
  response.status = 202
  response
end

#remove_nic_association(datacenter_id, load_balancer_id, _nic_id) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/profitbricks/requests/compute/remove_nic_association.rb', line 27

def remove_nic_association(datacenter_id, load_balancer_id, _nic_id)
  if load_balancer = data[:load_balancers]['items'].find do |lb|
    lb["datacenter_id"] == datacenter_id && lb["id"] == load_balancer_id
  end
  else
    raise Fog::Errors::NotFound, "The requested resource could not be found"
  end

  response        = Excon::Response.new
  response.status = 202
  response
end

#remove_user_from_group(group_id, user_id) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fog/profitbricks/requests/compute/remove_user_from_group.rb', line 26

def remove_user_from_group(group_id, user_id)
  response = Excon::Response.new
  response.status = 202

  if group = data[:groups]['items'].find do |grp|
    grp["id"] == group_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  if user = data[:users]['items'].find do |usr|
    usr["id"] == user_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response
end

#reset_dataObject



1279
1280
1281
# File 'lib/fog/profitbricks/compute.rb', line 1279

def reset_data
  self.class.data.delete(@profitbricks_username)
end

#restore_volume_snapshot(datacenter_id, volume_id, _options = {}) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fog/profitbricks/requests/compute/restore_volume_snapshot.rb', line 36

def restore_volume_snapshot(datacenter_id, volume_id, _options = {})
  response = Excon::Response.new
  response.status = 202

  if datacenter = data[:datacenters]['items'].find do |attrib|
    attrib['id'] == datacenter_id
  end
  else
    raise Excon::Error::HTTPStatus, 'Data center resource could not be found'
  end

  if volume = data[:volumes]['items'].find do |attrib|
    attrib['id'] == volume_id && attrib['datacenter_id'] == datacenter_id
  end
  else
    raise Excon::Error::HTTPStatus, 'Volume resource could not be found'
  end

  response
end

#start_server(datacenter_id, server_id) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/profitbricks/requests/compute/start_server.rb', line 27

def start_server(datacenter_id, server_id)
  if server = data[:servers]['items'].find do |attrib|
    attrib['datacenter_id'] == datacenter_id && attrib['id'] == server_id
  end
  else
    raise Fog::Errors::NotFound, 'The requested server resource could not be found'
  end

  server['vm_state'] = 'RUNNING'
  server['state'] = 'AVAILABLE'

  response        = Excon::Response.new
  response.status = 202
  response
end

#stop_server(datacenter_id, server_id) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fog/profitbricks/requests/compute/stop_server.rb', line 28

def stop_server(datacenter_id, server_id)
  if server = data[:servers]['items'].find do |attrib|
    attrib['datacenter_id'] == datacenter_id && attrib['id'] == server_id
  end
  else
    raise Fog::Errors::NotFound, 'The requested server resource could not be found'
  end

  server['vm_state'] = 'SHUTOFF'
  server['state'] = 'INACTIVE'

  response        = Excon::Response.new
  response.status = 202
  response
end

#update_datacenter(datacenter_id, options = {}) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/fog/profitbricks/requests/compute/update_datacenter.rb', line 49

def update_datacenter(datacenter_id, options = {})
  if dc = data[:datacenters]["items"].find do |datacenter|
    datacenter["id"] == datacenter_id
  end

    dc['properties']['version'] += 1 if dc['properties']
    dc['version'] += 1 if dc['version']

    dc['properties']['name'] = options[:properties][:name] if dc['properties']
    dc['name'] = options[:name] if dc['name']

  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 202
  response.body   = dc

  response
end

#update_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id, options = {}) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/fog/profitbricks/requests/compute/update_firewall_rule.rb', line 65

def update_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id, options = {})
  if firewall_rule = data[:firewall_rules]['items'].find do |attribute|
    attribute["datacenter_id"] == datacenter_id && attribute["server_id"] == server_id && attribute["nic_id"] == nic_id && attribute["id"] == firewall_rule_id
  end
    options.each do |key, value|
      firewall_rule[key] = value
    end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 202
  response.body   = firewall_rule

  response
end

#update_group(group_id, options = {}) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/fog/profitbricks/requests/compute/update_group.rb', line 63

def update_group(group_id, options = {})
  if group = data[:groups]['items'].find do |grp|
    grp["id"] == group_id
  end
    group['name']               = options[:name]
    group['createDataCenter']   = options[:createDataCenter] if [true, false].include?(options[:createDataCenter])
    group['createSnapshot']     = options[:createSnapshot] if [true, false].include?(options[:createSnapshot])
    group['reserveIp']          = options[:reserveIp] if [true, false].include?(options[:reserveIp])
    group['accessActivityLog']  = options[:accessActivityLog] if [true, false].include?(options[:accessActivityLog])
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 202
  response.body   = group

  response
end

#update_image(image_id, options = {}) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/fog/profitbricks/requests/compute/update_image.rb', line 68

def update_image(image_id, options = {})
  if img = data[:images]["items"].find do |image|
    image["id"] == image_id
  end
    img['licenceType'] = options[:licenceType]
    options.each do |key, value|
      img[key.to_s] = value
    end

  else
    raise Excon::Error::HTTPStatus, "The requested resource could not be found"
  end

  response        = Excon::Response.new
  response.status = 202
  response.body   = img

  response
end

#update_lan(datacenter_id, lan_id, options = {}) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/fog/profitbricks/requests/compute/update_lan.rb', line 106

def update_lan(datacenter_id, lan_id, options = {})
  if lan = data[:lans]['items'].find do |attrib|
    attrib['datacenter_id'] == datacenter_id && attrib['id'] == lan_id
  end
    options.each do |key, value|
      lan[key] = value
    end
  else
    raise Fog::Errors::NotFound, 'The requested LAN resource could not be found'
  end

  response        = Excon::Response.new
  response.status = 202
  response.body   = lan
  response
end

#update_load_balancer(datacenter_id, load_balancer_id, options = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/fog/profitbricks/requests/compute/update_load_balancer.rb', line 48

def update_load_balancer(datacenter_id, load_balancer_id, options = {})
  if load_balancer = data[:load_balancers]['items'].find do |attribute|
    attribute["datacenter_id"] == datacenter_id && attribute["id"] == load_balancer_id
  end
    options.each do |key, value|
      load_balancer[key] = value
    end
  else
    raise Fog::Errors::NotFound, 'The requested resource could not be found'
  end

  response        = Excon::Response.new
  response.status = 202
  response.body   = load_balancer

  response
end

#update_nic(datacenter_id, server_id, nic_id, options = {}) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/fog/profitbricks/requests/compute/update_nic.rb', line 85

def update_nic(datacenter_id, server_id, nic_id, options = {})
  if nic = data[:nics]['items'].find do |attribute|
    attribute["datacenter_id"] == datacenter_id && attribute["server_id"] == server_id && attribute["id"] == nic_id
  end
    nic['name'] = options[:name]
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 202
  response.body   = nic

  response
end

#update_server(_datacenter_id, server_id, properties = {}) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/fog/profitbricks/requests/compute/update_server.rb', line 125

def update_server(_datacenter_id, server_id, properties = {})
  if server = data[:servers]['items'].find do |attrib|
    attrib['id'] == server_id
  end
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  server['name'] = properties[:name]

  response        = Excon::Response.new
  response.status = 202
  response.body   = server
  response
end

#update_share(group_id, resource_id, options = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/fog/profitbricks/requests/compute/update_share.rb', line 48

def update_share(group_id, resource_id, options = {})
  if share = data[:shares]['items'].find do |shr|
    shr["id"] == resource_id
  end
    share['editPrivilege']   = options[:editPrivilege] if [true, false].include?(options[:editPrivilege])
    share['sharePrivilege']  = options[:sharePrivilege] if [true, false].include?(options[:sharePrivilege])
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 202
  response.body   = share

  response
end

#update_snapshot(snapshot_id, options = {}) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/fog/profitbricks/requests/compute/update_snapshot.rb', line 67

def update_snapshot(snapshot_id, options = {})
  if snapshot = data[:snapshots]['items'].find do |snpsht|
    snpsht["id"] == snapshot_id
  end
    options.each do |key, value|
      snapshot[key] = value
    end
  else
    raise Fog::Errors::NotFound, 'The requested resource could not be found'
  end

  response        = Excon::Response.new
  response.status = 202
  response.body   = snapshot

  response
end

#update_user(user_id, options = {}) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/fog/profitbricks/requests/compute/update_user.rb', line 72

def update_user(user_id, options = {})
  if user = data[:users]['items'].find do |usr|
    usr["id"] == user_id
  end
    user['firstname']     = options[:firstname]
    user['lastname']      = options[:lastname]
    user['email']         = options[:email]
    user['administrator'] = options[:administrator]
    user['forceSecAuth']  = options[:force_sec_auth] || false
  else
    raise Excon::Error::HTTPStatus, "Resource does not exist"
  end

  response        = Excon::Response.new
  response.status = 202
  response.body   = user

  response
end

#update_volume(datacenter_id, volume_id, options = {}) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/fog/profitbricks/requests/compute/update_volume.rb', line 60

def update_volume(datacenter_id, volume_id, options = {})
  if volume = data[:volumes]['items'].find do |vlm|
    vlm["id"] == volume_id && vlm["datacenter_id"] == datacenter_id
  end
    volume['name'] = options[:name]
    volume['size'] = options[:size]
  else
    raise Excon::Error::HTTPStatus, 'The requested resource could not be found'
  end

  response        = Excon::Response.new
  response.status = 202
  response.body   = volume

  response
end