Adds a generic vendor for unrecognizable systems #105

Merged
ThomasADavis merged 5 commits from generic-vendor into master 2020-02-03 00:38:24 +01:00
2 changed files with 30 additions and 1 deletions
Showing only changes of commit dad4a3b57d - Show all commits

View file

@ -5,6 +5,7 @@ from netbox_agent.vendors.dell import DellHost
from netbox_agent.vendors.hp import HPHost
from netbox_agent.vendors.qct import QCTHost
from netbox_agent.vendors.supermicro import SupermicroHost
from netbox_agent.vendors.generic import GenericHost
MANUFACTURERS = {
'Dell Inc.': DellHost,
@ -12,12 +13,17 @@ MANUFACTURERS = {
'HPE': HPHost,
'Supermicro': SupermicroHost,
'Quanta Cloud Technology Inc.': QCTHost,
'Generic': GenericHost,
}
def run(config):
manufacturer = dmidecode.get_by_type('Chassis')[0].get('Manufacturer')
server = MANUFACTURERS[manufacturer](dmi=dmidecode)
try:
server = MANUFACTURERS[manufacturer](dmi=dmidecode)
except: KeyError:
server = MANUFACTURERS["Generic"]
if config.debug:
server.print_debug()

23
netbox_agent/vendors/generic.py vendored Normal file
View file

@ -0,0 +1,23 @@
import netbox_agent.dmidecode as dmidecode
from netbox_agent.server import ServerBase
class GenericHost(ServerBase):
def __init__(self, *args, **kwargs):
super(GenericHost, self).__init__(*args, **kwargs)
self.manufacturer = dmidecode.get_by_type('Baseboard')[0].get('Manufacturer')
def is_blade(self):
return None
def get_blade_slot(self):
return None
def get_chassis_name(self):
return None
def get_chassis(self):
return self.get_product_name()
def get_chassis_service_tag(self):
return self.get_service_tag()