pep8 fixes
This commit is contained in:
parent
c508fa17f0
commit
4afd3b9170
4 changed files with 22 additions and 12 deletions
|
@ -5,10 +5,12 @@ from netbox_agent.raid.base import Raid, RaidController
|
|||
|
||||
REGEXP_CONTROLLER_HP = re.compile(r'Smart Array ([a-zA-Z0-9- ]+) in Slot ([0-9]+)')
|
||||
|
||||
|
||||
def _get_indentation(string):
|
||||
"""Return the number of spaces before the current line."""
|
||||
return len(string) - len(string.lstrip(' '))
|
||||
|
||||
|
||||
def _get_key_value(string):
|
||||
"""Return the (key, value) as a tuple from a string."""
|
||||
# Normally all properties look like this:
|
||||
|
@ -36,6 +38,7 @@ def _get_key_value(string):
|
|||
|
||||
return key.lstrip(' ').rstrip(' '), value.lstrip(' ').rstrip(' ')
|
||||
|
||||
|
||||
def _get_dict(lines, start_index, indentation):
|
||||
"""Recursive function for parsing hpssacli/ssacli output."""
|
||||
|
||||
|
@ -85,6 +88,7 @@ def _get_dict(lines, start_index, indentation):
|
|||
|
||||
return info, i
|
||||
|
||||
|
||||
class HPRaidController(RaidController):
|
||||
def __init__(self, controller_name, data):
|
||||
self.controller_name = controller_name
|
||||
|
@ -102,6 +106,7 @@ class HPRaidController(RaidController):
|
|||
def get_firmware_version(self):
|
||||
return self.data['Firmware Version']
|
||||
|
||||
|
||||
class HPRaid(Raid):
|
||||
def __init__(self):
|
||||
self.output = subprocess.getoutput('ssacli ctrl all show detail')
|
||||
|
@ -119,7 +124,7 @@ class HPRaid(Raid):
|
|||
product_name = REGEXP_CONTROLLER_HP.search(_product_name)
|
||||
if product_name:
|
||||
self.controllers.append(
|
||||
HPRaidController(product_name.group(1), info_dict[_product_name])
|
||||
HPRaidController(product_name.group(1), info_dict[_product_name])
|
||||
)
|
||||
|
||||
def get_controllers(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue