From 2252c6a3147465dd35b0965580d4215a507359b4 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Fri, 23 May 2014 14:08:47 -0700 Subject: turn mountable? into define_resource_requirements --- lib/chef/provider/mount/solaris.rb | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'lib/chef/provider/mount') diff --git a/lib/chef/provider/mount/solaris.rb b/lib/chef/provider/mount/solaris.rb index fdcea7501f..f39e4034c2 100644 --- a/lib/chef/provider/mount/solaris.rb +++ b/lib/chef/provider/mount/solaris.rb @@ -1,11 +1,8 @@ -# Author:: Hugo Fichter -# Based on previous work from Joshua Timberman -# (See original header below) -# License:: Apache License, Version 2.0 - # -# Author:: Joshua Timberman () -# Copyright:: Copyright (c) 2009 Opscode, Inc +# Author:: Hugo Fichter +# Author:: Lamont Granquist () +# Author:: Joshua Timberman () +# Copyright:: Copyright (c) 2009-2014 Opscode, Inc # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -46,10 +43,23 @@ class Chef current_resource.enabled(enabled?) end + def define_resource_requirements do + requirements.assert(:mount, :remount) do |a| + a.assertion { !device_should_exist? || ::File.exists?(new_resource.device) } + a.failure_message(Chef::Exceptions::Mount, "Device #{new_resource.device} does not exist") + a.whyrun("Assuming device #{new_resource.device} would have been created") + end + + requirements.assert(:mount, :remount) do |a| + a.assertion { ::File.exists?(new_resource.mount_point) } + a.failure_message(Chef::Exceptions::Mount, "Mount point #{new_resource.mount_point} does not exist") + a.whyrun("Assuming mount point #{new_resource.mount_point} would have been created") + end + end + protected def mount_fs - mountable? actual_options = unless new_resource.options.nil? new_resource.options(new_resource.options.delete("noauto")) end @@ -114,17 +124,6 @@ class Chef private - # FIXME: should be mountable! and probably should be in define_resource_requirements - def mountable? - # only check for existence of non-remote devices - if (device_should_exist? && !::File.exists?(new_resource.device) ) - raise Chef::Exceptions::Mount, "Device #{new_resource.device} does not exist" - elsif( !::File.exists?(new_resource.mount_point) ) - raise Chef::Exceptions::Mount, "Mount point #{new_resource.mount_point} does not exist" - end - true - end - def enabled? # Check to see if there is a entry in /etc/vfstab. Last entry for a volume wins. enabled = false -- cgit v1.2.1