##// END OF EJS Templates
ops: make ping view return orderedDict, and make the platform-id expose variables
super-admin -
r4851:98843d15 default
parent child Browse files
Show More
@@ -27,6 +27,7 b' from pyramid.httpexceptions import HTTPF'
27 from rhodecode.apps._base import BaseAppView
27 from rhodecode.apps._base import BaseAppView
28 from rhodecode.lib import helpers as h
28 from rhodecode.lib import helpers as h
29 from rhodecode.lib.auth import LoginRequired
29 from rhodecode.lib.auth import LoginRequired
30 from rhodecode.lib.compat import OrderedDict
30 from rhodecode.model.db import UserApiKeys
31 from rhodecode.model.db import UserApiKeys
31
32
32 log = logging.getLogger(__name__)
33 log = logging.getLogger(__name__)
@@ -41,18 +42,17 b' class OpsView(BaseAppView):'
41 return c
42 return c
42
43
43 def ops_ping(self):
44 def ops_ping(self):
44 data = {
45 data = OrderedDict()
45 'instance': self.request.registry.settings.get('instance_id'),
46 data['instance'] = self.request.registry.settings.get('instance_id')
46 }
47
47 if getattr(self.request, 'user'):
48 if getattr(self.request, 'user'):
48 caller_name = 'anonymous'
49 caller_name = 'anonymous'
49 if self.request.user.user_id:
50 if self.request.user.user_id:
50 caller_name = self.request.user.username
51 caller_name = self.request.user.username
51
52
52 data.update({
53 data['caller_ip'] = self.request.user.ip_addr
53 'caller_ip': self.request.user.ip_addr,
54 data['caller_name'] = caller_name
54 'caller_name': caller_name,
55
55 })
56 return {'ok': data}
56 return {'ok': data}
57
57
58 def ops_error_test(self):
58 def ops_error_test(self):
@@ -94,4 +94,3 b' class OpsView(BaseAppView):'
94 }
94 }
95
95
96 return {'healthcheck': health_spec}
96 return {'healthcheck': health_spec}
97
@@ -89,7 +89,10 b' def set_instance_id(config):'
89 if instance_id.startswith('*') or not instance_id:
89 if instance_id.startswith('*') or not instance_id:
90 prefix = instance_id.lstrip('*')
90 prefix = instance_id.lstrip('*')
91 _platform_id = platform.uname()[1] or 'instance'
91 _platform_id = platform.uname()[1] or 'instance'
92 config['instance_id'] = '%s%s-%s' % (prefix, _platform_id, os.getpid())
92 config['instance_id'] = '{prefix}uname:{platform}-pid:{pid}'.format(
93 prefix=prefix,
94 platform=_platform_id,
95 pid=os.getpid())
93
96
94
97
95 def get_default_user_id():
98 def get_default_user_id():
General Comments 0
You need to be logged in to leave comments. Login now