Skip to content

Commit

Permalink
Merge pull request #6283 from MosesMendoza/PUP-7807/master/aix_remoun…
Browse files Browse the repository at this point in the history
…t_options

(PUP-7807) Add mount options on AIX remount
  • Loading branch information
adrienthebo committed Oct 16, 2017
2 parents 7a86e42 + 0948773 commit f74eb05
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 13 deletions.
33 changes: 25 additions & 8 deletions lib/puppet/provider/mount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,38 @@ def mount
def remount
#TRANSLATORS refers to remounting a file system
info _("Remounting")
if resource[:remounts] == :true
os = Facter.value(:operatingsystem)
supports_remounts = (resource[:remounts] == :true)
if supports_remounts && os == 'AIX'
remount_with_option("remount")
elsif os.match(/^(FreeBSD|DragonFly|OpenBSD)$/)
remount_with_option("update")
elsif supports_remounts
mountcmd "-o", "remount", resource[:name]
elsif ["FreeBSD", "DragonFly", "OpenBSD"].include?(Facter.value(:operatingsystem))
if self.options && !self.options.empty?
options = self.options + ",update"
else
options = "update"
end
mountcmd "-o", options, resource[:name]
else
unmount
mount
end
end

# Remount by appending the supplied param "option" to any existing explicitly
# defined options. If resource has no explicitly defined options, will mount
# with only "option".
# @param [String] option A remount option to use or append with existing options
#
def remount_with_option(option)
if using_explicit_options?
options = self.options + "," + option
else
options = option
end
mountcmd "-o", options, resource[:name]
end

def using_explicit_options?
!self.options.nil? && !self.options.empty?
end

# This only works when the mount point is synced to the fstab.
def unmount
umount(resource[:name])
Expand Down
23 changes: 18 additions & 5 deletions spec/unit/provider/mount_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,24 @@

describe Puppet::Provider::Mount, " when remounting" do

it "should use '-o remount' if the resource specifies it supports remounting" do
@mounter.stubs(:info)
@resource.stubs(:[]).with(:remounts).returns(:true)
@mounter.expects(:mountcmd).with("-o", "remount", @name)
@mounter.remount
context "if the resource supports remounting" do
context "given explicit options on AIX" do
it "should combine the options with 'remount'" do
@mounter.stubs(:info)
@mounter.stubs(:options).returns('ro')
@resource.stubs(:[]).with(:remounts).returns(:true)
Facter.expects(:value).with(:operatingsystem).returns 'AIX'
@mounter.expects(:mountcmd).with("-o", "ro,remount", @name)
@mounter.remount
end
end

it "should use '-o remount'" do
@mounter.stubs(:info)
@resource.stubs(:[]).with(:remounts).returns(:true)
@mounter.expects(:mountcmd).with("-o", "remount", @name)
@mounter.remount
end
end

it "should mount with '-o update' on OpenBSD" do
Expand Down

0 comments on commit f74eb05

Please sign in to comment.