# class Chef::Provider::Mount::Windows

### Public Class Methods

new(new_resource, run_context) click to toggle source
Calls superclass method Chef::Provider.new

    # File lib/chef/provider/mount/windows.rb, line 34
    def initialize(new_resource, run_context)
      super
      @mount = nil
    end

### Public Instance Methods

is_volume(name) click to toggle source

    # File lib/chef/provider/mount/windows.rb, line 30
    def is_volume(name)
      name =~ /^\\\?\Volume\{[\w-]+\}\$/ ? true : false
    end

load_current_resource() click to toggle source

    # File lib/chef/provider/mount/windows.rb, line 39
    def load_current_resource
      if is_volume(@new_resource.device)
        @mount = Chef::Util::Windows::Volume.new(@new_resource.name)
      else #assume network drive
        @mount = Chef::Util::Windows::NetUse.new(@new_resource.name)
      end

      @current_resource = Chef::Resource::Mount.new(@new_resource.name)
      @current_resource.mount_point(@new_resource.mount_point)
      Chef::Log.debug("Checking for mount point #{@current_resource.mount_point}")

      begin
        @current_resource.device(@mount.device)
        Chef::Log.debug("#{@current_resource.device} mounted on #{@new_resource.mount_point}")
        @current_resource.mounted(true)
      rescue ArgumentError => e
        @current_resource.mounted(false)
        Chef::Log.debug("#{@new_resource.mount_point} is not mounted: #{e.message}")
      end
    end

mount_fs() click to toggle source

    # File lib/chef/provider/mount/windows.rb, line 60
    def mount_fs
      unless @current_resource.mounted
        @mount.add(:remote => @new_resource.device,
                   :username => @new_resource.username,
                   :domainname => @new_resource.domain,
                   :password => @new_resource.password)
        Chef::Log.debug("#{@new_resource} is mounted at #{@new_resource.mount_point}")
      else
        Chef::Log.debug("#{@new_resource} is already mounted at #{@new_resource.mount_point}")
      end
    end

umount_fs() click to toggle source

    # File lib/chef/provider/mount/windows.rb, line 72
    def umount_fs
      if @current_resource.mounted
        @mount.delete
        Chef::Log.debug("#{@new_resource} is no longer mounted at #{@new_resource.mount_point}")
      else
        Chef::Log.debug("#{@new_resource} is not mounted at #{@new_resource.mount_point}")
      end
    end