Module: Ohai::Mixin::OCIMetadata
- Defined in:
- lib/ohai/mixin/oci_metadata.rb
Constant Summary collapse
- OCI_METADATA_ADDR =
"169.254.169.254"
- OCI_METADATA_URL =
"/opc/v2"
- CHASSIS_ASSET_TAG_FILE =
"/sys/devices/virtual/dmi/id/chassis_asset_tag"
Instance Method Summary collapse
-
#fetch_metadata(metadata = "instance") ⇒ Object
Fetch metadata from api.
-
#http_get(uri) ⇒ Object
fetch the meta content with a timeout and the required header.
Instance Method Details
#fetch_metadata(metadata = "instance") ⇒ Object
Fetch metadata from api
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ohai/mixin/oci_metadata.rb', line 45 def ( = "instance") response = http_get("#{OCI_METADATA_URL}/#{}") 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) ⇒ Object
fetch the meta content with a timeout and the required header
32 33 34 35 36 37 38 39 40 41 42 |
# 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 |