Class: Synco::Methods::ZFS

Inherits:
Synco::Method show all
Defined in:
lib/synco/methods/zfs.rb

Instance Attribute Summary

Attributes inherited from Synco::Method

#arguments, #options

Attributes inherited from Controller

#events

Instance Method Summary collapse

Methods inherited from Synco::Method

#initialize

Methods inherited from Controller

#abort!, build, #fire, #freeze, #initialize, #on, #try

Constructor Details

This class inherits a constructor from Synco::Method

Instance Method Details

#call(scope, arguments: []) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/synco/methods/zfs.rb', line 30

def call(scope, arguments: [])
  from_server = scope.current_server
  master_server = scope.master_server
  target_server = scope.target_server
  directory = scope.directory
  
  send_command = [
    *@command,
    "send",
    master_server.full_path(directory)
  ]
  
  receive_command = [
    *@command,
    "receive",
    target_server.full_path(directory)
  ]
  
  input, output = IO.pipe
  
  Fiber.new do
    master_server.run(*send_command, out: output, from: from_server)
    output.close
  end.resume
  
  target_server.run(*receive_command, in: input, from: from_server)
  input.close
end

#default_commandObject



26
27
28
# File 'lib/synco/methods/zfs.rb', line 26

def default_command
  ['zfs', '-rnv']
end