Class: RightScale::MetadataSource

Inherits:
Object
  • Object
show all
Defined in:
lib/clouds/metadata_source.rb

Overview

Interface for a metadata source.

Defined Under Namespace

Classes: QueryFailed

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ MetadataSource

Returns a new instance of MetadataSource.

Raises:



33
34
35
# File 'lib/clouds/metadata_source.rb', line 33

def initialize(options)
  raise ArgumentError, "options[:logger] is required" unless @logger = options[:logger]
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



31
32
33
# File 'lib/clouds/metadata_source.rb', line 31

def logger
  @logger
end

Instance Method Details

#append_branch_name(path, branch_name) ⇒ Object

Appends a branch name to the given path.

Parameters

path(String)

metadata path

branch_name(String)

branch name to append

Return

result(String)

updated path



45
46
47
48
49
50
# File 'lib/clouds/metadata_source.rb', line 45

def append_branch_name(path, branch_name)
  # remove anything after equals.
  branch_name = branch_name.gsub(/\=.*$/, '')
  branch_name = "#{branch_name}/" unless '/' == branch_name[-1..-1]
  return append_leaf_name(path, branch_name)
end

#append_leaf_name(path, leaf_name) ⇒ Object

Appends a leaf name to the given path.

Parameters

path(String)

metadata path

leaf_name(String)

leaf name to append

Return

result(String)

updated path



60
61
62
63
# File 'lib/clouds/metadata_source.rb', line 60

def append_leaf_name(path, leaf_name)
  path = "#{path}/" unless '/' == path[-1..-1]
  return "#{path}#{URI.escape(leaf_name)}"
end

#finishObject

Releases any resources used to query metadata. Must be called before releasing source.

Raises:



81
82
83
# File 'lib/clouds/metadata_source.rb', line 81

def finish
  raise NotImplementedError
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

Raises:



75
76
77
# File 'lib/clouds/metadata_source.rb', line 75

def query(path)
  raise NotImplementedError
end