]>
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?
11 xclass
: 'Ext.app.ViewController',
14 change: function(el
, newVal
) {
15 let liveWarning
= this.lookupReference('liveWarning');
16 liveWarning
.setHidden(!newVal
);
17 let start
= this.lookupReference('start');
18 start
.setDisabled(newVal
);
22 validitychange: function(f
, valid
) {
23 this.lookupReference('doRestoreBtn').setDisabled(!valid
);
28 doRestore: function() {
30 let view
= me
.getView();
32 let values
= view
.down('form').getForm().getValues();
35 vmid
: view
.vmid
|| values
.vmid
,
36 force
: view
.vmid
? 1 : 0,
41 if (values
.start
&& !values
['live-restore']) {
44 if (values
['live-restore']) {
45 params
['live-restore'] = 1;
48 params
.storage
= values
.storage
;
50 if (values
.bwlimit
!== undefined) {
51 params
.bwlimit
= values
.bwlimit
;
55 if (view
.vmtype
=== 'lxc') {
56 params
.ostemplate
= view
.volid
;
58 if (values
.unprivileged
!== 'keep') {
59 params
.unprivileged
= values
.unprivileged
;
61 confirmMsg
= Proxmox
.Utils
.format_task_description('vzrestore', params
.vmid
);
62 } else if (view
.vmtype
=== 'qemu') {
63 params
.archive
= view
.volid
;
64 confirmMsg
= Proxmox
.Utils
.format_task_description('qmrestore', params
.vmid
);
66 throw 'unknown VM type';
69 let executeRestore
= () => {
70 Proxmox
.Utils
.API2Request({
71 url
: `/nodes/${view.nodename}/${view.vmtype}`,
75 failure
: response
=> Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
),
76 success: function(response
, options
) {
77 Ext
.create('Proxmox.window.TaskViewer', {
79 upid
: response
.result
.data
,
87 confirmMsg
+= '. ' + gettext('This will permanently erase current VM data.');
88 Ext
.Msg
.confirm(gettext('Confirm'), confirmMsg
, function(btn
) {
99 initComponent: function() {
103 throw "no node name specified";
106 throw "no volume ID specified";
109 throw "no vmtype specified";
112 let storagesel
= Ext
.create('PVE.form.StorageSelector', {
113 nodename
: me
.nodename
,
116 fieldLabel
: gettext('Storage'),
117 storageContent
: me
.vmtype
=== 'lxc' ? 'rootdir' : 'images',
118 // when restoring a container without specifying a storage, the backend defaults
119 // to 'local', which is unintuitive and 'rootdir' might not even be allowed on it
120 allowBlank
: me
.vmtype
!== 'lxc',
121 emptyText
: me
.vmtype
=== 'lxc' ? '' : gettext('From backup configuration'),
122 autoSelect
: me
.vmtype
=== 'lxc',
127 xtype
: 'displayfield',
128 value
: me
.volidText
|| me
.volid
,
129 fieldLabel
: gettext('Source'),
133 xtype
: 'pmxDisplayEditField',
135 fieldLabel
: me
.vmtype
=== 'lxc' ? 'CT' : 'VM',
139 xtype
: 'pveGuestIDSelector',
140 guestType
: me
.vmtype
,
141 loadNextFreeID
: true,
142 validateExists
: false,
146 xtype
: 'pveBandwidthField',
150 fieldLabel
: gettext('Bandwidth Limit'),
151 emptyText
: gettext('Defaults to target storage restore limit'),
154 'data-qtip': gettext("Use '0' to disable all bandwidth limits."),
158 xtype
: 'fieldcontainer',
161 xtype
: 'proxmoxcheckbox',
163 fieldLabel
: gettext('Unique'),
168 'data-qtip': gettext('Autogenerate unique properties, e.g., MAC addresses'),
173 xtype
: 'proxmoxcheckbox',
177 fieldLabel
: gettext('Start after restore'),
184 if (me
.vmtype
=== 'lxc') {
188 fieldLabel
: gettext('Privilege Level'),
189 reference
: 'noVNCScalingGroup',
190 height
: '15px', // renders faster with value assigned
198 gettext('Choose if you want to keep or override the privilege level of the restored Container.'),
203 name
: 'unprivileged',
205 boxLabel
: gettext('From Backup'),
211 name
: 'unprivileged',
213 boxLabel
: gettext('Unprivileged'),
218 name
: 'unprivileged',
220 boxLabel
: gettext('Privileged'),
222 //margin: '0 0 0 10',
227 } else if (me
.vmtype
=== 'qemu') {
229 xtype
: 'proxmoxcheckbox',
230 name
: 'live-restore',
231 itemId
: 'liveRestore',
233 fieldLabel
: gettext('Live restore'),
236 // align checkbox with 'start' if 'unique' is hidden
237 labelWidth
: me
.vmid
? 105 : 100,
240 xtype
: 'displayfield',
241 reference
: 'liveWarning',
242 // TODO: Remove once more tested/stable?
243 value
: gettext('Note: If anything goes wrong during the live-restore, new data written by the VM may be lost.'),
249 let title
= gettext('Restore') + ": " + (me
.vmtype
=== 'lxc' ? 'CT' : 'VM');
251 title
+= " " + me
.vmid
;
270 text
: gettext('Restore'),
271 reference
: 'doRestoreBtn',
272 handler
: 'doRestore',