Change validate() to raise instead of returning T/F
Robert was right - it's better to allow driver.interface.validate to raise an exception, and let that bubble up and be wrapped by the API, or logged, than to wrap it at a low level and convert to True/False. This patch changes the existing drivers' validate methods to remove the exception wrapping, and updates some doc strings. Change-Id: I02372db64ea0eb85a3c0a00de292c87d286808e1
This commit is contained in:
parent
97dddca673
commit
04b7fcf107
|
@ -84,7 +84,7 @@ class DeployInterface(object):
|
|||
deploy images to the node.
|
||||
|
||||
:param node: a single Node to validate.
|
||||
:returns: True or False, depending on capabilities.
|
||||
:raises: InvalidParameterValue
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
|
@ -124,7 +124,7 @@ class PowerInterface(object):
|
|||
manage the power state of the node.
|
||||
|
||||
:param node: a single Node to validate.
|
||||
:returns: True or False, depending on capabilities.
|
||||
:raises: InvalidParameterValue
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
|
@ -163,7 +163,7 @@ class ConsoleInterface(object):
|
|||
provide console access to the Node.
|
||||
|
||||
:param node: a single Node to validate.
|
||||
:returns: True or False, depending on capabilities.
|
||||
:raises: InvalidParameterValue
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
|
@ -188,7 +188,11 @@ class RescueInterface(object):
|
|||
|
||||
@abc.abstractmethod
|
||||
def validate(self, node):
|
||||
"""Validate the rescue info stored in the node' properties."""
|
||||
"""Validate the rescue info stored in the node' properties.
|
||||
|
||||
:param node: a single Node to validate.
|
||||
:raises: InvalidParameterValue
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def rescue(self, task, node):
|
||||
|
@ -216,7 +220,11 @@ class VendorInterface(object):
|
|||
|
||||
@abc.abstractmethod
|
||||
def validate(self, node):
|
||||
"""Validate vendor-specific info stored in the node' properties."""
|
||||
"""Validate vendor-specific info stored in the node' properties.
|
||||
|
||||
:param node: a single Node to validate.
|
||||
:raises: InvalidParameterValue
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def vendor_passthru(self, task, node, *args, **kwargs):
|
||||
|
|
|
@ -191,12 +191,12 @@ def _power_status(driver_info):
|
|||
class IPMIPower(base.PowerInterface):
|
||||
|
||||
def validate(self, node):
|
||||
"""Check that node['driver_info'] contains IPMI credentials."""
|
||||
try:
|
||||
_parse_driver_info(node)
|
||||
except exception.InvalidParameterValue:
|
||||
return False
|
||||
return True
|
||||
"""Check that node['driver_info'] contains IPMI credentials.
|
||||
|
||||
:param node: Single node object.
|
||||
:raises: InvalidParameterValue
|
||||
"""
|
||||
_parse_driver_info(node)
|
||||
|
||||
def get_power_state(self, task, node):
|
||||
"""Get the current power state."""
|
||||
|
|
|
@ -267,14 +267,9 @@ class SSHPower(base.PowerInterface):
|
|||
"""Check that node['driver_info'] contains the requisite fields.
|
||||
|
||||
:param node: Single node object.
|
||||
|
||||
:returns: True / False.
|
||||
:raises: InvalidParameterValue
|
||||
"""
|
||||
try:
|
||||
_parse_driver_info(node)
|
||||
except exception.InvalidParameterValue:
|
||||
return False
|
||||
return True
|
||||
_parse_driver_info(node)
|
||||
|
||||
def get_power_state(self, task, node):
|
||||
"""Get the current power state.
|
||||
|
|
Loading…
Reference in New Issue