add num_instances option for nova boot.
fix bug #1092475. Change-Id: I584b27c1f24c6a5183a2289e77580f204db2e4db
This commit is contained in:
parent
aa1df04bad
commit
fba20df12c
@ -48,6 +48,11 @@ def _boot(cs, args, reservation_id=None, min_count=None, max_count=None):
|
|||||||
if not args.flavor:
|
if not args.flavor:
|
||||||
raise exceptions.CommandError("you need to specify a Flavor ID ")
|
raise exceptions.CommandError("you need to specify a Flavor ID ")
|
||||||
|
|
||||||
|
if args.num_instances:
|
||||||
|
if args.num_instances <= 1:
|
||||||
|
raise exceptions.CommandError("num_instances should be > 1")
|
||||||
|
max_count = args.num_instances
|
||||||
|
|
||||||
flavor = _find_flavor(cs, args.flavor)
|
flavor = _find_flavor(cs, args.flavor)
|
||||||
|
|
||||||
if args.image:
|
if args.image:
|
||||||
@ -149,6 +154,11 @@ def _boot(cs, args, reservation_id=None, min_count=None, max_count=None):
|
|||||||
default=None,
|
default=None,
|
||||||
metavar='<image>',
|
metavar='<image>',
|
||||||
help="Image ID (see 'nova image-list'). ")
|
help="Image ID (see 'nova image-list'). ")
|
||||||
|
@utils.arg('--num-instances',
|
||||||
|
default=None,
|
||||||
|
type=int,
|
||||||
|
metavar='<number>',
|
||||||
|
help="boot multi instances at a time")
|
||||||
@utils.arg('--meta',
|
@utils.arg('--meta',
|
||||||
metavar="<key=value>",
|
metavar="<key=value>",
|
||||||
action='append',
|
action='append',
|
||||||
|
@ -224,6 +224,24 @@ class ShellTest(utils.TestCase):
|
|||||||
cmd = 'boot some-server --image 1 --file /foo=%s' % invalid_file
|
cmd = 'boot some-server --image 1 --file /foo=%s' % invalid_file
|
||||||
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
|
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
|
||||||
|
|
||||||
|
def test_boot_num_instances(self):
|
||||||
|
self.run_command('boot --image 1 --flavor 1 --num-instances 3 server')
|
||||||
|
self.assert_called_anytime(
|
||||||
|
'POST', '/servers',
|
||||||
|
{
|
||||||
|
'server': {
|
||||||
|
'flavorRef': '1',
|
||||||
|
'name': 'server',
|
||||||
|
'imageRef': '1',
|
||||||
|
'min_count': 1,
|
||||||
|
'max_count': 3,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
def test_flavor_list(self):
|
def test_flavor_list(self):
|
||||||
self.run_command('flavor-list')
|
self.run_command('flavor-list')
|
||||||
self.assert_called('GET', '/flavors/aa1/os-extra_specs')
|
self.assert_called('GET', '/flavors/aa1/os-extra_specs')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user