handle network cards #10

Merged
Solvik merged 6 commits from feature/network into master 2019-08-04 23:42:51 +02:00
3 changed files with 10 additions and 0 deletions
Showing only changes of commit 0c5ca003a6 - Show all commits

View file

@ -11,6 +11,11 @@ The goal is to generate an existing infrastructure on Netbox and have the abilit
* Create physical network interfaces with IPs
* Generic ability to guess datacenters through drivers (`cmd` and `file` and custom ones)
# Known limitations
* The project is only compatible with Linux.
Since it uses `ethtool` and parses `/sys/` directory, it's not compatible with *BSD distributions.
# Configuration
```

View file

@ -1,5 +1,6 @@
import re
import subprocess
from shutil import which
# Originally from https://github.com/opencoff/useful-scripts/blob/master/linktest.py
@ -64,6 +65,8 @@ class Ethtool():
return {'form_factor': r.groups()[0]}
def parse(self):
if which('ethtool') is None:
return None
return {
**self._parse_ethtool_output(),
**self._parse_ethtool_module_output(),

View file

@ -65,6 +65,8 @@ class Network():
return self.nics
def get_netbox_type_for_nic(self, nic):
if nic.get('ethtool') is None:
return IFACE_TYPE_OTHER
if nic['ethtool']['speed'] == '10000Mb/s':
if nic['ethtool']['port'] == 'FIBRE':
return IFACE_TYPE_10GE_SFP_PLUS