From 438b77e0066f8013fbfe62cd2316fac83f511fb4 Mon Sep 17 00:00:00 2001 From: Devananda van der Veen Date: Fri, 24 May 2013 13:32:25 -0700 Subject: [PATCH] Add validate_driver_info to driver classes. Change-Id: I8ba2f4bd70bd2d7af405868cca2aedb56d3f0640 --- ironic/drivers/base.py | 24 +++++++++++++++++++++++- ironic/drivers/fake.py | 6 ++++++ ironic/drivers/ipmi.py | 5 +++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/ironic/drivers/base.py b/ironic/drivers/base.py index bf4a8d11d2..2ff3ad2c8b 100644 --- a/ironic/drivers/base.py +++ b/ironic/drivers/base.py @@ -32,6 +32,17 @@ class DeployDriver(object): def __init__(self): """Constructor.""" + @abc.abstractmethod + def validate_driver_info(cls, node): + """Validate the driver-specific Node info. + + This method validates whether the 'deploy_info' property of the + supplied nodes contains the required information for this driver to + manage the nodes. + + :returns: True or False, depending on capabilities. + """ + @abc.abstractmethod def activate_bootloader(self, task, node): """Prepare the bootloader for this deployment.""" @@ -55,9 +66,20 @@ class ControlDriver(object): __metaclass__ = abc.ABCMeta @abc.abstractmethod - def __init__(self, nodes): + def __init__(self): """Constructor.""" + @abc.abstractmethod + def validate_driver_info(cls, node): + """Validate the driver-specific Node info. + + This method validates whether the 'control_info' property of the + supplied nodes contains the required information for this driver to + manage the nodes. + + :returns: True or False, depending on capabilities. + """ + @abc.abstractmethod def start_console(self, task, node): """Start a remote console for the nodes.""" diff --git a/ironic/drivers/fake.py b/ironic/drivers/fake.py index f8e89d46cf..a5a387dec3 100644 --- a/ironic/drivers/fake.py +++ b/ironic/drivers/fake.py @@ -25,6 +25,9 @@ class FakeDeployDriver(base.DeployDriver): def __init__(self): pass + def validate_driver_info(self, node): + return True + def activate_bootloader(self, task, node): pass @@ -42,6 +45,9 @@ class FakeControlDriver(base.ControlDriver): def __init__(self): pass + def validate_driver_info(self, node): + return True + def start_console(self, task, node): pass diff --git a/ironic/drivers/ipmi.py b/ironic/drivers/ipmi.py index 32b3070da6..93e87aa98a 100644 --- a/ironic/drivers/ipmi.py +++ b/ironic/drivers/ipmi.py @@ -198,6 +198,11 @@ class IPMIPowerDriver(base.ControlDriver): else: self.state = states.ERROR + def validate_driver_info(node): + # Temporary stub so patch I8ba2f4bd70bd2d7af405868cca2aedb56d3f0640 + # will pass. The next patch actually implements this. + pass + def get_power_state(self): """Checks and returns current power state.""" self._update_state()