vagrant-multi-putty 1.2.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/README.md +31 -5
- data/lib/vagrant-multi-putty/command.rb +23 -11
- data/lib/vagrant-multi-putty/config.rb +24 -10
- data/lib/vagrant-multi-putty/version.rb +1 -1
- metadata +6 -2
data/.gitignore
ADDED
data/README.md
CHANGED
@@ -17,9 +17,9 @@ $ vagrant plugin install vagrant-multi-putty
|
|
17
17
|
### Putty Binary
|
18
18
|
Download: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
|
19
19
|
|
20
|
-
Download the putty executable for your platform and
|
21
|
-
PATH variable. Seek your operating system manual for instructions
|
22
|
-
modify your PATH variable.
|
20
|
+
Download the putty executable for your platform and add it's location to your
|
21
|
+
PATH environment variable. Seek your operating system manual for instructions
|
22
|
+
on how to modify your PATH variable.
|
23
23
|
|
24
24
|
### SSH Private Key conversion using PuTTYgen
|
25
25
|
Download: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
|
@@ -37,7 +37,7 @@ or convert a private key of your own.
|
|
37
37
|
5. Save the key using the filename of "insecure_private_key.ppk".
|
38
38
|
|
39
39
|
Note: If you do not explicity set the config.putty.private_key_path variable,
|
40
|
-
you need to convert the insecure_private_key and store it with
|
40
|
+
you need to convert the insecure_private_key and store it with a ".ppk"
|
41
41
|
extension. The vagrant-multi-putty plugin appends this extension automatically.
|
42
42
|
|
43
43
|
## Configuration
|
@@ -53,12 +53,38 @@ vagrant-multi-putty:
|
|
53
53
|
All other config.ssh options should work for vagrant-multi-putty just like they
|
54
54
|
do for vagrant ssh.
|
55
55
|
|
56
|
-
There are currently
|
56
|
+
There are currently a few additional configuration parameters available:
|
57
57
|
|
58
58
|
* config.putty.username: Overrides the username set with
|
59
59
|
config.ssh.username.
|
60
60
|
* config.putty.private_key_path: Used to explicity set the path to the
|
61
61
|
private key variable.
|
62
|
+
* config.putty.modal: change vagrant-multi-putty to use modal window mode.
|
63
|
+
Execute putty and block the terminal until all putty processes have exited.
|
64
|
+
Can be set on the command line with -m or --modal. This is false by default.
|
65
|
+
* config.putty.after_modal: Configure a post hook block that will be called
|
66
|
+
once all child putty processes have exited and modal mode is enabled. The
|
67
|
+
default block is empty.
|
68
|
+
|
69
|
+
#### Example usage of after_modal post hook
|
70
|
+
This is an example which uses the the win32-activate gem written by nazoking. This
|
71
|
+
only works on windows since win32-activate uses the win32 API.
|
72
|
+
|
73
|
+
Github Page: https://github.com/nazoking/win32-activate
|
74
|
+
|
75
|
+
After all putty windows are closed, the terminal window used to run the 'vagrant putty'
|
76
|
+
command will be brought into focus and placed on top of all open windows.
|
77
|
+
```
|
78
|
+
Vagrant.configure("2") do |config|
|
79
|
+
# always modal mode
|
80
|
+
config.putty.modal = true
|
81
|
+
# set hook.
|
82
|
+
config.putty.after_modal do
|
83
|
+
require 'win32/activate'
|
84
|
+
Win32::Activate.active
|
85
|
+
end
|
86
|
+
end
|
87
|
+
```
|
62
88
|
|
63
89
|
## Usage
|
64
90
|
Basic usage:
|
@@ -5,7 +5,7 @@ require 'optparse'
|
|
5
5
|
module VagrantMultiPutty
|
6
6
|
class Command < Vagrant.plugin(2, :command)
|
7
7
|
def execute
|
8
|
-
options = {}
|
8
|
+
options = {:modal => @env.config_global.putty.modal }
|
9
9
|
opts = OptionParser.new do |opts|
|
10
10
|
opts.banner = "Usage: vagrant putty [vm-name...] [-- extra putty args]"
|
11
11
|
|
@@ -13,6 +13,10 @@ module VagrantMultiPutty
|
|
13
13
|
options[:plain_auth] = p
|
14
14
|
end
|
15
15
|
|
16
|
+
opts.on("-m", "--modal", "Block until all spawned putty processes have exited") do |m|
|
17
|
+
options[:modal] = m
|
18
|
+
end
|
19
|
+
|
16
20
|
opts.separator ""
|
17
21
|
end
|
18
22
|
|
@@ -33,13 +37,21 @@ module VagrantMultiPutty
|
|
33
37
|
# detach the process from vagrant.
|
34
38
|
with_target_vms(argv) do |vm|
|
35
39
|
@logger.info("Launching putty session to: #{vm.name}")
|
36
|
-
putty_connect(vm, putty_args,
|
40
|
+
putty_connect(vm, putty_args, options)
|
41
|
+
end
|
42
|
+
|
43
|
+
if options[:modal]
|
44
|
+
Process.wait(0, Process::WNOHANG)
|
45
|
+
@env.config_global.putty.after_modal_hook.call
|
37
46
|
end
|
47
|
+
|
38
48
|
return 0
|
39
49
|
end
|
40
50
|
|
41
|
-
def putty_connect(vm, args,
|
51
|
+
def putty_connect(vm, args, options={})
|
52
|
+
# This isn't called by vagrant automatically.
|
42
53
|
vm.config.putty.finalize!
|
54
|
+
|
43
55
|
ssh_info = vm.ssh_info
|
44
56
|
# If ssh_info is nil, the machine is not ready for ssh.
|
45
57
|
raise Vagrant::Errors::SSHNotReady if ssh_info.nil?
|
@@ -50,20 +62,20 @@ module VagrantMultiPutty
|
|
50
62
|
@logger.debug("Putty Private Key: #{pk_path}")
|
51
63
|
|
52
64
|
# Load options from machine ssh_info.
|
53
|
-
|
65
|
+
ssh_options = [ssh_info[:host]]
|
54
66
|
# config.putty.username overrides the machines ssh_info username.
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
67
|
+
ssh_options += ["-l", vm.config.putty.username || ssh_info[:username]]
|
68
|
+
ssh_options += ["-P", ssh_info[:port].to_s]
|
69
|
+
ssh_options += ["-i", pk_path] unless options[:plain_auth]
|
70
|
+
ssh_options += ["-X"] if ssh_info[:forward_x11]
|
71
|
+
ssh_options += ["-A"] if ssh_info[:forward_agent]
|
60
72
|
|
61
73
|
# Add in additional args from the command line.
|
62
|
-
|
74
|
+
ssh_options.concat(args) if !args.nil?
|
63
75
|
|
64
76
|
# Spawn putty and detach it so we can move on.
|
65
77
|
@logger.debug("Putty cmd line options: #{options.to_s}")
|
66
|
-
pid = spawn("putty", *
|
78
|
+
pid = spawn("putty", *ssh_options)
|
67
79
|
@logger.debug("Putty Child Pid: #{pid}")
|
68
80
|
Process.detach(pid)
|
69
81
|
end
|
@@ -1,16 +1,30 @@
|
|
1
1
|
module VagrantMultiPutty
|
2
2
|
class PuttyConfig < Vagrant.plugin(2, :config)
|
3
|
-
|
4
|
-
|
3
|
+
attr_accessor :username
|
4
|
+
attr_accessor :private_key_path
|
5
|
+
attr_accessor :after_modal_hook
|
6
|
+
attr_accessor :modal
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
8
|
+
def after_modal &proc
|
9
|
+
@after_modal_hook = proc
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
def initialize
|
13
|
+
@username = UNSET_VALUE
|
14
|
+
@private_key_path = UNSET_VALUE
|
15
|
+
@after_modal_hook = UNSET_VALUE
|
16
|
+
@modal = UNSET_VALUE
|
17
|
+
end
|
18
|
+
|
19
|
+
def finalize!
|
20
|
+
@username = nil if @username == UNSET_VALUE
|
21
|
+
@private_key_path = nil if @private_key_path == UNSET_VALUE
|
22
|
+
@after_modal_hook = Proc{ } if @after_modal_hook == UNSET_VALUE
|
23
|
+
@modal = false if @modal == UNSET_VALUE
|
24
|
+
end
|
25
|
+
|
26
|
+
def validate(machine)
|
27
|
+
{}
|
28
|
+
end
|
15
29
|
end
|
16
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-multi-putty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
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: 2013-
|
12
|
+
date: 2013-11-01 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Vagrant plugin to allow VM ssh with PuTTY (multi-vm supported)
|
15
15
|
email:
|
@@ -18,6 +18,7 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
+
- .gitignore
|
21
22
|
- Gemfile
|
22
23
|
- LICENSE
|
23
24
|
- README.md
|
@@ -41,6 +42,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
41
42
|
- - ! '>='
|
42
43
|
- !ruby/object:Gem::Version
|
43
44
|
version: '0'
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
hash: -108176497
|
44
48
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
49
|
none: false
|
46
50
|
requirements:
|