Sha256: 018fe75700327874fb3e621a7a7bf9babdaa7b4944aadcdccb8e97c25b490858

Contents?: true

Size: 1.17 KB

Versions: 44

Compression:

Stored size: 1.17 KB

Contents

require 'puppet/rails/host'
require 'puppet/indirector/active_record'
require 'puppet/resource/catalog'

class Puppet::Resource::Catalog::ActiveRecord < Puppet::Indirector::ActiveRecord
  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)

    catalog = Puppet::Resource::Catalog.new(host.name)

    host.resources.each do |resource|
      catalog.add_resource resource.to_transportable
    end

    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.railsmark "Saved catalog to database" do
      host.merge_resources(catalog.vertices)
      host.last_compile = Time.now

      if node = Puppet::Node.indirection.find(catalog.name)
        host.ip = node.parameters["ipaddress"]
        host.environment = node.environment.to_s
      end

      host.save
    end
  end
end

Version data entries

44 entries across 44 versions & 4 rubygems

Version Path
puppet-parse-0.1.4 lib/vendor/puppet/indirector/catalog/active_record.rb
puppet-parse-0.1.3 lib/vendor/puppet/indirector/catalog/active_record.rb
puppet-parse-0.1.2 lib/vendor/puppet/indirector/catalog/active_record.rb
puppet-parse-0.1.1 lib/vendor/puppet/indirector/catalog/active_record.rb
puppet-2.7.26 lib/puppet/indirector/catalog/active_record.rb
puppet-2.7.25 lib/puppet/indirector/catalog/active_record.rb
puppet-2.7.24 lib/puppet/indirector/catalog/active_record.rb
puppet-2.7.23 lib/puppet/indirector/catalog/active_record.rb
puppet-2.7.22 lib/puppet/indirector/catalog/active_record.rb
puppet-parse-0.1.0 lib/vendor/puppet/indirector/catalog/active_record.rb
puppet-parse-0.0.6 lib/vendor/puppet/indirector/catalog/active_record.rb
puppet-2.7.21 lib/puppet/indirector/catalog/active_record.rb
puppet-parse-0.0.5 lib/vendor/puppet/indirector/catalog/active_record.rb
puppet-parse-0.0.4 lib/vendor/puppet/indirector/catalog/active_record.rb
puppet-parse-0.0.2 lib/vendor/puppet/indirector/catalog/active_record.rb
puppet-2.7.20 lib/puppet/indirector/catalog/active_record.rb
puppet-2.7.20.rc1 lib/puppet/indirector/catalog/active_record.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/lib/puppet/indirector/catalog/active_record.rb
puppet-2.7.19 lib/puppet/indirector/catalog/active_record.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/lib/puppet/indirector/catalog/active_record.rb