Class: RightScale::MetadataSources::FileMetadataSource
- Inherits:
-
RightScale::MetadataSource
- Object
- RightScale::MetadataSource
- RightScale::MetadataSources::FileMetadataSource
- Defined in:
- lib/clouds/metadata_sources/file_metadata_source.rb
Overview
Provides metadata by reading a dictionary file on disk.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cloud_metadata_source_file_path ⇒ Object
Returns the value of attribute cloud_metadata_source_file_path.
-
#user_metadata_source_file_path ⇒ Object
Returns the value of attribute user_metadata_source_file_path.
Attributes inherited from RightScale::MetadataSource
Instance Method Summary collapse
-
#finish ⇒ Object
Nothing to do.
-
#initialize(options) ⇒ FileMetadataSource
constructor
A new instance of FileMetadataSource.
-
#query(path) ⇒ Object
Queries for metadata using the given path.
Methods inherited from RightScale::MetadataSource
#append_branch_name, #append_leaf_name
Constructor Details
#initialize(options) ⇒ FileMetadataSource
Returns a new instance of FileMetadataSource.
32 33 34 35 36 37 38 39 |
# File 'lib/clouds/metadata_sources/file_metadata_source.rb', line 32 def initialize() super() raise ArgumentError.new("options[:cloud_metadata_root_path] is required") unless = [:cloud_metadata_root_path] raise ArgumentError.new("options[:user_metadata_root_path] is required") unless = [:user_metadata_root_path] = [:cloud_metadata_source_file_path] = [:user_metadata_source_file_path] end |
Instance Attribute Details
#cloud_metadata_source_file_path ⇒ Object
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_path ⇒ Object
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
#finish ⇒ Object
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.) end |