module Ohai::Mixin::OCIMetadata
Constants
- CHASSIS_ASSET_TAG_FILE
- OCI_METADATA_ADDR
- OCI_METADATA_URL
Public Instance Methods
fetch_metadata(metadata = "instance")
click to toggle source
Fetch metadata from api
# File lib/ohai/mixin/oci_metadata.rb, line 45 def fetch_metadata(metadata = "instance") response = http_get("#{OCI_METADATA_URL}/#{metadata}") if response.code == "200" json_data = parse_json(response.body) if json_data.nil? logger.warn("Mixin OciMetadata: Metadata response is NOT valid JSON") end json_data else logger.warn("Mixin OciMetadata: Received response code #{response.code} requesting metadata") nil end end
http_get(uri)
click to toggle source
fetch the meta content with a timeout and the required header
# File lib/ohai/mixin/oci_metadata.rb, line 32 def http_get(uri) conn = Net::HTTP.start(OCI_METADATA_ADDR) conn.read_timeout = 6 conn.get( uri, { "Authorization" => "Bearer Oracle", "User-Agent" => "chef-ohai/#{Ohai::VERSION}", } ) end