1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

rackspace keypairs: add some Mocks

This commit is contained in:
Bart Vercammen 2013-07-19 11:07:47 +02:00
parent 54709b8677
commit 8bf52e4342
3 changed files with 50 additions and 6 deletions

View file

@ -8,10 +8,11 @@ module Fog
@@data ||= Hash.new do |hash, key|
hash[key] = begin
#Compute V2
flavor_id = Fog.credentials[:rackspace_flavor_id].to_s ||= Fog::Mock.random_numbers(1)
image_id = Fog.credentials[:rackspace_image_id] ||= Fog::Rackspace::MockData.uuid
flavor_id = Fog.credentials[:rackspace_flavor_id].to_s ||= Fog::Mock.random_numbers(1)
image_id = Fog.credentials[:rackspace_image_id] ||= Fog::Rackspace::MockData.uuid
image_name = Fog::Mock.random_letters(6)
network_id = Fog::Rackspace::MockData.uuid
user_id = Fog::Mock.random_numbers(6).to_s
flavor = {
"OS-FLV-EXT-DATA:ephemeral" => 4,
@ -88,6 +89,22 @@ module Fog
'cidr' => '192.168.0.0/24'
}
key_pair1 = {
'public_key' => "ssh-rsa ".concat(Fog::Mock.random_letters(372)).concat(" Generated by Nova\n"),
'private_key' => "-----BEGIN RSA PRIVATE KEY-----\n".concat(Fog::Mock.random_letters(1635)).concat("\n-----END RSA PRIVATE KEY-----\n"),
'user_id' => user_id,
'name' => Fog::Mock.random_letters(32),
'fingerprint' => "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00"
}
key_pair2 = {
'public_key' => "ssh-rsa ".concat(Fog::Mock.random_letters(372)).concat(" Generated by Nova\n"),
'private_key' => "-----BEGIN RSA PRIVATE KEY-----\n".concat(Fog::Mock.random_letters(1635)).concat("\n-----END RSA PRIVATE KEY-----\n"),
'user_id' => user_id,
'name' => Fog::Mock.random_letters(32),
'fingerprint' => "11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11"
}
#Block Storage
volume_type1_id = Fog::Mock.random_numbers(3).to_s
volume_type2_id = Fog::Mock.random_numbers(3).to_s
@ -106,11 +123,12 @@ module Fog
mock_data = {
#Compute V2
:flavors => Hash.new { |h,k| h[k] = flavor unless k == NOT_FOUND_ID},
:images => Hash.new { |h,k| h[k] = image unless k == NOT_FOUND_ID },
:flavors => Hash.new { |h,k| h[k] = flavor unless k == NOT_FOUND_ID },
:images => Hash.new { |h,k| h[k] = image unless k == NOT_FOUND_ID },
:networks => Hash.new { |h,k| h[k] = network unless k == NOT_FOUND_ID },
:keys => [],
:servers => {},
:keys => [],
:keypairs => [{'keypair' => key_pair1}, {'keypair' => key_pair2}],
:servers => {},
#Block Storage
:volumes => {},

View file

@ -31,6 +31,20 @@ module Fog
)
end
end
class Mock
def create_keypair(name, public_key=nil)
k = self.data[:keypairs][0]
k['keypair']['name'] = name
response = Excon::Response.new
response.status = 200
response.body = k
response
end
end
end
end
end

View file

@ -21,6 +21,18 @@ module Fog
)
end
end
class Mock
def list_keypairs
response = Excon::Response.new
response.status = 200
response.body = {
"keypairs" => self.data[:keypairs]
}
response
end
end
end
end
end