From d120cedb4e5b9ab055e0f47562eb461e0805daba Mon Sep 17 00:00:00 2001 From: Arata Notsu Date: Tue, 8 Oct 2013 13:18:04 +0900 Subject: [PATCH] Correct use of ConfigFilesNotFoundError ConfigFilesNotFoundError.__init__() takes "config_files", not "path". And pass the config value itself rather than the result of find_file(), which is always None. Change-Id: Ia5285d252d5636892c4fbeb9191a6c7ed4923b78 Closes-Bug: 1236176 (cherry picked from commit 84b02ca1d54fd058c68345068832e84d2f80b9a5) --- nova/cells/state.py | 2 +- nova/tests/cells/test_cells_state_manager.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/nova/cells/state.py b/nova/cells/state.py index 21a2705b7dd2..743c62465c7a 100644 --- a/nova/cells/state.py +++ b/nova/cells/state.py @@ -151,7 +151,7 @@ class CellStateManager(base.Base): if cells_config: config_path = CONF.find_file(cells_config) if not config_path: - raise cfg.ConfigFilesNotFoundError(path=config_path) + raise cfg.ConfigFilesNotFoundError(config_files=[cells_config]) return CellStateManagerFile(cell_state_cls, config_path) return CellStateManagerDB(cell_state_cls) diff --git a/nova/tests/cells/test_cells_state_manager.py b/nova/tests/cells/test_cells_state_manager.py index 8dcf3f03c0b6..bcc20f57329e 100644 --- a/nova/tests/cells/test_cells_state_manager.py +++ b/nova/tests/cells/test_cells_state_manager.py @@ -16,6 +16,8 @@ Tests For CellStateManager """ +from oslo.config import cfg + from nova.cells import state from nova import db from nova.db.sqlalchemy import models @@ -65,6 +67,12 @@ class TestCellsStateManager(test.TestCase): self.stubs.Set(db, 'compute_node_get_all', _fake_compute_node_get_all) self.stubs.Set(db, 'flavor_get_all', _fake_instance_type_all) + def test_cells_config_not_found(self): + self.flags(cells_config='no_such_file_exists.conf', group='cells') + e = self.assertRaises(cfg.ConfigFilesNotFoundError, + state.CellStateManager) + self.assertEqual(['no_such_file_exists.conf'], e.config_files) + def test_capacity_no_reserve(self): # utilize entire cell cap = self._capacity(0.0)