Permalink
Browse files

support copy snapshot

  • Loading branch information...
1 parent 47c65e9 commit e6c3f9bfa8168f426919f2bbb298b766fecc77cf @winebarrel winebarrel committed Dec 24, 2012
@@ -112,6 +112,28 @@ var ec2ui_controller = {
objResponse.callback();
},
+ copySnapshot : function (snapshotId, destRegion, description, callback) {
+ var params = [
+ ["SourceSnapshotId", snapshotId],
+ ["SourceRegion", ec2ui_session.getActiveEndpoint().name]
+ ];
+
+ if (description) {
+ params.push(["Description", description]);
+ }
+
+ ec2_httpclient.queryEC2InRegion(destRegion, "CopySnapshot", params, this, true, "onCompleteCopySnapshot", callback);
+ },
+
+ onCompleteCopySnapshot: function (objResponse) {
+ var xmlDoc = objResponse.xmlDoc;
+ var snapshotId = getNodeValueByName(xmlDoc, "snapshotId");
+
+ if (objResponse.callback) {
+ objResponse.callback(snapshotId);
+ }
+ },
+
deleteVolume : function (volumeId, callback) {
ec2_httpclient.queryEC2("DeleteVolume", [["VolumeId", volumeId]], this, true, "onCompleteDeleteVolume", callback);
},
@@ -101,6 +101,40 @@ var ec2ui_SnapshotTreeView = {
ec2ui_VolumeTreeView.createVolume(image);
},
+ copySnapshot: function () {
+ var image = this.getSelectedImage();
+ if (image == null) return;
+
+ var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
+
+ var region_list = [];
+
+ var endpointlist = ec2ui_session.getEndpoints();
+
+ for (var i = 0; i < endpointlist.length; i++) {
+ region_list.push(endpointlist[i].name);
+ }
+
+ var selected = {};
+
+ var ok = prompts.select(window, "Copy this volume", "Destination region:",
+ region_list.length, region_list, selected);
+
+ if (ok) {
+ var destRegion = region_list[selected.value];
+
+ var wrap = function(snapshotId) {
+ alert("The copy to " + destRegion + " has been started.\n\n" +
+ "The SNAP ID is: " + snapshotId);
+ }
+
+ var description = "[Copied " + image.id + " from " + ec2ui_session.getActiveEndpoint().name + "]";
+
+ ec2ui_session.controller.copySnapshot(
+ image.id, destRegion, description, wrap);
+ }
+ },
+
displayImages : function (imageList) {
BaseImagesView.displayImages.call(this, imageList);
@@ -166,6 +166,8 @@
label="&ec2ui.snapshot.contextmenu.createvol.label;" />
<menuitem oncommand="ec2ui_SnapshotTreeView.deleteSnapshot();"
label="&ec2ui.snapshot.contextmenu.delete.label;" />
+ <menuitem oncommand="ec2ui_SnapshotTreeView.copySnapshot();"
+ label="Copy this snapshot" />
<menuseparator />
<menuitem oncommand="ec2ui_SnapshotTreeView.copyToClipBoard('id');"
label="&ec2ui.snapshot.contextmenu.copysnapid.label;" />

0 comments on commit e6c3f9b

Please sign in to comment.