~ubuntu-branches/ubuntu/oneiric/puppet/oneiric-security

« back to all changes in this revision

Viewing changes to lib/puppet/client/pelement.rb

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2008-07-26 15:43:45 UTC
  • mto: (3.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080726154345-1fmgo76b4l72ulvc
ImportĀ upstreamĀ versionĀ 0.24.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
class Puppet::Client::PElement < Puppet::Client
2
 
    @drivername = :PElementServer
3
 
 
4
 
    @handler = Puppet::Server::PElement
5
 
 
6
 
    def apply(bucket)
7
 
 
8
 
        case bucket
9
 
        when Puppet::TransObject
10
 
            tmp = Puppet::TransBucket.new
11
 
            tmp.push bucket
12
 
            bucket = tmp
13
 
            bucket.name = Facter["hostname"].value
14
 
            bucket.type = "pelement"
15
 
        when Puppet::TransBucket
16
 
            # nothing
17
 
        else
18
 
            raise Puppet::DevError, "You must pass a transportable object, not a %s" %
19
 
                bucket.class
20
 
        end
21
 
 
22
 
        unless @local
23
 
            bucket = Base64.encode64(YAML::dump(bucket))
24
 
        end
25
 
        report = @driver.apply(bucket, "yaml")
26
 
 
27
 
        return report
28
 
    end
29
 
 
30
 
    def describe(type, name, retrieve = false, ignore = false)
31
 
        Puppet.info "Describing %s[%s]" % [type, name]
32
 
        text = @driver.describe(type, name, retrieve, ignore, "yaml")
33
 
 
34
 
        object = nil
35
 
        if @local
36
 
            object = text
37
 
        else
38
 
            object = YAML::load(Base64.decode64(text))
39
 
        end
40
 
 
41
 
        return object
42
 
    end
43
 
 
44
 
    def initialize(hash = {})
45
 
        if hash.include?(:PElementServer)
46
 
            unless hash[:PElementServer].is_a?(Puppet::Server::PElement)
47
 
                raise Puppet::DevError, "Must pass an actual PElement server object"
48
 
            end
49
 
        end
50
 
 
51
 
        super(hash)
52
 
    end
53
 
 
54
 
    def list(type, ignore = false, base = false)
55
 
        bucket = @driver.list(type, ignore, base, "yaml")
56
 
 
57
 
        unless @local
58
 
            bucket = YAML::load(Base64.decode64(bucket))
59
 
        end
60
 
 
61
 
        return bucket
62
 
    end
63
 
end
64
 
 
65
 
# $Id: pelement.rb 1145 2006-04-28 04:08:38Z luke $