summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorlutter <lutter@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-30 01:43:02 +0000
committerlutter <lutter@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-30 01:43:02 +0000
commit9bb9e1062a7bf747d1972d69eca9f00d2c0bd030 (patch)
tree07d69e7b1cba6f10cbf84e300bb4f7a36058ac20 /lib
parentf792a02aa153eedf5293791daaf355232f357cc4 (diff)
downloadpuppet-9bb9e1062a7bf747d1972d69eca9f00d2c0bd030.tar.gz
puppet-9bb9e1062a7bf747d1972d69eca9f00d2c0bd030.tar.xz
puppet-9bb9e1062a7bf747d1972d69eca9f00d2c0bd030.zip
Fix a small bug in mount where parsing fails if dump and pass are missing (they are optional on Linux) Revamp the tests slightly so that they parse fstabs provided in svn rather than relying on the fstab on the system the test is running on.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1343 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rwxr-xr-xlib/puppet/type/parsedtype/mount.rb75
1 files changed, 45 insertions, 30 deletions
diff --git a/lib/puppet/type/parsedtype/mount.rb b/lib/puppet/type/parsedtype/mount.rb
index 69254e1b6..f21348131 100755
--- a/lib/puppet/type/parsedtype/mount.rb
+++ b/lib/puppet/type/parsedtype/mount.rb
@@ -103,37 +103,47 @@ module Puppet
@doc = "Manages mounted mounts, including putting mount
information into the mount table."
- @instances = []
-
- @platform = Facter["operatingsystem"].value
- case @platform
- when "Solaris":
- @path = "/etc/vfstab"
- @fields = [:device, :blockdevice, :path, :fstype, :pass, :atboot,
- :options]
- when "Darwin":
- @filetype = Puppet::FileType.filetype(:netinfo)
- @filetype.format = "fstab"
- @path = "mounts"
- @fields = [:device, :path, :fstype, :options, :dump, :pass]
-
- # How to map the dumped table to what we want
- @fieldnames = {
- "name" => :device,
- "dir" => :path,
- "dump_freq" => :dump,
- "passno" => :pass,
- "vfstype" => :fstype,
- "opts" => :options
- }
- else
- @path = "/etc/fstab"
- @fields = [:device, :path, :fstype, :options, :dump, :pass]
+ def self.init
+ @platform = Facter["operatingsystem"].value
+ case @platform
+ when "Solaris":
+ @path = "/etc/vfstab"
+ @fields = [:device, :blockdevice, :path, :fstype, :pass, :atboot,
+ :options]
+ @defaults = [ nil ] * @fields.size
+ when "Darwin":
+ @filetype = Puppet::FileType.filetype(:netinfo)
+ @filetype.format = "fstab"
+ @path = "mounts"
+ @fields = [:device, :path, :fstype, :options, :dump, :pass]
+ @defaults = [ nil ] * @fields.size
+
+ # How to map the dumped table to what we want
+ @fieldnames = {
+ "name" => :device,
+ "dir" => :path,
+ "dump_freq" => :dump,
+ "passno" => :pass,
+ "vfstype" => :fstype,
+ "opts" => :options
+ }
+ else
+ @path = "/etc/fstab"
+ @fields = [:device, :path, :fstype, :options, :dump, :pass]
+ @defaults = [ nil ] * 4 + [ "0" ] * 2
+ end
+
+ # Allow Darwin to override the default filetype
+ unless defined? @filetype
+ @filetype = Puppet::FileType.filetype(:flat)
+ end
end
- # Allow Darwin to override the default filetype
- unless defined? @filetype
- @filetype = Puppet::FileType.filetype(:flat)
+ init
+
+ def self.clear
+ init
+ super
end
# Parse a mount tab.
@@ -156,10 +166,15 @@ module Puppet
comment(line)
else
values = line.split(/\s+/)
- unless @fields.length == values.length
+ if @fields.length < values.length
raise Puppet::Error, "Could not parse line %s" % line
end
+ values = @defaults.zip(values).collect { |d, v| v || d }
+ unless @fields.length == values.length
+ raise Puppet::Error, "Could not parse line %s" % line
+ end
+
@fields.zip(values).each do |field, value|
hash[field] = value
end