Consolidate resync scripts
Change-Id: I4a0dac648259cd1b29344f6e2fc46e5b98e0240f
This commit is contained in:
parent
048712430d
commit
688bce2924
|
@ -1,32 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from billingstack.openstack.common import log as logging
|
||||
|
||||
from billingstack import service
|
||||
from billingstack.biller.storage import get_connection
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
cfg.CONF.import_opt('storage_driver', 'billingstack.biller.storage',
|
||||
group='service:biller')
|
||||
|
||||
cfg.CONF.import_opt('state_path', 'billingstack.paths')
|
||||
|
||||
cfg.CONF.import_opt('database_connection',
|
||||
'billingstack.biller.storage.impl_sqlalchemy',
|
||||
group='biller:sqlalchemy')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
service.prepare_service(sys.argv)
|
||||
connection = get_connection()
|
||||
|
||||
LOG.info("Re-Syncing database")
|
||||
connection.teardown_schema()
|
||||
connection.setup_schema()
|
|
@ -1,33 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from billingstack.openstack.common import log as logging
|
||||
|
||||
from billingstack import service
|
||||
from billingstack.central.storage import get_connection
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
cfg.CONF.import_opt('storage_driver', 'billingstack.central',
|
||||
group='service:central')
|
||||
|
||||
|
||||
cfg.CONF.import_opt('state_path', 'billingstack.paths')
|
||||
|
||||
|
||||
cfg.CONF.import_opt('database_connection',
|
||||
'billingstack.central.storage.impl_sqlalchemy',
|
||||
group='central:sqlalchemy')
|
||||
|
||||
if __name__ == '__main__':
|
||||
service.prepare_service(sys.argv)
|
||||
conn = get_connection()
|
||||
|
||||
LOG.info("Re-Syncing database")
|
||||
conn.teardown_schema()
|
||||
conn.setup_schema()
|
|
@ -1,32 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from billingstack.openstack.common import log as logging
|
||||
|
||||
from billingstack import service
|
||||
from billingstack.rater.storage import get_connection
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
cfg.CONF.import_opt('storage_driver', 'billingstack.rater.storage',
|
||||
group='service:rater')
|
||||
|
||||
cfg.CONF.import_opt('state_path', 'billingstack.paths')
|
||||
|
||||
cfg.CONF.import_opt('database_connection',
|
||||
'billingstack.rater.storage.impl_sqlalchemy',
|
||||
group='rater:sqlalchemy')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
service.prepare_service(sys.argv)
|
||||
connection = get_connection()
|
||||
|
||||
LOG.info("Re-Syncing database")
|
||||
connection.teardown_schema()
|
||||
connection.setup_schema()
|
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from billingstack.openstack.common import log as logging
|
||||
from billingstack import service
|
||||
from billingstack.storage.utils import get_connection
|
||||
|
||||
# NOTE: make this based on entrypoints ?
|
||||
SERVICES = ['biller', 'central', 'rater']
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
cfg.CONF.import_opt('state_path', 'billingstack.paths')
|
||||
|
||||
cfg.CONF.register_cli_opt(cfg.StrOpt('services', default=SERVICES))
|
||||
cfg.CONF.register_cli_opt(cfg.BoolOpt('resync', default=False))
|
||||
|
||||
|
||||
def import_service_opts(service):
|
||||
cfg.CONF.import_opt('storage_driver', 'billingstack.%s.storage' % service,
|
||||
group='service:%s' % service)
|
||||
cfg.CONF.import_opt('database_connection',
|
||||
'billingstack.%s.storage.impl_sqlalchemy' % service,
|
||||
group='%s:sqlalchemy' % service)
|
||||
|
||||
|
||||
def resync_service_storage(service, resync=False):
|
||||
"""
|
||||
Resync the storage for a service
|
||||
"""
|
||||
connection = get_connection(service)
|
||||
if resync:
|
||||
connection.teardown_schema()
|
||||
connection.setup_schema()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
service.prepare_service(sys.argv)
|
||||
|
||||
try:
|
||||
services = cfg.CONF.services
|
||||
for svc in services:
|
||||
import_service_opts(svc)
|
||||
except Exception:
|
||||
LOG.error('Error importing service options for %s, will exit' % svc)
|
||||
sys.exit(0)
|
||||
|
||||
for svc in services:
|
||||
LOG.info("Doing storage for %s" % svc)
|
||||
resync_service_storage(svc)
|
Loading…
Reference in New Issue