Esempio n. 1
0
def setup():
    options = {"config_file": test_config_path()}
    conf = config.Config.load_paste_config("melangeapp", options, None)

    db_api.drop_db(conf)
    db_api.db_sync(conf)
    db_api.configure_db(conf)
Esempio n. 2
0
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 _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())
Esempio n. 4
0
    from melange.common import config
    from melange.db import db_api
    from melange.ipam import models
    from melange.db.sqlalchemy import session
    from melange.openstack.common import config as openstack_config

    oparser = optparse.OptionParser()
    openstack_config.add_common_options(oparser)
    openstack_config.add_log_options(oparser)
    (options, args) = openstack_config.parse_options(oparser)

    if len(args) < 1:
        sys.exit("Please include the connection string for the nova DB")

    try:
        conf = config.load_app_environment(optparse.OptionParser())
        db_api.configure_db(conf, ipv4.plugin(), mac.plugin())
        nova_engine = session._create_engine({'sql_connection': args[0]})
        instances = nova_engine.execute("select id,uuid from instances")
        melange_session = session.get_session()

        print "-----"
        for instance in instances:
            print "updating %(id)s with %(uuid)s" % instance
            session._ENGINE.execute("update interfaces set "
                                    "device_id='%(uuid)s' "
                                    "where device_id=%(id)s" % instance)

    except RuntimeError as error:
        sys.exit("ERROR: %s" % error)
    from melange.common import config
    from melange.db import db_api
    from melange.ipam import models
    from melange.db.sqlalchemy import session
    from melange.openstack.common import config as openstack_config

    oparser = optparse.OptionParser()
    openstack_config.add_common_options(oparser)
    openstack_config.add_log_options(oparser)
    (options, args) = openstack_config.parse_options(oparser)

    if len(args) < 1:
        sys.exit("Please include the connection string for the nova DB")

    try:
        conf = config.load_app_environment(optparse.OptionParser())
        db_api.configure_db(conf, ipv4.plugin(), mac.plugin())
        nova_engine = session._create_engine({'sql_connection': args[0]})
        instances = nova_engine.execute("select id,uuid from instances")
        melange_session = session.get_session()

        print "-----"
        for instance in instances:
            print "updating %(id)s with %(uuid)s" % instance
            session._ENGINE.execute("update interfaces set "
                                    "device_id='%(uuid)s' "
                                    "where device_id=%(id)s" % instance)

    except RuntimeError as error:
        sys.exit("ERROR: %s" % error)
Esempio n. 6
0
def _configure_db(options):
    conf = config.Config.load_paste_config("melange", options, None)
    db_api.configure_db(conf)