Class: Facter::GCE::Metadata Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

CONNECTION_ERRORS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

[
  OpenURI::HTTPError,
  Errno::EHOSTDOWN,
  Errno::EHOSTUNREACH,
  Errno::ENETUNREACH,
  Errno::ECONNABORTED,
  Errno::ECONNREFUSED,
  Errno::ECONNRESET,
  Errno::ETIMEDOUT,
  Timeout::Error,
]
METADATA_URL =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"http://metadata/computeMetadata/v1beta1/?recursive=true&alt=json"

Instance Method Summary collapse

Constructor Details

#initialize(url = METADATA_URL) ⇒ Metadata

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Metadata.



22
23
24
# File 'lib/facter/gce/metadata.rb', line 22

def initialize(url = METADATA_URL)
  @url = url
end

Instance Method Details

#fetchObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/facter/gce/metadata.rb', line 26

def fetch
   do |body|
    # This will only be reached if the confine associated with this class
    # was true which means that JSON was required, but it's a bit
    # questionable that we're relying on JSON being loaded as a side
    # effect of that.
    hash = ::JSON.parse(body)
    transform_metadata!(hash)
    hash
  end
end