Пример #1
0
def main():
    CONF(sys.argv[1:], project='oslo')
    logging.setup("oslo")

    with contextlib.closing(impl_zmq.ZmqProxy(CONF)) as reactor:
        reactor.consume_in_thread()
        reactor.wait()
Пример #2
0
def main():
    add_common_opts()
    CONF(project='libra', version=__version__)

    logging.setup('libra')

    LOG.debug('Configuration:')
    CONF.log_opt_values(LOG, std_logging.DEBUG)

    server = Server()

    if not CONF['daemon']:
        server.main()
    else:
        pidfile = daemon.pidfile.TimeoutPIDLockFile(CONF['mgm']['pid'], 10)
        if daemon.runner.is_pidfile_stale(pidfile):
            pidfile.break_lock()

        descriptors = get_descriptors()
        context = daemon.DaemonContext(
            working_directory='/',
            umask=0o022,
            pidfile=pidfile,
            files_preserve=descriptors
        )
        if CONF['user']:
            context.uid = pwd.getpwnam(CONF['user']).pw_uid
        if CONF['group']:
            context.gid = grp.getgrnam(CONF['group']).gr_gid

        context.open()
        server.main()

    return 0
Пример #3
0
def main():
    CONF(sys.argv[1:], project='oslo')
    logging.setup("oslo")

    with contextlib.closing(impl_zmq.ZmqProxy(CONF)) as reactor:
        reactor.consume_in_thread()
        reactor.wait()
Пример #4
0
def main():
    add_common_opts()
    CONF(project='libra', version=__version__)

    logging.setup('libra')

    LOG.debug('Configuration:')
    CONF.log_opt_values(LOG, std_logging.DEBUG)

    server = Server()

    if not CONF['daemon']:
        server.main()
    else:
        pidfile = daemon.pidfile.TimeoutPIDLockFile(CONF['mgm']['pid'], 10)
        if daemon.runner.is_pidfile_stale(pidfile):
            pidfile.break_lock()

        descriptors = get_descriptors()
        context = daemon.DaemonContext(working_directory='/',
                                       umask=0o022,
                                       pidfile=pidfile,
                                       files_preserve=descriptors)
        if CONF['user']:
            context.uid = pwd.getpwnam(CONF['user']).pw_uid
        if CONF['group']:
            context.gid = grp.getgrnam(CONF['group']).gr_gid

        context.open()
        server.main()

    return 0
Пример #5
0
def main():
    add_common_opts()
    CONF(project='libra', version=__version__)

    logging.setup('libra')

    LOG.debug('Configuration:')
    CONF.log_opt_values(LOG, std_logging.DEBUG)

    drivers = []

    pc = get_pecan_config()

    sock = server.make_socket(CONF['admin_api']['host'],
                              CONF['admin_api']['port'],
                              CONF['admin_api']['ssl_keyfile'],
                              CONF['admin_api']['ssl_certfile'])

    if CONF['daemon']:
        pidfile = daemon.pidfile.TimeoutPIDLockFile(CONF['admin_api']['pid'],
                                                    10)
        if daemon.runner.is_pidfile_stale(pidfile):
            pidfile.break_lock()

        descriptors = get_descriptors()
        descriptors.append(sock.fileno())
        context = daemon.DaemonContext(
            working_directory='/',
            umask=0o022,
            pidfile=pidfile,
            files_preserve=descriptors
        )
        if CONF['user']:
            context.uid = pwd.getpwnam(CONF['user']).pw_uid
        if CONF['group']:
            context.gid = grp.getgrnam(CONF['group']).gr_gid
        context.open()

    try:
        check_gearman_ssl_files()
    except Exception as e:
        LOG.critical(str(e))
        return

    # Use the root logger due to lots of services using logger
    LOG.info('Starting on %s:%d', CONF.admin_api.host, CONF.admin_api.port)
    api = setup_app(pc)

    for driver in CONF['admin_api']['stats_driver']:
        drivers.append(importutils.import_class(known_drivers[driver]))

    MaintThreads(drivers)
    sys.stderr = LogStdout()

    wsgi.server(sock, api, keepalive=False)

    return 0
Пример #6
0
def main():
    add_common_opts()
    CONF(project='libra', version=__version__)

    logging.setup('libra')

    LOG.debug('Configuration:')
    CONF.log_opt_values(LOG, std_logging.DEBUG)

    drivers = []

    pc = get_pecan_config()

    sock = server.make_socket(CONF['admin_api']['host'],
                              CONF['admin_api']['port'],
                              CONF['admin_api']['ssl_keyfile'],
                              CONF['admin_api']['ssl_certfile'])

    if CONF['daemon']:
        pidfile = daemon.pidfile.TimeoutPIDLockFile(CONF['admin_api']['pid'],
                                                    10)
        if daemon.runner.is_pidfile_stale(pidfile):
            pidfile.break_lock()

        descriptors = get_descriptors()
        descriptors.append(sock.fileno())
        context = daemon.DaemonContext(working_directory='/',
                                       umask=0o022,
                                       pidfile=pidfile,
                                       files_preserve=descriptors)
        if CONF['user']:
            context.uid = pwd.getpwnam(CONF['user']).pw_uid
        if CONF['group']:
            context.gid = grp.getgrnam(CONF['group']).gr_gid
        context.open()

    try:
        check_gearman_ssl_files()
    except Exception as e:
        LOG.critical(str(e))
        return

    # Use the root logger due to lots of services using logger
    LOG.info('Starting on %s:%d', CONF.admin_api.host, CONF.admin_api.port)
    api = setup_app(pc)

    for driver in CONF['admin_api']['stats_driver']:
        drivers.append(importutils.import_class(known_drivers[driver]))

    MaintThreads(drivers)
    sys.stderr = LogStdout()

    wsgi.server(sock, api, keepalive=False)

    return 0
Пример #7
0
def main():
    add_common_opts()
    CONF(project='libra', version=__version__)

    logging.setup('libra')

    LOG.debug('Configuration:')
    CONF.log_opt_values(LOG, std_logging.DEBUG)

    pc = get_pecan_config()

    # NOTE: Let's not force anyone to actually have to use SSL, it shouldn't be
    # up to us to decide.
    sock = server.make_socket(CONF['api']['host'],
                              CONF['api']['port'],
                              CONF['api']['ssl_keyfile'],
                              CONF['api']['ssl_certfile'])

    if CONF['daemon']:
        pidfile = daemon.pidfile.TimeoutPIDLockFile(CONF['api']['pid'], 10)
        if daemon.runner.is_pidfile_stale(pidfile):
            pidfile.break_lock()

        descriptors = get_descriptors()
        descriptors.append(sock.fileno())

        context = daemon.DaemonContext(
            working_directory='/',
            umask=0o022,
            pidfile=pidfile,
            files_preserve=descriptors
        )
        if CONF['user']:
            context.uid = pwd.getpwnam(CONF['user']).pw_uid
        if CONF['group']:
            context.gid = grp.getgrnam(CONF['group']).gr_gid
        context.open()

    try:
        check_gearman_ssl_files()
    except Exception as e:
        LOG.critical(str(e))
        return

    LOG.info('Starting on %s:%d', CONF.api.host, CONF.api.port)
    api = setup_app(pc)
    sys.stderr = LogStdout()

    wsgi.server(sock, api, keepalive=False, debug=CONF['debug'])

    return 0
Пример #8
0
def main():
    CONF(project='mnbtest', version=__version__)
    logging.setup('mnbtest')
    LOG.debug('Configuration:')

    print "Starting Test"
    print "LOG FILE = {0}".format(CONF.log_file)
    LOG.info('STARTING MNBTEST')
    CONF.log_opt_values(LOG, std_logging.DEBUG)

    LOG.info("Calling update_mnb with {0} messages".format(CONF.testcount))
    update_mnb('lbaas.instance.test', CONF.testcount, 456)

    time.sleep(30)
Пример #9
0
def main():
    CONF(project="mnbtest", version=__version__)
    logging.setup("mnbtest")
    LOG.debug("Configuration:")

    print "Starting Test"
    print "LOG FILE = {0}".format(CONF.log_file)
    LOG.info("STARTING MNBTEST")
    CONF.log_opt_values(LOG, std_logging.DEBUG)

    LOG.info("Calling update_mnb with {0} messages".format(CONF.testcount))
    update_mnb("lbaas.instance.test", CONF.testcount, 456)

    time.sleep(30)
Пример #10
0
def main():
    add_common_opts()
    CONF(project='libra', version=__version__)

    logging.setup('libra')

    LOG.debug('Configuration:')
    CONF.log_opt_values(LOG, std_logging.DEBUG)

    pc = get_pecan_config()

    # NOTE: Let's not force anyone to actually have to use SSL, it shouldn't be
    # up to us to decide.
    sock = server.make_socket(CONF['api']['host'], CONF['api']['port'],
                              CONF['api']['ssl_keyfile'],
                              CONF['api']['ssl_certfile'])

    if CONF['daemon']:
        pidfile = daemon.pidfile.TimeoutPIDLockFile(CONF['api']['pid'], 10)
        if daemon.runner.is_pidfile_stale(pidfile):
            pidfile.break_lock()

        descriptors = get_descriptors()
        descriptors.append(sock.fileno())

        context = daemon.DaemonContext(working_directory='/',
                                       umask=0o022,
                                       pidfile=pidfile,
                                       files_preserve=descriptors)
        if CONF['user']:
            context.uid = pwd.getpwnam(CONF['user']).pw_uid
        if CONF['group']:
            context.gid = grp.getgrnam(CONF['group']).gr_gid
        context.open()

    try:
        check_gearman_ssl_files()
    except Exception as e:
        LOG.critical(str(e))
        return

    LOG.info('Starting on %s:%d', CONF.api.host, CONF.api.port)
    api = setup_app(pc)
    sys.stderr = LogStdout()

    wsgi.server(sock, api, keepalive=False, debug=CONF['debug'])

    return 0
Пример #11
0
def main():
    """ Main Python entry point for the worker utility. """

    add_common_opts()
    CONF(project='libra', version=__version__)

    logging.setup('libra')

    LOG.debug('Configuration:')
    CONF.log_opt_values(LOG, std_logging.DEBUG)

    # Import the device driver we are going to use. This will be sent
    # along to the Gearman task that will use it to communicate with
    # the device.

    selected_driver = CONF['worker']['driver']
    driver_class = importutils.import_class(known_drivers[selected_driver])

    if selected_driver == 'haproxy':
        if CONF['user']:
            user = CONF['user']
        else:
            user = getpass.getuser()

        if CONF['group']:
            group = CONF['group']
        else:
            group = None

        haproxy_service = CONF['worker:haproxy']['service']
        haproxy_logfile = CONF['worker:haproxy']['logfile']
        driver = driver_class(haproxy_services[haproxy_service],
                              user,
                              group,
                              haproxy_logfile=haproxy_logfile)
    else:
        driver = driver_class()

    server = EventServer()

    # Tasks to execute in parallel
    task_list = [(config_thread, (driver, ))]

    if not CONF['daemon']:
        server.main(task_list)
    else:

        pidfile = daemon.pidfile.TimeoutPIDLockFile(CONF['worker']['pid'], 10)
        if daemon.runner.is_pidfile_stale(pidfile):
            pidfile.break_lock()
        descriptors = get_descriptors()
        context = daemon.DaemonContext(working_directory='/etc/haproxy',
                                       umask=0o022,
                                       pidfile=pidfile,
                                       files_preserve=descriptors)
        if CONF['user']:
            context.uid = pwd.getpwnam(CONF['user']).pw_uid
        if CONF['group']:
            context.gid = grp.getgrnam(CONF['group']).gr_gid

        context.open()
        server.main(task_list)

    return 0
Пример #12
0
from libra.openstack.common.notifier import test_notifier


options.CONF.set_override('use_stderr', False)

# NOTE: Tests fail due to diverse options being required.
options.CONF.import_group('api', 'libra.api')
options.CONF.import_group('mgm', 'libra.mgm')

# Used for notification testing.
options.CONF.import_opt('rpc_backend', 'libra.openstack.common.rpc')
options.CONF.import_opt(
    'notification_driver',
    'libra.openstack.common.notifier.api')

log.setup('libra')

_DB_CACHE = None


class NotifierFixture(fixtures.Fixture):
    def tearDown(self):
        self.clear()

    def get(self):
        return test_notifier.NOTIFICATIONS

    def clear(self):
        test_notifier.NOTIFICATIONS = []

Пример #13
0
def main():
    """ Main Python entry point for the worker utility. """

    add_common_opts()
    CONF(project='libra', version=__version__)

    logging.setup('libra')

    LOG.debug('Configuration:')
    CONF.log_opt_values(LOG, std_logging.DEBUG)

    # Import the device driver we are going to use. This will be sent
    # along to the Gearman task that will use it to communicate with
    # the device.

    selected_driver = CONF['worker']['driver']
    driver_class = importutils.import_class(known_drivers[selected_driver])

    if selected_driver == 'haproxy':
        if CONF['user']:
            user = CONF['user']
        else:
            user = getpass.getuser()

        if CONF['group']:
            group = CONF['group']
        else:
            group = None

        haproxy_service = CONF['worker:haproxy']['service']
        haproxy_logfile = CONF['worker:haproxy']['logfile']
        driver = driver_class(haproxy_services[haproxy_service],
                              user, group,
                              haproxy_logfile=haproxy_logfile)
    else:
        driver = driver_class()

    server = EventServer()

    # Tasks to execute in parallel
    task_list = [
        (config_thread, (driver,))
    ]

    if not CONF['daemon']:
        server.main(task_list)
    else:

        pidfile = daemon.pidfile.TimeoutPIDLockFile(CONF['worker']['pid'], 10)
        if daemon.runner.is_pidfile_stale(pidfile):
            pidfile.break_lock()
        descriptors = get_descriptors()
        context = daemon.DaemonContext(
            working_directory='/etc/haproxy',
            umask=0o022,
            pidfile=pidfile,
            files_preserve=descriptors
        )
        if CONF['user']:
            context.uid = pwd.getpwnam(CONF['user']).pw_uid
        if CONF['group']:
            context.gid = grp.getgrnam(CONF['group']).gr_gid

        context.open()
        server.main(task_list)

    return 0
Пример #14
0
from libra.openstack.common.fixture import config
from libra.openstack.common.fixture import moxstubout
from libra.openstack.common.notifier import test_notifier

options.CONF.set_override('use_stderr', False)

# NOTE: Tests fail due to diverse options being required.
options.CONF.import_group('api', 'libra.api')
options.CONF.import_group('mgm', 'libra.mgm')

# Used for notification testing.
options.CONF.import_opt('rpc_backend', 'libra.openstack.common.rpc')
options.CONF.import_opt('notification_driver',
                        'libra.openstack.common.notifier.api')

log.setup('libra')

_DB_CACHE = None


class NotifierFixture(fixtures.Fixture):
    def tearDown(self):
        self.clear()

    def get(self):
        return test_notifier.NOTIFICATIONS

    def clear(self):
        test_notifier.NOTIFICATIONS = []