system-settings: prepare to allow to create snapshots of full system settings

for support.
This commit is contained in:
Marcin Kuzminski 2016-06-28 02:08:54 +02:00
parent 0e916f338a
commit 9446dff948
3 changed files with 113 additions and 4 deletions

View file

@ -49,7 +49,7 @@ from rhodecode.lib.compat import OrderedDict
from rhodecode.lib.ext_json import json
from rhodecode.lib.utils import jsonify
from rhodecode.model.db import RhodeCodeUi, Repository
from rhodecode.model.db import RhodeCodeUi, Repository, User
from rhodecode.model.forms import ApplicationSettingsForm, \
ApplicationUiSettingsForm, ApplicationVisualisationForm, \
LabsSettingsForm, IssueTrackerPatternsForm
@ -60,6 +60,7 @@ from rhodecode.model.meta import Session
from rhodecode.model.settings import (
IssueTrackerSettingsModel, VcsSettingsModel, SettingNotFound,
SettingsModel)
from rhodecode.model.supervisor import SupervisorModel, SUPERVISOR_MASTER
@ -524,6 +525,7 @@ class SettingsController(BaseController):
def settings_system(self):
"""GET /admin/settings/system: All items in the collection"""
# url('admin_settings_system')
snapshot = str2bool(request.GET.get('snapshot'))
c.active = 'system'
defaults = self._form_defaults()
@ -558,6 +560,35 @@ class SettingsController(BaseController):
except TypeError:
c.system_memory = 'NOT AVAILABLE'
rhodecode_ini_safe = rhodecode.CONFIG.copy()
blacklist = [
'rhodecode_license_key',
'routes.map',
'pylons.h',
'pylons.app_globals',
'pylons.environ_config',
'sqlalchemy.db1.url',
('app_conf', 'sqlalchemy.db1.url')
]
for k in blacklist:
if isinstance(k, tuple):
section, key = k
if section in rhodecode_ini_safe:
rhodecode_ini_safe[section].pop(key, None)
else:
rhodecode_ini_safe.pop(k, None)
c.rhodecode_ini_safe = rhodecode_ini_safe
# TODO: marcink, figure out how to allow only selected users to do this
c.allowed_to_snapshot = False
if snapshot:
if c.allowed_to_snapshot:
return render('admin/settings/settings_system_snapshot.html')
else:
h.flash('You are not allowed to do this', category='warning')
return htmlfill.render(
render('admin/settings/settings.html'),
defaults=defaults,

View file

@ -45,12 +45,15 @@
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">${_('System Info')}</h3>
% if c.allowed_to_snapshot:
<a href="${url('admin_settings_system', snapshot=1)}" class="panel-edit">${_('create snapshot')}</a>
% endif
</div>
<div class="panel-body">
<dl class="dl-horizontal settings">
%for dt, dd, tt in elems:
<dt >${dt}:</dt>
<dd title="${tt}">${dd}</dd>
<dt>${dt}:</dt>
<dd title="${tt}">${dd}</dd>
%endfor
</dl>
</div>
@ -69,7 +72,7 @@
<tbody>
%for key, value in c.py_modules:
<tr>
<td >${key}</td>
<td>${key}</td>
<td>${value}</td>
</tr>
%endfor

View file

@ -0,0 +1,75 @@
<%
elems = [
## general
(_('RhodeCode Enterprise version'), c.rhodecode_version, ''),
(_('Upgrade info endpoint'), c.rhodecode_update_url, ''),
(_('Configuration INI file'), c.rhodecode_config_ini, ''),
## systems stats
(_('RhodeCode Enterprise Server IP'), c.server_ip, ''),
(_('RhodeCode Enterprise Server ID'), c.server_id, ''),
(_('Platform'), c.platform, ''),
(_('Uptime'), c.uptime_age, ''),
(_('Storage location'), c.storage, ''),
(_('Storage disk space'), "%s/%s, %s%% used%s" % (h.format_byte_size_binary(c.disk['used']), h.format_byte_size_binary(c.disk['total']),(c.disk['percent']), ' %s' % c.disk['error'] if 'error' in c.disk else ''), ''),
(_('Search index storage'), c.index_storage, ''),
(_('Search index size'), "%s %s" % (h.format_byte_size_binary(c.disk_index['used']), ' %s' % c.disk_index['error'] if 'error' in c.disk_index else ''), ''),
(_('Gist storage'), c.gist_storage, ''),
(_('Gist storage size'), "%s (%s items)%s" % (h.format_byte_size_binary(c.disk_gist['used']),c.disk_gist['items'], ' %s' % c.disk_gist['error'] if 'error' in c.disk_gist else ''), ''),
(_('Archive cache'), c.archive_storage, ''),
(_('Archive cache size'), "%s%s" % (h.format_byte_size_binary(c.disk_archive['used']), ' %s' % c.disk_archive['error'] if 'error' in c.disk_archive else ''), ''),
(_('System memory'), c.system_memory, ''),
(_('CPU'), '%s %%' %(c.cpu), ''),
(_('Load'), '1min: %s, 5min: %s, 15min: %s' %(c.load['1_min'],c.load['5_min'],c.load['15_min']), ''),
## rhodecode stuff
(_('Python version'), c.py_version, ''),
(_('Python path'), c.py_path, ''),
(_('GIT version'), c.git_version, ''),
(_('HG version'), c.hg_version, ''),
(_('SVN version'), c.svn_version, ''),
(_('Database'), "%s @ version: %s" % (c.db_type, c.db_migrate_version), ''),
(_('Database version'), c.db_version, ''),
]
%>
<pre>
SYSTEM INFO
-----------
% for dt, dd, tt in elems:
${dt}: ${dd}
% endfor
PYTHON PACKAGES
---------------
% for key, value in c.py_modules:
${key}: ${value}
% endfor
SYSTEM SETTINGS
---------------
% for key, value in sorted(c.rhodecode_ini_safe.items()):
% if isinstance(value, dict):
% for key2, value2 in value.items():
[${key}]${key2}: ${value2}
% endfor
% else:
${key}: ${value}
% endif
% endfor
</pre>