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…
Add table
Add a link
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
LAGon bonding interfacesParent LAG InterfaceonChildinterfacesmgmt_onlyinterfaceComments 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 limitationsYou 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 = Noneif 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 subprocessclass Ipmi():Abbreviations should be in capital letters
@ -0,0 +31,4 @@: o=OPERATOR: a=ADMIN: O=OEMBad Password Threshold : Not AvailableCan't you use
ipmitool -cso that you don't have to manually parse the output?@ -0,0 +42,4 @@ret = {}if self.ret != 0:return retfor 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
elsehere@ -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=OEMBad Password Threshold : Not Availabledoesn'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 limitationsGood idea!
@ -0,0 +42,4 @@ret = {}if self.ret != 0:return retfor 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 subprocessclass Ipmi():Will fix
@ -33,0 +35,4 @@NETWORK_IGNORE_IPS = Noneif 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=OEMBad Password Threshold : Not Availabletristesse
I didn't even know about generator comprehension, thansk a lot !!
Will fixx