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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fcd46de12c5ef967bd25ad6f494c597519b3e986
4
- data.tar.gz: b5edddbf5c610d8b726cb0f4c03f28098b1b6fc3
3
+ metadata.gz: cdcf8a578e0612bb91f99e478bdf1531822e3f9b
4
+ data.tar.gz: 776d7c48bdc21547f31dce203da85f83e1466874
5
5
  SHA512:
6
- metadata.gz: 9c7d38326331f0ffa9586f33e6b6681ca5e7ff4c9bd719635cf2159e6bc8d8983a817bc734af051adac24cb63a23fe24f2a8560e222c4c38bd6876a7f688c8f6
7
- data.tar.gz: f30809d380438c6a759201778b704b8c15c1fb5db78979932c55d667df55b1b8892cf022afea8ee3829baf89a9dfc05d01f75988b55da0e67b26389704adae91
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
- # Only active VMS pls.
38
- if !machine.communicate.ready?
39
- raise Vagrant::Errors::VMNotCreatedError
40
- end
39
+ state = machine.state
41
40
 
42
- ## Looks like this is pretty provider specific.
43
- case machine.provider_name
44
- when :virtualbox
45
- info = machine.provider.driver.execute('showvminfo', uuid, '--machinereadable', retryable: true)
46
- info.split("\n").each do |line|
47
- current_nic = $1.to_i if line =~ /^nic(\d+)=".+?"$/
48
- if line =~ /^Forwarding.+?="(.+?),(.+?),(.*?),(.+?),(.*?),(.+?)"$/
49
- widths[:nic_id] = "nic: #{current_nic.to_s}".length if "nic: #{current_nic.to_s}".length > widths[:nic_id]
50
-
51
- widths[:host_ip] = $3.to_s.length if $3.to_s.length > widths[:host_ip]
52
- widths[:host_port] = $4.to_s.length if $4.to_s.length > widths[:host_port]
53
-
54
- widths[:guest_ip] = $5.to_s.length if $5.to_s.length > widths[:guest_ip]
55
- widths[:guest_port] = $6.to_s.length if $6.to_s.length > widths[:guest_port]
56
-
57
- widths[:name] = $1.to_s.length if $1.to_s.length > widths[:name]
58
-
59
- machine_results << {
60
- :nic_id => current_nic,
61
- :name => $1.to_s,
62
- :protocol => $2.to_s,
63
- :host_ip => $3.to_s,
64
- :host_port => $4.to_s,
65
- :guest_ip => $5.to_s,
66
- :guest_port => $6.to_s,
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
- 'host ip'.rjust(widths[:host_ip]),':', 'port'.ljust(widths[:host_port]),
84
- 'protocol'.rjust(widths[:protocol]),
85
- 'name'.rjust(widths[:name])
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
- @env.ui.info(header.join(""))
91
- @env.ui.info('-' * header.join("").length)
92
- machine[:port_forwards].each do |fwd|
93
- line = []
94
- line << [ "nic[#{fwd[:nic_id]}]".ljust(widths[:nic_id]) ]
95
- line << [ fwd[:guest_ip].rjust(widths[:guest_ip]), ':', fwd[:guest_port].ljust(widths[:guest_port]) ]
96
- line << [ ' -> ' ]
97
- line << [ fwd[:host_ip].rjust(widths[:host_ip]), ':', fwd[:host_port].ljust(widths[:host_port]) ]
98
- line << [ fwd[:protocol].rjust(widths[:protocol]) ]
99
- line << [ fwd[:name].rjust(widths[:name]) ]
100
- opts = {}
101
- if fwd[:name] == 'ssh'
102
- opts[:color] = :yellow
103
- elsif fwd[:name] != "#{fwd[:protocol]}#{fwd[:host_port]}"
104
- opts[:color] = :red
105
- end
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
- @env.ui.info(line.join(""), opts)
116
+ @env.ui.info(line.join(""), opts)
117
+ end
108
118
  end
109
119
  @env.ui.info("")
110
120
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Netinfo
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  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.3
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-08 00:00:00.000000000 Z
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.0.14
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: