Class: HybridPlatformsConductor::HpcPlugins::Cmdb::Config

Inherits:
Cmdb
  • Object
show all
Defined in:
lib/hybrid_platforms_conductor/hpc_plugins/cmdb/config.rb

Overview

CMDB getting metadata from the Config DSL

Defined Under Namespace

Modules: ConfigDSLExtension

Constant Summary

Constants included from LoggerHelpers

LoggerHelpers::LEVELS_MODIFIERS, LoggerHelpers::LEVELS_TO_STDERR

Instance Method Summary collapse

Methods inherited from Cmdb

#initialize

Methods inherited from Plugin

extend_config_dsl_with, #initialize, valid?

Methods included from LoggerHelpers

#err, #init_loggers, #log_component=, #log_debug?, #log_level=, #out, #section, #set_loggers_format, #stderr_device, #stderr_device=, #stderr_displayed?, #stdout_device, #stdout_device=, #stdout_displayed?, #stdouts_to_s, #with_progress_bar

Constructor Details

This class inherits a constructor from HybridPlatformsConductor::Cmdb

Instance Method Details

#get_others(nodes, metadata) ⇒ Object

Get other properties for a given set of nodes. It’s better to not use this method and prefer using methods naming the property being returned. As the nodes_handler can’t know in advance which properties will be returned, it will call it every time there is a missing property. If this method always returns the same values, it would be clever to cache it here.

API
  • This method is optional.

API
  • @platforms_handler can be used.

API
  • @nodes_handler can be used.

API
  • @cmd_runner can be used.

Parameters
  • nodes (Array<String>): The nodes to lookup the property for.

  • metadata (Hash<String, Hash<Symbol,Object> >): Existing metadata for each node. Dependent properties should be present here.

Result
  • Hash<String, Hash<Symbol,Object> >: The corresponding properties, per required node.

    Nodes for which the property can't be fetched can be ommitted.
    


58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/hybrid_platforms_conductor/hpc_plugins/cmdb/config.rb', line 58

def get_others(nodes, )
  # Keep metadata values in a cache, per node
  @cached_metadata = {} unless defined?(@cached_metadata)
  nodes.each do |node|
    unless @cached_metadata.key?(node)
      @cached_metadata[node] = @nodes_handler.
        select_confs_for_node(node, @config.).
        map { || [:metadata] }.
        inject({}) { |, | .merge() }
    end
  end
  @cached_metadata.slice(*nodes)
end