示例#1
0
def get_routes():
    return endpoints_webapp2.api_server([
        CatalogEndpoints,
        MachineEndpoints,
        MachineProviderEndpoints,
        config.ConfigApi,
    ])
示例#2
0
def create_application():
    ereporter2.register_formatter()

    # Zap out the ndb in-process cache by default.
    # This cache causes excessive memory usage in in handler where a lot of
    # entities are fetched in one query. When coupled with high concurrency
    # as specified via max_concurrent_requests in app.yaml, this may cause out of
    # memory errors.
    ndb.Context.default_cache_policy = staticmethod(lambda _key: False)
    ndb.Context._cache_policy = staticmethod(lambda _key: False)

    # App that serves HTML pages and old API.
    frontend = handlers_frontend.create_application(False)

    def is_enabled_callback():
        return config.settings().enable_ts_monitoring

    gae_ts_mon.initialize(frontend, is_enabled_fn=is_enabled_callback)
    # App that serves new endpoints API.
    endpoints_api = endpoints_webapp2.api_server([
        handlers_endpoints_v1.IsolateService,
        # components.config endpoints for validation and configuring of
        # luci-config service URL.
        config.ConfigApi,
    ])
    gae_ts_mon.instrument_wsgi_application(endpoints_api)

    prpc_api = webapp2.WSGIApplication(handlers_prpc.get_routes())
    return frontend, endpoints_api, prpc_api
示例#3
0
def create_endpoints_app():
    return webapp2.WSGIApplication(
        endpoints_webapp2.api_server([
            CatalogEndpoints,
            MachineEndpoints,
            MachineProviderEndpoints,
            config.ConfigApi,
        ],
                                     base_path='/_ah/api'))
示例#4
0
 def __init__(self, api_service_cls, regex=None, source_ip='127.0.0.1'):
     super(Endpoints, self).__init__()
     self._api_service_cls = api_service_cls
     kwargs = {}
     if regex:
         kwargs['regex'] = regex
     self._api_app = webtest.TestApp(
         endpoints_webapp2.api_server([self._api_service_cls], **kwargs),
         extra_environ={'REMOTE_ADDR': source_ip})
示例#5
0
def create_applications():
    ereporter2.register_formatter()

    # App that serves HTML pages and the main API.
    frontend = monitoring.wrap_webapp2_app(
        handlers_frontend.create_application(False))

    api = monitoring.wrap_webapp2_app(
        endpoints_webapp2.api_server([auth.AuthService, config.ConfigApi]))

    return frontend, api
示例#6
0
def get_routes():
    return endpoints_webapp2.api_server([
        SwarmingServerService,
        SwarmingTaskService,
        SwarmingTasksService,
        SwarmingQueuesService,
        SwarmingBotService,
        SwarmingBotsService,
        # components.config endpoints for validation and configuring of luci-config
        # service URL.
        config.ConfigApi
    ])
示例#7
0
def create_application():
    ereporter2.register_formatter()
    # Task queues must be sent to the backend.
    utils.set_task_queue_module('backend')
    template.bootstrap()

    # Zap out the ndb in-process cache by default.
    # This cache causes excessive memory usage in in handler where a lot of
    # entities are fetched in one query. When coupled with high concurrency
    # as specified via max_concurrent_requests in app.yaml, this may cause out of
    # memory errors.
    ndb.Context.default_cache_policy = staticmethod(lambda _key: False)
    ndb.Context._cache_policy = staticmethod(lambda _key: False)

    # If running on a local dev server, allow bots to connect without prior
    # groups configuration. Useful when running smoke test.
    if utils.is_local_dev_server():
        acl.bootstrap_dev_server_acls()
        pools_config.bootstrap_dev_server_acls()

    def is_enabled_callback():
        return config.settings().enable_ts_monitoring

    # App that serves HTML pages and old API.
    frontend_app = handlers_frontend.create_application(False)
    gae_ts_mon.initialize(frontend_app, is_enabled_fn=is_enabled_callback)

    endpoints_api = endpoints_webapp2.api_server([
        handlers_endpoints.SwarmingServerService,
        handlers_endpoints.SwarmingTaskService,
        handlers_endpoints.SwarmingTasksService,
        handlers_endpoints.SwarmingQueuesService,
        handlers_endpoints.SwarmingBotService,
        handlers_endpoints.SwarmingBotsService,
        # components.config endpoints for validation and configuring of luci-config
        # service URL.
        config.ConfigApi,
    ])

    prpc_api = webapp2.WSGIApplication(handlers_prpc.get_routes())

    # Local import, because it instantiates the mapreduce app.
    # This is for the Web UI.
    from mapreduce import main
    gae_ts_mon.initialize(main.APP, is_enabled_fn=is_enabled_callback)

    event_mon_metrics.initialize()
    ts_mon_metrics.initialize()
    utils.report_memory(frontend_app)
    utils.report_memory(endpoints_api)
    utils.report_memory(prpc_api)
    return frontend_app, endpoints_api, prpc_api, main.APP
示例#8
0
def create_application():
    ereporter2.register_formatter()
    utils.set_task_queue_module('backend')
    template.bootstrap()

    # If running on a local dev server, allow bots to connect without prior
    # groups configuration. Useful when running smoke test.
    if utils.is_local_dev_server():
        acl.bootstrap_dev_server_acls()

    def is_enabled_callback():
        return config.settings().enable_ts_monitoring

    # App that serves HTML pages and old API.
    frontend_app = handlers_frontend.create_application(False)
    gae_ts_mon.initialize(frontend_app, is_enabled_fn=is_enabled_callback)

    # App that contains crons and task queues.
    backend_app = handlers_backend.create_application(False)
    gae_ts_mon.initialize(backend_app, is_enabled_fn=is_enabled_callback)

    # Local import, because it instantiates the mapreduce app.
    from mapreduce import main
    gae_ts_mon.initialize(main.APP, is_enabled_fn=is_enabled_callback)

    # TODO(maruel): Remove this once there is no known client anymore.
    api = webapp2.WSGIApplication(
        endpoints_webapp2.api_server(
            [
                handlers_endpoints.SwarmingServerService,
                handlers_endpoints.SwarmingTaskService,
                handlers_endpoints.SwarmingTasksService,
                handlers_endpoints.SwarmingQueuesService,
                handlers_endpoints.SwarmingBotService,
                handlers_endpoints.SwarmingBotsService,
                # components.config endpoints for validation and configuring of luci-config
                # service URL.
                config.ConfigApi,
            ],
            base_path='/_ah/api'))

    event_mon_metrics.initialize()
    ts_mon_metrics.initialize()
    return frontend_app, api, backend_app, main.APP
示例#9
0
def create_application():
    ereporter2.register_formatter()

    # App that serves HTML pages and old API.
    frontend = handlers_frontend.create_application(False)

    def is_enabled_callback():
        return config.settings().enable_ts_monitoring

    gae_ts_mon.initialize(frontend, is_enabled_fn=is_enabled_callback)
    # App that serves new endpoints API.
    api = webapp2.WSGIApplication(
        endpoints_webapp2.api_server(
            [
                handlers_endpoints_v1.IsolateService,
                # components.config endpoints for validation and configuring of
                # luci-config service URL.
                config.ConfigApi,
            ],
            base_path='/_ah/api'))
    return frontend, api
示例#10
0
def create_endpoints_app():
    return webapp2.WSGIApplication(
        endpoints_webapp2.api_server([config.ConfigApi], base_path='/_ah/api'))
示例#11
0
def get_routes():
    return endpoints_webapp2.api_server([CrRevApi])
示例#12
0
        except committers.AuthorizationError as e:
            # Technically should be 403, but use 404 to avoid exposing list names.
            logging.warning('Request not authorized: %s', e.message)
            self.abort(404)
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write('\n'.join(sorted(l.emails)))


class UpdateHandler(webapp2.RequestHandler):
    @hmac_util.CheckHmacAuth
    @auth_util.RequireAuth
    def post(self, list_name):
        """Updates the list of committers from the POST data recieved."""
        user = auth_util.User.from_request(self.request)
        email_json = base64.b64decode(self.request.get('committers'))
        emails = json.loads(email_json)

        # Throws committers.AuthorizationError if not HMAC authenticated, but we
        # require that via the decorator.
        committers.put_list(user, list_name, emails)


app = webapp2.WSGIApplication([
    ('/', MainPageHandler),
    ('/lists/([a-zA-Z0-9.@_-]+)', ListHandler),
    ('/update/([a-zA-Z0-9.@_-]+)', UpdateHandler),
],
                              debug=True)

ep_server = endpoints_webapp2.api_server([ep_api.CommittersApi])
示例#13
0
def get_routes():
    return endpoints_webapp2.api_server([
        config.ConfigApi,
        IsolateService,
    ])
示例#14
0
    ('/_ah/push-handlers/swarming',
     swarming_pubsub_pipeline_callback.SwarmingPubSubPipelineCallback),
    ('/_ah/push-handlers/tryjob',
     try_job_pubsub_pipeline_callback.TryJobPubSubPipelineCallback),
    ('/', home.Home),
    # Keep this as the last one for URL redirection if there is no matching
    # above and no matching in the dispatch.yaml for old urls.
    (r'/.*', url_redirect.URLRedirect),
]
default_web_application = webapp2.WSGIApplication(
    default_web_pages_handler_mappings, debug=False)
if appengine_util.IsInProductionApp():
  gae_ts_mon.initialize(default_web_application)

# Cloud Endpoint apis in the default module.
api_application = endpoints_webapp2.api_server([FindItApi])
if appengine_util.IsInProductionApp():
  gae_ts_mon.initialize(api_application)

# App Engine pipeline status pages in the default module.
# TODO(stgao): Move this to frontend module.
pipeline_status_handler_mappings = [
    ('/_ah/pipeline/rpc/tree', pipeline_status_ui._TreeStatusHandler),
    ('/_ah/pipeline/rpc/class_paths', pipeline_status_ui._ClassPathListHandler),
    ('/_ah/pipeline/rpc/list', pipeline_status_ui._RootListHandler),
    ('/_ah/pipeline(/.+)', pipeline_status_ui._StatusUiHandler),
]
pipeline_status_application = webapp2.WSGIApplication(
    pipeline_status_handler_mappings, debug=False)
if appengine_util.IsInProductionApp():
  gae_ts_mon.initialize(pipeline_status_application)
示例#15
0
        if filestat.is_dir:
          continue
        # Skip the old, consolidated data file (which should be deleted at some
        # point).
        if filestat.filename == '/'.join([object_path, ENTITY_KEY]):
          continue
        data_file = {'file_name': filestat.filename.split('/')[-1]}
        with gcs.open(filestat.filename) as f:
          data_file['file_content'] = f.read().decode('utf-8')
        data_files.append(data_file)
      if data_files:
        return BugdroidData(data_files=json.dumps(data_files))
      else:
        raise endpoints.NotFoundException()
    else:
      raise endpoints.NotFoundException()

  @endpoints.method(
      DATA_UPDATE_REQUEST_RESOURCE_CONTAINER,
      message_types.VoidMessage,
      path='data',
      http_method='POST',
      name='data.update')
  def data_update(self, _):
    return endpoints.InternalServerErrorException(
        'Bulk bugdroid data POST is obsolete due to excessive data size. '
        'See also crbug.com/880103.')


endpoint_list = endpoints_webapp2.api_server([BugdroidApi])
示例#16
0
def get_routes():
    return endpoints_webapp2.api_server([config.ConfigApi])
示例#17
0
def create_endpoints_app():  # pragma: no cover
    """Returns WSGI app that serves cloud endpoints requests."""
    # The default regex doesn't allow / but config_sets and paths have / in them.
    return endpoints_webapp2.api_server([api.ConfigApi, admin.AdminApi],
                                        regex='.+')
示例#18
0
"""Main program for Monorail.

Monorail is an issue tracking tool that is based on the code.google.com
issue tracker, but it has been ported to Google AppEngine and Google Cloud SQL.
"""
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import

import logging
import webapp2

from components import endpoints_webapp2

import gae_ts_mon

import registerpages
from framework import sorting
from services import api_svc_v1
from services import service_manager

services = service_manager.set_up_services()
sorting.InitializeArtValues(services)
registry = registerpages.ServletRegistry()
app_routes = registry.Register(services)
app = webapp2.WSGIApplication(app_routes, config={'services': services})
gae_ts_mon.initialize(app)

endpoints = endpoints_webapp2.api_server(
    [api_svc_v1.MonorailApi, api_svc_v1.ClientConfigApi])
示例#19
0
package = 'testing_api'


class WhoResponse(messages.Message):
    identity = messages.StringField(1)
    ip = messages.StringField(2)


@auth.endpoints_api(name='testing_service', version='v1')
class TestingServiceApi(remote.Service):
    @auth.endpoints_method(message_types.VoidMessage,
                           WhoResponse,
                           name='who',
                           http_method='GET')
    @auth.public
    def who(self, _request):
        return WhoResponse(identity=auth.get_current_identity().to_bytes(),
                           ip=auth.ip_to_string(auth.get_peer_ip()))

    @auth.endpoints_method(message_types.VoidMessage,
                           message_types.VoidMessage,
                           name='forbidden',
                           http_method='GET')
    @auth.require(lambda: False)
    def forbidden(self, _request):
        pass


app = endpoints_webapp2.api_server([TestingServiceApi])