Line 91: |
Line 91: |
| | | |
| == console == | | == console == |
− | * kudzu has been removed from EL6, so now this bug [[bugzilla:3596|Bug #3596: Stop using kudzu for NIC detection]] needs to be fixed so we can detect network interfaces. | + | * kudzu has been removed from EL6, so now this bug [[bugzilla:3596|Bug #3596: Stop using kudzu for NIC detection]] needs to be fixed so we can detect network interfaces. A patch is waiting to be aproved. |
− | * Here's a code snipet which seems to work, the only thing missing is to retrieve the interface description from hwdata, for now, it just return the name 'eth0, eth1 etc… instead of the description (in esmith/ethernet.pm)
| |
− | | |
− | <syntaxhighlight lang="perl">
| |
− | opendir(my $dh, "/sys/class/net") or die "Couldn't open /sys/class/net: $!";
| |
− | my @nics = grep { $_ !~ m/\./ } readdir($dh);
| |
− | my $adapters = '';
| |
− | my $index = 1;
| |
− | foreach my $nic (@nics){
| |
− | next if (
| |
− | # skip loopback
| |
− | $nic eq 'lo' ||
| |
− | # skip non links
| |
− | !-l "/sys/class/net/$nic" ||
| |
− | # skip wireless nics
| |
− | -d "/sys/class/net/$nic/wireless" ||
| |
− | -l "/sys/class/net/$nic/phy80211" ||
| |
− | # skip bridges
| |
− | -d "/sys/class/net/$nic/bridge" ||
| |
− | # skip vlans
| |
− | -f "/proc/net/vlan/$nic" ||
| |
− | # skip bonds
| |
− | -d "/sys/class/net/$nic/bonding" ||
| |
− | # skip tun/tap
| |
− | -f "/sys/class/net/$nic/tun_flags" ||
| |
− | # skip dummy
| |
− | -d "/sys/devices/virtual/net/$nic"
| |
− | );
| |
− | # Now we should be left only wth ethernet adapters
| |
− | my $mac = `cat /sys/class/net/$nic/address`;
| |
− | chomp($mac);
| |
− | my $driver = `readlink /sys/class/net/$nic/device/driver`;
| |
− | $driver = `basename $driver`;
| |
− | chomp($driver);
| |
− | $adapters .= "EthernetDriver" . $index++ . "\t" . $driver . "\t" .
| |
− | $mac . "\t" . "$nic" . "\n";
| |
− | }
| |
− | return $adapters;
| |
− | </syntaxhighlight>
| |
| | | |
| == various == | | == various == |