summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/metatype/closure.rb52
-rw-r--r--lib/puppet/metatype/instances.rb16
-rw-r--r--lib/puppet/node/configuration.rb20
-rw-r--r--lib/puppet/type.rb11
-rwxr-xr-xlib/puppet/type/tidy.rb1
5 files changed, 22 insertions, 78 deletions
diff --git a/lib/puppet/metatype/closure.rb b/lib/puppet/metatype/closure.rb
index 46e3c873f..259854411 100644
--- a/lib/puppet/metatype/closure.rb
+++ b/lib/puppet/metatype/closure.rb
@@ -42,56 +42,4 @@ class Puppet::Type
return @managed
end
end
-
- # Merge new information with an existing object, checking for conflicts
- # and such. This allows for two specifications of the same object and
- # the same values, but it's pretty limited right now. The result of merging
- # properties is very different from the result of merging parameters or
- # metaparams. This is currently unused.
- def merge(hash)
- hash.each { |param, value|
- if param.is_a?(String)
- param = param.intern
- end
-
- # Of course names are the same, duh.
- next if param == :name or param == self.class.namevar
-
- unless value.is_a?(Array)
- value = [value]
- end
-
- if @parameters.include?(param) and oldvals = @parameters[param].shouldorig
- unless oldvals.is_a?(Array)
- oldvals = [oldvals]
- end
- # If the values are exactly the same, order and everything,
- # then it's okay.
- if oldvals == value
- return true
- end
- # take the intersection
- newvals = oldvals & value
- if newvals.empty?
- self.fail "No common values for %s on %s(%s)" %
- [param, self.class.name, self.title]
- elsif newvals.length > 1
- self.fail "Too many values for %s on %s(%s)" %
- [param, self.class.name, self.title]
- else
- self.debug "Reduced old values %s and new values %s to %s" %
- [oldvals.inspect, value.inspect, newvals.inspect]
- @parameters[param].should = newvals
- #self.should = newvals
- return true
- end
- else
- self[param] = value
- end
- }
-
- # Set the defaults again, just in case.
- self.setdefaults
- end
end
-
diff --git a/lib/puppet/metatype/instances.rb b/lib/puppet/metatype/instances.rb
index 8cc648e8f..16dd28433 100644
--- a/lib/puppet/metatype/instances.rb
+++ b/lib/puppet/metatype/instances.rb
@@ -126,8 +126,6 @@ class Puppet::Type
# XXX This will have to change when transobjects change to using titles
title = hash.name
- #Puppet.debug "Creating %s[%s]" % [self.name, title]
-
# if the object already exists
if self.isomorphic? and retobj = self[title]
# if only one of our objects is implicit, then it's easy to see
@@ -142,19 +140,7 @@ class Puppet::Type
Puppet.debug "Ignoring implicit %s[%s]" % [self.name, title]
return nil
else
- # If only one of the objects is being managed, then merge them
- if retobj.managed?
- raise Puppet::Error, "%s '%s' is already being managed" %
- [self.name, title]
- else
- retobj.merge(hash)
- return retobj
- end
- # We will probably want to support merging of some kind in
- # the future, but for now, just throw an error.
- #retobj.merge(hash)
-
- #return retobj
+ raise Puppet::Error, "%s is already being managed" % retobj.ref
end
end
diff --git a/lib/puppet/node/configuration.rb b/lib/puppet/node/configuration.rb
index 804f357d1..393f23913 100644
--- a/lib/puppet/node/configuration.rb
+++ b/lib/puppet/node/configuration.rb
@@ -442,10 +442,18 @@ class Puppet::Node::Configuration < Puppet::PGraph
def to_configuration(convert)
result = self.class.new(self.name)
+ map = {}
vertices.each do |resource|
next if resource.respond_to?(:virtual?) and resource.virtual?
- result.add_resource resource.send(convert)
+ newres = resource.send(convert)
+
+ # We can't guarantee that resources don't munge their names
+ # (like files do with trailing slashes), so we have to keep track
+ # of what a resource got converted to.
+ map[resource.ref] = newres
+
+ result.add_resource newres
end
message = convert.to_s.gsub "_", " "
@@ -454,17 +462,19 @@ class Puppet::Node::Configuration < Puppet::PGraph
next if edge.source.respond_to?(:virtual?) and edge.source.virtual?
next if edge.target.respond_to?(:virtual?) and edge.target.virtual?
- unless source = result.resource(edge.source.ref)
- raise Puppet::DevError, "Could not find vertex for %s when converting %s" % [edge.source.ref, message]
+ unless source = map[edge.source.ref]
+ raise Puppet::DevError, "Could not find resource %s when converting %s resources" % [edge.source.ref, message]
end
- unless target = result.resource(edge.target.ref)
- raise Puppet::DevError, "Could not find vertex for %s when converting %s" % [edge.target.ref, message]
+ unless target = map[edge.target.ref]
+ raise Puppet::DevError, "Could not find resource %s when converting %s resources" % [edge.target.ref, message]
end
result.add_edge!(source, target, edge.label)
end
+ map.clear
+
result.add_class *self.classes
result.tag(*self.tags)
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index f5dd0f8dd..39a26f1fa 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -45,9 +45,6 @@ class Type
# the method name, or whether it operates on a specific type of attributes.
attr_accessor :file, :line
- # The configuration that this resource is stored in.
- attr_accessor :configuration
-
attr_writer :title
attr_writer :noop
@@ -119,6 +116,9 @@ class Type
define_method(:validate, &block)
#@validate = block
end
+
+ # The configuration that this resource is stored in.
+ attr_accessor :configuration
# create a log at specified level
def log(msg)
@@ -181,6 +181,9 @@ class Type
# If we got passed a transportable object, we just pull a bunch of info
# directly from it. This is the main object instantiation mechanism.
if hash.is_a?(Puppet::TransObject)
+ # XXX This will need to change when transobjects change to titles.
+ self.title = hash.name
+
#self[:name] = hash[:name]
[:file, :line, :tags, :configuration].each { |getter|
if hash.respond_to?(getter)
@@ -191,8 +194,6 @@ class Type
end
}
- # XXX This will need to change when transobjects change to titles.
- @title = hash.name
hash = hash.to_hash
else
if hash[:title]
diff --git a/lib/puppet/type/tidy.rb b/lib/puppet/type/tidy.rb
index f235d2e55..27456f7d6 100755
--- a/lib/puppet/type/tidy.rb
+++ b/lib/puppet/type/tidy.rb
@@ -139,7 +139,6 @@ module Puppet
type = @resource[:type] || :atime
end
- #return Integer(Time.now - stat.send(type))
return stat.send(type).to_i
end