Adding db_sync to mirror nova
This commit is contained in:
parent
0236aea227
commit
15d8f90cb9
@ -89,6 +89,15 @@ def do_version_control(options, args):
|
||||
glance.registry.db.migration.version_control(options)
|
||||
|
||||
|
||||
def do_db_sync(options, args):
|
||||
"""Place a database under migration control and upgrade"""
|
||||
try:
|
||||
db_version = args[1]
|
||||
except IndexError:
|
||||
db_version = None
|
||||
glance.registry.db.migration.db_sync(options, version=db_version)
|
||||
|
||||
|
||||
def dispatch_cmd(options, args):
|
||||
"""Search for do_* cmd in this module and then run it"""
|
||||
cmd = args[0]
|
||||
|
@ -24,8 +24,7 @@ DESCRIPTION
|
||||
glance-manage is a utility for managing and configuring a Glance installation.
|
||||
One important use of glance-manage is to setup the database. To do this run::
|
||||
|
||||
glance-manage version_control
|
||||
glance-manage upgrade
|
||||
glance-manage db_sync
|
||||
|
||||
OPTIONS
|
||||
=======
|
||||
|
@ -76,16 +76,39 @@ def version_control(options):
|
||||
|
||||
:param options: options dict
|
||||
"""
|
||||
repo_path = _find_migrate_repo()
|
||||
sql_connection = options['sql_connection']
|
||||
try:
|
||||
versioning_api.version_control(sql_connection, repo_path)
|
||||
_version_control(options)
|
||||
except versioning_exceptions.DatabaseAlreadyControlledError, e:
|
||||
msg = ("database '%(sql_connection)s' is already under migration "
|
||||
"control" % locals())
|
||||
raise exception.DatabaseMigrationError(msg)
|
||||
|
||||
|
||||
def _version_control(options):
|
||||
"""Place a database under migration control
|
||||
|
||||
:param options: options dict
|
||||
"""
|
||||
repo_path = _find_migrate_repo()
|
||||
sql_connection = options['sql_connection']
|
||||
return versioning_api.version_control(sql_connection, repo_path)
|
||||
|
||||
|
||||
def db_sync(options, version=None):
|
||||
"""Place a database under migration control and perform an upgrade
|
||||
|
||||
:param options: options dict
|
||||
:retval version number
|
||||
"""
|
||||
try:
|
||||
_version_control(options)
|
||||
except versioning_exceptions.DatabaseAlreadyControlledError, e:
|
||||
pass
|
||||
|
||||
upgrade(options, version=version)
|
||||
|
||||
|
||||
def _find_migrate_repo():
|
||||
"""Get the path for the migrate repository."""
|
||||
path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
|
||||
|
Loading…
x
Reference in New Issue
Block a user