Allow to override max_count in map_instances
Related-issue: https://mirantis.jira.com/browse/PROD-34308
Change-Id: Ifdec823b0136db5c4f739d9f5af6036ebdc26f78
diff --git a/_states/novav21.py b/_states/novav21.py
index ad8a4a5..00ea0c6 100644
--- a/_states/novav21.py
+++ b/_states/novav21.py
@@ -459,10 +459,13 @@
return ret
-def instances_mapped_to_cell(name, timeout=60, runas='nova'):
+def instances_mapped_to_cell(name, max_count=None, timeout=60, runas='nova'):
"""Ensure that all instances in the cell are mapped
:param name: cell name.
+ :param max_count: how many instances to map in one iteration. If there are
+ lots of instances present in the cell database, consider setting higher
+ value. By default nova will run in batches of 50.
:param timeout: amount of time in seconds mapping process should finish in.
:param runas: username to run the shell commands under.
"""
@@ -476,12 +479,13 @@
'Failed to map all instances in cell {0}, it does not exist'
.format(name))
return result
+ command = 'nova-manage cell_v2 map_instances --cell_uuid %s' % cell_uuid
+ if max_count:
+ command += ' --max-count %s' % max_count
start_time = time.time()
if not test:
while True:
- rc = __salt__['cmd.retcode'](
- 'nova-manage cell_v2 map_instances --cell_uuid %s' % cell_uuid,
- runas=runas)
+ rc = __salt__['cmd.retcode'](command, runas=runas)
if rc == 0 or time.time() - start_time > timeout:
break
if rc != 0: