vagrant-fwdports 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c19066fdbe7c3c58310e52b84eaa4601bcd42f36
4
+ data.tar.gz: 477b066401d5772a61d721dc81a705384d787548
5
+ SHA512:
6
+ metadata.gz: ab0b1827ea9e438dde5e9c043afe0d11fe718503dc96441dad87c327b0aecd904d0e8789a3b8687fd182d08015429825314e266c55ba234135398e6156945624
7
+ data.tar.gz: b807a1b01cba4c3401b5d623d9f206d9489a426180c0798e985d81a878e0ed31d6e912810426b35b959d61baf758991acfbb7c2d96eef7230752252090306b00
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vagrant-fwdports.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Takuya Arita
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,54 @@
1
+ # vagrant-fwdports
2
+
3
+ Vagrant's networking feature is great.
4
+ but sometimes we are confusing with auto-corrected ports.
5
+
6
+ vagrant-fwdports shows list of forwarded ports on Vagrant VM.
7
+
8
+ ## Notice
9
+
10
+ vagrant-fwdports supports only VirtualBox provider.
11
+
12
+ ## Installation
13
+
14
+ Clone vagrant-fwdports into working directory:
15
+
16
+ git clone https://github.com/ariarijp/vagrant-fwdports.git
17
+
18
+ Into vagrant-fwdports directory:
19
+
20
+ cd vagrant-fwdports
21
+
22
+ And then execute:
23
+
24
+ rake build
25
+
26
+ Finally install it:
27
+
28
+ vagrant plugin install ./pkg/vagrant-fwdports-[version].gem
29
+
30
+ ## Usage
31
+
32
+ vagrant fwdports
33
+
34
+
35
+ On Single VM
36
+
37
+ ```
38
+ +--------------------------------------+--------------+---------------------+------------+-----------+
39
+ | machine.id | machine.name | forwarded_port_name | guest_port | host_port |
40
+ +--------------------------------------+--------------+---------------------+------------+-----------+
41
+ | 7f4b1865-c6e9-45e7-8044-2c6a080440ee | default | ssh | 22 | 2222 |
42
+ +--------------------------------------+--------------+---------------------+------------+-----------+
43
+ ```
44
+
45
+ On Multi VM
46
+
47
+ ```
48
+ +--------------------------------------+--------------+---------------------+------------+-----------+
49
+ | machine.id | machine.name | forwarded_port_name | guest_port | host_port |
50
+ +--------------------------------------+--------------+---------------------+------------+-----------+
51
+ | aa0d0f4c-80bd-44f3-80f4-b2a6febecc8f | web | ssh | 22 | 2222 |
52
+ | c2ea05d3-f9ba-4b60-b8f9-6829b0c88123 | db | ssh | 22 | 2200 |
53
+ +--------------------------------------+--------------+---------------------+------------+-----------+
54
+ ```
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,11 @@
1
+ require "vagrant-fwdports/version"
2
+ require "vagrant-fwdports/plugin"
3
+
4
+ module VagrantPlugins
5
+ module FwdPorts
6
+ def self.source_root
7
+ @source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
8
+ end
9
+ end
10
+ end
11
+
@@ -0,0 +1,56 @@
1
+ require 'terminal-table'
2
+ require 'pp'
3
+
4
+ module VagrantPlugins
5
+ module FwdPorts
6
+ class FwdPortsError < Vagrant::Errors::VagrantError
7
+ error_namespace("vagrant-fwdports.errors")
8
+ end
9
+
10
+ class Command < Vagrant.plugin("2", :command)
11
+ include Vagrant::Util::SafePuts
12
+
13
+ def self.synopsis
14
+ "outputs list of forwarded ports on the vagrant machine"
15
+ end
16
+
17
+ def execute
18
+ options = {}
19
+
20
+ opts = OptionParser.new do |o|
21
+ o.banner = "Usage: vagrant fwdports"
22
+ end
23
+
24
+ argv = parse_options(opts)
25
+ return if !argv
26
+
27
+ results = []
28
+ state = nil;
29
+
30
+ with_target_vms(argv) do |machine|
31
+ id = machine.id
32
+ name = machine.name
33
+ state = machine.state
34
+ provider = machine.provider
35
+ driver = provider.driver
36
+
37
+ if state.id != :running
38
+ raise FwdPortsError.new :vm_is_not_running
39
+ elsif machine.provider_name != :virtualbox
40
+ raise FwdPortsError.new :provider_not_supported
41
+ end
42
+
43
+ driver.read_forwarded_ports.each do |fwdport|
44
+ results << [id, name, fwdport[1], fwdport[3], fwdport[2]]
45
+ end
46
+ end
47
+
48
+ table = Terminal::Table.new :rows => results, :headings => ['machine.id', 'machine.name', 'forwarded_port_name', 'guest_port', 'host_port']
49
+ @env.ui.info table.to_s
50
+
51
+ # Success, exit status 0
52
+ 0
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,21 @@
1
+ module VagrantPlugins
2
+ module FwdPorts
3
+ class Plugin < Vagrant.plugin('2')
4
+ name 'FwdPorts'
5
+ description <<-DESC
6
+ This plugin shows number of forwarded ports on your guest machine.
7
+ DESC
8
+
9
+ command(:fwdports) do
10
+ setup_i18n
11
+ require_relative 'command'
12
+ Command
13
+ end
14
+
15
+ def self.setup_i18n
16
+ I18n.load_path << File.expand_path('../../../locales/en.yml', __FILE__)
17
+ I18n.reload!
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,5 @@
1
+ module Vagrant
2
+ module Fwdports
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ en:
2
+ vagrant-fwdports:
3
+ errors:
4
+ vm_is_not_running: |-
5
+ VM is not running. Run `vagrant up`
6
+ provider_not_supported: |-
7
+ vagrant-fwdports does not support this provider.
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-fwdports/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-fwdports"
8
+ spec.version = Vagrant::Fwdports::VERSION
9
+ spec.authors = ["Takuya Arita"]
10
+ spec.email = ["takuya.arita@gmail.com"]
11
+ spec.description = "Show list of forwarded ports on Vagrant VM."
12
+ spec.summary = "Show list of forwarded ports on Vagrant VM."
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "terminal-table"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-fwdports
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Takuya Arita
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: terminal-table
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Show list of forwarded ports on Vagrant VM.
56
+ email:
57
+ - takuya.arita@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/vagrant-fwdports.rb
68
+ - lib/vagrant-fwdports/command.rb
69
+ - lib/vagrant-fwdports/plugin.rb
70
+ - lib/vagrant-fwdports/version.rb
71
+ - locales/en.yml
72
+ - vagrant-fwdports.gemspec
73
+ homepage: ''
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.2.1
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Show list of forwarded ports on Vagrant VM.
97
+ test_files: []