lib/beaker/hypervisor/aws_sdk.rb in beaker-aws-0.3.0 vs lib/beaker/hypervisor/aws_sdk.rb in beaker-aws-0.4.0

- old
+ new

@@ -21,20 +21,21 @@ @hosts = hosts @options = options @logger = options[:logger] # Get AWS credentials - creds = load_credentials() + creds = options[:use_fog_credentials] ? load_credentials() : Hash.new config = { :access_key_id => creds[:access_key], :secret_access_key => creds[:secret_key], + :session_token => creds[:session_token], :logger => Logger.new($stdout), :log_level => :debug, :log_formatter => AWS::Core::LogFormatter.colored, :max_retries => 12, - } + }.delete_if{ |k,v| v.nil? } AWS.config(config) @ec2 = AWS::EC2.new() test_split_install() end @@ -641,11 +642,11 @@ # @return [@hosts] # @api private def set_hostnames if @options[:use_beaker_hostnames] @hosts.each do |host| - host[:vmhostname] = host[:name] + host[:vmhostname] = host.name if host['platform'] =~ /el-7/ # on el-7 hosts, the hostname command doesn't "stick" randomly host.exec(Command.new("hostnamectl set-hostname #{host.name}")) else next if host['platform'] =~ /netscaler/ @@ -959,12 +960,13 @@ def load_env_credentials(prefix='AWS') provider = AWS::Core::CredentialProviders::ENVProvider.new prefix if provider.set? { - :access_key => provider.access_key_id, - :secret_key => provider.secret_access_key, + :access_key => provider.access_key_id, + :secret_key => provider.secret_access_key, + :session_token => provider.session_token, } else {} end end @@ -979,11 +981,12 @@ raise "You must specify an aws_access_key_id in your .fog file (#{dot_fog}) for ec2 instances!" unless default[:aws_access_key_id] raise "You must specify an aws_secret_access_key in your .fog file (#{dot_fog}) for ec2 instances!" unless default[:aws_secret_access_key] { - :access_key => default[:aws_access_key_id], - :secret_key => default[:aws_secret_access_key], + :access_key => default[:aws_access_key_id], + :secret_key => default[:aws_secret_access_key], + :session_token => default[:aws_session_token], } end # Adds port 8143 to host[:additional_ports] # if master, database and dashboard are not on same instance