openvz: add bridge vlan && firewall options to gui

parse bridge= vmbrX(vY)?(f)?

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
This commit is contained in:
Alexandre Derumier 2014-05-11 13:22:08 +02:00 committed by Dietmar Maurer
parent dc34665afc
commit 85c2c7b97e
2 changed files with 38 additions and 3 deletions

View File

@ -159,7 +159,21 @@ Ext.define('PVE.Parser', { statics: {
errors = true;
return false; // break
}
data[match_res[1]] = match_res[2];
if (match_res[1]==='bridge'){
var bridgevlanf = match_res[2];
var bridge_res = bridgevlanf.match(/^(vmbr(\d+))(v(\d+))?(f)?$/);
if (!bridge_res) {
errors = true;
return false; // break
}
data['bridge'] = bridge_res[1];
data['tag'] = bridge_res[4];
if(bridge_res[5]){
data['firewall'] = 1;
}
}else{
data[match_res[1]] = match_res[2];
}
});
if (errors || !data.ifname) {
@ -180,11 +194,21 @@ Ext.define('PVE.Parser', { statics: {
Ext.Object.each(netif, function(iface, data) {
var tmparray = [];
Ext.Array.each(['ifname', 'mac', 'bridge', 'host_ifname' , 'host_mac', 'mac_filter'], function(key) {
Ext.Array.each(['ifname', 'mac', 'bridge', 'host_ifname' , 'host_mac', 'mac_filter', 'tag', 'firewall'], function(key) {
var value = data[key];
if(key === 'bridge'){
if(data['tag']){
value = value + 'v' + data['tag'];
}
if(data['firewall']){
value = value + 'f';
}
}
if (value) {
tmparray.push(key + '=' + value);
}
});
netarray.push(tmparray.join(','));
});

View File

@ -82,6 +82,17 @@ Ext.define('PVE.OpenVZ.NetIfEdit', {
value: cdata.bridge,
allowBlank: false
},
{
xtype: 'pveVlanField',
name: 'tag',
value: cdata.tag,
},
{
xtype: 'pvecheckbox',
fieldLabel: gettext('Firewall'),
name: 'firewall',
checked: cdata.firewall,
},
{
xtype: 'textfield',
name: 'host_ifname',
@ -430,7 +441,7 @@ Ext.define('PVE.openvz.NetworkView', {
Ext.define('pve-openvz-network', {
extend: "Ext.data.Model",
proxy: { type: 'memory' },
fields: [ 'id', 'type', 'value', 'ifname', 'mac', 'bridge', 'host_ifname', 'host_mac' ]
fields: [ 'id', 'type', 'value', 'ifname', 'mac', 'bridge', 'host_ifname', 'host_mac', 'tag', 'firewall' ]
});
});