bug 7602: instance page - volume page - add "Create Snapshot" option.

This commit is contained in:
Jessica Wang 2010-12-20 18:17:08 -08:00
parent 825028229a
commit ca6b1cb9d9

View File

@ -1796,7 +1796,14 @@ var vmVolumeActionMap = {
dialogBeforeActionFn : doCreateTemplateFromVmVolume,
inProcessText: "Creating template....",
afterActionSeccessFn: function(json, id, $subgridItem) {}
}
},
"Take Snapshot": {
isAsyncJob: true,
asyncJobResponse: "createsnapshotresponse",
dialogBeforeActionFn : doTakeSnapshotFromVmVolume,
inProcessText: "Taking Snapshot....",
afterActionSeccessFn: function(json, id, $subgridItem) {}
}
}
function vmNicJSONToTemplate(json, $template, index) {
@ -1837,6 +1844,9 @@ function vmVolumeJSONToTemplate(json, $template) {
$actionMenu.find("#action_list").empty();
var noAvailableActions = true;
buildActionLinkForSubgridItem("Take Snapshot", vmVolumeActionMap, $actionMenu, $template);
noAvailableActions = false;
var hasCreateTemplate = false;
if(json.type=="ROOT") { //"create template" is allowed(when stopped), "detach disk" is disallowed.
if (json.vmstate == "Stopped") {
@ -1989,6 +1999,23 @@ function doCreateTemplateFromVmVolume($actionLink, $subgridItem) {
}).dialog("open");
}
function doTakeSnapshotFromVmVolume($actionLink, $subgridItem) {
$("#dialog_info")
.text("Please confirm you want to create snapshot for this volume")
.dialog('option', 'buttons', {
"Confirm": function() {
$(this).dialog("close");
var id = $subgridItem.data("jsonObj").id;
var apiCommand = "command=createSnapshot&volumeid="+id;
doActionToSubgridItem(id, $actionLink, apiCommand, $subgridItem);
},
"Cancel": function() {
$(this).dialog("close");
}
}).dialog("open");
}
//***** Routers tab (begin) ***************************************************************************************
var vmRouterActionMap = {
"Start Router": {