/**
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
" + sanitizeXSS(result.jobresult) + "
").dialog("open"); template.slideUp("slow", function() { $(this).remove(); }); } } }, error: function(XMLHttpResponse) { $("body").stopTime(timerKey); handleError(XMLHttpResponse); template.slideUp("slow", function() { $(this).remove(); }); } }); }, 0); }, error: function(XMLHttpResponse) { handleError(XMLHttpResponse); template.slideUp("slow", function() { $(this).remove(); }); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); return false; }); // Add Volume Dialog (end) activateDialog($("#dialog_add_volume_from_snapshot").dialog({ autoOpen: false, modal: true, zIndex: 2000 })); activateDialog($("#dialog_create_template_from_snapshot").dialog({ width: 400, autoOpen: false, modal: true, zIndex: 2000 })); function hideShowDetachAttachLinks(vmname, template) { var detachLink = template.find("#volume_action_detach_span"); var attachLink = template.find("#volume_action_attach_span"); if (vmname=="none"||vmname==""||vmname==null) { //if NOT attached to a virtual machine, hide "detach" link, show "attach" link. detachLink.hide(); attachLink.show(); } else { //if attached to a virtual machine, hide "attach" link, show "ditach" link. attachLink.hide(); detachLink.show(); } } // FUNCTION: volume JSON to Template function volumeJSONToTemplate(json, template) { template.attr("id", "volume"+json.id); if (index++ % 2 == 0) { template.addClass("smallrow_even"); } else { template.addClass("smallrow_odd"); } template.data("volumeId", json.id); template.data("vmname", getVmName(json.vmname, json.vmdisplayname)); template.data("vmstate", json.vmstate); template.data("domainId", json.domainid); template.data("account", sanitizeXSS(json.account)); template.data("volumeName", sanitizeXSS(json.name)); template.data("vmid", json.virtualmachineid); template.data("zoneId", json.zoneid); template.find("#volume_id").text(noNull(json.id)); template.find("#volume_name").text(noNull(json.name)); template.find("#volume_zone").text(noNull(json.zonename)); template.find("#volume_account").text(noNull(json.account)); template.find("#volume_deviceid").text(noNull(json.deviceid)); template.find("#volume_domain").text(noNull(json.domain)); template.find("#volume_hostname").text(noNull(json.storage)); template.find("#volume_path").text(noNull(json.path)); template.find("#volume_state").text(noNull(json.state)); template.find("#volume_size").text((json.size == "0") ? "" : convertBytes(json.size)); template.find("#volume_type").text(noNull(json.type) + " (" + noNull(json.storagetype) + " storage)"); if (json.virtualmachineid == null) { template.find("#volume_vmname").text("detached"); } else { template.find("#volume_vmname").text(getVmName(json.vmname, json.vmdisplayname) + " (" + json.vmstate + ")"); } setDateField(json.created, template.find("#volume_created")); if(json.type=="ROOT") { } else { // DataDisk if (json.virtualmachineid != undefined) { if (json.storagetype == "shared" && (json.vmstate == "Running" || json.vmstate == "Stopped")) { template.find("#volume_action_detach_span").show(); } } else { // Disk not attached if (json.storagetype == "shared") { template.find("#volume_action_attach_span, #volume_action_delete_span").show(); } } } if(json.state == "Creating" || json.state == "Corrupted" || json.name == "attaching") template.find("#grid_links_container").hide(); else template.find("#grid_links_container").show(); } function listVolumes() { var submenuContent = $("#submenu_content_volume"); var commandString; var advanced = submenuContent.find("#search_button").data("advanced"); if (advanced != null && advanced) { var name = submenuContent.find("#advanced_search #adv_search_name").val(); var zone = submenuContent.find("#advanced_search #adv_search_zone").val(); var pod = submenuContent.find("#advanced_search #adv_search_pod").val(); var domainId = submenuContent.find("#advanced_search #adv_search_domain").val(); var account = submenuContent.find("#advanced_search #adv_search_account").val(); var moreCriteria = []; if (name!=null && trim(name).length > 0) moreCriteria.push("&name="+encodeURIComponent(trim(name))); if (zone!=null && zone.length > 0) moreCriteria.push("&zoneId="+zone); if (pod!=null && pod.length > 0) moreCriteria.push("&podId="+pod); if (domainId!=null && domainId.length > 0) moreCriteria.push("&domainid="+domainId); if (account!=null && account.length > 0) moreCriteria.push("&account="+account); commandString = "command=listVolumes&page=" + currentPage + moreCriteria.join("") + "&response=json"; } else { var moreCriteria = []; if(domainId!=null) moreCriteria.push("&domainid="+domainId); var searchInput = submenuContent.find("#search_input").val(); if (searchInput != null && searchInput.length > 0) commandString = "command=listVolumes&page=" + currentPage + moreCriteria.join("") + "&keyword=" + searchInput + "&response=json" else commandString = "command=listVolumes&page=" + currentPage + moreCriteria.join("") + "&response=json"; } //listItems(submenuContent, commandString, jsonResponse1, jsonResponse2, template, fnJSONToTemplate); listItems(submenuContent, commandString, "listvolumesresponse", "volume", $("#volume_template"), volumeJSONToTemplate); } submenuContentEventBinder($("#submenu_content_volume"), listVolumes); $("#submenu_volume").bind("click", function(event) { event.preventDefault(); currentSubMenu.addClass("submenu_links_off").removeClass("submenu_links_on"); $(this).addClass("submenu_links_on").removeClass("submenu_links_off"); currentSubMenu = $(this); $("#submenu_content_volume").show(); $("#submenu_content_pool").hide(); $("#submenu_content_storage").hide(); $("#submenu_content_snapshot").hide(); var submenuContent = $("#submenu_content_volume"); if (isAdmin) submenuContent.find("#adv_search_pod_li, #adv_search_domain_li, #adv_search_account_li").show(); currentPage = 1; listVolumes(); }); function listSnapshots() { var submenuContent = $("#submenu_content_snapshot"); var commandString; var advanced = submenuContent.find("#search_button").data("advanced"); if (advanced != null && advanced) { var domainId = submenuContent.find("#advanced_search #adv_search_domain").val(); var account = submenuContent.find("#advanced_search #adv_search_account").val(); var moreCriteria = []; if (domainId!=null && domainId.length > 0) moreCriteria.push("&domainid="+domainId); if (account!=null && account.length > 0) moreCriteria.push("&account="+account); commandString = "command=listSnapshots&page="+currentPage+moreCriteria.join("")+"&response=json"; } else { var moreCriteria = []; if(domainId!=null) moreCriteria.push("&domainid="+domainId); var searchInput = submenuContent.find("#search_input").val(); if (searchInput != null && searchInput.length > 0) commandString = "command=listSnapshots&page="+currentPage+moreCriteria.join("")+"&keyword="+searchInput+"&response=json" else commandString = "command=listSnapshots&page="+currentPage+moreCriteria.join("")+"&response=json"; } //listItems(submenuContent, commandString, jsonResponse1, jsonResponse2, template, fnJSONToTemplate); listItems(submenuContent, commandString, "listsnapshotsresponse", "snapshot", $("#snapshot_template"), snapshotJSONToTemplate); } submenuContentEventBinder($("#submenu_content_snapshot"), listSnapshots); $("#snapshot_template").bind("click", function(event) { event.preventDefault(); event.stopPropagation(); var template = $(this); var snapshotId = template.data("snapshotId"); var target = event.target.id; switch(target) { case "snapshot_action_create_volume": $("#dialog_add_volume_from_snapshot") .dialog("option", "buttons", { "Add": function() { var thisDialog = $(this); thisDialog.dialog("close"); var isValid = true; isValid &= validateString("Name", thisDialog.find("#name"), thisDialog.find("#name_errormsg")); if (!isValid) return; var name = thisDialog.find("#name").val(); var loadingImg = template.find(".adding_loading"); var rowContainer = template.find("#row_container"); loadingImg.find(".adding_text").text("Creating volume...."); loadingImg.show(); rowContainer.hide(); $.ajax({ data: createURL("command=createVolume&snapshotid="+snapshotId+"&name="+name+"&response=json"), dataType: "json", success: function(json) { var jobId = json.createvolumeresponse.jobid; var timerKey = "createVolumeJob"+jobId; $("body").everyTime(2000, timerKey, function() { $.ajax({ data: createURL("command=queryAsyncJobResult&jobId="+json.createvolumeresponse.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 loadingImg.hide(); rowContainer.show(); $("#dialog_info").html("Volume was created successfully
").dialog("open"); } else if (result.jobstatus == 2) { loadingImg.hide(); rowContainer.show(); $("#dialog_alert").html("" + sanitizeXSS(result.jobresult) + "
").dialog("open"); } } }, error: function(XMLHttpResponse) { $("body").stopTime(timerKey); loadingImg.hide(); rowContainer.show(); handleError(XMLHttpResponse); } }); }, 0); }, error: function(XMLHttpResponse) { loadingImg.hide(); rowContainer.show(); handleError(XMLHttpResponse); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); break; case "snapshot_action_delete": var loadingImg = template.find(".adding_loading"); var rowContainer = template.find("#row_container"); loadingImg.find(".adding_text").text("Deleting snapshot...."); loadingImg.show(); rowContainer.hide(); $.ajax({ data: createURL("command=deleteSnapshot&id="+snapshotId+"&response=json"), dataType: "json", success: function(json) { var jobId = json.deletesnapshotresponse.jobid; var timerKey = "deleteSnapshotJob"+jobId; $("body").everyTime(2000, timerKey, function() { $.ajax({ data: createURL("command=queryAsyncJobResult&jobId="+json.deletesnapshotresponse.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 loadingImg.hide(); rowContainer.show(); template.slideUp("slow", function() { $(this).remove(); }); } else if (result.jobstatus == 2) { loadingImg.hide(); rowContainer.show(); $("#dialog_alert").html("" + sanitizeXSS(result.jobresult) + "
").dialog("open"); } } }, error: function(XMLHttpResponse) { $("body").stopTime(timerKey); loadingImg.hide(); rowContainer.show(); handleError(XMLHttpResponse); } }); }, 0); }, error: function(XMLHttpResponse) { loadingImg.hide(); rowContainer.show(); handleError(XMLHttpResponse); } }); break; case "snapshot_action_create_template": $("#dialog_create_template_from_snapshot") .dialog("option", "buttons", { "Add": function() { var thisDialog = $(this); var isValid = true; isValid &= validateString("Name", thisDialog.find("#name"), thisDialog.find("#name_errormsg"), false); isValid &= validateString("Display Text", thisDialog.find("#display_text"), thisDialog.find("#display_text_errormsg"), false); if (!isValid) return; var name = thisDialog.find("#name").val(); var displayText = thisDialog.find("#display_text").val(); var osTypeId = thisDialog.find("#os_type").val(); thisDialog.dialog("close"); var loadingImg = template.find(".adding_loading"); var rowContainer = template.find("#row_container"); loadingImg.find(".adding_text").text("Creating template...."); loadingImg.fadeIn("slow"); rowContainer.hide(); $.ajax({ data: createURL("command=createTemplate&snapshotid="+snapshotId+"&name="+name+"&displaytext="+displayText+"&ostypeid="+osTypeId+"&response=json"), dataType: "json", success: function(json) { var jobId = json.createtemplateresponse.jobid; var timerKey = "createTemplateJob"+jobId; $("body").everyTime(2000, timerKey, function() { $.ajax({ data: createURL("command=queryAsyncJobResult&jobId="+json.createtemplateresponse.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 loadingImg.hide(); rowContainer.show(); $("#dialog_info").html("Template was created successfully
").dialog("open"); } else if (result.jobstatus == 2) { loadingImg.hide(); rowContainer.show(); $("#dialog_alert").html("" + sanitizeXSS(result.jobresult) + "
").dialog("open"); } } }, error: function(XMLHttpResponse) { $("body").stopTime(timerKey); loadingImg.hide(); rowContainer.show(); handleError(XMLHttpResponse); } }); }, 0); }, error: function(XMLHttpResponse) { loadingImg.hide(); rowContainer.show(); handleError(XMLHttpResponse); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); break; } }); $("#volume_action_snapshot_grid, #volume_action_take_snapshot_container, #volume_action_recurring_snapshot_container").show(); $("#submenu_snapshot").show().bind("click", function(event) { event.preventDefault(); currentSubMenu.addClass("submenu_links_off").removeClass("submenu_links_on"); $(this).addClass("submenu_links_on").removeClass("submenu_links_off"); currentSubMenu = $(this); $("#submenu_content_snapshot").show(); $("#submenu_content_pool").hide(); $("#submenu_content_storage").hide(); $("#submenu_content_volume").hide(); var submenuContent = $("#submenu_content_snapshot"); if (isAdmin) submenuContent.find("#adv_search_domain_li, #adv_search_account_li").show(); else //There are no fields in Advanced Search Dialog Box for non-admin user. So, hide Advanced Search Link. submenuContent.find("#advanced_search_link").hide(); currentPage = 1; listSnapshots(); }); if (getHypervisorType() == "kvm") { $("#dialog_add_pool #pool_cluster_container").hide(); } activateDialog($("#dialog_detach_volume").dialog({ autoOpen: false, modal: true, zIndex: 2000 })); activateDialog($("#dialog_attach_volume").dialog({ autoOpen: false, modal: true, zIndex: 2000 })); activateDialog($("#dialog_delete_volume").dialog({ autoOpen: false, modal: true, zIndex: 2000 })); activateDialog($("#dialog_create_template").dialog({ width: 400, autoOpen: false, modal: true, zIndex: 2000 })); activateDialog($("#dialog_create_snapshot").dialog({ autoOpen: false, modal: true, zIndex: 2000 })); activateDialog($("#dialog_recurring_snapshot").dialog({ width: 735, autoOpen: false, modal: true, zIndex: 2000 })); $.ajax({ data: createURL("command=listOsTypes&response=json"), dataType: "json", success: function(json) { types = json.listostypesresponse.ostype; if (types != null && types.length > 0) { var select = $("#dialog_create_template #create_template_os_type").empty(); for (var i = 0; i < types.length; i++) { select.append(""); } } } }); // *** recurring snapshot dialog - event binding (begin) ****************************** var dialogRecurringSnapshot = $("#dialog_recurring_snapshot"); function clearTopPanel(target) { // "target == null" means target at all (hourly + daily + weekly + monthly) var dialogBox = dialogRecurringSnapshot; if(target == "hourly" || target == null) { dialogBox.find("#dialog_snapshot_hourly_info_unset").show(); dialogBox.find("#dialog_snapshot_hourly_info_set").hide(); dialogBox.find("#read_hourly_max, #read_hourly_minute").text("N/A"); dialogBox.find("#hourly_edit_link, #hourly_delete_link").data("intervalType", "hourly").data("max", "").data("timezone", (g_timezone==null)?"Etc/GMT+12":g_timezone).data("minute", "00"); } if(target == "daily" || target == null) { dialogBox.find("#dialog_snapshot_daily_info_unset").show(); dialogBox.find("#dialog_snapshot_daily_info_set").hide(); dialogBox.find("#read_daily_max, #read_daily_minute, #read_daily_hour, #read_daily_meridiem").text("N/A"); dialogBox.find("#daily_edit_link, #daily_delete_link").data("intervalType", "daily").data("max", "").data("timezone", (g_timezone==null)?"Etc/GMT+12":g_timezone).data("minute", "00").data("hour12", "00").data("meridiem", "AM"); } if(target == "weekly" || target == null) { dialogBox.find("#dialog_snapshot_weekly_info_unset").show(); dialogBox.find("#dialog_snapshot_weekly_info_set").hide(); dialogBox.find("#read_weekly_max, #read_weekly_minute, #read_weekly_hour, #read_weekly_meridiem, #read_weekly_day_of_week").text("N/A"); dialogBox.find("#weekly_edit_link, #weekly_delete_link").data("intervalType", "weekly").data("max", "").data("timezone", (g_timezone==null)?"Etc/GMT+12":g_timezone).data("minute", "00").data("hour12", "00").data("meridiem", "AM").data("dayOfWeek", "1"); } if(target == "monthly" || target == null) { dialogBox.find("#dialog_snapshot_monthly_info_unset").show(); dialogBox.find("#dialog_snapshot_monthly_info_set").hide(); dialogBox.find("#read_monthly_max, #read_monthly_minute, #read_monthly_hour, #read_monthly_meridiem, #read_monthly_day_of_month").text("N/A"); dialogBox.find("#monthly_edit_link, #monthly_delete_link").data("intervalType", "monthly").data("max", "").data("timezone", (g_timezone==null)?"Etc/GMT+12":g_timezone).data("minute", "00").data("hour12", "00").data("meridiem", "AM").data("dayOfMonth", "1"); } } function clearBottomPanel() { var dialogBox = dialogRecurringSnapshot; dialogBox.find("#edit_hour").val("00"); cleanErrMsg(dialogBox.find("#edit_hour"), dialogBox.find("#edit_time_errormsg")); dialogBox.find("#edit_minute").val("00"); cleanErrMsg(dialogBox.find("#edit_minute"), dialogBox.find("#edit_time_errormsg")); dialogBox.find("#edit_meridiem").val("AM"); dialogBox.find("#edit_max").val(""); cleanErrMsg(dialogBox.find("#edit_max"), dialogBox.find("#edit_max_errormsg")); dialogBox.find("#edit_timezone").val((g_timezone==null)?"Etc/GMT+12":g_timezone); cleanErrMsg(dialogBox.find("#edit_timezone"), dialogBox.find("#edit_timezone_errormsg")); dialogBox.find("#edit_day_of_week").val("1"); cleanErrMsg(dialogBox.find("#edit_day_of_week"), dialogBox.find("#edit_day_of_week_errormsg")); dialogBox.find("#edit_day_of_month").val("1"); cleanErrMsg(dialogBox.find("#edit_day_of_month"), dialogBox.find("#edit_day_of_month_errormsg")); } $("#dialog_recurring_snapshot").bind("click", function(event) { event.preventDefault(); event.stopPropagation(); var target = event.target; var targetId = target.id; var thisDialog = $(this); var volumeId = thisDialog.data("volumeId"); var topPanel = thisDialog.find("#dialog_snapshotleft"); var bottomPanel = thisDialog.find("#dialog_snapshotright"); if(targetId.indexOf("_edit_link")!=-1) { clearBottomPanel(); bottomPanel.animate({ height: 200 }, 1000, function() { //$(this).fadeIn("fast"); // Animation complete. }); //bottomPanel.show("slide", { direction: "left" }, 1000); } else if(targetId.indexOf("_delete_link")!=-1) { clearBottomPanel(); var snapshotPolicyId = $("#"+targetId).data("snapshotPolicyId"); if(snapshotPolicyId == null || snapshotPolicyId.length==0) return; $.ajax({ data: createURL("command=deleteSnapshotPolicies&id="+snapshotPolicyId+"&response=json"), dataType: "json", success: function(json) { clearTopPanel($("#"+targetId).data("intervalType")); }, error: function(XMLHttpResponse) { handleError(XMLHttpResponse); } }); } var thisLink; switch(targetId) { case "hourly_edit_link": $("#edit_interval_type").text("Hourly"); $("#edit_time_colon, #edit_hour_container, #edit_meridiem_container, #edit_day_of_week_container, #edit_day_of_month_container").hide(); $("#edit_past_the_hour, #edit_minute_container").show(); thisLink = thisDialog.find("#hourly_edit_link"); thisDialog.find("#edit_minute").val(thisLink.data("minute")); thisDialog.find("#edit_max").val(thisLink.data("max")); thisDialog.find("#edit_timezone").val(thisLink.data("timezone")); break; case "daily_edit_link": $("#edit_interval_type").text("Daily"); $("#edit_past_the_hour, #edit_day_of_week_container, #edit_day_of_month_container").hide(); $("#edit_minute_container, #edit_hour_container, #edit_meridiem_container").show(); thisLink = thisDialog.find("#daily_edit_link"); thisDialog.find("#edit_minute").val(thisLink.data("minute")); thisDialog.find("#edit_hour").val(thisLink.data("hour12")); thisDialog.find("#edit_meridiem").val(thisLink.data("meridiem")); thisDialog.find("#edit_max").val(thisLink.data("max")); thisDialog.find("#edit_timezone").val(thisLink.data("timezone")); break; case "weekly_edit_link": $("#edit_interval_type").text("Weekly"); $("#edit_past_the_hour, #edit_day_of_month_container").hide(); $("#edit_minute_container, #edit_hour_container, #edit_meridiem_container, #edit_day_of_week_container").show(); thisLink = thisDialog.find("#weekly_edit_link"); thisDialog.find("#edit_minute").val(thisLink.data("minute")); thisDialog.find("#edit_hour").val(thisLink.data("hour12")); thisDialog.find("#edit_meridiem").val(thisLink.data("meridiem")); thisDialog.find("#edit_day_of_week").val(thisLink.data("dayOfWeek")); thisDialog.find("#edit_max").val(thisLink.data("max")); thisDialog.find("#edit_timezone").val(thisLink.data("timezone")); break; case "monthly_edit_link": $("#edit_interval_type").text("Monthly"); $("#edit_past_the_hour, #edit_day_of_week_container").hide(); $("#edit_minute_container, #edit_hour_container, #edit_meridiem_container, #edit_day_of_month_container").show(); thisLink = thisDialog.find("#monthly_edit_link"); thisDialog.find("#edit_minute").val(thisLink.data("minute")); thisDialog.find("#edit_hour").val(thisLink.data("hour12")); thisDialog.find("#edit_meridiem").val(thisLink.data("meridiem")); thisDialog.find("#edit_day_of_month").val(thisLink.data("dayOfMonth")); thisDialog.find("#edit_max").val(thisLink.data("max")); thisDialog.find("#edit_timezone").val(thisLink.data("timezone")); break; case "apply_button": var intervalType = bottomPanel.find("#edit_interval_type").text().toLowerCase(); var minute, hour12, hour24, meridiem, dayOfWeek, dayOfWeekString, dayOfMonth, schedule, max, timezone; switch(intervalType) { case "hourly": var isValid = true; isValid &= validateNumber("Keep # of snapshots", bottomPanel.find("#edit_max"), bottomPanel.find("#edit_max_errormsg")); if (!isValid) return; minute = bottomPanel.find("#edit_minute").val(); schedule = minute; max = bottomPanel.find("#edit_max").val(); timezone = bottomPanel.find("#edit_timezone").val(); break; case "daily": var isValid = true; isValid &= validateNumber("Keep # of snapshots", bottomPanel.find("#edit_max"), bottomPanel.find("#edit_max_errormsg")); if (!isValid) return; minute = bottomPanel.find("#edit_minute").val(); hour12 = bottomPanel.find("#edit_hour").val(); meridiem = bottomPanel.find("#edit_meridiem").val(); if(meridiem=="AM") hour24 = hour12; else //meridiem=="PM" hour24 = (parseInt(hour12)+12).toString(); schedule = minute + ":" + hour24; max = bottomPanel.find("#edit_max").val(); timezone = bottomPanel.find("#edit_timezone").val(); break; case "weekly": var isValid = true; isValid &= validateNumber("Keep # of snapshots", bottomPanel.find("#edit_max"), bottomPanel.find("#edit_max_errormsg")); if (!isValid) return; minute = bottomPanel.find("#edit_minute").val(); hour12 = bottomPanel.find("#edit_hour").val(); meridiem = bottomPanel.find("#edit_meridiem").val(); if(meridiem=="AM") hour24 = hour12; else //meridiem=="PM" hour24 = (parseInt(hour12)+12).toString(); dayOfWeek = bottomPanel.find("#edit_day_of_week").val(); dayOfWeekString = bottomPanel.find("#edit_day_of_week option:selected").text(); schedule = minute + ":" + hour24 + ":" + dayOfWeek; max = bottomPanel.find("#edit_max").val(); timezone = bottomPanel.find("#edit_timezone").val(); break; case "monthly": var isValid = true; isValid &= validateNumber("Keep # of snapshots", bottomPanel.find("#edit_max"), bottomPanel.find("#edit_max_errormsg")); if (!isValid) return; minute = bottomPanel.find("#edit_minute").val(); hour12 = bottomPanel.find("#edit_hour").val(); meridiem = bottomPanel.find("#edit_meridiem").val(); if(meridiem=="AM") hour24 = hour12; else //meridiem=="PM" hour24 = (parseInt(hour12)+12).toString(); dayOfMonth = bottomPanel.find("#edit_day_of_month").val(); schedule = minute + ":" + hour24 + ":" + dayOfMonth; max = bottomPanel.find("#edit_max").val(); timezone = bottomPanel.find("#edit_timezone").val(); break; } var thisLink; $.ajax({ data: createURL("command=createSnapshotPolicy&intervaltype="+intervalType+"&schedule="+schedule+"&volumeid="+volumeId+"&maxsnaps="+max+"&timezone="+encodeURIComponent(timezone)+"&response=json"), dataType: "json", success: function(json) { switch(intervalType) { case "hourly": topPanel.find("#dialog_snapshot_hourly_info_unset").hide(); topPanel.find("#dialog_snapshot_hourly_info_set").show(); topPanel.find("#read_hourly_minute").text(minute); topPanel.find("#read_hourly_timezone").text("("+timezones[timezone]+")"); topPanel.find("#read_hourly_max").text(max); topPanel.find("#hourly_edit_link, #hourly_delete_link").data("intervalType", "hourly").data("snapshotPolicyId", json.createsnapshotpolicyresponse.id).data("max",max).data("timezone",timezone).data("minute", minute); break; case "daily": topPanel.find("#dialog_snapshot_daily_info_unset").hide(); topPanel.find("#dialog_snapshot_daily_info_set").show(); topPanel.find("#read_daily_minute").text(minute); topPanel.find("#read_daily_hour").text(hour12); topPanel.find("#read_daily_meridiem").text(meridiem); topPanel.find("#read_daily_timezone").text("("+timezones[timezone]+")"); topPanel.find("#read_daily_max").text(max); topPanel.find("#daily_edit_link, #daily_delete_link").data("intervalType", "daily").data("snapshotPolicyId", json.createsnapshotpolicyresponse.id).data("max",max).data("timezone",timezone).data("minute", minute).data("hour12", hour12).data("meridiem", meridiem); break; case "weekly": topPanel.find("#dialog_snapshot_weekly_info_unset").hide(); topPanel.find("#dialog_snapshot_weekly_info_set").show(); topPanel.find("#read_weekly_minute").text(minute); topPanel.find("#read_weekly_hour").text(hour12); topPanel.find("#read_weekly_meridiem").text(meridiem); topPanel.find("#read_weekly_timezone").text("("+timezones[timezone]+")"); topPanel.find("#read_weekly_day_of_week").text(dayOfWeekString); topPanel.find("#read_weekly_max").text(max); topPanel.find("#weekly_edit_link, #weekly_delete_link").data("intervalType", "weekly").data("snapshotPolicyId", json.createsnapshotpolicyresponse.id).data("max",max).data("timezone",timezone).data("minute", minute).data("hour12", hour12).data("meridiem", meridiem).data("dayOfWeek",dayOfWeek); break; case "monthly": topPanel.find("#dialog_snapshot_monthly_info_unset").hide(); topPanel.find("#dialog_snapshot_monthly_info_set").show(); topPanel.find("#read_monthly_minute").text(minute); topPanel.find("#read_monthly_hour").text(hour12); topPanel.find("#read_monthly_meridiem").text(meridiem); topPanel.find("#read_monthly_timezone").text("("+timezones[timezone]+")"); topPanel.find("#read_monthly_day_of_month").text(toDayOfMonthDesp(dayOfMonth)); topPanel.find("#read_monthly_max").text(max); topPanel.find("#monthly_edit_link, #monthly_delete_link").data("intervalType", "monthly").data("snapshotPolicyId", json.createsnapshotpolicyresponse.id).data("max",max).data("timezone",timezone).data("minute", minute).data("hour12", hour12).data("meridiem", meridiem).data("dayOfMonth",dayOfMonth); break; } }, error: function(XMLHttpResponse) { handleError(XMLHttpResponse); } }); break; } }); // *** recurring snapshot dialog - event binding (end) ****************************** // *** volume template - event binding (begin) ************************************** $("#volume_template").bind("click", function(event) { var template = $(this); var link = $(event.target); var linkAction = link.attr("id"); var volumeId = template.data("volumeId"); var vmId = template.data("vmid"); var vmname = template.data("vmname"); var vmState = template.data("vmstate"); var domainId = template.data("domainId"); var account = template.data("account"); var volumeName = template.data("volumeName"); var zoneId = template.data("zoneId"); var timerKey = "volume"+volumeId; var submenuContent = $("#submenu_content_volume"); switch (linkAction) { case "volume_action_delete" : //check if this volume is attached to a virtual machine. If yes, can't be deleted. if(vmname != null && (vmname != "" || vmname != "none")) { $("#dialog_alert").html("This volume is attached to virtual machine " + vmname + " and can't be deleted.
") $("#dialog_alert").dialog("open"); return; } $("#dialog_delete_volume") .dialog('option', 'buttons', { "Confirm": function() { var volumeTemplate = $("#volume"+volumeId); var loadingImg = volumeTemplate.find(".adding_loading"); var rowContainer = volumeTemplate.find("#row_container"); loadingImg.find(".adding_text").text("Deleting...."); $(this).dialog("close"); if(volumeTemplate.find("#volume_snapshot_detail_panel").css("display")=="block") //if volume's snapshot grid is poped down, close it. volumeTemplate.find("#volume_action_snapshot_grid").click(); loadingImg.fadeIn("slow"); rowContainer.hide(); $.ajax({ data: createURL("command=deleteVolume&id="+volumeId+"&response=json"), dataType: "json", success: function(json) { volumeTemplate.slideUp("slow", function(){ $(this).remove(); }); }, error: function(XMLHttpResponse) { handleError(XMLHttpResponse); loadingImg.hide(); rowContainer.show(); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); break; case "volume_action_detach" : $("#dialog_detach_volume") .dialog('option', 'buttons', { "Confirm": function() { var loadingImg = template.find(".adding_loading"); var rowContainer = template.find("#row_container"); loadingImg.find(".adding_text").text("Detaching...."); $(this).dialog("close"); if(template.find("#volume_snapshot_detail_panel").css("display")=="block") //if volume's snapshot grid is poped down, close it. template.find("#volume_action_snapshot_grid").click(); loadingImg.show(); rowContainer.hide(); $.ajax({ data: createURL("command=detachVolume&id="+volumeId+"&response=json"), dataType: "json", success: function(json) { $("body").everyTime(5000, timerKey, function() { $.ajax({ data: createURL("command=queryAsyncJobResult&jobId="+json.detachvolumeresponse.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 template.find("#volume_action_attach_span, #volume_action_delete_span, #volume_action_create_template_span").show(); template.find("#volume_action_detach_span").hide(); template.find("#volume_vmname").text("detached"); template.data("vmid", null).data("vmname", null); loadingImg.hide(); rowContainer.show(); } else if (result.jobstatus == 2) { // Failed loadingImg.hide(); rowContainer.show(); $("#dialog_alert").html("" + sanitizeXSS(result.jobresult) + "
").dialog("open"); } } }, error: function(XMLHttpResponse) { $("body").stopTime(timerKey); loadingImg.hide(); rowContainer.show(); handleError(XMLHttpResponse); } }); }, 0); }, error: function(XMLHttpResponse) { loadingImg.hide(); rowContainer.show(); handleError(XMLHttpResponse); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); break; case "volume_action_attach" : populateVirtualMachineField(domainId, account, zoneId); $("#dialog_attach_volume") .dialog('option', 'buttons', { "Confirm": function() { var virtualMachineId = $("#dialog_attach_volume #volume_vm").val(); if(virtualMachineId==null) { $(this).dialog("close"); $("#dialog_alert").html("Please attach volume to a valid virtual machine
").dialog("open"); return; } var loadingImg = template.find(".adding_loading"); var rowContainer = template.find("#row_container"); loadingImg.find(".adding_text").text("Attaching...."); $(this).dialog("close"); if(template.find("#volume_snapshot_detail_panel").css("display")=="block") //if volume's snapshot grid is poped down, close it. template.find("#volume_action_snapshot_grid").click(); loadingImg.show(); rowContainer.hide(); var virtualMachineId = $("#dialog_attach_volume #volume_vm").val(); $.ajax({ data: createURL("command=attachVolume&id="+volumeId+'&virtualMachineId='+virtualMachineId+"&response=json"), dataType: "json", success: function(json) { $("body").everyTime(5000, timerKey, function() { $.ajax({ data: createURL("command=queryAsyncJobResult&jobId="+json.attachvolumeresponse.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 if (result.virtualmachine[0].vmstate == "Stopped") { template.find("#volume_action_attach_span, #volume_action_delete_span").hide(); template.find("#volume_action_detach_span, #volume_action_create_template_span").show(); } else { template.find("#volume_action_attach_span, #volume_action_delete_span, #volume_action_create_template_span").hide(); template.find("#volume_action_detach_span").show(); } template.find("#volume_vmname").text(getVmName(result.virtualmachine[0].vmname, result.virtualmachine[0].vmdisplayname) + " (" + result.virtualmachine[0].vmstate + ")"); template.data("vmid", virtualMachineId).data("vmname", getVmName(result.virtualmachine[0].vmname, result.virtualmachine[0].vmdisplayname)); loadingImg.hide(); rowContainer.show(); } else if (result.jobstatus == 2) { // Failed loadingImg.hide(); rowContainer.show(); $("#dialog_alert").html("" + sanitizeXSS(result.jobresult) + "
").dialog("open"); } } }, error: function(XMLHttpResponse) { $("body").stopTime(timerKey); loadingImg.hide(); rowContainer.show(); handleError(XMLHttpResponse); } }); }, 0); }, error: function(XMLHttpResponse) { loadingImg.hide(); rowContainer.show(); handleError(XMLHttpResponse); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); break; case "volume_action_create_template" : if(vmId != null && vmState != "Stopped") { $("#dialog_alert").html(""+vmname+" needs to be stopped before you can create a template of this disk volume.
") $("#dialog_alert").dialog("open"); return false; } $("#dialog_create_template").find("#volume_name").text(volumeName); $("#dialog_create_template") .dialog('option', 'buttons', { "Create": function() { // validate values var isValid = true; isValid &= validateString("Name", $("#create_template_name"), $("#create_template_name_errormsg")); isValid &= validateString("Display Text", $("#create_template_desc"), $("#create_template_desc_errormsg")); if (!isValid) return; var name = trim($("#create_template_name").val()); var desc = trim($("#create_template_desc").val()); var osType = $("#create_template_os_type").val(); var isPublic = $("#create_template_public").val(); var password = $("#create_template_password").val(); $(this).dialog("close"); if(template.find("#volume_snapshot_detail_panel").css("display")=="block") //if volume's snapshot grid is poped down, close it. template.find("#volume_action_snapshot_grid").click(); template.find(".adding_loading .adding_text").text("Creating Template..."); template.find(".adding_loading").show(); template.find("#row_container").hide(); $.ajax({ data: createURL("command=createTemplate&volumeId="+volumeId+"&name="+encodeURIComponent(name)+"&displayText="+encodeURIComponent(desc)+"&osTypeId="+osType+"&isPublic="+isPublic+"&passwordEnabled="+password+"&response=json"), dataType: "json", success: function(json) { $("body").everyTime( 30000, // This is templates..it could take hours timerKey, function() { $.ajax({ data: createURL("command=queryAsyncJobResult&jobId="+json.createtemplateresponse.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); template.find(".adding_loading").hide(); template.find("#row_container").show(); if (result.jobstatus == 1) { $("#dialog_info").html("" + ((isPublic=="true")? "Public":"Private") + " template: " + name + " has been successfully created
").dialog("open"); } else if (result.jobstatus == 2) { $("#dialog_alert").html("" + sanitizeXSS(result.jobresult) + "
").dialog("open"); } } }, error: function(XMLHttpResponse) { template.find(".adding_loading").hide(); template.find("#row_container").show(); $("body").stopTime(timerKey); handleError(XMLHttpResponse); } }); }, 0 ); }, error: function(XMLHttpResponse) { template.find(".adding_loading").hide(); template.find("#row_container").show(); handleError(XMLHttpResponse); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); break; case "volume_action_take_snapshot": $("#dialog_create_snapshot") .dialog('option', 'buttons', { "Confirm": function() { var volumeTemplate = $("#volume"+volumeId); var loadingImg = volumeTemplate.find(".adding_loading"); var rowContainer = volumeTemplate.find("#row_container"); loadingImg.find(".adding_text").text("Taking snapshot...."); $(this).dialog("close"); if(template.find("#volume_snapshot_detail_panel").css("display")=="block") //if volume's snapshot grid is poped down, close it. template.find("#volume_action_snapshot_grid").click(); loadingImg.fadeIn("slow"); rowContainer.hide(); $.ajax({ data: createURL("command=createSnapshot&volumeid="+volumeId+"&response=json"), dataType: "json", success: function(json) { $("body").everyTime(5000, timerKey, function() { $.ajax({ data: createURL("command=queryAsyncJobResult&jobId="+json.createsnapshotresponse.jobid+"&response=json"), dataType: "json", success: function(json) { var result = json.queryasyncjobresultresponse; if (result.jobstatus == 0) { if(result.jobprocstatus == 1) loadingImg.find(".adding_text").text("Backing up...."); return; //Job has not completed } else { $("body").stopTime(timerKey); if (result.jobstatus == 1) { //Succeeded template.find("#volume_action_snapshot_grid").click(); //pop down volume's snapshot grid loadingImg.hide(); rowContainer.show(); $("#dialog_info").html("Snapshot was created successfully
").dialog("open"); } else if (result.jobstatus == 2) { loadingImg.hide(); rowContainer.show(); $("#dialog_alert").html("" + sanitizeXSS(result.jobresult) + "
").dialog("open"); } } }, error: function(XMLHttpResponse) { $("body").stopTime(timerKey); loadingImg.hide(); rowContainer.show(); handleError(XMLHttpResponse); } }); }, 0); }, error: function(XMLHttpResponse) { loadingImg.hide(); rowContainer.show(); handleError(XMLHttpResponse); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); break; case "volume_action_recurring_snapshot": var dialogBox = $("#dialog_recurring_snapshot"); clearTopPanel(); $.ajax({ data: createURL("command=listSnapshotPolicies&volumeid="+volumeId+"&response=json"), dataType: "json", async: false, success: function(json) { var items = json.listsnapshotpoliciesresponse.snapshotpolicy; if(items!=null && items.length>0) { for(var i=0; i" + sanitizeXSS(result.jobresult) + "
").dialog("open"); template.slideUp("slow", function() { $(this).remove(); }); } } }, error: function(XMLHttpResponse) { $("body").stopTime(timerKey); handleError(XMLHttpResponse); template.slideUp("slow", function() { $(this).remove(); }); } }); }, 0); }, error: function(XMLHttpResponse) { handleError(XMLHttpResponse); template.slideUp("slow", function() { $(this).remove(); }); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); break; case "volume_snapshot_action_delete_snapshot": var thisDialog = $(this); thisDialog.dialog("close"); var loadingImg = template.find(".adding_loading"); var rowContainer = template.find("#row_container"); loadingImg.find(".adding_text").text("Deleting snapshot...."); loadingImg.show(); rowContainer.hide(); $.ajax({ data: createURL("command=deleteSnapshot&id="+snapshotId+"&response=json"), dataType: "json", success: function(json) { var jobId = json.deletesnapshotresponse.jobid; var timerKey = "deleteSnapshotJob"+jobId; $("body").everyTime(2000, timerKey, function() { $.ajax({ data: createURL("command=queryAsyncJobResult&jobId="+json.deletesnapshotresponse.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 loadingImg.hide(); rowContainer.show(); template.slideUp("slow", function() { $(this).remove(); }); } else if (result.jobstatus == 2) { loadingImg.hide(); rowContainer.show(); $("#dialog_alert").html("" + sanitizeXSS(result.jobresult) + "
").dialog("open"); } } }, error: function(XMLHttpResponse) { $("body").stopTime(timerKey); loadingImg.hide(); rowContainer.show(); handleError(XMLHttpResponse); } }); }, 0); }, error: function(XMLHttpResponse) { loadingImg.hide(); rowContainer.show(); handleError(XMLHttpResponse); } }); break; case "volume_snapshot_action_create_template": $("#dialog_create_template_from_snapshot") .dialog("option", "buttons", { "Add": function() { var thisDialog = $(this); var isValid = true; isValid &= validateString("Name", thisDialog.find("#name"), thisDialog.find("#name_errormsg"), false); isValid &= validateString("Display Text", thisDialog.find("#display_text"), thisDialog.find("#display_text_errormsg"), false); if (!isValid) return; var name = thisDialog.find("#name").val(); var displayText = thisDialog.find("#display_text").val(); var osTypeId = thisDialog.find("#os_type").val(); thisDialog.dialog("close"); var loadingImg = template.find(".adding_loading"); var rowContainer = template.find("#row_container"); loadingImg.find(".adding_text").text("Creating template...."); loadingImg.fadeIn("slow"); rowContainer.hide(); $.ajax({ data: createURL("command=createTemplate&snapshotid="+snapshotId+"&name="+name+"&displaytext="+displayText+"&ostypeid="+osTypeId+"&response=json"), dataType: "json", success: function(json) { var jobId = json.createtemplateresponse.jobid; var timerKey = "createTemplateJob"+jobId; $("body").everyTime(2000, timerKey, function() { $.ajax({ data: createURL("command=queryAsyncJobResult&jobId="+json.createtemplateresponse.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 loadingImg.hide(); rowContainer.show(); $("#dialog_info").html("Template was created successfully
").dialog("open"); } else if (result.jobstatus == 2) { loadingImg.hide(); rowContainer.show(); $("#dialog_alert").html("" + sanitizeXSS(result.jobresult) + "
").dialog("open"); } } }, error: function(XMLHttpResponse) { $("body").stopTime(timerKey); loadingImg.hide(); rowContainer.show(); handleError(XMLHttpResponse); } }); }, 0); }, error: function(XMLHttpResponse) { loadingImg.hide(); rowContainer.show(); handleError(XMLHttpResponse); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); break; } }); // *** volume's snapshot template - event binding (end) ***************************** function volumeSnapshotJSONToTemplate(json, template) { template.addClass("smallrow_even"); template.attr("id", "volume_snapshot_"+json.id).data("snapshotId", json.id).data("volumeId", json.volumeid); template.find("#id").text(json.id); template.find("#name").text(json.name); template.find("#volume").text(json.volumename); template.find("#interval_type").text(json.intervaltype); template.find("#account").text(json.account); template.find("#domain").text(json.domain); setDateField(json.created, template.find("#created")); } function snapshotJSONToTemplate(json, template) { (index++ % 2 == 0)? template.addClass("smallrow_even"): template.addClass("smallrow_odd"); template.attr("id", "snapshot_"+json.id).data("snapshotId", json.id); template.find("#id").text(json.id); template.find("#name").text(json.name); template.find("#volume").text(json.volumename); template.find("#interval_type").text(json.intervaltype); template.find("#account").text(json.account); template.find("#domain").text(json.domain); setDateField(json.created, template.find("#created")); } } if (isAdmin()) { populateZoneField(true); populateDiskOfferingField(); populateOSTypeField(); // *** Primary Storage (begin) *** function poolJSONToTemplate(json, template) { template.attr("id", "pool"+json.id); if (index++ % 2 == 0) { template.find("#row_container").addClass("smallrow_even"); } else { template.find("#row_container").addClass("smallrow_odd"); } template.data("id", json.id).data("name", sanitizeXSS(json.name)); template.find("#pool_id").text(json.id); template.find("#pool_name").text(json.name); template.find("#pool_zone").text(json.zonename); template.find("#pool_pod").text(json.podname); template.find("#pool_cluster").text(json.clustername); template.find("#pool_type").text(json.type); template.find("#pool_ip").text(json.ipaddress); template.find("#pool_path").text(json.path); template.find("#pool_tags").text(json.tags); var statHtml = " Disk Total: " +convertBytes(json.disksizetotal)+" | Disk Allocated: " + convertBytes(json.disksizeallocated); template.find("#pool_statistics").html(statHtml); /* var statHtml = "Disk Total: " +convertBytes(json.disksizetotal)+" | Disk Allocated: " + json.disksizeallocated + "
"; template.find("#storage_disk_stat").html(statHtml); // State if (json.state == 'Up') { template.find("#storage_state_bar").removeClass("yellow_statusbar grey_statusbar red_statusbar").addClass("green_statusbar "); template.find("#storage_state").text(json.state).removeClass("grid_celltitles grid_stoppedtitles").addClass("grid_runningtitles"); template.find(".grid_links").find("#storage_action_cancel_maint_container, #storage_action_remove_container").hide(); } else if (json.state == 'Down' || json.state == "Alert") { template.find("#storage_state_bar").removeClass("yellow_statusbar grey_statusbar green_statusbar").addClass("red_statusbar"); template.find("#storage_state").text(json.state).removeClass("grid_celltitles grid_runningtitles").addClass("grid_stoppedtitles"); if (json.state == "Alert") { template.find(".grid_links").find("#storage_action_reconnect_container, #storage_action_enable_maint_container, #storage_action_cancel_maint_container, #storage_action_remove_container").hide(); } else { template.find(".grid_links").find("#storage_action_reconnect_container, #storage_action_cancel_maint_container, #storage_action_remove_container").hide(); } } else { template.find("#storage_state_bar").removeClass("yellow_statusbar green_statusbar red_statusbar").addClass("grey_statusbar"); template.find("#storage_state").text(json.state).removeClass("grid_runningtitles grid_stoppedtitles").addClass("grid_celltitles "); if (json.state == "ErrorInMaintenance") { template.find(".grid_links").find("#storage_action_reconnect_container, #storage_action_remove_container").hide(); } else if (json.state == "PrepareForMaintenance") { template.find(".grid_links").find("#storage_action_reconnect_container, #storage_action_enable_maint_container, #storage_action_remove_container").hide(); } else if (json.state == "Maintenance") { template.find(".grid_links").find("#storage_action_reconnect_container, #storage_action_enable_maint_container, #storage_action_cancel_maint_container").hide(); } else if (json.state == "Disconnected") { template.find(".grid_links").find("#storage_action_reconnect_container, #storage_action_enable_maint_container, #storage_action_cancel_maint_container, #storage_action_remove_container").hide(); } else { alert("Unsupported Host State: " + json.state); } } */ } // Dialog Setup activateDialog($("#dialog_add_pool").dialog({ autoOpen: false, modal: true, zIndex: 2000 })); // if hypervisor is KVM, limit the server option to NFS for now if (getHypervisorType() == 'kvm') { $("#dialog_add_pool").find("#add_pool_protocol").empty().html(''); } $("#dialog_add_pool").find("#pool_zone").bind("change", function(event) { var zoneId = $(this).val(); $.ajax({ data: createURL("command=listPods&zoneId="+zoneId+"&response=json"+maxPageSize), dataType: "json", async: false, success: function(json) { var pods = json.listpodsresponse.pod; var podSelect = $("#dialog_add_pool").find("#pool_pod").empty(); if (pods != null && pods.length > 0) { for (var i = 0; i < pods.length; i++) { podSelect.append(""); } } $("#dialog_add_pool").find("#pool_pod").change(); } }); }); $("#dialog_add_pool").find("#pool_pod").bind("change", function(event) { var podId = $(this).val(); if(podId == null || podId.length == 0) return; var clusterSelect = $("#dialog_add_pool").find("#pool_cluster").empty(); $.ajax({ data: createURL("command=listClusters&response=json&podid=" + podId), dataType: "json", success: function(json) { var items = json.listclustersresponse.cluster; if(items != null && items.length > 0) { for(var i=0; i