Commit ac71d74 1 parent 7419c67 commit ac71d74 Copy full SHA for ac71d74
File tree 3 files changed +42
-0
lines changed
3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ def del_vxlan(db, vxlan_name):
38
38
"""Del VXLAN"""
39
39
ctx = click .get_current_context ()
40
40
41
+ vxlan_keys = db .cfgdb .get_keys ('VXLAN_TUNNEL' )
42
+ if vxlan_name not in vxlan_keys :
43
+ ctx .fail ("Vxlan tunnel {} does not exist" .format (vxlan_name ))
44
+
41
45
vxlan_keys = db .cfgdb .get_keys ('VXLAN_EVPN_NVO' )
42
46
if not vxlan_keys :
43
47
vxlan_count = 0
@@ -56,6 +60,12 @@ def del_vxlan(db, vxlan_name):
56
60
if (vxlan_count > 0 ):
57
61
ctx .fail ("Please delete all VLAN VNI mappings." )
58
62
63
+ vnet_table = db .cfgdb .get_table ('VNET' )
64
+ vnet_keys = vnet_table .keys ()
65
+ for vnet_key in vnet_keys :
66
+ if ('vxlan_tunnel' in vnet_table [vnet_key ] and vnet_table [vnet_key ]['vxlan_tunnel' ] == vxlan_name ):
67
+ ctx .fail ("Please delete all VNET configuration referencing the tunnel " + vxlan_name )
68
+
59
69
db .cfgdb .set_entry ('VXLAN_TUNNEL' , vxlan_name , None )
60
70
61
71
@vxlan .group ('evpn_nvo' )
Original file line number Diff line number Diff line change
1
+ {
2
+ "VNET|Vnet_2000" : {
3
+ "peer_list" : " " ,
4
+ "vni" : " 2000" ,
5
+ "vxlan_tunnel" : " tunnel1"
6
+ },
7
+ "VXLAN_TUNNEL|tunnel1" : {
8
+ "src_ip" : " 10.10.10.10"
9
+ }
10
+ }
Original file line number Diff line number Diff line change 7
7
import config .main as config
8
8
import show .main as show
9
9
from utilities_common .db import Db
10
+ from .mock_tables import dbconnector
11
+
12
+ test_path = os .path .dirname (os .path .abspath (__file__ ))
13
+ mock_db_path = os .path .join (test_path , "vnet_input" )
10
14
11
15
show_vxlan_interface_output = """\
12
16
VTEP Information:
@@ -247,6 +251,24 @@ def test_config_vxlan_add(self):
247
251
assert result .exit_code == 0
248
252
assert result .output == show_vxlan_vlanvnimap_output
249
253
254
+ def test_config_vxlan_del (self ):
255
+ dbconnector .dedicated_dbs ['CONFIG_DB' ] = os .path .join (mock_db_path , 'config_db' )
256
+ db = Db ()
257
+ runner = CliRunner ()
258
+
259
+ result = runner .invoke (config .config .commands ["vxlan" ].commands ["del" ], ["tunnel_invalid" ], obj = db )
260
+ print (result .exit_code )
261
+ print (result .output )
262
+ assert result .exit_code != 0
263
+ assert "Error: Vxlan tunnel tunnel_invalid does not exist" in result .output
264
+
265
+ result = runner .invoke (config .config .commands ["vxlan" ].commands ["del" ], ["tunnel1" ], obj = db )
266
+ dbconnector .dedicated_dbs = {}
267
+ print (result .exit_code )
268
+ print (result .output )
269
+ assert result .exit_code != 0
270
+ assert "Please delete all VNET configuration referencing the tunnel" in result .output
271
+
250
272
@classmethod
251
273
def teardown_class (cls ):
252
274
os .environ ['UTILITIES_UNIT_TESTING' ] = "0"
You can’t perform that action at this time.
0 commit comments