Removed ZAML so that puppet doesn't need to be installed to generate sample reports, added the samples namespace to the reports namespace, and added the reports:samples:populate task to generate sample reports and import them into the DB. Also fixed Transaction declaration to be class instead of module since this matches its original definition and monkeypatching it as a module was causing errors.
Paired-with:Matt Robinson Signed-off-by: Max Martin <[email protected]> --- Local-branch: feature/next/6531_report_generator lib/tasks/generate_and_import_samples.rake | 6 ++++++ lib/tasks/generate_sample_reports.rake | 27 ++++++++++++--------------- 2 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 lib/tasks/generate_and_import_samples.rake diff --git a/lib/tasks/generate_and_import_samples.rake b/lib/tasks/generate_and_import_samples.rake new file mode 100644 index 0000000..f3f6e89 --- /dev/null +++ b/lib/tasks/generate_and_import_samples.rake @@ -0,0 +1,6 @@ +namespace :reports do + namespace :samples do + desc "Generate sample YAML reports and import them into the database" + task :populate => [:generate, 'reports:import'] + end +end diff --git a/lib/tasks/generate_sample_reports.rake b/lib/tasks/generate_sample_reports.rake index c6e7e9e..3d88d1c 100644 --- a/lib/tasks/generate_sample_reports.rake +++ b/lib/tasks/generate_sample_reports.rake @@ -5,15 +5,10 @@ require 'rubygems' require 'active_support/all' require 'YAML' require 'fileutils' -begin - require 'puppet/util/zaml' - YAML = ZAML -rescue LoadError -end module Puppet; end module Puppet::Resource; end -module Puppet::Transaction; end +class Puppet::Transaction; end module Puppet::Util; end # http://projects.puppetlabs.com/projects/puppet/wiki/Report_Format_2 @@ -173,18 +168,20 @@ class Array end namespace :reports do + namespace :samples do - desc "Generate sample YAML reports" - task :generate_samples do - DEFAULT_DIR = 'tmp/sample_reports' - report_dir = ENV['REPORT_DIR'] || DEFAULT_DIR + desc "Generate sample YAML reports" + task :generate do + DEFAULT_DIR = 'tmp/sample_reports' + report_dir = ENV['REPORT_DIR'] || DEFAULT_DIR - FileUtils.mkdir_p(report_dir) + FileUtils.mkdir_p(report_dir) - 100.times do - report = DataGenerator.generate_report - File.open("#{report_dir}/#{report.host}.yaml","w") do |f| - f.print YAML.dump(report) + 100.times do + report = DataGenerator.generate_report + File.open("#{report_dir}/#{report.host}.yaml","w") do |f| + f.print YAML.dump(report) + end end end end -- 1.7.4 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
