vagrant-zscp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cdd2eade49cf4518b306f9d3cc7c632b5b3c2284
4
+ data.tar.gz: e8eabad1df92ff74a4e9ab87bf667526f91dc0b2
5
+ SHA512:
6
+ metadata.gz: 0395f36643d5936006adbe2eefca8e57923cb488d1f26307c250690a255bb11823574b265c5a239213159de19588af47730556b5c0cdc144e1466ea5f4fe417a
7
+ data.tar.gz: 0146d484e0611c501ee795c306ecc65ef67ac32c5a2aa5dcc629da34f1de9a48e76dce807e86cf07e13a8874b93ad786f441dc39f844c937596f3571cf633d82
@@ -0,0 +1 @@
1
+ /*.gem
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
5
+ end
6
+
7
+ group :plugins do
8
+ gem "vagrant-zscp", path: "."
9
+ end
File without changes
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "vagrant/zscp"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,2 @@
1
+ require "vagrant/zscp/version"
2
+ require "vagrant/zscp/plugin"
@@ -0,0 +1,57 @@
1
+ require 'optparse'
2
+
3
+ require "vagrant/action/builtin/mixin_synced_folders"
4
+ require_relative "../helper"
5
+
6
+ module Vagrant
7
+ module Zscp
8
+ module Command
9
+ class Rsync < Vagrant.plugin("2", :command)
10
+ include Vagrant::Action::Builtin::MixinSyncedFolders
11
+
12
+ def execute
13
+ opts = OptionParser.new do |o|
14
+ o.banner = "Usage: vagrant zscp [vm-name]"
15
+ o.separator ""
16
+ end
17
+
18
+ # Parse the options and return if we don't have any target.
19
+ argv = parse_options(opts)
20
+ return if !argv
21
+
22
+ # Go through each machine and perform the rsync
23
+ error = false
24
+ with_target_vms(argv) do |machine|
25
+ if machine.provider.capability?(:proxy_machine)
26
+ proxy = machine.provider.capability(:proxy_machine)
27
+ if proxy
28
+ machine.ui.warn("vagrant.rsync_proxy_machine")
29
+ machine = proxy
30
+ end
31
+ end
32
+
33
+ if !machine.communicate.ready?
34
+ machine.ui.error("vagrant.rsync_communicator_not_ready")
35
+ error = true
36
+ next
37
+ end
38
+
39
+ # Determine the rsync synced folders for this machine
40
+ folders = synced_folders(machine, cached: true)[:zscp]
41
+ next if !folders || folders.empty?
42
+
43
+ # Get the SSH info for this machine so we can access it
44
+ ssh_info = machine.ssh_info
45
+
46
+ # Sync them!
47
+ folders.each do |id, folder_opts|
48
+ ZscpHelper.scp(machine, ssh_info, folder_opts)
49
+ end
50
+ end
51
+
52
+ return error ? 1 : 0
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,51 @@
1
+ module Vagrant
2
+ module Zscp
3
+ # This is a helper that abstracts out the functionality of scping
4
+ # folders so that it can be called from anywhere.
5
+ class ZscpHelper
6
+ def self.scp(machine, ssh_info, opts)
7
+ guestpath = opts[:guestpath]
8
+ hostpath = opts[:hostpath]
9
+ hostpath = File.expand_path(hostpath, machine.env.root_path)
10
+ hostpath = Vagrant::Util::Platform.fs_real_path(hostpath).to_s
11
+ if (opts[:zscp_include])
12
+ included_files = opts[:zscp_include].join(' ')
13
+ else
14
+ included_files = '.'
15
+ end
16
+
17
+ username = ssh_info[:username]
18
+ host = ssh_info[:host]
19
+
20
+ if !hostpath.end_with?("/")
21
+ hostpath += "/"
22
+ end
23
+
24
+ machine.ui.info("Sending #{hostpath} to #{guestpath}")
25
+ Dir.mktmpdir { |dir|
26
+ machine.ui.info("Removing remote #{guestpath}")
27
+ machine.communicate.execute("sudo rm -rf #{guestpath}; sudo mkdir -p #{guestpath}; sudo chown #{username}:$(id -gn) #{guestpath}")
28
+
29
+ machine.ui.info("Compressing #{hostpath} into #{dir}/temp.tar.gz")
30
+ `tar -czLf #{dir}/temp.tar.gz -C #{hostpath} #{included_files}`
31
+
32
+ machine.ui.info("Copying #{dir}/temp.tar.gz to #{guestpath}")
33
+ command = [
34
+ "scp",
35
+ '-o StrictHostKeyChecking=no',
36
+ '-o UserKnownHostsFile=/dev/null',
37
+ "-o port=#{ssh_info[:port]}",
38
+ "-i '#{ssh_info[:private_key_path][0]}'",
39
+ "#{dir}/temp.tar.gz",
40
+ "#{username}@#{host}:#{guestpath}"
41
+ ].join(' ')
42
+ system(command)
43
+
44
+ machine.ui.info("Extracting remotely #{guestpath}/temp.tar.gz")
45
+ machine.communicate.execute("tar -xzf #{guestpath}/temp.tar.gz -C #{guestpath}; rm #{guestpath}/temp.tar.gz")
46
+ }
47
+ machine.ui.info("#{guestpath} synchronised")
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,27 @@
1
+ require "vagrant"
2
+
3
+ module Vagrant
4
+ module Zscp
5
+ # This plugin implements zSCP synced folders.
6
+ # It will also compress folders into a targz file to reduce back and forth
7
+ # communication
8
+ #
9
+ class Plugin < Vagrant.plugin("2")
10
+ name "zSCP synced folders"
11
+ description <<-EOF
12
+ The zSCP synced folders plugin enables you to use SCP as a synced folder
13
+ implementation.
14
+ EOF
15
+
16
+ command("zscp", primary: false) do
17
+ require_relative "command/zscp"
18
+ Command::Rsync
19
+ end
20
+
21
+ synced_folder("zscp", 5) do
22
+ require_relative "synced_folder"
23
+ SyncedFolder
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,30 @@
1
+ require "log4r"
2
+
3
+ require_relative "helper"
4
+
5
+ module Vagrant
6
+ module Zscp
7
+ class SyncedFolder < Vagrant.plugin("2", :synced_folder)
8
+ def initialize(*args)
9
+ super
10
+ @logger = Log4r::Logger.new("vagrant::synced_folders::zscp")
11
+ end
12
+
13
+ def usable?(machine, raise_error=false)
14
+ return true
15
+ end
16
+
17
+ def prepare(machine, folders, opts)
18
+ # Nothing is necessary to do before VM boot.
19
+ end
20
+
21
+ def enable(machine, folders, opts)
22
+ ssh_info = machine.ssh_info
23
+
24
+ folders.each do |id, folder_opts|
25
+ ZscpHelper.scp(machine, ssh_info, folder_opts)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,5 @@
1
+ module Vagrant
2
+ module Zscp
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant/zscp/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-zscp"
8
+ spec.version = Vagrant::Zscp::VERSION
9
+ spec.authors = ["Colin Hebert"]
10
+ spec.email = ["chebert@atlassian.com"]
11
+
12
+ spec.summary = %q{Copies files to a vagrant VM using scp and compressing the content.}
13
+ spec.description = %q{Copies files to a vagrant VM using scp and compressing the content.}
14
+ spec.homepage = "https://www.atlassian.com"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.10"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_runtime_dependency "log4r", "~> 1.1"
24
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-zscp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Colin Hebert
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-06-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: log4r
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
55
+ description: Copies files to a vagrant VM using scp and compressing the content.
56
+ email:
57
+ - chebert@atlassian.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - README.md
65
+ - Rakefile
66
+ - bin/console
67
+ - bin/setup
68
+ - lib/vagrant/zscp.rb
69
+ - lib/vagrant/zscp/command/zscp.rb
70
+ - lib/vagrant/zscp/helper.rb
71
+ - lib/vagrant/zscp/plugin.rb
72
+ - lib/vagrant/zscp/synced_folder.rb
73
+ - lib/vagrant/zscp/version.rb
74
+ - vagrant-zscp.gemspec
75
+ homepage: https://www.atlassian.com
76
+ licenses: []
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.0.14
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Copies files to a vagrant VM using scp and compressing the content.
98
+ test_files: []