lib/fog/rackspace/requests/compute_v2/create_keypair.rb in fog-maestrodev-1.19.0.20140212012611 vs lib/fog/rackspace/requests/compute_v2/create_keypair.rb in fog-maestrodev-1.20.0.20140305101305

- old
+ new

@@ -16,15 +16,22 @@ # @raise [Fog::Compute::RackspaceV2::NotFound] # @raise [Fog::Compute::RackspaceV2::BadRequest] # @raise [Fog::Compute::RackspaceV2::InternalServerError] # @raise [Fog::Compute::RackspaceV2::ServiceError] # @see http://docs.rackspace.com/servers/api/v2/cs-devguide/content/CreateKeyPair.html - def create_keypair(key_name, public_key=nil) + def create_keypair(key_name, attributes = nil) + key_data = { 'name' => key_name } + + if attributes.is_a?(String) + Fog::Logger.deprecation "Passing the public key as the 2nd arg is deprecated, please pass a hash of attributes." + key_data.merge!("public_key" => attributes) + end + + key_data.merge!(attributes) if attributes.is_a?(Hash) + data = { - 'keypair' => { - 'name' => key_name - } + 'keypair' => key_data } request( :method => 'POST', :expects => 200, @@ -33,12 +40,16 @@ ) end end class Mock - def create_keypair(key_name, public_key=nil) + def create_keypair(key_name, attributes = nil) # 409 response when already existing raise Fog::Compute::RackspaceV2::ServiceError if not self.data[:keypairs].select { |k| key_name.include? k['keypair']['name'] }.first.nil? + + if attributes.is_a?(String) + Fog::Logger.deprecation "Passing the public key as the 2nd arg is deprecated, please pass a hash of attributes." + end k = self.data[:keypair] k['name'] = key_name self.data[:keypairs] << { 'keypair' => k }