From 186c3e99cf04b22ddbb1046cc9e42d1f7473e8cf Mon Sep 17 00:00:00 2001
From: =?utf8?q?Mathieu=20Gagne=CC=81?= <mgagne@iweb.com>
Date: Thu, 7 Aug 2014 19:21:49 -0400
Subject: [PATCH] Make manage.py usable

It's not possible to use manage.py in its current state due to
an exception thrown by oslo.config:

  oslo.config.cfg.ArgsAlreadyParsedError:
    arguments already parsed: cannot register CLI option

This exception is a side-effect of including
cinder.openstack.common.logging in most of the migration scripts.

This change therefore suggests removing oslo.config and other imports
from manage.py to make it usable again.

It is now possible to use manage.py:

  tox -evenv -- python cinder/db/sqlalchemy/migrate_repo/manage.py \
    version_control --url=sqlite:///./cinder.db

  tox -evenv -- python cinder/db/sqlalchemy/migrate_repo/manage.py \
    upgrade --url=sqlite:///./cinder.db

Closes-bug: #1355297
Change-Id: I843cfa9a4e4758a6bc8e5c04f064e9d3107b01fa
---
 cinder/db/sqlalchemy/migrate_repo/manage.py | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/cinder/db/sqlalchemy/migrate_repo/manage.py b/cinder/db/sqlalchemy/migrate_repo/manage.py
index d12e89188..22877d940 100755
--- a/cinder/db/sqlalchemy/migrate_repo/manage.py
+++ b/cinder/db/sqlalchemy/migrate_repo/manage.py
@@ -15,19 +15,11 @@
 
 import os
 
-from oslo.config import cfg
-
-from cinder import i18n
-i18n.enable_lazy()
-
 from cinder.db.sqlalchemy import migrate_repo
-from cinder import version
 
 from migrate.versioning.shell import main
 
-CONF = cfg.CONF
 
 if __name__ == '__main__':
-    CONF([], project='cinder', version=version.version_string())
-    main(debug='False', url=CONF.database.connection,
+    main(debug='False',
          repository=os.path.abspath(os.path.dirname(migrate_repo.__file__)))
-- 
2.45.2