diff options
author | danielsdeleo <dan@opscode.com> | 2013-01-17 13:43:28 -0800 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-01-17 15:02:54 -0800 |
commit | 62f9b0e3be8e22eef092163c331b7d3f8d350f94 (patch) | |
tree | 6b37c7a275918580b59c16de32a16c24f5dbe77f /lib/chef/provider | |
parent | 30ec971df95264b39e5e403c08b634d4708f5bee (diff) | |
parent | b568c4d060765e75023f50f24d0a394ada5aed0b (diff) | |
download | chef-62f9b0e3be8e22eef092163c331b7d3f8d350f94.tar.gz |
Merge branch '10-stable' into integrate-chef-10-18-0
Conflicts:
.gitattributes
chef-expander/Rakefile
chef-expander/lib/chef/expander/version.rb
chef-server-api/Rakefile
chef-server-api/chef-server-api.gemspec
chef-server-api/lib/chef-server-api/version.rb
chef-server-webui/Rakefile
chef-server-webui/chef-server-webui.gemspec
chef-server-webui/lib/chef-server-webui/version.rb
chef-server/Rakefile
chef-server/lib/chef-server/version.rb
chef-solr/lib/chef/solr/version.rb
chef.gemspec
chef/Rakefile
chef/spec/support/platform_helpers.rb
chef/spec/support/shared/functional/file_resource.rb
chef/spec/unit/api_client_spec.rb
chef/spec/unit/provider/directory_spec.rb
ci/jenkins_run_tests.bat
ci/jenkins_run_tests.sh
distro/common/html/chef-client.8.html
distro/common/html/chef-expander.8.html
distro/common/html/chef-expanderctl.8.html
distro/common/html/chef-server-webui.8.html
distro/common/html/chef-server.8.html
distro/common/html/chef-shell.1.html
distro/common/html/chef-solo.8.html
distro/common/html/chef-solr.8.html
distro/common/html/knife-bootstrap.1.html
distro/common/html/knife-client.1.html
distro/common/html/knife-configure.1.html
distro/common/html/knife-cookbook-site.1.html
distro/common/html/knife-cookbook.1.html
distro/common/html/knife-data-bag.1.html
distro/common/html/knife-environment.1.html
distro/common/html/knife-exec.1.html
distro/common/html/knife-index.1.html
distro/common/html/knife-node.1.html
distro/common/html/knife-role.1.html
distro/common/html/knife-search.1.html
distro/common/html/knife-ssh.1.html
distro/common/html/knife-status.1.html
distro/common/html/knife-tag.1.html
distro/common/html/knife.1.html
distro/common/man/man1/chef-shell.1
distro/common/man/man1/knife-bootstrap.1
distro/common/man/man1/knife-client.1
distro/common/man/man1/knife-configure.1
distro/common/man/man1/knife-cookbook-site.1
distro/common/man/man1/knife-cookbook.1
distro/common/man/man1/knife-data-bag.1
distro/common/man/man1/knife-environment.1
distro/common/man/man1/knife-exec.1
distro/common/man/man1/knife-index.1
distro/common/man/man1/knife-node.1
distro/common/man/man1/knife-role.1
distro/common/man/man1/knife-search.1
distro/common/man/man1/knife-ssh.1
distro/common/man/man1/knife-status.1
distro/common/man/man1/knife-tag.1
distro/common/man/man1/knife.1
distro/common/man/man8/chef-client.8
distro/common/man/man8/chef-expander.8
distro/common/man/man8/chef-expanderctl.8
distro/common/man/man8/chef-server-webui.8
distro/common/man/man8/chef-server.8
distro/common/man/man8/chef-solo.8
distro/common/man/man8/chef-solr.8
lib/chef/api_client.rb
lib/chef/rest.rb
lib/chef/version.rb
spec/functional/knife/ssh_spec.rb
spec/functional/resource/cookbook_file_spec.rb
spec/spec_helper.rb
spec/stress/win32/security_spec.rb
spec/support/shared/functional/securable_resource.rb
spec/unit/config_spec.rb
spec/unit/knife/ssh_spec.rb
Diffstat (limited to 'lib/chef/provider')
-rw-r--r-- | lib/chef/provider/log.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/package/yum-dump.py | 20 | ||||
-rw-r--r-- | lib/chef/provider/package/yum.rb | 41 | ||||
-rw-r--r-- | lib/chef/provider/template.rb | 2 |
4 files changed, 63 insertions, 2 deletions
diff --git a/lib/chef/provider/log.rb b/lib/chef/provider/log.rb index 5d0417ebda..927ee72fcc 100644 --- a/lib/chef/provider/log.rb +++ b/lib/chef/provider/log.rb @@ -38,7 +38,7 @@ class Chef # === Return # true:: Always return true def action_write - Chef::Log.send(@new_resource.level, @new_resource.name) + Chef::Log.send(@new_resource.level, @new_resource.message) @new_resource.updated_by_last_action(true) end diff --git a/lib/chef/provider/package/yum-dump.py b/lib/chef/provider/package/yum-dump.py index 99136eceec..407eb8f408 100644 --- a/lib/chef/provider/package/yum-dump.py +++ b/lib/chef/provider/package/yum-dump.py @@ -107,6 +107,14 @@ def setup(yb, options): elif YUM_MAJOR == 2: yb.conf.setConfigOption('cache', options.cache) + # Handle repo toggle via id or glob exactly like yum + for opt, repos in options.repo_control: + for repo in repos: + if opt == '--enablerepo': + yb.repos.enableRepo(repo) + elif opt == '--disablerepo': + yb.repos.disableRepo(repo) + return 0 def dump_packages(yb, list, output_provides): @@ -239,6 +247,12 @@ def yum_dump(options): print >> sys.stderr, "yum-dump Unlock Error: %s" % e return 200 +# Preserve order of enable/disable repo args like yum does +def gather_repo_opts(option, opt, value, parser): + if getattr(parser.values, option.dest, None) is None: + setattr(parser.values, option.dest, []) + getattr(parser.values, option.dest).append((opt, value.split(','))) + def main(): usage = "Usage: %prog [options]\n" + \ "Output a list of installed, available and re-installable packages via yum" @@ -261,6 +275,12 @@ def main(): parser.add_option("-a", "--available", action="store_const", const="available", dest="package_list", default="all", help="output only available and re-installable packages") + parser.add_option("--enablerepo", + action="callback", callback=gather_repo_opts, type="string", dest="repo_control", default=[], + help="enable disabled repositories by id or glob") + parser.add_option("--disablerepo", + action="callback", callback=gather_repo_opts, type="string", dest="repo_control", default=[], + help="disable repositories by id or glob") (options, args) = parser.parse_args() diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb index 9048048b83..f67262ef6f 100644 --- a/lib/chef/provider/package/yum.rb +++ b/lib/chef/provider/package/yum.rb @@ -664,12 +664,16 @@ class Chef @allow_multi_install = [] + @extra_repo_control = nil + # these are for subsequent runs if we are on an interval Chef::Client.when_run_starts do YumCache.instance.reload end end + attr_reader :extra_repo_control + # Cache management # @@ -693,6 +697,10 @@ class Chef raise ArgumentError, "Unexpected value in next_refresh: #{@next_refresh}" end + if @extra_repo_control + opts << " #{@extra_repo_control}" + end + one_line = false error = nil @@ -848,6 +856,22 @@ class Chef @allow_multi_install end + def enable_extra_repo_control(arg) + # Don't touch cache if it's the same repos as the last load + unless @extra_repo_control == arg + @extra_repo_control = arg + reload + end + end + + def disable_extra_repo_control + # Only force reload when set + if @extra_repo_control + @extra_repo_control = nil + reload + end + end + private def version(package_name, arch=nil, is_available=false, is_installed=false) @@ -995,6 +1019,23 @@ class Chef @yum.reload end + if @new_resource.options + repo_control = [] + @new_resource.options.split.each do |opt| + if opt =~ %r{--(enable|disable)repo=.+} + repo_control << opt + end + end + + if repo_control.size > 0 + @yum.enable_extra_repo_control(repo_control.join(" ")) + else + @yum.disable_extra_repo_control + end + else + @yum.disable_extra_repo_control + end + # At this point package_name could be: # # 1) a package name, eg: "foo" diff --git a/lib/chef/provider/template.rb b/lib/chef/provider/template.rb index fbd5c600b9..6df671c8e5 100644 --- a/lib/chef/provider/template.rb +++ b/lib/chef/provider/template.rb @@ -66,7 +66,7 @@ class Chef description << diff_current(rendered_template.path) converge_by(description) do backup - FileUtils.mv(rendered_template.path, @new_resource.path) + FileUtils.cp(rendered_template.path, @new_resource.path) Chef::Log.info("#{@new_resource} updated content") access_controls.set_all! update_new_file_state(@new_resource.path) |