Rework all network part #21
No reviewers
Labels
No labels
help wanted
need testing
status: accepted
status: discussing
type: bug
type: documentation
type: duplicate
type: enhancement
type:hardware
type: invalid
type: major feature
type: minor feature
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: DGNum/netbox-agent#21
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/rework_network"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #20 and #22
LAG
on bonding interfacesParent LAG Interface
onChild
interfacesmgmt_only
interfaceComments from this night that I forgot to submit. 😄
@ -16,1 +22,4 @@
- [python3-netaddr](https://github.com/drkjam/netaddr)
- [python3-netifaces](https://github.com/al45tair/netifaces)
# Known limitations
You should also list the binaries used as subprocesses, and maybe the specific kernel flags they require, if they do.
@ -19,3 +28,4 @@
Since it uses `ethtool` and parses `/sys/` directory, it's not compatible with *BSD distributions.
* Netbox `>=2.6.0,<=2.6.2` has a caching problem ; if the cache lifetime is too high, the script can get stale data after modification.
We advise to set `CACHE_TIME` to `0`.
Maybe in the future the cache time could also be handled in the agent by enforcing that amount of time between two requests. Especially if there's a way to know that value through the API, and if we can group multiple calls in one.
@ -33,0 +35,4 @@
NETWORK_IGNORE_IPS = None
if config.get('network'):
NETWORK_IGNORE_INTERFACES = config['network']['ignore_interfaces']
NETWORK_IGNORE_IPS = config['network']['ignore_ips']
If one is defined but not the other, you'll get an exception here.
@ -0,0 +2,4 @@
import subprocess
class Ipmi():
Abbreviations should be in capital letters
@ -0,0 +31,4 @@
: o=OPERATOR
: a=ADMIN
: O=OEM
Bad Password Threshold : Not Available
Can't you use
ipmitool -c
so that you don't have to manually parse the output?@ -0,0 +42,4 @@
ret = {}
if self.ret != 0:
return ret
for line in self.output.split('\n'):
Good case for
str.splitlines()
Use a generator comprehension (i.e. use parentheses rather than brackets) or better, use
filter
@ -53,3 +77,3 @@
nic = {
'name': interface,
'mac': open('/sys/class/net/{}/address'.format(interface), 'r').read().strip(),
'mac': mac if mac != '00:00:00:00:00:00' else None,
Useless
else
here@ -69,0 +123,4 @@
interface = nb.dcim.interfaces.get(
device_id=self.device.id,
mac_address=nic['mac'],
name=nic['name'],
You could do something like
and/or split it in several lines for readability
@ -148,3 +327,2 @@
mac_address=nic['mac'],
)
interface = self.get_netbox_network_card(nic)
if not interface:
adress = str(...)
would be cleaner, I guess?@ -0,0 +31,4 @@
: o=OPERATOR
: a=ADMIN
: O=OEM
Bad Password Threshold : Not Available
doesn't work with
lan print
@ -19,3 +28,4 @@
Since it uses `ethtool` and parses `/sys/` directory, it's not compatible with *BSD distributions.
* Netbox `>=2.6.0,<=2.6.2` has a caching problem ; if the cache lifetime is too high, the script can get stale data after modification.
We advise to set `CACHE_TIME` to `0`.
There's a few issue on the netbox project to fix the cache invalidation upon modification
Not our case to fix
@ -19,3 +28,4 @@
Since it uses `ethtool` and parses `/sys/` directory, it's not compatible with *BSD distributions.
* Netbox `>=2.6.0,<=2.6.2` has a caching problem ; if the cache lifetime is too high, the script can get stale data after modification.
We advise to set `CACHE_TIME` to `0`.
jup right
@ -16,1 +22,4 @@
- [python3-netaddr](https://github.com/drkjam/netaddr)
- [python3-netifaces](https://github.com/al45tair/netifaces)
# Known limitations
Good idea!
@ -0,0 +42,4 @@
ret = {}
if self.ret != 0:
return ret
for line in self.output.split('\n'):
Will fix
@ -148,3 +327,2 @@
mac_address=nic['mac'],
)
interface = self.get_netbox_network_card(nic)
if not interface:
Will fix
@ -53,3 +77,3 @@
nic = {
'name': interface,
'mac': open('/sys/class/net/{}/address'.format(interface), 'r').read().strip(),
'mac': mac if mac != '00:00:00:00:00:00' else None,
Good catch, will fix
@ -0,0 +2,4 @@
import subprocess
class Ipmi():
Will fix
@ -33,0 +35,4 @@
NETWORK_IGNORE_IPS = None
if config.get('network'):
NETWORK_IGNORE_INTERFACES = config['network']['ignore_interfaces']
NETWORK_IGNORE_IPS = config['network']['ignore_ips']
Good catch
@ -0,0 +31,4 @@
: o=OPERATOR
: a=ADMIN
: O=OEM
Bad Password Threshold : Not Available
tristesse
I didn't even know about generator comprehension, thansk a lot !!
Will fixx