lib/fog/joyent/compute.rb in fog-1.38.0 vs lib/fog/joyent/compute.rb in fog-1.39.0

- old
+ new

@@ -4,20 +4,19 @@ module Fog module Compute class Joyent < Fog::Service requires :joyent_username - recognizes :joyent_password recognizes :joyent_url recognizes :joyent_keyname recognizes :joyent_keyfile recognizes :joyent_keydata recognizes :joyent_keyphrase recognizes :joyent_version - secrets :joyent_password, :joyent_keydata, :joyent_keyphrase + secrets :joyent_keydata, :joyent_keyphrase model_path 'fog/joyent/models/compute' request_path 'fog/joyent/requests/compute' request :list_datacenters @@ -98,11 +97,10 @@ self.class.data end def initialize(options = {}) @joyent_username = options[:joyent_username] - @joyent_password = options[:joyent_password] end def request(opts) raise "Not Implemented" end @@ -115,11 +113,11 @@ def initialize(options = {}) @connection_options = options[:connection_options] || {} @persistent = options[:persistent] || false @joyent_url = options[:joyent_url] || 'https://us-sw-1.api.joyentcloud.com' - @joyent_version = options[:joyent_version] || '~6.5' + @joyent_version = options[:joyent_version] || '~7' @joyent_username = options[:joyent_username] unless @joyent_username raise ArgumentError, "options[:joyent_username] required" end @@ -135,11 +133,10 @@ @joyent_keyphrase = options[:joyent_keyphrase] @key_manager = Net::SSH::Authentication::KeyManager.new(nil, { :keys_only => true, :passphrase => @joyent_keyphrase }) - @header_method = method(:header_for_signature_auth) if options[:joyent_keyfile] if File.exist?(options[:joyent_keyfile]) @joyent_keyfile = options[:joyent_keyfile] @key_manager.add(@joyent_keyfile) @@ -152,15 +149,12 @@ else @joyent_keydata = options[:joyent_keydata] @key_manager.add_key_data(@joyent_keydata) end end - elsif options[:joyent_password] - @joyent_password = options[:joyent_password] - @header_method = method(:header_for_basic_auth) else - raise ArgumentError, "Must provide either a joyent_password or joyent_keyname and joyent_keyfile pair" + raise ArgumentError, "Must provide a joyent_keyname and joyent_keyfile pair" end @connection = Fog::XML::Connection.new( @joyent_url, @persistent, @@ -171,11 +165,11 @@ def request(opts = {}) opts[:headers] = { "X-Api-Version" => @joyent_version, "Content-Type" => "application/json", "Accept" => "application/json" - }.merge(opts[:headers] || {}).merge(@header_method.call) + }.merge(opts[:headers] || {}).merge(header_for_signature_auth) if opts[:body] opts[:body] = Fog::JSON.encode(opts[:body]) end @@ -195,15 +189,9 @@ private def json_decode(body) parsed = Fog::JSON.decode(body) decode_time_attrs(parsed) - end - - def header_for_basic_auth - { - "Authorization" => "Basic #{Base64.encode64("#{@joyent_username}:#{@joyent_password}").delete("\r\n")}" - } end def header_for_signature_auth date = Time.now.utc.httpdate