[pve-devel] [PATCH] openvz: add bridge vlan && firewall options to gui

Alexandre Derumier aderumier at odiso.com
Sun May 11 13:22:08 CEST 2014


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

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 www/manager/Parser.js         |   28 ++++++++++++++++++++++++++--
 www/manager/openvz/Network.js |   13 ++++++++++++-
 2 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/www/manager/Parser.js b/www/manager/Parser.js
index db4242a..e245bb7 100644
--- a/www/manager/Parser.js
+++ b/www/manager/Parser.js
@@ -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(','));
 	});
diff --git a/www/manager/openvz/Network.js b/www/manager/openvz/Network.js
index a7a72b6..13986db 100644
--- a/www/manager/openvz/Network.js
+++ b/www/manager/openvz/Network.js
@@ -83,6 +83,17 @@ Ext.define('PVE.OpenVZ.NetIfEdit', {
 		    allowBlank: false
 		},
 		{
+		    xtype: 'pveVlanField',
+		    name: 'tag',
+		    value: cdata.tag,
+		},
+		{
+		    xtype: 'pvecheckbox',
+		    fieldLabel: gettext('Firewall'),
+		    name: 'firewall',
+		    checked: cdata.firewall,
+		},
+		{
 		    xtype: 'textfield',
 		    name: 'host_ifname',
 		    fieldLabel: gettext('Host device name'),
@@ -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' ]
     });
 
 });
-- 
1.7.10.4




More information about the pve-devel mailing list