vagrant-goodhosts 1.1.0beta → 1.1.0beta2
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-goodhosts/GoodHosts.rb +50 -41
- data/lib/vagrant-goodhosts/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58cfe3e3e7669fb2b8bf147db6786a38f6b94b8d4164460852872a007d2df40c
|
4
|
+
data.tar.gz: c5131a3c95e03d98a182092138ad55b1df1ae9cbe66ef7ad2800a2e3721b0d97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
114
|
-
|
115
|
-
|
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 =
|
120
|
-
|
121
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
-
|
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
|
-
|
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
|