summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ifconfig/vxlan.py29
-rw-r--r--python/vyos/ifconfig/wireguard.py3
2 files changed, 18 insertions, 14 deletions
diff --git a/python/vyos/ifconfig/vxlan.py b/python/vyos/ifconfig/vxlan.py
index bc2ec508b..86702b2cd 100644
--- a/python/vyos/ifconfig/vxlan.py
+++ b/python/vyos/ifconfig/vxlan.py
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see <http://www.gnu.org/licenses/>.
-
+from vyos import ConfigError
from vyos.ifconfig.interface import Interface
@@ -54,20 +54,23 @@ class VXLANIf(Interface):
super().__init__(ifname, **kargs)
def _create(self):
- # we assume that by default a multicast interface is created
- group = 'group {}'.format(self.config['group'])
-
- # if remote host is specified we ignore the multicast address
+ cmd = ''
if self.config['remote']:
- group = 'remote {}'.format(self.config['remote'])
-
- # an underlay device is not always specified
- dev = ''
- if self.config['dev']:
- dev = 'dev {}'.format(self.config['dev'])
+ # an underlay device is only mandatory with multicast, not unicast
+ dev = ''
+ if self.config['dev']:
+ dev = 'dev {}'.format(self.config['dev'])
+ # iproute2 command for unicast
+ cmd = 'ip link add {ifname} type vxlan id {vni} remote {remote} {dev_optional} dstport {port}'.format(
+ **self.config, dev_optional=dev)
+ else:
+ if not self.config['dev']:
+ raise ConfigError(
+ f'VXLAN "{self.config["ifname"]}" is missing mandatory underlay interface for a multicast network.')
+ # iproute2 command for multicast
+ cmd = 'ip link add {ifname} type vxlan id {vni} group {group} dev {dev} dstport {port}'.format(
+ **self.config)
- cmd = 'ip link add {ifname} type vxlan id {vni} {group} {dev} dstport {port}'.format(
- **config)
self._cmd(cmd)
@staticmethod
diff --git a/python/vyos/ifconfig/wireguard.py b/python/vyos/ifconfig/wireguard.py
index 2926e72e1..411c3e146 100644
--- a/python/vyos/ifconfig/wireguard.py
+++ b/python/vyos/ifconfig/wireguard.py
@@ -16,6 +16,7 @@
import os
+import vyos
from vyos.ifconfig.interface import Interface
class WireGuardIf(Interface):
@@ -101,7 +102,7 @@ class WireGuardIf(Interface):
wgdump = vyos.interfaces.wireguard_dump().get(
self.config['ifname'], None)
- c = Config()
+ c = vyos.config.Config()
c.set_level(["interfaces", "wireguard", self.config['ifname']])
description = c.return_effective_value(["description"])
ips = c.return_effective_values(["address"])