Project

General

Profile

Actions

Bug #1979

closed

Updating puppet:import:puppet_classes for parameterized classes

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

Status:
Closed
Priority:
Normal
Assignee:
Category:
Importers
Target version:
Difficulty:
Triaged:
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
Actions #1

Updated by Ohad Levy over 11 years ago

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

thanks!

Actions #2

Updated by Ohad Levy over 11 years ago

  • Target version set to 1.1
Actions #3

Updated by David Schmitt over 11 years ago

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

Actions #4

Updated by Drew Blessing over 11 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.

Actions #5

Updated by David Schmitt over 11 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.

Actions #6

Updated by Daniel Lobato Garcia over 11 years ago

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

Actions #7

Updated by Daniel Lobato Garcia over 11 years ago

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

Actions #8

Updated by Daniel Lobato Garcia over 11 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

Actions #9

Updated by Daniel Lobato Garcia over 11 years ago

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

Also available in: Atom PDF