
from oslo.config import cfg

from gnocchi.indexer import sqlalchemy as sql_db
from gnocchi.rest import app
from gnocchi import service


def storage_dbsync():
    service.prepare_service()
    indexer = sql_db.SQLAlchemyIndexer(cfg.CONF)
    indexer.upgrade()


def api():
    service.prepare_service()
    app.build_server()


from oslo.config import cfg

from gnocchi.indexer import sqlalchemy as sql_db
from gnocchi.rest import app
from gnocchi import service


def storage_dbsync():
    service.prepare_service()
    indexer = sql_db.SQLAlchemyIndexer(cfg.CONF)
    indexer.connect()
    indexer.upgrade()


def api():
    service.prepare_service()
    app.build_server()

Connect to database before upgrading it
Connect to database before upgrading it

This change ensure we are connected to the database before
we upgrade it.

Change-Id: Ia0be33892a99897ff294d004f4d935f3753e6200

  
  from oslo.config import cfg
  
  from gnocchi.indexer import sqlalchemy as sql_db
  from gnocchi.rest import app
  from gnocchi import service
  
  
  def storage_dbsync():
      service.prepare_service()
      indexer = sql_db.SQLAlchemyIndexer(cfg.CONF)
+     indexer.connect()
      indexer.upgrade()
  
  
  def api():
      service.prepare_service()
      app.build_server()
  
Connect to database before upgrading it
## Code Before:

from oslo.config import cfg

from gnocchi.indexer import sqlalchemy as sql_db
from gnocchi.rest import app
from gnocchi import service


def storage_dbsync():
    service.prepare_service()
    indexer = sql_db.SQLAlchemyIndexer(cfg.CONF)
    indexer.upgrade()


def api():
    service.prepare_service()
    app.build_server()

## Instruction:
Connect to database before upgrading it
## Code After:

from oslo.config import cfg

from gnocchi.indexer import sqlalchemy as sql_db
from gnocchi.rest import app
from gnocchi import service


def storage_dbsync():
    service.prepare_service()
    indexer = sql_db.SQLAlchemyIndexer(cfg.CONF)
    indexer.connect()
    indexer.upgrade()


def api():
    service.prepare_service()
    app.build_server()
