Class: Elasticsnap::FreezeFs

Inherits:
Object
  • Object
show all
Defined in:
lib/elasticsnap/freeze_fs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mount: nil, security_group: nil, ssh_user: nil) ⇒ FreezeFs

Returns a new instance of FreezeFs.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
# 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

Instance Attribute Details

#mountObject

Returns the value of attribute mount.



5
6
7
# File 'lib/elasticsnap/freeze_fs.rb', line 5

def mount
  @mount
end

#security_groupObject

Returns the value of attribute security_group.



6
7
8
# File 'lib/elasticsnap/freeze_fs.rb', line 6

def security_group
  @security_group
end

#ssh_userObject

Returns the value of attribute ssh_user.



7
8
9
# File 'lib/elasticsnap/freeze_fs.rb', line 7

def ssh_user
  @ssh_user
end

Instance Method Details

#freeze(&block) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# 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_fsObject



33
34
35
# File 'lib/elasticsnap/freeze_fs.rb', line 33

def freeze_fs
  run_command 'sudo fsfreeze', '-f', mount
end

#syncObject



29
30
31
# File 'lib/elasticsnap/freeze_fs.rb', line 29

def sync
  run_command('sudo sync')
end

#unfreeze_fsObject



37
38
39
# File 'lib/elasticsnap/freeze_fs.rb', line 37

def unfreeze_fs
  run_command 'sudo fsfreeze', '-u', mount
end