diff --git a/nova/cmd/manage.py b/nova/cmd/manage.py index 3d33602f56f..1329774754c 100644 --- a/nova/cmd/manage.py +++ b/nova/cmd/manage.py @@ -2662,7 +2662,9 @@ def get_machine_type(self, instance_uuid=None): exception.InstanceMappingNotFound) as e: print(str(e)) return 2 - except Exception: + except Exception as e: + print('Unexpected error, see nova-manage.log for the full ' + 'trace: %s ' % str(e)) LOG.exception('Unexpected error') return 1 @@ -2716,7 +2718,9 @@ def update_machine_type( ) as e: print(str(e)) return 2 - except Exception: + except Exception as e: + print('Unexpected error, see nova-manage.log for the full ' + 'trace: %s ' % str(e)) LOG.exception('Unexpected error') return 1 @@ -2747,7 +2751,9 @@ def list_unset_machine_type(self, cell_uuid=None): except exception.CellMappingNotFound as e: print(str(e)) return 2 - except Exception: + except Exception as e: + print('Unexpected error, see nova-manage.log for the full ' + 'trace: %s ' % str(e)) LOG.exception('Unexpected error') return 1 diff --git a/nova/tests/unit/cmd/test_manage.py b/nova/tests/unit/cmd/test_manage.py index 875345d35bf..c926f344d31 100644 --- a/nova/tests/unit/cmd/test_manage.py +++ b/nova/tests/unit/cmd/test_manage.py @@ -3050,10 +3050,14 @@ def test_get(self, mock_get_context, mock_get_machine_type): def test_get_unknown_failure( self, mock_get_context, mock_get_machine_type ): - mock_get_machine_type.side_effect = Exception() + mock_get_machine_type.side_effect = Exception('oops') ret = self.commands.get_machine_type( instance_uuid=uuidsentinel.instance ) + output = self.output.getvalue().strip() + self.assertIn( + 'Unexpected error, see nova-manage.log for the full trace: oops', + output) self.assertEqual(1, ret) @mock.patch('nova.virt.libvirt.machine_type_utils.get_machine_type') @@ -3145,11 +3149,15 @@ def test_update_force(self, mock_get_context, mock_update): @mock.patch('nova.virt.libvirt.machine_type_utils.update_machine_type') @mock.patch('nova.context.get_admin_context', new=mock.Mock()) def test_update_unknown_failure(self, mock_update): - mock_update.side_effect = Exception() + mock_update.side_effect = Exception('oops') ret = self.commands.update_machine_type( instance_uuid=uuidsentinel.instance, machine_type=mock.sentinel.machine_type ) + output = self.output.getvalue().strip() + self.assertIn( + 'Unexpected error, see nova-manage.log for the full trace: oops', + output) self.assertEqual(1, ret) @mock.patch('nova.virt.libvirt.machine_type_utils.update_machine_type') @@ -3269,9 +3277,13 @@ def test_list_unset_machine_type_none_found( def test_list_unset_machine_type_unknown_failure( self, mock_get_context, mock_get_instances ): - mock_get_instances.side_effect = Exception() + mock_get_instances.side_effect = Exception('oops') ret = self.commands.list_unset_machine_type( cell_uuid=uuidsentinel.cell_uuid) + output = self.output.getvalue().strip() + self.assertIn( + 'Unexpected error, see nova-manage.log for the full trace: oops', + output) self.assertEqual(1, ret) @mock.patch(