Improve client node_count validation
Currently client rely node_count validation on server side, this is not good, the patch fix this. Also make node_count default to 1. Add invalid --node-count test. Change-Id: I21109682358e125ae99326978eee73e09db476ba Closes-Bug: #1522668 Related-Bug: #1465097
This commit is contained in:
parent
d25bd6e3c3
commit
9e52d59148
@ -42,7 +42,13 @@ class TestCommandLineArgument(utils.TestCase):
|
|||||||
_few_argument_error = [
|
_few_argument_error = [
|
||||||
'.*?^usage: magnum ',
|
'.*?^usage: magnum ',
|
||||||
'.*?^error: (the following arguments|too few arguments)',
|
'.*?^error: (the following arguments|too few arguments)',
|
||||||
".*?^Try"
|
".*?^Try 'magnum help ",
|
||||||
|
]
|
||||||
|
|
||||||
|
_invalid_value_error = [
|
||||||
|
'.*?^usage: ',
|
||||||
|
'.*?^error: argument .*: invalid .* value:',
|
||||||
|
".*?^Try 'magnum help ",
|
||||||
]
|
]
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -73,6 +73,12 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
|
|||||||
self._mandatory_arg_error)
|
self._mandatory_arg_error)
|
||||||
self.assertFalse(mock_create.called)
|
self.assertFalse(mock_create.called)
|
||||||
|
|
||||||
|
@mock.patch('magnumclient.v1.bays.BayManager.create')
|
||||||
|
def test_bay_create_failure_invalid_node_count(self, mock_create):
|
||||||
|
self._test_arg_failure('bay-create --baymodel xxx --node-count test',
|
||||||
|
self._invalid_value_error)
|
||||||
|
self.assertFalse(mock_create.called)
|
||||||
|
|
||||||
@mock.patch('magnumclient.v1.bays.BayManager.create')
|
@mock.patch('magnumclient.v1.bays.BayManager.create')
|
||||||
def test_bay_create_failure_only_bay_create_timeout(self, mock_create):
|
def test_bay_create_failure_only_bay_create_timeout(self, mock_create):
|
||||||
self._test_arg_failure('bay-create --timeout 15',
|
self._test_arg_failure('bay-create --timeout 15',
|
||||||
|
@ -38,6 +38,8 @@ def do_bay_list(cs, args):
|
|||||||
help='ID or name of the baymodel.')
|
help='ID or name of the baymodel.')
|
||||||
@utils.arg('--node-count',
|
@utils.arg('--node-count',
|
||||||
metavar='<node-count>',
|
metavar='<node-count>',
|
||||||
|
type=int,
|
||||||
|
default=1,
|
||||||
help='The bay node count.')
|
help='The bay node count.')
|
||||||
@utils.arg('--master-count',
|
@utils.arg('--master-count',
|
||||||
metavar='<master-count>',
|
metavar='<master-count>',
|
||||||
|
Loading…
Reference in New Issue
Block a user