ops: make ping view return orderedDict, and make the platform-id expose variables
This commit is contained in:
parent
a664610f98
commit
ca160683bf
2 changed files with 11 additions and 9 deletions
|
|
@ -27,6 +27,7 @@ from pyramid.httpexceptions import HTTPFound
|
|||
from rhodecode.apps._base import BaseAppView
|
||||
from rhodecode.lib import helpers as h
|
||||
from rhodecode.lib.auth import LoginRequired
|
||||
from rhodecode.lib.compat import OrderedDict
|
||||
from rhodecode.model.db import UserApiKeys
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
@ -41,18 +42,17 @@ class OpsView(BaseAppView):
|
|||
return c
|
||||
|
||||
def ops_ping(self):
|
||||
data = {
|
||||
'instance': self.request.registry.settings.get('instance_id'),
|
||||
}
|
||||
data = OrderedDict()
|
||||
data['instance'] = self.request.registry.settings.get('instance_id')
|
||||
|
||||
if getattr(self.request, 'user'):
|
||||
caller_name = 'anonymous'
|
||||
if self.request.user.user_id:
|
||||
caller_name = self.request.user.username
|
||||
|
||||
data.update({
|
||||
'caller_ip': self.request.user.ip_addr,
|
||||
'caller_name': caller_name,
|
||||
})
|
||||
data['caller_ip'] = self.request.user.ip_addr
|
||||
data['caller_name'] = caller_name
|
||||
|
||||
return {'ok': data}
|
||||
|
||||
def ops_error_test(self):
|
||||
|
|
@ -94,4 +94,3 @@ class OpsView(BaseAppView):
|
|||
}
|
||||
|
||||
return {'healthcheck': health_spec}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,10 @@ def set_instance_id(config):
|
|||
if instance_id.startswith('*') or not instance_id:
|
||||
prefix = instance_id.lstrip('*')
|
||||
_platform_id = platform.uname()[1] or 'instance'
|
||||
config['instance_id'] = '%s%s-%s' % (prefix, _platform_id, os.getpid())
|
||||
config['instance_id'] = '{prefix}uname:{platform}-pid:{pid}'.format(
|
||||
prefix=prefix,
|
||||
platform=_platform_id,
|
||||
pid=os.getpid())
|
||||
|
||||
|
||||
def get_default_user_id():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue