Class: Fog::AWS::Mock
- Inherits:
-
Object
- Object
- Fog::AWS::Mock
- Defined in:
- lib/fog/providers/aws.rb
Class Method Summary collapse
- .availability_zone ⇒ Object
- .box_usage ⇒ Object
- .dns_name_for(ip_address) ⇒ Object
- .etag ⇒ Object
- .image ⇒ Object
- .image_id ⇒ Object
- .instance_id ⇒ Object
- .ip_address ⇒ Object
- .kernel_id ⇒ Object
- .key_fingerprint ⇒ Object
- .key_material ⇒ Object
- .owner_id ⇒ Object
- .private_dns_name_for(ip_address) ⇒ Object
- .ramdisk_id ⇒ Object
- .request_id ⇒ Object
- .reservation_id ⇒ Object
- .snapshot_id ⇒ Object
- .volume_id ⇒ Object
Class Method Details
.availability_zone ⇒ Object
68 69 70 |
# File 'lib/fog/providers/aws.rb', line 68 def self.availability_zone "us-east-1" << Fog::Mock.random_selection('abcd', 1) end |
.box_usage ⇒ Object
72 73 74 |
# File 'lib/fog/providers/aws.rb', line 72 def self.box_usage sprintf("%0.10f", rand / 100).to_f end |
.dns_name_for(ip_address) ⇒ Object
76 77 78 |
# File 'lib/fog/providers/aws.rb', line 76 def self.dns_name_for(ip_address) "ec2-#{ip_address.gsub('.','-')}.compute-1.amazonaws.com" end |
.etag ⇒ Object
84 85 86 |
# File 'lib/fog/providers/aws.rb', line 84 def self.etag Fog::Mock.random_hex(32) end |
.image ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/fog/providers/aws.rb', line 88 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_id ⇒ Object
110 111 112 |
# File 'lib/fog/providers/aws.rb', line 110 def self.image_id "ami-#{Fog::Mock.random_hex(8)}" end |
.instance_id ⇒ Object
122 123 124 |
# File 'lib/fog/providers/aws.rb', line 122 def self.instance_id "i-#{Fog::Mock.random_hex(8)}" end |
.ip_address ⇒ Object
126 127 128 129 130 131 132 |
# File 'lib/fog/providers/aws.rb', line 126 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_id ⇒ Object
134 135 136 |
# File 'lib/fog/providers/aws.rb', line 134 def self.kernel_id "aki-#{Fog::Mock.random_hex(8)}" end |
.key_fingerprint ⇒ Object
114 115 116 117 118 119 120 |
# File 'lib/fog/providers/aws.rb', line 114 def self.key_fingerprint fingerprint = [] 20.times do fingerprint << Fog::Mock.random_hex(2) end fingerprint.join(':') end |
.key_material ⇒ Object
138 139 140 141 142 143 144 145 146 |
# File 'lib/fog/providers/aws.rb', line 138 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_id ⇒ Object
148 149 150 |
# File 'lib/fog/providers/aws.rb', line 148 def self.owner_id Fog::Mock.random_numbers(12) end |
.private_dns_name_for(ip_address) ⇒ Object
80 81 82 |
# File 'lib/fog/providers/aws.rb', line 80 def self.private_dns_name_for(ip_address) "ip-#{ip_address.gsub('.','-')}.ec2.internal" end |
.ramdisk_id ⇒ Object
152 153 154 |
# File 'lib/fog/providers/aws.rb', line 152 def self.ramdisk_id "ari-#{Fog::Mock.random_hex(8)}" end |
.request_id ⇒ Object
156 157 158 159 160 161 162 163 164 |
# File 'lib/fog/providers/aws.rb', line 156 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_id ⇒ Object
166 167 168 |
# File 'lib/fog/providers/aws.rb', line 166 def self.reservation_id "r-#{Fog::Mock.random_hex(8)}" end |
.snapshot_id ⇒ Object
170 171 172 |
# File 'lib/fog/providers/aws.rb', line 170 def self.snapshot_id "snap-#{Fog::Mock.random_hex(8)}" end |
.volume_id ⇒ Object
174 175 176 |
# File 'lib/fog/providers/aws.rb', line 174 def self.volume_id "vol-#{Fog::Mock.random_hex(8)}" end |