Commit 1d7b7f5a authored by Dietmar Maurer's avatar Dietmar Maurer

implement simple restore dialog

parent 404ff2c3
...@@ -245,6 +245,9 @@ __PACKAGE__->register_method({ ...@@ -245,6 +245,9 @@ __PACKAGE__->register_method({
if (PVE::Storage::parse_volume_id($ostemplate, 1)) { if (PVE::Storage::parse_volume_id($ostemplate, 1)) {
$archive = PVE::Storage::path($stcfg, $ostemplate); $archive = PVE::Storage::path($stcfg, $ostemplate);
} else { } else {
raise_param_exc({ archive => "Only root can pass arbitrary paths." })
if $user ne 'root@pam';
$archive = abs_path($ostemplate); $archive = abs_path($ostemplate);
} }
die "can't find file '$archive'\n" if ! -f $archive; die "can't find file '$archive'\n" if ! -f $archive;
......
...@@ -86,7 +86,47 @@ Ext.define('PVE.grid.BackupView', { ...@@ -86,7 +86,47 @@ Ext.define('PVE.grid.BackupView', {
var volid = rec.data.volid; 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();
}
});
});
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment