Commit c23fea89 authored by PrajaktaPurohit's avatar PrajaktaPurohit
Browse files

Merge branch '10-stable' into reporting_with_summary_only

parents dcdfdecb 37e11b41
......@@ -23,7 +23,7 @@ require 'open3'
module Chef
module Expander
VERSION = "10.14.3"
VERSION = "10.14.5"
def self.version
@rev ||= begin
......
module ChefServerApi
VERSION = '10.14.3'
VERSION = '10.14.5'
end
module ChefServerWebui
VERSION = '10.14.3'
VERSION = '10.14.5'
end
......@@ -17,5 +17,5 @@
#
module ChefServer
VERSION = '10.14.3'
VERSION = '10.14.5'
end
class Chef
class Solr
VERSION = '10.14.3'
VERSION = '10.14.5'
# Solr Schema. Used to detect incompatibilities between installed solr and
# chef-solr versions.
......
......@@ -201,7 +201,7 @@ class Chef
why_run false
color false
client_fork false
enable_reporting false
enable_reporting true
# Set these to enable SSL authentication / mutual-authentication
# with the server
......
......@@ -369,7 +369,7 @@ class Chef
return platform, version
end
def provider_for_resource(resource, action)
def provider_for_resource(resource, action=:nothing)
node = resource.run_context && resource.run_context.node
raise ArgumentError, "Cannot find the provider for a resource with no run context set" unless node
provider = find_provider_for_node(node, resource).new(resource, resource.run_context)
......
......@@ -29,10 +29,7 @@ class Chef
def load_current_resource
@current_resource = Chef::Resource::CookbookFile.new(@new_resource.name)
@new_resource.path.gsub!(/\\/, "/") # for Windows
@current_resource.path(@new_resource.path)
setup_acl
@current_resource
super
end
def action_create
......@@ -47,6 +44,9 @@ class Chef
Chef::Log.debug("#{@new_resource} staging #{file_cache_location} to #{tempfile.path}")
tempfile.close
FileUtils.cp(file_cache_location, tempfile.path)
# Since the @new_resource.path file will not be updated
# at the time of converge, we must use the tempfile
update_new_file_state(tempfile.path)
end
Chef::Log.info("#{@new_resource} created file #{@new_resource.path}")
end
......
......@@ -408,10 +408,10 @@ class Chef
end
def run_callback_from_file(callback_file)
if ::File.exist?(callback_file)
Chef::Log.info "#{@new_resource} queueing checkdeploy hook #{callback_file}"
recipe_eval do
Dir.chdir(release_path) do
Chef::Log.info "#{@new_resource} running deploy hook #{callback_file}"
recipe_eval { from_file(callback_file) }
from_file(callback_file) if ::File.exist?(callback_file)
end
end
end
......
......@@ -33,9 +33,12 @@ class Chef
def load_current_resource
@current_resource = Chef::Resource::Directory.new(@new_resource.name)
@current_resource.path(@new_resource.path)
load_current_resource_attrs
setup_acl
@current_resource
end
def define_resource_requirements
# this must be evaluated before whyrun messages are printed
access_controls.requires_changes?
......
......@@ -58,12 +58,14 @@ class Chef
def is_binary?(path)
::File.open(path) do |file|
buff = file.read(Chef::Config[:diff_filesize_threshold])
buff = "" if buff.nil?
return buff !~ /^[\r[:print:]]*$/
end
end
def diff_current(temp_path)
suppress_resource_reporting = false
......@@ -123,13 +125,39 @@ class Chef
end
def load_current_resource
@current_resource = Chef::Resource::File.new(@new_resource.name)
# Every child should be specifying their own constructor, so this
# should only be run in the file case.
@current_resource ||= Chef::Resource::File.new(@new_resource.name)
@new_resource.path.gsub!(/\\/, "/") # for Windows
@current_resource.path(@new_resource.path)
if @new_resource.content && ::File.exist?(@new_resource.path)
@current_resource.checksum(checksum(@new_resource.path))
if !::File.directory?(@new_resource.path)
if ::File.exist?(@new_resource.path)
@current_resource.checksum(checksum(@new_resource.path))
end
end
load_current_resource_attrs
setup_acl
@current_resource
end
def load_current_resource_attrs
if ::File.exist?(@new_resource.path)
stat = ::File.stat(@new_resource.path)
@current_resource.owner(stat.uid)
@current_resource.mode(stat.mode & 07777)
@current_resource.group(stat.gid)
if @new_resource.group.nil?
@new_resource.group(@current_resource.group)
end
if @new_resource.owner.nil?
@new_resource.owner(@current_resource.owner)
end
if @new_resource.mode.nil?
@new_resource.mode(@current_resource.mode)
end
end
end
def setup_acl
......@@ -183,6 +211,19 @@ class Chef
end
end
# if you are using a tempfile before creating, you must
# override the default with the tempfile, since the
# file at @new_resource.path will not be updated on converge
def update_new_file_state(path=@new_resource.path)
stat = ::File.stat(path)
@new_resource.owner(stat.uid)
@new_resource.mode(stat.mode & 07777)
@new_resource.group(stat.gid)
if !::File.directory?(path)
@new_resource.checksum(checksum(path))
end
end
def action_create
if !::File.exists?(@new_resource.path)
description = []
......@@ -190,10 +231,13 @@ class Chef
desc << " with content checksum #{short_cksum(new_resource_content_checksum)}" if new_resource.content
description << desc
description << diff_current_from_content(@new_resource.content)
converge_by(description) do
Chef::Log.info("entered create")
::File.open(@new_resource.path, "w+") {|f| f.write @new_resource.content }
access_controls.set_all
Chef::Log.info("#{@new_resource} created file #{@new_resource.path}")
update_new_file_state
end
else
set_content unless @new_resource.content.nil?
......@@ -205,6 +249,8 @@ class Chef
if access_controls.requires_changes?
converge_by(access_controls.describe_changes) do
access_controls.set_all
#Update file state with new access values
update_new_file_state
end
end
end
......
......@@ -34,18 +34,21 @@ class Chef
# Send a HEAD request to @new_resource.url, with ?message=@new_resource.message
def action_head
converge_by("#{@new_resource} HEAD to #{@new_resource.url}") do
message = check_message(@new_resource.message)
modified = @rest.run_request(
:HEAD,
@rest.create_url("#{@new_resource.url}?message=#{message}"),
@new_resource.headers,
false,
10,
false
)
Chef::Log.info("#{@new_resource} HEAD to #{@new_resource.url} successful")
Chef::Log.debug("#{@new_resource} HEAD request response: #{modified}")
message = check_message(@new_resource.message)
# returns true from Chef::REST if returns 2XX (Net::HTTPSuccess)
modified = @rest.run_request(
:HEAD,
@rest.create_url("#{@new_resource.url}?message=#{message}"),
@new_resource.headers,
false,
10,
false
)
Chef::Log.info("#{@new_resource} HEAD to #{@new_resource.url} successful")
Chef::Log.debug("#{@new_resource} HEAD request response: #{modified}")
# :head is usually used to trigger notifications, which converge_by now does
if modified
converge_by("#{@new_resource} HEAD to #{@new_resource.url} returned modified, trigger notifications") {}
end
end
......
......@@ -78,6 +78,7 @@ class Chef
end
description = install_version ? "version #{install_version} of" : ""
converge_by("install #{description} package #{@new_resource.package_name}") do
@new_resource.version(install_version)
install_package(@new_resource.package_name, install_version)
end
end
......@@ -88,6 +89,7 @@ class Chef
elsif @current_resource.version == candidate_version
Chef::Log.debug("#{@new_resource} is at the latest version - nothing to do")
else
@new_resource.version(candidate_version)
orig_version = @current_resource.version || "uninstalled"
converge_by("upgrade package #{@new_resource.package_name} from #{orig_version} to #{candidate_version}") do
status = upgrade_package(@new_resource.package_name, candidate_version)
......
......@@ -27,8 +27,8 @@ class Chef
class RemoteFile < Chef::Provider::File
def load_current_resource
@current_resource = Chef::Resource::RemoteFile.new(@new_resource.name)
super
@current_resource.checksum(checksum(@current_resource.path)) if ::File.exist?(@current_resource.path)
end
def action_create
......
......@@ -34,6 +34,17 @@ class Chef
true
end
def load_new_resource_state
# If the user didn't specify a change in enabled state,
# it will be the same as the old resource
if ( @new_resource.enabled.nil? )
@new_resource.enabled(@current_resource.enabled)
end
if ( @new_resource.running.nil? )
@new_resource.running(@current_resource.running)
end
end
def shared_resource_requirements
end
......@@ -56,6 +67,8 @@ class Chef
Chef::Log.info("#{@new_resource} enabled")
end
end
load_new_resource_state
@new_resource.enabled(true)
end
def action_disable
......@@ -67,6 +80,8 @@ class Chef
else
Chef::Log.debug("#{@new_resource} already disabled - nothing to do")
end
load_new_resource_state
@new_resource.enabled(false)
end
def action_start
......@@ -78,6 +93,8 @@ class Chef
else
Chef::Log.debug("#{@new_resource} already running - nothing to do")
end
load_new_resource_state
@new_resource.running(true)
end
def action_stop
......@@ -89,6 +106,8 @@ class Chef
else
Chef::Log.debug("#{@new_resource} already stopped - nothing to do")
end
load_new_resource_state
@new_resource.running(false)
end
def action_restart
......@@ -96,6 +115,8 @@ class Chef
restart_service
Chef::Log.info("#{@new_resource} restarted")
end
load_new_resource_state
@new_resource.running(true)
end
def action_reload
......@@ -105,6 +126,7 @@ class Chef
Chef::Log.info("#{@new_resource} reloaded")
end
end
load_new_resource_state
end
def enable_service
......
......@@ -31,8 +31,8 @@ class Chef
include Chef::Mixin::Template
def load_current_resource
@current_resource = Chef::Resource::Template.new(@new_resource.name)
super
@current_resource.checksum(checksum(@current_resource.path)) if ::File.exist?(@current_resource.path)
end
def define_resource_requirements
......@@ -64,6 +64,14 @@ class Chef
FileUtils.mv(rendered_template.path, @new_resource.path)
Chef::Log.info("#{@new_resource} updated content")
access_controls.set_all!
stat = ::File.stat(@new_resource.path)
# template depends on the checksum not changing, and updates it
# itself later in the code, so we cannot set it here, as we do with
# all other < File child provider classes
@new_resource.owner(stat.uid)
@new_resource.mode(stat.mode & 07777)
@new_resource.group(stat.gid)
end
end
end
......
......@@ -606,8 +606,8 @@ F
raise customize_exception(e)
end
ensure
events.resource_completed(self)
@elapsed_time = Time.now - start_time
events.resource_completed(self)
end
end
......
#
# Author:: Adam Jacob (<adam@opscode.com>)
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Author:: Tyler Cloke (<tyler@opscode.com>)
# Copyright:: Copyright (c) 2008, 2011 Opscode, Inc.
# License:: Apache License, Version 2.0
#
......
#
# Author:: Bryan McLellan (btm@loftninjas.org)
# Author:: Tyler Cloke (<tyler@opscode.com>)
# Copyright:: Copyright (c) 2009 Bryan McLellan
# License:: Apache License, Version 2.0
#
......@@ -22,6 +23,10 @@ class Chef
class Resource
class Cron < Chef::Resource
identity_attr :command
state_attrs :minute, :hour, :day, :month, :weekday, :user
def initialize(name, run_context=nil)
super
@resource_name = :cron
......
#
# Author:: Daniel DeLeo (<dan@kallistec.com>)
# Author:: Tyler Cloke (<tyler@opscode.com>)
# Copyright:: Copyright (c) 2008 Opscode, Inc.
# License:: Apache License, Version 2.0
#
......@@ -49,9 +50,13 @@ class Chef
# release directory. Callback files can contain chef code (resources, etc.)
#
class Deploy < Chef::Resource
provider_base Chef::Provider::Deploy
identity_attr :repository
state_attrs :deploy_to, :revision
def initialize(name, run_context=nil)
super
@resource_name = :deploy
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment