Skip to content

Commit

Permalink
"nova boot" should not log an error if subsidiary commands fail
Browse files Browse the repository at this point in the history
Fix:
Intially the cli was raising "CommadError" in case the requested
flavor or image were not present.
This error category was not approrpiate as it signifies an error
in the command syntax. When the requested resource (flavour/image)
does not exist, a ResourceNotFound error should be raised. So,
added a new error category "ResourceNotFound" to cater for this
scenario and updated the code to raise this new error.
"nova show <instance_name>" command has also been updated to raise
"ResourceNotFound" error when the requested vm for which details
have to be displayed does not exist.

Closes-Bug: #1258488
Change-Id: If64a087944586ef5792efe3baa62e455b9bbaa07
  • Loading branch information
Jyotsna-P committed Jun 17, 2014
1 parent d07699d commit b78c0d4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions novaclient/openstack/common/apiclient/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ class CommandError(ClientException):
pass


class ResourceNotFound(ClientException):
"""Error in getting the resource."""
pass


class AuthorizationFailure(ClientException):
"""Cannot authorize API client."""
pass
Expand Down
6 changes: 3 additions & 3 deletions novaclient/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ def setUp(self):

def test_find_none(self):
"""Test a few non-valid inputs."""
self.assertRaises(exceptions.CommandError,
self.assertRaises(exceptions.ResourceNotFound,
utils.find_resource,
self.manager,
'asdf')
self.assertRaises(exceptions.CommandError,
self.assertRaises(exceptions.ResourceNotFound,
utils.find_resource,
self.manager,
None)
self.assertRaises(exceptions.CommandError,
self.assertRaises(exceptions.ResourceNotFound,
utils.find_resource,
self.manager,
{})
Expand Down
2 changes: 1 addition & 1 deletion novaclient/tests/v1_1/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ def test_show_no_image(self):
self.assert_called('GET', '/flavors/1', pos=-1)

def test_show_bad_id(self):
self.assertRaises(exceptions.CommandError,
self.assertRaises(exceptions.ResourceNotFound,
self.run_command, 'show xxx')

@mock.patch('novaclient.v1_1.shell.utils.print_dict')
Expand Down
2 changes: 1 addition & 1 deletion novaclient/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def find_resource(manager, name_or_id, **find_args):
msg = _("No %(class)s with a name or ID of '%(name)s' exists.") % \
{'class': manager.resource_class.__name__.lower(),
'name': name_or_id}
raise exceptions.CommandError(msg)
raise exceptions.ResourceNotFound(msg)
except exceptions.NoUniqueMatch:
msg = (_("Multiple %(class)s matches found for '%(name)s', use an ID "
"to be more specific.") %
Expand Down

0 comments on commit b78c0d4

Please sign in to comment.