Merge pull request #7989 from chrisroberts/fix/more-networking-sorting

Only match interfaces without special characters
This commit is contained in:
Chris Roberts 2016-11-14 13:17:19 -08:00 committed by GitHub
commit 214f3ccee7
2 changed files with 7 additions and 1 deletions

View File

@ -55,7 +55,7 @@ module VagrantPlugins
resorted_ifaces = [] resorted_ifaces = []
resorted_ifaces += ifaces.find_all do |iface| resorted_ifaces += ifaces.find_all do |iface|
POSSIBLE_ETHERNET_PREFIXES.any?{|prefix| iface.start_with?(prefix)} && POSSIBLE_ETHERNET_PREFIXES.any?{|prefix| iface.start_with?(prefix)} &&
!iface.include?(':') iface.match(/^[a-zA-Z0-9]+$/)
end end
resorted_ifaces += ifaces - resorted_ifaces resorted_ifaces += ifaces - resorted_ifaces
ifaces = resorted_ifaces ifaces = resorted_ifaces

View File

@ -69,6 +69,12 @@ describe "VagrantPlugins::GuestLinux::Cap::NetworkInterfaces" do
expect(result).to eq(["eth0", "eth1", "eth2", "bridge0", "docker0", "docker1", "eth0:0"]) expect(result).to eq(["eth0", "eth1", "eth2", "bridge0", "docker0", "docker1", "eth0:0"])
end end
it "does not include ethernet devices aliases within prefix device listing with dot separators" do
expect(comm).to receive(:sudo).and_yield(:stdout, "eth1\neth2\ndocker0\nbridge0\neth0\ndocker1\neth0.1@eth0")
result = cap.network_interfaces(machine)
expect(result).to eq(["eth0", "eth1", "eth2", "bridge0", "docker0", "docker1", "eth0.1@eth0"])
end
it "properly sorts non-consistent device name formats" do it "properly sorts non-consistent device name formats" do
expect(comm).to receive(:sudo).and_yield(:stdout, "eth0\neth1\ndocker0\nveth437f7f9\nveth06b3e44\nveth8bb7081") expect(comm).to receive(:sudo).and_yield(:stdout, "eth0\neth1\ndocker0\nveth437f7f9\nveth06b3e44\nveth8bb7081")
result = cap.network_interfaces(machine) result = cap.network_interfaces(machine)