31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/ohai/mixin/do_metadata.rb', line 31
def fetch_metadata
uri = DO_METADATA_URL.to_s
response = http_client.get(uri)
case response.code
when "200"
parser = FFI_Yajl::Parser.new
parser.parse(response.body)
when "404"
logger.trace("Mixin DOMetadata: Encountered 404 response retrieving Digital Ocean metadata: #{uri} ; continuing.")
{}
else
raise "Mixin DOMetadata: Encountered error retrieving Digital Ocean metadata (#{uri} returned #{response.code} response)"
end
end
|