Merge "Deprecate num-instances in favor of min/max count"
This commit is contained in:
commit
735af643aa
@ -590,6 +590,51 @@ class ShellTest(utils.TestCase):
|
|||||||
cmd = 'boot --image 1 --flavor 1 --num-instances 0 server'
|
cmd = 'boot --image 1 --flavor 1 --num-instances 0 server'
|
||||||
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
|
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
|
||||||
|
|
||||||
|
def test_boot_num_instances_and_count(self):
|
||||||
|
cmd = 'boot --image 1 --flavor 1 --num-instances 3 --min-count 3 serv'
|
||||||
|
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
|
||||||
|
cmd = 'boot --image 1 --flavor 1 --num-instances 3 --max-count 3 serv'
|
||||||
|
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
|
||||||
|
|
||||||
|
def test_boot_min_max_count(self):
|
||||||
|
self.run_command('boot --image 1 --flavor 1 --max-count 3 server')
|
||||||
|
self.assert_called_anytime(
|
||||||
|
'POST', '/servers',
|
||||||
|
{
|
||||||
|
'server': {
|
||||||
|
'flavorRef': '1',
|
||||||
|
'name': 'server',
|
||||||
|
'imageRef': '1',
|
||||||
|
'min_count': 1,
|
||||||
|
'max_count': 3,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
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 5 server')
|
||||||
|
self.assert_called_anytime(
|
||||||
|
'POST', '/servers',
|
||||||
|
{
|
||||||
|
'server': {
|
||||||
|
'flavorRef': '1',
|
||||||
|
'name': 'server',
|
||||||
|
'imageRef': '1',
|
||||||
|
'min_count': 3,
|
||||||
|
'max_count': 5,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
@mock.patch('novaclient.v1_1.shell._poll_for_status')
|
@mock.patch('novaclient.v1_1.shell._poll_for_status')
|
||||||
def test_boot_with_poll(self, poll_method):
|
def test_boot_with_poll(self, poll_method):
|
||||||
self.run_command('boot --flavor 1 --image 1 some-server --poll')
|
self.run_command('boot --flavor 1 --image 1 some-server --poll')
|
||||||
|
@ -489,6 +489,51 @@ class ShellTest(utils.TestCase):
|
|||||||
cmd = 'boot --image 1 --flavor 1 --num-instances 0 server'
|
cmd = 'boot --image 1 --flavor 1 --num-instances 0 server'
|
||||||
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
|
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
|
||||||
|
|
||||||
|
def test_boot_num_instances_and_count(self):
|
||||||
|
cmd = 'boot --image 1 --flavor 1 --num-instances 3 --min-count 3 serv'
|
||||||
|
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
|
||||||
|
cmd = 'boot --image 1 --flavor 1 --num-instances 3 --max-count 3 serv'
|
||||||
|
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
|
||||||
|
|
||||||
|
def test_boot_min_max_count(self):
|
||||||
|
self.run_command('boot --image 1 --flavor 1 --max-count 3 server')
|
||||||
|
self.assert_called_anytime(
|
||||||
|
'POST', '/servers',
|
||||||
|
{
|
||||||
|
'server': {
|
||||||
|
'flavor_ref': '1',
|
||||||
|
'name': 'server',
|
||||||
|
'image_ref': '1',
|
||||||
|
'os-multiple-create:min_count': 1,
|
||||||
|
'os-multiple-create:max_count': 3,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
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 5 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': 5,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
@mock.patch('novaclient.v3.shell._poll_for_status')
|
@mock.patch('novaclient.v3.shell._poll_for_status')
|
||||||
def test_boot_with_poll(self, poll_method):
|
def test_boot_with_poll(self, poll_method):
|
||||||
self.run_command('boot --flavor 1 --image 1 some-server --poll')
|
self.run_command('boot --flavor 1 --image 1 some-server --poll')
|
||||||
|
@ -148,10 +148,25 @@ def _boot(cs, args):
|
|||||||
|
|
||||||
min_count = 1
|
min_count = 1
|
||||||
max_count = 1
|
max_count = 1
|
||||||
if args.num_instances is not None:
|
# 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:
|
if args.num_instances <= 1:
|
||||||
raise exceptions.CommandError(_("num_instances should be > 1"))
|
raise exceptions.CommandError(_("num_instances should be > 1"))
|
||||||
max_count = args.num_instances
|
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"))
|
||||||
|
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"))
|
||||||
|
max_count = args.max_count
|
||||||
|
|
||||||
flavor = _find_flavor(cs, args.flavor)
|
flavor = _find_flavor(cs, args.flavor)
|
||||||
|
|
||||||
@ -312,7 +327,17 @@ def _boot(cs, args):
|
|||||||
default=None,
|
default=None,
|
||||||
type=int,
|
type=int,
|
||||||
metavar='<number>',
|
metavar='<number>',
|
||||||
help=_("boot multiple servers at a time (limited by quota)."))
|
help=argparse.SUPPRESS)
|
||||||
|
@utils.arg('--min-count',
|
||||||
|
default=None,
|
||||||
|
type=int,
|
||||||
|
metavar='<number>',
|
||||||
|
help=_("Boot at least <number> servers (limited by quota)."))
|
||||||
|
@utils.arg('--max-count',
|
||||||
|
default=None,
|
||||||
|
type=int,
|
||||||
|
metavar='<number>',
|
||||||
|
help=_("Boot up to <number> servers (limited by quota)."))
|
||||||
@utils.arg('--meta',
|
@utils.arg('--meta',
|
||||||
metavar="<key=value>",
|
metavar="<key=value>",
|
||||||
action='append',
|
action='append',
|
||||||
|
@ -84,10 +84,25 @@ def _boot(cs, args):
|
|||||||
|
|
||||||
min_count = 1
|
min_count = 1
|
||||||
max_count = 1
|
max_count = 1
|
||||||
if args.num_instances is not None:
|
# 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:
|
if args.num_instances <= 1:
|
||||||
raise exceptions.CommandError("num_instances should be > 1")
|
raise exceptions.CommandError("num_instances should be > 1")
|
||||||
max_count = args.num_instances
|
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")
|
||||||
|
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")
|
||||||
|
max_count = args.max_count
|
||||||
|
|
||||||
flavor = _find_flavor(cs, args.flavor)
|
flavor = _find_flavor(cs, args.flavor)
|
||||||
|
|
||||||
@ -214,7 +229,17 @@ def _boot(cs, args):
|
|||||||
default=None,
|
default=None,
|
||||||
type=int,
|
type=int,
|
||||||
metavar='<number>',
|
metavar='<number>',
|
||||||
help="boot multiple servers at a time (limited by quota).")
|
help=argparse.SUPPRESS)
|
||||||
|
@utils.arg('--min-count',
|
||||||
|
default=None,
|
||||||
|
type=int,
|
||||||
|
metavar='<number>',
|
||||||
|
help="Boot at least <number> servers (limited by quota).")
|
||||||
|
@utils.arg('--max-count',
|
||||||
|
default=None,
|
||||||
|
type=int,
|
||||||
|
metavar='<number>',
|
||||||
|
help="Boot up to <number> servers (limited by quota).")
|
||||||
@utils.arg('--meta',
|
@utils.arg('--meta',
|
||||||
metavar="<key=value>",
|
metavar="<key=value>",
|
||||||
action='append',
|
action='append',
|
||||||
|
Loading…
Reference in New Issue
Block a user