# File lib/fog/ibm/core.rb, line 61 def primary_ip { "type" => 0, "ip" => Fog::IBM::Mock.ip_address, "hostname" => Fog::IBM::Mock.hostname } end
class Fog::IBM::Mock
Public Class Methods
create_address(location_id, offering_id, vlan_id)
click to toggle source
# File lib/fog/ibm/core.rb, line 159 def create_address(location_id, offering_id, vlan_id) # TODO: Figure out vlan handling { "id" => Fog::IBM::Mock.id, "location" => location_id, "offeringId"=> offering_id, "ip" => "", "state" => 0 } end
create_instance(name, image_id, instance_type, location, options)
click to toggle source
# File lib/fog/ibm/core.rb, line 107 def create_instance(name, image_id, instance_type, location, options) { "name" => name, "location" => location, "keyName" => options[:key_name], "primaryIP" => Fog::IBM::Mock.primary_ip, "productCodes" => [], "requestId" => Fog::IBM::Mock.request_id, "imageId" => image_id, "launchTime" => Fog::IBM::Mock.launch_time, "id" => Fog::IBM::Mock.instance_id, "volumes" => [], "isMiniEphemeral" => "false", "instanceType" => instance_type, "diskSize" => "60", "requestName" => "", "secondaryIP" => [], "status" => 1, "software" => [ { "name"=>"SUSE Linux Enterprise Server", "type"=>"OS", "version"=>"11 SP1" } ], "expirationTime"=> Fog::IBM::Mock.expiry_time, "owner" => Fog::IBM::Mock.owner } end
create_volume(name, format, location_id, size, offering_id)
click to toggle source
# File lib/fog/ibm/core.rb, line 135 def create_volume(name, format, location_id, size, offering_id) { "instanceId" => "0", "state" => 1, "size" => size, "offeringId" => offering_id, "ioPrice" => { "rate" => 0.11, "unitOfMeasure" => "CNT", "countryCode" => "897", "effectiveDate" => Fog::IBM::Mock.launch_time, "currencyCode" => "USD", "pricePerQuantity" => 1 }, "owner" => Fog::IBM::Mock.owner, "createdTime" => Fog::IBM::Mock.launch_time, "location" => location_id, "productCodes"=> [], "format" => format, "name" => name, "id" => Fog::IBM::Mock.id, } end
expiry_time()
click to toggle source
1 year from now, in miliseconds since epoch
# File lib/fog/ibm/core.rb, line 83 def expiry_time ((Time.now.tv_sec + 31556926) * 1000).to_i end
hostname()
click to toggle source
# File lib/fog/ibm/core.rb, line 73 def hostname "vhost" + Fog::Mock.random_numbers(3).to_i.to_s + ".fake.compute.ihost.com" end
id()
click to toggle source
# File lib/fog/ibm/core.rb, line 55 def id Fog::Mock.random_numbers(7).to_i.to_s end
Also aliased as: instance_id, request_id
ip_address()
click to toggle source
# File lib/fog/ibm/core.rb, line 65 def 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
key_material()
click to toggle source
# File lib/fog/ibm/core.rb, line 91 def key_material OpenSSL::PKey::RSA.generate(1024) end
launch_time()
click to toggle source
Miliseconds since epoch
# File lib/fog/ibm/core.rb, line 78 def launch_time (Time.now.tv_sec * 1000).to_i end
owner()
click to toggle source
# File lib/fog/ibm/core.rb, line 87 def owner "user" + Fog::Mock.random_numbers(3).to_i.to_s + "@company.com" end
primary_ip()
click to toggle source
private_image(name, description)
click to toggle source
# File lib/fog/ibm/core.rb, line 95 def private_image(name, description) { "name" => name, "createdTime" => Fog::IBM::Mock.launch_time, "productCodes"=> [], "id" => Fog::IBM::Mock.instance_id, "description" => description, "visibility" => "PRIVATE", "state" => 0 } end