Class: Vagrant::Syncer::Command::Rsync

Inherits:
Object
  • Object
show all
Includes:
Action::Builtin::MixinSyncedFolders
Defined in:
lib/syncer/command/rsync.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.synopsisObject



13
14
15
# File 'lib/syncer/command/rsync.rb', line 13

def self.synopsis
  "syncs rsync synced folders to remote machine"
end

Instance Method Details

#executeObject



17
18
19
20
21
22
23
24
25
26
27
28
29
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
# File 'lib/syncer/command/rsync.rb', line 17

def execute
  opts = OptionParser.new do |o|
    o.banner = "Usage: vagrant rsync [vm-name]"
    o.separator ""
    o.separator "This command forces any synced folders with type 'rsync' to sync."
    o.separator "RSync is not an automatic sync so a manual command is used."
    o.separator ""
    o.separator "Options:"
    o.separator ""
  end

  # Parse the options and return if we don't have any target.
  argv = parse_options(opts)
  return  unless argv

  # Go through each machine and perform full sync.
  with_target_vms(argv) do |machine|
    if machine.provider.capability?(:proxy_machine)
      proxy = machine.provider.capability(:proxy_machine)
      if proxy
        machine.ui.warn(I18n.t(
          "vagrant.rsync_proxy_machine",
          name: machine.name.to_s,
          provider: machine.provider_name.to_s))

        machine = proxy
      end
    end

    next  unless machine.communicate.ready?
    next  unless synced_folders(machine)[:rsync]

    if machine.ssh_info
      Machine.new(machine).full_sync
    end
  end

  return 0
end