Permalink
Browse files

Add support for specifying and scaling on domain sensors.

The UI needs some love still.
  • Loading branch information...
oldpatricka committed Feb 8, 2013
1 parent 787b666 commit 1fc6be59237e04e14a890504ae66b92eb4f187c7
@@ -6,6 +6,10 @@
padding: 0;
}
+#details-nav {
+ border-bottom: 1px solid #e3e3e3;
+}
+
@media (min-width: 768px) {
.domain-well {
min-height: 400px;
@@ -209,6 +209,11 @@ function phantom_update_sensors() {
$("#phantom_domain_metric_choice").empty();
for (var i=0; i<metrics.length; i++) {
var metric = metrics[i];
+ if (metric.lastIndexOf("domain:", 0) === 0) {
+ var metric_cleaned = metric.split("domain:")[1];
+ metric = metric_cleaned;
+ }
+
var new_opt = $('<option>', {'name': metric, value: metric, text: metric});
$("#phantom_domain_metric_choice").append(new_opt);
}
@@ -343,7 +348,24 @@ function gather_domain_params_from_ui() {
var lc_name = $("#phantom_domain_lc_choice").val();
var domain_name = $("#phantom_domain_name_label").text();
var de_name = g_decision_engines_by_name[$("#phantom_domain_de_choice").val()];
- var monitor_sensors = $("input[name=hidden-tags]").val();
+ var monitor_sensors_raw = $("input[name=hidden-tags]").val();
+
+ var all_sensors = monitor_sensors_raw.split(",");
+ var monitor_sensors_array = [];
+ var monitor_domain_sensors_array = [];
+ for (var i=0; i < all_sensors.length; i++) {
+ var s = all_sensors[i];
+ if (s.lastIndexOf("domain:", 0) === 0) {
+
+ var s_cleaned = s.split("domain:")[1];
+ monitor_domain_sensors_array.push(s_cleaned);
+ }
+ else {
+ monitor_sensors_array.push(s);
+ }
+ }
+ var monitor_sensors = monitor_sensors_array.join(",");
+ var monitor_domain_sensors = monitor_domain_sensors_array.join(",");
// Multicloud attrs
var vm_count = $("#phantom_domain_size_input").val();
@@ -367,7 +389,8 @@ function gather_domain_params_from_ui() {
error_msg = "You must specify a domain name";
}
- var data = {"name": domain_name, "lc_name": lc_name, "de_name": de_name, "monitor_sensors": monitor_sensors};
+ var data = {"name": domain_name, "lc_name": lc_name, "de_name": de_name,
+ "monitor_sensors": monitor_sensors, "monitor_domain_sensors": monitor_domain_sensors};
if (de_name == "multicloud") {
if (! vm_count) {
@@ -513,6 +536,8 @@ function phantom_domain_select_domain_internal(domain_name, load_details) {
var domain_data = g_domain_data[domain_name];
$("#phantom_domain_name_label").text(domain_name);
+ $("#details-nav a[href='#vm-details-tab']").tab("show");
+
if (Object.keys(domain_data).length == 0) {
phantom_select_de(DEFAULT_DECISION_ENGINE);
$("#phantom_domain_start_buttons").show();
@@ -530,6 +555,11 @@ function phantom_domain_select_domain_internal(domain_name, load_details) {
for (var i=0; i<sensors.length; i++) {
$("#phantom_domain_sensors_input").tagsManager('pushTag', sensors[i]);
}
+
+ var domain_sensors = String(domain_data.monitor_domain_sensors).split(",");
+ for (var i=0; i<domain_sensors.length; i++) {
+ $("#phantom_domain_sensors_input").tagsManager('pushTag', "domain:" + domain_sensors[i]);
+ }
if (domain_data.de_name == "multicloud") {
$("#phantom_domain_size_input").val(domain_data.vm_size);
@@ -591,8 +621,8 @@ function phantom_domain_load_instances() {
var table_body = $("#details_table_body").empty();
- for(var i in g_domain_details) {
- var instance = g_domain_details[i];
+ for(var i in g_domain_details.instances) {
+ var instance = g_domain_details.instances[i];
var filter = $("#phantom_domain_filter_list").val();
if (filter != "All VMs") {
@@ -655,8 +685,9 @@ function get_selected_instance_id() {
function get_instance(instance_id) {
var instance = null;
- for(var i in g_domain_details) {
- var inst = g_domain_details[i];
+ for(var i in g_domain_details.instances) {
+
+ var inst = g_domain_details.instances[i];
if (inst.instance_id === instance_id) {
instance = inst;
break;
@@ -665,6 +696,44 @@ function get_instance(instance_id) {
return instance;
}
+function show_domain_details(domain_id) {
+ function make_row(key, value) {
+ return "<tr><td><strong>" + key + ":</strong></td><td>" + value + "</td></tr>";
+ }
+
+ if (domain_id === null) {
+ return;
+ }
+
+ var $table = $("#domain-table-body").empty();
+ var domain = g_domain_details_cache[domain_id];
+ if (domain === null) {
+ return;
+ }
+
+ var data = "";
+ var sensor_data = domain.domain_metrics;
+ for (var metric in sensor_data) {
+ for (var sensor_type in sensor_data[metric]) {
+ if (sensor_type === "Series") {
+ // Ignore series data because it is ugly :)
+ continue;
+ }
+
+ data += make_row(metric, sensor_data[metric][sensor_type]);
+ }
+ }
+ $table.append(data);
+
+ if ($table.children().length === 0) {
+ $("#domain-metrics").hide();
+ }
+ else {
+ $("#domain-metrics").show();
+ }
+}
+
+
function show_instance_details(instance_id) {
function make_row(key, value) {
return "<tr><td><strong>" + key + ":</strong></td><td>" + value + "</td></tr>";
@@ -717,22 +786,6 @@ function show_instance_details(instance_id) {
table.append(data);
}
-
-function sensor_data_to_string(sensor_data) {
-
- var str = "";
- for (var metric in sensor_data) {
- for (var sensor_type in sensor_data[metric]) {
- if (sensor_type === "Series") {
- // Ignore series data because it is ugly :)
- continue;
- }
- str += metric + ": " + sensor_type + ": " + sensor_data[metric][sensor_type] + " <br>";
- }
- }
- return str;
-}
-
function phantom_domain_details_internal() {
phantom_domain_details_abort();
@@ -744,6 +797,7 @@ function phantom_domain_details_internal() {
g_domain_details = g_domain_details_cache[domain_name];
phantom_domain_load_instances();
show_instance_details(g_selected_instance);
+ show_domain_details(domain_name);
}
var url = make_url("api/domain/details");
@@ -755,15 +809,16 @@ function phantom_domain_details_internal() {
var lc_name = obj.lc_name;
var vm_count = obj.domain_size;
- g_domain_details = obj.instances;
- g_domain_details_cache[domain_name] = obj.instances;
+ g_domain_details = obj;
+ g_domain_details_cache[domain_name] = obj;
$("#phantom_domain_size_input").val(vm_count);
$("#phantom_domain_lc_choice").val(lc_name);
phantom_domain_load_instances();
phantom_domain_buttons(true);
phantom_domain_details_buttons(true);
show_instance_details(g_selected_instance);
+ show_domain_details(domain_name);
phantom_start_details_timer();
}
@@ -148,44 +148,61 @@ <h5 class="phantom_area_header magic-underline">Configuration for <span id="phan
<div class="span5">
<div id="details_pane" class="well well-small domain-well">
- <div id="loading_details">
- <select name="phantom_domain_filter_list" id="phantom_domain_filter_list">
- <option>All VMs</option>
- <option>Healthy</option>
- <option>Errors</option>
- <option>RUNNING</option>
- <option>PENDING</option>
- <option>TERMINATING</option>
- <option>FAILED</option>
- </select>
- <img src="/static/images/loading0.gif" id="phantom_details_loading_image"/>
- </div>
- <div id="details_table_container">
- <table class="table table-bordered table-hover table-white" id="details_table">
- <thead>
- <tr>
- <th>Instance ID</th>
- <th>Status</th>
- </tr>
- </thead>
- <tbody id="details_table_body">
- </tbody>
- </table>
- </div>
+ <ul class="nav nav-pills" id="details-nav">
+ <li><a href="#vm-details-tab" data-toggle="pill">VM Details</a></li>
+ <li><a href="#domain-details-tab" data-toggle="pill">Domain Details</a></li>
+ </ul>
+ <div class="tab-content">
+ <div class="tab-pane" id="vm-details-tab">
+ <div id="loading_details">
+ <select name="phantom_domain_filter_list" id="phantom_domain_filter_list">
+ <option>All VMs</option>
+ <option>Healthy</option>
+ <option>Errors</option>
+ <option>RUNNING</option>
+ <option>PENDING</option>
+ <option>TERMINATING</option>
+ <option>FAILED</option>
+ </select>
+ <img src="/static/images/loading0.gif" id="phantom_details_loading_image"/>
+ </div>
+ <div id="details_table_container">
+ <table class="table table-bordered table-hover table-white" id="details_table">
+ <thead>
+ <tr>
+ <th>Instance ID</th>
+ <th>Status</th>
+ </tr>
+ </thead>
+ <tbody id="details_table_body">
+ </tbody>
+ </table>
+ </div>
- <table class="table table-condensed" id="instance_table">
- <tbody id="instance_table_body">
- </tbody>
- </table>
+ <table class="table table-condensed" id="instance_table">
+ <tbody id="instance_table_body">
+ </tbody>
+ </table>
- <div id="phantom_details_button_div" class="control-group pull-right">
- <input type="button" id="details_button_replace_vm" class="btn btn-mini" value="Replace"/>
- <input type="button" id="details_button_terminate_vm" class="btn btn-mini btn-danger" value="Terminate"/>
+ <div id="phantom_details_button_div" class="control-group pull-right">
+ <input type="button" id="details_button_replace_vm" class="btn btn-mini" value="Replace"/>
+ <input type="button" id="details_button_terminate_vm" class="btn btn-mini btn-danger" value="Terminate"/>
+ </div>
+ <div style="clear: both"></div>
+ <!-- Hack that I don't understand, but is standard practice? Makes parent div inherit height of
+ contained elements
+ -->
+ </div>
+ <div class="tab-pane" id="domain-details-tab">
+ <div id="#domain-metrics">
+ <h5 class="magic-underline">Domain Metrics</h5>
+ <table class="table table-condensed" id="domain-table">
+ <tbody id="domain-table-body">
+ </tbody>
+ </table>
+ </div>
+ </div>
</div>
- <div style="clear: both"></div>
- <!-- Hack that I don't understand, but is standard practice? Makes parent div inherit height of
- contained elements
- -->
</div>
</div>
</div>
View
@@ -170,7 +170,6 @@ def has_phantom_data(self):
def describe_domain(self, username, domain):
# TODO: this should eventually be part of the REST API
describe = self.epum.describe_domain(domain, caller=username)
- g_general_log.info("describe_domain: %s" % describe)
return describe
def get_all_groups(self):
View
@@ -98,6 +98,7 @@ def _get_all_domains_dashi(userobj):
ent['lc_name'] = engine_conf.get('dtname')
ent['metric'] = engine_conf.get('metric')
ent['monitor_sensors'] = engine_conf.get('monitor_sensors')
+ ent['monitor_domain_sensors'] = engine_conf.get('monitor_domain_sensors')
ent['sensor_cooldown'] = engine_conf.get('cooldown_period')
ent['sensor_minimum_vms'] = engine_conf.get('minimum_vms')
ent['sensor_maximum_vms'] = engine_conf.get('maximum_vms')
@@ -230,6 +231,9 @@ def _start_domain(phantom_con, domain_name, lc_name, de_name, de_params, host_li
ordered_clouds_key = 'clouds'
monitor_sensors_key = 'monitor_sensors'
monitor_sensors = de_params.get('monitor_sensors', '')
+ monitor_domain_sensors_key = 'monitor_domain_sensors'
+ monitor_domain_sensors = de_params.get('monitor_domain_sensors', '')
+ print "MONITOR DOMAIN: %s" % monitor_domain_sensors
sample_function_key = 'sample_function'
sample_function = 'Average'
# TODO: this should eventually be configurable
@@ -240,13 +244,15 @@ def _start_domain(phantom_con, domain_name, lc_name, de_name, de_params, host_li
policy_variant_tag = Tag(connection=phantom_con, key=policy_variant_key, value=policy_variant, resource_id=domain_name)
clouds_tag = Tag(connection=phantom_con, key=ordered_clouds_key, value=host_list_str, resource_id=domain_name)
monitor_sensors_tag = Tag(connection=phantom_con, key=monitor_sensors_key, value=monitor_sensors, resource_id=domain_name)
+ monitor_domain_sensors_tag = Tag(connection=phantom_con, key=monitor_domain_sensors_key, value=monitor_domain_sensors, resource_id=domain_name)
sample_function_tag = Tag(connection=phantom_con, key=sample_function_key, value=sample_function, resource_id=domain_name)
sensor_type_tag = Tag(connection=phantom_con, key=sensor_type_key, value=sensor_type, resource_id=domain_name)
tags.append(policy_tag)
tags.append(policy_variant_tag)
tags.append(clouds_tag)
tags.append(monitor_sensors_tag)
+ tags.append(monitor_domain_sensors_tag)
tags.append(sample_function_tag)
tags.append(sensor_type_tag)
@@ -624,6 +630,7 @@ def phantom_domain_start(request_params, userobj):
de_params = {}
de_params["monitor_sensors"] = request_params["monitor_sensors"];
+ de_params["monitor_domain_sensors"] = request_params["monitor_domain_sensors"];
if de_name == "sensor":
for p in sensor_params:
if p not in request_params:
@@ -822,10 +829,16 @@ def phantom_domain_details(request_params, userobj):
site_dict = _get_launch_configuration(phantom_con, lc_db_object)
# TODO: this should come from the REST interface
- metrics = userobj.describe_domain(userobj._user_dbobject.access_key, domain_name)
+ domain = userobj.describe_domain(userobj._user_dbobject.access_key, domain_name)
instance_metrics = {}
- if metrics is not None:
- for instance in metrics.get('instances', []):
+ if domain is not None:
+
+ #TODO: replace with real data
+ #domain_metrics = {'metric': {'Average': 5, 'Series': [1, 2, 3]}}
+ domain_metrics = domain.get('sensor_data')
+ print "DOMAIN: %s" % domain
+
+ for instance in domain.get('instances', []):
instance_metrics[instance.get('iaas_id')] = '', instance.get('sensor_data')
inst_list = []
@@ -870,7 +883,8 @@ def phantom_domain_details(request_params, userobj):
response_dict = {
'instances': inst_list,
'lc_name': asg.launch_config_name,
- 'domain_size': asg.desired_capacity
+ 'domain_size': asg.desired_capacity,
+ 'domain_metrics': domain_metrics
}
return response_dict

0 comments on commit 1fc6be5

Please sign in to comment.