Class: Chef::Provider::Mount

Inherits:
Chef::Provider show all
Includes:
Mixin::Command
Defined in:
lib/chef/provider/mount.rb,
lib/chef/provider/mount/mount.rb,
lib/chef/provider/mount/windows.rb

Direct Known Subclasses

Mount, Windows

Defined Under Namespace

Classes: Mount, Windows

Instance Attribute Summary

Attributes inherited from Chef::Provider

#action, #current_resource, #new_resource, #run_context

Instance Method Summary collapse

Methods included from Mixin::Command

#chdir_or_tmpdir, #handle_command_failures, #output_of_command, #run_command, #run_command_with_systems_locale

Methods included from Mixin::Command::Windows

#popen4

Methods included from Mixin::Command::Unix

#popen4

Methods inherited from Chef::Provider

#action_nothing, #cleanup_after_converge, #cookbook_name, #define_resource_requirements, #events, #initialize, #node, #process_resource_requirements, #requirements, #resource_collection, #run_action, #set_updated_status, #whyrun_mode?

Methods included from DSL::Recipe

#method_missing

Methods included from Mixin::ConvertToClassName

#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #snake_case_basename

Constructor Details

This class inherits a constructor from Chef::Provider

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Chef::DSL::Recipe

Instance Method Details

#action_disableObject



94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/chef/provider/mount.rb', line 94

def action_disable
  if @current_resource.enabled
    converge_by("remount #{@current_resource.device}") do 
      status = disable_fs
      if status
        Chef::Log.info("#{@new_resource} disabled")
      else
        Chef::Log.debug("#{@new_resource} already disabled")
      end
    end
  end
end

#action_enableObject



81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/chef/provider/mount.rb', line 81

def action_enable
  unless @current_resource.enabled
    converge_by("remount #{@current_resource.device}") do 
      status = enable_fs
      if status
        Chef::Log.info("#{@new_resource} enabled")
      else
        Chef::Log.debug("#{@new_resource} already enabled")
      end
    end
  end
end

#action_mountObject



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/chef/provider/mount.rb', line 38

def action_mount
  unless @current_resource.mounted
    converge_by("mount #{@current_resource.device} to #{@current_resource.mount_point}") do 
      status = mount_fs()
      if status
        Chef::Log.info("#{@new_resource} mounted")
      end
    end
  else
    Chef::Log.debug("#{@new_resource} is already mounted")
  end
end

#action_remountObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/chef/provider/mount.rb', line 64

def action_remount
  unless @new_resource.supports[:remount]
    raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :remount"
  else
    if @current_resource.mounted
      converge_by("remount #{@current_resource.device}") do 
        status = remount_fs()
        if status
          Chef::Log.info("#{@new_resource} remounted")
        end
      end
    else
      Chef::Log.debug("#{@new_resource} not mounted, nothing to remount")
    end
  end
end

#action_umountObject



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/chef/provider/mount.rb', line 51

def action_umount
  if @current_resource.mounted
    converge_by("unmount #{@current_resource.device}") do 
      status = umount_fs()
      if status
        Chef::Log.info("#{@new_resource} unmounted")
      end
    end
  else
    Chef::Log.debug("#{@new_resource} is already unmounted")
  end
end

#disable_fsObject



123
124
125
# File 'lib/chef/provider/mount.rb', line 123

def disable_fs
  raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :disable"        
end

#enable_fsObject



119
120
121
# File 'lib/chef/provider/mount.rb', line 119

def enable_fs
  raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :enable"        
end

#load_current_resourceObject



34
35
36
# File 'lib/chef/provider/mount.rb', line 34

def load_current_resource
  true
end

#mount_fsObject



107
108
109
# File 'lib/chef/provider/mount.rb', line 107

def mount_fs
  raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :mount"
end

#remount_fsObject



115
116
117
# File 'lib/chef/provider/mount.rb', line 115

def remount_fs
  raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :remount"
end

#umount_fsObject



111
112
113
# File 'lib/chef/provider/mount.rb', line 111

def umount_fs
  raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :umount"
end

#whyrun_supported?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/chef/provider/mount.rb', line 30

def whyrun_supported?
  true
end