diff --git a/PVE/API2/OpenVZ.pm b/PVE/API2/OpenVZ.pm index f9c89127..abc25b7a 100644 --- a/PVE/API2/OpenVZ.pm +++ b/PVE/API2/OpenVZ.pm @@ -245,6 +245,9 @@ __PACKAGE__->register_method({ if (PVE::Storage::parse_volume_id($ostemplate, 1)) { $archive = PVE::Storage::path($stcfg, $ostemplate); } else { + raise_param_exc({ archive => "Only root can pass arbitrary paths." }) + if $user ne 'root@pam'; + $archive = abs_path($ostemplate); } die "can't find file '$archive'\n" if ! -f $archive; diff --git a/www/manager/grid/BackupView.js b/www/manager/grid/BackupView.js index 675efaac..7eef70d5 100644 --- a/www/manager/grid/BackupView.js +++ b/www/manager/grid/BackupView.js @@ -86,7 +86,47 @@ Ext.define('PVE.grid.BackupView', { var volid = rec.data.volid; - console.log("RESRORE " + volid); + msg = 'Are you sure you want to restore from "' + volid + '"? ' + + 'This will permanently erase current VM data.'; + Ext.Msg.confirm('Restore Confirmation', msg, function(btn) { + if (btn !== 'yes') { + return; + } + + var url; + var params = { + vmid: vmid, + force: 1 + }; + + if (vmtype === 'openvz') { + url = '/nodes/' + nodename + '/openvz'; + params.ostemplate = volid; + } else if (vmtype === 'qemu') { + url = '/nodes/' + nodename + '/qemu'; + params.archive = volid; + } else { + throw 'unknown VM type'; + } + + PVE.Utils.API2Request({ + url: url, + params: params, + method: 'POST', + waitMsgTarget: me, + failure: function(response, opts) { + Ext.Msg.alert('Error', response.htmlStatus); + }, + success: function(response, options) { + var upid = response.result.data; + + var win = Ext.create('PVE.window.TaskViewer', { + upid: upid + }); + win.show(); + } + }); + }); } });