Commit f18317d7 authored by Dietmar Maurer's avatar Dietmar Maurer

make it easier to set VLAN tags on OVS ports/bond

parent f99b3b96
......@@ -55,6 +55,13 @@ my $confdesc = {
optional => 1,
type => 'string', format => 'pve-iface-list',
},
ovs_tag => {
description => "Specify a VLan tag (used by OVSPort, OVSIntPort, OVSBond)",
optional => 1,
type => 'integer',
minimum => 1,
maximum => 4094,
},
ovs_options => {
description => "OVS interface options.",
optional => 1,
......@@ -130,7 +137,7 @@ __PACKAGE__->register_method({
type => {
description => "Only list specific interface types.",
type => 'string',
enum => $network_type_enum,
enum => [ @$network_type_enum, 'any_bridge' ],
optional => 1,
},
},
......@@ -158,7 +165,11 @@ __PACKAGE__->register_method({
if ($param->{type}) {
foreach my $k (keys %$config) {
delete $config->{$k} if $param->{type} ne $config->{$k}->{type};
my $type = $config->{$k}->{type};
my $match = ($param->{type} eq $type) || (
($param->{type} eq 'any_bridge') &&
($type eq 'bridge' || $type eq 'OVSBridge'));
delete $config->{$k} if !$match;
}
}
......
......@@ -19,6 +19,7 @@ JSSRC= \
data/DiffStore.js \
data/ObjectStore.js \
data/ResourceStore.js \
form/VLanField.js \
form/Checkbox.js \
form/TextField.js \
form/RRDTypeSelector.js \
......
......@@ -2,7 +2,7 @@ Ext.define('PVE.form.BridgeSelector', {
extend: 'PVE.form.ComboGrid',
alias: ['widget.PVE.form.BridgeSelector'],
bridgeType: 'bridge', // or OVSBridge
bridgeType: 'any_bridge', // bridge, OVSBridge or any_bridge
setNodename: function(nodename) {
var me = this;
......
Ext.define('PVE.form.VlanField', {
extend: 'Ext.form.field.Number',
alias: ['widget.pveVlanField'],
deleteEmpty: false,
emptyText: 'no VLAN',
fieldLabel: gettext('VLAN Tag'),
allowBlank: true,
getSubmitData: function() {
var me = this,
data = null,
val;
if (!me.disabled && me.submitValue) {
val = me.getSubmitValue();
if (val) {
data = {};
data[me.getName()] = val;
} else if (me.deleteEmpty) {
data = {};
data['delete'] = me.getName();
}
}
return data;
},
initComponent: function() {
var me = this;
Ext.apply(me, {
minValue: 1,
maxValue: 4094
});
me.callParent();
}
});
......@@ -79,6 +79,12 @@ Ext.define('PVE.node.NetworkEdit', {
bridgeType: 'OVSBridge',
name: 'ovs_bridge'
});
column2.push({
xtype: 'pveVlanField',
deleteEmpty: !me.create,
name: 'ovs_tag',
value: ''
});
column2.push({
xtype: 'textfield',
fieldLabel: gettext('OVS options'),
......@@ -129,6 +135,12 @@ Ext.define('PVE.node.NetworkEdit', {
bridgeType: 'OVSBridge',
name: 'ovs_bridge'
});
column2.push({
xtype: 'pveVlanField',
deleteEmpty: !me.create,
name: 'ovs_tag',
value: ''
});
column2.push({
xtype: 'textfield',
fieldLabel: gettext('OVS options'),
......@@ -166,11 +178,6 @@ Ext.define('PVE.node.NetworkEdit', {
if (me.iftype === 'OVSBond') {
column1.push([
{
xtype: 'textfield',
fieldLabel: gettext('Slaves'),
name: 'ovs_bonds'
},
{
xtype: 'bondModeSelector',
fieldLabel: gettext('Mode'),
......@@ -178,6 +185,11 @@ Ext.define('PVE.node.NetworkEdit', {
openvswitch: true,
value: me.create ? 'active-backup' : undefined,
allowBlank: false
},
{
xtype: 'textfield',
fieldLabel: gettext('Slaves'),
name: 'ovs_bonds'
}
]);
} else {
......
......@@ -89,15 +89,10 @@ Ext.define('PVE.qemu.NetworkInputPanel', {
},
me.bridgesel,
{
xtype: 'numberfield',
xtype: 'pveVlanField',
name: 'tag',
minValue: 1,
maxValue: 4094,
value: '',
emptyText: 'no VLAN',
fieldLabel: gettext('VLAN Tag'),
labelAlign: 'right',
allowBlank: true
labelAlign: 'right'
},
{
xtype: 'radiofield',
......
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