Display all notes when no host specified, since not all notes include a host.
git-svn-id: file:///home/svn/framework3/trunk@13645 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
parent
496170eac1
commit
a20195d9a4
|
@ -808,33 +808,38 @@ class Db
|
|||
return
|
||||
end
|
||||
|
||||
host_ranges.push(nil) if host_ranges.empty?
|
||||
|
||||
note_list = []
|
||||
delete_count = 0
|
||||
each_host_range_chunk(host_ranges) do |host_search|
|
||||
framework.db.hosts(framework.db.workspace, false, host_search).each do |host|
|
||||
host.notes.each do |note|
|
||||
next if(types and types.index(note.ntype).nil?)
|
||||
msg = "Time: #{note.created_at} Note:"
|
||||
if (note.host)
|
||||
host = note.host
|
||||
msg << " host=#{note.host.address}"
|
||||
if set_rhosts
|
||||
# only unique addresses
|
||||
rhosts << host.address unless rhosts.include?(host.address)
|
||||
end
|
||||
end
|
||||
if (note.service)
|
||||
name = (note.service.name ? note.service.name : "#{note.service.port}/#{note.service.proto}")
|
||||
msg << " service=#{name}"
|
||||
end
|
||||
msg << " type=#{note.ntype} data=#{note.data.inspect}"
|
||||
print_status(msg)
|
||||
if mode == :delete
|
||||
note.destroy
|
||||
delete_count += 1
|
||||
if host_ranges.empty? # No host specified - collect all notes
|
||||
note_list = framework.db.notes
|
||||
else # Collect notes of specified hosts
|
||||
each_host_range_chunk(host_ranges) do |host_search|
|
||||
framework.db.hosts(framework.db.workspace, false, host_search).each do |host|
|
||||
note_list.concat(host.notes)
|
||||
end
|
||||
end
|
||||
end
|
||||
# Now display them
|
||||
note_list.each do |note|
|
||||
next if(types and types.index(note.ntype).nil?)
|
||||
msg = "Time: #{note.created_at} Note:"
|
||||
if (note.host)
|
||||
host = note.host
|
||||
msg << " host=#{note.host.address}"
|
||||
if set_rhosts
|
||||
# only unique addresses
|
||||
rhosts << host.address unless rhosts.include?(host.address)
|
||||
end
|
||||
end
|
||||
if (note.service)
|
||||
name = (note.service.name ? note.service.name : "#{note.service.port}/#{note.service.proto}")
|
||||
msg << " service=#{name}"
|
||||
end
|
||||
msg << " type=#{note.ntype} data=#{note.data.inspect}"
|
||||
print_status(msg)
|
||||
if mode == :delete
|
||||
note.destroy
|
||||
delete_count += 1
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue