Merge "Display baymodel info with bay-show command"
This commit is contained in:
@@ -16,6 +16,7 @@ import mock
|
||||
|
||||
from magnumclient import exceptions
|
||||
from magnumclient.tests.v1 import shell_test_base
|
||||
from magnumclient.tests.v1 import test_baymodels_shell
|
||||
from magnumclient.v1.bays import Bay
|
||||
|
||||
|
||||
@@ -113,6 +114,17 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
|
||||
'--timeout 15')
|
||||
self.assertTrue(mock_create.called)
|
||||
|
||||
@mock.patch('magnumclient.v1.baymodels.BayModelManager.get')
|
||||
@mock.patch('magnumclient.v1.bays.BayManager.get')
|
||||
def test_bay_show_baymodel_metadata(self, mock_bay, mock_baymodel):
|
||||
mock_bay.return_value = FakeBay(info={'links': 0, 'baymodel_id': 0})
|
||||
mock_baymodel.return_value = test_baymodels_shell.FakeBayModel(
|
||||
info={'links': 0, 'uuid': 0, 'id': 0, 'name': ''})
|
||||
|
||||
self._test_arg_success('bay-show --long x', 'baymodel_name')
|
||||
self.assertTrue(mock_bay.called)
|
||||
self.assertTrue(mock_baymodel.called)
|
||||
|
||||
@mock.patch('magnumclient.v1.baymodels.BayModelManager.get')
|
||||
@mock.patch('magnumclient.v1.bays.BayManager.create')
|
||||
def test_bay_create_success_only_baymodel_arg(self, mock_create, mock_get):
|
||||
|
||||
@@ -124,9 +124,19 @@ def do_bay_delete(cs, args):
|
||||
@utils.arg('bay',
|
||||
metavar='<bay>',
|
||||
help='ID or name of the bay to show.')
|
||||
@utils.arg('--long',
|
||||
action='store_true', default=False,
|
||||
help='Display extra associated Baymodel info.')
|
||||
def do_bay_show(cs, args):
|
||||
"""Show details about the given bay."""
|
||||
bay = cs.bays.get(args.bay)
|
||||
if args.long:
|
||||
baymodel = cs.baymodels.get(bay.baymodel_id)
|
||||
del baymodel._info['links'], baymodel._info['uuid']
|
||||
|
||||
for key in baymodel._info:
|
||||
if 'baymodel_' + key not in bay._info:
|
||||
bay._info['baymodel_' + key] = baymodel._info[key]
|
||||
_show_bay(bay)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user