Class: Fog::AWS::Mock

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

Class Method Summary collapse

Class Method Details

.availability_zoneObject



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

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

.box_usageObject



74
75
76
# File 'lib/fog/providers/aws.rb', line 74

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

.dns_name_for(ip_address) ⇒ Object



78
79
80
# File 'lib/fog/providers/aws.rb', line 78

def self.dns_name_for(ip_address)
  "ec2-#{ip_address.gsub('.','-')}.compute-1.amazonaws.com"
end

.etagObject



86
87
88
# File 'lib/fog/providers/aws.rb', line 86

def self.etag
  Fog::Mock.random_hex(32)
end

.imageObject



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/fog/providers/aws.rb', line 90

def self.image
  path = []
  (rand(3) + 2).times do
    path << Fog::Mock.random_letters(rand(9) + 8)
  end
  {
    "imageOwnerId"   => Fog::Mock.random_letters(rand(5) + 4),
    "blockDeviceMapping" => [],
    "productCodes"   => [],
    "kernelId"       => kernel_id,
    "ramdiskId"      => ramdisk_id,
    "imageState"     => "available",
    "imageId"        => image_id,
    "architecture"   => "i386",
    "isPublic"       => true,
    "imageLocation"  => path.join('/'),
    "imageType"      => "machine",
    "rootDeviceType" => ["ebs","instance-store"][rand(2)],
    "rootDeviceName" => "/dev/sda1"
  }
end

.image_idObject



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

def self.image_id
  "ami-#{Fog::Mock.random_hex(8)}"
end

.instance_idObject



124
125
126
# File 'lib/fog/providers/aws.rb', line 124

def self.instance_id
  "i-#{Fog::Mock.random_hex(8)}"
end

.ip_addressObject



128
129
130
131
132
133
134
# File 'lib/fog/providers/aws.rb', line 128

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

.kernel_idObject



136
137
138
# File 'lib/fog/providers/aws.rb', line 136

def self.kernel_id
  "aki-#{Fog::Mock.random_hex(8)}"
end

.key_fingerprintObject



116
117
118
119
120
121
122
# File 'lib/fog/providers/aws.rb', line 116

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

.key_materialObject



140
141
142
143
144
145
146
147
148
# File 'lib/fog/providers/aws.rb', line 140

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

.owner_idObject



150
151
152
# File 'lib/fog/providers/aws.rb', line 150

def self.owner_id
  Fog::Mock.random_numbers(12)
end

.private_dns_name_for(ip_address) ⇒ Object



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

def self.private_dns_name_for(ip_address)
  "ip-#{ip_address.gsub('.','-')}.ec2.internal"
end

.ramdisk_idObject



154
155
156
# File 'lib/fog/providers/aws.rb', line 154

def self.ramdisk_id
  "ari-#{Fog::Mock.random_hex(8)}"
end

.request_idObject



158
159
160
161
162
163
164
165
166
# File 'lib/fog/providers/aws.rb', line 158

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

.reservation_idObject



168
169
170
# File 'lib/fog/providers/aws.rb', line 168

def self.reservation_id
  "r-#{Fog::Mock.random_hex(8)}"
end

.snapshot_idObject



172
173
174
# File 'lib/fog/providers/aws.rb', line 172

def self.snapshot_id
  "snap-#{Fog::Mock.random_hex(8)}"
end

.volume_idObject



176
177
178
# File 'lib/fog/providers/aws.rb', line 176

def self.volume_id
  "vol-#{Fog::Mock.random_hex(8)}"
end