diff options
author | Lucas Alvares Gomes <lucasagomes@gmail.com> | 2014-04-29 17:47:30 +0100 |
---|---|---|
committer | Lucas Alvares Gomes <lucasagomes@gmail.com> | 2014-06-10 17:53:58 +0100 |
commit | 4da3ec8b8ae75e8ffc7582c4b0c37c1f9c14dd75 (patch) | |
tree | e8dba47d6b1441f259e60b6072f818921a8e29ec | |
parent | 2b2022c331d78b5ca1df6d06a58d2229af3036b7 (diff) | |
download | ironic-4da3ec8b8ae75e8ffc7582c4b0c37c1f9c14dd75.tar.gz |
Remove 'node' parameter from the Console and Rescue interfaces
The node parameter is redundant since the node object is an attribute
of the task object.
Partial-Bug: #1312632
Change-Id: Ic7bf898b7d881e36188511d75837e450f29f066c
-rw-r--r-- | ironic/conductor/manager.py | 6 | ||||
-rw-r--r-- | ironic/drivers/base.py | 37 | ||||
-rw-r--r-- | ironic/drivers/modules/fake.py | 6 | ||||
-rw-r--r-- | ironic/drivers/modules/ipmitool.py | 12 | ||||
-rw-r--r-- | ironic/tests/conductor/test_manager.py | 4 | ||||
-rw-r--r-- | ironic/tests/drivers/test_ipmitool.py | 9 |
6 files changed, 39 insertions, 35 deletions
diff --git a/ironic/conductor/manager.py b/ironic/conductor/manager.py index 2a4588b0b..3a5368dec 100644 --- a/ironic/conductor/manager.py +++ b/ironic/conductor/manager.py @@ -834,7 +834,7 @@ class ConductorManager(periodic_task.PeriodicTasks): raise exception.NodeConsoleNotEnabled(node=node_id) task.driver.console.validate(task, node) - return task.driver.console.get_console(task, node) + return task.driver.console.get_console(task) @messaging.expected_exceptions(exception.NoFreeConductorWorker, exception.NodeLocked, @@ -884,9 +884,9 @@ class ConductorManager(periodic_task.PeriodicTasks): node = task.node try: if enabled: - task.driver.console.start_console(task, node) + task.driver.console.start_console(task) else: - task.driver.console.stop_console(task, node) + task.driver.console.stop_console(task) except Exception as e: with excutils.save_and_reraise_exception(): op = _('enabling') if enabled else _('disabling') diff --git a/ironic/drivers/base.py b/ironic/drivers/base.py index 66090de20..3d057468a 100644 --- a/ironic/drivers/base.py +++ b/ironic/drivers/base.py @@ -236,6 +236,9 @@ class PowerInterface(object): class ConsoleInterface(object): """Interface for console-related actions.""" + # TODO(lucasagomes): The 'node' parameter needs to be passed to validate() + # because of the ConductorManager.validate_driver_interfaces(). + # Remove it after all cleaning all the interfaces @abc.abstractmethod def validate(self, task, node): """Validate the driver-specific Node console info. @@ -244,34 +247,33 @@ class ConsoleInterface(object): supplied node contains the required information for this driver to provide console access to the Node. - :param task: a task from TaskManager. + :param task: a TaskManager instance containing the node to act on. :param node: a single Node to validate. :raises: InvalidParameterValue """ @abc.abstractmethod - def start_console(self, task, node): - """Start a remote console for the node. + def start_console(self, task): + """Start a remote console for the task's node. - TODO + :param task: a TaskManager instance containing the node to act on. """ @abc.abstractmethod - def stop_console(self, task, node): - """Stop the remote console session for the node. + def stop_console(self, task): + """Stop the remote console session for the task's node. - TODO + :param task: a TaskManager instance containing the node to act on. """ @abc.abstractmethod - def get_console(self, task, node): + def get_console(self, task): """Get connection information about the console. This method should return the necessary information for the client to access the console. - :param task: a task from TaskManager. - :param node: a single Node. + :param task: a TaskManager instance containing the node to act on. :returns: the console connection information. """ @@ -280,27 +282,30 @@ class ConsoleInterface(object): class RescueInterface(object): """Interface for rescue-related actions.""" + # TODO(lucasagomes): The 'node' parameter needs to be passed to validate() + # because of the ConductorManager.validate_driver_interfaces(). + # Remove it after all cleaning all the interfaces @abc.abstractmethod def validate(self, task, node): """Validate the rescue info stored in the node' properties. - :param task: a task from TaskManager. + :param task: a TaskManager instance containing the node to act on. :param node: a single Node to validate. :raises: InvalidParameterValue """ @abc.abstractmethod - def rescue(self, task, node): - """Boot the node into a rescue environment. + def rescue(self, task): + """Boot the task's node into a rescue environment. - TODO + :param task: a TaskManager instance containing the node to act on. """ @abc.abstractmethod - def unrescue(self, task, node): + def unrescue(self, task): """Tear down the rescue environment, and return to normal. - TODO + :param task: a TaskManager instance containing the node to act on. """ diff --git a/ironic/drivers/modules/fake.py b/ironic/drivers/modules/fake.py index 6bd701739..223eeeb88 100644 --- a/ironic/drivers/modules/fake.py +++ b/ironic/drivers/modules/fake.py @@ -136,13 +136,13 @@ class FakeConsole(base.ConsoleInterface): def validate(self, task, node): return True - def start_console(self, task, node): + def start_console(self, task): pass - def stop_console(self, task, node): + def stop_console(self, task): pass - def get_console(self, task, node): + def get_console(self, task): return {} diff --git a/ironic/drivers/modules/ipmitool.py b/ironic/drivers/modules/ipmitool.py index 8dabd220f..6de92ee64 100644 --- a/ironic/drivers/modules/ipmitool.py +++ b/ironic/drivers/modules/ipmitool.py @@ -416,9 +416,9 @@ class IPMIShellinaboxConsole(base.ConsoleInterface): raise exception.InvalidParameterValue(_( "IPMI terminal port not supplied to IPMI driver.")) - def start_console(self, task, node): + def start_console(self, task): """Start a remote console for the node.""" - driver_info = _parse_driver_info(node) + driver_info = _parse_driver_info(task.node) path = _console_pwfile_path(driver_info['uuid']) pw_file = console_utils.make_persistent_password_file( @@ -438,14 +438,14 @@ class IPMIShellinaboxConsole(base.ConsoleInterface): driver_info['port'], ipmi_cmd) - def stop_console(self, task, node): + def stop_console(self, task): """Stop the remote console session for the node.""" - driver_info = _parse_driver_info(node) + driver_info = _parse_driver_info(task.node) console_utils.stop_shellinabox_console(driver_info['uuid']) utils.unlink_without_raise(_console_pwfile_path(driver_info['uuid'])) - def get_console(self, task, node): + def get_console(self, task): """Get the type and connection information about the console.""" - driver_info = _parse_driver_info(node) + driver_info = _parse_driver_info(task.node) url = console_utils.get_shellinabox_console_url(driver_info['port']) return {'type': 'shellinabox', 'url': url} diff --git a/ironic/tests/conductor/test_manager.py b/ironic/tests/conductor/test_manager.py index d600b7b42..e6183d8e9 100644 --- a/ironic/tests/conductor/test_manager.py +++ b/ironic/tests/conductor/test_manager.py @@ -1018,7 +1018,7 @@ class ManagerTestCase(tests_db_base.DbTestCase): mock_sc.side_effect = exception.IronicException('test-error') self.service.set_console_mode(self.context, node.uuid, True) self.service._worker_pool.waitall() - mock_sc.assert_called_once_with(mock.ANY, mock.ANY) + mock_sc.assert_called_once_with(mock.ANY) node.refresh() self.assertIsNotNone(node.last_error) @@ -1032,7 +1032,7 @@ class ManagerTestCase(tests_db_base.DbTestCase): mock_sc.side_effect = exception.IronicException('test-error') self.service.set_console_mode(self.context, node.uuid, False) self.service._worker_pool.waitall() - mock_sc.assert_called_once_with(mock.ANY, mock.ANY) + mock_sc.assert_called_once_with(mock.ANY) node.refresh() self.assertIsNotNone(node.last_error) diff --git a/ironic/tests/drivers/test_ipmitool.py b/ironic/tests/drivers/test_ipmitool.py index 211ae3c39..845e1a656 100644 --- a/ironic/tests/drivers/test_ipmitool.py +++ b/ironic/tests/drivers/test_ipmitool.py @@ -463,7 +463,7 @@ class IPMIToolDriverTestCase(db_base.DbTestCase): with task_manager.acquire(self.context, self.node['uuid']) as task: - self.driver.console.start_console(task, self.node) + self.driver.console.start_console(task) mock_exec.assert_called_once_with(self.info['uuid'], self.info['port'], @@ -480,7 +480,7 @@ class IPMIToolDriverTestCase(db_base.DbTestCase): self.node['uuid']) as task: self.assertRaises(exception.ConsoleSubprocessFailed, self.driver.console.start_console, - task, self.node) + task) @mock.patch.object(console_utils, 'stop_shellinabox_console', autospec=True) @@ -489,7 +489,7 @@ class IPMIToolDriverTestCase(db_base.DbTestCase): with task_manager.acquire(self.context, self.node['uuid']) as task: - self.driver.console.stop_console(task, self.node) + self.driver.console.stop_console(task) mock_exec.assert_called_once_with(self.info['uuid']) self.assertTrue(mock_exec.called) @@ -503,8 +503,7 @@ class IPMIToolDriverTestCase(db_base.DbTestCase): with task_manager.acquire(self.context, self.node['uuid']) as task: - console_info = self.driver.console.get_console(task, - self.node) + console_info = self.driver.console.get_console(task) self.assertEqual(expected, console_info) mock_exec.assert_called_once_with(self.info['port']) |