~bkerensa/ubuntu/raring/puppet/new-upstream-release

« back to all changes in this revision

Viewing changes to lib/puppet/indirector.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-07-25 01:00:37 UTC
  • mfrom: (1.1.24 upstream) (3.1.25 sid)
  • Revision ID: james.westby@ubuntu.com-20110725010037-875vuxs10eboqgw3
Tags: 2.7.1-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - debian/puppetmaster-passenger.postinst: Use cacrl instead of hostcrl to
    set the location of the CRL in apache2 configuration. Fix apache2
    configuration on upgrade as well (LP: #641001)
  - move all puppet dependencies to puppet-common since all the code
    actually located in puppet-common.
  - move libagueas from a recommend to a dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
  require 'puppet/indirector/envelope'
13
13
  require 'puppet/network/format_handler'
14
14
 
 
15
  def self.configure_routes(application_routes)
 
16
    application_routes.each do |indirection_name, termini|
 
17
      indirection_name = indirection_name.to_sym
 
18
      terminus_name = termini["terminus"]
 
19
      cache_name    = termini["cache"]
 
20
 
 
21
      Puppet::Indirector::Terminus.terminus_class(indirection_name, terminus_name || cache_name)
 
22
 
 
23
      indirection = Puppet::Indirector::Indirection.instance(indirection_name)
 
24
      raise "Indirection #{indirection_name} does not exist" unless indirection
 
25
 
 
26
      indirection.terminus_class = terminus_name if terminus_name
 
27
      indirection.cache_class = cache_name if cache_name
 
28
    end
 
29
  end
 
30
 
15
31
  # Declare that the including class indirects its methods to
16
32
  # this terminus.  The terminus name must be the name of a Puppet
17
33
  # default, not the value -- if it's the value, then it gets
21
37
    raise(ArgumentError, "Already handling indirection for #{@indirection.name}; cannot also handle #{indirection}") if @indirection
22
38
    # populate this class with the various new methods
23
39
    extend ClassMethods
24
 
    include InstanceMethods
25
40
    include Puppet::Indirector::Envelope
26
41
    extend Puppet::Network::FormatHandler
27
42
 
32
47
 
33
48
  module ClassMethods
34
49
    attr_reader :indirection
35
 
 
36
 
    def cache_class=(klass)
37
 
      indirection.cache_class = klass
38
 
    end
39
 
 
40
 
    def terminus_class=(klass)
41
 
      indirection.terminus_class = klass
42
 
    end
43
 
 
44
 
    # Expire any cached instance.
45
 
    def expire(*args)
46
 
      indirection.expire(*args)
47
 
    end
48
 
 
49
 
    def find(*args)
50
 
      indirection.find(*args)
51
 
    end
52
 
 
53
 
    def head(*args)
54
 
      indirection.head(*args)
55
 
    end
56
 
 
57
 
    def destroy(*args)
58
 
      indirection.destroy(*args)
59
 
    end
60
 
 
61
 
    def search(*args)
62
 
      indirection.search(*args)
63
 
    end
64
 
  end
65
 
 
66
 
  module InstanceMethods
67
 
    def save(key = nil)
68
 
      self.class.indirection.save key, self
69
 
    end
70
50
  end
71
51
end