Example #1
0
    def test_monkey_patch(self):
        utils.monkey_patch()
        patron.tests.unit.monkey_patch_example.CALLED_FUNCTION = []
        from patron.tests.unit.monkey_patch_example import example_a
        from patron.tests.unit.monkey_patch_example import example_b

        self.assertEqual('Example function', example_a.example_function_a())
        exampleA = example_a.ExampleClassA()
        exampleA.example_method()
        ret_a = exampleA.example_method_add(3, 5)
        self.assertEqual(ret_a, 8)

        self.assertEqual('Example function', example_b.example_function_b())
        exampleB = example_b.ExampleClassB()
        exampleB.example_method()
        ret_b = exampleB.example_method_add(3, 5)

        self.assertEqual(ret_b, 8)
        package_a = self.example_package + 'example_a.'
        self.assertIn(package_a + 'example_function_a',
                      patron.tests.unit.monkey_patch_example.CALLED_FUNCTION)

        self.assertIn(package_a + 'ExampleClassA.example_method',
                        patron.tests.unit.monkey_patch_example.CALLED_FUNCTION)
        self.assertIn(package_a + 'ExampleClassA.example_method_add',
                        patron.tests.unit.monkey_patch_example.CALLED_FUNCTION)
        package_b = self.example_package + 'example_b.'
        self.assertNotIn(package_b + 'example_function_b',
                         patron.tests.unit.monkey_patch_example.CALLED_FUNCTION)
        self.assertNotIn(package_b + 'ExampleClassB.example_method',
                         patron.tests.unit.monkey_patch_example.CALLED_FUNCTION)
        self.assertNotIn(package_b + 'ExampleClassB.example_method_add',
                         patron.tests.unit.monkey_patch_example.CALLED_FUNCTION)
Example #2
0
def main():
    config.parse_args(sys.argv)
    logging.setup(config.CONF, "patron")
    utils.monkey_patch()

    gmr.TextGuruMeditation.setup_autorun(version)

    server = s3server.get_wsgi_server()
    service.serve(server)
    service.wait()
Example #3
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "patron")
    utils.monkey_patch()

    gmr.TextGuruMeditation.setup_autorun(version)

    server = service.Service.create(binary='patron-cert', topic=CONF.cert_topic)
    service.serve(server)
    service.wait()
Example #4
0
def main():
    config.parse_args(sys.argv)
    logging.setup(config.CONF, "patron")
    utils.monkey_patch()

    gmr.TextGuruMeditation.setup_autorun(version)

    server = s3server.get_wsgi_server()
    service.serve(server)
    service.wait()
Example #5
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "patron")
    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    server = service.Service.create(binary="patron-scheduler", topic=CONF.scheduler_topic)
    service.serve(server)
    service.wait()
Example #6
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "patron")
    utils.monkey_patch()

    gmr.TextGuruMeditation.setup_autorun(version)

    server = service.Service.create(binary='patron-cert',
                                    topic=CONF.cert_topic)
    service.serve(server)
    service.wait()
Example #7
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "patron")
    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    should_use_ssl = 'osapi_compute' in CONF.enabled_ssl_apis
    server = service.WSGIService('osapi_compute', use_ssl=should_use_ssl)
    service.serve(server, workers=server.workers)
    service.wait()
Example #8
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "patron")
    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    should_use_ssl = "osapi_compute" in CONF.enabled_ssl_apis
    server = service.WSGIService("osapi_compute", use_ssl=should_use_ssl)
    service.serve(server, workers=server.workers)
    service.wait()
Example #9
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "patron")
    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    server = service.Service.create(binary='patron-scheduler',
                                    topic=CONF.scheduler_topic)
    service.serve(server)
    service.wait()
Example #10
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, 'patron')
    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    server = service.Service.create(binary='patron-cells',
                                    topic=CONF.cells.topic,
                                    manager=CONF.cells.manager)
    service.serve(server)
    service.wait()
Example #11
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, 'patron')
    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    server = service.Service.create(binary='patron-cells',
                                    topic=CONF.cells.topic,
                                    manager=CONF.cells.manager)
    service.serve(server)
    service.wait()
Example #12
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "patron")
    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    server = service.Service.create(binary='patron-conductor',
                                    topic=CONF.conductor.topic,
                                    manager=CONF.conductor.manager)
    workers = CONF.conductor.workers or processutils.get_worker_count()
    service.serve(server, workers=workers)
    service.wait()
Example #13
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "patron")
    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    server = service.Service.create(binary='patron-verify',
                                    topic=CONF.verify.topic,
                                    manager=CONF.verify.manager)
    workers = CONF.verify.workers or processutils.get_worker_count()
    service.serve(server, workers=workers)
    service.wait()
Example #14
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "patron")
    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    if not CONF.conductor.use_local:
        objects_base.NovaObject.indirection_api = \
            conductor_rpcapi.ConductorAPI()

    should_use_ssl = 'metadata' in CONF.enabled_ssl_apis
    server = service.WSGIService('metadata', use_ssl=should_use_ssl)
    service.serve(server, workers=server.workers)
    service.wait()
Example #15
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "patron")
    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    if not CONF.conductor.use_local:
        block_db_access()
        objects_base.NovaObject.indirection_api = conductor_rpcapi.ConductorAPI()

    server = service.Service.create(
        binary="patron-compute", topic=CONF.compute_topic, db_allowed=CONF.conductor.use_local
    )
    service.serve(server)
    service.wait()
Example #16
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "patron")
    LOG = logging.getLogger('patron.all')
    utils.monkey_patch()
    objects.register_all()
    launcher = service.process_launcher()

    # patron-api
    for api in CONF.enabled_apis:
        try:
            should_use_ssl = api in CONF.enabled_ssl_apis
            server = service.WSGIService(api, use_ssl=should_use_ssl)
            launcher.launch_service(server, workers=server.workers or 1)
        except (Exception, SystemExit):
            LOG.exception(_LE('Failed to load %s-api'), api)

    for mod in [s3server, xvp_proxy]:
        try:
            launcher.launch_service(mod.get_wsgi_server())
        except (Exception, SystemExit):
            LOG.exception(_LE('Failed to load %s'), mod.__name__)

    for binary in ['patron-compute', 'patron-network', 'patron-scheduler',
                   'patron-cert', 'patron-conductor']:

        # FIXME(sirp): Most service configs are defined in patron/service.py, but
        # conductor has set a new precedent of storing these configs
        # patron/<service>/api.py.
        #
        # We should update the existing services to use this new approach so we
        # don't have to treat conductor differently here.
        if binary == 'patron-conductor':
            topic = CONF.conductor.topic
            manager = CONF.conductor.manager
        else:
            topic = None
            manager = None

        try:
            launcher.launch_service(service.Service.create(binary=binary,
                                                           topic=topic,
                                                          manager=manager))
        except (Exception, SystemExit):
            LOG.exception(_LE('Failed to load %s'), binary)
    launcher.wait()
Example #17
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "patron")
    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    if not CONF.conductor.use_local:
        block_db_access()
        objects_base.NovaObject.indirection_api = \
            conductor_rpcapi.ConductorAPI()

    server = service.Service.create(binary='patron-network',
                                    topic=CONF.network_topic,
                                    db_allowed=CONF.conductor.use_local)
    service.serve(server)
    service.wait()
Example #18
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "patron")
    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    launcher = service.process_launcher()
    for api in CONF.enabled_apis:
        should_use_ssl = api in CONF.enabled_ssl_apis
        if api == 'ec2':
            server = service.WSGIService(api, use_ssl=should_use_ssl,
                                         max_url_len=16384)
        else:
            server = service.WSGIService(api, use_ssl=should_use_ssl)
        launcher.launch_service(server, workers=server.workers or 1)
    launcher.wait()
Example #19
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "patron")
    LOG = logging.getLogger("patron.all")
    utils.monkey_patch()
    objects.register_all()
    launcher = service.process_launcher()

    # patron-api
    for api in CONF.enabled_apis:
        try:
            should_use_ssl = api in CONF.enabled_ssl_apis
            server = service.WSGIService(api, use_ssl=should_use_ssl)
            launcher.launch_service(server, workers=server.workers or 1)
        except (Exception, SystemExit):
            LOG.exception(_LE("Failed to load %s-api"), api)

    for mod in [s3server, xvp_proxy]:
        try:
            launcher.launch_service(mod.get_wsgi_server())
        except (Exception, SystemExit):
            LOG.exception(_LE("Failed to load %s"), mod.__name__)

    for binary in ["patron-compute", "patron-network", "patron-scheduler", "patron-cert", "patron-conductor"]:

        # FIXME(sirp): Most service configs are defined in patron/service.py, but
        # conductor has set a new precedent of storing these configs
        # patron/<service>/api.py.
        #
        # We should update the existing services to use this new approach so we
        # don't have to treat conductor differently here.
        if binary == "patron-conductor":
            topic = CONF.conductor.topic
            manager = CONF.conductor.manager
        else:
            topic = None
            manager = None

        try:
            launcher.launch_service(service.Service.create(binary=binary, topic=topic, manager=manager))
        except (Exception, SystemExit):
            LOG.exception(_LE("Failed to load %s"), binary)
    launcher.wait()
Example #20
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "patron")
    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    launcher = service.process_launcher()
    for api in CONF.enabled_apis:
        should_use_ssl = api in CONF.enabled_ssl_apis
        if api == 'ec2':
            server = service.WSGIService(api,
                                         use_ssl=should_use_ssl,
                                         max_url_len=16384)
        else:
            server = service.WSGIService(api, use_ssl=should_use_ssl)
        launcher.launch_service(server, workers=server.workers or 1)
    launcher.wait()
Example #21
0
    def test_monkey_patch(self):
        utils.monkey_patch()
        patron.tests.unit.monkey_patch_example.CALLED_FUNCTION = []
        from patron.tests.unit.monkey_patch_example import example_a
        from patron.tests.unit.monkey_patch_example import example_b

        self.assertEqual('Example function', example_a.example_function_a())
        exampleA = example_a.ExampleClassA()
        exampleA.example_method()
        ret_a = exampleA.example_method_add(3, 5)
        self.assertEqual(ret_a, 8)

        self.assertEqual('Example function', example_b.example_function_b())
        exampleB = example_b.ExampleClassB()
        exampleB.example_method()
        ret_b = exampleB.example_method_add(3, 5)

        self.assertEqual(ret_b, 8)
        package_a = self.example_package + 'example_a.'
        self.assertIn(package_a + 'example_function_a',
                      patron.tests.unit.monkey_patch_example.CALLED_FUNCTION)

        self.assertIn(package_a + 'ExampleClassA.example_method',
                      patron.tests.unit.monkey_patch_example.CALLED_FUNCTION)
        self.assertIn(package_a + 'ExampleClassA.example_method_add',
                      patron.tests.unit.monkey_patch_example.CALLED_FUNCTION)
        package_b = self.example_package + 'example_b.'
        self.assertNotIn(
            package_b + 'example_function_b',
            patron.tests.unit.monkey_patch_example.CALLED_FUNCTION)
        self.assertNotIn(
            package_b + 'ExampleClassB.example_method',
            patron.tests.unit.monkey_patch_example.CALLED_FUNCTION)
        self.assertNotIn(
            package_b + 'ExampleClassB.example_method_add',
            patron.tests.unit.monkey_patch_example.CALLED_FUNCTION)