Class: Pec2::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/pec2/metadata.rb

Class Method Summary collapse

Class Method Details

.get_documentObject



6
7
8
# File 'lib/pec2/metadata.rb', line 6

def get_document
  JSON.parse(('/latest/dynamic/instance-identity/document/'))
end

.get_metadata(path) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/pec2/metadata.rb', line 10

def (path)
  begin
    result = {}
    ::Timeout.timeout(TIME_OUT) {
      body = open('http://169.254.169.254' + path).read
      return body
    }
    return result
  rescue Timeout::Error => e
    raise "not EC2 instance"
  end
end