Example #1
0
def _get_current_database_heads(config):
    with DBConnection(config.neutron_config.database.connection) as conn:
        opts = {
            'version_table': get_alembic_version_table(config)
        }
        context = alembic_migration.MigrationContext.configure(
            conn, opts=opts)
        return context.get_current_heads()
Example #2
0
 def run(self):
     DBConnection(CONF.database.connection)
     tenant_id = '56418eb1bba14ab7bdf6a411663a3821'
     LOG.debug('XXX2 ensure_default_security_group tenant %s', tenant_id)
     ctx = context.get_admin_context()
     with ctx.session.begin(subtransactions=True):
         query = self._model_query(ctx, sg_models.DefaultSecurityGroup)
         f = query.filter_by(tenant_id=tenant_id)
         default_group = f.one()
         LOG.debug('XXX2 res %s', str(default_group))
         print(default_group['security_group_id'])
Example #3
0
def run_migrations_online():
    """Run migrations in 'online' mode.

    In this scenario we need to create an Engine
    and associate a connection with the context.

    """
    set_mysql_engine()
    connection = config.attributes.get('connection')
    with DBConnection(neutron_config.database.connection, connection) as conn:
        context.configure(
            connection=conn,
            target_metadata=target_metadata,
            include_object=include_object,
            process_revision_directives=autogen.process_revision_directives)
        with context.begin_transaction():
            context.run_migrations()
Example #4
0
def run_migrations_online():
    """Run migrations in 'online' mode.

    In this scenario we need to create an Engine
    and associate a connection with the context.

    """
    set_mysql_engine()
    connection = config.attributes.get('connection')
    with DBConnection(neutron_config.database.connection, connection) as conn:
        context.configure(
            connection=conn,
            target_metadata=target_metadata,
            version_table=P4_VERSION_TABLE,
        )
        with context.begin_transaction():
            context.run_migrations()