Class: Wakame::Actor::S3fs

Inherits:
Object
  • Object
show all
Includes:
Wakame::Actor
Defined in:
lib/wakame/actor/s3fs.rb

Constant Summary

Constants included from Wakame::Actor

STATUS_CANCELED, STATUS_FAILED, STATUS_RUNNING, STATUS_SUCCESS

Instance Method Summary collapse

Methods included from Wakame::Actor

included

Instance Method Details

#mount(bucket, path, opts = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/wakame/actor/s3fs.rb', line 8

def mount(bucket, path, opts={})
  Wakame.log.debug("Wakame::Actor::S3fs.mount")
  #return
  raise "#{path} does not exist or not directory." unless File.directory?(path)
  #  's3fs' or '/dev/xxx' ?
  mount_point_dev=`/bin/df "#{path}" | /usr/bin/awk 'NR==2 {print $1}'`.strip
  Wakame.log.debug("#{mount_point_dev}: #{bucket}, /bin/mount | awk '$3==path {print $1}' path=\"#{path}\"")

  if mount_point_dev != 's3fs'
    Wakame.log.debug("Mounting volume: #{bucket} as #{path} (with options: #{opts})")
    Wakame::Util.exec("/usr/local/sbin/s3fs #{escape_mount_opts(opts)} '#{Shellwords.shellescape(bucket)}' '#{Shellwords.shellescape(path)}'")
  else
    Wakame.log.debug("Mounting s3fs bucket: #{bucket} as #{path} (with options: #{opts})")
  end
end

#umount(path) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/wakame/actor/s3fs.rb', line 24

def umount(path)
  Wakame.log.debug("Wakame::Actor::S3fs.umount")
  #return
  raise "#{path} does not exist or not directory." unless File.directory?(path)

  mount_point_dev=`/bin/df "#{path}" | awk 'NR==2 {print $1}'`
  Wakame.log.debug("Unmounting volume: #{mount_point_dev} on #{path}")
  Wakame::Util.exec("/bin/umount '#{Shellwords.shellescape(path)}'")
end