forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 1
/
scan_profiles.rb
27 lines (21 loc) · 917 Bytes
/
scan_profiles.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module TaskHelpers
class Exports
class ScanProfiles
def export(options = {})
export_dir = options[:directory]
scan_item_sets = options[:all] ? ScanItemSet.all : ScanItemSet.where(:read_only => [false, nil])
scan_item_sets.order(:id).each do |scan_item_set|
$log.info("Exporting Scan Profile: #{scan_item_set.name} (ID: #{scan_item_set.id})")
profile = ScanItem.get_profile(scan_item_set.name).first.dup
%w[id created_on updated_on].each { |key| profile.delete(key) }
profile['definition'].each do |dd|
%w[id created_on updated_on description].each { |key| dd.delete(key) }
end
scan_profile = profile.to_yaml
filename = Exports.safe_filename(scan_item_set.name, options[:keep_spaces])
File.write("#{export_dir}/#{filename}.yaml", scan_profile)
end
end
end
end
end