Commit 404ff2c3 authored by Dietmar Maurer's avatar Dietmar Maurer

add backup panel for openvz containers

parent 6ec52543
...@@ -47,12 +47,14 @@ JSSRC= \ ...@@ -47,12 +47,14 @@ JSSRC= \
window/TaskViewer.js \ window/TaskViewer.js \
window/Wizard.js \ window/Wizard.js \
window/NotesEdit.js \ window/NotesEdit.js \
window/Backup.js \
panel/NotesView.js \ panel/NotesView.js \
grid/SelectFeature.js \ grid/SelectFeature.js \
grid/ObjectGrid.js \ grid/ObjectGrid.js \
grid/ResourceGrid.js \ grid/ResourceGrid.js \
tree/ResourceTree.js \ tree/ResourceTree.js \
panel/ConfigPanel.js \ panel/ConfigPanel.js \
grid/BackupView.js \
node/DNSEdit.js \ node/DNSEdit.js \
node/DNSView.js \ node/DNSView.js \
node/TimeView.js \ node/TimeView.js \
...@@ -80,7 +82,6 @@ JSSRC= \ ...@@ -80,7 +82,6 @@ JSSRC= \
qemu/KeyboardEdit.js \ qemu/KeyboardEdit.js \
qemu/HardwareView.js \ qemu/HardwareView.js \
qemu/Options.js \ qemu/Options.js \
qemu/Backup.js \
qemu/Config.js \ qemu/Config.js \
qemu/CreateWizard.js \ qemu/CreateWizard.js \
openvz/StatusView.js \ openvz/StatusView.js \
......
Ext.define('PVE.qemu.Backup', { Ext.define('PVE.grid.BackupView', {
extend: 'Ext.window.Window',
resizable: false,
initComponent : function() {
var me = this;
if (!me.nodename) {
throw "no node name specified";
}
if (!me.vmid) {
throw "no VM ID specified";
}
var storagesel = Ext.create('PVE.form.StorageSelector', {
nodename: me.nodename,
name: 'storage',
value: me.storage,
fieldLabel: 'Storage',
storageContent: 'backup',
allowBlank: false
});
me.formPanel = Ext.create('Ext.form.Panel', {
bodyPadding: 10,
border: false,
fieldDefaults: {
labelWidth: 100,
anchor: '100%'
},
items: [
storagesel,
{
xtype: 'pvecheckbox',
name: 'compress',
uncheckedValue: 0,
checked: true,
fieldLabel: 'Compress'
},
{
xtype: 'pvecheckbox',
name: 'snapshot',
uncheckedValue: 0,
checked: true,
fieldLabel: 'Snapshot mode'
}
]
});
var form = me.formPanel.getForm();
var submitBtn = Ext.create('Ext.Button', {
text: 'Backup',
handler: function(){
var storage = storagesel.getValue();
var msg = 'Start backup to storage "' + storage + '"';
var values = form.getValues();
console.dir(me.vmid, me.nodename, values.online);
PVE.Utils.API2Request({
url: '/nodes/' + me.nodename + '/vzdump',
params: {
storage: storage,
vmid: me.vmid,
compress: values.compress,
snapshot: values.snapshot
},
method: 'POST',
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();
me.close();
}
});
}
});
Ext.apply(me, {
title: "Backup VM " + me.vmid,
width: 350,
modal: true,
layout: 'auto',
border: false,
items: [ me.formPanel ],
buttons: [ submitBtn ],
});
me.callParent();
}
});
Ext.define('PVE.qemu.BackupView', {
extend: 'Ext.grid.GridPanel', extend: 'Ext.grid.GridPanel',
alias: ['widget.pveQemuBackupView'], alias: ['widget.pveBackupView'],
initComponent : function() { initComponent : function() {
...@@ -117,6 +17,11 @@ Ext.define('PVE.qemu.BackupView', { ...@@ -117,6 +17,11 @@ Ext.define('PVE.qemu.BackupView', {
throw "no VM ID specified"; throw "no VM ID specified";
} }
var vmtype = me.pveSelNode.data.type;
if (!vmtype) {
throw "no VM type specified";
}
me.store = Ext.create('Ext.data.Store', { me.store = Ext.create('Ext.data.Store', {
model: 'pve-storage-content', model: 'pve-storage-content',
sorters: { sorters: {
...@@ -159,9 +64,10 @@ Ext.define('PVE.qemu.BackupView', { ...@@ -159,9 +64,10 @@ Ext.define('PVE.qemu.BackupView', {
var backup_btn = new Ext.Button({ var backup_btn = new Ext.Button({
text: 'Backup now', text: 'Backup now',
handler: function() { handler: function() {
var win = Ext.create('PVE.qemu.Backup', { var win = Ext.create('PVE.window.Backup', {
nodename: nodename, nodename: nodename,
vmid: vmid, vmid: vmid,
vmtype: vmtype,
storage: storagesel.getValue() storage: storagesel.getValue()
}); });
win.show(); win.show();
...@@ -221,7 +127,5 @@ Ext.define('PVE.qemu.BackupView', { ...@@ -221,7 +127,5 @@ Ext.define('PVE.qemu.BackupView', {
}); });
me.callParent(); me.callParent();
//setStorage('local');
} }
}); });
...@@ -61,9 +61,9 @@ Ext.define('PVE.openvz.Config', { ...@@ -61,9 +61,9 @@ Ext.define('PVE.openvz.Config', {
vmid: vmid vmid: vmid
}, },
{ {
xtype: 'pveBackupView',
title: 'Backup', title: 'Backup',
itemId: 'backup', itemId: 'backup'
html: 'Backup and restore - not implemented!'
}, },
{ {
title: 'Permissions', title: 'Permissions',
......
...@@ -46,7 +46,7 @@ Ext.define('PVE.qemu.Config', { ...@@ -46,7 +46,7 @@ Ext.define('PVE.qemu.Config', {
vmid: vmid vmid: vmid
}, },
{ {
xtype: 'pveQemuBackupView', xtype: 'pveBackupView',
title: 'Backup', title: 'Backup',
itemId: 'backup' itemId: 'backup'
}, },
......
...@@ -42,7 +42,7 @@ Ext.define('PVE.storage.DirInputPanel', { ...@@ -42,7 +42,7 @@ Ext.define('PVE.storage.DirInputPanel', {
xtype: 'pveContentTypeSelector', xtype: 'pveContentTypeSelector',
name: 'content', name: 'content',
value: 'images', value: 'images',
multiSelect: me.storageId === 'local', multiSelect: true,
fieldLabel: 'Content', fieldLabel: 'Content',
allowBlank: false allowBlank: false
} }
...@@ -114,9 +114,8 @@ Ext.define('PVE.storage.DirEdit', { ...@@ -114,9 +114,8 @@ Ext.define('PVE.storage.DirEdit', {
var values = response.result.data; var values = response.result.data;
var ctypes = values.content || ''; var ctypes = values.content || '';
if (values.storage === 'local') {
values.content = ctypes.split(','); values.content = ctypes.split(',');
}
if (values.nodes) { if (values.nodes) {
values.nodes = values.nodes.split(','); values.nodes = values.nodes.split(',');
} }
......
...@@ -116,7 +116,7 @@ Ext.define('PVE.storage.NFSInputPanel', { ...@@ -116,7 +116,7 @@ Ext.define('PVE.storage.NFSInputPanel', {
xtype: 'pveContentTypeSelector', xtype: 'pveContentTypeSelector',
name: 'content', name: 'content',
value: 'images', value: 'images',
multiSelect: me.storageId === 'local', multiSelect: true,
fieldLabel: 'Content', fieldLabel: 'Content',
allowBlank: false allowBlank: false
} }
...@@ -179,9 +179,8 @@ Ext.define('PVE.storage.NFSEdit', { ...@@ -179,9 +179,8 @@ Ext.define('PVE.storage.NFSEdit', {
var values = response.result.data; var values = response.result.data;
var ctypes = values.content || ''; var ctypes = values.content || '';
if (values.storage === 'local') {
values.content = ctypes.split(','); values.content = ctypes.split(',');
}
if (values.nodes) { if (values.nodes) {
values.nodes = values.nodes.split(','); values.nodes = values.nodes.split(',');
} }
......
Ext.define('PVE.window.Backup', {
extend: 'Ext.window.Window',
resizable: false,
initComponent : function() {
var me = this;
if (!me.nodename) {
throw "no node name specified";
}
if (!me.vmid) {
throw "no VM ID specified";
}
if (!me.vmtype) {
throw "no VM type specified";
}
var storagesel = Ext.create('PVE.form.StorageSelector', {
nodename: me.nodename,
name: 'storage',
value: me.storage,
fieldLabel: 'Storage',
storageContent: 'backup',
allowBlank: false
});
me.formPanel = Ext.create('Ext.form.Panel', {
bodyPadding: 10,
border: false,
fieldDefaults: {
labelWidth: 100,
anchor: '100%'
},
items: [
storagesel,
{
xtype: 'pvecheckbox',
name: 'compress',
uncheckedValue: 0,
checked: true,
fieldLabel: 'Compress'
},
{
xtype: 'pvecheckbox',
name: 'snapshot',
uncheckedValue: 0,
checked: true,
fieldLabel: 'Snapshot mode'
}
]
});
var form = me.formPanel.getForm();
var submitBtn = Ext.create('Ext.Button', {
text: 'Backup',
handler: function(){
var storage = storagesel.getValue();
var values = form.getValues();
console.dir(me.vmid, me.nodename, values.online);
PVE.Utils.API2Request({
url: '/nodes/' + me.nodename + '/vzdump',
params: {
storage: storage,
vmid: me.vmid,
compress: values.compress,
snapshot: values.snapshot
},
method: 'POST',
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();
me.close();
}
});
}
});
var title = (me.vmtype === 'openvz') ?
"Backup CT " + me.vmid :
"Backup VM " + me.vmid;
Ext.apply(me, {
title: title,
width: 350,
modal: true,
layout: 'auto',
border: false,
items: [ me.formPanel ],
buttons: [ submitBtn ],
});
me.callParent();
}
});
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