Class: Fog::Compute::Google::Mock

Inherits:
Object
  • Object
show all
Includes:
Collections, Shared
Defined in:
lib/fog/google/compute.rb,
lib/fog/google/requests/compute/get_disk.rb,
lib/fog/google/requests/compute/get_zone.rb,
lib/fog/google/requests/compute/set_tags.rb,
lib/fog/google/requests/compute/get_image.rb,
lib/fog/google/requests/compute/get_server.rb,
lib/fog/google/requests/compute/list_disks.rb,
lib/fog/google/requests/compute/list_zones.rb,
lib/fog/google/requests/compute/attach_disk.rb,
lib/fog/google/requests/compute/delete_disk.rb,
lib/fog/google/requests/compute/detach_disk.rb,
lib/fog/google/requests/compute/get_address.rb,
lib/fog/google/requests/compute/get_network.rb,
lib/fog/google/requests/compute/insert_disk.rb,
lib/fog/google/requests/compute/list_images.rb,
lib/fog/google/requests/compute/delete_image.rb,
lib/fog/google/requests/compute/get_firewall.rb,
lib/fog/google/requests/compute/get_snapshot.rb,
lib/fog/google/requests/compute/insert_image.rb,
lib/fog/google/requests/compute/list_servers.rb,
lib/fog/google/requests/compute/set_metadata.rb,
lib/fog/google/requests/compute/delete_server.rb,
lib/fog/google/requests/compute/insert_server.rb,
lib/fog/google/requests/compute/list_networks.rb,
lib/fog/google/requests/compute/delete_address.rb,
lib/fog/google/requests/compute/delete_network.rb,
lib/fog/google/requests/compute/insert_address.rb,
lib/fog/google/requests/compute/insert_network.rb,
lib/fog/google/requests/compute/list_addresses.rb,
lib/fog/google/requests/compute/list_firewalls.rb,
lib/fog/google/requests/compute/list_snapshots.rb,
lib/fog/google/requests/compute/delete_firewall.rb,
lib/fog/google/requests/compute/delete_snapshot.rb,
lib/fog/google/requests/compute/insert_firewall.rb,
lib/fog/google/requests/compute/insert_snapshot.rb,
lib/fog/google/requests/compute/get_machine_type.rb,
lib/fog/google/requests/compute/get_zone_operation.rb,
lib/fog/google/requests/compute/list_machine_types.rb,
lib/fog/google/requests/compute/get_global_operation.rb,
lib/fog/google/requests/compute/list_zone_operations.rb,
lib/fog/google/requests/compute/delete_zone_operation.rb,
lib/fog/google/requests/compute/list_global_operations.rb,
lib/fog/google/requests/compute/delete_global_operation.rb

Instance Attribute Summary

Attributes included from Shared

#api_version, #project

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Shared

#backoff_if_unfound, #build_excon_response, #find_zone, #shared_initialize

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



133
134
135
# File 'lib/fog/google/compute.rb', line 133

def initialize(options={})
  shared_initialize(options)
end

Class Method Details

.data(api_version) ⇒ Object



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
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
# File 'lib/fog/google/compute.rb', line 142

def self.data(api_version)
  @data ||= Hash.new do |hash, key|
    case key
    when 'google'
      hash[key] = {
        :images => {
          "centos-6-2-v20120621" => {
            "kind" => "compute#image",
            "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/google/global/images/centos-6-2-v20120621",
            "id" => "12920641029336858796",
            "creationTimestamp" => "2012-06-21T22:59:56.392-07:00",
            "name" => "centos-6-2-v20120621",
            "description" => "CentOS 6.2; Created Thu, 21 Jun 2012 14:22:21 +0000",
            "sourceType" => "RAW",
            "rawDisk" => {
              "containerType" => "TAR",
              "source" => ""
            },
            "deprecated" => {
              "state" => "DELETED",
              "replacement" => "https://www.googleapis.com/compute/#{api_version}/projects/google/global/images/centos-6-v20130104"
            },
            "status" => "READY"
          },
          "centos-6-v20120912" => {
            "kind" => "compute#image",
            "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/google/global/images/centos-6-v20120912",
            "id" => "12994279803511049620",
            "creationTimestamp" => "2012-09-18T08:52:47.584-07:00",
            "name" => "centos-6-v20120912",
            "description" => "CentOS 6; Created Wed, 12 Sep 2012 00:00:00 +0000",
            "sourceType" => "RAW",
            "rawDisk" => {
              "containerType" => "TAR",
              "source" => ""
            },
            "deprecated" => {
              "state" => "DEPRECATED",
              "replacement" => "https://www.googleapis.com/compute/#{api_version}/projects/google/global/images/centos-6-v20130104"
            },
            "status" => "READY"
          },
          "centos-6-v20121106" => {
            "kind" => "compute#image",
            "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/google/global/images/centos-6-v20121106",
            "id" => "13037720516378381209",
            "creationTimestamp" => "2012-11-09T11:40:41.079-08:00",
            "name" => "centos-6-v20121106",
            "description" => "SCSI-enabled CentOS 6; Created Tue, 06 Nov 2012 00:00:00 +0000",
            "sourceType" => "RAW",
            "rawDisk" => {
              "containerType" => "TAR",
              "source" => ""
            },
            "status" => "READY"
          }
        }
      }
    when 'debian-cloud'
      hash[key] = {
        :images => {
          "debian-6-squeeze-v20130816" => {
            "kind" => "compute#image",
            "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/debian-cloud/global/images/debian-6-squeeze-v20130816",
            "id" => "14841592146580482051",
            "creationTimestamp" => "2013-09-04T13:21:53.292-07:00",
            "name" => "debian-6-squeeze-v20130816",
            "description" => "Debian GNU/Linux 6.0.7 (squeeze) built on 2013-08-16",
            "sourceType" => "RAW",
            "rawDisk" => {
              "containerType" => "TAR",
              "source" => ""
            },
            "status" => "READY"
          },
          "debian-7-wheezy-v20130816" => {
            "kind" => "compute#image",
            "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/debian-cloud/global/images/debian-7-wheezy-v20130816",
            "id" => "4213305957435180899",
            "creationTimestamp" => "2013-09-04T13:24:30.479-07:00",
            "name" => "debian-7-wheezy-v20130816",
            "description" => "Debian GNU/Linux 7.1 (wheezy) built on 2013-08-16",
            "sourceType" => "RAW",
            "rawDisk" => {
              "containerType" => "TAR",
              "source" => ""
            },
            "status" => "READY"
          },
          "debian-7-wheezy-v20131014" => {
            "kind" => "compute#image",
            "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/debian-cloud/global/images/debian-7-wheezy-v20131014",
            "id" => "4213305957435180899",
            "creationTimestamp" => "2013-09-04T13:24:30.479-07:00",
            "name" => "debian-7-wheezy-v20131014",
            "description" => "Debian GNU/Linux 7.1 (wheezy) built on 2013-10-14",
            "sourceType" => "RAW",
            "rawDisk" => {
              "containerType" => "TAR",
              "source" => ""
            },
            "status" => "READY"
          },
          "debian-7-wheezy-v20131120" => {
            "kind" => "compute#image",
            "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/debian-cloud/global/images/debian-7-wheezy-v20131120",
            "id" => "17312518942796567788",
            "creationTimestamp" => "2013-11-25T15:17:00.436-08:00",
            "name" => "debian-7-wheezy-v20131120",
            "description" => "Debian GNU/Linux 7.2 (wheezy) built on 2013-11-20",
            "sourceType" => "RAW",
            "rawDisk" => {
              "containerType" => "TAR",
              "source" => ""
            },
            "status" => "READY",
            "archiveSizeBytes" => "341857472"
          }
        }
      }
    when 'centos-cloud'
      hash[key] = {
        :images => {
          "centos-6-v20130813" => {
            "kind" => "compute#image",
            "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/centos-cloud/global/images/centos-6-v20130813",
            "id" => "4670523370938782739",
            "creationTimestamp" => "2013-08-19T11:56:47.004-07:00",
            "name" => "centos-6-v20130813",
            "description" => "SCSI-enabled CentOS 6; Created Tue, 13 Aug 2013 00:00:00 +0000",
            "sourceType" => "RAW",
            "rawDisk" => {
              "containerType" => "TAR",
              "source" => ""
            },
            "status" => "READY"
          }
        }
      }
    else
      hash[key] = {
        :servers => {
          "fog-1" => {
            "kind" => "compute#instance",
            "id" => "1361932147851415727",
            "creationTimestamp" => "2013-09-26T04:55:43.881-07:00",
            "zone" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a",
            "status" => "RUNNING",
            "name" => "fog-1380196541",
            "tags" => { "fingerprint" => "42WmSpB8rSM=" },
            "machineType" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a/machineTypes/n1-standard-1",
            "canIpForward" => false,
            "networkInterfaces" => [
              {
                "network" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/global/networks/default",
                "networkIP" => "10.240.121.54",
                "name" => "nic0",
                "accessConfigs" => [
                  {
                    "kind" => "compute#accessConfig",
                    "type" => "ONE_TO_ONE_NAT",
                    "name" => "External NAT",
                    "natIP" => "108.59.81.28"
                  }
                ]
              }
            ],
            "disks" => [
              {
                "kind" => "compute#attachedDisk",
                "index" => 0,
                "type" => "PERSISTENT",
                "mode" => "READ_WRITE",
                "source" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a/disks/fog-1",
                "deviceName" => "persistent-disk-0",
                "boot" => true
              }
            ],
            "metadata" => {
              "kind" => "compute#metadata",
              "fingerprint" => "5_hasd_gC3E=",
              "items" => [
                {
                  "key" => "sshKeys",
                  "value" => "sysadmin:ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEA1zc7mx+0H8Roywet/L0aVX6MUdkDfzd/17kZhprAbpUXYOILv9AG4lIzQk6xGxDIltghytjfVGme/4A42Sb0Z9LN0pxB4KnWTNoOSHPJtp6jbXpq6PdN9r3Z5NKQg0A/Tfw7gt2N0GDsj6vpK8VbHHdW78JAVUxql18ootJxjaksdocsiHNK8iA6/v9qiLRhX3fOgtK7KpxxdZxLRzFg9vkp8jcGISgpZt27kOgXWhR5YLhi8pRJookzphO5O4yhflgoHoAE65XkfrsRCe0HU5QTbY2jH88rBVkq0KVlZh/lEsuwfmG4d77kEqaCGGro+j1Wrvo2K3DSQ+rEcvPp2CYRUySjhaeLF18UzQLtxNeoN14QOYqlm9ITdkCnmq5w4Wn007MjSOFp8LEq2RekrnddGXjg1/vgmXtaVSGzJAlXwtVfZor3dTRmF0JCpr7DsiupBaDFtLUlGFFlSKmPDVMPOOB5wajexmcvSp2Vu4U3yP8Lai/9/ZxMdsGPhpdCsWVL83B5tF4oYj1HVIycbYIxIIfFqOxZcCru3CMfe9jmzKgKLv2UtkfOS8jpS/Os2gAiB3wPweH3agvtwYAYBVMDwt5cnrhgHYWoOz7ABD8KgmCrD7Y9HikiCqIUNkgUFd9YmjcYi5FkU5rFXIawN7efs341lsdf923lsdf923fs= johndoe@acme"
                }
              ]
            },
            "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a/instances/fog-1380196541"
          }
        },
        :zones => {
          "europe-west1-a" => {
            "kind" => "compute#zone",
            "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/europe-west1-a",
            "id" => "10419676573632995924",
            "creationTimestamp" => "2013-09-26T02:56:13.115-07:00",
            "name" => "europe-west1-a",
            "description" => "europe-west1-a",
            "status" => "UP",
            "maintenanceWindows" => [
              {
                "name" => "2014-01-18-planned-outage",
                "description" => "maintenance zone",
                "beginTime" => "2014-01-18T12:00:00.000-08:00",
                "endTime" => "2014-02-02T12:00:00.000-08:00"
              }
            ],
            "quotas" => [
              {"metric" => "INSTANCES", "limit" => 16.0, "usage" => 0.0},
              {"metric" => "CPUS", "limit" => 24.0, "usage" => 0.0},
              {"metric" => "DISKS", "limit" => 16.0, "usage" => 0.0},
              {"metric" => "DISKS_TOTAL_GB", "limit" => 2048.0, "usage" => 0.0}
            ],
            "region" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/regions/europe-west1"
          },
          "us-central1-a" => {
            "kind" => "compute#zone",
            "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a",
            "id" => "6562457277909136262",
            "creationTimestamp" => "2013-09-26T02:56:13.116-07:00",
            "name" => "us-central1-a",
            "description" => "us-central1-a",
            "status" => "UP",
            "maintenanceWindows" => nil,
            "quotas" => [
              {"metric" => "INSTANCES", "limit" => 16.0, "usage" => 1.0},
              {"metric" => "CPUS", "limit" => 24.0, "usage" => 1.0},
              {"metric" => "DISKS", "limit" => 16.0, "usage" => 0.0},
              {"metric" => "DISKS_TOTAL_GB", "limit" => 2048.0, "usage" => 0.0}
            ],
            "region" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/regions/us-central1"
          },
          "us-central1-b" => {
            "kind" => "compute#zone",
            "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-b",
            "id" => "8701502109626061015",
            "creationTimestamp" => "2013-09-26T02:56:13.124-07:00",
            "name" => "us-central1-b",
            "description" => "us-central1-b",
            "status" => "UP",
            "maintenanceWindows" => [{"name" => "2013-10-26-planned-outage",
              "description" => "maintenance zone",
            "beginTime" => "2013-10-26T12:00:00.000-07:00",
            "endTime" => "2013-11-10T12:00:00.000-08:00"}],
            "quotas" => [
              {"metric" => "INSTANCES", "limit" => 16.0, "usage" => 0.0},
              {"metric" => "CPUS", "limit" => 24.0, "usage" => 0.0},
              {"metric" => "DISKS", "limit" => 16.0, "usage" => 0.0},
              {"metric" => "DISKS_TOTAL_GB", "limit" => 2048.0, "usage" => 0.0}
            ],
            "region" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/regions/us-central1"
          },
          "us-central2-a" => {
            "kind" => "compute#zone",
            "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central2-a",
            "id" => "13611654493253680292",
            "creationTimestamp" => "2013-09-26T02:56:13.125-07:00",
            "name" => "us-central2-a",
            "description" => "us-central2-a",
            "status" => "UP",
            "maintenanceWindows" => [
              {
                "name" => "2013-10-12-planned-outage",
                "description" => "maintenance zone",
                "beginTime" => "2013-10-12T12:00:00.000-07:00",
                "endTime" => "2013-10-27T12:00:00.000-07:00"
              }
            ],
            "quotas" => [
              {"metric" => "INSTANCES", "limit" => 16.0, "usage" => 0.0},
              {"metric" => "CPUS", "limit" => 24.0, "usage" => 0.0},
              {"metric" => "DISKS", "limit" => 16.0, "usage" => 0.0},
              {"metric" => "DISKS_TOTAL_GB", "limit" => 2048.0, "usage" => 0.0}
            ],
            "region" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/regions/us-central2"
          }
        },
        :machine_types => Hash.new do |machine_types_hash, zone|
          machine_types_hash[zone] = {
            "f1-micro" => {
              "kind" => "compute#machineType",
              "id" => "4618642685664990776",
              "creationTimestamp" => "2013-04-25T13:32:49.088-07:00",
              "name" => "f1-micro",
              "description" => "1 vCPU (shared physical core) and 0.6 GB RAM",
              "guestCpus" => 1,
              "memoryMb" => 614,
              "imageSpaceGb" => 0,
              "maximumPersistentDisks" => 4,
              "maximumPersistentDisksSizeGb" => "3072",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/f1-micro"
            },
            "g1-small" => {
              "kind" => "compute#machineType",
              "id" => "7224129552184485774",
              "creationTimestamp" => "2013-04-25T13:32:45.550-07:00",
              "name" => "g1-small",
              "description" => "1 vCPU (shared physical core) and 1.7 GB RAM",
              "guestCpus" => 1,
              "memoryMb" => 1740,
              "imageSpaceGb" => 0,
              "maximumPersistentDisks" => 4,
              "maximumPersistentDisksSizeGb" => "3072",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/g1-small"
            },
            "n1-highcpu-2" => {
              "kind" => "compute#machineType",
              "id" => "13043554592196512955",
              "creationTimestamp" => "2012-11-16T11:46:10.572-08:00",
              "name" => "n1-highcpu-2",
              "description" => "2 vCPUs, 1.8 GB RAM",
              "guestCpus" => 2,
              "memoryMb" => 1843,
              "imageSpaceGb" => 10,
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highcpu-2"
            },
            "n1-highcpu-2-d" => {
              "kind" => "compute#machineType",
              "id" => "13043555176034896271",
              "creationTimestamp" => "2012-11-16T11:47:07.825-08:00",
              "name" => "n1-highcpu-2-d",
              "description" => "2 vCPUs, 1.8 GB RAM, 1 scratch disk (870 GB)",
              "guestCpus" => 2,
              "memoryMb" => 1843,
              "imageSpaceGb" => 10,
              "scratchDisks" => [
               {
                "diskGb" => 870
               }
              ],
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highcpu-2-d"
            },
            "n1-highcpu-4" => {
              "kind" => "compute#machineType",
              "id" => "13043555705736970382",
              "creationTimestamp" => "2012-11-16T11:48:06.087-08:00",
              "name" => "n1-highcpu-4",
              "description" => "4 vCPUs, 3.6 GB RAM",
              "guestCpus" => 4,
              "memoryMb" => 3686,
              "imageSpaceGb" => 10,
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highcpu-4"
            },
            "n1-highcpu-4-d" => {
              "kind" => "compute#machineType",
              "id" => "13043556330284250611",
              "creationTimestamp" => "2012-11-16T11:49:07.563-08:00",
              "name" => "n1-highcpu-4-d",
              "description" => "4 vCPUS, 3.6 GB RAM, 1 scratch disk (1770 GB)",
              "guestCpus" => 4,
              "memoryMb" => 3686,
              "imageSpaceGb" => 10,
              "scratchDisks" => [
               {
                "diskGb" => 1770
               }
              ],
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highcpu-4-d"
            },
            "n1-highcpu-8" => {
              "kind" => "compute#machineType",
              "id" => "13043556949665240937",
              "creationTimestamp" => "2012-11-16T11:50:15.128-08:00",
              "name" => "n1-highcpu-8",
              "description" => "8 vCPUs, 7.2 GB RAM",
              "guestCpus" => 8,
              "memoryMb" => 7373,
              "imageSpaceGb" => 10,
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highcpu-8"
            },
            "n1-highcpu-8-d" => {
              "kind" => "compute#machineType",
              "id" => "13043557458004959701",
              "creationTimestamp" => "2012-11-16T11:51:04.549-08:00",
              "name" => "n1-highcpu-8-d",
              "description" => "8 vCPUS, 7.2 GB RAM, 2 scratch disks (1770 GB, 1770 GB)",
              "guestCpus" => 8,
              "memoryMb" => 7373,
              "imageSpaceGb" => 10,
              "scratchDisks" => [
               {
                "diskGb" => 1770
               },
               {
                "diskGb" => 1770
               }
              ],
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highcpu-8-d"
            },
            "n1-highmem-2" => {
              "kind" => "compute#machineType",
              "id" => "13043551079318055993",
              "creationTimestamp" => "2012-11-16T11:40:06.129-08:00",
              "name" => "n1-highmem-2",
              "description" => "2 vCPUs, 13 GB RAM",
              "guestCpus" => 2,
              "memoryMb" => 13312,
              "imageSpaceGb" => 10,
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highmem-2"
            },
            "n1-highmem-2-d" => {
              "kind" => "compute#machineType",
              "id" => "13043551625558644085",
              "creationTimestamp" => "2012-11-16T11:40:59.630-08:00",
              "name" => "n1-highmem-2-d",
              "description" => "2 vCPUs, 13 GB RAM, 1 scratch disk (870 GB)",
              "guestCpus" => 2,
              "memoryMb" => 13312,
              "imageSpaceGb" => 10,
              "scratchDisks" => [
               {
                "diskGb" => 870
               }
              ],
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highmem-2-d"
            },
            "n1-highmem-4" => {
              "kind" => "compute#machineType",
              "id" => "13043552263604939569",
              "creationTimestamp" => "2012-11-16T11:42:08.983-08:00",
              "name" => "n1-highmem-4",
              "description" => "4 vCPUs, 26 GB RAM",
              "guestCpus" => 4,
              "memoryMb" => 26624,
              "imageSpaceGb" => 10,
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highmem-4"
            },
            "n1-highmem-4-d" => {
              "kind" => "compute#machineType",
              "id" => "13043552953632709737",
              "creationTimestamp" => "2012-11-16T11:43:17.400-08:00",
              "name" => "n1-highmem-4-d",
              "description" => "4 vCPUs, 26 GB RAM, 1 scratch disk (1770 GB)",
              "guestCpus" => 4,
              "memoryMb" => 26624,
              "imageSpaceGb" => 10,
              "scratchDisks" => [
               {
                "diskGb" => 1770
               }
              ],
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highmem-4-d"
            },
            "n1-highmem-8" => {
              "kind" => "compute#machineType",
              "id" => "13043553584275586275",
              "creationTimestamp" => "2012-11-16T11:44:25.985-08:00",
              "name" => "n1-highmem-8",
              "description" => "8 vCPUs, 52 GB RAM",
              "guestCpus" => 8,
              "memoryMb" => 53248,
              "imageSpaceGb" => 10,
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highmem-8"
            },
            "n1-highmem-8-d" => {
              "kind" => "compute#machineType",
              "id" => "13043554021673472746",
              "creationTimestamp" => "2012-11-16T11:45:08.195-08:00",
              "name" => "n1-highmem-8-d",
              "description" => "8 vCPUs, 52 GB RAM, 2 scratch disks (1770 GB, 1770 GB)",
              "guestCpus" => 8,
              "memoryMb" => 53248,
              "imageSpaceGb" => 10,
              "scratchDisks" => [
               {
                "diskGb" => 1770
               },
               {
                "diskGb" => 1770
               }
              ],
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-highmem-8-d"
            },
            "n1-standard-1" => {
              "kind" => "compute#machineType",
              "id" => "12907738072351752276",
              "creationTimestamp" => "2012-06-07T13:48:14.670-07:00",
              "name" => "n1-standard-1",
              "description" => "1 vCPU, 3.75 GB RAM",
              "guestCpus" => 1,
              "memoryMb" => 3840,
              "imageSpaceGb" => 10,
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-standard-1"
            },
            "n1-standard-1-d" => {
              "kind" => "compute#machineType",
              "id" => "12908559201265214706",
              "creationTimestamp" => "2012-06-07T13:48:34.258-07:00",
              "name" => "n1-standard-1-d",
              "description" => "1 vCPU, 3.75 GB RAM, 1 scratch disk (420 GB)",
              "guestCpus" => 1,
              "memoryMb" => 3840,
              "imageSpaceGb" => 10,
              "scratchDisks" => [
               {
                "diskGb" => 420
               }
              ],
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-standard-1-d"
            },
            "n1-standard-2" => {
              "kind" => "compute#machineType",
              "id" => "12908559320241551184",
              "creationTimestamp" => "2012-06-07T13:48:56.867-07:00",
              "name" => "n1-standard-2",
              "description" => "2 vCPUs, 7.5 GB RAM",
              "guestCpus" => 2,
              "memoryMb" => 7680,
              "imageSpaceGb" => 10,
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-standard-2"
            },
            "n1-standard-2-d" => {
              "kind" => "compute#machineType",
              "id" => "12908559582417967837",
              "creationTimestamp" => "2012-06-07T13:49:19.448-07:00",
              "name" => "n1-standard-2-d",
              "description" => "2 vCPUs, 7.5 GB RAM, 1 scratch disk (870 GB)",
              "guestCpus" => 2,
              "memoryMb" => 7680,
              "imageSpaceGb" => 10,
              "scratchDisks" => [
               {
                "diskGb" => 870
               }
              ],
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-standard-2-d"
            },
            "n1-standard-4" => {
              "kind" => "compute#machineType",
              "id" => "12908559692070444049",
              "creationTimestamp" => "2012-06-07T13:49:40.050-07:00",
              "name" => "n1-standard-4",
              "description" => "4 vCPUs, 15 GB RAM",
              "guestCpus" => 4,
              "memoryMb" => 15360,
              "imageSpaceGb" => 10,
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-standard-4"
            },
            "n1-standard-4-d" => {
              "kind" => "compute#machineType",
              "id" => "12908559991903153608",
              "creationTimestamp" => "2012-06-07T13:50:05.677-07:00",
              "name" => "n1-standard-4-d",
              "description" => "4 vCPUs, 15 GB RAM, 1 scratch disk (1770 GB)",
              "guestCpus" => 4,
              "memoryMb" => 15360,
              "imageSpaceGb" => 10,
              "scratchDisks" => [
               {
                "diskGb" => 1770
               }
              ],
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-standard-4-d"
            },
            "n1-standard-8" => {
              "kind" => "compute#machineType",
              "id" => "12908560197989714867",
              "creationTimestamp" => "2012-06-07T13:50:42.334-07:00",
              "name" => "n1-standard-8",
              "description" => "8 vCPUs, 30 GB RAM",
              "guestCpus" => 8,
              "memoryMb" => 30720,
              "imageSpaceGb" => 10,
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-standard-8"
            },
            "n1-standard-8-d" => {
              "kind" => "compute#machineType",
              "id" => "12908560709887590691",
              "creationTimestamp" => "2012-06-07T13:51:19.936-07:00",
              "name" => "n1-standard-8-d",
              "description" => "8 vCPUs, 30 GB RAM, 2 scratch disks (1770 GB, 1770 GB)",
              "guestCpus" => 8,
              "memoryMb" => 30720,
              "imageSpaceGb" => 10,
              "scratchDisks" => [
               {
                "diskGb" => 1770
               },
               {
                "diskGb" => 1770
               }
              ],
              "maximumPersistentDisks" => 16,
              "maximumPersistentDisksSizeGb" => "10240",
              "zone" => zone,
              "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/#{zone}/machineTypes/n1-standard-8-d"
             }
          }
        end,
        :images => {},
        :disks => {
          "fog-1" => {
            "kind" => "compute#disk",
            "id" => "3338131294770784461",
            "creationTimestamp" => "2013-12-18T19:47:10.583-08:00",
            "zone" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a",
            "status" => "READY",
            "name" => "fog-1",
            "sizeGb" => "10",
            "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a/disks/fog-1",
            "sourceImage" => "https://www.googleapis.com/compute/#{api_version}/projects/debian-cloud/global/images/debian-7-wheezy-v20131120",
            "sourceImageId" => "17312518942796567788"
          },
          "fog-2" => {
            "kind" => "compute#disk",
            "id" => "3338131294770784462",
            "creationTimestamp" => "2013-12-18T19:47:10.583-08:00",
            "zone" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a",
            "status" => "READY",
            "name" => "fog-2",
            "sizeGb" => "10",
            "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{key}/zones/us-central1-a/disks/fog-1"
          }
        },
        :operations => {}
      }
    end
  end
end

.resetObject



822
823
824
# File 'lib/fog/google/compute.rb', line 822

def self.reset
  @data = nil
end

Instance Method Details

#attach_disk(instance, zone, deviceName) ⇒ Object



6
7
8
# File 'lib/fog/google/requests/compute/attach_disk.rb', line 6

def attach_disk(instance, zone, deviceName)
  Fog::Mock.not_implemented
end

#build_response(params = {}) ⇒ Object



137
138
139
140
# File 'lib/fog/google/compute.rb', line 137

def build_response(params={})
  body = params[:body] || {}
  build_excon_response(body)
end

#data(project = @project) ⇒ Object



826
827
828
# File 'lib/fog/google/compute.rb', line 826

def data(project=@project)
  self.class.data(api_version)[project]
end

#delete_address(address_name, region_name) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/delete_address.rb', line 7

def delete_address(address_name, region_name)
  Fog::Mock.not_implemented
end

#delete_disk(disk_name, zone_name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/google/requests/compute/delete_disk.rb', line 7

def delete_disk(disk_name, zone_name)
  get_disk(disk_name, zone_name)

  operation = self.random_operation
  self.data[:operations][operation] = {
    "kind" => "compute#operation",
    "id" => Fog::Mock.random_numbers(19).to_s,
    "name" => operation,
    "zone" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}",
    "operationType" => "delete",
    "targetLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}/disks/#{disk_name}",
    "targetId" => self.data[:disks][disk_name]["id"],
    "status" => Fog::Compute::Google::Operation::PENDING_STATE,
    "user" => "123456789012-qwertyuiopasdfghjkl1234567890qwe@developer.gserviceaccount.com",
    "progress" => 0,
    "insertTime" => Time.now.iso8601,
    "startTime" => Time.now.iso8601,
    "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}/operations/#{operation}"
  }
  self.data[:disks].delete disk_name

  build_response(:body => self.data[:operations][operation])
end

#delete_firewall(firewall_name) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/delete_firewall.rb', line 7

def delete_firewall(firewall_name)
  Fog::Mock.not_implemented
end

#delete_global_operation(operation) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/delete_global_operation.rb', line 7

def delete_global_operation(operation)
  Fog::Mock.not_implemented
end

#delete_image(image_name) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/delete_image.rb', line 7

def delete_image(image_name)
  Fog::Mock.not_implemented
end

#delete_network(network_name) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/delete_network.rb', line 7

def delete_network(network_name)
  Fog::Mock.not_implemented
end

#delete_server(server_name, zone_name = nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fog/google/requests/compute/delete_server.rb', line 25

def delete_server(server_name, zone_name=nil)
  zone_name = find_zone(zone_name)
  get_server(server_name, zone_name)
  server = self.data[:servers][server_name]
  server["status"] = "STOPPED"
  server["mock-deletionTimestamp"] = Time.now.iso8601

  operation = self.random_operation
  self.data[:operations][operation] = {
    "kind" => "compute#operation",
    "id" => Fog::Mock.random_numbers(19).to_s,
    "name" => operation,
    "zone" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}",
    "operationType" => "delete",
    "targetLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}/instances/#{server_name}",
    "targetId" => self.data[:servers][server_name]["id"],
    "status" => Fog::Compute::Google::Operation::PENDING_STATE,
    "user" => "123456789012-qwertyuiopasdfghjkl1234567890qwe@developer.gserviceaccount.com",
    "progress" => 0,
    "insertTime" => Time.now.iso8601,
    "startTime" => Time.now.iso8601,
    "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}/operations/#{operation}"
  }

  build_response(:body => self.data[:operations][operation])
end

#delete_snapshot(snapshot_name, zone_name) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/delete_snapshot.rb', line 7

def delete_snapshot(snapshot_name, zone_name)
  Fog::Mock.not_implemented
end

#delete_zone_operation(zone, operation) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/delete_zone_operation.rb', line 7

def delete_zone_operation(zone, operation)
  Fog::Mock.not_implemented
end

#detach_disk(instance, zone, deviceName) ⇒ Object



6
7
8
# File 'lib/fog/google/requests/compute/detach_disk.rb', line 6

def detach_disk(instance, zone, deviceName)
  Fog::Mock.not_implemented
end

#get_address(address_name, region_name) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/get_address.rb', line 7

def get_address(address_name, region_name)
  Fog::Mock.not_implemented
end

#get_disk(disk_name, zone_name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/google/requests/compute/get_disk.rb', line 7

def get_disk(disk_name, zone_name)
  disk = self.data[:disks][disk_name]
  if zone_name.start_with? 'http'
    zone_name = zone_name.split('/')[-1]
  end
  get_zone(zone_name)
  zone = self.data[:zones][zone_name]
  if disk.nil? or disk["zone"] != zone["selfLink"]
    return build_response(:body => {
      "error" => {
        "errors" => [
         {
          "domain" => "global",
          "reason" => "notFound",
          "message" => "The resource 'projects/#{@project}/zones/#{zone_name}/disks/#{disk_name}' was not found"
         }
        ],
        "code" => 404,
        "message" => "The resource 'projects/#{@project}/zones/#{zone_name}/disks/#{disk_name}' was not found"
      }
    })
  end

  # TODO transition the disk through the states

  build_response(:body => disk)
end

#get_firewall(firewall_name) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/get_firewall.rb', line 7

def get_firewall(firewall_name)
  Fog::Mock.not_implemented
end

#get_global_operation(operation) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/get_global_operation.rb', line 7

def get_global_operation(operation)
  Fog::Mock.not_implemented
end

#get_image(image_name, project = @project) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fog/google/requests/compute/get_image.rb', line 7

def get_image(image_name, project=@project)
  image = data(project)[:images][image_name] || {
    "error" => {
      "errors" => [
        {
          "domain" => "global",
          "reason" => "invalid",
          "message" => "Invalid value for field 'resource.images': 'https://www.googleapis.com/compute/#{api_version}/projects/#{project}/global/images/#{image_name}'.  Resource was not found."
        }
      ],
      "code" => 400,
      "message" => "Invalid value for field 'resource.images': 'https://www.googleapis.com/compute/#{api_version}/projects/#{project}/global/images/#{image_name}'.  Resource was not found."
    }
  }
  build_response(:body => image)
end

#get_machine_type(machine_type_name, zone_name = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/google/requests/compute/get_machine_type.rb', line 7

def get_machine_type(machine_type_name, zone_name = nil)
  zone_name = self.data[:zones].keys.first if zone_name.nil?
  get_zone(zone_name)
  machine_type = self.data[:machine_types][zone_name][machine_type_name] || {
    "error" => {
     "errors" => [
      {
       "domain" => "global",
       "reason" => "notFound",
       "message" => "The resource 'projects/google/zones/#{zone_name}/machineTypes/#{machine_type_name}' was not found"
      }
     ],
     "code" => 404,
     "message" => "The resource 'projects/google/zones/#{zone_name}/machineTypes/#{machine_type_name}' was not found"
    }
  }
  build_response(:body => machine_type)
end

#get_network(network_name) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/get_network.rb', line 7

def get_network(network_name)
  Fog::Mock.not_implemented
end

#get_server(server_name, zone_name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
53
54
# File 'lib/fog/google/requests/compute/get_server.rb', line 7

def get_server(server_name, zone_name)
  server = self.data[:servers][server_name]
  get_zone(zone_name)
  zone = self.data[:zones][zone_name]
  if server.nil? or server["zone"] != zone["selfLink"]
    return build_response(:body => {
      "error" => {
        "errors" => [
         {
          "domain" => "global",
          "reason" => "notFound",
          "message" => "The resource 'projects/#{@project}/zones/#{zone_name}/instances/#{server_name}' was not found"
         }
        ],
        "code" => 404,
        "message" => "The resource 'projects/#{@project}/zones/#{zone_name}/instances/#{server_name}' was not found"
      }
    })
  end

  # transition the server through the provisioning -> staging -> running states
  creation_time = Time.iso8601(server['creationTimestamp'])
  case server['status']
  when 'PROVISIONING'
    if Time.now - creation_time > Fog::Mock.delay/2
      server['status'] = 'STAGING'
    end
  when 'STAGING'
    if Time.now - creation_time > Fog::Mock.delay
      server['status'] = 'RUNNING'
    end
  when 'STOPPED'
    if server['mock-deletionTimestamp']
      # stopped -> terminated
      if Time.now - Time.iso8601(server['mock-deletionTimestamp']) > Fog::Mock.delay
        server['status'] = 'TERMINATED'
      end
    else
      # TODO stopped -> provisioning
    end
  when 'TERMINATED'
    if Time.now - Time.iso8601(server['mock-deletionTimestamp']) > Fog::Mock.delay
      self.data[:servers][server_name] = nil
    end
  end

  build_response(:body => server)
end

#get_snapshot(snap_name) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/get_snapshot.rb', line 7

def get_snapshot(snap_name)
  Fog::Mock.not_implemented
end

#get_zone(zone_name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fog/google/requests/compute/get_zone.rb', line 7

def get_zone(zone_name)
  zone = self.data[:zones][zone_name] || {
    "error" => {
      "errors" => [
       {
        "domain" => "global",
        "reason" => "notFound",
        "message" => "The resource 'projects/#{project}/zones/#{zone_name}' was not found"
       }
      ],
      "code" => 404,
      "message" => "The resource 'projects/#{project}/zones/#{zone_name}' was not found"
    }
  }
  build_response(:body => zone)
end

#get_zone_operation(zone_name, operation) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/google/requests/compute/get_zone_operation.rb', line 7

def get_zone_operation(zone_name, operation)
  operation = self.data[:operations][operation]
  if operation
    case operation["status"]
    when Fog::Compute::Google::Operation::PENDING_STATE
      operation["status"] = Fog::Compute::Google::Operation::RUNNING_STATE
      operation["progress"] = 50
    else
      operation["status"] = Fog::Compute::Google::Operation::DONE_STATE
      operation["progress"] = 100
    end
  else
    operation = {
      "error" => {
        "errors" => [
         {
          "domain" => "global",
          "reason" => "notFound",
          "message" => "The resource 'projects/#{project}/zones/#{zone_name}/operations/#{operation}' was not found"
         }
        ],
        "code" => 404,
        "message" => "The resource 'projects/#{project}/zones/#{zone_name}/operations/#{operation}' was not found"
      }
    }
  end
  build_response(:body => operation)
end

#handle_disks(options, zone_name) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/google/requests/compute/insert_server.rb', line 8

def handle_disks(options, zone_name)
  disks = []
  i = 0
  options.delete('disks').each do |disk|
    disk = Disk.new(disk) unless disk.is_a? Disk
    disks << {
      "kind"=>"compute#attachedDisk",
      "index"=>i,
      "type"=>"PERSISTENT",
      "mode"=>"READ_WRITE",
      "source"=>"https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}/disks/#{disk.name}",
      "deviceName"=>"persistent-disk-#{i}",
      "boot"=>true
    }
    i+=1
  end
  disks
end

#insert_address(address_name, region_name) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/insert_address.rb', line 7

def insert_address(address_name, region_name)
  Fog::Mock.not_implemented
end

#insert_disk(disk_name, zone_name, image_name = nil, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
53
54
55
56
57
58
59
60
61
# File 'lib/fog/google/requests/compute/insert_disk.rb', line 7

def insert_disk(disk_name, zone_name, image_name=nil, options={})
  # check that image and zone exist
  image = nil
  if image_name
    image = images.get(image_name)
    raise ArgumentError.new("Invalid image specified: #{image_name}") unless image
  end
  get_zone(zone_name)

  id = Fog::Mock.random_numbers(19).to_s
  object = {
    "kind" => "compute#disk",
    "id" => id,
    "creationTimestamp" => Time.now.iso8601,
    "zone" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}",
    "status" => "READY",
    "name" => disk_name,
    "sizeGb" => options['sizeGb'] || "10",
    "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}/disks/#{disk_name}"
  }
  if image
    object.merge({
      "sourceImage" => image.self_link,
      "sourceImageId" => image.id
    })
  end
  self.data[:disks][disk_name] = object

  if image
    object.merge!({
      "sourceImage" => image.self_link,
      "sourceImageId" => image.id
    })
  end
  self.data[:disks][disk_name] = object

  operation = self.random_operation
  self.data[:operations][operation] = {
    "kind" => "compute#operation",
    "id" => Fog::Mock.random_numbers(19).to_s,
    "name" => operation,
    "zone" => object["zone"],
    "operationType" => "insert",
    "targetLink" => object["selfLink"],
    "targetId" => id,
    "status" => Fog::Compute::Google::Operation::PENDING_STATE,
    "user" => "123456789012-qwertyuiopasdfghjkl1234567890qwe@developer.gserviceaccount.com",
    "progress" => 0,
    "insertTime" => Time.now.iso8601,
    "startTime" => Time.now.iso8601,
    "selfLink" => "#{object["zone"]}/operations/#{operation}"
  }

  build_response(:body => self.data[:operations][operation])
end

#insert_firewall(firewall_name, source_range = [], allowed = [], network = @default_network, source_tags = []) ⇒ Object



6
7
8
# File 'lib/fog/google/requests/compute/insert_firewall.rb', line 6

def insert_firewall(firewall_name, source_range=[],  allowed=[], network=@default_network, source_tags=[])
  Fog::Mock.not_implemented
end

#insert_image(image_name, options = {}) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/insert_image.rb', line 7

def insert_image(image_name, options={})
  Fog::Mock.not_implemented
end

#insert_network(network_name, ip_range) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/insert_network.rb', line 7

def insert_network(network_name, ip_range)
  Fog::Mock.not_implemented
end

#insert_server(server_name, zone_name, options = {}, *deprecated_args) ⇒ Object



27
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
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
# File 'lib/fog/google/requests/compute/insert_server.rb', line 27

def insert_server(server_name, zone_name, options={}, *deprecated_args)

  # check that zone exists
  get_zone(zone_name)

  if options['disks'].nil? or options['disks'].empty?
    raise ArgumentError.new "Empty value for field 'disks'. Boot disk must be specified"
  end

  id = Fog::Mock.random_numbers(19).to_s
  self.data[:servers][server_name] = {
    "kind" => "compute#instance",
    "id" => id,
    "creationTimestamp" => Time.now.iso8601,
    "zone" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}",
    "status" => "PROVISIONING",
    "name" => server_name,
    "tags" => { "fingerprint" => "42WmSpB8rSM=" },
    "machineType" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}/machineTypes/#{options['machineType']}",
    "canIpForward" => false,
    "networkInterfaces" => [
      {
        "network" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/global/networks/default",
        "networkIP" => Fog::Mock.random_ip,
        "name" => "nic0",
        "accessConfigs" => [
          {
            "kind" => "compute#accessConfig",
            "type" => "ONE_TO_ONE_NAT",
            "name" => "External NAT",
            "natIP" => Fog::Mock.random_ip
          }
        ]
      }
    ],
    "disks" => handle_disks(options, zone_name),
    "metadata" => {
      "kind" => "compute#metadata",
      "fingerprint" => "5_hasd_gC3E=",
      "items" => [
        {
          "key" => "sshKeys",
          "value" => "sysadmin:ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEA1zc7mx+0H8Roywet/L0aVX6MUdkDfzd/17kZhprAbpUXYOILv9AG4lIzQk6xGxDIltghytjfVGme/4A42Sb0Z9LN0pxB4KnWTNoOSHPJtp6jbXpq6PdN9r3Z5NKQg0A/Tfw7gt2N0GDsj6vpK8VbHHdW78JAVUxql18ootJxjaksdocsiHNK8iA6/v9qiLRhX3fOgtK7KpxxdZxLRzFg9vkp8jcGISgpZt27kOgXWhR5YLhi8pRJookzphO5O4yhflgoHoAE65XkfrsRCe0HU5QTbY2jH88rBVkq0KVlZh/lEsuwfmG4d77kEqaCGGro+j1Wrvo2K3DSQ+rEcvPp2CYRUySjhaeLF18UzQLtxNeoN14QOYqlm9ITdkCnmq5w4Wn007MjSOFp8LEq2RekrnddGXjg1/vgmXtaVSGzJAlXwtVfZor3dTRmF0JCpr7DsiupBaDFtLUlGFFlSKmPDVMPOOB5wajexmcvSp2Vu4U3yP8Lai/9/ZxMdsGPhpdCsWVL83B5tF4oYj1HVIycbYIxIIfFqOxZcCru3CMfe9jmzKgKLv2UtkfOS8jpS/Os2gAiB3wPweH3agvtwYAYBVMDwt5cnrhgHYWoOz7ABD8KgmCrD7Y9HikiCqIUNkgUFd9YmjcYi5FkU5rFXIawN7efs341lsdf923lsdf923fs= johndoe@acme"
        }
      ]
    },
    "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}/instances/#{server_name}"
  }

  operation = self.random_operation
  self.data[:operations][operation] = {
    "kind" => "compute#operation",
    "id" => Fog::Mock.random_numbers(19).to_s,
    "name" => operation,
    "zone" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}",
    "operationType" => "insert",
    "targetLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}/instances/#{server_name}",
    "targetId" => id,
    "status" => Fog::Compute::Google::Operation::PENDING_STATE,
    "user" => "123456789012-qwertyuiopasdfghjkl1234567890qwe@developer.gserviceaccount.com",
    "progress" => 0,
    "insertTime" => Time.now.iso8601,
    "startTime" => Time.now.iso8601,
    "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}/operations/#{operation}"
  }

  build_response(:body => self.data[:operations][operation])
end

#insert_snapshot(snap_name) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/insert_snapshot.rb', line 7

def insert_snapshot(snap_name)
  Fog::Mock.not_implemented
end

#list_addresses(region_name) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/list_addresses.rb', line 7

def list_addresses(region_name)
  Fog::Mock.not_implemented
end

#list_disks(zone_name) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/fog/google/requests/compute/list_disks.rb', line 7

def list_disks(zone_name)
  disks = self.data[:disks].values.select{|d| d["zone"].split("/")[-1] == zone_name}
  build_response(:body => {
    "kind" => "compute#diskList",
    "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}/disks",
    "id" => "projects/#{@project}/zones/#{zone_name}/disks",
    "items" => disks
  })
end

#list_firewallsObject



7
8
9
# File 'lib/fog/google/requests/compute/list_firewalls.rb', line 7

def list_firewalls
  Fog::Mock.not_implemented
end

#list_global_operationsObject



7
8
9
# File 'lib/fog/google/requests/compute/list_global_operations.rb', line 7

def list_global_operations
  Fog::Mock.not_implemented
end

#list_images(project = @project) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/fog/google/requests/compute/list_images.rb', line 7

def list_images(project=@project)
  images = data(project)[:images].values
  build_response(:body => {
    "kind" => "compute#imageList",
    "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{project}/global/images",
    "id" => "projects/#{project}/global/images",
    "items" => images
  })
end

#list_machine_types(zone_name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/fog/google/requests/compute/list_machine_types.rb', line 7

def list_machine_types(zone_name)
  get_zone(zone_name)
  machine_types = data[:machine_types][zone_name].values
  build_response(:body => {
    "kind" => "compute#machineTypeList",
    "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}/machineTypes",
    "id" => "projects/high-cistern-340/zones/us-central1-a/machineTypes",
    "items" => machine_types
  })
end

#list_networksObject



7
8
9
# File 'lib/fog/google/requests/compute/list_networks.rb', line 7

def list_networks
  Fog::Mock.not_implemented
end

#list_servers(zone_name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/google/requests/compute/list_servers.rb', line 7

def list_servers(zone_name)
  get_zone(zone_name)
  zone = self.data[:zones][zone_name]
  servers = self.data[:servers].values.select{|s| s["zone"] == zone["selfLink"]}
  build_response(:body => {
    "kind" => "compute#instanceList",
    "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}/instances",
    "id" => "projects/#{@project}/zones/#{zone_name}/instances",
    "items" => servers
  })
end

#list_snapshotsObject



7
8
9
# File 'lib/fog/google/requests/compute/list_snapshots.rb', line 7

def list_snapshots
  Fog::Mock.not_implemented
end

#list_zone_operations(zone) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/list_zone_operations.rb', line 7

def list_zone_operations(zone)
  Fog::Mock.not_implemented
end

#list_zonesObject



7
8
9
10
11
12
13
14
15
# File 'lib/fog/google/requests/compute/list_zones.rb', line 7

def list_zones
  zones = self.data[:zones].values
  build_response(:body => {
    "kind" => "compute#zoneList",
    "selfLink" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones",
    "id" => "projects/#{@project}/zones",
    "items" => zones
  })
end

#random_operationObject



835
836
837
# File 'lib/fog/google/compute.rb', line 835

def random_operation
  "operation-#{Fog::Mock.random_numbers(13)}-#{Fog::Mock.random_hex(13)}-#{Fog::Mock.random_hex(8)}"
end

#reset_dataObject



830
831
832
833
# File 'lib/fog/google/compute.rb', line 830

def reset_data
  # not particularly useful because it deletes zones
  self.class.data(api_version).delete(@project)
end

#set_metadata(instance, zone, metadata = {}) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/set_metadata.rb', line 7

def (instance, zone, ={})
  Fog::Mock.not_implemented
end

#set_tags(instance, zone, tags = []) ⇒ Object



7
8
9
# File 'lib/fog/google/requests/compute/set_tags.rb', line 7

def set_tags(instance, zone, tags=[])
  Fog::Mock.not_implemented
end