more fixes

This commit is contained in:
Solvik Blum 2019-08-03 23:57:36 +02:00
commit eaaf565b37
No known key found for this signature in database
GPG key ID: CC12B3DC262B6C47
6 changed files with 14 additions and 14 deletions

View file

@ -6,11 +6,11 @@ class DellHost(ServerBase):
return self.get_product_name().startswith('PowerEdge M') return self.get_product_name().startswith('PowerEdge M')
def get_blade_slot(self): def get_blade_slot(self):
''' """
Return blade slot Return blade slot
dmidecode output is: dmidecode output is:
` Location In Chassis: Slot 03` ` Location In Chassis: Slot 03`
''' """
if self.is_blade(): if self.is_blade():
return int(self.dmi.get_by_type('Baseboard')[0].get('Location In Chassis').split()[1]) return int(self.dmi.get_by_type('Baseboard')[0].get('Location In Chassis').split()[1])
return None return None

View file

@ -58,10 +58,10 @@ for type_id, type_str in _type2str.items():
def parse(): def parse():
''' """
parse the full output of the dmidecode parse the full output of the dmidecode
command and return a dic containing the parsed information command and return a dic containing the parsed information
''' """
buffer = _execute_cmd() buffer = _execute_cmd()
if isinstance(buffer, bytes): if isinstance(buffer, bytes):
buffer = buffer.decode('utf-8') buffer = buffer.decode('utf-8')
@ -70,7 +70,7 @@ def parse():
def get_by_type(type_id): def get_by_type(type_id):
''' """
filter the output of dmidecode per type filter the output of dmidecode per type
0 BIOS 0 BIOS
1 System 1 System
@ -115,7 +115,7 @@ def get_by_type(type_id):
40 Additional Information 40 Additional Information
41 Onboard Devices Extended Information 41 Onboard Devices Extended Information
42 Management Controller Host Interface 42 Management Controller Host Interface
''' """
if isinstance(type_id, str): if isinstance(type_id, str):
type_id = _str2type[type_id] type_id = _str2type[type_id]

View file

@ -11,11 +11,11 @@ class HPHost(ServerBase):
return self.get_product_name().startswith('ProLiant BL') return self.get_product_name().startswith('ProLiant BL')
def _find_rack_locator(self): def _find_rack_locator(self):
''' """
Depending on the server, the type of the `HP ProLiant System/Rack Locator` Depending on the server, the type of the `HP ProLiant System/Rack Locator`
can change. can change.
So we need to find it every time So we need to find it every time
''' """
# FIXME: make a dmidecode function get_by_dminame() ? # FIXME: make a dmidecode function get_by_dminame() ?
if self.is_blade(): if self.is_blade():
for key, value in self.dmi.parse().items(): for key, value in self.dmi.parse().items():

View file

@ -22,15 +22,15 @@ class ServerBase():
self.network_cards = [] self.network_cards = []
def get_product_name(self): def get_product_name(self):
''' """
Return the Chassis Name from dmidecode info Return the Chassis Name from dmidecode info
''' """
return self.system[0]['Product Name'] return self.system[0]['Product Name']
def get_service_tag(self): def get_service_tag(self):
''' """
Return the Service Tag from dmidecode info Return the Service Tag from dmidecode info
''' """
return self.system[0]['Serial Number'] return self.system[0]['Serial Number']
def is_blade(self): def is_blade(self):

View file

@ -12,7 +12,7 @@ setup(
include_package_data=True, include_package_data=True,
use_scm_version=True, use_scm_version=True,
packages=find_packages(), packages=find_packages(),
install_requires=open('requirements.txt').readlines(), install_requires=find_packages(),
zip_safe=False, zip_safe=False,
keywords=['netbox'], keywords=['netbox'],
classifiers=[ classifiers=[

View file

@ -20,7 +20,7 @@ max-line-length = 99
import-order-style = google import-order-style = google
# Inform flake8-import-order plugin that `fact` should be treated as a local package name. # Inform flake8-import-order plugin that `fact` should be treated as a local package name.
application-import-names = fact application-import-names = netbox_agent
# [testenv] # [testenv]
# setenv = # setenv =