vagrant-goodhosts 1.1.0beta → 1.1.0beta2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f6a0225da423c0c803dacaeb97182e8768510d601db33c182a088733d282f60
4
- data.tar.gz: f2756ce326a5d766baa4fd63f5d4d158c13fb0591c88a9763dc6e9846b377bbc
3
+ metadata.gz: 58cfe3e3e7669fb2b8bf147db6786a38f6b94b8d4164460852872a007d2df40c
4
+ data.tar.gz: c5131a3c95e03d98a182092138ad55b1df1ae9cbe66ef7ad2800a2e3721b0d97
5
5
  SHA512:
6
- metadata.gz: 11d1c0937d56326ebbd390adc477c8c047b6422f0c81c21ad454d297992876941267102811acbc7e7e32e960a2feb2767d055f086a4461b8f6008cd1b81d0581
7
- data.tar.gz: 528d8f7ff5b81d8a377530a628710ef62ae4432790099f3c8a4673c01e2c3d1ef4032181680e63bc5cd49f8925d01374ed3d8ae919a09bd2849ad0def44022d2
6
+ metadata.gz: a6d3be03ecd50f179a01380ccda77aaddeddc943d324179e750777222c1b974c50186492d9753bdc8c3ae47da032363fcde0862a045c4fa741fe3335d8c26077
7
+ data.tar.gz: 4fd89f66e460df2accaf9ceae0ed8736b257dfde7e3b1f19cb8a65877e62f87d14d88421c4a98141a371b4aaf0170843555a4bd07e96976c6b60f2923d088925
@@ -110,24 +110,21 @@ module VagrantPlugins
110
110
  def add_goodhost_entries(ip_address, hostnames)
111
111
  cli = get_cli
112
112
  if cli.include? ".exe"
113
- clean = "\"--clean\","
114
- if disable_clean(ip_address)
115
- clean = ''
116
- end
117
- stdin, stdout, stderr, wait_thr = Open3.popen3("powershell", "-Command", "Start-Process '#{cli}' -ArgumentList \"add\",#{clean}\"#{ip_address}\",\"#{hostnames}\" -Verb RunAs")
113
+ clean = get_clean_parameter_by_system(ip_address, true)
114
+ command = "Start-Process '#{cli}' -ArgumentList \"add\",#{clean}\"#{ip_address}\",\"#{hostnames}\" -Verb RunAs"
115
+ stdin, stdout, stderr, wait_thr = Open3.popen3("powershell", "-Command", command)
118
116
  else
119
- clean = "--clean"
120
- if disable_clean(ip_address)
121
- clean = ''
122
- end
123
- stdin, stdout, stderr, wait_thr = Open3.popen3("sudo '#{cli}' add #{clean} #{ip_address} #{hostnames}")
117
+ clean = get_clean_parameter_by_system(ip_address, false)
118
+ command = "sudo '#{cli}' add #{clean} #{ip_address} #{hostnames}"
119
+ stdin, stdout, stderr, wait_thr = Open3.popen3(command)
124
120
  end
125
- return stdin, stdout, stderr, wait_thr
121
+ return stdin, stdout, stderr, wait_thr, command
126
122
  end
127
123
 
128
124
  def add_host_entries
129
125
  error = false
130
- error_text = ""
126
+ error_text = ''
127
+ command = ''
131
128
  hostnames_by_ips = generate_hostnames_by_ips
132
129
 
133
130
  return if hostnames_by_ips.none?
@@ -144,32 +141,33 @@ module VagrantPlugins
144
141
  hosts_to_add = check_hostnames_to_add(ip_address, hostnames)
145
142
  next if hosts_to_add.none?
146
143
 
147
- _stdin, _stdout, stderr, wait_thr = add_goodhost_entries(ip_address, hosts_to_add)
144
+ _stdin, _stdout, stderr, wait_thr, command = add_goodhost_entries(ip_address, hosts_to_add)
148
145
  unless wait_thr.value.success?
149
146
  error = true
150
147
  error_text = stderr.read.strip
151
148
  end
152
149
  end
153
- print_readme(error, error_text)
150
+ print_readme(error, error_text, command)
154
151
  end
155
152
 
156
153
  def remove_goodhost_entries(ip_address, hostnames)
157
154
  cli = get_cli
158
- clean = "\"--clean\","
159
- if disable_clean(ip_address)
160
- clean = ''
161
- end
162
155
  if cli.include? ".exe"
163
- stdin, stdout, stderr, wait_thr = Open3.popen3("powershell", "-Command", "Start-Process '#{cli}' -ArgumentList \"remove\",#{clean}\"#{ip_address}\",\"#{hostnames}\" -Verb RunAs")
156
+ clean = get_clean_parameter_by_system(ip_address, true)
157
+ command = "Start-Process '#{cli}' -ArgumentList \"remove\",#{clean}\"#{ip_address}\",\"#{hostnames}\" -Verb RunAs"
158
+ stdin, stdout, stderr, wait_thr = Open3.popen3("powershell", "-Command", command)
164
159
  else
165
- stdin, stdout, stderr, wait_thr = Open3.popen3("sudo '#{cli}' remove #{clean} #{ip_address} #{hostnames}")
160
+ clean = get_clean_parameter_by_system(ip_address, false)
161
+ command = "sudo '#{cli}' remove #{clean} #{ip_address} #{hostnames}"
162
+ stdin, stdout, stderr, wait_thr = Open3.popen3(command)
166
163
  end
167
- return stdin, stdout, stderr, wait_thr
164
+ return stdin, stdout, stderr, wait_thr, command
168
165
  end
169
166
 
170
167
  def remove_host_entries
171
168
  error = false
172
- error_text = ""
169
+ error_text = ''
170
+ command = ''
173
171
  hostnames_by_ips = generate_hostnames_by_ips
174
172
 
175
173
  return if hostnames_by_ips.none?
@@ -182,22 +180,35 @@ module VagrantPlugins
182
180
  next
183
181
  end
184
182
 
185
- _stdin, _stdout, stderr, wait_thr = remove_goodhost_entries(ip_address, hostnames)
183
+ _stdin, _stdout, stderr, wait_thr, command = remove_goodhost_entries(ip_address, hostnames)
186
184
  unless wait_thr.value.success?
187
185
  error = true
188
186
  error_text = stderr.read.strip
189
187
  end
190
188
  end
191
- print_readme(error, error_text)
189
+ print_readme(error, error_text, command)
192
190
  end
193
191
 
194
- def print_readme(error, error_text)
192
+ def get_clean_parameter_by_system(ip_address, is_win)
193
+ clean = "--clean"
194
+ if is_win
195
+ clean = "\"--clean\","
196
+ end
197
+
198
+ if disable_clean(ip_address)
199
+ clean = ''
200
+ end
201
+ return clean
202
+ end
203
+
204
+ def print_readme(error, error_text, command)
195
205
  unless error
196
206
  return false
197
207
  end
198
208
 
199
209
  cli = get_cli
200
210
  @ui.error "[vagrant-goodhosts] Issue executing goodhosts CLI: #{error_text}"
211
+ @ui.error "[vagrant-goodhosts] Command: #{command}"
201
212
  @ui.error "[vagrant-goodhosts] Cli path: #{cli}"
202
213
  if cli.include? ".exe"
203
214
  @ui.error "[vagrant-goodhosts] Check the readme at https://github.com/goodhosts/vagrant#windows-uac-prompt"
@@ -207,6 +218,18 @@ module VagrantPlugins
207
218
  end
208
219
  end
209
220
 
221
+ def append_hostsnames_by_ips(hostnames_by_ips, hostnames, ip_address, ip_index)
222
+ if hostnames[ip_index].count() > 0
223
+ hostnames[ip_index].each do |hostname|
224
+ unless ip_address.nil?
225
+ @ui.info "[vagrant-goodhosts] - found entry for: #{ip_address} #{hostname}"
226
+ end
227
+ end
228
+ hostnames_by_ips = { ip_address => hostnames[ip_index].join(" ") }
229
+ end
230
+ return hostnames_by_ips
231
+ end
232
+
210
233
  def generate_hostnames_by_ips
211
234
  hostnames_by_ips = []
212
235
  ips = get_ips
@@ -218,25 +241,11 @@ module VagrantPlugins
218
241
  if ips.count() > 1
219
242
  ips.each do |ip|
220
243
  ip_address = ip
221
- if hostnames[ip].count() > 0
222
- hostnames[ip].each do |hostname|
223
- unless ip_address.nil?
224
- @ui.info "[vagrant-goodhosts] - found entry for: #{ip_address} #{hostname}"
225
- end
226
- end
227
- hostnames_by_ips = { ip_address => hostnames[ip].join(" ") }
228
- end
244
+ hostnames_by_ips = append_hostsnames_by_ips(hostnames_by_ips, hostnames, ip_address, ip)
229
245
  end
230
246
  else
231
247
  ip_address = ips[0]
232
- if hostnames[ip_address].count() > 0
233
- hostnames[ip_address].each do |hostname|
234
- unless ip_address.nil?
235
- @ui.info "[vagrant-goodhosts] - found entry for: #{ip_address} #{hostname}"
236
- end
237
- end
238
- hostnames_by_ips = { ip_address => hostnames[ip_address].join(" ") }
239
- end
248
+ hostnames_by_ips = append_hostsnames_by_ips(hostnames_by_ips, hostnames, ip_address, ip_address)
240
249
  end
241
250
 
242
251
  return hostnames_by_ips
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module GoodHosts
3
- VERSION = '1.1.0beta'
3
+ VERSION = '1.1.0beta2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-goodhosts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0beta
4
+ version: 1.1.0beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniele Scasciafratte