Merge "Allow the default value of 1 to be set for boot multiple"

This commit is contained in:
Jenkins 2014-05-12 16:15:26 +00:00 committed by Gerrit Code Review
commit 0e61a37e7e
4 changed files with 50 additions and 16 deletions

View File

@ -571,8 +571,6 @@ class ShellTest(utils.TestCase):
})
def test_boot_invalid_num_instances(self):
cmd = 'boot --image 1 --flavor 1 --num-instances 1 server'
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
cmd = 'boot --image 1 --flavor 1 --num-instances 0 server'
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
@ -596,6 +594,19 @@ class ShellTest(utils.TestCase):
}
})
self.run_command('boot --image 1 --flavor 1 --min-count 3 server')
self.assert_called_anytime(
'POST', '/servers',
{
'server': {
'flavorRef': '1',
'name': 'server',
'imageRef': '1',
'min_count': 3,
'max_count': 3,
}
})
self.run_command('boot --image 1 --flavor 1 '
'--min-count 3 --max-count 3 server')
self.assert_called_anytime(
'POST', '/servers',
{
@ -620,6 +631,8 @@ class ShellTest(utils.TestCase):
'max_count': 5,
}
})
cmd = 'boot --image 1 --flavor 1 --min-count 3 --max-count 1 serv'
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
@mock.patch('novaclient.v1_1.shell._poll_for_status')
def test_boot_with_poll(self, poll_method):

View File

@ -470,8 +470,6 @@ class ShellTest(utils.TestCase):
})
def test_boot_invalid_num_instances(self):
cmd = 'boot --image 1 --flavor 1 --num-instances 1 server'
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
cmd = 'boot --image 1 --flavor 1 --num-instances 0 server'
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
@ -495,6 +493,19 @@ class ShellTest(utils.TestCase):
}
})
self.run_command('boot --image 1 --flavor 1 --min-count 3 server')
self.assert_called_anytime(
'POST', '/servers',
{
'server': {
'flavor_ref': '1',
'name': 'server',
'image_ref': '1',
'os-multiple-create:min_count': 3,
'os-multiple-create:max_count': 3,
}
})
self.run_command('boot --image 1 --flavor 1 '
'--min-count 3 --max-count 3 server')
self.assert_called_anytime(
'POST', '/servers',
{
@ -519,6 +530,8 @@ class ShellTest(utils.TestCase):
'os-multiple-create:max_count': 5,
}
})
cmd = 'boot --image 1 --flavor 1 --min-count 3 --max-count 1 serv'
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
@mock.patch('novaclient.v3.shell._poll_for_status')
def test_boot_with_poll(self, poll_method):

View File

@ -151,22 +151,26 @@ def _boot(cs, args):
# Don't let user mix num_instances and max_count/min_count.
if (args.num_instances is not None and
args.min_count is None and args.max_count is None):
if args.num_instances <= 1:
raise exceptions.CommandError(_("num_instances should be > 1"))
if args.num_instances < 1:
raise exceptions.CommandError(_("num_instances should be >= 1"))
max_count = args.num_instances
elif (args.num_instances is not None and
(args.min_count is not None or args.max_count is not None)):
raise exceptions.CommandError(_("Don't mix num-instances and "
"max/min-count"))
if args.min_count is not None:
if args.min_count <= 1:
raise exceptions.CommandError(_("min_count should be > 1"))
if args.min_count < 1:
raise exceptions.CommandError(_("min_count should be >= 1"))
min_count = args.min_count
max_count = min_count
if args.max_count is not None:
if args.max_count <= 1:
raise exceptions.CommandError(_("max_count should be > 1"))
if args.max_count < 1:
raise exceptions.CommandError(_("max_count should be >= 1"))
max_count = args.max_count
if (args.min_count is not None and args.max_count is not None and
args.min_count > args.max_count):
raise exceptions.CommandError(_(
"min_count should be <= max_count"))
flavor = _find_flavor(cs, args.flavor)

View File

@ -87,22 +87,26 @@ def _boot(cs, args):
# Don't let user mix num_instances and max_count/min_count.
if (args.num_instances is not None and
args.min_count is None and args.max_count is None):
if args.num_instances <= 1:
raise exceptions.CommandError("num_instances should be > 1")
if args.num_instances < 1:
raise exceptions.CommandError("num_instances should be >= 1")
max_count = args.num_instances
elif (args.num_instances is not None and
(args.min_count is not None or args.max_count is not None)):
raise exceptions.CommandError("Don't mix num-instances and "
"max/min-count")
if args.min_count is not None:
if args.min_count <= 1:
raise exceptions.CommandError("min_count should be > 1")
if args.min_count < 1:
raise exceptions.CommandError("min_count should be >= 1")
min_count = args.min_count
max_count = min_count
if args.max_count is not None:
if args.max_count <= 1:
raise exceptions.CommandError("max_count should be > 1")
if args.max_count < 1:
raise exceptions.CommandError("max_count should be >= 1")
max_count = args.max_count
if (args.min_count is not None and args.max_count is not None and
args.min_count > args.max_count):
raise exceptions.CommandError(
"min_count should be <= max_count")
flavor = _find_flavor(cs, args.flavor)