def settings(req): if req.zato.get('cluster'): _settings = {} defaults = deepcopy(DEFAULT_STATS_SETTINGS) for mapping in job_mappings: response = req.zato.client.invoke( 'zato.scheduler.job.get-by-name', { 'cluster_id': req.zato.cluster.id, 'name': mapping.job_name }) if response.has_data: for attr in mapping.attrs: try: attr.job_attr['extra'] except TypeError: setting_base_name = 'scheduler_{}_interval'.format( attr.form_name) setting_unit_name = 'scheduler_{}_interval_unit'.format( attr.form_name) defaults[setting_unit_name] = attr.job_attr _settings[setting_base_name] = getattr( response.data, attr.job_attr) else: # A sample response.data.extra is, for instance, 'max_batch_size=123456' _settings['scheduler_{}'.format( attr.form_name)] = response.data.extra.split( '=')[1] for name in DEFAULT_STATS_SETTINGS: if not name.startswith('scheduler'): _settings[name] = Setting.objects.get_value( name, default=DEFAULT_STATS_SETTINGS[name]) else: defaults, _settings = None, {} return_data = { 'zato_clusters': req.zato.clusters, 'cluster_id': req.zato.cluster_id, 'choose_cluster_form': req.zato.choose_cluster_form, 'form': SettingsForm(initial=_settings), 'defaults': defaults, } return TemplateResponse(req, 'zato/stats/settings.html', return_data)
def settings(req): if req.zato.get('cluster'): return_data = { 'zato_clusters': req.zato.clusters, 'cluster_id': req.zato.cluster_id, 'search_form': req.zato.search_form, } _settings = {} defaults = deepcopy(DEFAULT_STATS_SETTINGS) for mapping in job_mappings: request = { 'cluster_id': req.zato.cluster.id, 'name': mapping.job_name } try: response = req.zato.client.invoke( 'zato.scheduler.job.get-by-name', request) except Exception: logger.warn(format_exc()) return_data['has_scheduler_jobs'] = False break if response.has_data: for attr in mapping.attrs: try: attr.job_attr['extra'] except TypeError: setting_base_name = 'scheduler_{}_interval'.format( attr.form_name) setting_unit_name = 'scheduler_{}_interval_unit'.format( attr.form_name) defaults[setting_unit_name] = attr.job_attr _settings[setting_base_name] = getattr( response.data, attr.job_attr) else: # A sample response.data.extra is, for instance, 'max_batch_size=123456' _settings['scheduler_{}'.format( attr.form_name)] = response.data.extra.split( '=')[1] # No break in the exception handler above means we were able to read in all the scheduler jobs needed else: return_data['has_scheduler_jobs'] = True for name in DEFAULT_STATS_SETTINGS: if not name.startswith('scheduler'): _settings[name] = req.zato.settings_db.get( name, default=DEFAULT_STATS_SETTINGS[name]) else: defaults, _settings = None, {} return_data['form'] = SettingsForm(initial=_settings) return_data['defaults'] = defaults return TemplateResponse(req, 'zato/stats/settings.html', return_data)
_settings['scheduler_{}'.format( attr.form_name)] = response.data.extra.split( '=')[1] # No break in the exception handler above means we were able to read in all the scheduler jobs needed else: return_data['has_scheduler_jobs'] = True for name in DEFAULT_STATS_SETTINGS: if not name.startswith('scheduler'): _settings[name] = req.zato.settings_db.get( name, default=DEFAULT_STATS_SETTINGS[name]) else: defaults, _settings = None, {} return_data['form'] = SettingsForm(initial=_settings) return_data['defaults'] = defaults return TemplateResponse(req, 'zato/stats/settings.html', return_data) @method_allowed('POST') def settings_save(req): for name in DEFAULT_STATS_SETTINGS: if not name.startswith('scheduler'): value = req.POST[name] req.zato.settings_db.set(name, value) for mapping in job_mappings: