vagrant-serial 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,10 +9,10 @@ require "fileutils"
9
9
 
10
10
  Vagrant.config_keys.register(:serial) { Vagrant::Serial::Config }
11
11
 
12
- Vagrant.actions[:start].insert_after Vagrant::Action::VM::Customize, Vagrant::Serial::Middleware::ClearForwardedPorts
13
12
  Vagrant.actions[:start].insert_after Vagrant::Action::VM::Customize, Vagrant::Serial::Middleware::ConfigurePorts
14
- Vagrant.actions[:start].insert_after Vagrant::Action::VM::Boot, Vagrant::Serial::Middleware::ForwardPorts
13
+ Vagrant.actions[:start].insert_after Vagrant::Action::VM::Customize, Vagrant::Serial::Middleware::ClearConfiguredPorts
14
+ Vagrant.actions[:start].insert_after Vagrant::Action::VM::Boot, Vagrant::Serial::Middleware::StartForwardingPorts
15
15
 
16
- Vagrant.actions[:resume].insert_after Vagrant::Action::VM::Resume, Vagrant::Serial::Middleware::ForwardPorts
17
- Vagrant.actions[:halt].insert_after Vagrant::Action::VM::CheckAccessible, Vagrant::Serial::Middleware::ClearForwardedPorts
18
- Vagrant.actions[:suspend].insert_after Vagrant::Action::VM::CheckAccessible, Vagrant::Serial::Middleware::ClearForwardedPorts
16
+ Vagrant.actions[:resume].insert_after Vagrant::Action::VM::Resume, Vagrant::Serial::Middleware::StartForwardingPorts
17
+ Vagrant.actions[:halt].insert_after Vagrant::Action::VM::CheckAccessible, Vagrant::Serial::Middleware::StopForwardingPorts
18
+ Vagrant.actions[:suspend].insert_after Vagrant::Action::VM::CheckAccessible, Vagrant::Serial::Middleware::StopForwardingPorts
@@ -0,0 +1,26 @@
1
+ module Vagrant
2
+ module Serial
3
+ module Middleware
4
+ class ClearConfiguredPorts
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ FileUtils.mkdir_p(env[:vm].config.serial.sockets_path) if !File.directory?(env[:vm].config.serial.sockets_path)
11
+
12
+ env[:ui].info "Clearing any previously configured serial ports..."
13
+
14
+ command = ["modifyvm", env[:vm].uuid, "--uart1", "off"]
15
+ env[:vm].driver.execute_command(command)
16
+
17
+ command = ["modifyvm", env[:vm].uuid, "--uart2", "off"]
18
+ env[:vm].driver.execute_command(command)
19
+
20
+ @app.call(env)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+
@@ -10,7 +10,7 @@ module Vagrant
10
10
  if env[:vm].config.serial.set?
11
11
  FileUtils.mkdir_p(env[:vm].config.serial.sockets_path) if !File.directory?(env[:vm].config.serial.sockets_path)
12
12
 
13
- env[:ui].info "Setting up serial ports..."
13
+ env[:ui].info "Configuring serial ports..."
14
14
  if env[:vm].config.serial.forward_com1
15
15
  command = ["modifyvm", env[:vm].uuid, "--uart1", "0x3F8", "4", "--uartmode1", "server", "#{env[:vm].config.serial.sockets_path}/#{env[:vm].uuid}-com1"]
16
16
  env[:vm].driver.execute_command(command)
@@ -1,7 +1,7 @@
1
1
  module Vagrant
2
2
  module Serial
3
3
  module Middleware
4
- class ForwardPorts
4
+ class StartForwardingPorts
5
5
  def initialize(app, env)
6
6
  @app = app
7
7
  end
@@ -10,6 +10,8 @@ module Vagrant
10
10
  if env[:vm].config.serial.set?
11
11
  FileUtils.mkdir_p(env[:vm].config.serial.sockets_path) if !File.directory?(env[:vm].config.serial.sockets_path)
12
12
 
13
+ env[:ui].info "Starting serial ports forwarding..."
14
+
13
15
  if env[:vm].config.serial.forward_com1
14
16
  `/sbin/start-stop-daemon --quiet --start --pidfile #{env[:vm].config.serial.sockets_path}/socat.#{env[:vm].uuid}-com1.pid --background --make-pidfile --exec /usr/bin/socat -- tcp-l:#{env[:vm].config.serial.forward_com1},reuseaddr,fork UNIX-CONNECT:#{env[:vm].config.serial.sockets_path}/#{env[:vm].uuid}-com1`
15
17
  env[:ui].info "COM1 => #{env[:vm].config.serial.forward_com1}"
@@ -0,0 +1,29 @@
1
+ module Vagrant
2
+ module Serial
3
+ module Middleware
4
+ class StopForwardingPorts
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ if env[:vm].config.serial.set?
11
+ FileUtils.mkdir_p(env[:vm].config.serial.sockets_path) if env[:vm].config.serial.set? && !File.directory?(env[:vm].config.serial.sockets_path)
12
+
13
+ env[:ui].info "Stopping serial ports forwarding..."
14
+
15
+ if env[:vm].config.serial.forward_com1
16
+ `/sbin/start-stop-daemon --stop --quiet --pidfile #{env[:vm].config.serial.sockets_path}/socat.#{env[:vm].uuid}-com1.pid --exec /usr/bin/socat && rm #{env[:vm].config.serial.sockets_path}/socat.#{env[:vm].uuid}-com1.pid`
17
+ end
18
+
19
+ if env[:vm].config.serial.forward_com2
20
+ `/sbin/start-stop-daemon --stop --quiet --pidfile #{env[:vm].config.serial.sockets_path}/socat.#{env[:vm].uuid}-com2.pid --exec /usr/bin/socat && rm #{env[:vm].config.serial.sockets_path}/socat.#{env[:vm].uuid}-com2.pid`
21
+ end
22
+ end
23
+
24
+ @app.call(env)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Serial
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-serial
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-10 00:00:00.000000000 Z
12
+ date: 2012-11-12 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Vagrant plugin to configure serial-ports in vms
15
15
  email:
@@ -25,9 +25,10 @@ files:
25
25
  - Rakefile
26
26
  - lib/vagrant-serial.rb
27
27
  - lib/vagrant-serial/config.rb
28
- - lib/vagrant-serial/middleware/clear_forwarded_ports.rb
28
+ - lib/vagrant-serial/middleware/clear_configured_ports.rb
29
29
  - lib/vagrant-serial/middleware/configure_ports.rb
30
- - lib/vagrant-serial/middleware/forward_ports.rb
30
+ - lib/vagrant-serial/middleware/start_forwarding_ports.rb
31
+ - lib/vagrant-serial/middleware/stop_forwarding_ports.rb
31
32
  - lib/vagrant-serial/version.rb
32
33
  - lib/vagrant_init.rb
33
34
  - vagrant-serial.gemspec
@@ -1,21 +0,0 @@
1
- module Vagrant
2
- module Serial
3
- module Middleware
4
- class ClearForwardedPorts
5
- def initialize(app, env)
6
- @app = app
7
- end
8
-
9
- def call(env)
10
- FileUtils.mkdir_p(env[:vm].config.serial.sockets_path) if env[:vm].config.serial.set? && !File.directory?(env[:vm].config.serial.sockets_path)
11
-
12
- env[:ui].info "Stopping serial ports forwarding..."
13
- `/sbin/start-stop-daemon --stop --oknodo --quiet --pidfile #{env[:vm].config.serial.sockets_path}/socat.#{env[:vm].uuid}-com1.pid --exec /usr/bin/socat && rm -f #{env[:vm].config.serial.sockets_path}/socat.#{env[:vm].uuid}-com1.pid`
14
- `/sbin/start-stop-daemon --stop --oknodo --quiet --pidfile #{env[:vm].config.serial.sockets_path}/socat.#{env[:vm].uuid}-com2.pid --exec /usr/bin/socat && rm -f #{env[:vm].config.serial.sockets_path}/socat.#{env[:vm].uuid}-com2.pid`
15
-
16
- @app.call(env)
17
- end
18
- end
19
- end
20
- end
21
- end