Please confirm you enable maintenance for host: "+sanitizeXSS(hostName)+". Enabling maintenance mode will cause a live migration of all running instances on this host to any available host. An alert will be sent to the admin when this process has been completed.
") .dialog('option', 'buttons', { "Confirm": function() { $(this).dialog("close"); $.ajax({ data: createURL("command=prepareHostForMaintenance&id="+hostId+"&response=json"), dataType: "json", success: function(json) { template.find(".row_loading").show(); template.find(".loading_animationcontainer .loading_animationtext").text("Preparing..."); template.find(".loading_animationcontainer").show(); template.fadeIn("slow"); var that = template; template.find(".continue_button").data("hostId", hostId).unbind("click").bind("click", function(event) { that.find(".loading_animationcontainer").hide(); that.find(".loadingmessage_container").fadeOut("slow"); that.find(".row_loading").fadeOut("slow"); // Host status is likely to change at this point. So, refresh the row now. $.ajax({ data: createURL("command=listHosts&id="+hostId+"&response=json"), dataType: "json", success: function(json) { routingJSONToTemplate(json.listhostsresponse.host[0], that); } }); return false; }); var timerKey = "host"+hostId; $("body").everyTime( 15000, // Migration could possibly take a while timerKey, function() { $.ajax({ data: createURL("command=queryAsyncJobResult&jobId="+json.preparehostformaintenanceresponse.jobid+"&response=json"), dataType: "json", success: function(json) { var result = json.queryasyncjobresultresponse; if (result.jobstatus == 0) { return; //Job has not completed } else { $("body").stopTime(timerKey); if (result.jobstatus == 1) { // Succeeded routingStateToTemplate(result.host[0].state, template); template.find("#routing_disconnected").text(result.host[0].disconnected); template.find(".loadingmessage_container .loadingmessage_top p").html("We are actively enabling maintenance on your host. Please refresh periodically for an updated status."); template.find(".loadingmessage_container").fadeIn("slow"); } else if (result.jobstatus == 2) { // Failed routingStateToTemplate(result.host[0].state, template); template.find(".loadingmessage_container .loadingmessage_top p").text("We were unable to successfully prepare your host for maintenance. Please check your logs for more info."); template.find(".loadingmessage_container").fadeIn("slow"); } } }, error: function(XMLHttpResponse) { $("body").stopTime(timerKey); handleError(XMLHttpResponse); } }); }, 0 ); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); break; case "host_action_cancel_maint" : $("#dialog_confirmation") .html("Please confirm you want to cancel maintenance for host: "+sanitizeXSS(hostName)+".
") .dialog('option', 'buttons', { "Confirm": function() { $(this).dialog("close"); $.ajax({ data: createURL("command=cancelHostMaintenance&id="+hostId+"&response=json"), dataType: "json", success: function(json) { template.find(".row_loading").show(); template.find(".loading_animationcontainer .loading_animationtext").text("Cancelling..."); template.find(".loading_animationcontainer").show(); template.fadeIn("slow"); var that = template; template.find(".continue_button").data("hostId", hostId).unbind("click").bind("click", function(event) { that.find(".loading_animationcontainer").hide(); that.find(".loadingmessage_container").fadeOut("slow"); that.find(".row_loading").fadeOut("slow"); // Host status is likely to change at this point. So, refresh the row now. $.ajax({ data: createURL("command=listHosts&id="+hostId+"&response=json"), dataType: "json", success: function(json) { routingJSONToTemplate(json.listhostsresponse.host[0], that); } }); return false; }); var timerKey = "host"+hostId; $("body").everyTime( 5000, timerKey, function() { $.ajax({ data: createURL("command=queryAsyncJobResult&jobId="+json.cancelhostmaintenanceresponse.jobid+"&response=json"), dataType: "json", success: function(json) { var result = json.queryasyncjobresultresponse; if (result.jobstatus == 0) { return; //Job has not completed } else { $("body").stopTime(timerKey); if (result.jobstatus == 1) { // Succeeded routingStateToTemplate(result.host[0].state, template); //result.host[0].status == "ErrorInMaintenance" template.find("#routing_disconnected").text(result.host[0].disconnected); template.find(".loadingmessage_container .loadingmessage_top p").html("We are actively cancelling your scheduled maintenance. Please refresh periodically for an updated status."); template.find(".loadingmessage_container").fadeIn("slow"); } else if (result.jobstatus == 2) { // Failed routingStateToTemplate(result.host[0].state, template); template.find(".loadingmessage_container .loadingmessage_top p").text("We were unable to cancel your maintenance process. Please try again."); template.find(".loadingmessage_container").fadeIn("slow"); } } }, error: function(XMLHttpResponse) { $("body").stopTime(timerKey); template.find(".loading_animationcontainer").hide(); handleError(XMLHttpResponse); } }); }, 0 ); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); break; case "host_action_reconnect" : $("#dialog_confirmation") .html("Please confirm you want to force a reconnection for host: "+sanitizeXSS(hostName)+".
") .dialog('option', 'buttons', { "Confirm": function() { $(this).dialog("close"); $.ajax({ data: createURL("command=reconnectHost&id="+hostId+"&response=json"), dataType: "json", success: function(json) { template.find(".row_loading").show(); template.find(".loading_animationcontainer .loading_animationtext").text("Reconnecting..."); template.find(".loading_animationcontainer").show(); template.fadeIn("slow"); var that = template; template.find(".continue_button").data("hostId", hostId).unbind("click").bind("click", function(event) { that.find(".loading_animationcontainer").hide(); that.find(".loadingmessage_container").fadeOut("slow"); that.find(".row_loading").fadeOut("slow"); // Host status is likely to change at this point. So, refresh the row now. $.ajax({ data: createURL("command=listHosts&id="+hostId+"&response=json"), dataType: "json", success: function(json) { routingJSONToTemplate(json.listhostsresponse.host[0], that); } }); return false; }); var timerKey = "host"+hostId; $("body").everyTime( 5000, timerKey, function() { $.ajax({ data: createURL("command=queryAsyncJobResult&jobId="+json.reconnecthostresponse.jobid+"&response=json"), dataType: "json", success: function(json) { var result = json.queryasyncjobresultresponse; if (result.jobstatus == 0) { return; //Job has not completed } else { $("body").stopTime(timerKey); if (result.jobstatus == 1) { // Succeeded routingStateToTemplate(result.host[0].state, template); template.find("#routing_disconnected").text(result.host[0].disconnected); template.find(".loadingmessage_container .loadingmessage_top p").html("We are actively reconnecting your host. Please refresh periodically for an updated status."); template.find(".loadingmessage_container").fadeIn("slow"); } else if (result.jobstatus == 2) { // Failed routingStateToTemplate(result.host[0].state, template); template.find(".loadingmessage_container .loadingmessage_top p").text("We were unable to reconnect your host. Please try again."); template.find(".loadingmessage_container").fadeIn("slow"); } } }, error: function(XMLHttpResponse) { $("body").stopTime(timerKey); handleError(XMLHttpResponse); } }); }, 0 ); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); break; case "host_action_remove" : $("#dialog_confirmation") .html("Please confirm you want to remove this host: "+sanitizeXSS(hostName)+" from the management server.
") .dialog('option', 'buttons', { "Confirm": function() { $(this).dialog("close"); $.ajax({ data: createURL("command=deleteHost&id="+hostId+"&response=json"), dataType: "json", success: function(json) { template.slideUp("slow", function() { $(this).remove(); changeGridRowsTotal(submenuContent.find("#grid_rows_total"), -1); }); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); break; case "host_action_update_os" : $("#dialog_update_os #host_os").val(template.data("osId")); $("#dialog_update_os") .dialog('option', 'buttons', { "Update": function() { $(this).dialog("close"); var osId = $("#dialog_update_os #host_os").val(); var osName = $("#dialog_update_os #host_os option:selected").text(); var category = ""; if (osId.length > 0) { category = "&osCategoryId="+osId; } $.ajax({ data: createURL("command=updateHost&id="+hostId+category+"&response=json"), dataType: "json", success: function(json) { template.find("#routing_os").text(osName); template.data("osId", osId); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); break; default : break; } return false; }); // FUNCTION: Routing JSON to Template function routingJSONToTemplate(json, template) { template.attr("id", "host"+json.id); if (index++ % 2 == 0) { template.find("#row_container").addClass("row_even"); } else { template.find("#row_container").addClass("row_odd"); } template.data("hostId", json.id).data("hostName", sanitizeXSS(json.name)); template.find("#routing_zone").text(json.zonename); template.find("#routing_pod").text(json.podname); template.find("#routing_cluster").text(json.clustername); template.find("#routing_name").text(json.name); template.find("#routing_ipaddress").text(json.ipaddress); template.find("#routing_version").text(json.version); template.find("#routing_os").text(json.oscategoryname); template.data("osId", json.oscategoryid); setDateField(json.disconnected, template.find("#routing_disconnected")); var spaceCharacter = " " var statHtml = "CPU Total: " + ((json.cpunumber==null)? spaceCharacter:json.cpunumber) + " x " + ((json.cpuspeed==null)? spaceCharacter:convertHz(json.cpuspeed))+" | CPU Allocated: " + ((json.cpuallocated==null)? spaceCharacter:json.cpuallocated) + " | CPU Used: " + ((json.cpuused==null)? spaceCharacter:json.cpuused) + "
"; template.find("#host_cpu_stat").html(statHtml); statHtml = "MEM Total: " + ((json.memorytotal==null)? spaceCharacter:convertBytes(json.memorytotal))+" | MEM Allocated: " + ((json.memoryallocated==null)? spaceCharacter:convertBytes(json.memoryallocated)) + " | MEM Used: " + ((json.memoryused==null)? spaceCharacter:convertBytes(json.memoryused)) + "
"; template.find("#host_mem_stat").html(statHtml); statHtml = "Network Read: " + ((json.networkkbsread==null)? spaceCharacter:convertBytes(json.networkkbsread * 1024))+" | Network Write: " + ((json.networkkbswrite==null)? spaceCharacter:convertBytes(json.networkkbswrite * 1024)) + "
"; template.find("#host_network_stat").html(statHtml); routingStateToTemplate(json.state, template); } function routingStateToTemplate(state, template) { template.find(".grid_links").find("#host_action_reconnect_container, #host_action_enable_maint_container, #host_action_cancel_maint_container, #host_action_remove_container, #host_action_update_os_container").show(); if (state == 'Up' || state == "Connecting") { template.find("#host_state_bar").removeClass("yellow_statusbar grey_statusbar red_statusbar").addClass("green_statusbar "); template.find("#routing_state").text(state).removeClass("grid_celltitles grid_stoppedtitles").addClass("grid_runningtitles"); template.find(".grid_links").find("#host_action_cancel_maint_container, #host_action_remove_container").hide(); } else if (state == 'Down' || state == "Alert") { template.find("#host_state_bar").removeClass("yellow_statusbar grey_statusbar green_statusbar").addClass("red_statusbar"); template.find("#routing_state").text(state).removeClass("grid_celltitles grid_runningtitles").addClass("grid_stoppedtitles"); if (state == "Alert") { template.find(".grid_links").find("#host_action_reconnect_container, #host_action_enable_maint_container, #host_action_cancel_maint_container, #host_action_remove_container").hide(); } else { template.find(".grid_links").find("#host_action_reconnect_container, #host_action_cancel_maint_container").hide(); } } else { template.find("#host_state_bar").removeClass("yellow_statusbar green_statusbar red_statusbar").addClass("grey_statusbar"); template.find("#routing_state").text(state).removeClass("grid_runningtitles grid_stoppedtitles").addClass("grid_celltitles "); if (state == "ErrorInMaintenance") { template.find(".grid_links").find("#host_action_reconnect_container, #host_action_remove_container").hide(); } else if (state == "PrepareForMaintenance") { template.find(".grid_links").find("#host_action_reconnect_container, #host_action_enable_maint_container, #host_action_remove_container").hide(); } else if (state == "Maintenance") { template.find(".grid_links").find("#host_action_reconnect_container, #host_action_enable_maint_container").hide(); } else if (state == "Disconnected") { template.find(".grid_links").find("#host_action_reconnect_container, #host_action_enable_maint_container, #host_action_cancel_maint_container, #host_action_remove_container").hide(); } else { alert("Unsupported Host State: " + state); } } } var submenuContent = $("#submenu_content_routing"); // Add New Routing Host $("#host_action_new_routing").bind("click", function(event) { dialogAddRouting.find("#new_cluster_name").val(""); dialogAddRouting.find("#host_zone").change(); //refresh cluster dropdown dialogAddRouting .dialog('option', 'buttons', { "Add": function() { var dialogBox = $(this); var clusterRadio = dialogBox.find("input[name=cluster]:checked").val(); // validate values var isValid = true; isValid &= validateString("Host name", dialogBox.find("#host_hostname"), dialogBox.find("#host_hostname_errormsg")); isValid &= validateString("User name", dialogBox.find("#host_username"), dialogBox.find("#host_username_errormsg")); isValid &= validateString("Password", dialogBox.find("#host_password"), dialogBox.find("#host_password_errormsg")); if(clusterRadio == "new_cluster_radio") isValid &= validateString("Cluster name", dialogBox.find("#new_cluster_name"), dialogBox.find("#new_cluster_name_errormsg")); if (!isValid) return; var array1 = []; var zoneId = dialogBox.find("#host_zone").val(); array1.push("&zoneId="+zoneId); var podId = dialogBox.find("#host_pod").val(); array1.push("&podId="+podId); var username = trim(dialogBox.find("#host_username").val()); array1.push("&username="+encodeURIComponent(username)); var password = trim(dialogBox.find("#host_password").val()); array1.push("&password="+encodeURIComponent(password)); //xenserver supports cluster. kvm doesn't support cluster. if (getHypervisorType() != "kvm") { if(clusterRadio == "new_cluster_radio") { var newClusterName = trim(dialogBox.find("#new_cluster_name").val()); array1.push("&clustername="+encodeURIComponent(newClusterName)); } else if(clusterRadio == "existing_cluster_radio") { var clusterId = dialogBox.find("#cluster_select").val(); // We will default to no cluster if someone selects Join Cluster with no cluster available. if (clusterId != '-1') { array1.push("&clusterid="+clusterId); } } } var hostname = trim(dialogBox.find("#host_hostname").val()); var url; if(hostname.indexOf("http://")==-1) url = "http://" + hostname; else url = hostname; array1.push("&url="+encodeURIComponent(url)); var template = $("#routing_template").clone(true); var loadingImg = template.find(".adding_loading"); var rowContainer = template.find("#row_container"); loadingImg.find(".adding_text").text("Adding...."); loadingImg.show(); rowContainer.hide(); submenuContent.find("#grid_content").append(template.fadeIn("slow")); dialogBox.dialog("close"); $.ajax({ data: createURL("command=addHost&response=json" + array1.join("")), dataType: "json", success: function(json) { var items = json.addhostresponse.host; routingJSONToTemplate(items[0], template); loadingImg.hide(); rowContainer.show(); changeGridRowsTotal(submenuContent.find("#grid_rows_total"), 1); if(items.length > 1) { for(var i=1; i