19
19
from vyos .config import Config
20
20
from vyos .configdict import get_interface_dict
21
21
from vyos .configdict import is_node_changed
22
+ from vyos .configdict import is_source_interface
23
+ from vyos .configdep import set_dependents
24
+ from vyos .configdep import call_dependents
22
25
from vyos .configverify import verify_vrf
23
26
from vyos .configverify import verify_address
24
27
from vyos .configverify import verify_bridge_delete
35
38
from pathlib import Path
36
39
airbag .enable ()
37
40
41
+
38
42
def get_config (config = None ):
39
43
"""
40
44
Retrive CLI config as dictionary. Dictionary can never be empty, as at least the
@@ -61,11 +65,25 @@ def get_config(config=None):
61
65
if 'disable' not in peer_config and 'host_name' in peer_config :
62
66
wireguard ['peers_need_resolve' ].append (peer )
63
67
68
+ # Check if interface is used as source-interface on VXLAN interface
69
+ tmp = is_source_interface (conf , ifname , 'vxlan' )
70
+ if tmp :
71
+ if 'deleted' not in wireguard :
72
+ set_dependents ('vxlan' , conf , tmp )
73
+ else :
74
+ wireguard ['is_source_interface' ] = tmp
75
+
64
76
return wireguard
65
77
78
+
66
79
def verify (wireguard ):
67
80
if 'deleted' in wireguard :
68
81
verify_bridge_delete (wireguard )
82
+ if 'is_source_interface' in wireguard :
83
+ raise ConfigError (
84
+ f'Interface "{ wireguard ["ifname" ]} " cannot be deleted as it is used '
85
+ f'as source interface for "{ wireguard ["is_source_interface" ]} "!'
86
+ )
69
87
return None
70
88
71
89
verify_mtu_ipv6 (wireguard )
@@ -119,9 +137,11 @@ def verify(wireguard):
119
137
120
138
public_keys .append (peer ['public_key' ])
121
139
140
+
122
141
def generate (wireguard ):
123
142
return None
124
143
144
+
125
145
def apply (wireguard ):
126
146
check_kmod ('wireguard' )
127
147
@@ -157,8 +177,11 @@ def apply(wireguard):
157
177
domain_action = 'stop'
158
178
call (f'systemctl { domain_action } vyos-domain-resolver.service' )
159
179
180
+ call_dependents ()
181
+
160
182
return None
161
183
184
+
162
185
if __name__ == '__main__' :
163
186
try :
164
187
c = get_config ()
0 commit comments