def GET(self): try: url_param = [ i for i in web.ctx['path'].split('/') if i not in ['', 'api', 'config'] ] except: error_msg = "URl not Found" raise web.notfound(error_msg) result = {} if len(url_param) == 0: result[METRICS] = configurator.get_collectd_config() result[LOGGING] = configurator.get_fluentd_config() elif url_param[0] == SUPPORTED_PLUGINS: result[METRICS] = configurator.get_supported_metrics_plugins() result[LOGGING] = configurator.get_supported_logging_plugins() elif url_param[0] == SUPPORTED_TARGETS: result = configurator.get_supported_targets() elif url_param[0] == "mapping": result[METRICS] = configurator.get_collectd_plugins_mapping() result[LOGGING] = configurator.get_fluentd_plugins_mapping() result[TARGETS] = configurator.get_supported_targets_mapping() elif url_param[0] == "params": user_data = web.input(metrics_plugins="", logging_plugins="", targets="") metric_plugin_instances = [] target_instances = [] logging_plugin_instances = [] # print user_data if user_data.metrics_plugins: metric_plugin_instances = user_data.metrics_plugins.split(",") result[METRICS] = configurator.get_metrics_plugins_params( metric_plugin_instances) if user_data.targets: target_instances = user_data.targets.split(",") result[TARGETS] = configurator.get_targets_params( target_instances) if user_data.logging_plugins: logging_plugin_instances = user_data.logging_plugins.split(",") result[LOGGING] = configurator.get_logging_plugins_params( logging_plugin_instances) if not (user_data.metrics_plugins or user_data.targets or user_data.logging_plugins): result[METRICS] = configurator.get_metrics_plugins_params( metric_plugin_instances) result[LOGGING] = configurator.get_logging_plugins_params( logging_plugin_instances) result[TARGETS] = configurator.get_targets_params( target_instances) else: error_msg = "URl not Found" raise web.notfound(error_msg) return json.dumps(result)
def GET(self): try: url_param = [i for i in web.ctx['path'].split('/') if i not in ['', 'api', 'config']] except: error_msg = "URl not Found" raise web.notfound(error_msg) result = {} try: import platform if float(".".join([platform.python_version_tuple()[0], platform.python_version_tuple()[1]])) < 2.6: result["distro"] = " ".join(platform.dist()) else: result["distro"] = " ".join(platform.linux_distribution()) except: result["distro"] = None if len(url_param) == 0: result[METRICS] = configurator.get_collectd_config() result[LOGGING] = configurator.get_fluentd_config() elif url_param[0] == SUPPORTED_PLUGINS: result[METRICS] = configurator.get_supported_metrics_plugins() result[LOGGING] = configurator.get_supported_logging_plugins() elif url_param[0] == SUPPORTED_TARGETS: result = configurator.get_supported_targets() elif url_param[0] == "mapping": result[METRICS] = configurator.get_collectd_plugins_mapping() result[LOGGING] = configurator.get_fluentd_plugins_mapping() result[TARGETS] = configurator.get_supported_targets_mapping() elif url_param[0] == "params": user_data = web.input(metrics_plugins="", logging_plugins="", targets="") metric_plugin_instances = [] target_instances = [] logging_plugin_instances = [] # print user_data if user_data.metrics_plugins: metric_plugin_instances = user_data.metrics_plugins.split(",") result[METRICS] = configurator.get_metrics_plugins_params(metric_plugin_instances) if user_data.targets: target_instances = user_data.targets.split(",") result[TARGETS] = configurator.get_targets_params(target_instances) if user_data.logging_plugins: logging_plugin_instances = user_data.logging_plugins.split(",") result[LOGGING] = configurator.get_logging_plugins_params(logging_plugin_instances) if not (user_data.metrics_plugins or user_data.targets or user_data.logging_plugins): result[METRICS] = configurator.get_metrics_plugins_params(metric_plugin_instances) result[LOGGING] = configurator.get_logging_plugins_params(logging_plugin_instances) result[TARGETS] = configurator.get_targets_params(target_instances) else: error_msg = "URl not Found" raise web.notfound(error_msg) return json.dumps(result)