summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/resource.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-19 02:08:11 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-19 02:08:11 +0000
commitdc5f4dc0d01dc2ccb4679afbf3802a7ab0f3c126 (patch)
tree6082433e05ad445aa4323a05de7d5820c5c023d6 /lib/puppet/parser/resource.rb
parent5a52855c1da2cb4716587bf0223c6d20eddaf00a (diff)
downloadpuppet-dc5f4dc0d01dc2ccb4679afbf3802a7ab0f3c126.tar.gz
puppet-dc5f4dc0d01dc2ccb4679afbf3802a7ab0f3c126.tar.xz
puppet-dc5f4dc0d01dc2ccb4679afbf3802a7ab0f3c126.zip
Fixing most of the rails stuff. I think everything basically works now, and now I am just going through and making sure things get deleted when they are supposed (i.e., you remove a resource and it gets deleted from the host's config).
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1950 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/parser/resource.rb')
-rw-r--r--lib/puppet/parser/resource.rb74
1 files changed, 33 insertions, 41 deletions
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index 7ea85dded..857b5fa39 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -101,27 +101,6 @@ class Puppet::Parser::Resource
else
self.fail "Cannot find definition %s" % self.type
end
-
-
-# if builtin?
-# devfail "Cannot evaluate a builtin type"
-# end
-#
-# unless klass = scope.finddefine(self.type)
-# self.fail "Cannot find definition %s" % self.type
-# end
-#
-# finish()
-#
-# scope.deleteresource(self)
-#
-# return klass.evaluate(:scope => scope,
-# :type => self.type,
-# :name => self.title,
-# :arguments => self.to_hash,
-# :scope => self.scope,
-# :exported => self.exported
-# )
ensure
@evaluated = true
end
@@ -252,9 +231,24 @@ class Puppet::Parser::Resource
end
end
- # Store our object as a Rails object. We need the host object we're storing it
- # with.
- def store(host)
+ #def tags
+ # unless defined? @tags
+ # @tags = scope.tags
+ # @tags << self.type
+ # end
+ # @tags
+ #end
+
+ def to_hash
+ @params.inject({}) do |hash, ary|
+ param = ary[1]
+ hash[param.name] = param.value
+ hash
+ end
+ end
+
+ # Turn our parser resource into a Rails resource.
+ def to_rails(host)
args = {}
#FIXME: support files/lines, etc.
#%w{type title tags file line exported}.each do |param|
@@ -280,28 +274,26 @@ class Puppet::Parser::Resource
obj = host.resources.build(args)
end
+ if l = self.line
+ obj.line = l
+ end
+
# Either way, now add our parameters
+ exists = {}
+ obj.param_names.each do |pn| exists[pn.name] = pn end
@params.each do |name, param|
- param.store(obj)
+ param.to_rails(obj)
+ exists.delete(name.to_s) if exists.include?(name.to_s)
end
- return obj
- end
-
- #def tags
- # unless defined? @tags
- # @tags = scope.tags
- # @tags << self.type
- # end
- # @tags
- #end
-
- def to_hash
- @params.inject({}) do |hash, ary|
- param = ary[1]
- hash[param.name] = param.value
- hash
+ unless exists.empty?
+ obj.save
+ exists.each do |name, param|
+ obj.param_names.delete(param)
+ end
end
+
+ return obj
end
def to_s