Merge "Remove db auto-creation magic from glance-manage"

This commit is contained in:
Jenkins 2012-09-05 23:31:18 +00:00 committed by Gerrit Code Review
commit 09dc108007
5 changed files with 12 additions and 8 deletions

View File

@ -81,11 +81,6 @@ def do_db_sync(args):
Place a database under migration control and upgrade,
creating first if necessary.
"""
# override auto-create flag, as complete DB should always
# be created on sync if not already existing
CONF.register_opts(glance.db.sqlalchemy.api.db_opts)
CONF.set_override('db_auto_create', True)
glance.db.sqlalchemy.api.configure_db()
version = args.pop(0) if args else None
current_version = args.pop(0) if args else None
glance.db.sqlalchemy.migration.db_sync(version, current_version)

View File

@ -840,5 +840,6 @@ def image_tag_get_all(context, image_id, session=None):
tags = session.query(models.ImageTag).\
filter_by(image_id=image_id).\
filter_by(deleted=False).\
order_by(sqlalchemy.asc(models.ImageTag.created_at)).\
all()
return [tag['value'] for tag in tags]

View File

@ -98,6 +98,9 @@ def version_control(version=None):
def _version_control(version):
"""
Place a database under migration control
This will only set the specific version of a database, it won't
run any migrations.
"""
repo_path = get_migrate_repo_path()
sql_connection = CONF.sql_connection
@ -114,7 +117,7 @@ def db_sync(version=None, current_version=None):
"""
sql_connection = CONF.sql_connection
try:
_version_control(current_version)
_version_control(current_version or 0)
except versioning_exceptions.DatabaseAlreadyControlledError, e:
if current_version is not None:
msg = (_("database '%(sql_connection)s' is already under "

View File

@ -53,8 +53,11 @@ class TestGlanceManage(functional.FunctionalTest):
self.assertTrue('CREATE TABLE images' in out)
self.assertTrue('CREATE TABLE image_tags' in out)
self.assertTrue('CREATE TABLE image_members' in out)
self.assertTrue('CREATE TABLE image_properties' in out)
#NOTE(bcwaldon): For some reason we need double-quotes around
# these two table names
self.assertTrue('CREATE TABLE "image_members"' in out)
self.assertTrue('CREATE TABLE "image_properties"' in out)
@depends_on_exe('sqlite3')
@skip_if_disabled

View File

@ -35,6 +35,8 @@ from sqlalchemy.pool import NullPool
from glance.common import exception
import glance.db.sqlalchemy.migration as migration_api
#NOTE(bcwaldon): import this to prevent circular import
from glance.db.sqlalchemy import api
from glance.db.sqlalchemy import models
from glance.openstack.common import cfg
from glance.tests import utils