Fix agent, wasn't working anymore (#115)
Bad rebase made dmidecode calls fail
This commit is contained in:
parent
bb7c8c8f94
commit
5590f39131
6 changed files with 16 additions and 13 deletions
|
@ -18,12 +18,13 @@ MANUFACTURERS = {
|
|||
|
||||
|
||||
def run(config):
|
||||
manufacturer = dmidecode.get_by_type('Chassis')[0].get('Manufacturer')
|
||||
dmi = dmidecode.parse()
|
||||
manufacturer = dmidecode.get_by_type(dmi, 'Chassis')[0].get('Manufacturer')
|
||||
|
||||
try:
|
||||
server = MANUFACTURERS[manufacturer](dmi=dmidecode)
|
||||
server = MANUFACTURERS[manufacturer](dmi=dmi)
|
||||
except KeyError:
|
||||
server = GenericHost
|
||||
server = GenericHost(dmi=dmi)
|
||||
|
||||
if config.debug:
|
||||
server.print_debug()
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import logging
|
||||
|
||||
import netbox_agent.dmidecode as dmidecode
|
||||
from netbox_agent.config import netbox_instance as nb
|
||||
|
||||
PSU_DMI_TYPE = 39
|
||||
|
@ -16,7 +17,7 @@ class PowerSupply():
|
|||
|
||||
def get_power_supply(self):
|
||||
power_supply = []
|
||||
for psu in self.server.dmi.get_by_type(PSU_DMI_TYPE):
|
||||
for psu in dmidecode.get_by_type(self.server.dmi, PSU_DMI_TYPE):
|
||||
if 'Present' not in psu['Status'] or psu['Status'] == 'Not Present':
|
||||
continue
|
||||
|
||||
|
|
6
netbox_agent/vendors/dell.py
vendored
6
netbox_agent/vendors/dell.py
vendored
|
@ -20,7 +20,7 @@ class DellHost(ServerBase):
|
|||
` Location In Chassis: Slot 03`
|
||||
"""
|
||||
if self.is_blade():
|
||||
return self.dmi.get_by_type('Baseboard')[0].get('Location In Chassis').strip()
|
||||
return self.baseboard[0].get('Location In Chassis').strip()
|
||||
return None
|
||||
|
||||
def get_chassis_name(self):
|
||||
|
@ -30,12 +30,12 @@ class DellHost(ServerBase):
|
|||
|
||||
def get_chassis(self):
|
||||
if self.is_blade():
|
||||
return self.dmi.get_by_type('Chassis')[0]['Version'].strip()
|
||||
return self.chassis[0]['Version'].strip()
|
||||
return self.get_product_name()
|
||||
|
||||
def get_chassis_service_tag(self):
|
||||
if self.is_blade():
|
||||
return self.dmi.get_by_type('Chassis')[0]['Serial Number'].strip()
|
||||
return self.chassis[0]['Serial Number'].strip()
|
||||
return self.get_service_tag()
|
||||
|
||||
def get_power_consumption(self):
|
||||
|
|
2
netbox_agent/vendors/generic.py
vendored
2
netbox_agent/vendors/generic.py
vendored
|
@ -5,7 +5,7 @@ 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')
|
||||
self.manufacturer = dmidecode.get_by_type(self.dmi, 'Baseboard')[0].get('Manufacturer')
|
||||
|
||||
def is_blade(self):
|
||||
return None
|
||||
|
|
3
netbox_agent/vendors/hp.py
vendored
3
netbox_agent/vendors/hp.py
vendored
|
@ -1,3 +1,4 @@
|
|||
import netbox_agent.dmidecode as dmidecode
|
||||
from netbox_agent.server import ServerBase
|
||||
|
||||
|
||||
|
@ -19,7 +20,7 @@ class HPHost(ServerBase):
|
|||
"""
|
||||
# FIXME: make a dmidecode function get_by_dminame() ?
|
||||
if self.is_blade():
|
||||
locator = self.dmi.get_by_type(204)
|
||||
locator = dmidecode.get_by_type(self.dmi, 204)
|
||||
if self.get_product_name() == 'ProLiant BL460c Gen10':
|
||||
locator = locator[0]['Strings']
|
||||
return {
|
||||
|
|
8
netbox_agent/vendors/qct.py
vendored
8
netbox_agent/vendors/qct.py
vendored
|
@ -7,12 +7,12 @@ class QCTHost(ServerBase):
|
|||
self.manufacturer = 'QCT'
|
||||
|
||||
def is_blade(self):
|
||||
return 'Location In Chassis' in self.dmi.get_by_type('Baseboard')[0].keys()
|
||||
return 'Location In Chassis' in self.baseboard[0].keys()
|
||||
|
||||
def get_blade_slot(self):
|
||||
if self.is_blade():
|
||||
return 'Slot {}'.format(
|
||||
self.dmi.get_by_type('Baseboard')[0].get('Location In Chassis').strip()
|
||||
self.baseboard[0].get('Location In Chassis').strip()
|
||||
)
|
||||
return None
|
||||
|
||||
|
@ -23,10 +23,10 @@ class QCTHost(ServerBase):
|
|||
|
||||
def get_chassis(self):
|
||||
if self.is_blade():
|
||||
return self.dmi.get_by_type('Chassis')[0]['Version'].strip()
|
||||
return self.chassis[0]['Version'].strip()
|
||||
return self.get_product_name()
|
||||
|
||||
def get_chassis_service_tag(self):
|
||||
if self.is_blade():
|
||||
return self.dmi.get_by_type('Chassis')[0]['Serial Number'].strip()
|
||||
return self.chassis[0]['Serial Number'].strip()
|
||||
return self.get_service_tag()
|
||||
|
|
Loading…
Reference in a new issue