vagrant-netinfo 0.0.3 → 0.0.4
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/lib/vagrant-netinfo/command.rb +64 -54
- data/lib/vagrant-netinfo/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdcf8a578e0612bb91f99e478bdf1531822e3f9b
|
4
|
+
data.tar.gz: 776d7c48bdc21547f31dce203da85f83e1466874
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39cc6e47742358fdffac60950c870b13b3dd0ef85e6182f3508c0d170a5f13e93a9fc75f8b3361ac3a70d23fc6e3079ef6c8302522a7ab140e0bb9ccecf2ba21
|
7
|
+
data.tar.gz: 297b5a0a6b773175302edcb81db25910952d575ba784dc44bb97414600ecba61f3745e773d17c40f1f07df997a97199ac890c244ec537466267196a547821838
|
@@ -29,82 +29,92 @@ module VagrantPlugins
|
|
29
29
|
results = []
|
30
30
|
uuid = nil
|
31
31
|
|
32
|
+
@logger.info("Loading all machines")
|
32
33
|
with_target_vms(argv) do |machine|
|
34
|
+
|
33
35
|
current_nic = nil
|
34
36
|
uuid = machine.id
|
35
37
|
machine_results = []
|
36
38
|
|
37
|
-
|
38
|
-
if !machine.communicate.ready?
|
39
|
-
raise Vagrant::Errors::VMNotCreatedError
|
40
|
-
end
|
39
|
+
state = machine.state
|
41
40
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
:name
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
41
|
+
if state.id == ::Vagrant::MachineState::NOT_CREATED_ID
|
42
|
+
## machine is not up or ready. Dont bother.
|
43
|
+
else
|
44
|
+
|
45
|
+
## Looks like this is pretty provider specific.
|
46
|
+
case machine.provider_name
|
47
|
+
when :virtualbox
|
48
|
+
info = machine.provider.driver.execute('showvminfo', uuid, '--machinereadable', retryable: true)
|
49
|
+
info.split("\n").each do |line|
|
50
|
+
current_nic = $1.to_i if line =~ /^nic(\d+)=".+?"$/
|
51
|
+
if line =~ /^Forwarding.+?="(.+?),(.+?),(.*?),(.+?),(.*?),(.+?)"$/
|
52
|
+
widths[:nic_id] = "nic: #{current_nic.to_s}".length if "nic: #{current_nic.to_s}".length > widths[:nic_id]
|
53
|
+
|
54
|
+
widths[:host_ip] = $3.to_s.length if $3.to_s.length > widths[:host_ip]
|
55
|
+
widths[:host_port] = $4.to_s.length if $4.to_s.length > widths[:host_port]
|
56
|
+
|
57
|
+
widths[:guest_ip] = $5.to_s.length if $5.to_s.length > widths[:guest_ip]
|
58
|
+
widths[:guest_port] = $6.to_s.length if $6.to_s.length > widths[:guest_port]
|
59
|
+
|
60
|
+
widths[:name] = $1.to_s.length if $1.to_s.length > widths[:name]
|
61
|
+
|
62
|
+
machine_results << {
|
63
|
+
:nic_id => current_nic,
|
64
|
+
:name => $1.to_s,
|
65
|
+
:protocol => $2.to_s,
|
66
|
+
:host_ip => $3.to_s,
|
67
|
+
:host_port => $4.to_s,
|
68
|
+
:guest_ip => $5.to_s,
|
69
|
+
:guest_port => $6.to_s,
|
70
|
+
}
|
71
|
+
end
|
68
72
|
end
|
73
|
+
else
|
74
|
+
raise Vagrant::Errors::ProviderNotUsable
|
69
75
|
end
|
70
|
-
else
|
71
|
-
raise Vagrant::Errors::ProviderNotUsable
|
72
76
|
end
|
73
77
|
|
74
78
|
results << {
|
75
79
|
:name => machine.name.to_s,
|
80
|
+
:state => state,
|
76
81
|
:provider => machine.provider_name.to_s,
|
77
82
|
:port_forwards => machine_results
|
78
83
|
}
|
79
84
|
end
|
80
85
|
|
81
86
|
header = [ ' '.ljust(widths[:nic_id]), 'guest ip'.rjust(widths[:guest_ip]), ':', 'port'.ljust(widths[:guest_port]),
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
87
|
+
' ',
|
88
|
+
'host ip'.rjust(widths[:host_ip]),':', 'port'.ljust(widths[:host_port]),
|
89
|
+
'protocol'.rjust(widths[:protocol]),
|
90
|
+
'name'.rjust(widths[:name])
|
86
91
|
]
|
87
92
|
|
93
|
+
no_results_states = [:not_created]
|
94
|
+
state = ''
|
95
|
+
|
88
96
|
results.each do |machine|
|
89
|
-
@env.ui.info("Machine '#{machine[:name].to_s}' (#{machine[:provider]})")
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
97
|
+
@env.ui.info("Machine '#{machine[:name].to_s}' (#{machine[:provider]}): #{machine[:state].short_description}")
|
98
|
+
if ! no_results_states.include?(machine[:state].id)
|
99
|
+
@env.ui.info(header.join(""))
|
100
|
+
@env.ui.info('-' * header.join("").length)
|
101
|
+
machine[:port_forwards].each do |fwd|
|
102
|
+
line = []
|
103
|
+
line << [ "nic[#{fwd[:nic_id]}]".ljust(widths[:nic_id]) ]
|
104
|
+
line << [ fwd[:guest_ip].rjust(widths[:guest_ip]), ':', fwd[:guest_port].ljust(widths[:guest_port]) ]
|
105
|
+
line << [ ' -> ' ]
|
106
|
+
line << [ fwd[:host_ip].rjust(widths[:host_ip]), ':', fwd[:host_port].ljust(widths[:host_port]) ]
|
107
|
+
line << [ fwd[:protocol].rjust(widths[:protocol]) ]
|
108
|
+
line << [ fwd[:name].rjust(widths[:name]) ]
|
109
|
+
opts = {}
|
110
|
+
if fwd[:name] == 'ssh'
|
111
|
+
opts[:color] = :yellow
|
112
|
+
elsif fwd[:name] != "#{fwd[:protocol]}#{fwd[:host_port]}"
|
113
|
+
opts[:color] = :red
|
114
|
+
end
|
106
115
|
|
107
|
-
|
116
|
+
@env.ui.info(line.join(""), opts)
|
117
|
+
end
|
108
118
|
end
|
109
119
|
@env.ui.info("")
|
110
120
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-netinfo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Vansteenkiste
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -89,8 +89,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
89
|
version: '0'
|
90
90
|
requirements: []
|
91
91
|
rubyforge_project:
|
92
|
-
rubygems_version: 2.
|
92
|
+
rubygems_version: 2.2.2
|
93
93
|
signing_key:
|
94
94
|
specification_version: 4
|
95
95
|
summary: Display network information on a running vagrant box
|
96
96
|
test_files: []
|
97
|
+
has_rdoc:
|