summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-09-20 16:25:18 +0000
committerGerrit Code Review <review@openstack.org>2016-09-20 16:25:18 +0000
commit9137f53d903e3191d6a758671ad31d9475349f19 (patch)
tree65c312b65a83b0c970c7df5c0398ccbfe548e7d8
parentebd1f566c8faaebbc01603eb01583373c029c317 (diff)
parent79cee4f6fbd3a691b50ab5daa756e25c7e4adb1b (diff)
downloadironic-9137f53d903e3191d6a758671ad31d9475349f19.tar.gz
Merge "Refactor common checks when instantiating the ipmitool classes"
-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()