guests/gentoo: Use shared cap for listing network interfaces
This commit is contained in:
parent
8fe47b79c2
commit
e2becda89d
|
@ -12,15 +12,11 @@ module VagrantPlugins
|
|||
comm = machine.communicate
|
||||
|
||||
commands = []
|
||||
interfaces = []
|
||||
interfaces = machine.guest.capability(:network_interfaces, "/bin/ip")
|
||||
|
||||
# Remove any previous network additions to the configuration file.
|
||||
commands << "sed -i'' -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net"
|
||||
|
||||
comm.sudo("ifconfig -a | grep -o ^[0-9a-z]* | grep -v '^lo'") do |_, stdout|
|
||||
interfaces = stdout.split("\n")
|
||||
end
|
||||
|
||||
networks.each_with_index do |network, i|
|
||||
network[:device] = interfaces[network[:interface]]
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@ module VagrantPlugins
|
|||
# eth0\nenp0s8\nenp0s9
|
||||
#
|
||||
# @return [Array<String>]
|
||||
def self.network_interfaces(machine)
|
||||
def self.network_interfaces(machine, path = "/sbin/ip")
|
||||
s = ""
|
||||
machine.communicate.sudo("/sbin/ip -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'") do |type, data|
|
||||
machine.communicate.sudo("#{path} -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'") do |type, data|
|
||||
s << data if type == :stdout
|
||||
end
|
||||
s.split("\n")
|
||||
|
|
Loading…
Reference in New Issue