diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/leap_cli/config/macros.rb | 22 | ||||
-rw-r--r-- | lib/leap_cli/config/object_list.rb | 4 | ||||
-rw-r--r-- | lib/leap_cli/version.rb | 2 |
3 files changed, 19 insertions, 9 deletions
diff --git a/lib/leap_cli/config/macros.rb b/lib/leap_cli/config/macros.rb index aaed77a..69c3049 100644 --- a/lib/leap_cli/config/macros.rb +++ b/lib/leap_cli/config/macros.rb @@ -157,15 +157,24 @@ module LeapCli; module Config end # - # Generates entries needed for updating /etc/hosts on a node, but only including the IPs of the - # other nodes we have encountered. Also, for virtual machines, use the local address if this - # @node is in the same location. + # Generates entries needed for updating /etc/hosts on a node (as a hash). # - def hosts_file - if @referenced_nodes && @referenced_nodes.any? + # Argument `nodes` can be nil or a list of nodes. If nil, only include the + # IPs of the other nodes this @node as has encountered. + # + # Also, for virtual machines, we use the local address if this @node is in + # the same location as the node in question. + # + def hosts_file(nodes=nil) + if nodes.nil? + if @referenced_nodes && @referenced_nodes.any? + nodes = @referenced_nodes + end + end + if nodes hosts = {} my_location = @node['location'] ? @node['location']['name'] : nil - @referenced_nodes.each_node do |node| + nodes.each_node do |node| next if node.name == @node.name hosts[node.name] = {'ip_address' => node.ip_address, 'domain_internal' => node.domain.internal, 'domain_full' => node.domain.full} node_location = node['location'] ? node['location']['name'] : nil @@ -177,7 +186,6 @@ module LeapCli; module Config end end end - #hosts = @referenced_nodes.pick_fields("ip_address", "domain.internal", "domain.full") return hosts else return nil diff --git a/lib/leap_cli/config/object_list.rb b/lib/leap_cli/config/object_list.rb index 830e96d..9ca4697 100644 --- a/lib/leap_cli/config/object_list.rb +++ b/lib/leap_cli/config/object_list.rb @@ -46,7 +46,9 @@ module LeapCli each do |name, config| value = config[field] if value.is_a? Array - if value.include?(match_value) + if operator == :equal && value.include?(match_value) + results[name] = config + elsif operator == :not_equal && !value.include?(match_value) results[name] = config end else diff --git a/lib/leap_cli/version.rb b/lib/leap_cli/version.rb index db05129..056b248 100644 --- a/lib/leap_cli/version.rb +++ b/lib/leap_cli/version.rb @@ -1,6 +1,6 @@ module LeapCli unless defined?(LeapCli::VERSION) - VERSION = '1.3.0' + VERSION = '1.3.1' COMPATIBLE_PLATFORM_VERSION = '0.3.0'..'1.99' SUMMARY = 'Command line interface to the LEAP platform' DESCRIPTION = 'The command "leap" can be used to manage a bevy of servers running the LEAP platform from the comfort of your own home.' |