summaryrefslogtreecommitdiff
path: root/lib/chef/provider/mount
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-05-30 20:11:59 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-05-30 20:11:59 -0700
commit67294ec99faa6832d6ab99d7e905bf890900bc28 (patch)
treeb3faf423c16610a5282f7f23923ec2c43e084690 /lib/chef/provider/mount
parent57de4f18c8fa3f2e1a0760d2a2d48a35094cd407 (diff)
downloadchef-67294ec99faa6832d6ab99d7e905bf890900bc28.tar.gz
adding disable_fs unit tests
still need enable_fs unit tests
Diffstat (limited to 'lib/chef/provider/mount')
-rw-r--r--lib/chef/provider/mount/solaris.rb24
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/chef/provider/mount/solaris.rb b/lib/chef/provider/mount/solaris.rb
index a5b1d5db20..a9e2234664 100644
--- a/lib/chef/provider/mount/solaris.rb
+++ b/lib/chef/provider/mount/solaris.rb
@@ -99,7 +99,8 @@ class Chef
passstr = pass == 0 ? "-" : pass
optstr = (actual_options.nil? || actual_options.empty?) ? "-" : actual_options.join(',')
- Tempfile.open("vfstab", "etc") do |f|
+ # FIXME: permissions
+ etc_tempfile do |f|
f.write(IO.read(VFSTAB))
f.puts("#{device}\t-\t#{mount_point}\t#{fstype}\t#{passstr}\t#{autostr}\t#{optstr}")
f.close
@@ -112,7 +113,7 @@ class Chef
found = false
::File.readlines(VFSTAB).reverse_each do |line|
- if !found && line =~ /^#{device_vfstab_regex}\s+[-\/\w]+\s+#{Regexp.escape(mount_point)}/
+ if !found && line =~ /^#{device_vfstab_regex}\s+\S+\s+#{Regexp.escape(mount_point)}/
found = true
Chef::Log.debug("#{new_resource} is removed from vfstab")
next
@@ -120,13 +121,24 @@ class Chef
contents << line
end
- Tempfile.open("vfstab", "etc") do |f|
- f.write(contents.reverse)
- f.close
- FileUtils.mv f.path, VFSTAB
+ if found
+ # FIXME: permissions
+ etc_tempfile do |f|
+ f.write(contents.reverse.join(''))
+ f.close
+ FileUtils.mv f.path, VFSTAB
+ end
+ else
+ # this is likely some kind of internal error, since we should only call disable_fs when there
+ # the filesystem we want to disable is enabled.
+ Chef::Log.warn("#{new_resource} did not find the mountpoint to disable in the vfstab")
end
end
+ def etc_tempfile
+ yield Tempfile.open("vfstab", "/etc")
+ end
+
def mount_options_unchanged?
current_resource.fstype == fstype and
current_resource.options == options and