summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2018-03-22 09:56:23 +0000
committerThom May <thom@chef.io>2018-03-22 11:13:21 +0000
commit8a0926ac5069e4a0a3db37e436d7b6d3d243f19c (patch)
tree813535d73dba99eb51196facf0d65b44c602418a
parent2d28e56c536af67bb6817d3a9bfe4d2439b611f8 (diff)
downloadchef-tm/13_revert_mount_properties.tar.gz
partially revert 61e3d4bb: do not use properties for mounttm/13_revert_mount_properties
Signed-off-by: Thom May <thom@chef.io>
-rw-r--r--lib/chef/provider/mount/solaris.rb8
-rw-r--r--lib/chef/resource/mount.rb146
2 files changed, 130 insertions, 24 deletions
diff --git a/lib/chef/provider/mount/solaris.rb b/lib/chef/provider/mount/solaris.rb
index f59a2d2c6a..fc2c9483ce 100644
--- a/lib/chef/provider/mount/solaris.rb
+++ b/lib/chef/provider/mount/solaris.rb
@@ -74,8 +74,8 @@ class Chef
end
def mount_fs
- actual_options = options || []
- actual_options.delete("noauto")
+ actual_options = native_options(options)
+ actual_options.delete("-")
command = "mount -F #{fstype}"
command << " -o #{actual_options.join(',')}" unless actual_options.empty?
command << " #{device} #{mount_point}"
@@ -88,8 +88,8 @@ class Chef
def remount_fs
# FIXME: Should remount always do the remount or only if the options change?
- actual_options = options || []
- actual_options.delete("noauto")
+ actual_options = native_options(options)
+ actual_options.delete("-")
mount_options = actual_options.empty? ? "" : ",#{actual_options.join(',')}"
shell_out!("mount -o remount#{mount_options} #{mount_point}")
end
diff --git a/lib/chef/resource/mount.rb b/lib/chef/resource/mount.rb
index 2b1a93becb..1a1f8c0565 100644
--- a/lib/chef/resource/mount.rb
+++ b/lib/chef/resource/mount.rb
@@ -24,37 +24,143 @@ class Chef
# Use the mount resource to manage a mounted file system.
class Mount < Chef::Resource
+ identity_attr :device
+
+ state_attrs :mount_point, :device_type, :fstype, :username, :password, :domain
+
default_action :mount
allowed_actions :mount, :umount, :unmount, :remount, :enable, :disable
# this is a poor API please do not re-use this pattern
- property :supports, Hash,
- default: lazy { { remount: false } },
- coerce: proc { |x| x.is_a?(Array) ? x.each_with_object({}) { |i, m| m[i] = true } : x }
+ property :supports, Hash, default: lazy { { remount: false } },
+ coerce: proc { |x| x.is_a?(Array) ? x.each_with_object({}) { |i, m| m[i] = true } : x }
property :password, String, sensitive: true
- property :mount_point, String, name_property: true
- property :device, String, identity: true
+ def initialize(name, run_context = nil)
+ super
+ @mount_point = name
+ @device = nil
+ @device_type = :device
+ @fsck_device = "-"
+ @fstype = "auto"
+ @options = ["defaults"]
+ @dump = 0
+ @pass = 2
+ @mounted = false
+ @enabled = false
+ @username = nil
+ @password = nil
+ @domain = nil
+ end
+
+ def mount_point(arg = nil)
+ set_or_return(
+ :mount_point,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def device(arg = nil)
+ set_or_return(
+ :device,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def device_type(arg = nil)
+ real_arg = arg.kind_of?(String) ? arg.to_sym : arg
+ valid_devices = if RUBY_PLATFORM =~ /solaris/i
+ [ :device ]
+ else
+ [ :device, :label, :uuid ]
+ end
+ set_or_return(
+ :device_type,
+ real_arg,
+ :equal_to => valid_devices
+ )
+ end
+
+ def fsck_device(arg = nil)
+ set_or_return(
+ :fsck_device,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def fstype(arg = nil)
+ set_or_return(
+ :fstype,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
+
+ def options(arg = nil)
+ ret = set_or_return(
+ :options,
+ arg,
+ :kind_of => [ Array, String ]
+ )
+
+ if ret.is_a? String
+ ret.tr(",", " ").split(/ /)
+ else
+ ret
+ end
+ end
+
+ def dump(arg = nil)
+ set_or_return(
+ :dump,
+ arg,
+ :kind_of => [ Integer, FalseClass ]
+ )
+ end
- property :device_type, [String, Symbol],
- coerce: proc { |arg| arg.kind_of?(String) ? arg.to_sym : arg },
- default: :device,
- equal_to: RUBY_PLATFORM =~ /solaris/i ? %i{ device } : %i{ device label uuid }
+ def pass(arg = nil)
+ set_or_return(
+ :pass,
+ arg,
+ :kind_of => [ Integer, FalseClass ]
+ )
+ end
+
+ def mounted(arg = nil)
+ set_or_return(
+ :mounted,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
- property :fsck_device, [String, nil], default: "-"
- property :fstype, [String, nil], default: "auto"
+ def enabled(arg = nil)
+ set_or_return(
+ :enabled,
+ arg,
+ :kind_of => [ TrueClass, FalseClass ]
+ )
+ end
- property :options, [Array, String, nil],
- coerce: proc { |arg| arg.kind_of?(String) ? arg.split(",") : arg },
- default: %w{defaults}
+ def username(arg = nil)
+ set_or_return(
+ :username,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
- property :dump, [Integer, FalseClass, nil], default: 0
- property :pass, [Integer, FalseClass, nil], default: 2
- property :mounted, [TrueClass, FalseClass], default: false
- property :enabled, [TrueClass, FalseClass], default: false
- property :username, String
- property :domain, String
+ def domain(arg = nil)
+ set_or_return(
+ :domain,
+ arg,
+ :kind_of => [ String ]
+ )
+ end
private