From e5850ead7104b372a17781fb38ce3efae191e88e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 30 May 2017 16:25:26 +0200 Subject: [PATCH] library: fix handling of vlan_id - the maximum allowed vlan_id is 4094, not 4095. - for ifcfg, we must convert the value to str() - for nm, we don't need to convert the value, it's already int(). --- library/network_connections.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/network_connections.py b/library/network_connections.py index f825694..f7633f3 100755 --- a/library/network_connections.py +++ b/library/network_connections.py @@ -664,7 +664,7 @@ class ArgValidator_DictConnection(ArgValidatorDict): ArgValidatorMac ('mac'), ArgValidatorBool('check_iface_exists', default_value = True), ArgValidatorStr ('parent'), - ArgValidatorNum ('vlan_id', val_min = 0, val_max = 4095, default_value = None), + ArgValidatorNum ('vlan_id', val_min = 0, val_max = 4094, default_value = None), ArgValidatorBool('ignore_errors', default_value = None), ArgValidator_DictIP(), ], @@ -932,7 +932,7 @@ class IfcfgUtil: ifcfg['VLAN'] = 'yes' ifcfg['TYPE'] = 'Vlan' ifcfg['PHYSDEV'] = cls._connection_find_master(connection['parent'], connections, idx) - ifcfg['VID'] = connection['vlan_id'] + ifcfg['VID'] = str(connection['vlan_id']) else: raise MyError('unsupported type %s' % (connection['type'])) @@ -1225,7 +1225,7 @@ class NMUtil: s_con.set_property(NM.SETTING_CONNECTION_TYPE, 'team') elif connection['type'] == 'vlan': s_vlan = self.connection_ensure_setting(con, NM.SettingVlan) - s_vlan.set_property(NM.SETTING_VLAN_ID, int(connection['vlan_id'])) + s_vlan.set_property(NM.SETTING_VLAN_ID, connection['vlan_id']) s_vlan.set_property(NM.SETTING_VLAN_PARENT, self._connection_find_master_uuid(connection['parent'], connections, idx)) else: raise MyError('unsupported type %s' % (connection['type']))