Class: Fog::AWS::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/aws.rb

Class Method Summary collapse

Class Method Details

.availability_zoneObject


18
19
20
# File 'lib/fog/aws.rb', line 18

def self.availability_zone
  "us-east-1" << random_selection('abcd', 1)
end

.box_usageObject


22
23
24
# File 'lib/fog/aws.rb', line 22

def self.box_usage
  sprintf("%0.10f", rand / 100).to_f
end

.console_outputObject


26
27
28
# File 'lib/fog/aws.rb', line 26

def self.console_output
  'This is my console. There are many like it, but this one is mine. My console is my best friend. It is my life. I must master it as I master my life. My console, without me, is useless. Without my console, I am useless.'
end

.etagObject


30
31
32
# File 'lib/fog/aws.rb', line 30

def self.etag
  hex(32)
end

.imageObject


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fog/aws.rb', line 34

def self.image
  path = []
  (rand(3) + 2).times do
    path << letters(rand(9) + 8)
  end
  {
    "imageOwnerId"  => letters(rand(5) + 4),
    "productCodes"  => [],
    "kernelId"      => kernel_id,
    "ramdiskId"     => ramdisk_id,
    "imageState"    => "available",
    "imageId"       => image_id,
    "architecture"  => "i386",
    "isPublic"      => true,
    "imageLocation" => path.join('/'),
    "imageType"     => "machine"
  }
end

.image_idObject


53
54
55
# File 'lib/fog/aws.rb', line 53

def self.image_id
  "ami-#{hex(8)}"
end

.instance_idObject


69
70
71
# File 'lib/fog/aws.rb', line 69

def self.instance_id
  "i-#{hex(8)}"
end

.ip_addressObject


73
74
75
76
77
78
79
# File 'lib/fog/aws.rb', line 73

def self.ip_address
  ip = []
  4.times do
    ip << numbers(rand(3) + 1).to_i.to_s # remove leading 0
  end
  ip.join('.')
end

.kernel_idObject


81
82
83
# File 'lib/fog/aws.rb', line 81

def self.kernel_id
  "aki-#{hex(8)}"
end

.key_fingerprintObject


57
58
59
60
61
62
63
# File 'lib/fog/aws.rb', line 57

def self.key_fingerprint
  fingerprint = []
  20.times do
    fingerprint << hex(2)
  end
  fingerprint.join(':')
end

.key_materialObject


85
86
87
88
89
90
91
92
93
# File 'lib/fog/aws.rb', line 85

def self.key_material
  key_material = ['-----BEGIN RSA PRIVATE KEY-----']
  20.times do
    key_material << base64(76)
  end
  key_material << base64(67) + '='
  key_material << '-----END RSA PRIVATE KEY-----'
  key_material.join("\n")
end

.owner_idObject


95
96
97
# File 'lib/fog/aws.rb', line 95

def self.owner_id
  numbers(12)
end

.ramdisk_idObject


99
100
101
# File 'lib/fog/aws.rb', line 99

def self.ramdisk_id
  "ari-#{hex(8)}"
end

.request_idObject


103
104
105
106
107
108
109
110
111
# File 'lib/fog/aws.rb', line 103

def self.request_id
  request_id = []
  request_id << hex(8)
  3.times do
    request_id << hex(4)
  end
  request_id << hex(12)
  request_id.join('-')
end

.reservation_idObject


113
114
115
# File 'lib/fog/aws.rb', line 113

def self.reservation_id
  "r-#{hex(8)}"
end

.snapshot_idObject


117
118
119
# File 'lib/fog/aws.rb', line 117

def self.snapshot_id
  "snap-#{hex(8)}"
end

.volume_idObject


121
122
123
# File 'lib/fog/aws.rb', line 121

def self.volume_id
  "vol-#{hex(8)}"
end