'Perform online data migrations for the release in batches.'

@args('--max_count', metavar='<number>', dest='max_count', type=int, help='Maximum    number    of    objects    to    consider.')
@args('--ignore_state', action='store_true', dest='ignore_state', help='Force    records    to    migrate    even    if    another    operation    is    performed    on    them.    This    may    be    dangerous,    please    refer    to    release    notes    for    more    information.')
def online_data_migrations(self, max_count=None, ignore_state=False):

    ctxt = context.get_admin_context()
    if (max_count is not None):
        unlimited = False
        if (max_count < 1):
            print(_('Must    supply    a    positive    value    for    max_number.'))
            sys.exit(127)
    else:
        unlimited = True
        max_count = 50
        print((_('Running    batches    of    %i    until    complete.') % max_count))
    ran = None
    migration_info = {}
    while ((ran is None) or (ran != 0)):
        migrations = self._run_migration(ctxt, max_count, ignore_state)
        migration_info.update(migrations)
        ran = sum([done for (found, done, remaining) in migrations.values()])
        if (not unlimited):
            break
    t = prettytable.PrettyTable([_('Migration'), _('Found'), _('Done'), _('Remaining')])
    for name in sorted(migration_info.keys()):
        info = migration_info[name]
        t.add_row([name, info[0], info[1], info[2]])
    print(t)
    sys.exit((1 if ran else 0))
