vagrant-redir 0.1.1 → 0.1.2
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/.gitignore +18 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +21 -0
- data/README.md +236 -0
- data/Rakefile +6 -0
- data/bin/clean_test_dir +5 -0
- data/bin/console +14 -0
- data/bin/link_test_dir +39 -0
- data/bin/setup +8 -0
- data/lib/vagrant/redir/command/addr.rb +60 -0
- data/lib/vagrant/redir/command/config.rb +56 -0
- data/lib/vagrant/redir/command/down.rb +47 -0
- data/lib/vagrant/redir/command/kill.rb +47 -0
- data/lib/vagrant/redir/command/pids.rb +53 -0
- data/lib/vagrant/redir/command/ps.rb +53 -0
- data/lib/vagrant/redir/command/root.rb +84 -0
- data/lib/vagrant/redir/command/status.rb +54 -0
- data/lib/vagrant/redir/command/up.rb +67 -0
- data/lib/vagrant/redir/errors.rb +20 -0
- data/lib/vagrant/redir/helper.rb +230 -0
- data/lib/vagrant/redir/plugin.rb +30 -0
- data/lib/vagrant/redir/version.rb +5 -0
- data/lib/vagrant/redir.rb +10 -0
- data/locales/en.yml +21 -0
- data/vagrant-redir.gemspec +24 -0
- metadata +30 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b1c8789c7750060b8749d313883dce21fcad8bf9
|
|
4
|
+
data.tar.gz: ef453e3fafa1f95d1147de45274d9e602ab45ff4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3abde7d52ca301d85887b26f740a8ba4c87c8c7a4815313b24c255ca6357a2ef9bb1eee892d2bee332622e6fc735be07e17662f35a87f4b0e72f30c206fa375c
|
|
7
|
+
data.tar.gz: 0ad8718b6c11d81ab83a17475bdaf3fb8bc9b508bf5c4edfd0d3e760e97b4d55199f9cfcfae60a6ad2ee425724cc864e3064cea599b244724f7f09eccca7a740
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at TODO: Write your email address. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
source "https://rubygems.org"
|
|
2
|
+
|
|
3
|
+
group :development do
|
|
4
|
+
gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
group :plugins do
|
|
8
|
+
gem "bundler", "~> 1.13"
|
|
9
|
+
gem "rake", "~> 10.0"
|
|
10
|
+
gem "rspec", "~> 3.0"
|
|
11
|
+
gem "vagrant-redir", path: "."
|
|
12
|
+
end
|
|
13
|
+
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 st02tkh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# vagrant-redir
|
|
2
|
+
|
|
3
|
+
This plugin allows to manage redir's ports forwarding used by vagrant-lxc provider.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
$ vagrant plugin install vagrant-redir
|
|
11
|
+
```
|
|
12
|
+
or
|
|
13
|
+
|
|
14
|
+
```shell
|
|
15
|
+
$ git clone https://github.com/st02tkh/vagrant-redir.git
|
|
16
|
+
$ cd vagrant-redir
|
|
17
|
+
$ gem build vagrant-redir.gemspec
|
|
18
|
+
$ vagrant plugin install ./vagrant-redir-X.Y.Z.gem
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
Show available subcommands:
|
|
24
|
+
|
|
25
|
+
```shell
|
|
26
|
+
$ vagrant redir <subcommand>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Shows a help for a subcommand run it with '-h':
|
|
30
|
+
|
|
31
|
+
```shell
|
|
32
|
+
$ vagrant redir <subcommand> -h
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### addr
|
|
37
|
+
|
|
38
|
+
Shows a list of VM's ID, name and public IP
|
|
39
|
+
|
|
40
|
+
```shell
|
|
41
|
+
$ vagrant redir addr
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
will show:
|
|
45
|
+
|
|
46
|
+
```shell
|
|
47
|
+
List of VM(s) public IP addresses:
|
|
48
|
+
id: xdg_1506653541513_93050 name: xdg ip: 10.0.3.173
|
|
49
|
+
id: db1_1506915461158_4146 name: db1 ip: 10.0.3.55
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
or for particular VM:
|
|
53
|
+
|
|
54
|
+
```shell
|
|
55
|
+
$ vagrant redir addr [<name>]
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
### config
|
|
61
|
+
|
|
62
|
+
Shows a list of VMs with a list of forwarded port for it:
|
|
63
|
+
|
|
64
|
+
```shell
|
|
65
|
+
$ vagrant redir config
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
will show:
|
|
69
|
+
|
|
70
|
+
```shell
|
|
71
|
+
Port forwarding configuration for VM 'xdg':
|
|
72
|
+
guest: 8000, host: 8900, host_ip: 0.0.0.0, protocol: tcp
|
|
73
|
+
guest: 8001, host: 8901, host_ip: 0.0.0.0, protocol: tcp
|
|
74
|
+
guest: 80, host: 8908, host_ip: 0.0.0.0, protocol: tcp
|
|
75
|
+
guest: 22, host: 8902, host_ip: 0.0.0.0, protocol: tcp
|
|
76
|
+
|
|
77
|
+
Port forwarding configuration for VM 'db1':
|
|
78
|
+
guest: 8000, host: 9000, host_ip: 0.0.0.0, protocol: tcp
|
|
79
|
+
guest: 8001, host: 9001, host_ip: 0.0.0.0, protocol: tcp
|
|
80
|
+
guest: 80, host: 9080, host_ip: 0.0.0.0, protocol: tcp
|
|
81
|
+
guest: 22, host: 9022, host_ip: 0.0.0.0, protocol: tcp
|
|
82
|
+
```
|
|
83
|
+
or for particular VM:
|
|
84
|
+
|
|
85
|
+
```shell
|
|
86
|
+
$ vagrant redir config [<name>]
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
### down
|
|
92
|
+
|
|
93
|
+
Shut down redir processes used for port forwarding for VMs.
|
|
94
|
+
Same process vagrant starts on 'vagrant halt' command.
|
|
95
|
+
|
|
96
|
+
```shell
|
|
97
|
+
$ vagrant redir down
|
|
98
|
+
```
|
|
99
|
+
or for particular VM:
|
|
100
|
+
|
|
101
|
+
```shell
|
|
102
|
+
$ vagrant redir down [<name>]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
### kill
|
|
108
|
+
|
|
109
|
+
Kill redir processes used for port forwarding for VMs.
|
|
110
|
+
This is usefull when lxc contaner was stopped not by 'vagrant halt' command and redir processes are still running.
|
|
111
|
+
|
|
112
|
+
```shell
|
|
113
|
+
$ vagrant redir kill
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
or for particular VM:
|
|
117
|
+
|
|
118
|
+
```shell
|
|
119
|
+
$ vagrant redir kill [<name>]
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
### pids
|
|
125
|
+
|
|
126
|
+
Show stored redir pids and appropriate processes states
|
|
127
|
+
This is helpful to diagnose are all redir processes running or some of them are not running.
|
|
128
|
+
|
|
129
|
+
```shell
|
|
130
|
+
$ vagrant redir pids
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
will show:
|
|
134
|
+
|
|
135
|
+
```shell
|
|
136
|
+
List of stored redir's pids of VM 'xdg':
|
|
137
|
+
pid: 16458; host_port: 8901; is_system_port: false; is_running: false
|
|
138
|
+
pid: 16472; host_port: 8908; is_system_port: false; is_running: false
|
|
139
|
+
pid: 16486; host_port: 8902; is_system_port: false; is_running: false
|
|
140
|
+
pid: 16444; host_port: 8900; is_system_port: false; is_running: false
|
|
141
|
+
|
|
142
|
+
List of stored redir's pids of VM 'db1':
|
|
143
|
+
pid: 16519; host_port: 9000; is_system_port: false; is_running: false
|
|
144
|
+
pid: 16547; host_port: 9080; is_system_port: false; is_running: false
|
|
145
|
+
pid: 16533; host_port: 9001; is_system_port: false; is_running: false
|
|
146
|
+
pid: 16561; host_port: 9022; is_system_port: false; is_running: false
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
or for particular VM:
|
|
150
|
+
|
|
151
|
+
```shell
|
|
152
|
+
$ vagrant redir pids [<name>]
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
### ps
|
|
158
|
+
|
|
159
|
+
Show pids of running redir processes grepped by VM's public IP
|
|
160
|
+
|
|
161
|
+
```shell
|
|
162
|
+
$ vagrant redir ps
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
will show:
|
|
166
|
+
|
|
167
|
+
```shell
|
|
168
|
+
List of running redir's pids for VM 'xdg' grepped by public IP:
|
|
169
|
+
pid: 12637; host_port: 8900; is_system_port: false
|
|
170
|
+
pid: 12651; host_port: 8901; is_system_port: false
|
|
171
|
+
pid: 12665; host_port: 8908; is_system_port: false
|
|
172
|
+
pid: 12679; host_port: 8902; is_system_port: false
|
|
173
|
+
|
|
174
|
+
List of running redir's pids for VM 'db1' grepped by public IP:
|
|
175
|
+
pid: 12712; host_port: 9000; is_system_port: false
|
|
176
|
+
pid: 12726; host_port: 9001; is_system_port: false
|
|
177
|
+
pid: 12740; host_port: 9080; is_system_port: false
|
|
178
|
+
pid: 12754; host_port: 9022; is_system_port: false
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
or for particular VM:
|
|
182
|
+
|
|
183
|
+
```shell
|
|
184
|
+
$ vagrant redir ps [<name>]
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
### status
|
|
191
|
+
|
|
192
|
+
Show list of running redir processes by stored pids
|
|
193
|
+
|
|
194
|
+
```shell
|
|
195
|
+
$ vagrant redir status
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
or for particular VM:
|
|
200
|
+
|
|
201
|
+
```shell
|
|
202
|
+
$ vagrant redir status [<name>]
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
### up
|
|
208
|
+
|
|
209
|
+
Setup port forwarding for vm(s).
|
|
210
|
+
Same process vagrant starts on 'vagrant up' command.
|
|
211
|
+
|
|
212
|
+
```shell
|
|
213
|
+
$ vagrant redir pids
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
or for particular VM:
|
|
218
|
+
|
|
219
|
+
```shell
|
|
220
|
+
$ vagrant redir pids [<name>]
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
## Contributing
|
|
227
|
+
|
|
228
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/st02tkh/vagrant-redir. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
229
|
+
|
|
230
|
+
## License
|
|
231
|
+
|
|
232
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
233
|
+
|
|
234
|
+
## Code of Conduct
|
|
235
|
+
|
|
236
|
+
Everyone interacting in the Vagrant::Redir project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/vagrant-redir/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/clean_test_dir
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "vagrant/redir"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/link_test_dir
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#! /usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
if [ -z "$1" ]; then
|
|
4
|
+
echo "Usage: $0 TGT_DIR"
|
|
5
|
+
echo " TGT_DIR - a directory with Vagrantfile"
|
|
6
|
+
exit 100
|
|
7
|
+
fi
|
|
8
|
+
|
|
9
|
+
except_list=".git .gitignore .gitmodules bin lib spec Gemfile Gemfile.lock README README.md Puppetfile redir_map locales"
|
|
10
|
+
|
|
11
|
+
this_dir="$(cd $(dirname "$0") && pwd)"
|
|
12
|
+
proj_dir="$(cd "$this_dir/.." && pwd)"
|
|
13
|
+
tgt_dir="$(cd "$1" && pwd)"
|
|
14
|
+
|
|
15
|
+
function list_include_item {
|
|
16
|
+
local list="$1"
|
|
17
|
+
local item="$2"
|
|
18
|
+
if [[ $list =~ (^|[[:space:]])"$item"($|[[:space:]]) ]] ; then
|
|
19
|
+
# yes, list include item
|
|
20
|
+
result=0
|
|
21
|
+
else
|
|
22
|
+
result=1
|
|
23
|
+
fi
|
|
24
|
+
return $result
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
find "$tgt_dir" -mindepth 1 -maxdepth 1 | while read tgt_path; do
|
|
28
|
+
tgt_basename="$(basename "$tgt_path")"
|
|
29
|
+
if `list_include_item "$except_list" "$tgt_basename"` ; then
|
|
30
|
+
:
|
|
31
|
+
else
|
|
32
|
+
(cd "$proj_dir" \
|
|
33
|
+
&& ([ -L "$tgt_basename" ] \
|
|
34
|
+
&& ln -sf "$tgt_basename" && rm "$tgt_basename"; : ) \
|
|
35
|
+
&& ln -s "$tgt_path"
|
|
36
|
+
)
|
|
37
|
+
echo "$tgt_path -> $proj_dir/$tgt_basename"
|
|
38
|
+
fi
|
|
39
|
+
done
|
data/bin/setup
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require "log4r"
|
|
2
|
+
require 'optparse'
|
|
3
|
+
require "vagrant/redir/helper"
|
|
4
|
+
|
|
5
|
+
module Vagrant
|
|
6
|
+
module Redir
|
|
7
|
+
module Command
|
|
8
|
+
class Addr < Vagrant.plugin("2", :command)
|
|
9
|
+
|
|
10
|
+
include Vagrant::Redir::Helper
|
|
11
|
+
|
|
12
|
+
def initialize(argv, env)
|
|
13
|
+
super
|
|
14
|
+
@logger = Log4r::Logger.new("vagrant::redir::command::addr")
|
|
15
|
+
@argv
|
|
16
|
+
@env = env
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def execute
|
|
20
|
+
return help if @argv.include?("-h") || @argv.include?("--help")
|
|
21
|
+
|
|
22
|
+
opts = OptionParser.new
|
|
23
|
+
argv = parse_options(opts)
|
|
24
|
+
@logger.debug("argv: #{argv}")
|
|
25
|
+
|
|
26
|
+
if with_target_vms(argv) { }.count > 0
|
|
27
|
+
@env.ui.info I18n.t("vagrant_redir.command.addr.list_title")
|
|
28
|
+
with_target_vms(argv) do |vm|
|
|
29
|
+
|
|
30
|
+
pub_ip = vm.provider.capability(:public_address)
|
|
31
|
+
|
|
32
|
+
if vm.state.id != :running
|
|
33
|
+
raise ::Vagrant::Redir::Errors::NotRunning
|
|
34
|
+
end
|
|
35
|
+
if pub_ip == nil
|
|
36
|
+
raise ::Vagrant::Redir::Errors::Unknown
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
@env.ui.info I18n.t("vagrant_redir.command.addr.list_item", id: vm.id, name: vm.name, ip: pub_ip)
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def help
|
|
46
|
+
opts = OptionParser.new do |opts|
|
|
47
|
+
opts.banner = "Usage: vagrant redir addr [<name>]"
|
|
48
|
+
opts.separator ""
|
|
49
|
+
opts.separator "Show VM's ID, name and public IP address"
|
|
50
|
+
opts.separator ""
|
|
51
|
+
opts.separator " <name> - optional virtual machine name"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
@env.ui.info(opts.help, :prefix => false)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require "log4r"
|
|
2
|
+
require 'optparse'
|
|
3
|
+
require "vagrant/redir/helper"
|
|
4
|
+
|
|
5
|
+
module Vagrant
|
|
6
|
+
module Redir
|
|
7
|
+
module Command
|
|
8
|
+
class Config < Vagrant.plugin("2", :command)
|
|
9
|
+
|
|
10
|
+
include Vagrant::Redir::Helper
|
|
11
|
+
|
|
12
|
+
def initialize(argv, env)
|
|
13
|
+
super
|
|
14
|
+
@logger = Log4r::Logger.new("vagrant::redir::command::config")
|
|
15
|
+
@argv
|
|
16
|
+
@env = env
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def execute
|
|
20
|
+
return help if @argv.include?("-h") || @argv.include?("--help")
|
|
21
|
+
|
|
22
|
+
opts = OptionParser.new
|
|
23
|
+
argv = parse_options(opts)
|
|
24
|
+
@logger.debug("argv: #{argv}")
|
|
25
|
+
|
|
26
|
+
with_target_vms(argv) do |vm|
|
|
27
|
+
if compile_forwarded_ports(vm.config).any?
|
|
28
|
+
@env.ui.info I18n.t("vagrant_redir.command.config.list_title", name: vm.name)
|
|
29
|
+
compile_forwarded_ports(vm.config).each do |record|
|
|
30
|
+
r = record.delete(:id)
|
|
31
|
+
s = record.collect do |k, v|
|
|
32
|
+
"#{k}: #{v}"
|
|
33
|
+
end.join(', ')
|
|
34
|
+
@env.ui.info(" #{s}")
|
|
35
|
+
end
|
|
36
|
+
@env.ui.info("")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def help
|
|
42
|
+
opts = OptionParser.new do |opts|
|
|
43
|
+
opts.banner = "Usage: vagrant redir config [<name>]"
|
|
44
|
+
opts.separator ""
|
|
45
|
+
opts.separator "Show port forwarding configuration"
|
|
46
|
+
opts.separator ""
|
|
47
|
+
opts.separator " <name> - optional virtual machine name"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
@env.ui.info(opts.help, :prefix => false)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require "log4r"
|
|
2
|
+
require 'optparse'
|
|
3
|
+
require "vagrant/redir/helper"
|
|
4
|
+
|
|
5
|
+
module Vagrant
|
|
6
|
+
module Redir
|
|
7
|
+
module Command
|
|
8
|
+
class Down < Vagrant.plugin("2", :command)
|
|
9
|
+
|
|
10
|
+
include Vagrant::Redir::Helper
|
|
11
|
+
|
|
12
|
+
def initialize(argv, env)
|
|
13
|
+
super
|
|
14
|
+
@logger = Log4r::Logger.new("vagrant::redir::command::down")
|
|
15
|
+
@argv
|
|
16
|
+
@env = env
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def execute
|
|
20
|
+
return help if @argv.include?("-h") || @argv.include?("--help")
|
|
21
|
+
|
|
22
|
+
opts = OptionParser.new
|
|
23
|
+
argv = parse_options(opts)
|
|
24
|
+
@logger.debug("argv: #{argv}")
|
|
25
|
+
|
|
26
|
+
with_target_vms(argv) do |vm|
|
|
27
|
+
@env.ui.info I18n.t("vagrant_redir.command.down.shutting_down_vm", name: vm.name)
|
|
28
|
+
ensure_killed_by_stored_pids(vm)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def help
|
|
33
|
+
opts = OptionParser.new do |opts|
|
|
34
|
+
opts.banner = "Usage: vagrant redir down [<name>]"
|
|
35
|
+
opts.separator ""
|
|
36
|
+
opts.separator "Shut down redir processes by stored pids and remove inactive stored pids"
|
|
37
|
+
opts.separator ""
|
|
38
|
+
opts.separator " <name> - optional virtual machine name"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
@env.ui.info(opts.help, :prefix => false)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require "log4r"
|
|
2
|
+
require 'optparse'
|
|
3
|
+
require "vagrant/redir/helper"
|
|
4
|
+
|
|
5
|
+
module Vagrant
|
|
6
|
+
module Redir
|
|
7
|
+
module Command
|
|
8
|
+
class Kill < Vagrant.plugin("2", :command)
|
|
9
|
+
|
|
10
|
+
include Vagrant::Redir::Helper
|
|
11
|
+
|
|
12
|
+
def initialize(argv, env)
|
|
13
|
+
super
|
|
14
|
+
@logger = Log4r::Logger.new("vagrant::redir::command::kill")
|
|
15
|
+
@argv
|
|
16
|
+
@env = env
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def execute
|
|
20
|
+
return help if @argv.include?("-h") || @argv.include?("--help")
|
|
21
|
+
|
|
22
|
+
opts = OptionParser.new
|
|
23
|
+
argv = parse_options(opts)
|
|
24
|
+
@logger.debug("argv: #{argv}")
|
|
25
|
+
|
|
26
|
+
with_target_vms(argv) do |vm|
|
|
27
|
+
@logger.debug "Killing redir processes for VM #{vm.name}:"
|
|
28
|
+
ensure_killed_by_ip(vm)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def help
|
|
33
|
+
opts = OptionParser.new do |opts|
|
|
34
|
+
opts.banner = "Usage: vagrant redir kill [<name>]"
|
|
35
|
+
opts.separator ""
|
|
36
|
+
opts.separator "Kill redir processes by stored pids and remove stoed pids"
|
|
37
|
+
opts.separator ""
|
|
38
|
+
opts.separator " <name> - optional virtual machine name"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
@env.ui.info(opts.help, :prefix => false)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|