Fixing initial migration
The last commit broke the initial migration(which is worse, because it was the only substantial migration). This commit keeps from setting up the DB before running migrations. If any future migrations need to read from the DB they will need to do the same dance that's in 002. Change-Id: Icedf99d95b538cb24cccccc4d47ef68bdf225b4c
This commit is contained in:
parent
7b6cfd4ace
commit
72ebf18512
@ -35,8 +35,6 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
||||
if os.path.exists(os.path.join(possible_topdir, 'melange', '__init__.py')):
|
||||
sys.path.insert(0, possible_topdir)
|
||||
|
||||
from melange import ipv4
|
||||
from melange import mac
|
||||
from melange import version
|
||||
from melange.common import config
|
||||
from melange.common import utils
|
||||
@ -63,20 +61,13 @@ class Commands(object):
|
||||
def __init__(self, conf):
|
||||
self.conf = conf
|
||||
|
||||
def _db_connect(self):
|
||||
conf, app = config.Config.load_paste_app('melange', options, args)
|
||||
db_api.configure_db(conf, ipv4.plugin(), mac.plugin())
|
||||
|
||||
def db_sync(self):
|
||||
self._db_connect()
|
||||
db_api.db_sync(self.conf)
|
||||
|
||||
def db_upgrade(self, version=None, repo_path=None):
|
||||
self._db_connect()
|
||||
db_api.db_upgrade(self.conf, version, repo_path=repo_path)
|
||||
|
||||
def db_downgrade(self, version, repo_path=None):
|
||||
self._db_connect()
|
||||
db_api.db_downgrade(self.conf, version, repo_path=repo_path)
|
||||
|
||||
def routes(self, version):
|
||||
@ -136,7 +127,6 @@ if __name__ == '__main__':
|
||||
try:
|
||||
conf = config.Config.load_paste_config('melange', options, args)
|
||||
config.setup_logging(options, conf)
|
||||
db_api.configure_db(conf, ipv4.plugin(), mac.plugin())
|
||||
|
||||
command_name = args.pop(0)
|
||||
Commands(conf).execute(command_name, *args)
|
||||
|
@ -15,16 +15,19 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
#import optparse
|
||||
import optparse
|
||||
|
||||
#from melange import ipv4
|
||||
#from melange import mac
|
||||
#from melange.common import config
|
||||
from melange import ipv4
|
||||
from melange import mac
|
||||
from melange import version
|
||||
from melange.common import config
|
||||
from melange.db import db_api
|
||||
from melange.db.sqlalchemy import session
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
_db_connect()
|
||||
|
||||
interface = session.get_session().execute(
|
||||
"SELECT COUNT(1) as count FROM interfaces "
|
||||
"WHERE device_id NOT REGEXP '.*-.*' AND device_id IS NOT NULL")
|
||||
@ -44,12 +47,35 @@ $ python melange/db/sqlalchemy/migrate_repo/versions/002_device_id_to_uuid.py\\
|
||||
---------------------------------------------------------
|
||||
"""
|
||||
|
||||
# check for uuids in interfaces.device_id
|
||||
|
||||
|
||||
def downgrade(migrate_engine):
|
||||
pass
|
||||
|
||||
|
||||
def _db_connect():
|
||||
# If you really need to do another migration before all of this goes into
|
||||
# quantum, and you need to access the DB, this is what you need:
|
||||
oparser = optparse.OptionParser(version="%%prog %s"
|
||||
% version.version_string())
|
||||
create_options(oparser)
|
||||
(options, args) = config.parse_options(oparser)
|
||||
conf, app = config.Config.load_paste_app('melange', options, args)
|
||||
db_api.configure_db(conf, ipv4.plugin(), mac.plugin())
|
||||
|
||||
|
||||
def create_options(parser):
|
||||
"""Sets up the CLI and config-file options.
|
||||
:param parser: The option parser
|
||||
:returns: None
|
||||
"""
|
||||
parser.add_option('-p', '--port', dest="port", metavar="PORT",
|
||||
type=int, default=9898,
|
||||
help="Port the Melange API host listens on. "
|
||||
"Default: %default")
|
||||
config.add_common_options(parser)
|
||||
config.add_log_options(parser)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import gettext
|
||||
import optparse
|
||||
|
Loading…
Reference in New Issue
Block a user