lib/ohai/mixin/ec2_metadata.rb
# Get metadata for a given path and API version
#
# @details
#   Typically, a 200 response is expected for valid metadata.
#   On certain instance types, traversing the provided metadata path
#   produces a 404 for some unknown reason. In that event, return
#   `nil` and continue the run instead of failing it.
Get metadata for a given path and API version
Get metadata for a given path and API version
def metadata_get(id, api_version)
        path = "/#{api_version}/meta-data/#{id}"
        response = http_client.get(path)
        case response.code
        when '200'
          response.body
        when '404'
          Ohai::Log.debug("Encountered 404 response retreiving EC2 metadata path: #{path} ; continuing.")
          nil
        else
          raise "Encountered error retrieving EC2 metadata (#{path} returned #{response.code} response)"
        end
      end
def metadata_get ( id , api_version ) path = "/#{api_version}/meta-data/#{id}" response = http_client . get ( path ) case response . code when '200' response . body when '404' Ohai :: Log . debug ( "Encountered 404 response retreiving EC2 metadata path: #{path} ; continuing." ) nil else raise "Encountered error retrieving EC2 metadata (#{path} returned #{response.code} response)" end end
Get metadata for a given path and API version
Get metadata for a given path and API version
id
<not_specific>
api_version
<not_specific>
details
Typically, a 200 response is expected for valid metadata. On certain instance types, traversing the provided metadata path produces a 404 for some unknown reason. In that event, return `nil` and continue the run instead of failing it.
Typically a 200 response is expected for valid metadata . On certain instance types traversing the provided metadata path produces a 404 for some unknown reason . In that event return ` nil ` and continue the run instead of failing it .