def db_version():
    repo_path = _find_migrate_repo()
    try:
        return versioning_api.db_version(FLAGS.sql_connection, repo_path)
    except versioning_exceptions.DatabaseNotControlledError:
        # If we aren't version controlled we may already have the database
        # in the state from before we started version control, check for that
        # and set up version_control appropriately
        meta = sqlalchemy.MetaData()
        engine = sqlalchemy.create_engine(FLAGS.sql_connection, echo=False)
        meta.reflect(bind=engine)
        try:
            for table in ('auth_tokens', 'zones', 'export_devices',
                          'fixed_ips', 'floating_ips', 'instances',
                          'key_pairs', 'networks', 'projects', 'quotas',
                          'security_group_instance_association',
                          'security_group_rules', 'security_groups',
                          'services', 'migrations',
                          'users', 'user_project_association',
                          'user_project_role_association',
                          'user_role_association',
                          'virtual_storage_arrays',
                          'volumes', 'volume_metadata',
                          'volume_types', 'volume_type_extra_specs'):
                assert table in meta.tables
            return db_version_control(1)
        except __HOLE__:
            return db_version_control(0)
dataset/ETHPy150Open nii-cloud/dodai-compute/nova/db/sqlalchemy/migration.py/db_version