powervc-driver/glance-powervc/bin/glance-powervc

60 lines
2.0 KiB
Python

#!/usr/bin/env python
# Copyright 2013, 2014 IBM Corp.
"""Starter script for the PowerVC Driver ImageManager Service."""
import eventlet
import os
import socket
import sys
import traceback
eventlet.patcher.monkey_patch(os=False, socket=True, time=True)
# FIXME: Is there a way to keep multiple instances from running at the same time?
# FIXME: Haven't really looked too close at this yet. It may need more work.
# If ../powervc/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
os.pardir,
os.pardir))
if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'powervc', '__init__.py')):
sys.path.insert(0, POSSIBLE_TOPDIR)
# TODO RYKAL
# This should go in the base __init__ folder I think
from oslo import i18n
i18n.install('glance')
# NOTE: Import powervc driver common config at the very beginning to parse
# AMQP.
from powervc.common import config
from powervc.glance.common import config as glance_config
from nova.openstack.common import log
from nova.openstack.common import service
from oslo.utils import importutils
CONF = glance_config.CONF
LOG = log.getLogger(__name__)
if __name__ == '__main__':
try:
# Obtain glance opts from glance-api.conf
glance_config.parse_config(sys.argv, 'glance', 'glance-api')
log.setup('powervc')
LOG.info(_('Launching PowerVC Driver ImageManager service...'))
manager = importutils.import_object(
'powervc.glance.manager.manager.PowerVCImageManager')
launcher = service.ServiceLauncher()
launcher.launch_service(manager)
LOG.info(_('PowerVC Driver ImageManager service started'))
launcher.wait()
LOG.info(_('PowerVC Driver ImageManager service ended'))
except Exception:
traceback.print_exc()
raise