Included Modules

Files

Class/Module Index [+]

Quicksearch

Chef::Provider::Mount::Solaris

Constants

VFSTAB

Public Instance Methods

define_resource_requirements() click to toggle source
# File lib/chef/provider/mount/solaris.rb, line 51
def define_resource_requirements
  requirements.assert(:mount, :remount) do |a|
    a.assertion { !device_should_exist? || ::File.exist?(device) }
    a.failure_message(Chef::Exceptions::Mount, "Device #{device} does not exist")
    a.whyrun("Assuming device #{device} would have been created")
  end

  requirements.assert(:mount, :remount) do |a|
    a.assertion { ::File.exist?(mount_point) }
    a.failure_message(Chef::Exceptions::Mount, "Mount point #{mount_point} does not exist")
    a.whyrun("Assuming mount point #{mount_point} would have been created")
  end
end
disable_fs() click to toggle source
# File lib/chef/provider/mount/solaris.rb, line 111
def disable_fs
  contents = []

  found = false
  ::File.readlines(VFSTAB).reverse_each do |line|
    if !found && line =~ /^#{device_regex}\s+\S+\s+#{Regexp.escape(mount_point)}/
      found = true
      Chef::Log.debug("#{new_resource} is removed from vfstab")
      next
    end
    contents << line
  end

  if found
    etc_tempfile do |f|
      f.write(contents.reverse.join(''))
      f.close
      # move, preserving modes of destination file
      mover = Chef::FileContentManagement::Deploy.strategy(true)
      mover.deploy(f.path, VFSTAB)
    end
  else
    # this is likely some kind of internal error, since we should only call disable_fs when there
    # the filesystem we want to disable is enabled.
    Chef::Log.warn("#{new_resource} did not find the mountpoint to disable in the vfstab")
  end
end
enable_fs() click to toggle source
# File lib/chef/provider/mount/solaris.rb, line 83
def enable_fs
  if !mount_options_unchanged?
    # we are enabling because our options have changed, so disable first then re-enable.
    # XXX: this should be refactored to be the responsibility of the caller
    disable_fs if current_resource.enabled
  end

  auto = options.nil? || ! options.include?("noauto")
  actual_options = unless options.nil?
                     options.delete("noauto")
                     options
                   end

  autostr = auto ? 'yes' : 'no'
  passstr = pass == 0 ? "-" : pass
  optstr = (actual_options.nil? || actual_options.empty?) ? "-" : actual_options.join(',')

  etc_tempfile do |f|
    f.write(IO.read(VFSTAB).chomp)
    f.puts("\n#{device}\t-\t#{mount_point}\t#{fstype}\t#{passstr}\t#{autostr}\t#{optstr}")
    f.close
    # move, preserving modes of destination file
    mover = Chef::FileContentManagement::Deploy.strategy(true)
    mover.deploy(f.path, VFSTAB)
  end

end
enabled?() click to toggle source
# File lib/chef/provider/mount/solaris.rb, line 159
def enabled?
  read_vfstab_status[0]
end
etc_tempfile() click to toggle source
# File lib/chef/provider/mount/solaris.rb, line 139
def etc_tempfile
  yield Tempfile.open("vfstab", "/etc")
end
load_current_resource() click to toggle source
# File lib/chef/provider/mount/solaris.rb, line 43
def load_current_resource
  @current_resource = Chef::Resource::Mount.new(new_resource.name)
  current_resource.mount_point(mount_point)
  current_resource.device(device)
  current_resource.device_type(device_type)
  update_current_resource_state
end
mount_fs() click to toggle source
# File lib/chef/provider/mount/solaris.rb, line 65
def mount_fs
  actual_options = options || []
  actual_options.delete("noauto")
  command = "mount -F #{fstype}"
  command << " -o #{actual_options.join(',')}" unless actual_options.empty?
  command << " #{device} #{mount_point}"
  shell_out!(command)
end
mount_options_unchanged?() click to toggle source
# File lib/chef/provider/mount/solaris.rb, line 143
def mount_options_unchanged?
  current_resource.fstype == fstype and
    current_resource.options == options and
    current_resource.dump == dump and
    current_resource.pass == pass
end
mounted?() click to toggle source
# File lib/chef/provider/mount/solaris.rb, line 163
def mounted?
  mounted = false
  shell_out!("mount -v").stdout.each_line do |line|
    # <device> on <mountpoint> type <fstype> <options> on <date>
    # /dev/dsk/c1t0d0s0 on / type ufs read/write/setuid/devices/intr/largefiles/logging/xattr/onerror=panic/dev=700040 on Tue May  1 11:33:55 2012
    case line
    when /^#{device_regex}\s+on\s+#{Regexp.escape(mount_point)}\s+/
      Chef::Log.debug("Special device #{device} is mounted as #{mount_point}")
      mounted = true
    when /^([\/\w]+)\son\s#{Regexp.escape(mount_point)}\s+/
      Chef::Log.debug("Special device #{$1} is mounted as #{mount_point}")
      mounted = false
    end
  end
  mounted
end
remount_fs() click to toggle source
# File lib/chef/provider/mount/solaris.rb, line 78
def remount_fs
  # FIXME: what about options like "-o remount,logging" to enable logging on a UFS device?
  shell_out!("mount -o remount #{mount_point}")
end
umount_fs() click to toggle source
# File lib/chef/provider/mount/solaris.rb, line 74
def umount_fs
  shell_out!("umount #{mount_point}")
end
update_current_resource_state() click to toggle source
# File lib/chef/provider/mount/solaris.rb, line 150
def update_current_resource_state
  current_resource.mounted(mounted?)
  ( enabled, fstype, options, pass ) = read_vfstab_status
  current_resource.enabled(enabled)
  current_resource.fstype(fstype)
  current_resource.options(options)
  current_resource.pass(pass)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.