billingstack/tools/resync_storage.py
Endre Karlson 82c0a77f1d Make it resync and remove import_opts
Change-Id: If40c429e80e0308e61c38d1aa2abfaba5d20dba6
2013-06-25 23:46:10 +02:00

39 lines
979 B
Python

#!/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 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)
services = cfg.CONF.services
for svc in services:
LOG.info("Doing storage for %s" % svc)
resync_service_storage(svc, resync=cfg.CONF.resync)