diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-02-28 20:11:51 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-02-28 20:11:51 +0000 |
| commit | 6d8a1dc1af819950e5c8edf1b70acefd540d3695 (patch) | |
| tree | 53b09cecbba80414c1ff74eb3797f087cdf00f9a | |
| parent | 65ed766a6118e1ceac7f9abbabfa44a7a46cf662 (diff) | |
| download | puppet-6d8a1dc1af819950e5c8edf1b70acefd540d3695.tar.gz puppet-6d8a1dc1af819950e5c8edf1b70acefd540d3695.tar.xz puppet-6d8a1dc1af819950e5c8edf1b70acefd540d3695.zip | |
Fixing user and group management in the config handling.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@960 980ebf18-57e1-0310-9a29-db15c13687c0
| -rw-r--r-- | lib/puppet/config.rb | 40 | ||||
| -rwxr-xr-x | test/other/config.rb | 26 |
2 files changed, 47 insertions, 19 deletions
diff --git a/lib/puppet/config.rb b/lib/puppet/config.rb index b8a41ca4d..aeaa218ce 100644 --- a/lib/puppet/config.rb +++ b/lib/puppet/config.rb @@ -290,38 +290,44 @@ class Config def section_to_transportable(section, done) objects = [] persection(section) { |obj| - [:owner, :group].each { |type| - if obj.respond_to? type and val = obj.send(type) + [:owner, :group].each { |attr| + type = nil + if attr == :owner + type = :user + else + type = attr + end + if obj.respond_to? attr and name = obj.send(attr) # Skip owners and groups we've already done, but tag them with # our section if necessary - if done[type].include?(val) - next unless defined? @section and @section - - tags = done[type][val].tags - unless tags.include?(@section) - done[type][val].tags = tags << @section + if done[type].include?(name) + tags = done[type][name].tags + unless tags.include?(section) + done[type][name].tags = tags << section end + elsif newobj = Puppet::Type.type(type)[name] + newobj.tag(section) else - newobj = TransObject.new(val, type.to_s) - newobj[:ensure] = "exists" - done[type] << newobj + newobj = TransObject.new(name, type.to_s) + newobj[:ensure] = "present" + done[type][name] = newobj + objects << newobj end end } if obj.respond_to? :to_transportable - unless done[:file].include? obj.value + unless done[:file].include? obj.name trans = obj.to_transportable # transportable could return nil next unless trans objects << trans - done[:file] << obj.value + done[:file][obj.name] = obj end end } bucket = Puppet::TransBucket.new - bucket.name = "autosection-%s" % bucket.object_id bucket.type = section bucket.push(*objects) bucket.keyword = "class" @@ -384,10 +390,8 @@ Generated on #{Time.now}. # Convert our configuration into a list of transportable objects. def to_transportable - done = { - :owner => [], - :group => [], - :file => [] + done = Hash.new { |hash, key| + hash[key] = {} } topbucket = Puppet::TransBucket.new diff --git a/test/other/config.rb b/test/other/config.rb index 60cb01ba7..276dcf2f3 100755 --- a/test/other/config.rb +++ b/test/other/config.rb @@ -12,6 +12,13 @@ require 'test/unit' class TestConfig < Test::Unit::TestCase include TestPuppet + def check_for_users + count = Puppet::Type.type(:user).inject(0) { |c,o| + c + 1 + } + assert(count > 0, "Found no users") + end + def check_to_transportable(config) trans = nil assert_nothing_raised("Could not convert to a transportable") { @@ -23,6 +30,8 @@ class TestConfig < Test::Unit::TestCase comp = trans.to_type } + check_for_users() + assert_nothing_raised("Could not retrieve transported config") { comp.retrieve } @@ -37,10 +46,23 @@ class TestConfig < Test::Unit::TestCase Puppet[:parseonly] = true parser = Puppet::Parser::Parser.new() + objects = nil assert_nothing_raised("Could not parse generated manifest") { parser.string = manifest - parser.parse + objects = parser.parse + } + scope = Puppet::Parser::Scope.new + assert_nothing_raised("Could not compile objects") { + scope.evaluate(:ast => objects) } + trans = nil + assert_nothing_raised("Could not convert objects to transportable") { + trans = scope.to_trans + } + assert_nothing_raised("Could not instantiate objects") { + trans.to_type + } + check_for_users() end def check_to_comp(config) @@ -52,6 +74,8 @@ class TestConfig < Test::Unit::TestCase assert_nothing_raised("Could not retrieve component") { comp.retrieve } + + check_for_users() end def check_to_config(config) |
