]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/window/Restore.js
1 Ext
.define('PVE.window.Restore', {
2 extend
: 'Ext.window.Window', // fixme: Proxmox.window.Edit?
7 xclass
: 'Ext.app.ViewController',
10 change: function(el
, newVal
) {
11 let liveWarning
= this.lookupReference('liveWarning');
12 liveWarning
.setHidden(!newVal
);
13 let start
= this.lookupReference('start');
14 start
.setDisabled(newVal
);
20 initComponent: function() {
24 throw "no node name specified";
28 throw "no volume ID specified";
32 throw "no vmtype specified";
35 var storagesel
= Ext
.create('PVE.form.StorageSelector', {
36 nodename
: me
.nodename
,
39 fieldLabel
: gettext('Storage'),
40 storageContent
: me
.vmtype
=== 'lxc' ? 'rootdir' : 'images',
41 // when restoring a container without specifying a storage, the backend defaults
42 // to 'local', which is unintuitive and 'rootdir' might not even be allowed on it
43 allowBlank
: me
.vmtype
!== 'lxc',
44 emptyText
: me
.vmtype
=== 'lxc' ? '' : gettext('From backup configuration'),
45 autoSelect
: me
.vmtype
=== 'lxc',
50 IDfield
= Ext
.create('Ext.form.field.Display', {
53 fieldLabel
: me
.vmtype
=== 'lxc' ? 'CT' : 'VM',
56 IDfield
= Ext
.create('PVE.form.GuestIDSelector', {
60 validateExists
: false,
66 xtype
: 'displayfield',
67 value
: me
.volidText
|| me
.volid
,
68 fieldLabel
: gettext('Source'),
73 xtype
: 'pveBandwidthField',
77 fieldLabel
: gettext('Bandwidth Limit'),
78 emptyText
: gettext('Defaults to target storage restore limit'),
81 'data-qtip': gettext("Use '0' to disable all bandwidth limits."),
85 xtype
: 'fieldcontainer',
88 xtype
: 'proxmoxcheckbox',
90 fieldLabel
: gettext('Unique'),
95 'data-qtip': gettext('Autogenerate unique properties, e.g., MAC addresses'),
100 xtype
: 'proxmoxcheckbox',
104 fieldLabel
: gettext('Start after restore'),
111 if (me
.vmtype
=== 'lxc') {
115 fieldLabel
: gettext('Privilege Level'),
116 reference
: 'noVNCScalingGroup',
117 height
: '15px', // renders faster with value assigned
125 gettext('Choose if you want to keep or override the privilege level of the restored Container.'),
130 name
: 'unprivileged',
132 boxLabel
: gettext('From Backup'),
138 name
: 'unprivileged',
140 boxLabel
: gettext('Unprivileged'),
145 name
: 'unprivileged',
147 boxLabel
: gettext('Privileged'),
149 //margin: '0 0 0 10',
154 } else if (me
.vmtype
=== 'qemu') {
156 xtype
: 'proxmoxcheckbox',
157 name
: 'live-restore',
158 itemId
: 'liveRestore',
160 fieldLabel
: gettext('Live restore'),
163 // align checkbox with 'start' if 'unique' is hidden
164 labelWidth
: me
.vmid
? 105 : 100,
167 xtype
: 'displayfield',
168 reference
: 'liveWarning',
169 // TODO: Remove once more tested/stable?
170 value
: gettext('Note: If anything goes wrong during the live-restore, new data written by the VM may be lost.'),
176 me
.formPanel
= Ext
.create('Ext.form.Panel', {
186 var form
= me
.formPanel
.getForm();
188 var doRestore = function(url
, params
) {
189 Proxmox
.Utils
.API2Request({
194 failure: function(response
, opts
) {
195 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
197 success: function(response
, options
) {
198 var upid
= response
.result
.data
;
200 var win
= Ext
.create('Proxmox.window.TaskViewer', {
209 var submitBtn
= Ext
.create('Ext.Button', {
210 text
: gettext('Restore'),
211 handler: function() {
212 var values
= form
.getValues();
215 vmid
: me
.vmid
|| values
.vmid
,
216 force
: me
.vmid
? 1 : 0,
218 if (values
.unique
) { params
.unique
= 1; }
219 if (values
.start
&& !values
['live-restore']) { params
.start
= 1; }
220 if (values
['live-restore']) { params
['live-restore'] = 1; }
221 if (values
.storage
) { params
.storage
= values
.storage
; }
223 if (values
.bwlimit
!== undefined) {
224 params
.bwlimit
= values
.bwlimit
;
229 if (me
.vmtype
=== 'lxc') {
230 url
= '/nodes/' + me
.nodename
+ '/lxc';
231 params
.ostemplate
= me
.volid
;
233 if (values
.unprivileged
!== 'keep') {
234 params
.unprivileged
= values
.unprivileged
;
236 msg
= Proxmox
.Utils
.format_task_description('vzrestore', params
.vmid
);
237 } else if (me
.vmtype
=== 'qemu') {
238 url
= '/nodes/' + me
.nodename
+ '/qemu';
239 params
.archive
= me
.volid
;
240 msg
= Proxmox
.Utils
.format_task_description('qmrestore', params
.vmid
);
242 throw 'unknown VM type';
246 msg
+= '. ' + gettext('This will permanently erase current VM data.');
247 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
251 doRestore(url
, params
);
254 doRestore(url
, params
);
259 form
.on('validitychange', function(f
, valid
) {
260 submitBtn
.setDisabled(!valid
);
263 var title
= gettext('Restore') + ": " + (
264 me
.vmtype
=== 'lxc' ? 'CT' : 'VM');
267 title
+= " " + me
.vmid
;
276 items
: [me
.formPanel
],
277 buttons
: [submitBtn
],