Class: Wakame::Actor::System

Inherits:
Object
  • Object
show all
Includes:
Wakame::Actor
Defined in:
lib/wakame/actor/system.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(dev, path, opts = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/wakame/actor/system.rb', line 16

def mount(dev, path, opts={})
  Wakame.log.debug("Wakame::Actor::System.mount")
  cond = ConditionalWait.new { |c|
    c.poll {
      self.sync
      File.blockdev?(dev)
    }
  }
  cond.wait

  raise "#{dev} does not exist or not block device." unless File.blockdev?(dev)
  raise "#{path} does not exist or not directory."   unless File.directory?(path)
  
  mount_point_dev=`/bin/df "#{path}" | /usr/bin/awk 'NR==2 {print $1}'`.strip
  Wakame.log.debug("#{mount_point_dev}: #{dev}, /bin/mount | awk '$3==path {print $1}' path=\"#{path}\"")
  if mount_point_dev != dev
    Wakame.log.debug("Mounting volume: #{dev} as #{path} (with options: #{opts})")
    Wakame::Util.exec("/bin/mount #{escape_mount_opts(opts)} '#{Shellwords.shellescape(dev)}' '#{Shellwords.shellescape(path)}'")
  else
    Wakame.log.debug("Mounting EBS volume: #{dev} as #{path} (with options: #{opts})")
  end
end

#sync(count = 1) ⇒ Object



9
10
11
12
13
14
# File 'lib/wakame/actor/system.rb', line 9

def sync(count = 1)
  count.to_i.times do |i|
    Wakame.log.debug("Wakame::Actor::System.sync #{i + 1}/#{count}")
    Wakame::Util.exec("/bin/sync")
  end
end

#touch(path) ⇒ Object



47
48
49
# File 'lib/wakame/actor/system.rb', line 47

def touch(path)
  FileUtils.touch(path)
end

#umount(path) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/wakame/actor/system.rb', line 39

def umount(path)
  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