Several minor fixes #47
|
@ -102,7 +102,7 @@ class Inventory():
|
|||
self.raid = HPRaid()
|
||||
|
||||
if not self.raid:
|
||||
return
|
||||
return []
|
||||
|
||||
controllers = self.raid.get_controllers()
|
||||
if len(self.raid.get_controllers()):
|
||||
|
|
|
@ -59,8 +59,29 @@ class Network():
|
|||
logging.debug('Ignore interface {interface}'.format(interface=interface))
|
||||
ok you've just fixed that :) ok you've just fixed that :)
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.
There's still the following error:
Just add this and it'll be good to go!
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, [])
```
pushed up a fix. pushed up a fix.
|
||||
continue
|
||||
|
||||
ip_addr = netifaces.ifaddresses(interface).get(netifaces.AF_INET)
|
||||
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, [])
|
||||
|
||||
or we could go:
or we could go:
```suggestion
ip_addr += netifaces.ifaddresses(interface).get(netifaces.AF_INET6, [])
```
```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
```
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'}]} 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.
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?
|
||||
# netifaces returns a ipv6 netmask that netaddr does not understand.
|
||||
# this strips the netmask down to the correct format for netaddr,
|
||||
# and remove the interface.
|
||||
# ie, this:
|
||||
# {
|
||||
# 'addr': 'fe80::ec4:7aff:fe59:ec4a%eno1.50',
|
||||
# 'netmask': 'ffff:ffff:ffff:ffff::/64'
|
||||
# }
|
||||
#
|
||||
# becomes:
|
||||
# {
|
||||
# 'addr': 'fe80::ec4:7aff:fe59:ec4a',
|
||||
# 'netmask': 'ffff:ffff:ffff:ffff::'
|
||||
# }
|
||||
#
|
||||
for addr in ip6_addr:
|
||||
addr["addr"] = addr["addr"].replace('%{}'.format(interface), '')
|
||||
addr["netmask"] = addr["netmask"].split('/')[0]
|
||||
ip_addr.append(addr)
|
||||
|
||||
if NETWORK_IGNORE_IPS and ip_addr:
|
||||
for i, ip in enumerate(ip_addr):
|
||||
if re.match(NETWORK_IGNORE_IPS, ip['addr']):
|
||||
|
|
8
netbox_agent/vendors/supermicro.py
vendored
|
@ -2,8 +2,14 @@ from netbox_agent.server import ServerBase
|
|||
|
||||
|
||||
class SupermicroHost(ServerBase):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SupermicroHost, self).__init__(*args, **kwargs)
|
||||
self.manufacturer = 'Supermicro'
|
||||
|
||||
def is_blade(self):
|
||||
return self.get_product_name().startswith('SBI')
|
||||
blade = self.get_product_name().startswith('SBI')
|
||||
blade |= self.get_product_name().startswith('SYS')
|
||||
return blade
|
||||
|
||||
def get_blade_slot(self):
|
||||
# No supermicro on hands
|
||||
|
|
ip6_addr
isn't defined, we cant+=
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 ?