2009-08-17 01:19:35 -04:00
|
|
|
unless Fog.mocking?
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class EC2
|
|
|
|
|
|
|
|
# Create a new key pair
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * key_name<~String> - Unique name for key pair.
|
|
|
|
#
|
|
|
|
# ==== Returns
|
2009-11-02 21:48:49 -05:00
|
|
|
# * response<~Excon::Response>:
|
2009-08-17 01:19:35 -04:00
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'keyFingerprint'<~String> - SHA-1 digest of DER encoded private key
|
|
|
|
# * 'keyMaterial'<~String> - Unencrypted encoded PEM private key
|
|
|
|
# * 'keyName'<~String> - Name of key
|
|
|
|
# * 'requestId'<~String> - Id of request
|
|
|
|
def create_key_pair(key_name)
|
2010-03-16 01:15:33 -04:00
|
|
|
request(
|
|
|
|
'Action' => 'CreateKeyPair',
|
|
|
|
'KeyName' => key_name,
|
|
|
|
:parser => Fog::Parsers::AWS::EC2::CreateKeyPair.new
|
|
|
|
)
|
2009-08-17 01:19:35 -04:00
|
|
|
end
|
|
|
|
|
2009-07-13 22:14:59 -04:00
|
|
|
end
|
2009-08-17 01:19:35 -04:00
|
|
|
end
|
|
|
|
end
|
2009-07-13 22:14:59 -04:00
|
|
|
|
2009-08-17 01:19:35 -04:00
|
|
|
else
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class EC2
|
|
|
|
|
|
|
|
def create_key_pair(key_name)
|
2009-11-20 14:08:08 -05:00
|
|
|
response = Excon::Response.new
|
2009-08-20 22:25:52 -04:00
|
|
|
unless Fog::AWS::EC2.data[:key_pairs][key_name]
|
2009-08-17 01:19:35 -04:00
|
|
|
response.status = 200
|
|
|
|
data = {
|
|
|
|
'keyFingerprint' => Fog::AWS::Mock.key_fingerprint,
|
|
|
|
'keyMaterial' => Fog::AWS::Mock.key_material,
|
|
|
|
'keyName' => key_name
|
|
|
|
}
|
2009-08-20 22:25:52 -04:00
|
|
|
Fog::AWS::EC2.data[:key_pairs][key_name] = data
|
2009-08-17 01:19:35 -04:00
|
|
|
response.body = {
|
|
|
|
'requestId' => Fog::AWS::Mock.request_id
|
|
|
|
}.merge!(data)
|
|
|
|
else
|
|
|
|
response.status = 400
|
2009-11-20 14:08:08 -05:00
|
|
|
raise(Excon::Errors.status_error({:expects => 200}, response))
|
2009-08-17 01:19:35 -04:00
|
|
|
end
|
|
|
|
response
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2009-07-13 22:14:59 -04:00
|
|
|
end
|
|
|
|
end
|
2009-08-17 01:19:35 -04:00
|
|
|
|
2009-07-13 22:14:59 -04:00
|
|
|
end
|