-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dataset created from zone is downloaded to local file system
- Add WIP documentation to README - Add Rsync util for downloading file from GZ in a fraction of the time that net/scp takes - [refs #26]
- Loading branch information
Showing
6 changed files
with
196 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
module Vagrant | ||
module Smartos | ||
module Zones | ||
module Util | ||
class Rsync | ||
attr_reader :connection | ||
|
||
def initialize(connection) | ||
@connection = connection | ||
end | ||
|
||
def available? | ||
Vagrant::Util::Subprocess.execute(*%w'which rsync').exit_code == 0 | ||
end | ||
|
||
def download(from, to) | ||
command = %W' | ||
rsync | ||
-avz | ||
--progress | ||
' | ||
Vagrant::Util::Subprocess.execute(*command, '-e', ssh_command, remote(from), to, notify: [:stdout]) | ||
end | ||
|
||
def ssh_command | ||
"ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i #{identity_file} -p #{remote_port}" | ||
end | ||
|
||
def identity_file | ||
connection.options[:keys].first | ||
end | ||
|
||
def remote(file) | ||
"#{remote_user}@#{connection.host}:#{file}" | ||
end | ||
|
||
def remote_port | ||
connection.options[:port] | ||
end | ||
|
||
def remote_user | ||
connection.options[:user] | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |