Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions nova/cmd/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
18 changes: 15 additions & 3 deletions nova/tests/unit/cmd/test_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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(
Expand Down