Class: HybridPlatformsConductor::HpcPlugins::Cmdb::HostKeys

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

Overview

Get the needed host keys to nodes

Constant Summary

Constants included from LoggerHelpers

LoggerHelpers::LEVELS_MODIFIERS, LoggerHelpers::LEVELS_TO_STDERR

Instance Method Summary collapse

Methods included from ParallelThreads

#for_each_element_in

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_host_keys(nodes, metadata) ⇒ Object

Get a specific property for a given set of nodes.

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, Object>: The corresponding property, per required node.

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


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb', line 42

def get_host_keys(nodes, )
   = {}
  # Get the list of nodes, per hostname (just in case several nodes share the same hostname)
  # Hash<String, Array<String> >
  hostnames = Hash.new { |hash, key| hash[key] = [] }
  .each do |node, |
    if [:host_ip]
      hostnames[[:host_ip]] << node
    elsif [:hostname]
      hostnames[[:hostname]] << node
    end
  end
  unless hostnames.empty?
    host_keys_for(*hostnames.keys).each do |hostname, ip|
      hostnames[hostname].each do |node|
        [node] = ip
      end
    end
  end
  
end

#property_dependenciesObject

Return possible dependencies between properties. A property can need another property to be set before. For example an IP would need first to have the hostname to be known in order to be looked up.

API
  • This method is optional

Result
  • Hash<Symbol, Symbol or Array<Symbol> >: The list of necessary properties (or single one) that should be set, per property name (:others can also be used here)



25
26
27
28
29
# File 'lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb', line 25

def property_dependencies
  {
    host_keys: %i[hostname host_ip]
  }
end