Permalink
Browse files

Improve domain sensor UI

  • Loading branch information...
oldpatricka committed Feb 9, 2013
1 parent 1fc6be5 commit 7848c2a1ae9e557efe3c2740eaa33074e9da7427
@@ -16,6 +16,10 @@
}
}
+span.domain_sensor_tag {
+ background-color: #d9edf7;
+}
+
#phantom_instance_context_menu {
display: none;
}
@@ -18,6 +18,8 @@ $(document).ready(function() {
$("#nav-domains").addClass("active");
$("#phantom_domain_main_combined_pane_inner").hide();
+ $("#scaling_sensor_value").hide();
+ $("#domain-metrics").hide();
var $sensor_input = $("#phantom_domain_sensors_input").tagsManager({
typeahead: true,
@@ -114,8 +116,6 @@ $(document).ready(function() {
if (instance === null) {
return;
}
- console.log(instance_id);
- console.log(instance);
phantom_domain_instance_replace_click(instance.instance_id, instance.cloud);
return false;
@@ -209,6 +209,9 @@ function phantom_update_sensors() {
$("#phantom_domain_metric_choice").empty();
for (var i=0; i<metrics.length; i++) {
var metric = metrics[i];
+
+ $(".myTag span:contains('domain:')").parent().addClass("domain_sensor_tag");
+
if (metric.lastIndexOf("domain:", 0) === 0) {
var metric_cleaned = metric.split("domain:")[1];
metric = metric_cleaned;
@@ -553,20 +556,25 @@ function phantom_domain_select_domain_internal(domain_name, load_details) {
$("#phantom_domain_sensors_input").tagsManager('empty');
var sensors = String(domain_data.monitor_sensors).split(",");
for (var i=0; i<sensors.length; i++) {
+ if (!sensors[i]) {
+ continue;
+ }
$("#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++) {
+ if (!domain_sensors[i]) {
+ continue;
+ }
$("#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);
}
else if (domain_data.de_name == "sensor") {
- //TODO: load all tags
- $("#phantom_domain_sensors_input").tagsManager('pushTag', domain_data.metric);
+ //$("#phantom_domain_sensors_input").tagsManager('pushTag', domain_data.metric);
$("#phantom_domain_metric_choice").val(domain_data.metric);
$("#phantom_domain_cooldown_input").val(domain_data.sensor_cooldown);
$("#phantom_domain_minimum_input").val(domain_data.sensor_minimum_vms);
@@ -599,6 +607,10 @@ function phantom_domain_deselect_domain() {
$("#phantom_details_button_div").hide();
$("#details_table_body").empty();
$("#instance_table_body").empty();
+ $("#scaling_sensor_value").hide();
+ $("#scaling_table_body").empty();
+ $("#domain_table_body").empty();
+ $("#domain-metrics").hide();
$("#phantom_domain_main_combined_pane_inner").hide();
$("#phantom_domain_main_combined_pane_inner input[type='text']").val("");
$("#phantom_domain_main_combined_pane_inner select").empty();
@@ -705,7 +717,7 @@ function show_domain_details(domain_id) {
return;
}
- var $table = $("#domain-table-body").empty();
+ var $table = $("#domain_table_body").empty();
var domain = g_domain_details_cache[domain_id];
if (domain === null) {
return;
@@ -724,13 +736,46 @@ function show_domain_details(domain_id) {
}
}
$table.append(data);
-
- if ($table.children().length === 0) {
+ if ($table.children("tr").length === 0) {
$("#domain-metrics").hide();
}
else {
$("#domain-metrics").show();
}
+
+ var de_name = g_decision_engines_by_name[$("#phantom_domain_de_choice").val()];
+ if (de_name === "sensor") {
+
+ var scaling_metric = g_domain_data[domain_id]['metric'];
+ var domain_metrics = domain.domain_metrics;
+ var sensor_data = null;
+ if (domain.domain_metrics && scaling_metric in domain.domain_metrics) {
+ sensor_data = domain.domain_metrics[scaling_metric]['Average'];
+ }
+ else {
+ var instance_metrics = [];
+ for (var i=0; i<domain.instances.length; i++) {
+ var instance = domain.instances[i];
+ if (instance.sensor_data && scaling_metric in instance.sensor_data) {
+ instance_metrics.push(instance.sensor_data[scaling_metric]['Average']);
+ }
+ }
+ if (instance_metrics.length > 0){
+ var sum = 0;
+ for (var j=0; j<instance_metrics.length; j++) {
+ sum += parseFloat(instance_metrics[j]);
+ }
+ sensor_data = sum/instance_metrics.length;
+ }
+
+ }
+
+ if (sensor_data !== null) {
+ $("#scaling_sensor_value").show();
+ var row = make_row(scaling_metric, sensor_data);
+ $("#scaling_table_body").empty().append(row);
+ }
+ }
}
@@ -194,10 +194,19 @@ <h5 class="phantom_area_header magic-underline">Configuration for <span id="phan
-->
</div>
<div class="tab-pane" id="domain-details-tab">
+ <div id="#scaling_sensor_value">
+ <h5 class="magic-underline">Scale Sensor Value</h5>
+ <p class="help-block"><small>This sensor value is the calculated number that Phantom uses to scale your domain.</small></p>
+ <table class="table table-condensed" id="scaling_table">
+ <tbody id="scaling_table_body">
+ </tbody>
+ </table>
+ </div>
<div id="#domain-metrics">
<h5 class="magic-underline">Domain Metrics</h5>
+ <p class="help-block"><small>These are metrics that are monitored on a domain-wide level.</small></p>
<table class="table table-condensed" id="domain-table">
- <tbody id="domain-table-body">
+ <tbody id="domain_table_body">
</tbody>
</table>
</div>
View
@@ -112,7 +112,7 @@ def _get_all_domains_dashi(userobj):
return_asgs[a['name']] = ent
return return_asgs
-
+
@LogEntryDecorator
def _get_phantom_con(userobj):
@@ -137,19 +137,23 @@ def multicloud_tags_from_de_params(phantom_con, domain_name, de_params):
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', '')
sample_function_key = 'sample_function'
sample_function = 'Average'
# TODO: this should eventually be configurable
sensor_type_key = 'sensor_type'
sensor_type = 'opentsdb'
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 = []
tags.append(policy_tag)
tags.append(monitor_sensors_tag)
+ tags.append(monitor_domain_sensors_tag)
tags.append(sample_function_tag)
tags.append(sensor_type_tag)
@@ -166,6 +170,8 @@ def sensor_tags_from_de_params(phantom_con, domain_name, de_params):
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', '')
cooldown_key = 'cooldown_period'
cooldown = de_params.get('sensor_cooldown')
@@ -186,6 +192,7 @@ def sensor_tags_from_de_params(phantom_con, domain_name, de_params):
metric_tag = Tag(connection=phantom_con, key=metric_key, value=metric, 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)
cooldown_tag = Tag(connection=phantom_con, key=cooldown_key, value=cooldown, resource_id=domain_name)
@@ -198,6 +205,7 @@ def sensor_tags_from_de_params(phantom_con, domain_name, de_params):
tags.append(policy_tag)
tags.append(metric_tag)
tags.append(monitor_sensors_tag)
+ tags.append(monitor_domain_sensors_tag)
tags.append(sample_function_tag)
tags.append(sensor_type_tag)
tags.append(cooldown_tag)
@@ -233,7 +241,6 @@ def _start_domain(phantom_con, domain_name, lc_name, de_name, de_params, host_li
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
@@ -304,7 +311,7 @@ def update_desired_size(request_params, userobj):
e_msg = "The domain %s does not exist." % (asg_name)
raise PhantomWebException(e_msg)
asgs[0].set_capacity(asg_new_desired_size)
-
+
response_dict = {
'Success': True,
}
@@ -616,11 +623,11 @@ def phantom_domain_load(request_params, userobj):
@PhantomWebDecorator
@LogEntryDecorator
def phantom_domain_start(request_params, userobj):
- sensor_params = ["sensor_metric", "sensor_cooldown", "sensor_minimum_vms",
- "sensor_maximum_vms", "sensor_scale_up_threshold", "sensor_scale_up_vms",
+ sensor_params = ["sensor_metric", "sensor_cooldown", "sensor_minimum_vms",
+ "sensor_maximum_vms", "sensor_scale_up_threshold", "sensor_scale_up_vms",
"sensor_scale_down_threshold", "sensor_scale_down_vms"]
multicloud_params = ["vm_count",]
- mandatory_params = ['name', "lc_name", "de_name", "monitor_sensors"]
+ mandatory_params = ['name', "lc_name", "de_name", "monitor_sensors", "monitor_domain_sensors"]
for p in mandatory_params:
if p not in request_params:
raise PhantomWebException('Missing parameter %s' % (p))
@@ -684,11 +691,11 @@ def phantom_domain_start(request_params, userobj):
@PhantomWebDecorator
@LogEntryDecorator
def phantom_domain_resize(request_params, userobj):
- sensor_params = ["sensor_metric", "sensor_cooldown", "sensor_minimum_vms",
- "sensor_maximum_vms", "sensor_scale_up_threshold", "sensor_scale_up_vms",
+ sensor_params = ["sensor_metric", "sensor_cooldown", "sensor_minimum_vms",
+ "sensor_maximum_vms", "sensor_scale_up_threshold", "sensor_scale_up_vms",
"sensor_scale_down_threshold", "sensor_scale_down_vms"]
multicloud_params = ["vm_count",]
- mandatory_params = ["name", "de_name", "monitor_sensors"]
+ mandatory_params = ["name", "de_name", "monitor_sensors", "monitor_domain_sensors"]
for p in mandatory_params:
if p not in request_params:
raise PhantomWebException('Missing parameter %s' % (p))
@@ -697,6 +704,7 @@ def phantom_domain_resize(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:
@@ -824,19 +832,17 @@ def phantom_domain_details(request_params, userobj):
msg = "Could not find the launch configuration '%s' associated with the domain '%s'" % (lc_name, domain_name)
g_general_log.error(msg)
raise PhantomWebException(msg)
-
+
lc_db_object = lc_db_objects_a[0]
site_dict = _get_launch_configuration(phantom_con, lc_db_object)
# TODO: this should come from the REST interface
domain = userobj.describe_domain(userobj._user_dbobject.access_key, domain_name)
instance_metrics = {}
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')
@@ -872,7 +878,7 @@ def phantom_domain_details(request_params, userobj):
error_msg = "The user %s does not have a cloud configured %s. They must have deleted it after starting the domain." % (userobj._user_dbobject.access_key, cloud_name)
g_general_log.error(error_msg)
raise PhantomWebException(error_msg)
-
+
iaas_con = iaas_cloud.get_iaas_compute_con()
boto_insts = iaas_con.get_all_instances(instance_ids=[i_d['instance_id'],])
if boto_insts and boto_insts[0].instances:

0 comments on commit 7848c2a

Please sign in to comment.