From ca6b1cb9d93f44d1097eb035ce9a7441d1fecf57 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Mon, 20 Dec 2010 18:17:08 -0800 Subject: [PATCH] bug 7602: instance page - volume page - add "Create Snapshot" option. --- ui/scripts/cloud.core.instance.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/ui/scripts/cloud.core.instance.js b/ui/scripts/cloud.core.instance.js index 478f6ffd818..8bbcf0a7e61 100644 --- a/ui/scripts/cloud.core.instance.js +++ b/ui/scripts/cloud.core.instance.js @@ -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": {