summaryrefslogtreecommitdiff
path: root/ironic/drivers/modules/ipmitool.py
diff options
context:
space:
mode:
Diffstat (limited to 'ironic/drivers/modules/ipmitool.py')
-rw-r--r--ironic/drivers/modules/ipmitool.py48
1 files changed, 16 insertions, 32 deletions
diff --git a/ironic/drivers/modules/ipmitool.py b/ironic/drivers/modules/ipmitool.py
index 5ab0d7cff..9cf145e30 100644
--- a/ironic/drivers/modules/ipmitool.py
+++ b/ironic/drivers/modules/ipmitool.py
@@ -739,17 +739,22 @@ def _check_temp_dir():
TMP_DIR_CHECKED = True
+def _constructor_checks(driver):
+ """Common checks to be performed when instantiating an ipmitool class."""
+ try:
+ _check_option_support(['timing', 'single_bridge', 'dual_bridge'])
+ except OSError:
+ raise exception.DriverLoadError(
+ driver=driver,
+ reason=_("Unable to locate usable ipmitool command in "
+ "the system path when checking ipmitool version"))
+ _check_temp_dir()
+
+
class IPMIPower(base.PowerInterface):
def __init__(self):
- try:
- _check_option_support(['timing', 'single_bridge', 'dual_bridge'])
- except OSError:
- raise exception.DriverLoadError(
- driver=self.__class__.__name__,
- reason=_("Unable to locate usable ipmitool command in "
- "the system path when checking ipmitool version"))
- _check_temp_dir()
+ _constructor_checks(driver=self.__class__.__name__)
def get_properties(self):
return COMMON_PROPERTIES
@@ -841,14 +846,7 @@ class IPMIManagement(base.ManagementInterface):
return COMMON_PROPERTIES
def __init__(self):
- try:
- _check_option_support(['timing', 'single_bridge', 'dual_bridge'])
- except OSError:
- raise exception.DriverLoadError(
- driver=self.__class__.__name__,
- reason=_("Unable to locate usable ipmitool command in "
- "the system path when checking ipmitool version"))
- _check_temp_dir()
+ _constructor_checks(driver=self.__class__.__name__)
@METRICS.timer('IPMIManagement.validate')
def validate(self, task):
@@ -1041,14 +1039,7 @@ class IPMIManagement(base.ManagementInterface):
class VendorPassthru(base.VendorInterface):
def __init__(self):
- try:
- _check_option_support(['single_bridge', 'dual_bridge'])
- except OSError:
- raise exception.DriverLoadError(
- driver=self.__class__.__name__,
- reason=_("Unable to locate usable ipmitool command in "
- "the system path when checking ipmitool version"))
- _check_temp_dir()
+ _constructor_checks(driver=self.__class__.__name__)
@METRICS.timer('VendorPassthru.send_raw')
@base.passthru(['POST'])
@@ -1138,14 +1129,7 @@ class IPMIConsole(base.ConsoleInterface):
"""A base ConsoleInterface that uses ipmitool."""
def __init__(self):
- try:
- _check_option_support(['timing', 'single_bridge', 'dual_bridge'])
- except OSError:
- raise exception.DriverLoadError(
- driver=self.__class__.__name__,
- reason=_("Unable to locate usable ipmitool command in "
- "the system path when checking ipmitool version"))
- _check_temp_dir()
+ _constructor_checks(driver=self.__class__.__name__)
def get_properties(self):
d = COMMON_PROPERTIES.copy()