Return a less dramatic message for public flavors.

Getting the access list of a public flavor bails out with a dramatic
error message, suggesting that something is broken.  This changes the
message to an unagitated "Access list not available for public
flavors."

Change-Id: I432496c24b23de8fa58de93f2cbed8bed1d540b1
This commit is contained in:
Sven Anderson 2016-03-04 19:36:03 +01:00
parent d63800d5ec
commit c2ec89d285
3 changed files with 8 additions and 6 deletions
novaclient
tests
functional/v2/legacy
unit/v2
v2

@ -54,13 +54,11 @@ class TestFlvAccessNovaClient(base.TenantTestBase):
# For microversion < 2.7 the 'flavor-access-add' operation is executed
# successfully for public flavor, but the next operation,
# 'flavor-access-list --flavor %(name_of_public_flavor)' returns
# CommandError: Failed to get access list for public flavor type.
# a CommandError
flv_name = self.name_generate(prefix='flv')
self.nova('flavor-create %s auto 512 1 1' % flv_name)
self.addCleanup(self.nova, 'flavor-delete %s' % flv_name)
self.nova('flavor-access-add %s %s' % (flv_name, self.tenant_id))
output = self.nova('flavor-access-list --flavor %s' % flv_name,
fail_ok=True, merge_stderr=True)
self.assertIn("ERROR (CommandError): "
"Failed to get access list for public flavor type.\n",
output)
self.assertIn("CommandError", output)

@ -851,6 +851,10 @@ class ShellTest(utils.TestCase):
cmd = 'flavor-access-list'
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
def test_flavor_access_list_public(self):
cmd = 'flavor-access-list --flavor 1'
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
def test_flavor_access_add_by_id(self):
self.run_command('flavor-access-add 2 proj2')
self.assert_called('POST', '/flavors/2/action',

@ -882,8 +882,8 @@ def do_flavor_access_list(cs, args):
elif args.flavor:
flavor = _find_flavor(cs, args.flavor)
if flavor.is_public:
raise exceptions.CommandError(_("Failed to get access list "
"for public flavor type."))
raise exceptions.CommandError(_("Access list not available "
"for public flavors."))
kwargs = {'flavor': flavor}
elif args.tenant:
kwargs = {'tenant': args.tenant}