#!/usr/bin/env python # Copyright 2013, 2014 IBM Corp. """Starter script for the PowerVC cinder-volume Service.""" import os import sys import eventlet import traceback # 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) from oslo import i18n # TODO RYKAL # This should go in the base __init__ folder I think i18n.install('cinder') # NOTE: Import powervc driver common config at the very beginning to parse # AMQP. from powervc.common import config from cinder import utils from cinder.openstack.common import log as logging # Currently cinder service uses threading instead of eventlet's event, # This causes if you don't monkey patch threading, it will hang there # all the time. For detail, check this fix in incubator project: # https://github.com/openstack/oslo-incubator/commit/\ # 1e7007824374842bc8108dff5e5e2694e12932b2 # Will create a bug to cinder to fix this. Temporarily fix is to replace # cinder service instead of nova service in 1365373. """Need to patch nova logging with cinder logging, or it will throw cfg already parsed error""" import nova.openstack.common as nova_common nova_common.log = logging from nova.openstack.common import service from cinder.common import config as cinder_config # NOTE: parse config before import manager config.parse_power_config(sys.argv, 'cinder') from powervc.volume.manager import manager eventlet.patcher.monkey_patch(os=False, socket=True, time=True) logging.setup('powervc') LOG = logging.getLogger(__name__) if __name__ == '__main__': try: logging.setup('powervc') utils.monkey_patch() LOG.info(_('Launching PowerVC Driver StorageManager service...')) launcher = service.ServiceLauncher() launcher.launch_service(manager.PowerVCCinderManager()) launcher.wait() LOG.info(_('PowerVC Driver StorageManager service ended')) except Exception: traceback.print_exc() raise