Class: RightScale::MetadataSources::FileMetadataSource

Inherits:
RightScale::MetadataSource show all
Defined in:
lib/clouds/metadata_sources/file_metadata_source.rb

Overview

Provides metadata by reading a dictionary file on disk.

Direct Known Subclasses

ConfigDriveMetadataSource

Instance Attribute Summary collapse

Attributes inherited from RightScale::MetadataSource

#logger

Instance Method Summary collapse

Methods inherited from RightScale::MetadataSource

#append_branch_name, #append_leaf_name

Constructor Details

#initialize(options) ⇒ FileMetadataSource

Returns a new instance of FileMetadataSource.

Raises:



32
33
34
35
36
37
38
39
# File 'lib/clouds/metadata_sources/file_metadata_source.rb', line 32

def initialize(options)
  super(options)
  raise ArgumentError.new("options[:cloud_metadata_root_path] is required") unless  = options[:cloud_metadata_root_path]
  raise ArgumentError.new("options[:user_metadata_root_path] is required") unless  = options[:user_metadata_root_path]

   = options[:cloud_metadata_source_file_path]
   = options[:user_metadata_source_file_path]
end

Instance Attribute Details

#cloud_metadata_source_file_pathObject

Returns the value of attribute cloud_metadata_source_file_path.



30
31
32
# File 'lib/clouds/metadata_sources/file_metadata_source.rb', line 30

def 
  
end

#user_metadata_source_file_pathObject

Returns the value of attribute user_metadata_source_file_path.



30
31
32
# File 'lib/clouds/metadata_sources/file_metadata_source.rb', line 30

def 
  
end

Instance Method Details

#finishObject

Nothing to do.



66
67
68
# File 'lib/clouds/metadata_sources/file_metadata_source.rb', line 66

def finish
  true
end

#query(path) ⇒ Object

Queries for metadata using the given path.

Parameters

path(String)

metadata path

Return

metadata(String)

query result or empty

Raises

QueryFailed

on any failure to query



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/clouds/metadata_sources/file_metadata_source.rb', line 51

def query(path)
  result = ""
  if path == 
    result = File.read() if 
  elsif path == 
    result = File.read() if 
  else
    raise QueryFailed.new("Unknown path: #{path}")
  end
  result
rescue Exception => e
  raise QueryFailed.new(e.message)
end