Sha256: b3186aaafcc7ec30c511032c9ae34045aa8fde143b909f81e2651e35bfc06668

Contents?: true

Size: 1.43 KB

Versions: 11

Compression:

Stored size: 1.43 KB

Contents

#
# Author:: Adam Jacob (<adam@opscode.com>)
# Copyright:: Copyright (c) 2010 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'chef/handler'
require 'chef/resource/directory'

class Chef
  class Handler
    class JsonFile < ::Chef::Handler

      def initialize(config={})
        super(config)
      end

      def report(node, runner, start_time, end_time, elapsed_time, exception)
        if exception
          Chef::Log.error("Creating JSON exception report")
        else
          Chef::Log.info("Creating JSON run report")
        end

        data = build_report_data(node, runner, start_time, end_time, elapsed_time, exception)
        build_report_dir
        savetime = Time.now.strftime("%Y%m%d%H%M%S")
        File.open(File.join(config[:path], "chef-run-report-#{savetime}.json"), "w") do |file|
          file.puts JSON.pretty_generate(data)
        end
      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
chef-0.9.0.rc01 lib/chef/handler/json_file.rb
chef-0.9.0.b02 lib/chef/handler/json_file.rb
chef-0.9.0.b01 lib/chef/handler/json_file.rb
chef-0.9.0.a92 lib/chef/handler/json_file.rb
chef-0.9.0.a91 lib/chef/handler/json_file.rb
chef-0.9.0.a90 lib/chef/handler/json_file.rb
chef-0.9.0.a10 lib/chef/handler/json_file.rb
chef-0.9.0.a8 lib/chef/handler/json_file.rb
chef-0.9.0.a6 lib/chef/handler/json_file.rb
chef-0.9.0.a4 lib/chef/handler/json_file.rb
chef-0.9.0.a3 lib/chef/handler/json_file.rb