Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for multiple metrics

  • Loading branch information...
commit 24e861c34aa43efa23812c60e0b66d3d995506b3 1 parent f0b4415
@oldpatricka oldpatricka authored
View
107 phantomweb/static/css/bootstrap-tagmanager.css
@@ -0,0 +1,107 @@
+ .myTag
+ {
+ background: none repeat scroll 0 0 #CDE69C;
+ border: 1px solid #A5D24A;
+ border-radius: 3px 3px 3px 3px;
+ color: #638421;
+
+// to be tested
+ display: block;
+ float: left;
+//
+
+ font-family: helvetica;
+ font-size: 13px;
+ margin-bottom: 5px;
+ margin-right: 5px;
+ //padding-top: 6px;
+ //padding-bottom: 5px;
+ padding: 6px 5px 5px 5px;
+ text-decoration: none;
+
+ vertical-align: middle;
+ line-height: 18px;
+ height:18px;
+ -moz-transition: border 0.2s linear 0s, box-shadow 0.2s linear 0s;
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
+ }
+ .myTagError
+ {
+ background-color: #F2DEDE;
+ }
+ .myTagRemover
+ {
+ color:silver;
+ }
+ .tagManager
+ {
+ border-radius: 3px 3px 3px 3px;
+ margin-top:0;
+ }
+
+ .myFramedTag
+ {
+ background: none repeat scroll 0 0 #CDE69C;
+ border: 1px solid #A5D24A;
+ border-radius: 3px 3px 3px 3px;
+ color: #638421;
+ //display: block;
+ //float: left;
+ font-family: helvetica;
+ font-size: 11px;
+ margin-bottom: 5px;
+ margin-right: 5px;
+ //padding-top: 6px;
+ //padding-bottom: 5px;
+ padding: 5px 4px 4px 4px;
+ text-decoration: none;
+ white-space: nowrap;
+
+ vertical-align: middle;
+ line-height: 18px;
+ //height:18px;
+ -moz-transition: border 0.2s linear 0s, box-shadow 0.2s linear 0s;
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
+ }
+
+ .myMinTag
+ {
+ background: none repeat scroll 0 0 #CDE69C;
+ border: 1px solid #A5D24A;
+ border-radius: 3px 3px 3px 3px;
+ color: #638421;
+ //display: block;
+ //float: left;
+ font-family: helvetica;
+ font-size: 11px;
+ margin-bottom: 5px;
+ margin-right: 5px;
+ //padding-top: 6px;
+ //padding-bottom: 5px;
+ padding: 2px 4px 2px 4px;
+ text-decoration: none;
+
+ vertical-align: middle;
+ line-height: 18px;
+ //height:18px;
+ -moz-transition: border 0.2s linear 0s, box-shadow 0.2s linear 0s;
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
+ }
+
+ .myMinNonTag
+ {
+ font-family: helvetica;
+ font-size: 11px;
+ margin-bottom: 5px;
+ margin-right: 5px;
+ //padding-top: 6px;
+ //padding-bottom: 5px;
+ padding: 2px 4px 2px 4px;
+ text-decoration: none;
+
+ vertical-align: middle;
+ line-height: 18px;
+ //height:18px;
+ -moz-transition: border 0.2s linear 0s, box-shadow 0.2s linear 0s;
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
+ }
View
40 phantomweb/static/css/phantom_common.css
@@ -1,36 +1,52 @@
-#phantom_content
-{
+span.myTag {
+ background: none repeat scroll 0 0 #EEE;
+ border: 1px solid #AAA;
+ border-radius: 3px 3px 3px 3px;
+ color: #555;
+
+ font-size: 11px;
+ margin-bottom: 5px;
+ margin-right: 5px;
+ padding: 3px 2px 2px 3px;
+ text-decoration: none;
+
+ vertical-align: middle;
+ line-height: 18px;
+ height:18px;
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
+}
+
+a.myTagRemover {
+ color: #444;
+}
+
+#phantom_content {
display: table;
width: 900px;
height: 500px;
}
-.phantom_links
-{
+.phantom_links {
display: inline;
padding-right: 20px;
}
-#phantom_links_div
-{
+#phantom_links_div {
display: inline;
width: 100%;
text-align: left;
}
-#phantom_reset_pw_div li
-{
+#phantom_reset_pw_div li {
list-style-type: none;
}
-.phantom_headings
-{
+.phantom_headings {
font-size: x-large;
padding-top: 20px;
padding-right: 25px;
}
-.phantom_area_header
-{
+.phantom_area_header {
font-size: 1pc;
}
View
7 phantomweb/static/css/phantom_domain.css
@@ -11,6 +11,13 @@
height: 500px;
}
+#phantom_domain_sensors_label
+{
+ display: inline-block;
+ width: 100%;
+ margin-bottom: 5px;
+}
+
#phantom_domain_status_bar_div
{
height: 25px;
View
456 phantomweb/static/js/bootstrap-tagmanager.js
@@ -0,0 +1,456 @@
+/* ===================================================
+ * bootstrap-tagmanager.js v2.2
+ * http://welldonethings.com/tags/manager
+ * ===================================================
+ * Copyright 2012 Max Favilli
+ *
+ * Licensed under the Mozilla Public License, Version 2.0 You may not use this work except in compliance with the License.
+ *
+ * http://www.mozilla.org/MPL/2.0/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================== */
+
+"use strict";
+
+(function (jQuery) {
+ if (typeof console === "undefined" || typeof console.log === "undefined") {
+ console = {};
+ console.log = function () { };
+ }
+
+ jQuery.fn.tagsManager = function (options,tagToManipulate) {
+ var tagManagerOptions = {
+ prefilled: null,
+ CapitalizeFirstLetter: false,
+ preventSubmitOnEnter: true,
+ typeahead: false,
+ typeaheadAjaxSource: null,
+ typeaheadAjaxPolling: false,
+ typeaheadSource: null,
+ AjaxPush: null,
+ delimeters: [44, 188, 13],
+ backspace: [8],
+ maxTags: 0,
+ hiddenTagListName: null,
+ deleteTagsOnBackspace: true,
+ tagsContainer: null,
+ tagCloseIcon: 'x'
+ };
+
+ jQuery.extend(tagManagerOptions, options);
+
+ if (tagManagerOptions.hiddenTagListName === null) {
+ tagManagerOptions.hiddenTagListName = "hidden-" + this.attr('name');
+ }
+
+ var obj = this;
+ var objName = obj.attr('name').replace(/[^\w]/g, '_');
+ var queuedTag = "";
+ var delimeters = tagManagerOptions.delimeters;
+ var backspace = tagManagerOptions.backspace;
+
+ var setupTypeahead = function () {
+ if (!obj.typeahead) return;
+
+ if (tagManagerOptions.typeaheadSource != null && jQuery.isFunction(tagManagerOptions.typeaheadSource)) {
+ obj.typeahead({ source: tagManagerOptions.typeaheadSource });
+ } else if (tagManagerOptions.typeaheadSource != null) {
+ obj.typeahead();
+ obj.data('active', true);
+ obj.data('typeahead').source = tagManagerOptions.typeaheadSource;
+ obj.data('active', false);
+ } else if (tagManagerOptions.typeaheadAjaxSource != null) {
+ if (!tagManagerOptions.typeaheadAjaxPolling) {
+ obj.typeahead();
+ jQuery.getJSON(tagManagerOptions.typeaheadAjaxSource, function (data) {
+ var sourceAjaxArray = [];
+ if (data != undefined && data.tags != undefined) {
+ sourceAjaxArray.length = 0;
+ jQuery.each(data.tags, function (key, val) {
+ var a = 1;
+ sourceAjaxArray.push(val.tag);
+ obj.data('active', true);
+ obj.data('typeahead').source = sourceAjaxArray;
+ obj.data('active', false);
+ });
+ }
+ });
+ } else if (tagManagerOptions.typeaheadAjaxPolling) {
+ obj.typeahead({ source: ajaxPolling });
+ }
+ } else if (tagManagerOptions.typeaheadDelegate) {
+ obj.typeahead(tagManagerOptions.typeaheadDelegate)
+ }
+ };
+
+ var ajaxPolling = function (query, process) {
+ jQuery.getJSON(tagManagerOptions.typeaheadAjaxSource, function (data) {
+ var sourceAjaxArray = [];
+ if (data != undefined && data.tags != undefined) {
+ sourceAjaxArray.length = 0;
+ jQuery.each(data.tags, function (key, val) {
+ var a = 1;
+ sourceAjaxArray.push(val.tag);
+ });
+ process(sourceAjaxArray);
+ }
+ });
+ };
+
+ var trimTag = function (tag) {
+ var txt = jQuery.trim(tag);
+
+ var l = txt.length;
+ var t = 0;
+
+ for (var i = l - 1; i >= 0; i--) {
+ if (-1 == jQuery.inArray(txt.charCodeAt(i), delimeters)) break;
+ t++;
+ }
+
+ txt = txt.substring(0, l - t);
+ l = txt.length;
+ t = 0;
+
+ //remove from head
+ for (var i = 0; i < l; i++) {
+ if (-1 == jQuery.inArray(txt.charCodeAt(i), delimeters)) break;
+ t++;
+ }
+
+ txt = txt.substring(t, l);
+ return txt;
+ };
+
+ //$(this).on('popTag', function (e){
+ // var tlis = obj.data("tlis");
+ // var tlid = obj.data("tlid");
+
+ // if (tlid.length > 0) {
+ // var tagId = tlid.pop();
+ // tlis.pop();
+ // // console.log("TagIdToRemove: " + tagId);
+ // jQuery("#" + objName + "_" + tagId).remove();
+ // refreshHiddenTagList();
+ // // console.log(tlis);
+ // }
+ //});
+
+ var popTag = function () {
+ var tlis = obj.data("tlis");
+ var tlid = obj.data("tlid");
+
+ if (tlid.length > 0) {
+ var tagId = tlid.pop();
+ tlis.pop();
+ // console.log("TagIdToRemove: " + tagId);
+ jQuery("#" + objName + "_" + tagId).remove();
+ refreshHiddenTagList();
+ // console.log(tlis);
+ }
+ };
+
+ var empty = function () {
+ var tlis = obj.data("tlis");
+ var tlid = obj.data("tlid");
+
+ while (tlid.length > 0) {
+ var tagId = tlid.pop();
+ tlis.pop();
+ // console.log("TagIdToRemove: " + tagId);
+ jQuery("#" + objName + "_" + tagId).remove();
+ refreshHiddenTagList();
+ // console.log(tlis);
+ }
+ };
+
+ var refreshHiddenTagList = function () {
+ var tlis = obj.data("tlis");
+ var lhiddenTagList = obj.data("lhiddenTagList");
+
+ if (lhiddenTagList == undefined)
+ return;
+
+ jQuery(lhiddenTagList).val(tlis.join(",")).change();
+ };
+
+ var spliceTag = function (tagId) {
+ var tlis = obj.data("tlis");
+ var tlid = obj.data("tlid");
+
+ var p = jQuery.inArray(tagId, tlid)
+
+ // console.log("TagIdToRemove: " + tagId);
+ // console.log("position: " + p);
+
+ if (-1 != p) {
+ jQuery("#" + objName + "_" + tagId).remove();
+ tlis.splice(p, 1);
+ tlid.splice(p, 1);
+ refreshHiddenTagList();
+ // console.log(tlis);
+ }
+
+ if (tagManagerOptions.maxTags > 0 && tlis.length < tagManagerOptions.maxTags) {
+ obj.show();
+ }
+ };
+
+ var pushTag = function (tag) {
+ if (!tag || tag.length <= 0) return;
+
+ if (tagManagerOptions.CapitalizeFirstLetter && tag.length > 1) {
+ tag = tag.charAt(0).toUpperCase() + tag.slice(1).toLowerCase();
+ }
+
+ // call the validator (if any) and do not let the tag pass if invalid
+ if (tagManagerOptions.validator !== undefined) {
+ if (tagManagerOptions.validator(tag) !== true) return;
+ }
+
+ var tlis = obj.data("tlis");
+ var tlid = obj.data("tlid");
+
+ // dont accept new tags beyond the defined maximum
+ if (tagManagerOptions.maxTags > 0 && tlis.length >= tagManagerOptions.maxTags) return;
+
+ var alreadyInList = false;
+ var p = jQuery.inArray(tag, tlis);
+ if (-1 != p) {
+ // console.log("tag:" + tag + " !!already in list!!");
+ alreadyInList = true;
+ }
+
+ if (alreadyInList) {
+ var pTagId = tlid[p];
+ jQuery("#" + objName + "_" + pTagId).stop()
+ .animate({ backgroundColor: tagManagerOptions.blinkBGColor_1 }, 100)
+ .animate({ backgroundColor: tagManagerOptions.blinkBGColor_2 }, 100)
+ .animate({ backgroundColor: tagManagerOptions.blinkBGColor_1 }, 100)
+ .animate({ backgroundColor: tagManagerOptions.blinkBGColor_2 }, 100)
+ .animate({ backgroundColor: tagManagerOptions.blinkBGColor_1 }, 100)
+ .animate({ backgroundColor: tagManagerOptions.blinkBGColor_2 }, 100);
+ } else {
+ var max = Math.max.apply(null, tlid);
+ max = max == -Infinity ? 0 : max;
+
+ var tagId = ++max;
+ tlis.push(tag);
+ tlid.push(tagId);
+
+ if (tagManagerOptions.AjaxPush != null) {
+ jQuery.post(tagManagerOptions.AjaxPush, { tag: tag });
+ }
+
+ // console.log("tagList: " + tlis);
+
+ var newTagId = objName + '_' + tagId;
+ var newTagRemoveId = objName + '_Remover_' + tagId;
+ var html = '';
+ html += '<span class="myTag" id="' + newTagId + '"><span>' + tag + '&nbsp;&nbsp;</span><a href="#" class="myTagRemover" id="' + newTagRemoveId + '" TagIdToRemove="' + tagId + '" title="Remove">' + tagManagerOptions.tagCloseIcon + '</a></span>';
+
+ if (tagManagerOptions.tagsContainer != null) {
+ jQuery(tagManagerOptions.tagsContainer).append(html)
+ } else {
+ obj.before(html);
+ }
+
+ jQuery("#" + newTagRemoveId).on("click", obj, function (e) {
+ e.preventDefault();
+ var TagIdToRemove = parseInt(jQuery(this).attr("TagIdToRemove"));
+ spliceTag(TagIdToRemove, e.data);
+ });
+
+ refreshHiddenTagList();
+
+ if (tagManagerOptions.maxTags > 0 && tlis.length >= tagManagerOptions.maxTags) {
+ obj.hide();
+ }
+ }
+ obj.val("");
+ };
+
+ return this.each(function () {
+
+ if (typeof options == 'string') {
+ switch (options) {
+ case "empty":
+ empty();
+ break;
+ case "popTag":
+ popTag();
+ break;
+ case "pushTag":
+ pushTag(tagToManipulate);
+ break;
+ }
+ return;
+ }
+
+ //let's store some instance specific data directly into the DOM object
+ var tlis = new Array();
+ var tlid = new Array();
+ obj.data("tlis", tlis); //list of string tags
+ obj.data("tlid", tlid); //list of ID of the string tags
+
+ var html = "";
+ html += "<input name='" + tagManagerOptions.hiddenTagListName + "' type='hidden' value=''/>";
+ obj.after(html);
+ obj.data("lhiddenTagList",
+ obj.siblings("input[name='" + tagManagerOptions.hiddenTagListName + "']")[0]
+ );
+
+ if (tagManagerOptions.typeahead) {
+ setupTypeahead();
+ //obj.typeahead({ source: SourceArray })
+ }
+
+ obj.on("focus", function (e) {
+ if (jQuery(this).popover) {
+ jQuery(this).popover("hide");
+ //jQuery(this).popover = null;
+ }
+ });
+
+ // disable submit on enter for this input field
+ obj.on("keypress", function (e) {
+ if (jQuery(this).popover) {
+ jQuery(this).popover("hide");
+ //jQuery(this).popover = null;
+ }
+ if (tagManagerOptions.preventSubmitOnEnter) {
+ if (e.which == 13) {
+ e.cancelBubble = true;
+ e.returnValue = false;
+ e.stopPropagation();
+ e.preventDefault();
+ //e.keyCode = 9;
+ }
+ }
+ // console.log("keyup: " + e.keyCode);
+ });
+
+ obj.on("keyup", obj, function (e) {
+ var p = jQuery.inArray(e.which, delimeters);
+ if (-1 != p) {
+ //user just entered a valid delimeter
+ var user_input = jQuery(this).val(); //user_input = jQuery().inArray(delimeters[p]);
+ user_input = trimTag(user_input);
+ pushTag(user_input, e.data);
+ // console.log("pushTag: keyup");
+ }
+
+ // console.log("keyup: " + e.which);
+ });
+
+ if (tagManagerOptions.deleteTagsOnBackspace) {
+ obj.on("keydown", obj, function (e) {
+ var p = jQuery.inArray(e.which, backspace);
+ if (-1 != p) {
+ //user just entered backspace or equivalent
+ var user_input = jQuery(this).val(); //user_input = jQuery().inArray(delimeters[p]);
+ var i = user_input.length;
+ if (i <= 0) {
+ // console.log("backspace detected");
+ e.preventDefault();
+ popTag();
+ }
+ }
+ });
+ }
+
+ obj.change(function (e) {
+ e.cancelBubble = true;
+ e.returnValue = false;
+ e.stopPropagation();
+ e.preventDefault();
+
+ var is_chrome = navigator.userAgent.indexOf('Chrome') > -1;
+ var is_explorer = navigator.userAgent.indexOf('MSIE') > -1;
+ var is_firefox = navigator.userAgent.indexOf('Firefox') > -1;
+ var is_safari = navigator.userAgent.indexOf("Safari") > -1;
+
+ if (!is_chrome && !is_safari)
+ jQuery(this).focus();
+
+ // console.log('Handler for .change() called, value selected:' + obj.val());
+ var ao = jQuery(".typeahead:visible");
+ if (ao[0] != undefined) {
+ // console.log('change: typeaheadIsVisible is visible');
+ //when the user click with the mouse on the typeahead li element we get the change event fired twice, once when the input field loose focus and later with the input field value is replaced with li value
+ var user_input = $(this).data('typeahead').$menu.find('.active').attr('data-value');
+ user_input = trimTag(user_input);
+ if (queuedTag == obj.val() && queuedTag == user_input) {
+ queuedTag = "";
+ obj.val(queuedTag);
+ } else {
+ pushTag(user_input);
+ queuedTag = user_input;
+ // console.log('Handler for .change() called, typeahead value pushed:' + queuedTag);
+ }
+ } else {
+ // console.log('change: typeaheadIsVisible is NOT visible');
+ var user_input = jQuery(this).val(); //user_input = jQuery().inArray(delimeters[p]);
+ user_input = trimTag(user_input);
+ pushTag(user_input);
+ // console.log("pushTag: change ");
+ }
+
+ });
+
+ if (1 == 1 || !tagManagerOptions.typeahead) {
+ obj.on("blur", function (e) {
+ //lost focus
+ e.cancelBubble = true;
+ e.returnValue = false;
+ e.stopPropagation();
+ e.preventDefault();
+
+ var push = true;
+ if (tagManagerOptions.typeahead) {
+ var ao = jQuery(".typeahead:visible");
+ if (ao[0] != undefined) {
+ // console.log('blur: typeaheadIsVisible is visible');
+ push = false;
+ } else {
+ // console.log('blur: typeaheadIsVisible is NOT visible');
+ push = true;
+ }
+ }
+
+ if (push) {
+ // console.log('lost focus');
+ var user_input = jQuery(this).val(); //user_input = jQuery().inArray(delimeters[p]);
+ user_input = trimTag(user_input);
+ pushTag(user_input);
+ // console.log("pushTag: blur");
+ }
+ });
+ }
+
+ if (tagManagerOptions.prefilled != null) {
+ if (typeof (tagManagerOptions.prefilled) == "object") {
+ var pta = tagManagerOptions.prefilled;
+ jQuery.each(pta, function (key, val) {
+ var a = 1;
+ pushTag(val, obj);
+ });
+ } else if (typeof (tagManagerOptions.prefilled) == "string") {
+ var pta = tagManagerOptions.prefilled.split(',');
+
+ jQuery.each(pta, function (key, val) {
+ var a = 1;
+ pushTag(val, obj);
+ });
+
+ }
+ }
+ });
+
+ }
+})(jQuery);
View
64 phantomweb/static/js/phantom_domain.js
@@ -9,9 +9,14 @@ $(document).ready(function() {
$("#phantom_domain_main_combined_pane_inner").hide();
- $("#phantom_domain_de_choice").val(DEFAULT_DECISION_ENGINE)
- phantom_select_de(DEFAULT_DECISION_ENGINE);
+ $("#phantom_domain_sensors_input").tagsManager();
+
+ $("input[name=hidden-tags]").change(function() {
+ phantom_update_sensors();
+ });
+ $("#phantom_domain_de_choice").val(DEFAULT_DECISION_ENGINE);
+ phantom_select_de(DEFAULT_DECISION_ENGINE);
phantom_domain_load();
$("body").click(function() {
@@ -73,6 +78,20 @@ function phantom_add_domain_click() {
phantom_domain_select_domain();
}
+function phantom_update_sensors() {
+ var metrics_raw = $("input[name=hidden-tags]").val();
+ var metrics = metrics_raw.split(",");
+ var old_selected_metric = $("#phantom_domain_metric_choice").val();
+
+ $("#phantom_domain_metric_choice").empty();
+ for (var i=0; i<metrics.length; i++) {
+ var metric = metrics[i];
+ var new_opt = $('<option>', {'name': metric, value: metric, text: metric});
+ $("#phantom_domain_metric_choice").append(new_opt);
+ }
+ $("#phantom_domain_metric_choice").val(old_selected_metric);
+}
+
function phantom_domain_load_lc_names() {
$("#phantom_domain_lc_choice").empty();
@@ -157,15 +176,18 @@ function phantom_domain_load() {
// TODO: refactor for DRY with resize
function phantom_domain_start_click_internal() {
var url = make_url('api/domain/start');
+
+ // All-DE attrs
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();
// Multicloud attrs
var vm_count = $("#phantom_domain_size_input").val();
// Sensor attrs
- var metric = $("#phantom_domain_metric_input").val();
+ var metric = $("#phantom_domain_metric_choice").val();
var cooldown = $("#phantom_domain_cooldown_input").val();
var minimum_vms = $("#phantom_domain_minimum_input").val();
var maximum_vms = $("#phantom_domain_maximum_input").val();
@@ -183,7 +205,7 @@ function phantom_domain_start_click_internal() {
error_msg = "You must specify a domain name";
}
- var data = {"name": domain_name, "lc_name": lc_name, "de_name": de_name};
+ var data = {"name": domain_name, "lc_name": lc_name, "de_name": de_name, "monitor_sensors": monitor_sensors};
if (de_name == "multicloud") {
if (! vm_count) {
@@ -264,12 +286,13 @@ function phantom_domain_resize_click_internal() {
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();
// Multicloud attrs
var vm_count = $("#phantom_domain_size_input").val();
// Sensor attrs
- var metric = $("#phantom_domain_metric_input").val();
+ var metric = $("#phantom_domain_metric_choice").val();
var cooldown = $("#phantom_domain_cooldown_input").val();
var minimum_vms = $("#phantom_domain_minimum_input").val();
var maximum_vms = $("#phantom_domain_maximum_input").val();
@@ -287,7 +310,7 @@ function phantom_domain_resize_click_internal() {
error_msg = "You must specify a domain name";
}
- var data = {"name": domain_name, "lc_name": lc_name, "de_name": de_name};
+ var data = {"name": domain_name, "lc_name": lc_name, "de_name": de_name, "monitor_sensors": monitor_sensors};
if (de_name == "multicloud") {
if (! vm_count) {
@@ -332,6 +355,11 @@ function phantom_domain_resize_click_internal() {
data["sensor_scale_down_vms"] = scale_down_vms;
}
+ if (error_msg != undefined) {
+ alert(error_msg);
+ return;
+ }
+
var success_func = function(obj) {
//("#phantom_domain_size_input").val("");
//$("#phantom_domain_list_domains").val(domain_name);
@@ -427,11 +455,19 @@ function phantom_domain_select_domain_internal() {
$("#phantom_domain_running_buttons").show();
phantom_select_de(g_decision_engines_by_type[domain_data.de_name]);
+ $("#phantom_domain_sensors_input").tagsManager('empty');
+ var sensors = String(domain_data.monitor_sensors).split(",");
+ for (var i=0; i<sensors.length; i++) {
+ $("#phantom_domain_sensors_input").tagsManager('pushTag', sensors[i]);
+ }
+
if (domain_data.de_name == "multicloud") {
$("#phantom_domain_size_input").val(domain_data.vm_size);
}
else if (domain_data.de_name == "sensor") {
- $("#phantom_domain_metric_input").val(domain_data.metric);
+ //TODO: load all tags
+ $("#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);
$("#phantom_domain_maximum_input").val(domain_data.sensor_maximum_vms);
@@ -485,7 +521,7 @@ function phantom_domain_load_instances() {
fields[6] = instance.keyname;
var parsed_sensor_data = sensor_data_to_string(instance.sensor_data);
if (parsed_sensor_data !== "") {
- fields[7] = instance.metric + ": " + sensor_data_to_string(instance.sensor_data);
+ fields[7] = sensor_data_to_string(instance.sensor_data);
}
var filter = $("#phantom_domain_filter_list").val();
@@ -520,12 +556,14 @@ function phantom_domain_load_instances() {
function sensor_data_to_string(sensor_data) {
var str = "";
- for (var sensor_type in sensor_data) {
- if (sensor_type === "Series") {
- // Ignore series data because it is ugly :)
- continue;
+ 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>";
}
- str += sensor_type + ": " + sensor_data[sensor_type] + " ";
}
return str;
}
View
9 phantomweb/static/js/textext.js
@@ -0,0 +1,9 @@
+/**
+ * jQuery TextExt Plugin
+ * http://textextjs.com
+ *
+ * @version 1.3.1
+ * @copyright Copyright (C) 2011 Alex Gorbatchev. All rights reserved.
+ * @license MIT License
+ */
+;(function(a,b){function c(){}function d(){}function e(){}function x(a,b){typeof b=="string"&&(b=b.split("."));var c=b.join(".").replace(/\.(\w)/g,function(a,b){return b.toUpperCase()}),d=b.shift(),e;return typeof (e=a[c])!=i?e=e:typeof (e=a[d])!=i&&b.length>0&&(e=x(e,b)),e}function y(){function e(a,d){c.bind(a,function(){return d.apply(b,arguments)})}var a=g.apply(arguments),b=this,c=a.length===1?b:a.shift(),d;a=a[0]||{};for(d in a)e(d,a[d])}function z(a,b){return{input:a,form:b}}var f=(JSON||{}).stringify,g=Array.prototype.slice,h,i="undefined",j="item.manager",k="plugins",l="ext",m="html.wrap",n="html.hidden",o="keys",p="preInvalidate",q="postInvalidate",r="getFormData",s="setFormData",t="setInputData",u="postInit",v="ready",w={itemManager:d,plugins:[],ext:{},html:{wrap:'<div class="text-core"><div class="text-wrap"/></div>',hidden:'<input type="hidden" />'},keys:{8:"backspace",9:"tab",13:"enter!",27:"escape!",37:"left",38:"up!",39:"right",40:"down!",46:"delete",108:"numpadEnter"}};if(!f)throw new Error("JSON.stringify() not found");h=d.prototype,h.init=function(a){},h.filter=function(a,b){var c=[],d,e;for(d=0;d<a.length;d++)e=a[d],this.itemContains(e,b)&&c.push(e);return c},h.itemContains=function(a,b){return this.itemToString(a).toLowerCase().indexOf(b.toLowerCase())==0},h.stringToItem=function(a){return a},h.itemToString=function(a){return a},h.compareItems=function(a,b){return a==b},h=c.prototype,h.init=function(b,c){var d=this,e,f,g;d._defaults=a.extend({},w),d._opts=c||{},d._plugins={},d._itemManager=f=new(d.opts(j)),b=a(b),g=a(d.opts(m)),e=a(d.opts(n)),b.wrap(g).keydown(function(a){return d.onKeyDown(a)}).keyup(function(a){return d.onKeyUp(a)}).data("textext",d),a(d).data({hiddenInput:e,wrapElement:b.parents(".text-wrap").first(),input:b}),e.attr("name",b.attr("name")),b.attr("name",null),e.insertAfter(b),a.extend(!0,f,d.opts(l+".item.manager")),a.extend(!0,d,d.opts(l+".*"),d.opts(l+".core")),d.originalWidth=b.outerWidth(),d.invalidateBounds(),f.init(d),d.initPatches(),d.initPlugins(d.opts(k),a.fn.textext.plugins),d.on({setFormData:d.onSetFormData,getFormData:d.onGetFormData,setInputData:d.onSetInputData,anyKeyUp:d.onAnyKeyUp}),d.trigger(u),d.trigger(v),d.getFormData(0)},h.initPatches=function(){var b=[],c=a.fn.textext.patches,d;for(d in c)b.push(d);this.initPlugins(b,c)},h.initPlugins=function(b,c){var d=this,e,f,g,h=[],i;typeof b=="string"&&(b=b.split(/\s*,\s*|\s+/g));for(i=0;i<b.length;i++)f=b[i],g=c[f],g&&(d._plugins[f]=g=new g,d[f]=function(a){return function(){return a}}(g),h.push(g),a.extend(!0,g,d.opts(l+".*"),d.opts(l+"."+f)));h.sort(function(a,b){return a=a.initPriority(),b=b.initPriority(),a===b?0:a<b?1:-1});for(i=0;i<h.length;i++)h[i].init(d)},h.hasPlugin=function(a){return!!this._plugins[a]},h.on=y,h.bind=function(a,b){this.input().bind(a,b)},h.trigger=function(){var a=arguments;this.input().trigger(a[0],g.call(a,1))},h.itemManager=function(){return this._itemManager},h.input=function(){return a(this).data("input")},h.opts=function(a){var b=x(this._opts,a);return typeof b=="undefined"?x(this._defaults,a):b},h.wrapElement=function(){return a(this).data("wrapElement")},h.invalidateBounds=function(){var a=this,b=a.input(),c=a.wrapElement(),d=c.parent(),e=a.originalWidth+"px",f;a.trigger(p),f=b.outerHeight()+"px",b.css({width:e}),c.css({width:e,height:f}),d.css({height:f}),a.trigger(q)},h.focusInput=function(){this.input()[0].focus()},h.serializeData=f,h.hiddenInput=function(b){return a(this).data("hiddenInput")},h.getWeightedEventResponse=function(a,b){var c=this,d={},e=0;c.trigger(a,d,b);for(var f in d)e=Math.max(e,f);return d[e]},h.getFormData=function(a){var b=this,c=b.getWeightedEventResponse(r,a||0);b.trigger(s,c.form),b.trigger(t,c.input)},h.onAnyKeyUp=function(a,b){this.getFormData(b)},h.onSetInputData=function(a,b){this.input().val(b)},h.onSetFormData=function(a,b){var c=this;c.hiddenInput().val(c.serializeData(b))},h.onGetFormData=function(a,b){var c=this.input().val();b[0]=z(c,c)},a(["Down","Up"]).each(function(){var a=this.toString();h["onKey"+a]=function(b){var c=this,d=c.opts(o)[b.keyCode],e=!0;return d&&(e=d.substr(-1)!="!",d=d.replace("!",""),c.trigger(d+"Key"+a),a=="Up"&&c._lastKeyDown==b.keyCode&&(c._lastKeyDown=null,c.trigger(d+"KeyPress")),a=="Down"&&(c._lastKeyDown=b.keyCode)),c.trigger("anyKey"+a,b.keyCode),e}}),h=e.prototype,h.on=y,h.formDataObject=z,h.init=function(a){throw new Error("Not implemented")},h.baseInit=function(b,c){var d=this;b._defaults=a.extend(!0,b._defaults,c),d._core=b,d._timers={}},h.startTimer=function(a,b,c){var d=this;d.stopTimer(a),d._timers[a]=setTimeout(function(){delete d._timers[a],c.apply(d)},b*1e3)},h.stopTimer=function(a){clearTimeout(this._timers[a])},h.core=function(){return this._core},h.opts=function(a){return this.core().opts(a)},h.itemManager=function(){return this.core().itemManager()},h.input=function(){return this.core().input()},h.val=function(a){var b=this.input();if(typeof a===i)return b.val();b.val(a)},h.trigger=function(){var a=this.core();a.trigger.apply(a,arguments)},h.bind=function(a,b){this.core().bind(a,b)},h.initPriority=function(){return 0};var A=!1,B=a.fn.textext=function(b){var d;return!A&&(d=a.fn.textext.css)!=null&&(a("head").append("<style>"+d+"</style>"),A=!0),this.map(function(){var d=a(this);if(b==null)return d.data("textext");var e=new c;return e.init(d,b),d.data("textext",e),e.input()[0]})};B.addPlugin=function(a,b){B.plugins[a]=b,b.prototype=new B.TextExtPlugin},B.addPatch=function(a,b){B.patches[a]=b,b.prototype=new B.TextExtPlugin},B.TextExt=c,B.TextExtPlugin=e,B.ItemManager=d,B.plugins={},B.patches={}})(jQuery),function(a){function b(){}a.fn.textext.TextExtIE9Patches=b,a.fn.textext.addPatch("ie9",b);var c=b.prototype;c.init=function(a){if(navigator.userAgent.indexOf("MSIE 9")==-1)return;var b=this;a.on({postInvalidate:b.onPostInvalidate})},c.onPostInvalidate=function(){var a=this,b=a.input(),c=b.val();b.val(Math.random()),b.val(c)}}(jQuery);(function(a){function b(){}a.fn.textext.TextExtAjax=b,a.fn.textext.addPlugin("ajax",b);var c=b.prototype,d="ajax.data.callback",e="ajax.cache.results",f="ajax.loading.delay",g="ajax.loading.message",h="ajax.type.delay",i="setSuggestions",j="showDropdown",k="loading",l={ajax:{typeDelay:.5,loadingMessage:"Loading...",loadingDelay:.5,cacheResults:!1,dataCallback:null}};c.init=function(a){var b=this;b.baseInit(a,l),b.on({getSuggestions:b.onGetSuggestions}),b._suggestions=null},c.load=function(b){var c=this,e=c.opts(d)||function(a){return{q:a}},f;f=a.extend(!0,{data:e(b),success:function(a){c.onComplete(a,b)},error:function(a,c){console.error(c,b)}},c.opts("ajax")),a.ajax(f)},c.onComplete=function(a,b){var c=this,d=a;c.dontShowLoading(),c.opts(e)==1&&(c._suggestions=a,d=c.itemManager().filter(a,b)),c.trigger(i,{result:d})},c.dontShowLoading=function(){this.stopTimer(k)},c.showLoading=function(){var a=this;a.dontShowLoading(),a.startTimer(k,a.opts(f),function(){a.trigger(j,function(b){b.clearItems();var c=b.addDropdownItem(a.opts(g));c.addClass("text-loading")})})},c.onGetSuggestions=function(a,b){var c=this,d=c._suggestions,f=(b||{}).query||"";if(d&&c.opts(e)===!0)return c.onComplete(d,f);c.startTimer("ajax",c.opts(h),function(){c.showLoading(),c.load(f)})}})(jQuery);(function(a){function b(){}a.fn.textext.TextExtArrow=b,a.fn.textext.addPlugin("arrow",b);var c=b.prototype,d="html.arrow",e={html:{arrow:'<div class="text-arrow"/>'}};c.init=function(b){var c=this,f;c.baseInit(b,e),c._arrow=f=a(c.opts(d)),c.core().wrapElement().append(f),f.bind("click",function(a){c.onArrowClick(a)})},c.onArrowClick=function(a){this.trigger("toggleDropdown"),this.core().focusInput()}})(jQuery);(function(a){function b(){}a.fn.textext.TextExtAutocomplete=b,a.fn.textext.addPlugin("autocomplete",b);var c=b.prototype,d=".",e="text-selected",f=d+e,g="text-suggestion",h=d+g,i="text-label",j=d+i,k="autocomplete.enabled",l="autocomplete.dropdown.position",m="autocomplete.dropdown.maxHeight",n="autocomplete.render",o="html.dropdown",p="html.suggestion",q="hideDropdown",r="showDropdown",s="getSuggestions",t="getFormData",u="toggleDropdown",v="above",w="below",x="mousedownOnAutocomplete",y={autocomplete:{enabled:!0,dropdown:{position:w,maxHeight:"100px"}},html:{dropdown:'<div class="text-dropdown"><div class="text-list"/></div>',suggestion:'<div class="text-suggestion"><span class="text-label"/></div>'}};c.init=function(b){var c=this;c.baseInit(b,y);var d=c.input(),e;c.opts(k)===!0&&(c.on({blur:c.onBlur,anyKeyUp:c.onAnyKeyUp,deleteKeyUp:c.onAnyKeyUp,backspaceKeyPress:c.onBackspaceKeyPress,enterKeyPress:c.onEnterKeyPress,escapeKeyPress:c.onEscapeKeyPress,setSuggestions:c.onSetSuggestions,showDropdown:c.onShowDropdown,hideDropdown:c.onHideDropdown,toggleDropdown:c.onToggleDropdown,postInvalidate:c.positionDropdown,getFormData:c.onGetFormData,downKeyDown:c.onDownKeyDown,upKeyDown:c.onUpKeyDown}),e=a(c.opts(o)),e.insertAfter(d),c.on(e,{mouseover:c.onMouseOver,mousedown:c.onMouseDown,click:c.onClick}),e.css("maxHeight",c.opts(m)).addClass("text-position-"+c.opts(l)),a(c).data("container",e),a(document.body).click(function(a){c.isDropdownVisible()&&!c.withinWrapElement(a.target)&&c.trigger(q)}),c.positionDropdown())},c.containerElement=function(){return a(this).data("container")},c.onMouseOver=function(b){var c=this,d=a(b.target);d.is(h)&&(c.clearSelected(),d.addClass(e))},c.onMouseDown=function(a){this.containerElement().data(x,!0)},c.onClick=function(b){var c=this,d=a(b.target);(d.is(h)||d.is(j))&&c.trigger("enterKeyPress"),c.core().hasPlugin("tags")&&c.val("")},c.onBlur=function(a){var b=this,c=b.containerElement(),d=c.data(x)===!0;b.isDropdownVisible()&&(d?b.core().focusInput():b.trigger(q)),c.removeData(x)},c.onBackspaceKeyPress=function(a){var b=this,c=b.val().length>0;(c||b.isDropdownVisible())&&b.getSuggestions()},c.onAnyKeyUp=function(a,b){var c=this,d=c.opts("keys."+b)!=null;c.val().length>0&&!d&&c.getSuggestions()},c.onDownKeyDown=function(a){var b=this;b.isDropdownVisible()?b.toggleNextSuggestion():b.getSuggestions()},c.onUpKeyDown=function(a){this.togglePreviousSuggestion()},c.onEnterKeyPress=function(a){var b=this;b.isDropdownVisible()&&b.selectFromDropdown()},c.onEscapeKeyPress=function(a){var b=this;b.isDropdownVisible()&&b.trigger(q)},c.positionDropdown=function(){var a=this,b=a.containerElement(),c=a.opts(l),d=a.core().wrapElement().outerHeight(),e={};e[c===v?"bottom":"top"]=d+"px",b.css(e)},c.suggestionElements=function(){return this.containerElement().find(h)},c.setSelectedSuggestion=function(b){if(!b)return;var c=this,d=c.suggestionElements(),f=d.first(),h,i;c.clearSelected();for(i=0;i<d.length;i++){h=a(d[i]);if(c.itemManager().compareItems(h.data(g),b)){f=h.addClass(e);break}}f.addClass(e),c.scrollSuggestionIntoView(f)},c.selectedSuggestionElement=function(){return this.suggestionElements().filter(f).first()},c.isDropdownVisible=function(){return this.containerElement().is(":visible")===!0},c.onGetFormData=function(a,b,c){var d=this,e=d.val(),f=e,g=e;b[100]=d.formDataObject(f,g)},c.initPriority=function(){return 200},c.onHideDropdown=function(a){this.hideDropdown()},c.onToggleDropdown=function(a){var b=this;b.trigger(b.containerElement().is(":visible")?q:r)},c.onShowDropdown=function(b,c){var d=this,e=d.selectedSuggestionElement().data(g),f=d._suggestions;if(!f)return d.trigger(s);a.isFunction(c)?c(d):(d.renderSuggestions(d._suggestions),d.toggleNextSuggestion()),d.showDropdown(d.containerElement()),d.setSelectedSuggestion(e)},c.onSetSuggestions=function(a,b){var c=this,d=c._suggestions=b.result;b.showHideDropdown!==!1&&c.trigger(d===null||d.length===0?q:r)},c.getSuggestions=function(){var a=this,b=a.val();if(a._previousInputValue==b)return;b==""&&(current=null),a._previousInputValue=b,a.trigger(s,{query:b})},c.clearItems=function(){this.containerElement().find(".text-list").children().remove()},c.renderSuggestions=function(b){var c=this;c.clearItems(),a.each(b||[],function(a,b){c.addSuggestion(b)})},c.showDropdown=function(){this.containerElement().show()},c.hideDropdown=function(){var a=this,b=a.containerElement();a._previousInputValue=null,b.hide()},c.addSuggestion=function(a){var b=this,c=b.opts(n),d=b.addDropdownItem(c?c.call(b,a):b.itemManager().itemToString(a));d.data(g,a)},c.addDropdownItem=function(b){var c=this,d=c.containerElement().find(".text-list"),e=a(c.opts(p));return e.find(".text-label").html(b),d.append(e),e},c.clearSelected=function(){this.suggestionElements().removeClass(e)},c.toggleNextSuggestion=function(){var a=this,b=a.selectedSuggestionElement(),c;b.length>0?(c=b.next(),c.length>0&&b.removeClass(e)):c=a.suggestionElements().first(),c.addClass(e),a.scrollSuggestionIntoView(c)},c.togglePreviousSuggestion=function(){var a=this,b=a.selectedSuggestionElement(),c=b.prev();if(c.length==0)return;a.clearSelected(),c.addClass(e),a.scrollSuggestionIntoView(c)},c.scrollSuggestionIntoView=function(a){var b=a.outerHeight(),c=this.containerElement(),d=c.innerHeight(),e=c.scrollTop(),f=(a.position()||{}).top,g=null,h=parseInt(c.css("paddingTop"));if(f==null)return;f+b>d&&(g=f+e+b-d+h),f<0&&(g=f+e-h),g!=null&&c.scrollTop(g)},c.selectFromDropdown=function(){var a=this,b=a.selectedSuggestionElement().data(g);b&&(a.val(a.itemManager().itemToString(b)),a.core().getFormData()),a.trigger(q)},c.withinWrapElement=function(a){return this.core().wrapElement().find(a).size()>0}})(jQuery);(function(a){function b(){}a.fn.textext.TextExtFilter=b,a.fn.textext.addPlugin("filter",b);var c=b.prototype,d="filter.enabled",e="filter.items",f={filter:{enabled:!0,items:null}};c.init=function(a){var b=this;b.baseInit(a,f),b.on({getFormData:b.onGetFormData,isTagAllowed:b.onIsTagAllowed,setSuggestions:b.onSetSuggestions}),b._suggestions=null},c.onGetFormData=function(a,b,c){var d=this,e=d.val(),f=e,g="";d.core().hasPlugin("tags")||(d.isValueAllowed(f)&&(g=e),b[300]=d.formDataObject(f,g))},c.isValueAllowed=function(a){var b=this,c=b.opts("filterItems")||b._suggestions||[],e=b.itemManager(),f=!b.opts(d),g;for(g=0;g<c.length&&!f;g++)e.compareItems(a,c[g])&&(f=!0);return f},c.onIsTagAllowed=function(a,b){b.result=this.isValueAllowed(b.tag)},c.onSetSuggestions=function(a,b){this._suggestions=b.result}})(jQuery);(function(a){function b(){}a.fn.textext.TextExtFocus=b,a.fn.textext.addPlugin("focus",b);var c=b.prototype,d="html.focus",e={html:{focus:'<div class="text-focus"/>'}};c.init=function(a){var b=this;b.baseInit(a,e),b.core().wrapElement().append(b.opts(d)),b.on({blur:b.onBlur,focus:b.onFocus}),b._timeoutId=0},c.onBlur=function(a){var b=this;clearTimeout(b._timeoutId),b._timeoutId=setTimeout(function(){b.getFocus().hide()},100)},c.onFocus=function(a){var b=this;clearTimeout(b._timeoutId),b.getFocus().show()},c.getFocus=function(){return this.core().wrapElement().find(".text-focus")}})(jQuery);(function(a){function b(){}a.fn.textext.TextExtPrompt=b,a.fn.textext.addPlugin("prompt",b);var c=b.prototype,d="text-hide-prompt",e="prompt",f="html.prompt",g={prompt:"Awaiting input...",html:{prompt:'<div class="text-prompt"/>'}};c.init=function(b){var c=this,d="placeholder",h,i;c.baseInit(b,g),h=a(c.opts(f)),a(c).data("container",h),c.core().wrapElement().append(h),c.setPrompt(c.opts(e)),i=b.input().attr(d),i||(i=c.opts(e)),b.input().attr(d,""),i&&c.setPrompt(i),a.trim(c.val()).length>0&&c.hidePrompt(),c.on({blur:c.onBlur,focus:c.onFocus,postInvalidate:c.onPostInvalidate,postInit:c.onPostInit})},c.onPostInit=function(a){this.invalidateBounds()},c.onPostInvalidate=function(a){this.invalidateBounds()},c.invalidateBounds=function(){var a=this,b=a.input();a.containerElement().css({paddingLeft:b.css("paddingLeft"),paddingTop:b.css("paddingTop")})},c.onBlur=function(a){var b=this;b.startTimer("prompt",.1,function(){b.showPrompt()})},c.showPrompt=function(){var b=this,c=b.input();a.trim(b.val()).length===0&&!c.is(":focus")&&b.containerElement().removeClass(d)},c.hidePrompt=function(){this.stopTimer("prompt"),this.containerElement().addClass(d)},c.onFocus=function(a){this.hidePrompt()},c.setPrompt=function(a){this.containerElement().text(a)},c.containerElement=function(){return a(this).data("container")}})(jQuery);(function(a){function b(){}a.fn.textext.TextExtSuggestions=b,a.fn.textext.addPlugin("suggestions",b);var c=b.prototype,d="suggestions",e={suggestions:null};c.init=function(a){var b=this;b.baseInit(a,e),b.on({getSuggestions:b.onGetSuggestions,postInit:b.onPostInit})},c.setSuggestions=function(a,b){this.trigger("setSuggestions",{result:a,showHideDropdown:b!=0})},c.onPostInit=function(a){var b=this;b.setSuggestions(b.opts(d),!1)},c.onGetSuggestions=function(a,b){var c=this,e=c.opts(d);e.sort(),c.setSuggestions(c.itemManager().filter(e,b.query))}})(jQuery);(function(a){function b(){}a.fn.textext.TextExtTags=b,a.fn.textext.addPlugin("tags",b);var c=b.prototype,d=".",e="text-tags-on-top",f=d+e,g="text-tag",h=d+g,i="text-tags",j=d+i,k="text-label",l=d+k,m="text-remove",n=d+m,o="tags.enabled",p="tags.items",q="html.tag",r="html.tags",s="isTagAllowed",t="tagClick",u={tags:{enabled:!0,items:null},html:{tags:'<div class="text-tags"/>',tag:'<div class="text-tag"><div class="text-button"><span class="text-label"/><a class="text-remove"/></div></div>'}};c.init=function(b){this.baseInit(b,u);var c=this,d=c.input(),e;c.opts(o)&&(e=a(c.opts(r)),d.after(e),a(c).data("container",e),c.on({enterKeyPress:c.onEnterKeyPress,backspaceKeyDown:c.onBackspaceKeyDown,preInvalidate:c.onPreInvalidate,postInit:c.onPostInit,getFormData:c.onGetFormData}),c.on(e,{click:c.onClick,mousemove:c.onContainerMouseMove}),c.on(d,{mousemove:c.onInputMouseMove})),c._originalPadding={left:parseInt(d.css("paddingLeft")||0),top:parseInt(d.css("paddingTop")||0)},c._paddingBox={left:0,top:0},c.updateFormCache()},c.containerElement=function(){return a(this).data("container")},c.onPostInit=function(a){var b=this;b.addTags(b.opts(p))},c.onGetFormData=function(a,b,c){var d=this,e=c===13?"":d.val(),f=d._formData;b[200]=d.formDataObject(e,f)},c.initPriority=function(){return 100},c.onInputMouseMove=function(a){this.toggleZIndex(a)},c.onContainerMouseMove=function(a){this.toggleZIndex(a)},c.onBackspaceKeyDown=function(a){var b=this,c=b.tagElements().last();b.val().length==0&&b.removeTag(c)},c.onPreInvalidate=function(a){var b=this,c=b.tagElements().last(),d=c.position();c.length>0?d.left+=c.innerWidth():d=b._originalPadding,b._paddingBox=d,b.input().css({paddingLeft:d.left,paddingTop:d.top})},c.onClick=function(b){function k(a,b){i.data(g,a),i.find(l).text(c.itemManager().itemToString(a)),c.updateFormCache(),d.getFormData(),d.invalidateBounds(),b&&d.focusInput()}var c=this,d=c.core(),e=a(b.target),f=0,i;e.is(j)?f=1:e.is(n)?(c.removeTag(e.parents(h+":first")),f=1):e.is(l)&&(i=e.parents(h+":first"),c.trigger(t,i,i.data(g),k)),f&&d.focusInput()},c.onEnterKeyPress=function(a){var b=this,c=b.val(),d=b.itemManager().stringToItem(c);b.isTagAllowed(d)&&(b.addTags([d]),b.core().focusInput())},c.updateFormCache=function(){var b=this,c=[];b.tagElements().each(function(){c.push(a(this).data(g))}),b._formData=c},c.toggleZIndex=function(a){var b=this,c=b.input().offset(),d=a.clientX-c.left,g=a.clientY-c.top,h=b._paddingBox,i=b.containerElement(),j=i.is(f),k=d>h.left&&g>h.top;(!j&&!k||j&&k)&&i[(j?"remove":"add")+"Class"](e)},c.tagElements=function(){return this.containerElement().find(h)},c.isTagAllowed=function(a){var b={tag:a,result:!0};return this.trigger(s,b),b.result===!0},c.addTags=function(a){if(!a||a.length==0)return;var b=this,c=b.core(),d=b.containerElement(),e,f;for(e=0;e<a.length;e++)f=a[e],f&&b.isTagAllowed(f)&&d.append(b.renderTag(f));b.updateFormCache(),c.getFormData(),c.invalidateBounds()},c.getTagElement=function(b){var c=this,d=c.tagElements(),e,f;for(e=0;e<d.length,f=a(d[e]);e++)if(c.itemManager().compareItems(f.data(g),b))return f},c.removeTag=function(b){var c=this,d=c.core(),e;b instanceof a?(e=b,b=b.data(g)):e=c.getTagElement(b),e.remove(),c.updateFormCache(),d.getFormData(),d.invalidateBounds()},c.renderTag=function(b){var c=this,d=a(c.opts(q));return d.find(".text-label").text(c.itemManager().itemToString(b)),d.data(g,b),d}})(jQuery);(function(a){var b=document,c="getElementsByTagName",d=b[c]("head")[0]||b[c]("body")[0],e=b.createElement("style");e.innerHTML=a,d.appendChild(e)})('\n.text-core{position:relative;}\n.text-core .text-wrap{background:#fff;position:absolute;}\n.text-core .text-wrap textarea,.text-core .text-wrap input{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-border-radius:0px;-moz-border-radius:0px;border-radius:0px;border:1px solid #9daccc;outline:none;resize:none;position:absolute;z-index:1;background:none;overflow:hidden;margin:0;padding:3px 5px 4px 5px;white-space:nowrap;font:11px "lucida grande",tahoma,verdana,arial,sans-serif;line-height:13px;height:auto;}\n\n.text-core .text-wrap .text-arrow{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;top:0;right:0;width:22px;height:22px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAOAQMAAADHWqTrAAAAA3NCSVQICAjb4U/gAAAABlBMVEX///8yXJnt8Ns4AAAACXBIWXMAAAsSAAALEgHS3X78AAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1MzmNZGAwAAABpJREFUCJljYEAF/xsY6hkY7BgYZBgYOFBkADkdAmFDagYFAAAAAElFTkSuQmCC") 50% 50% no-repeat;cursor:pointer;z-index:2;}\n\n.text-core .text-wrap .text-dropdown{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0;position:absolute;z-index:3;background:#fff;border:1px solid #9daccc;width:100%;max-height:100px;padding:1px;font:11px "lucida grande",tahoma,verdana,arial,sans-serif;display:none;overflow-x:hidden;overflow-y:auto;}\n.text-core .text-wrap .text-dropdown.text-position-below{margin-top:1px;}\n.text-core .text-wrap .text-dropdown.text-position-above{margin-bottom:1px;}\n.text-core .text-wrap .text-dropdown .text-list .text-suggestion{padding:3px 5px;cursor:pointer;}\n.text-core .text-wrap .text-dropdown .text-list .text-suggestion em{font-style:normal;text-decoration:underline;}\n.text-core .text-wrap .text-dropdown .text-list .text-suggestion.text-selected{color:#fff;background:#6d84b4;}\n\n.text-core .text-wrap .text-focus{-webkit-box-shadow:0px 0px 6px #6d84b4;-moz-box-shadow:0px 0px 6px #6d84b4;box-shadow:0px 0px 6px #6d84b4;position:absolute;width:100%;height:100%;display:none;}\n.text-core .text-wrap .text-focus.text-show-focus{display:block;}\n\n.text-core .text-wrap .text-prompt{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;width:100%;height:100%;margin:1px 0 0 2px;font:11px "lucida grande",tahoma,verdana,arial,sans-serif;color:#c0c0c0;overflow:hidden;white-space:pre;}\n.text-core .text-wrap .text-prompt.text-hide-prompt{display:none;}\n\n.text-core .text-wrap .text-tags{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;width:100%;height:100%;padding:3px 35px 3px 3px;cursor:text;}\n.text-core .text-wrap .text-tags.text-tags-on-top{z-index:2;}\n.text-core .text-wrap .text-tags .text-tag{float:left;}\n.text-core .text-wrap .text-tags .text-tag .text-button{-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:relative;float:left;border:1px solid #9daccc;background:#e2e6f0;color:#000;padding:0px 17px 0px 3px;margin:0 2px 2px 0;cursor:pointer;height:16px;font:11px "lucida grande",tahoma,verdana,arial,sans-serif;}\n.text-core .text-wrap .text-tags .text-tag .text-button a.text-remove{position:absolute;right:3px;top:2px;display:block;width:11px;height:11px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAhCAYAAAAPm1F2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAAB50RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNS4xqx9I6wAAAQ5JREFUOI2dlD0WwiAQhCc8L6HHgAPoASwtSYvX8BrQxtIyveYA8RppLO1jE+LwE8lzms2yH8MCj1QoaBzH+VuUYNYMS213UlvDRamtUbXb5ZyPHuDoxwGgip3ipfvGuGzPz+vZ/coDONdzFuYCO6ramQQG0DJIE1oPBBvM6e9LqaS2FwD7FWwnVoIAsOc2Xn1jDlyd8pfPBRVOBHA8cc/3yCmQqt0jcY4LuTyAF3pOYS6wI48LAm4MUrx5JthgSQJAt5LtNgAUgEMBBIC3AL2xgo58dEPfhE9wygef89FtCeC49UwltR1pQrK2qr9vNr7uRTCBF3pOYS6wI4/zdQ8MUpxPI9hgSQL0Xyio/QBt54DzsHQx6gAAAABJRU5ErkJggg==") 0 0 no-repeat;}\n.text-core .text-wrap .text-tags .text-tag .text-button a.text-remove:hover{background-position:0 -11px;}\n.text-core .text-wrap .text-tags .text-tag .text-button a.text-remove:active{background-position:0 -22px;}\n');
View
2  phantomweb/templates/base.html
@@ -14,7 +14,7 @@
<link rel="top" title="Nimbus v1.0 documentation" href="#" />
- <script src="http://code.jquery.com/jquery-1.4.3.js"></script>
+ <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://www.nimbusproject.org/js/jquery.corner.js"></script>
{% block headscripts %}{% endblock %}
View
11 phantomweb/templates/phantom_domain.html
@@ -11,6 +11,7 @@
// -->
</script>
+ <script src="/static/js/bootstrap-tagmanager.js"></script>
<script src="/static/js/phantom_common.js"></script>
<script src="/static/js/phantom_domain.js"></script>
{% endblock %}
@@ -46,12 +47,17 @@
<label class="phantom_area_header">Configuration for <span id="phantom_domain_name_label"></span></label>
<div class="phantom_domain_section_div phantom_domain_row" >
- <label class="phantom_domain_label" id="phantom_domain_lc_div">Launch Configuration</label>
+ <label class="phantom_domain_label" id="phantom_domain_lc_div">Launch Configuration:</label>
<select id="phantom_domain_lc_choice" class="phantom_domain_value phantom_domain_combo">
</select>
</div>
<div class="phantom_domain_section_div phantom_domain_row" >
+ <label class="phantom_domain_label" id="phantom_domain_sensors_label">Sensors to Monitor:</label>
+ <input name="tags" id="phantom_domain_sensors_input" placeholder="Add Sensor"></input>
+ </div>
+
+ <div class="phantom_domain_section_div phantom_domain_row" >
<label class="phantom_domain_label" id="phantom_domain_de_div">Decision Engine:</label>
<select id="phantom_domain_de_choice" class="phantom_domain_value phantom_domain_combo">
</select>
@@ -64,7 +70,8 @@
<div class="phantom_domain_de_pref phantom_domain_section_div phantom_domain_row" id="phantom_domain_sensor_preferences">
<label for="phantom_domain_metric_input" class="phantom_domain_label">Metric:</label>
- <input type='text' id="phantom_domain_metric_input" class="phantom_domain_value"/>
+ <select id="phantom_domain_metric_choice" class="phantom_domain_value phantom_domain_combo"></select>
+ <!--<input type='text' id="phantom_domain_metric_input" class="phantom_domain_value"/>-->
<label for="phantom_domain_cooldown_input" class="phantom_domain_label">Cooldown (s):</label>
<input type='text' id="phantom_domain_cooldown_input" class="phantom_domain_value"/>
View
40 phantomweb/workload.py
@@ -95,6 +95,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['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')
@@ -128,6 +129,9 @@ def sensor_tags_from_de_params(phantom_con, domain_name, de_params):
metric_key = 'metric'
metric = de_params.get('sensor_metric')
+ monitor_sensors_key = 'monitor_sensors'
+ monitor_sensors = de_params.get('monitor_sensors', '')
+
cooldown_key = 'cooldown_period'
cooldown = de_params.get('sensor_cooldown')
scale_up_threshold_key = 'scale_up_threshold'
@@ -146,6 +150,7 @@ def sensor_tags_from_de_params(phantom_con, domain_name, de_params):
sensor_type = 'cloudwatch'
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)
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)
@@ -157,6 +162,7 @@ def sensor_tags_from_de_params(phantom_con, domain_name, de_params):
tags = []
tags.append(policy_tag)
tags.append(metric_tag)
+ tags.append(monitor_sensors_tag)
tags.append(sample_function_tag)
tags.append(sensor_type_tag)
tags.append(cooldown_tag)
@@ -189,34 +195,22 @@ def _start_domain(phantom_con, domain_name, lc_name, de_name, de_params, host_li
ordered_clouds_key = 'clouds'
n_preserve_key = 'n_preserve'
n_preserve = de_params.get('vm_count')
+ monitor_sensors_key = 'monitor_sensors'
+ monitor_sensors = de_params.get('monitor_sensors', '')
policy_tag = Tag(connection=phantom_con, key=policy_name_key, value=policy_name, resource_id=domain_name)
clouds_tag = Tag(connection=phantom_con, key=ordered_clouds_key, value=host_list_str, resource_id=domain_name)
npreserve_tag = Tag(connection=phantom_con, key=n_preserve_key, value=n_preserve, resource_id=domain_name)
+ monitor_sensors_tag = Tag(connection=phantom_con, key=monitor_sensors_key, value=monitor_sensors, resource_id=domain_name)
tags.append(policy_tag)
tags.append(clouds_tag)
tags.append(npreserve_tag)
+ tags.append(monitor_sensors_tag)
min_size = de_params.get('vm_count')
max_size = de_params.get('vm_count')
- # TODO: This is hardcoded for this sync, should be exposed in the UI
- metric_key = 'metric'
- metric = 'CPUUtilization'
- sample_function_key = 'sample_function'
- sample_function = 'Average'
- sensor_type_key = 'sensor_type'
- sensor_type = 'cloudwatch'
-
- metric_tag = Tag(connection=phantom_con, key=metric_key, value=metric, 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(metric_tag)
- tags.append(sample_function_tag)
- tags.append(sensor_type_tag)
-
elif de_name == 'sensor':
min_size = de_params.get('sensor_minimum_vms')
@@ -564,7 +558,7 @@ def phantom_domain_start(request_params, userobj):
"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"]
+ mandatory_params = ['name', "lc_name", "de_name", "monitor_sensors"]
for p in mandatory_params:
if p not in request_params:
raise PhantomWebException('Missing parameter %s' % (p))
@@ -573,6 +567,7 @@ def phantom_domain_start(request_params, userobj):
de_name = request_params["de_name"]
de_params = {}
+ de_params["monitor_sensors"] = request_params["monitor_sensors"];
if de_name == "sensor":
for p in sensor_params:
if p not in request_params:
@@ -593,7 +588,8 @@ def phantom_domain_start(request_params, userobj):
g_general_log.debug("%s not in %s" % (p, request_params))
raise PhantomWebException('Missing parameter %s' % (p))
- de_params["vm_count"] = request_params["vm_count"]
+
+ g_general_log.info("starting with params: %s" % de_params)
lc_db_object = LaunchConfigurationDB.objects.filter(name=lc_name, username=userobj._user_dbobject.access_key)
if not lc_db_object or len(lc_db_object) < 1:
@@ -627,7 +623,7 @@ def phantom_domain_resize(request_params, userobj):
"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"]
+ mandatory_params = ["name", "de_name", "monitor_sensors"]
for p in mandatory_params:
if p not in request_params:
raise PhantomWebException('Missing parameter %s' % (p))
@@ -635,8 +631,8 @@ def phantom_domain_resize(request_params, userobj):
de_name = request_params["de_name"]
de_params = {}
+ de_params["monitor_sensors"] = request_params["monitor_sensors"];
if de_name == "sensor":
- g_general_log.debug("PDA: updating sensor")
for p in sensor_params:
if p not in request_params:
raise PhantomWebException('Missing parameter %s' % (p))
@@ -651,7 +647,6 @@ def phantom_domain_resize(request_params, userobj):
de_params["sensor_scale_down_vms"] = request_params["sensor_scale_down_vms"]
elif de_name == "multicloud":
- g_general_log.debug("PDA: updating multicloud")
for p in multicloud_params:
if p not in request_params:
g_general_log.debug("%s not in %s" % (p, request_params))
@@ -763,9 +758,8 @@ def phantom_domain_details(request_params, userobj):
metrics = userobj.describe_domain(userobj._user_dbobject.access_key, domain_name)
instance_metrics = {}
if metrics is not None:
- metric = metrics.get('config', {}).get('engine_conf', {}).get('metric')
for instance in metrics.get('instances', []):
- instance_metrics[instance.get('iaas_id')] = metric, instance.get('sensor_data')
+ instance_metrics[instance.get('iaas_id')] = '', instance.get('sensor_data')
inst_list = []
for instance in asg.instances:

0 comments on commit 24e861c

Please sign in to comment.
Something went wrong with that request. Please try again.