core: added ops view to pyramid to have a PING command with pure pyramid.
This commit is contained in:
parent
e6137d85f4
commit
81cfa0f585
5 changed files with 92 additions and 0 deletions
35
rhodecode/apps/ops/__init__.py
Normal file
35
rhodecode/apps/ops/__init__.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (C) 2016-2017 RhodeCode GmbH
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License, version 3
|
||||
# (only), as published by the Free Software Foundation.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# This program is dual-licensed. If you wish to learn more about the
|
||||
# RhodeCode Enterprise Edition, including its added features, Support services,
|
||||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||
|
||||
from rhodecode.config.routing import ADMIN_PREFIX
|
||||
|
||||
|
||||
def admin_routes(config):
|
||||
config.add_route(
|
||||
name='ops_ping',
|
||||
pattern='/ping')
|
||||
|
||||
|
||||
def includeme(config):
|
||||
|
||||
config.include(admin_routes, route_prefix=ADMIN_PREFIX + '/ops')
|
||||
|
||||
# Scan module for configuration decorators.
|
||||
config.scan()
|
||||
54
rhodecode/apps/ops/views.py
Normal file
54
rhodecode/apps/ops/views.py
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (C) 2016-2017 RhodeCode GmbH
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License, version 3
|
||||
# (only), as published by the Free Software Foundation.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# This program is dual-licensed. If you wish to learn more about the
|
||||
# RhodeCode Enterprise Edition, including its added features, Support services,
|
||||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||
|
||||
import logging
|
||||
|
||||
from pyramid.view import view_config
|
||||
|
||||
from rhodecode.apps._base import BaseAppView
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class OpsView(BaseAppView):
|
||||
|
||||
def load_default_context(self):
|
||||
c = self._get_local_tmpl_context()
|
||||
c.user = c.auth_user.get_instance()
|
||||
self._register_global_c(c)
|
||||
return c
|
||||
|
||||
@view_config(
|
||||
route_name='ops_ping', request_method='GET',
|
||||
renderer='json_ext')
|
||||
def ops_ping(self):
|
||||
data = {
|
||||
'instance': self.request.registry.settings.get('instance_id'),
|
||||
}
|
||||
if getattr(self.request, 'user'):
|
||||
data.update({
|
||||
'caller_ip': self.request.user.ip_addr,
|
||||
'caller_name': self.request.user.username,
|
||||
})
|
||||
return {'ok': data}
|
||||
|
||||
|
||||
|
||||
|
|
@ -284,6 +284,7 @@ def includeme(config):
|
|||
|
||||
# apps
|
||||
config.include('rhodecode.apps._base')
|
||||
config.include('rhodecode.apps.ops')
|
||||
|
||||
config.include('rhodecode.apps.admin')
|
||||
config.include('rhodecode.apps.channelstream')
|
||||
|
|
|
|||
|
|
@ -207,6 +207,7 @@ class SettingsModel(BaseModel):
|
|||
caches.clear_cache_manager(cache_manager)
|
||||
|
||||
def get_all_settings(self, cache=False):
|
||||
|
||||
def _compute():
|
||||
q = self._get_settings_query()
|
||||
if not q:
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ function registerRCRoutes() {
|
|||
pyroutes.register('repo_integrations_new', '%(repo_name)s/settings/integrations/new', ['repo_name']);
|
||||
pyroutes.register('repo_integrations_create', '%(repo_name)s/settings/integrations/%(integration)s/new', ['repo_name', 'integration']);
|
||||
pyroutes.register('repo_integrations_edit', '%(repo_name)s/settings/integrations/%(integration)s/%(integration_id)s', ['repo_name', 'integration', 'integration_id']);
|
||||
pyroutes.register('ops_ping', '_admin/ops/ping', []);
|
||||
pyroutes.register('admin_settings_open_source', '_admin/settings/open_source', []);
|
||||
pyroutes.register('admin_settings_vcs_svn_generate_cfg', '_admin/settings/vcs/svn_generate_cfg', []);
|
||||
pyroutes.register('admin_settings_system', '_admin/settings/system', []);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue