Several minor fixes (#47)
Several minor fixes: - raid_array check should return an empty array, not NoneType - not all systems will have IPv6 defined, handle this case - Vendor Supermicro was incomplete.
This commit is contained in:
parent
0faee59bde
commit
6ec08e8669
3 changed files with 31 additions and 4 deletions
|
@ -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))
|
||||
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, [])
|
||||
|
||||
# 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
8
netbox_agent/vendors/supermicro.py
vendored
|
@ -3,8 +3,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):
|
||||
if self.is_blade():
|
||||
|
|
Loading…
Reference in a new issue