Class: LeapCli::Config::Node
- Defined in:
- lib/leap_cli/config/node.rb
Instance Attribute Summary collapse
-
#file_paths ⇒ Object
Returns the value of attribute file_paths.
Attributes inherited from Object
Instance Method Summary collapse
-
#initialize(manager = nil) ⇒ Node
constructor
A new instance of Node.
-
#pick_fields(*keys) ⇒ Object
Return a hash table representation of ourselves, with the key equal to the @node.name, and the value equal to the fields specified in *keys.
-
#supported_ssh_host_key_algorithms ⇒ Object
returns a string list of supported ssh host key algorithms for this node.
-
#test_dependencies ⇒ Object
can be overridden by the platform.
-
#vagrant? ⇒ Boolean
returns true if this node has an ip address in the range of the vagrant network.
Methods inherited from Object
#[], #deep_merge!, #default, #dump_json, #dump_yaml, #environment, #environment=, #eval_file, #evaluate, #get, #get!, #hkey, #inherit_from!, #key, #manager, #method_missing, #pick
Methods inherited from Hash
#deep_dup, #deep_merge, #deep_merge!, #pick
Constructor Details
#initialize(manager = nil) ⇒ Node
Returns a new instance of Node.
12 13 14 15 16 |
# File 'lib/leap_cli/config/node.rb', line 12 def initialize(manager=nil) super(manager) @node = self @file_paths = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class LeapCli::Config::Object
Instance Attribute Details
#file_paths ⇒ Object
Returns the value of attribute file_paths.
10 11 12 |
# File 'lib/leap_cli/config/node.rb', line 10 def file_paths @file_paths end |
Instance Method Details
#pick_fields(*keys) ⇒ Object
Return a hash table representation of ourselves, with the key equal to the @node.name, and the value equal to the fields specified in *keys.
Also, the result is flattened to a single hash, so a key of ‘a.b’ becomes ‘a_b’
compare to Object#pick(*keys). This method is the sames as Config::ObjectList#pick_fields, but works on a single node.
Example:
node.pick('domain.internal') =>
{
'node1': {
'domain_internal': 'node1.example.i'
}
}
55 56 57 |
# File 'lib/leap_cli/config/node.rb', line 55 def pick_fields(*keys) {@node.name => self.pick(*keys)} end |
#supported_ssh_host_key_algorithms ⇒ Object
returns a string list of supported ssh host key algorithms for this node. or an empty string if it could not be determined
69 70 71 72 73 |
# File 'lib/leap_cli/config/node.rb', line 69 def supported_ssh_host_key_algorithms @host_key_algo ||= SshKey.supported_host_key_algorithms( Util.read_file([:node_ssh_pub_key, @node.name]) ) end |
#test_dependencies ⇒ Object
can be overridden by the platform. returns a list of node names that should be tested before this node
63 64 65 |
# File 'lib/leap_cli/config/node.rb', line 63 def test_dependencies [] end |
#vagrant? ⇒ Boolean
returns true if this node has an ip address in the range of the vagrant network
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/leap_cli/config/node.rb', line 21 def vagrant? begin vagrant_range = IPAddr.new LeapCli.leapfile.vagrant_network rescue ArgumentError => exc Util::bail! { Util::log :invalid, "ip address '#{@node.ip_address}' vagrant.network" } end begin ip_address = IPAddr.new @node.get('ip_address') rescue ArgumentError => exc Util::log :warning, "invalid ip address '#{@node.get('ip_address')}' for node '#{@node.name}'" end return vagrant_range.include?(ip_address) end |