Adding an ability to specify batches num for online migrations.

- By default migrations would use 50 chunks per round.
  We can specify larger number to speed it up.

Prod-Related: PROD-33940
Change-Id: I3d2d3f4590b3a303be55ae76f8e3e701b24e4563
diff --git a/README.rst b/README.rst
index 9039cd0..02d0279 100644
--- a/README.rst
+++ b/README.rst
@@ -195,6 +195,18 @@
       controller:
         update_cells: true
 
+Increase number of chunks for online db migrations:
+
+.. note:: This only should be done in offline as large number of
+   rows locked by this process may cause service outage, which
+   may not be expected.
+
+.. code-block:: yaml
+
+    nova:
+      controller:
+        db_migrations:
+          max_count: 5000000
 
 Configuring TLS communications
 ------------------------------
diff --git a/nova/db/online_sync.sls b/nova/db/online_sync.sls
index 828b35c..ae26a41 100644
--- a/nova/db/online_sync.sls
+++ b/nova/db/online_sync.sls
@@ -4,9 +4,14 @@
 {%- if not grains.get('noservices') and controller.version not in ["juno", "kilo", "liberty"] and controller.get('role', 'primary') == 'primary' %}
 {%- set should_run = '/bin/true' %}
 {%- endif %}
+{%- if controller.get('db_migrations', {}).max_count is defined %}
+{%-   set batches = " --max-count %s" % controller.db_migrations.max_count %}
+{%- else %}
+{%-   set batches = "" %}
+{%- endif %}
 
 nova_controller_online_data_migrations:
   cmd.run:
-  - name: nova-manage db online_data_migrations
+  - name: nova-manage db online_data_migrations{{ batches }}
   - onlyif: {{ should_run }}
   - runas: 'nova'