diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-05-02 14:12:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-02 14:12:23 +0200 |
commit | 932657a64a7faa0c51124f87a301057d1df297bd (patch) | |
tree | 89505acd9b50ca3e046181c960a8e2e25bcaaa27 /python/vyos/ifconfig/vlan.py | |
parent | d51029d1684d852e690e1a6d96bdc89ed56c56db (diff) | |
parent | 4a67e1a940901283bc3e441e59b17ce5af18a095 (diff) | |
download | vyos-1x-932657a64a7faa0c51124f87a301057d1df297bd.tar.gz vyos-1x-932657a64a7faa0c51124f87a301057d1df297bd.zip |
Merge pull request #383 from thomas-mangin/T2372
disable :T2372: disable sub-interface if parent is
Diffstat (limited to 'python/vyos/ifconfig/vlan.py')
-rw-r--r-- | python/vyos/ifconfig/vlan.py | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/python/vyos/ifconfig/vlan.py b/python/vyos/ifconfig/vlan.py index 7b1e00d87..d68e8f6cd 100644 --- a/python/vyos/ifconfig/vlan.py +++ b/python/vyos/ifconfig/vlan.py @@ -101,26 +101,26 @@ class VLAN: >>> i.add_vlan(10) """ vlan_ifname = self.config['ifname'] + '.' + str(vlan_id) - if not os.path.exists(f'/sys/class/net/{vlan_ifname}'): - self._vlan_id = int(vlan_id) - - if ethertype: - self._ethertype = ethertype - ethertype = 'proto {}'.format(ethertype) - - # Optional ingress QOS mapping - opt_i = '' - if ingress_qos: - opt_i = 'ingress-qos-map ' + ingress_qos - # Optional egress QOS mapping - opt_e = '' - if egress_qos: - opt_e = 'egress-qos-map ' + egress_qos - - # create interface in the system - cmd = 'ip link add link {ifname} name {ifname}.{vlan} type vlan {proto} id {vlan} {opt_e} {opt_i}' \ - .format(ifname=self.config['ifname'], vlan=self._vlan_id, proto=ethertype, opt_e=opt_e, opt_i=opt_i) - self._cmd(cmd) + if os.path.exists(f'/sys/class/net/{vlan_ifname}'): + return self.__class__(vlan_ifname) + + if ethertype: + self._ethertype = ethertype + ethertype = 'proto {}'.format(ethertype) + + # Optional ingress QOS mapping + opt_i = '' + if ingress_qos: + opt_i = 'ingress-qos-map ' + ingress_qos + # Optional egress QOS mapping + opt_e = '' + if egress_qos: + opt_e = 'egress-qos-map ' + egress_qos + + # create interface in the system + cmd = 'ip link add link {ifname} name {ifname}.{vlan} type vlan {proto} id {vlan} {opt_e} {opt_i}' \ + .format(ifname=self.ifname, vlan=vlan_id, proto=ethertype, opt_e=opt_e, opt_i=opt_i) + self._cmd(cmd) # return new object mapping to the newly created interface # we can now work on this object for e.g. IP address setting |