class Elasticsnap::FreezeFs
Attributes
mount[RW]
security_group[RW]
ssh_user[RW]
Public Class Methods
new(mount: nil, security_group: nil, ssh_user: nil)
click to toggle source
# File lib/elasticsnap/freeze_fs.rb, line 9 def initialize(mount: nil, security_group: nil, ssh_user: nil) raise ArgumentError, 'mount required' if mount.nil? raise ArgumentError, 'security_group required' if security_group.nil? @mount = mount @security_group = security_group @ssh_user = ssh_user end
Public Instance Methods
freeze(&block)
click to toggle source
# File lib/elasticsnap/freeze_fs.rb, line 18 def freeze(&block) begin sync freeze_fs block.call unless block.nil? ensure unfreeze_fs end end
freeze_fs()
click to toggle source
# File lib/elasticsnap/freeze_fs.rb, line 33 def freeze_fs run_command 'sudo fsfreeze', '-f', mount end
sync()
click to toggle source
# File lib/elasticsnap/freeze_fs.rb, line 29 def sync run_command('sudo sync') end
unfreeze_fs()
click to toggle source
# File lib/elasticsnap/freeze_fs.rb, line 37 def unfreeze_fs run_command 'sudo fsfreeze', '-u', mount end
Private Instance Methods
capistrano_config()
click to toggle source
# File lib/elasticsnap/freeze_fs.rb, line 51 def capistrano_config @cap_config ||= Capistrano::Configuration.new end
run_command(*command)
click to toggle source
# File lib/elasticsnap/freeze_fs.rb, line 42 def run_command(*command) stream(*command) end
stream(*command)
click to toggle source
# File lib/elasticsnap/freeze_fs.rb, line 46 def stream(*command) command = [command].flatten.join(' ') capistrano_config.stream(command, hosts: SecurityGroup.new(name: security_group).ssh_hosts(ssh_user: ssh_user)) end