Project

General

Profile

Bug #1979

Updating puppet:import:puppet_classes for parameterized classes

Added by David Schmitt over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Importers
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:

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

Associated revisions

Revision eefbf33f (diff)
Added by Daniel Lobato Garcia over 9 years ago

fixes #1979 Updating puppet:import:puppet_classes for parameterized classes

Puppet import_classes task uses PuppetClassImporter instead of Environment.import_classes which is not available anymore

History

#1 Updated by Ohad Levy over 9 years ago

great, would you mind adding sending it a pull request?

thanks!

#2 Updated by Ohad Levy over 9 years ago

  • Target version set to 1.1

#3 Updated by David Schmitt over 9 years ago

I will as soon as I have unencumbered 'net access.

#4 Updated by Drew Blessing over 9 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.

#5 Updated by David Schmitt over 9 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.

#6 Updated by Daniel Lobato Garcia over 9 years ago

Can confirm the patch works indeed. I can step up and do the pull request if needed.

#7 Updated by Daniel Lobato Garcia over 9 years ago

Does [env, classes.to_sentence] need to be changed to .inspect ? .to_sentence looks much cleaner to me.

#8 Updated by Daniel Lobato Garcia over 9 years ago

Daniel Lobato Garcia wrote:

Does [env, classes.to_sentence] need to be changed to .inspect ? .to_sentence looks much cleaner to me.

https://github.com/theforeman/foreman/pull/291

#9 Updated by Daniel Lobato Garcia over 9 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF