58: def describe(type, name, retrieve = nil, ignore = [], format = "yaml", client = nil, clientip = nil)
59: Puppet.info "Describing %s[%s]" % [type.to_s.capitalize, name]
60: @local = true unless client
61: typeklass = nil
62: unless typeklass = Puppet::Type.type(type)
63: raise Puppet::Error, "Puppet type %s is unsupported" % type
64: end
65:
66: obj = nil
67:
68: retrieve ||= :all
69: ignore ||= []
70:
71: begin
72: obj = typeklass.create(:name => name, :check => retrieve)
73: rescue Puppet::Error => detail
74: raise Puppet::Error, "%s[%s] could not be created: %s" %
75: [type, name, detail]
76: end
77:
78: unless obj
79: raise XMLRPC::FaultException.new(
80: 1, "Could not create %s[%s]" % [type, name]
81: )
82: end
83:
84: trans = obj.to_trans
85:
86:
87: ignore.each do |st|
88: if trans.include? st
89: trans.delete(st)
90: end
91: end
92:
93:
94: trans.each do |attr, value|
95: if value.nil?
96: trans.delete(attr)
97: end
98: end
99:
100: unless @local
101: case format
102: when "yaml"
103: trans = Base64.encode64(YAML::dump(trans))
104: else
105: raise XMLRPC::FaultException.new(
106: 1, "Unavailable config format %s" % format
107: )
108: end
109: end
110:
111: return trans
112: end