diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-09-05 19:35:43 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2019-09-06 12:56:56 +0200 |
commit | 98aafc8f704ef54b6ece514c038b6aea414df734 (patch) | |
tree | 747dd4507c513dd4f5a233294e6ce82b3096d6b8 /python/vyos/ifconfig.py | |
parent | dcde45826501302fd5fc2fbfcc1c376c2d51ea3a (diff) | |
download | vyos-1x-98aafc8f704ef54b6ece514c038b6aea414df734.tar.gz vyos-1x-98aafc8f704ef54b6ece514c038b6aea414df734.zip |
vxlan: T1636: initial rewrite with XML and Python
Tested using:
Site 1 (VyOS 1.2.2)
-------------------
set interfaces vxlan vxlan100 address '10.10.10.2/24'
set interfaces vxlan vxlan100 remote '172.18.201.10'
set interfaces vxlan vxlan100 vni '100'
Site 2 (rewrite)
----------------
set interfaces vxlan vxlan100 address '10.10.10.1/24'
set interfaces vxlan vxlan100 description 'VyOS VXLAN'
set interfaces vxlan vxlan100 remote '172.18.202.10'
set interfaces vxlan vxlan100 vni '100'
Diffstat (limited to 'python/vyos/ifconfig.py')
-rw-r--r-- | python/vyos/ifconfig.py | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index bc22478a6..0479e3672 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -1407,32 +1407,43 @@ class VXLANIf(Interface, ): """ def __init__(self, ifname, config=''): if config: + self._ifname = ifname + if not os.path.exists('/sys/class/net/{}'.format(self._ifname)): # we assume that by default a multicast interface is created group = 'group {}'.format(config['group']) + # if remote host is specified we ignore the multicast address if config['remote']: group = 'remote {}'.format(config['remote']) + # an underlay device is not always specified dev = '' if config['dev']: - dev = 'dev'.format(config['dev']) + dev = 'dev {}'.format(config['dev']) - cmd = 'ip link add dev {intf} type vxlan id {vni} {group} {dev} {port}' - .format(intf=self._ifname, config['vni'], group=group, dev=dev, port=config['port']) + cmd = 'ip link add {intf} type vxlan id {vni} {grp_rem} {dev} dstport {port}' \ + .format(intf=self._ifname, vni=config['vni'], grp_rem=group, dev=dev, port=config['port']) self._cmd(cmd) super().__init__(ifname, type='vxlan') + @staticmethod + def get_config(): + """ + VXLAN interfaces require a configuration when they are added using + iproute2. This static method will provide the configuration dictionary + used by this class. - @staticmethod - def get_config(): - config = { - 'vni': 0, - 'dev': '', - 'group': '', - 'port': 8472 # The Linux implementation of VXLAN pre-dates + Example: + >> dict = VXLANIf().get_config() + """ + config = { + 'vni': 0, + 'dev': '', + 'group': '', + 'port': 8472, # The Linux implementation of VXLAN pre-dates # the IANA's selection of a standard destination port - 'remote': '', - 'ttl': 16 - } + 'remote': '' + } + return config |