lib/right_chimp/Chimp.rb in right_chimp-2.1.10 vs lib/right_chimp/Chimp.rb in right_chimp-2.1.12

- old
+ new

@@ -221,11 +221,11 @@ @servers += all_instances.select {|s| s['links']['incarnator']['href'] == href } } - Log.debug "[#{Chimp.get_job_uuid}] Found #{@servers.count} servers for that array query" + Log.debug "[#{Chimp.get_job_uuid}] Found #{@servers.count} servers for that array query" end # The result will be stored (not returned) into @servers end @@ -330,11 +330,12 @@ [ '--group', '-g', GetoptLong::REQUIRED_ARGUMENT ], [ '--group-type', '-2', GetoptLong::REQUIRED_ARGUMENT ], [ '--group-concurrency', '-3', GetoptLong::REQUIRED_ARGUMENT ], [ '--timing-log', '-4', GetoptLong::REQUIRED_ARGUMENT ], [ '--timeout', '-5', GetoptLong::REQUIRED_ARGUMENT ], - [ '--noverify', '-6', GetoptLong::NO_ARGUMENT ] + [ '--noverify', '-6', GetoptLong::NO_ARGUMENT ], + [ '--exact-matching', '-8', GetoptLong::NO_ARGUMENT ] ) opts.each do |opt, arg| case opt when '--help', '-h' @@ -431,10 +432,12 @@ @timing_log = arg when '--timeout' @timeout = arg when '--noverify' @verify = false + when '--exact-matching' + @exact = true end end if @use_chimpd && ( @script.nil? || @script.empty? ) if @chimpd_wait_until_done == false @@ -554,11 +557,15 @@ # def get_servers_by_deployment(names) servers = [] all_instances = Connection.all_instances - result = all_instances.select {|i| names.any? {|n| i['links']['deployment']['name'] =~ /#{n}/ }} + if @exact + result = all_instances.select {|i| names.any? {|n| i['links']['deployment']['name'].eql? n }} + else + result = all_instances.select {|i| names.any? {|n| i['links']['deployment']['name'] =~ /#{n}/ }} + end servers = result return(servers) end @@ -575,10 +582,19 @@ # One API call per array Log.debug "[#{Chimp.get_job_uuid}] Making API 1.5 call: client.server_arrays.index(:filter => [#{array_name}])" result = Connection.client.server_arrays.index(:filter => ["name==#{array_name}"]) # Result is an array with all the server arrays if result.size != 0 - arrays_hrefs += result.collect(&:href) + if @exact + #remove results that do not exactly match + result.each{ |r| + if array_names.include?(r.raw['name']) + arrays_hrefs += [ r.href ] + end + } + else + arrays_hrefs += result.collect(&:href) + end else if @ignore_errors Log.debug "[#{Chimp.get_job_uuid}] Could not find array \"#{array_name}\"" else Log.error "[#{Chimp.get_job_uuid}] Could not find array \"#{array_name}\""