Class: HybridPlatformsConductor::HpcPlugins::Cmdb::HostIp
- Includes:
- ParallelThreads
- Defined in:
- lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb
Overview
Get the host IP
Constant Summary
Constants included from LoggerHelpers
LoggerHelpers::LEVELS_MODIFIERS, LoggerHelpers::LEVELS_TO_STDERR
Instance Method Summary collapse
-
#get_host_ip(nodes, metadata) ⇒ Object
Get a specific property for a given set of nodes.
-
#property_dependencies ⇒ Object
Return possible dependencies between properties.
Methods included from ParallelThreads
Methods inherited from Cmdb
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_ip(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 |
# File 'lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb', line 42 def get_host_ip(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, | hostnames[[:hostname]] << node if [:hostname] end unless hostnames.empty? ip_for(*hostnames.keys).each do |hostname, ip| hostnames[hostname].each do |node| [node] = ip end end end end |
#property_dependencies ⇒ Object
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_ip.rb', line 25 def property_dependencies { host_ip: :hostname } end |