Several minor fixes #47

Merged
ThomasADavis merged 8 commits from fixes-1 into master 2019-08-29 17:33:28 +02:00
ThomasADavis commented 2019-08-27 19:32:11 +02:00 (Migrated from github.com)

raid_array check should return an empty array, not NoneType

not all systems will have IPv6 defined, so try to get the information.. if not
just continue on.

Vendor Supermicro was incomplete.

raid_array check should return an empty array, not NoneType not all systems will have IPv6 defined, so try to get the information.. if not just continue on. Vendor Supermicro was incomplete.
Solvik (Migrated from github.com) requested changes 2019-08-27 21:56:41 +02:00
@ -63,1 +62,3 @@
ip_addr += netifaces.ifaddresses(interface).get(netifaces.AF_INET6)
ip_addr = netifaces.ifaddresses(interface).get(netifaces.AF_INET, [])
ip6_addr = netifaces.ifaddresses(interface).get(netifaces.AF_INET6, [])
Solvik (Migrated from github.com) commented 2019-08-27 21:56:23 +02:00

or we could go:

            ip_addr += netifaces.ifaddresses(interface).get(netifaces.AF_INET6, [])
or we could go: ```suggestion ip_addr += netifaces.ifaddresses(interface).get(netifaces.AF_INET6, []) ```
Solvik commented 2019-08-27 22:01:12 +02:00 (Migrated from github.com)

Thanks for the PR !! I've added a single comment, the rest looks good to me :)

Thanks for the PR !! I've added a single comment, the rest looks good to me :)
ThomasADavis (Migrated from github.com) reviewed 2019-08-27 23:05:30 +02:00
@ -63,1 +62,3 @@
ip_addr += netifaces.ifaddresses(interface).get(netifaces.AF_INET6)
ip_addr = netifaces.ifaddresses(interface).get(netifaces.AF_INET, [])
ip6_addr = netifaces.ifaddresses(interface).get(netifaces.AF_INET6, [])
ThomasADavis (Migrated from github.com) commented 2019-08-27 23:05:29 +02:00
  File "/usr/local/bin/netbox_agent", line 11, in <module>
    load_entry_point('netbox-agent==0.1', 'console_scripts', 'netbox_agent')()
  File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/cli.py", line 41, in main
    return run(args)
  File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/cli.py", line 27, in run
    server.netbox_update()
  File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/server.py", line 275, in netbox_update
    self.network = Network(server=self)
  File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/network.py", line 49, in __init__
    self.scan()
  File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/network.py", line 63, in scan
    ip_addr += netifaces.ifaddresses(interface).get(netifaces.AF_INET6, [])
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'list'
[root@d8-r13-c5-n1 ~]# 
eno1.50: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.84.97  netmask 255.255.252.0  broadcast 192.168.87.255
        inet6 fe80::ec4:7aff:fe59:ec4a  prefixlen 64  scopeid 0x20<link>
        ether 0c:c4:7a:59:ec:4a  txqueuelen 1000  (Ethernet)
        RX packets 41180169  bytes 2674792656 (2.4 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10087607  bytes 5226819088 (4.8 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
```Traceback (most recent call last): File "/usr/local/bin/netbox_agent", line 11, in <module> load_entry_point('netbox-agent==0.1', 'console_scripts', 'netbox_agent')() File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/cli.py", line 41, in main return run(args) File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/cli.py", line 27, in run server.netbox_update() File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/server.py", line 275, in netbox_update self.network = Network(server=self) File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/network.py", line 49, in __init__ self.scan() File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/network.py", line 63, in scan ip_addr += netifaces.ifaddresses(interface).get(netifaces.AF_INET6, []) TypeError: unsupported operand type(s) for +=: 'NoneType' and 'list' [root@d8-r13-c5-n1 ~]# eno1.50: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.84.97 netmask 255.255.252.0 broadcast 192.168.87.255 inet6 fe80::ec4:7aff:fe59:ec4a prefixlen 64 scopeid 0x20<link> ether 0c:c4:7a:59:ec:4a txqueuelen 1000 (Ethernet) RX packets 41180169 bytes 2674792656 (2.4 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 10087607 bytes 5226819088 (4.8 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ```
ThomasADavis (Migrated from github.com) reviewed 2019-08-27 23:14:40 +02:00
@ -63,1 +62,3 @@
ip_addr += netifaces.ifaddresses(interface).get(netifaces.AF_INET6)
ip_addr = netifaces.ifaddresses(interface).get(netifaces.AF_INET, [])
ip6_addr = netifaces.ifaddresses(interface).get(netifaces.AF_INET6, [])
ThomasADavis (Migrated from github.com) commented 2019-08-27 23:14:40 +02:00

Oh, wait, I found the problem.. both need the [] ; but that causes another problem.

{17: [{'addr': '0c:c4:7a:59:ec:4a', 'broadcast': 'ff:ff:ff:ff:ff:ff'}], 10: [{'addr': 'fe80::ec4:7aff:fe59:ec4a%eno1', 'netmask': 'ffff:ffff:ffff:ffff::/64'}]}
ip_addr= []
Traceback (most recent call last):
File "/usr/local/bin/netbox_agent", line 11, in
load_entry_point('netbox-agent==0.1', 'console_scripts', 'netbox_agent')()
File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/cli.py", line 41, in main
return run(args)
File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/cli.py", line 27, in run
server.netbox_update()
File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/server.py", line 275, in netbox_update
self.network = Network(server=self)
File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/network.py", line 49, in init
self.scan()
File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/network.py", line 90, in scan
] if ip_addr else None, # FIXME: handle IPv6 addresses
File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/network.py", line 89, in
) for x in ip_addr
File "/usr/local/lib/python3.6/site-packages/netaddr-0.7.19-py3.6.egg/netaddr/ip/init.py", line 280, in init
% self.class.name)
ValueError: IPAddress() does not support netmasks or subnet prefixes! See documentation for details.

Oh, wait, I found the problem.. both need the [] ; but that causes another problem. {17: [{'addr': '0c:c4:7a:59:ec:4a', 'broadcast': 'ff:ff:ff:ff:ff:ff'}], 10: [{'addr': 'fe80::ec4:7aff:fe59:ec4a%eno1', 'netmask': 'ffff:ffff:ffff:ffff::/64'}]} ip_addr= [] Traceback (most recent call last): File "/usr/local/bin/netbox_agent", line 11, in <module> load_entry_point('netbox-agent==0.1', 'console_scripts', 'netbox_agent')() File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/cli.py", line 41, in main return run(args) File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/cli.py", line 27, in run server.netbox_update() File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/server.py", line 275, in netbox_update self.network = Network(server=self) File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/network.py", line 49, in __init__ self.scan() File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/network.py", line 90, in scan ] if ip_addr else None, # FIXME: handle IPv6 addresses File "/usr/local/lib/python3.6/site-packages/netbox_agent-0.1-py3.6.egg/netbox_agent/network.py", line 89, in <listcomp> ) for x in ip_addr File "/usr/local/lib/python3.6/site-packages/netaddr-0.7.19-py3.6.egg/netaddr/ip/__init__.py", line 280, in __init__ % self.__class__.__name__) ValueError: IPAddress() does not support netmasks or subnet prefixes! See documentation for details.
Solvik (Migrated from github.com) reviewed 2019-08-28 12:05:52 +02:00
@ -63,1 +62,3 @@
ip_addr += netifaces.ifaddresses(interface).get(netifaces.AF_INET6)
ip_addr = netifaces.ifaddresses(interface).get(netifaces.AF_INET, [])
ip6_addr = netifaces.ifaddresses(interface).get(netifaces.AF_INET6, [])
Solvik (Migrated from github.com) commented 2019-08-28 12:05:52 +02:00
ip_addr = netifaces.ifaddresses(interface).get(netifaces.AF_INET, [])
ip_addr += netifaces.ifaddresses(interface).get(netifaces.AF_INET6, [])

works like a charm on a VM without any IPs, not your case?

``` ip_addr = netifaces.ifaddresses(interface).get(netifaces.AF_INET, []) ip_addr += netifaces.ifaddresses(interface).get(netifaces.AF_INET6, []) ``` works like a charm on a VM without any IPs, not your case?
ThomasADavis commented 2019-08-28 17:26:47 +02:00 (Migrated from github.com)

I've updated the pull, fixes the IPv6 subnet problem which was crashing IPAddress (netifaces returns an IPv6 netmask that netaddr does not understand) It now works for me!

I've updated the pull, fixes the IPv6 subnet problem which was crashing IPAddress (netifaces returns an IPv6 netmask that netaddr does not understand) It now works for me!
Solvik (Migrated from github.com) requested changes 2019-08-28 18:05:05 +02:00
@ -59,8 +59,29 @@ class Network():
logging.debug('Ignore interface {interface}'.format(interface=interface))
Solvik (Migrated from github.com) commented 2019-08-28 18:03:00 +02:00

ip6_addr isn't defined, we cant +=

`ip6_addr` isn't defined, we cant `+=`
Solvik (Migrated from github.com) commented 2019-08-28 18:04:36 +02:00

I've tried to reproduce this case during my testing, but it was unsuccessful. It's good you caught this!
We should do the same thing for addr and remove %.* no ?

I've tried to reproduce this case during my testing, but it was unsuccessful. It's good you caught this! We should do the same thing for `addr` and remove `%.*` no ?
Solvik (Migrated from github.com) reviewed 2019-08-28 18:05:42 +02:00
@ -59,8 +59,29 @@ class Network():
logging.debug('Ignore interface {interface}'.format(interface=interface))
Solvik (Migrated from github.com) commented 2019-08-28 18:05:42 +02:00

ok you've just fixed that :)

ok you've just fixed that :)
ThomasADavis (Migrated from github.com) reviewed 2019-08-28 18:37:19 +02:00
@ -59,8 +59,29 @@ class Network():
logging.debug('Ignore interface {interface}'.format(interface=interface))
ThomasADavis (Migrated from github.com) commented 2019-08-28 18:37:19 +02:00

yup. once you fix the netmask and ipv6 address, it goes right in.

yup. once you fix the netmask and ipv6 address, it goes right in.
ThomasADavis commented 2019-08-28 18:46:09 +02:00 (Migrated from github.com)

So, it should be ready - ipv6 addresses now work correctly, and are even registered correctly to the interface.

So, it should be ready - ipv6 addresses now work correctly, and are even registered correctly to the interface.
Solvik (Migrated from github.com) reviewed 2019-08-29 10:39:43 +02:00
@ -59,8 +59,29 @@ class Network():
logging.debug('Ignore interface {interface}'.format(interface=interface))
Solvik (Migrated from github.com) commented 2019-08-29 10:39:43 +02:00

There's still the following error:

File "/tmp/netbox_agent/netbox_agent/network.py", line 80, in scan
    for addr in ip6_addr:
TypeError: 'NoneType' object is not iterable

Just add this and it'll be good to go!

            ip6_addr = netifaces.ifaddresses(interface).get(netifaces.AF_INET6, [])
There's still the following error: ``` File "/tmp/netbox_agent/netbox_agent/network.py", line 80, in scan for addr in ip6_addr: TypeError: 'NoneType' object is not iterable ``` Just add this and it'll be good to go! ```suggestion ip6_addr = netifaces.ifaddresses(interface).get(netifaces.AF_INET6, []) ```
ThomasADavis (Migrated from github.com) reviewed 2019-08-29 17:19:45 +02:00
@ -59,8 +59,29 @@ class Network():
logging.debug('Ignore interface {interface}'.format(interface=interface))
ThomasADavis (Migrated from github.com) commented 2019-08-29 17:19:45 +02:00

pushed up a fix.

pushed up a fix.
Solvik (Migrated from github.com) approved these changes 2019-08-29 17:32:35 +02:00
Sign in to join this conversation.
No description provided.