Bug #1979
closedUpdating puppet:import:puppet_classes for parameterized classes
Description
Hi,
please apply this patch to get the rake task "puppet:import:puppet_classes" working again:
--- foreman/lib/tasks/puppet.rake 2012-11-27 11:14:09.000000000 +0100 +++ /usr/share/foreman/lib/tasks/puppet.rake 2012-11-27 11:24:42.000000000 +0100 @@ -77,7 +77,8 @@ # the on-disk puppet installation begin puts "Evaluating possible changes to your installation" unless args.batch - changes = Environment.importClasses proxy.id + importer = PuppetClassImporter.new({ :url => proxy.url }) + changes = importer.changes rescue => e if args.batch Rails.logger.error "Failed to refresh puppet classes: #{e}" @@ -98,7 +99,7 @@ puts "Scheduled changes to your environment" puts "Create/update environments" for env, classes in changes["new"] - print "%-15s: %s\n" % [env, classes.to_sentence] + print "%-15s: %s\n" % [env, classes.inspect] end puts "Delete environments" for env, classes in changes["obsolete"] @@ -118,9 +119,9 @@ errors = "" # Apply the filtered changes to the database begin - changed = { :new => changes["new"], :obsolete => changes["obsolete"] } - [:new, :obsolete].each { |kind| changed[kind].each_key { |k| changes[kind.to_s][k] = changes[kind.to_s][k].inspect } } - errors = Environment.obsolete_and_new(changed) + changed = { 'new' => changes["new"], 'obsolete' => changes["obsolete"] } + ['new', 'obsolete'].each { |kind| changed[kind].each_key { |k| changes[kind.to_s][k] = changes[kind.to_s][k].to_json } } + errors = PuppetClassImporter.new.obsolete_and_new(changed) rescue => e errors = e.message + "\n" + e.backtrace.join("\n") end
Updated by Ohad Levy over 12 years ago
great, would you mind adding sending it a pull request?
thanks!
Updated by David Schmitt over 12 years ago
I will as soon as I have unencumbered 'net access.
Updated by Drew Blessing over 12 years ago
I tested this patch and can verify the fix works. I really want to make sure this ends up in 1.1. David, do you have time to submit the pull request? I'd be happy to work up these changes and submit. Thanks for catching this problem and providing a fix.
Updated by David Schmitt over 12 years ago
Drew Blessing wrote:
David, do you have time to submit the pull request? I'd be happy to work up these changes and submit.
Please do! I hoped to come around to it, but live intervened.
Updated by Daniel Lobato Garcia over 12 years ago
Can confirm the patch works indeed. I can step up and do the pull request if needed.
Updated by Daniel Lobato Garcia over 12 years ago
Does [env, classes.to_sentence] need to be changed to .inspect ? .to_sentence looks much cleaner to me.
Updated by Daniel Lobato Garcia over 12 years ago
Daniel Lobato Garcia wrote:
Does [env, classes.to_sentence] need to be changed to .inspect ? .to_sentence looks much cleaner to me.
Updated by Daniel Lobato Garcia over 12 years ago
- Status changed from New to Closed
- % Done changed from 0 to 100
Applied in changeset eefbf33f1812a21f4d68a8b95329061ce850e49c.