Sha256: 5ad1b90f1236401dd74632dff3e055c3da097a07bde5a5d4f36f2cf428e9b139

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

require 'optparse'

require "vagrant/action/builtin/mixin_synced_folders"
require_relative "../helper"

module Vagrant
  module Zscp
    module Command
      class Rsync < Vagrant.plugin("2", :command)
        include Vagrant::Action::Builtin::MixinSyncedFolders

        def execute
          opts = OptionParser.new do |o|
            o.banner = "Usage: vagrant zscp [vm-name]"
            o.separator ""
          end

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

          # Go through each machine and perform the rsync
          error = false
          with_target_vms(argv) do |machine|
            if machine.provider.capability?(:proxy_machine)
              proxy = machine.provider.capability(:proxy_machine)
              if proxy
                machine.ui.warn("vagrant.rsync_proxy_machine")
                machine = proxy
              end
            end

            if !machine.communicate.ready?
              machine.ui.error("vagrant.rsync_communicator_not_ready")
              error = true
              next
            end

            # Determine the rsync synced folders for this machine
            folders = synced_folders(machine, cached: true)[:zscp]
            next if !folders || folders.empty?

            # Get the SSH info for this machine so we can access it
            ssh_info = machine.ssh_info

            # Sync them!
            folders.each do |id, folder_opts|
              ZscpHelper.scp(machine, ssh_info, folder_opts)
            end
          end

          return error ? 1 : 0
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vagrant-zscp-0.1.2 lib/vagrant/zscp/command/zscp.rb
vagrant-zscp-0.1.1 lib/vagrant/zscp/command/zscp.rb
vagrant-zscp-0.1.0 lib/vagrant/zscp/command/zscp.rb