class AWS::InstMD
Constants
- VERSION
Attributes
dynamic[RW]
meta_data[RW]
user_data[RW]
Public Class Methods
method_missing(name, *args, &block)
click to toggle source
# File lib/aws/instmd.rb, line 5 def self.method_missing name, *args, &block @@root ||= InstMD.new @@root.method(name).call(*args, &block) end
new(version='latest', host='169.254.169.254', port='80')
click to toggle source
Amazon, Y U NO trailing slash entries in /, /$version and /$version/dynamic/?? There is waaay too much code here.
# File lib/aws/instmd.rb, line 42 def initialize version='latest', host='169.254.169.254', port='80' http = Net::HTTP.new host, port @meta_data = Treeish.new http, "/#{version}/meta-data/" @user_data = InstMD.query http, "/#{version}/user-data" @dynamic = Hashish.new begin dynamic_stuff = InstMD.query(http, "/#{version}/dynamic/").lines rescue dynamic_stuff = [] end dynamic_stuff.each do |e| e = e.chomp.chomp '/' @dynamic[e] = Treeish.new http, "/#{version}/dynamic/#{e}/" end end
query(http, path)
click to toggle source
# File lib/aws/instmd.rb, line 59 def self.query http, path rep = http.request Net::HTTP::Get.new path unless Net::HTTPOK === rep raise Net::HTTPBadResponse, "#{rep.code} #{path}" end rep.body end
Public Instance Methods
to_hash()
click to toggle source
# File lib/aws/instmd.rb, line 67 def to_hash {:meta_data => @meta_data, :user_data => @user_data, :dynamic => @dynamic} end