diff options
author | NAshwini <ashwini.nehate@msystechnologies.com> | 2017-07-06 01:40:48 +0530 |
---|---|---|
committer | Bryan McLellan <btm@loftninjas.org> | 2017-07-05 16:10:48 -0400 |
commit | ae4d04bbe366199e4597b375b43c254d0117c989 (patch) | |
tree | 98c553435578d40b9e272bd3dbfbf08be717bec3 /lib | |
parent | e419d7f0eb0c494a0a2f5d5963eac6fb35153bac (diff) | |
download | chef-ae4d04bbe366199e4597b375b43c254d0117c989.tar.gz |
[MSYS-590] Make mount idempotent on Aix (#6213)
* Make mount idempotent on Aix
Signed-off-by: NAshwini <ashwini.nehate@msystechnologies.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/provider/mount/aix.rb | 57 |
1 files changed, 49 insertions, 8 deletions
diff --git a/lib/chef/provider/mount/aix.rb b/lib/chef/provider/mount/aix.rb index 73460e84a1..ef760b0ba6 100644 --- a/lib/chef/provider/mount/aix.rb +++ b/lib/chef/provider/mount/aix.rb @@ -40,30 +40,60 @@ class Chef # Check to see if there is an entry in /etc/filesystems. Last entry for a volume wins. Using command "lsfs" to fetch entries. enabled = false + regex_arr = device_fstab_regex.split(":") + if regex_arr.size.eql?(2) + nodename = regex_arr[0] + devicename = regex_arr[1] + else + devicename = regex_arr[0] + end # lsfs o/p = #MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct # search only for current mount point shell_out("lsfs -c #{@new_resource.mount_point}").stdout.each_line do |line| case line when /^#\s/ next - when /^#{Regexp.escape(@new_resource.mount_point)}:#{device_fstab_regex}:(\S+):(\[\S+\])?:(\S+)?:(\S+):(\S+):(\S+):(\S+)/ + when /^#{Regexp.escape(@new_resource.mount_point)}:#{devicename}:(\S+):#{nodename}:(\S+)?:(\S+):(\S+):(\S+):(\S+)/ # mount point entry with ipv6 address for nodename (ipv6 address use ':') enabled = true @current_resource.fstype($1) - @current_resource.options($5) - Chef::Log.debug("Found mount #{device_fstab} to #{@new_resource.mount_point} in /etc/filesystems") + @current_resource.options($4) + Chef::Log.debug("Found mount point #{@new_resource.mount_point} :: device_type #{@current_resource.device_type} in /etc/filesystems") next - when /^#{Regexp.escape(@new_resource.mount_point)}:#{device_fstab_regex}::(\S+):(\S+)?:(\S+)?:(\S+):(\S+):(\S+):(\S+)/ + when /^#{Regexp.escape(@new_resource.mount_point)}:#{nodename}:(\S+)::(\S+)?:(\S+):(\S+):(\S+):(\S+)/ # mount point entry with hostname or ipv4 address enabled = true @current_resource.fstype($1) + @current_resource.options($4) + @current_resource.device("") + Chef::Log.debug("Found mount point #{@new_resource.mount_point} :: device_type #{@current_resource.device_type} in /etc/filesystems") + next + when /^#{Regexp.escape(@new_resource.mount_point)}:(\S+)?:(\S+):#{devicename}:(\S+)?:(\S+):(\S+):(\S+):(\S+)/ + # mount point entry with hostname or ipv4 address + enabled = true + @current_resource.fstype($2) @current_resource.options($5) - Chef::Log.debug("Found mount #{device_fstab} to #{@new_resource.mount_point} in /etc/filesystems") + @current_resource.device(devicename + "/") + Chef::Log.debug("Found mount point #{@new_resource.mount_point} :: device_type #{@current_resource.device_type} in /etc/filesystems") next - when /^#{Regexp.escape(@new_resource.mount_point)}/ - enabled = false - Chef::Log.debug("Found conflicting mount point #{@new_resource.mount_point} in /etc/filesystems") + when /^#{Regexp.escape(@new_resource.mount_point)}:(.*?):(.*?):(.*?):(.*?):(.*?):(.*?):(.*?):(.*?)/ + if $3.split("=")[0].eql?("LABEL") || $1.split("=")[0].eql?("LABEL") + @current_resource.device_type("label") + elsif $3.split("=")[0].eql?("UUID") || $1.split("=")[0].eql?("UUID") + @current_resource.device_type("uuid") + else + @current_resource.device_type("device") + end + + if @current_resource.device_type != @new_resource.device_type + enabled = true + Chef::Log.debug("Found mount point #{@new_resource.mount_point} :: device_type #{@current_resource.device_type} in /etc/filesystems") + else + enabled = false + Chef::Log.debug("Found conflicting mount point #{@new_resource.mount_point} in /etc/filesystems") + end end + end @current_resource.enabled(enabled) end @@ -149,6 +179,17 @@ class Chef end end + def mount_options_unchanged? + current_resource_options = @current_resource.options.delete_if { |x| x == "rw" } + + @current_resource.device == @new_resource.device && + @current_resource.fsck_device == @new_resource.fsck_device && + @current_resource.fstype == @new_resource.fstype && + current_resource_options == @new_resource.options && + @current_resource.dump == @new_resource.dump && + @current_resource.pass == @new_resource.pass + end + def disable_fs contents = [] if @current_resource.enabled |