]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
added support for custom /etc/hosts files, fixed bug in ObjectList filters (when...
authorelijah <elijah@riseup.net>
Fri, 7 Feb 2014 08:00:12 +0000 (00:00 -0800)
committerelijah <elijah@riseup.net>
Fri, 7 Feb 2014 08:00:12 +0000 (00:00 -0800)
lib/leap_cli/config/macros.rb
lib/leap_cli/config/object_list.rb
lib/leap_cli/version.rb

index aaed77a5d9e16d46b417cc9afe59a30d901497a9..69c3049dd03bcbd42de7f4989e415c42e7b08ada 100644 (file)
@@ -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
index 830e96d2f097fee9996d8eaa008c26d8716ccd1f..9ca46975e630df51b78eeeed7feede278392675e 100644 (file)
@@ -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
index db051299e9d56c0123557b26e2fdbbb7a1865019..056b248bee3a9ff415c979c78c29ef7efee0e2ca 100644 (file)
@@ -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.'