diff --git a/novaclient/tests/unit/v2/test_migrations.py b/novaclient/tests/unit/v2/test_migrations.py index e69d3327e..408909cda 100644 --- a/novaclient/tests/unit/v2/test_migrations.py +++ b/novaclient/tests/unit/v2/test_migrations.py @@ -10,6 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. +import mock + from novaclient import api_versions from novaclient.tests.unit import utils from novaclient.tests.unit.v2 import fakes @@ -38,6 +40,15 @@ class MigrationsTest(utils.TestCase): self.assertIsInstance(m, migrations.Migration) self.assertEqual(m.migration_type, 'live-migration') + @mock.patch('novaclient.v2.migrations.warnings.warn') + def test_list_migrations_with_cell_name(self, mock_warn): + ml = self.cs.migrations.list(cell_name="abc") + self.assert_request_id(ml, fakes.FAKE_REQUEST_ID_LIST) + self.cs.assert_called('GET', '/os-migrations?cell_name=abc') + for m in ml: + self.assertIsInstance(m, migrations.Migration) + self.assertTrue(mock_warn.called) + def test_list_migrations_with_filters(self): ml = self.cs.migrations.list('host1', 'finished', 'child1') self.assert_request_id(ml, fakes.FAKE_REQUEST_ID_LIST) diff --git a/novaclient/v2/client.py b/novaclient/v2/client.py index b85077392..73280b59b 100644 --- a/novaclient/v2/client.py +++ b/novaclient/v2/client.py @@ -183,7 +183,11 @@ class Client(object): self.server_external_events = \ server_external_events.ServerExternalEventManager(self) - self.logger = logger or logging.getLogger(__name__) + if not logger: + logger = logging.getLogger(__name__) + if not logger.handlers: + logger.addHandler(logging.StreamHandler()) + self.logger = logger # Add in any extensions... if extensions: diff --git a/novaclient/v2/migrations.py b/novaclient/v2/migrations.py index 5a39ed992..72e0deda9 100644 --- a/novaclient/v2/migrations.py +++ b/novaclient/v2/migrations.py @@ -19,6 +19,8 @@ from six.moves.urllib import parse from novaclient import base from novaclient.i18n import _ +import warnings + class Migration(base.Resource): def __repr__(self): @@ -41,9 +43,9 @@ class MigrationManager(base.ManagerWithFind): if status: opts['status'] = status if cell_name: - self.client.logger.warning(_("Argument 'cell_name' is " - "deprecated since Pike, and will " - "be removed in a future release.")) + warnings.warn(_("Argument 'cell_name' is " + "deprecated since Pike, and will " + "be removed in a future release.")) opts['cell_name'] = cell_name if instance_uuid: opts['instance_uuid'] = instance_uuid