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

add backup panel for openvz containers

parent 6ec52543
......@@ -47,12 +47,14 @@ JSSRC= \
window/TaskViewer.js \
window/Wizard.js \
window/NotesEdit.js \
window/Backup.js \
panel/NotesView.js \
grid/SelectFeature.js \
grid/ObjectGrid.js \
grid/ResourceGrid.js \
tree/ResourceTree.js \
panel/ConfigPanel.js \
grid/BackupView.js \
node/DNSEdit.js \
node/DNSView.js \
node/TimeView.js \
......@@ -80,7 +82,6 @@ JSSRC= \
qemu/KeyboardEdit.js \
qemu/HardwareView.js \
qemu/Options.js \
qemu/Backup.js \
qemu/Config.js \
qemu/CreateWizard.js \
openvz/StatusView.js \
......
Ext.define('PVE.qemu.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";
}
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', {
Ext.define('PVE.grid.BackupView', {
extend: 'Ext.grid.GridPanel',
alias: ['widget.pveQemuBackupView'],
alias: ['widget.pveBackupView'],
initComponent : function() {
......@@ -117,6 +17,11 @@ Ext.define('PVE.qemu.BackupView', {
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', {
model: 'pve-storage-content',
sorters: {
......@@ -159,9 +64,10 @@ Ext.define('PVE.qemu.BackupView', {
var backup_btn = new Ext.Button({
text: 'Backup now',
handler: function() {
var win = Ext.create('PVE.qemu.Backup', {
var win = Ext.create('PVE.window.Backup', {
nodename: nodename,
vmid: vmid,
vmtype: vmtype,
storage: storagesel.getValue()
});
win.show();
......@@ -221,7 +127,5 @@ Ext.define('PVE.qemu.BackupView', {
});
me.callParent();
//setStorage('local');
}
});
......@@ -61,9 +61,9 @@ Ext.define('PVE.openvz.Config', {
vmid: vmid
},
{
xtype: 'pveBackupView',
title: 'Backup',
itemId: 'backup',
html: 'Backup and restore - not implemented!'
itemId: 'backup'
},
{
title: 'Permissions',
......
......@@ -46,7 +46,7 @@ Ext.define('PVE.qemu.Config', {
vmid: vmid
},
{
xtype: 'pveQemuBackupView',
xtype: 'pveBackupView',
title: 'Backup',
itemId: 'backup'
},
......
......@@ -42,7 +42,7 @@ Ext.define('PVE.storage.DirInputPanel', {
xtype: 'pveContentTypeSelector',
name: 'content',
value: 'images',
multiSelect: me.storageId === 'local',
multiSelect: true,
fieldLabel: 'Content',
allowBlank: false
}
......@@ -114,9 +114,8 @@ Ext.define('PVE.storage.DirEdit', {
var values = response.result.data;
var ctypes = values.content || '';
if (values.storage === 'local') {
values.content = ctypes.split(',');
}
values.content = ctypes.split(',');
if (values.nodes) {
values.nodes = values.nodes.split(',');
}
......
......@@ -116,7 +116,7 @@ Ext.define('PVE.storage.NFSInputPanel', {
xtype: 'pveContentTypeSelector',
name: 'content',
value: 'images',
multiSelect: me.storageId === 'local',
multiSelect: true,
fieldLabel: 'Content',
allowBlank: false
}
......@@ -179,9 +179,8 @@ Ext.define('PVE.storage.NFSEdit', {
var values = response.result.data;
var ctypes = values.content || '';
if (values.storage === 'local') {
values.content = ctypes.split(',');
}
values.content = ctypes.split(',');
if (values.nodes) {
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