*** /usr/lib/ruby/1.8/facter/ec2.rb 2011-10-02 10:40:43.000000000 +0000 --- /usr/lib/ruby/1.8/facter/ec2.rb.orig 2011-10-02 10:39:47.000000000 +0000 *************** *** 1,8 **** # Changelog: # Original facts - Tim Dysinger # Updated and added can_connect? function - KurtBe - # Fixed can_connect - removed quotes from port number so can_connect works properly - David Lowes - # Made sure that facts are pulled from EC2 using the "latest" api instead of "2008-02-01" API - David Lowes require 'open-uri' require 'timeout' --- 1,6 ---- *************** *** 16,26 **** def metadata(id = "") ! open("http://169.254.169.254/latest/meta-data/#{id||=''}").read. split("\n").each do |o| key = "#{id}#{o.gsub(/\=.*$/, '/')}" if key[-1..-1] != '/' ! value = open("http://169.254.169.254/latest/meta-data/#{key}").read. split("\n") value = value.size>1 ? value : value.first symbol = "ec2_#{key.gsub(/\-|\//, '_')}".to_sym --- 14,24 ---- def metadata(id = "") ! open("http://169.254.169.254/2008-02-01/meta-data/#{id||=''}").read. split("\n").each do |o| key = "#{id}#{o.gsub(/\=.*$/, '/')}" if key[-1..-1] != '/' ! value = open("http://169.254.169.254/2008-02-01/meta-data/#{key}").read. split("\n") value = value.size>1 ? value : value.first symbol = "ec2_#{key.gsub(/\-|\//, '_')}".to_sym *************** *** 31,36 **** end end ! if can_connect?("169.254.169.254",80) metadata end --- 29,35 ---- end end ! if can_connect?("169.254.169.254","80") metadata end +