Class: Vagrant::Smartos::Zones::Util::Rsync
- Inherits:
-
Object
- Object
- Vagrant::Smartos::Zones::Util::Rsync
- Defined in:
- lib/vagrant/smartos/zones/util/rsync.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #available? ⇒ Boolean
- #download(from, to) ⇒ Object
- #identity_file ⇒ Object
-
#initialize(connection) ⇒ Rsync
constructor
A new instance of Rsync.
- #remote(file) ⇒ Object
- #remote_port ⇒ Object
- #remote_user ⇒ Object
- #rsync_command ⇒ Object
- #ssh_command ⇒ Object
- #upload(from, to) ⇒ Object
Constructor Details
#initialize(connection) ⇒ Rsync
Returns a new instance of Rsync.
8 9 10 |
# File 'lib/vagrant/smartos/zones/util/rsync.rb', line 8 def initialize(connection) @connection = connection end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
6 7 8 |
# File 'lib/vagrant/smartos/zones/util/rsync.rb', line 6 def connection @connection end |
Instance Method Details
#available? ⇒ Boolean
12 13 14 |
# File 'lib/vagrant/smartos/zones/util/rsync.rb', line 12 def available? Vagrant::Util::Subprocess.execute(*%w(which rsync)).exit_code == 0 end |
#download(from, to) ⇒ Object
16 17 18 |
# File 'lib/vagrant/smartos/zones/util/rsync.rb', line 16 def download(from, to) Vagrant::Util::Subprocess.execute(*rsync_command, '-e', ssh_command, remote(from), to, notify: [:stdout]) end |
#identity_file ⇒ Object
32 33 34 |
# File 'lib/vagrant/smartos/zones/util/rsync.rb', line 32 def identity_file connection.[:keys].first end |
#remote(file) ⇒ Object
36 37 38 |
# File 'lib/vagrant/smartos/zones/util/rsync.rb', line 36 def remote(file) "#{remote_user}@#{connection.host}:#{file}" end |
#remote_port ⇒ Object
40 41 42 |
# File 'lib/vagrant/smartos/zones/util/rsync.rb', line 40 def remote_port connection.[:port] end |
#remote_user ⇒ Object
44 45 46 |
# File 'lib/vagrant/smartos/zones/util/rsync.rb', line 44 def remote_user connection.[:user] end |
#rsync_command ⇒ Object
24 25 26 |
# File 'lib/vagrant/smartos/zones/util/rsync.rb', line 24 def rsync_command %w(rsync -avz --progress) end |
#ssh_command ⇒ Object
28 29 30 |
# File 'lib/vagrant/smartos/zones/util/rsync.rb', line 28 def ssh_command "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i #{identity_file} -p #{remote_port}" end |
#upload(from, to) ⇒ Object
20 21 22 |
# File 'lib/vagrant/smartos/zones/util/rsync.rb', line 20 def upload(from, to) Vagrant::Util::Subprocess.execute(*rsync_command, '-e', ssh_command, from, remote(to), notify: [:stdout]) end |