vagrant-multi-putty 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ # Immediately sync all stdout so that tools like buildbot can
5
+ # immediately load in the output.
6
+ $stdout.sync = true
7
+ $stderr.sync = true
8
+
9
+ # Change to the directory of this file.
10
+ Dir.chdir(File.expand_path("../", __FILE__))
11
+
12
+ # This installs the tasks that help with gem creation and
13
+ # publishing.
14
+ Bundler::GemHelper.install_tasks
@@ -1,2 +1,4 @@
1
1
  require 'vagrant-multi-putty/command'
2
2
  require 'vagrant-multi-putty/config'
3
+ require 'vagrant-multi-putty/plugin'
4
+ require 'vagrant-multi-putty/version'
@@ -3,7 +3,7 @@ require 'rubygems'
3
3
  require 'optparse'
4
4
 
5
5
  module VagrantMultiPutty
6
- class Command < Vagrant::Command::Base
6
+ class Command < Vagrant.plugin(2, :command)
7
7
  def execute
8
8
  options = {}
9
9
  opts = OptionParser.new do |opts|
@@ -17,7 +17,7 @@ module VagrantMultiPutty
17
17
  end
18
18
 
19
19
  argv = parse_options(opts)
20
- return if !argv
20
+ return -1 if !argv
21
21
 
22
22
  # This is borrowed from the ssh base command that ships with vagrant.
23
23
  # It is used to parse out arguments meant for the putty program.
@@ -32,31 +32,30 @@ module VagrantMultiPutty
32
32
  # Since putty is a program with a GUI window, we can perform a spawn and
33
33
  # detach the process from vagrant.
34
34
  with_target_vms(argv) do |vm|
35
- # Also borrowed from the base ssh.rb code.
36
- # Basic checks needed for a putty connection
37
- raise Vagrant::Errors::VMNotCreatedError if !vm.created?
38
- raise Vagrant::Errors::VMInaccessible if !vm.state == :inaccessible
39
- raise Vagrant::Errors::VMNotRunningError if vm.state != :running
40
-
41
35
  @logger.info("Launching putty session to: #{vm.name}")
42
36
  putty_connect(vm, putty_args, plain_auth=options[:plain_auth])
43
37
  end
38
+ return 0
44
39
  end
45
40
 
46
41
  def putty_connect(vm, args, plain_auth=False)
47
- # Get the path to the private key for VM.
48
- private_key = vm.config.putty.private_key_path || "#{vm.env.default_private_key_path}.ppk"
42
+ ssh_info = vm.ssh_info
43
+ # If ssh_info is nil, the machine is not ready for ssh.
44
+ raise Vagrant::Errors::SSHNotReady if ssh_info.nil?
45
+
46
+ # The config.putty directive overrides the config.ssh private_key_path directive.
47
+ private_key = vm.config.putty.private_key_path || "#{ssh_info[:private_key_path]}.ppk"
49
48
  pk_path = File.expand_path("#{private_key}", vm.env.root_path)
50
49
  @logger.debug("Putty Private Key: #{pk_path}")
51
50
 
52
- # Load options set in the Vagrantfile
53
- ssh_port = vm.config.ssh.port || vm.driver.ssh_port(vm.config.ssh.guest_port)
54
- options = [vm.config.ssh.host]
55
- options += ["-l", vm.config.putty.username || vm.config.ssh.username]
56
- options += ["-P", ssh_port.to_s]
51
+ # Load options from machine ssh_info.
52
+ options = [ssh_info[:host]]
53
+ # config.putty.username overrides the machines ssh_info username.
54
+ options += ["-l", vm.config.putty.username || ssh_info[:username]]
55
+ options += ["-P", ssh_info[:port].to_s]
57
56
  options += ["-i", pk_path] if !plain_auth
58
- options += ["-X"] if vm.config.ssh.forward_x11
59
- options += ["-A"] if vm.config.ssh.forward_agent
57
+ options += ["-X"] if ssh_info[:forward_x11]
58
+ options += ["-A"] if ssh_info[:forward_agent]
60
59
 
61
60
  # Add in additional args from the command line.
62
61
  options.concat(args) if !args.nil?
@@ -68,6 +67,4 @@ module VagrantMultiPutty
68
67
  Process.detach(pid)
69
68
  end
70
69
  end
71
-
72
- Vagrant.commands.register(:putty) { Command }
73
70
  end
@@ -1,9 +1,16 @@
1
-
2
1
  module VagrantMultiPutty
3
- class PuttyConfig < Vagrant::Config::Base
2
+ class PuttyConfig < Vagrant.plugin(2, :config)
4
3
  attr_accessor :username
5
4
  attr_accessor :private_key_path
6
- end
7
5
 
8
- Vagrant.config_keys.register(:putty) { PuttyConfig }
6
+ def initialize
7
+ @username = UNSET_VALUE
8
+ @private_key_path = UNSET_VALUE
9
+ end
10
+
11
+ def finalize!
12
+ @username = nil if @username == UNSET_VALUE
13
+ @private_key_path = nil if @private_key_path == UNSET_VALUE
14
+ end
15
+ end
9
16
  end
@@ -0,0 +1,21 @@
1
+ require 'vagrant'
2
+
3
+ module VagrantMultiPutty
4
+ class Plugin < Vagrant.plugin("2")
5
+ name "vagrant-multi-putty"
6
+ description <<-DESC
7
+ Vagrant-multi-putty allows you to ssh into your virtual machines using the putty
8
+ program. This plugin also supports opening putty sessions into multi-vm environments.
9
+ DESC
10
+
11
+ command "putty" do
12
+ require_relative "command"
13
+ Command
14
+ end
15
+
16
+ config "putty" do
17
+ require_relative "config"
18
+ PuttyConfig
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module VagrantMultiPutty
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -13,8 +13,6 @@ Gem::Specification.new do |s|
13
13
 
14
14
  s.required_rubygems_version = ">= 1.4.0"
15
15
 
16
- s.add_dependency "vagrant", "~> 1.0.5"
17
-
18
16
  s.files = `git ls-files`.split("\n")
19
17
  s.require_path = 'lib'
20
18
  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.0.1
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,24 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-05 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: vagrant
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: 1.0.5
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- version: 1.0.5
12
+ date: 2013-04-10 00:00:00.000000000 Z
13
+ dependencies: []
30
14
  description: Vagrant plugin to allow VM ssh with PuTTY (multi-vm supported)
31
15
  email:
32
16
  - nickryand@gmail.com
@@ -37,11 +21,12 @@ files:
37
21
  - Gemfile
38
22
  - LICENSE
39
23
  - README.md
24
+ - Rakefile
40
25
  - lib/vagrant-multi-putty.rb
41
26
  - lib/vagrant-multi-putty/command.rb
42
27
  - lib/vagrant-multi-putty/config.rb
28
+ - lib/vagrant-multi-putty/plugin.rb
43
29
  - lib/vagrant-multi-putty/version.rb
44
- - lib/vagrant_init.rb
45
30
  - vagrant-multi-putty.gemspec
46
31
  homepage: https://github.com/nickryand/vagrant-multi-putty
47
32
  licenses:
@@ -56,6 +41,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
41
  - - ! '>='
57
42
  - !ruby/object:Gem::Version
58
43
  version: '0'
44
+ segments:
45
+ - 0
46
+ hash: 464008797
59
47
  required_rubygems_version: !ruby/object:Gem::Requirement
60
48
  none: false
61
49
  requirements:
data/lib/vagrant_init.rb DELETED
@@ -1 +0,0 @@
1
- require 'vagrant-multi-putty'