diff --git a/lib/kadeploy3/common/nodes.rb b/lib/kadeploy3/common/nodes.rb index 3de212f4862f887b8a554f0aecc4377d53f3311e..165cc3d5872bbfd09d37741c973f212d2c2c67a4 100644 --- a/lib/kadeploy3/common/nodes.rb +++ b/lib/kadeploy3/common/nodes.rb @@ -286,6 +286,34 @@ module Nodes return numbers_array end + # Check two hostnames are close (the difference is only one number) + # + # Arguments + # * hostname1 : string + # * hostname2 : string + # + # Output + # * return false if it is too remote + def NodeSet::cmp_hosts(hostname1,hostname2) + close = true + i = 0 + j = 0 + array_host1 = separate_number_letter(hostname1) + array_host2 = separate_number_letter(hostname2) + if array_host1.length == array_host2.length + while close == true && i < array_host1.length + if array_host1[i] != array_host2[i] + j += 1 + close = false if (array_host1[i] =~ /[a-zA-Z\-\.]+/ || array_host2[i] =~ /[a-zA-Z\-\.]+/ || j>1) + end + i+=1 + end + else + close = false + end + return close + end + private # Sort hostname @@ -404,33 +432,6 @@ module Nodes return [[head] + [tail] + diff_array] end - # Check two hostnames are close (the difference is only one number) - # - # Arguments - # * hostname1 : string - # * hostname2 : string - # - # Output - # * return false if it is too remote - def NodeSet::cmp_hosts(hostname1,hostname2) - close = true - i = 0 - j = 0 - array_host1 = separate_number_letter(hostname1) - array_host2 = separate_number_letter(hostname2) - if array_host1.length == array_host2.length - while close == true && i < array_host1.length - if array_host1[i] != array_host2[i] - j += 1 - close = false if (array_host1[i] =~ /[a-zA-Z\-\.]+/ || array_host2[i] =~ /[a-zA-Z\-\.]+/ || j>1) - end - i+=1 - end - else - close = false - end - return close - end # find one remote host # @@ -506,7 +507,7 @@ module Nodes private_class_method(:make_array_of_figures, :make_array_of_hostnames, :separate_number_letter, - :diff_hosts, :cmp_hosts, :remote_host_find, + :diff_hosts, :remote_host_find, :numbers_fold, :nodes_group_list_fold) public diff --git a/lib/kadeploy3/server/microsteps.rb b/lib/kadeploy3/server/microsteps.rb index b5fee568b06d731d5007cea00efecf254d2cbaab..5654bd6bae4895bd4167a4a83613b7f84ac3a365 100644 --- a/lib/kadeploy3/server/microsteps.rb +++ b/lib/kadeploy3/server/microsteps.rb @@ -241,7 +241,7 @@ class Microstep < Automata::QueueTask end end - def command(cmd,opts={},_block) + def command(cmd,opts={},&_block) raise '@current_operation should not be set' if @current_operation @lock.synchronize{ @current_operation = Execute[cmd] } @current_operation.run(opts)