diff options
Diffstat (limited to 'lib/puppet/indirector/catalog/active_record.rb')
-rw-r--r-- | lib/puppet/indirector/catalog/active_record.rb | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/lib/puppet/indirector/catalog/active_record.rb b/lib/puppet/indirector/catalog/active_record.rb index 575ce72fb..fabb08eb9 100644 --- a/lib/puppet/indirector/catalog/active_record.rb +++ b/lib/puppet/indirector/catalog/active_record.rb @@ -3,39 +3,39 @@ require 'puppet/indirector/active_record' require 'puppet/resource/catalog' class Puppet::Resource::Catalog::ActiveRecord < Puppet::Indirector::ActiveRecord - use_ar_model Puppet::Rails::Host + use_ar_model Puppet::Rails::Host - # If we can find the host, then return a catalog with the host's resources - # as the vertices. - def find(request) - return nil unless request.options[:cache_integration_hack] - return nil unless host = ar_model.find_by_name(request.key) + # If we can find the host, then return a catalog with the host's resources + # as the vertices. + def find(request) + return nil unless request.options[:cache_integration_hack] + return nil unless host = ar_model.find_by_name(request.key) - catalog = Puppet::Resource::Catalog.new(host.name) + catalog = Puppet::Resource::Catalog.new(host.name) - host.resources.each do |resource| - catalog.add_resource resource.to_transportable - end - - catalog + host.resources.each do |resource| + catalog.add_resource resource.to_transportable end - # Save the values from a Facts instance as the facts on a Rails Host instance. - def save(request) - catalog = request.instance + catalog + end + + # Save the values from a Facts instance as the facts on a Rails Host instance. + def save(request) + catalog = request.instance - host = ar_model.find_by_name(catalog.name) || ar_model.create(:name => catalog.name) + host = ar_model.find_by_name(catalog.name) || ar_model.create(:name => catalog.name) - host.railsmark "Saved catalog to database" do - host.merge_resources(catalog.vertices) - host.last_compile = Time.now + host.railsmark "Saved catalog to database" do + host.merge_resources(catalog.vertices) + host.last_compile = Time.now - if node = Puppet::Node.find(catalog.name) - host.ip = node.parameters["ipaddress"] - host.environment = node.environment - end + if node = Puppet::Node.find(catalog.name) + host.ip = node.parameters["ipaddress"] + host.environment = node.environment + end - host.save - end + host.save end + end end |