vagrant-libvirt 0.0.17 → 0.0.18
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.
- checksums.yaml +4 -4
- data/lib/vagrant-libvirt/action/forward_ports.rb +36 -7
- data/lib/vagrant-libvirt/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bc2f0fdfc01511f71626fdc2fe8b7cbe21c6a09
|
4
|
+
data.tar.gz: a6af2428f90f0ccc535835336f07cf1f765dd4ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62d3180bf379f2b6d264c6c8e8fa29e8d340b5d6dd74c456ac536967c8c10c77b42a942963569db8e6ed936622a8b20ebf9dbb6f81a12b99e420290b943b5b54
|
7
|
+
data.tar.gz: 6b6ff342e37bfe6c6ceae077d974dad0cedae2eed7581529b2e0b465dac81a007b6ed17c026e6125a160c741abe3322b3338e8e9a584ed1abbbcfb2b79a3ed1b
|
@@ -3,6 +3,8 @@ module VagrantPlugins
|
|
3
3
|
module Action
|
4
4
|
# Adds support for vagrant's `forward_ports` configuration directive.
|
5
5
|
class ForwardPorts
|
6
|
+
@@lock = Mutex.new
|
7
|
+
|
6
8
|
def initialize(app, env)
|
7
9
|
@app = app
|
8
10
|
@logger = Log4r::Logger.new('vagrant_libvirt::action::forward_ports')
|
@@ -94,8 +96,21 @@ module VagrantPlugins
|
|
94
96
|
) + ssh_info[:private_key_path].map do |pk|
|
95
97
|
"IdentityFile=#{pk}"
|
96
98
|
end).map { |s| s.prepend('-o ') }.join(' ')
|
97
|
-
|
98
|
-
|
99
|
+
|
100
|
+
# TODO: instead of this, try and lock and get the stdin from spawn...
|
101
|
+
ssh_cmd = ''
|
102
|
+
if host_port <= 1024
|
103
|
+
@@lock.synchronize do
|
104
|
+
# TODO: add i18n
|
105
|
+
@env[:ui].info 'Requesting sudo for host port(s) <= 1024'
|
106
|
+
r = system('sudo -v')
|
107
|
+
if r
|
108
|
+
ssh_cmd << 'sudo ' # add sudo prefix
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
ssh_cmd << "ssh #{options} #{params}"
|
99
114
|
|
100
115
|
@logger.debug "Forwarding port with `#{ssh_cmd}`"
|
101
116
|
spawn(ssh_cmd, [:out, :err] => '/dev/null')
|
@@ -119,6 +134,8 @@ module VagrantPlugins
|
|
119
134
|
module Action
|
120
135
|
# Cleans up ssh-forwarded ports on VM halt/destroy.
|
121
136
|
class ClearForwardedPorts
|
137
|
+
@@lock = Mutex.new
|
138
|
+
|
122
139
|
def initialize(app, env)
|
123
140
|
@app = app
|
124
141
|
@logger = Log4r::Logger.new(
|
@@ -133,10 +150,19 @@ module VagrantPlugins
|
|
133
150
|
env[:ui].info I18n.t(
|
134
151
|
'vagrant.actions.vm.clear_forward_ports.deleting'
|
135
152
|
)
|
136
|
-
ssh_pids.each do |
|
137
|
-
next unless ssh_pid?(pid)
|
138
|
-
@logger.debug "Killing pid #{pid}"
|
139
|
-
|
153
|
+
ssh_pids.each do |tag|
|
154
|
+
next unless ssh_pid?(tag[:pid])
|
155
|
+
@logger.debug "Killing pid #{tag[:pid]}"
|
156
|
+
kill_cmd = ''
|
157
|
+
|
158
|
+
if tag[:port] <= 1024
|
159
|
+
kill_cmd << 'sudo ' # add sudo prefix
|
160
|
+
end
|
161
|
+
|
162
|
+
kill_cmd << "kill #{tag[:pid]}"
|
163
|
+
@@lock.synchronize do
|
164
|
+
system(kill_cmd)
|
165
|
+
end
|
140
166
|
end
|
141
167
|
|
142
168
|
@logger.info 'Removing ssh pid files'
|
@@ -153,7 +179,10 @@ module VagrantPlugins
|
|
153
179
|
def ssh_pids
|
154
180
|
glob = @env[:machine].data_dir.join('pids').to_s + '/ssh_*.pid'
|
155
181
|
@ssh_pids = Dir[glob].map do |file|
|
156
|
-
|
182
|
+
{
|
183
|
+
:pid => File.read(file).strip.chomp,
|
184
|
+
:port => File.basename(file)['ssh_'.length..-1*('.pid'.length+1)].to_i
|
185
|
+
}
|
157
186
|
end
|
158
187
|
end
|
159
188
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-libvirt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Stanek
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-06-
|
13
|
+
date: 2014-06-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fog
|