diff --git a/netbox_agent/inventory.py b/netbox_agent/inventory.py index 06aee92..035a84b 100644 --- a/netbox_agent/inventory.py +++ b/netbox_agent/inventory.py @@ -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()): diff --git a/netbox_agent/network.py b/netbox_agent/network.py index 78f7090..a933758 100644 --- a/netbox_agent/network.py +++ b/netbox_agent/network.py @@ -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']): diff --git a/netbox_agent/vendors/supermicro.py b/netbox_agent/vendors/supermicro.py index a697e03..18b03c6 100644 --- a/netbox_agent/vendors/supermicro.py +++ b/netbox_agent/vendors/supermicro.py @@ -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():