Merge "Remove db auto-creation magic from glance-manage"
This commit is contained in:
commit
09dc108007
@ -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)
|
||||
|
@ -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]
|
||||
|
@ -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 "
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user