vagrant-sakura 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/LICENSE-vagrant-aws.txt +8 -0
- data/lib/vagrant-sakura/action.rb +20 -17
- data/lib/vagrant-sakura/action/sync_folders.rb +96 -0
- data/lib/vagrant-sakura/version.rb +1 -1
- data/locales/en.yml +5 -0
- data/vagrant-sakura.gemspec +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed22d90e7ac0a847a3df3114dfb4d3c72f09ed03
|
4
|
+
data.tar.gz: c515ec435d3c2bfec4d73e6c2fb2a9fa49d5405b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d06e0b32afab6b86ae38cbe7a4d85284968a7d03c565de5778eabb7e10d5352446fabf6496905c05032a87caac374a7ab90ea37f2e9033bd4a12e0758cc9fa5f
|
7
|
+
data.tar.gz: 7ea023edc7e7aa70a994e2c9cccd55dfe3855ec40b687b424b2abf0899d904955ec90f37de2167f74a9c84239dd222abb1a9ab3ae33161d99abe3d8aaa85d57f
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,8 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
Copyright (c) 2013 Mitchell Hashimoto
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
7
|
+
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -43,20 +43,23 @@ module VagrantPlugins
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
46
|
+
def self.action_provision
|
47
|
+
Vagrant::Action::Builder.new.tap do |b|
|
48
|
+
b.use ConfigValidate
|
49
|
+
b.use ConnectSakura
|
50
|
+
b.use Call, ReadState do |env, b2|
|
51
|
+
case env[:machine_state_id]
|
52
|
+
when :up
|
53
|
+
b2.use Provision
|
54
|
+
b2.use SyncFolders
|
55
|
+
when :down, :cleaning
|
56
|
+
b2.use MessageDown
|
57
|
+
when :not_created
|
58
|
+
b2.use MessageNotCreated
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
60
63
|
|
61
64
|
def self.action_read_ssh_info
|
62
65
|
Vagrant::Action::Builder.new.tap do |b|
|
@@ -82,7 +85,7 @@ module VagrantPlugins
|
|
82
85
|
case env[:machine_state_id]
|
83
86
|
when :up
|
84
87
|
b2.use Reset
|
85
|
-
b2.use
|
88
|
+
b2.use action_provision
|
86
89
|
when :down, :cleaning
|
87
90
|
b2.use MessageDown
|
88
91
|
when :not_created
|
@@ -140,7 +143,7 @@ module VagrantPlugins
|
|
140
143
|
b2.use Provision
|
141
144
|
when :not_created
|
142
145
|
b2.use RunInstance
|
143
|
-
b2.use
|
146
|
+
b2.use action_provision
|
144
147
|
end
|
145
148
|
end
|
146
149
|
end
|
@@ -161,7 +164,7 @@ module VagrantPlugins
|
|
161
164
|
autoload :ReadState, action_root.join("read_state")
|
162
165
|
autoload :Reset, action_root.join("reset")
|
163
166
|
autoload :RunInstance, action_root.join("run_instance")
|
164
|
-
|
167
|
+
autoload :SyncFolders, action_root.join("sync_folders")
|
165
168
|
end
|
166
169
|
end
|
167
170
|
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require "log4r"
|
2
|
+
|
3
|
+
require "vagrant/util/subprocess"
|
4
|
+
|
5
|
+
require "vagrant/util/scoped_hash_override"
|
6
|
+
|
7
|
+
require "vagrant/util/which"
|
8
|
+
|
9
|
+
module VagrantPlugins
|
10
|
+
module Sakura
|
11
|
+
module Action
|
12
|
+
# This middleware uses `rsync` to sync the folders over to the
|
13
|
+
# Sakura Cloud instance.
|
14
|
+
class SyncFolders
|
15
|
+
include Vagrant::Util::ScopedHashOverride
|
16
|
+
|
17
|
+
def initialize(app, env)
|
18
|
+
@app = app
|
19
|
+
@logger = Log4r::Logger.new("vagrant_sakura::action::sync_folders")
|
20
|
+
end
|
21
|
+
|
22
|
+
def call(env)
|
23
|
+
@app.call(env)
|
24
|
+
|
25
|
+
ssh_info = env[:machine].ssh_info
|
26
|
+
|
27
|
+
env[:machine].config.vm.synced_folders.each do |id, data|
|
28
|
+
data = scoped_hash_override(data, :sakura)
|
29
|
+
|
30
|
+
# Ignore disabled shared folders
|
31
|
+
next if data[:disabled]
|
32
|
+
|
33
|
+
unless Vagrant::Util::Which.which('rsync')
|
34
|
+
env[:ui].warn(I18n.t('vagrant_sakura.rsync_not_found_warning'))
|
35
|
+
break
|
36
|
+
end
|
37
|
+
|
38
|
+
hostpath = File.expand_path(data[:hostpath], env[:root_path])
|
39
|
+
guestpath = data[:guestpath]
|
40
|
+
|
41
|
+
# Make sure there is a trailing slash on the host path to
|
42
|
+
# avoid creating an additional directory with rsync
|
43
|
+
hostpath = "#{hostpath}/" if hostpath !~ /\/$/
|
44
|
+
|
45
|
+
# on windows rsync.exe requires cygdrive-style paths
|
46
|
+
if Vagrant::Util::Platform.windows?
|
47
|
+
hostpath = hostpath.gsub(/^(\w):/) { "/cygdrive/#{$1}" }
|
48
|
+
end
|
49
|
+
|
50
|
+
env[:ui].info(I18n.t("vagrant_sakura.rsync_folder",
|
51
|
+
:hostpath => hostpath,
|
52
|
+
:guestpath => guestpath))
|
53
|
+
|
54
|
+
# Create the host path if it doesn't exist and option flag is set
|
55
|
+
if data[:create]
|
56
|
+
begin
|
57
|
+
FileUtils::mkdir_p(hostpath)
|
58
|
+
rescue => err
|
59
|
+
raise Errors::MkdirError,
|
60
|
+
:hostpath => hostpath,
|
61
|
+
:err => err
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Create the guest path
|
66
|
+
env[:machine].communicate.sudo("mkdir -p '#{guestpath}'")
|
67
|
+
env[:machine].communicate.sudo(
|
68
|
+
"chown #{ssh_info[:username]} '#{guestpath}'")
|
69
|
+
|
70
|
+
# Rsync over to the guest path using the SSH info
|
71
|
+
command = [
|
72
|
+
"rsync", "--verbose", "--archive", "-z",
|
73
|
+
"--exclude", ".vagrant/", "--exclude", "Vagrantfile",
|
74
|
+
"-e", "ssh -p #{ssh_info[:port]} -o StrictHostKeyChecking=no -i '#{ssh_info[:private_key_path]}'",
|
75
|
+
hostpath,
|
76
|
+
"#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]
|
77
|
+
|
78
|
+
# we need to fix permissions when using rsync.exe on windows, see
|
79
|
+
# http://stackoverflow.com/questions/5798807/rsync-permission-denied-created-directories-have-no-permissions
|
80
|
+
if Vagrant::Util::Platform.windows?
|
81
|
+
command.insert(1, "--chmod", "ugo=rwX")
|
82
|
+
end
|
83
|
+
|
84
|
+
r = Vagrant::Util::Subprocess.execute(*command)
|
85
|
+
if r.exit_code != 0
|
86
|
+
raise Errors::RsyncError,
|
87
|
+
:guestpath => guestpath,
|
88
|
+
:hostpath => hostpath,
|
89
|
+
:stderr => r.stderr
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/locales/en.yml
CHANGED
@@ -16,6 +16,11 @@ en:
|
|
16
16
|
Server is booted and ready for use!
|
17
17
|
reset: |-
|
18
18
|
The server was reloaded.
|
19
|
+
rsync_folder: |-
|
20
|
+
Rsyncing folder: %{hostpath} => %{guestpath}
|
21
|
+
rsync_not_found_warning: |-
|
22
|
+
Warning! Folder sync disabled because the rsync binary is missing.
|
23
|
+
Make sure rsync is installed and the binary can be found in the PATH.
|
19
24
|
state_cleaning: |-
|
20
25
|
The server is terminated and cleaning up.
|
21
26
|
state_down: |-
|
data/vagrant-sakura.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["sahara@surt.net"]
|
11
11
|
spec.description = %q{Enables Vagrant to manage machines in Sakura Cloud.}
|
12
12
|
spec.summary = %q{Enables Vagrant to manage machines in Sakura Cloud.}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/tsahara/vagrant-sakura"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-sakura
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomoyuki Sahara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- .gitignore
|
49
49
|
- CHANGELOG.md
|
50
50
|
- Gemfile
|
51
|
+
- LICENSE-vagrant-aws.txt
|
51
52
|
- LICENSE.txt
|
52
53
|
- README.md
|
53
54
|
- Rakefile
|
@@ -70,6 +71,7 @@ files:
|
|
70
71
|
- lib/vagrant-sakura/action/read_state.rb
|
71
72
|
- lib/vagrant-sakura/action/reset.rb
|
72
73
|
- lib/vagrant-sakura/action/run_instance.rb
|
74
|
+
- lib/vagrant-sakura/action/sync_folders.rb
|
73
75
|
- lib/vagrant-sakura/command.rb
|
74
76
|
- lib/vagrant-sakura/config.rb
|
75
77
|
- lib/vagrant-sakura/driver/api.rb
|
@@ -80,7 +82,7 @@ files:
|
|
80
82
|
- lib/vagrant-sakura/version.rb
|
81
83
|
- locales/en.yml
|
82
84
|
- vagrant-sakura.gemspec
|
83
|
-
homepage:
|
85
|
+
homepage: https://github.com/tsahara/vagrant-sakura
|
84
86
|
licenses:
|
85
87
|
- MIT
|
86
88
|
metadata: {}
|