Skip to content

Commit

Permalink
Merge pull request ceph#20043 from Rubab-Syed/configuration_setting_b…
Browse files Browse the repository at this point in the history
…rowser

mgr/dashboard: add configuration setting browser

Reviewed-by: John Spray <[email protected]>
  • Loading branch information
John Spray authored Feb 9, 2018
2 parents 30aed9f + 14bb815 commit 4e2748d
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/common/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,17 @@ void md_config_t::show_config(Formatter *f)
_show_config(NULL, f);
}

void md_config_t::config_options(Formatter *f)
{
Mutex::Locker l(lock);
f->open_array_section("options");
for (const auto& i: schema) {
const Option &opt = i.second;
opt.dump(f);
}
f->close_section();
}

void md_config_t::_show_config(std::ostream *out, Formatter *f)
{
if (out) {
Expand Down
3 changes: 3 additions & 0 deletions src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ struct md_config_t {
void show_config(std::ostream& out);
/// dump all config values to a formatter
void show_config(Formatter *f);

/// dump all config settings to a formatter
void config_options(Formatter *f);

/// obtain a diff between our config values and another md_config_t values
void diff(const md_config_t *other,
Expand Down
8 changes: 6 additions & 2 deletions src/mgr/ActivePyModules.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,13 @@ PyObject *ActivePyModules::get_python(const std::string &what)
}
});
return f.get();
} else if (what == "config") {
} else if (what.substr(0, 6) == "config") {
PyFormatter f;
g_conf->show_config(&f);
if (what == "config_options") {
g_conf->config_options(&f);
} else if (what == "config") {
g_conf->show_config(&f);
}
return f.get();
} else if (what == "mon_map") {
PyFormatter f;
Expand Down
5 changes: 4 additions & 1 deletion src/pybind/mgr/dashboard/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@
<i class="fa fa-heartbeat" rv-style="health_status | health_color"></i>
<span>Cluster health</span></a>
</li>
<li class="treeview{%if path_info.startswith(('/server', '/osd', '/monitor'))%} active{%endif%}">
<li class="treeview{%if path_info.startswith(('/server', '/osd', '/monitor','/config_options'))%} active{%endif%}">
<a href="#"><i class="fa fa-server"></i> <span>Cluster</span>
<span class="pull-right-container">
<i class="fa fa-angle-left pull-right"></i>
Expand All @@ -362,6 +362,9 @@
<li>
<a href="{{ url_prefix }}/monitors">Monitors</a>
</li>
<li>
<a href="{{ url_prefix }}/config_options">Configuration</a>
</li>
</ul>
</li>
<li class="treeview{%if path_info.startswith('/rbd')%} active{%endif%}">
Expand Down
120 changes: 120 additions & 0 deletions src/pybind/mgr/dashboard/config_options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@

{% extends "base.html" %}

{% block content %}


<script>
$(document).ready(function(){
// Pre-populated initial data at page load
var content_data = {{ content_data }};

rivets.formatters.display_arrays = function(arr) {
result = arr.join().replace(/,/g, "<br/>");
return "<div style='width:90px;word-break:break-all'>" + result + "</div>";
};

str_to_level = function(str) {
if (str == "basic")
return "0"
else if (str == "advanced")
return "1"
else if (str == "developer")
return "2"
};

apply_filters = function() {
content_data.options_list = [];
var selection = "#" + content_data.service;
$(selection).attr('selected','selected');
var level = $("#level").val();
var service = $("#service").val();
if (level == "developer" && service == "any") {
content_data.options_list = content_data.options.options;
}
for (var opt of content_data.options.options) {
if (service == "any" && str_to_level(opt.level) <= level) {
content_data.options_list.push(opt);
} else if (opt.services.includes(service) && str_to_level(opt.level) <= level) {
content_data.options_list.push(opt);
}
}

};

rivets.bind($("#content"), content_data);
apply_filters();

});
</script>

<!-- Page Header -->
<section class="content-header">
<h1 style="font-weight:bold">
Configuration Options
<div class="pull-right" style="font-size:17px">
<label>Services:</label>
<select id="service" style="color:grey" onchange="apply_filters()">
<option id="mon">mon</option>
<option id="mgr">mgr</option>
<option id="osd">osd</option>
<option id="mds">mds</option>
<option id="common">common</option>
<option id="mds_client">mds_client</option>
<option id="rgw">rgw</option>
<option id="any">any</option>
</select>
<label>Level:</label>
<select id="level" style="color:grey" onchange="apply_filters()">
<option value="0">basic</option>
<option value="1">advanced</option>
<option value="2">developer</option>
</select>
</div>
</h1>
</section>

<!-- Main content -->
<section class="content">
<div class="box" style="overflow:auto">
<div class="box-body">
<table class="table table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Long description</th>
<th>Type</th>
<th>Level</th>
<th>Default</th>
<th>Daemon default</th>
<th>Tags</th>
<th>Services</th>
<th>See_also</th>
<th>Max</th>
<th>Min</th>
</tr>
</thead>
<tbody>
<tr rv-each-opt="options_list">
<td><div style="width:120px;word-break:break-all">{opt.name}</div></td>
<td><div style="width:80px;word-break:break-all">{opt.desc}</td>
<td><div style="width:120px;word-break:break-all">{opt.long_desc}</div></td>
<td><div style="width:70px;word-break:break-all">{opt.type}<div></td>
<td>{opt.level}</td>
<td><div style="width:80px;word-break:break-all">{opt.default}<div></td>
<td><div style="width:120px;word-break:break-all">{opt.daemon_default}</div></td>
<td rv-html="opt.tags | display_arrays"</td>
<td rv-html="opt.services | display_arrays"></td>
<td rv-html="opt.see_also | display_arrays"</td>
<td>{opt.max}</td>
<td>{opt.min}</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>


{% endblock %}
22 changes: 22 additions & 0 deletions src/pybind/mgr/dashboard/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,28 @@ def servers(self):
toplevel_data=json.dumps(self._toplevel_data(), indent=2),
content_data=json.dumps(self._servers(), indent=2)
)

@cherrypy.expose
def config_options(self, service="any"):
template = env.get_template("config_options.html")
return template.render(
url_prefix = global_instance().url_prefix,
ceph_version=global_instance().version,
path_info=cherrypy.request.path_info,
toplevel_data=json.dumps(self._toplevel_data(), indent=2),
content_data=json.dumps(self.config_options_data(service), indent=2)
)

@cherrypy.expose
@cherrypy.tools.json_out()
def config_options_data(self, service):
options = {}
options = global_instance().get("config_options")

return {
'options': options,
'service': service,
}

@cherrypy.expose
def monitors(self):
Expand Down
3 changes: 2 additions & 1 deletion src/pybind/mgr/dashboard/monitors.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
<!-- Page Header -->
<section class="content-header">
<h1 style="font-weight:bold">
Monitors
Monitors
<button class="pull-right btn btn-default"><a href="{{url_prefix}}/config_options/mon">Configuration</a></button>
</h1>
</section>

Expand Down
1 change: 1 addition & 0 deletions src/pybind/mgr/dashboard/osd_perf.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
<h1>
osd.{osd.osd}
<button class="pull-right btn btn-default"><a rv-href="url_perf">Performance Counters</a></button>
<button class="pull-right btn btn-default" style="margin-right:5px"><a href="{{url_prefix}}/config_options/osd">Configuration</a></button>
</h1>
</section>

Expand Down
1 change: 1 addition & 0 deletions src/pybind/mgr/dashboard/rgw_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

<section class="content-header">
<button class="pull-right btn btn-default"><a rv-href="url_perf">Performance Counters</a></button>
<button class="pull-right btn btn-default" style="margin-right:5px"><a href="{{url_prefix}}/config_options/rgw">Configuration</a></button>
<h1 rv-text="rgw_id"></h1>
</section>

Expand Down

0 comments on commit 4e2748d

Please sign in to comment.