@@ -101,7 +101,7 @@ def create_vlan(dvs, vlan_name, vlan_ids):
101
101
return
102
102
103
103
104
- def create_vxlan_tunnel (dvs , name , src_ip , dst_ip , tunnel_map_ids , tunnel_map_entry_ids , tunnel_ids , tunnel_term_ids , skip_dst_ip = False ):
104
+ def create_vxlan_tunnel (dvs , name , src_ip , dst_ip , tunnel_map_ids , tunnel_map_entry_ids , tunnel_ids , tunnel_term_ids , lo_id , skip_dst_ip = False ):
105
105
asic_db = swsscommon .DBConnector (swsscommon .ASIC_DB , dvs .redis_sock , 0 )
106
106
conf_db = swsscommon .DBConnector (swsscommon .CONFIG_DB , dvs .redis_sock , 0 )
107
107
@@ -143,13 +143,13 @@ def create_vxlan_tunnel(dvs, name, src_ip, dst_ip, tunnel_map_ids, tunnel_map_en
143
143
}
144
144
)
145
145
146
- # FIXME: !!!
147
- # check_object(asic_db, "ASIC_STATE:SAI_OBJECT_TYPE_TUNNEL", tunnel_id,
148
- # {
149
- # 'SAI_TUNNEL_ATTR_TYPE ': 'SAI_TUNNEL_TYPE_VXLAN' ,
150
- # 'SAI_TUNNEL_ATTR_DECAP_MAPPERS': '1:%s' % tunnel_map_id,
151
- # }
152
- # )
146
+ check_object ( asic_db , "ASIC_STATE:SAI_OBJECT_TYPE_TUNNEL" , tunnel_id ,
147
+ {
148
+ 'SAI_TUNNEL_ATTR_TYPE' : 'SAI_TUNNEL_TYPE_VXLAN' ,
149
+ 'SAI_TUNNEL_ATTR_UNDERLAY_INTERFACE ' : lo_id ,
150
+ 'SAI_TUNNEL_ATTR_DECAP_MAPPERS' : '1:%s' % tunnel_map_id ,
151
+ }
152
+ )
153
153
154
154
tunnel_type = 'SAI_TUNNEL_TERM_TABLE_ENTRY_TYPE_P2P' if dst_ip != '0.0.0.0' else 'SAI_TUNNEL_TERM_TABLE_ENTRY_TYPE_P2MP'
155
155
expected_attributes = {
@@ -214,15 +214,35 @@ def create_vxlan_tunnel_entry(dvs, tunnel_name, tunnel_map_entry_name, tunnel_ma
214
214
215
215
return
216
216
217
+ def get_lo (dvs ):
218
+ asic_db = swsscommon .DBConnector (swsscommon .ASIC_DB , dvs .redis_sock , 0 )
219
+ vr_id = get_default_vr_id (asic_db )
220
+
221
+ tbl = swsscommon .Table (asic_db , 'ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE' )
222
+
223
+ entries = tbl .getKeys ()
224
+ lo_id = None
225
+ for entry in entries :
226
+ status , fvs = tbl .get (entry )
227
+ assert status , "Got an error when get a key"
228
+ for key , value in fvs :
229
+ if key == 'SAI_ROUTER_INTERFACE_ATTR_TYPE' and value == 'SAI_ROUTER_INTERFACE_TYPE_LOOPBACK' :
230
+ lo_id = entry
231
+ break
232
+ else :
233
+ assert False , 'Don\' t found loopback id'
234
+
235
+ return lo_id
236
+
217
237
218
238
def test_vxlan_term_orch (dvs ):
219
- return
220
239
tunnel_map_ids = set ()
221
240
tunnel_map_entry_ids = set ()
222
241
tunnel_ids = set ()
223
242
tunnel_term_ids = set ()
224
243
tunnel_map_map = {}
225
244
vlan_ids = get_exist_entries (dvs , "ASIC_STATE:SAI_OBJECT_TYPE_VLAN" )
245
+ loopback_id = get_lo (dvs )
226
246
227
247
create_vlan (dvs , "Vlan50" , vlan_ids )
228
248
create_vlan (dvs , "Vlan51" , vlan_ids )
@@ -234,25 +254,25 @@ def test_vxlan_term_orch(dvs):
234
254
create_vlan (dvs , "Vlan57" , vlan_ids )
235
255
236
256
tunnel_map_map ['tunnel_1' ] = create_vxlan_tunnel (dvs , 'tunnel_1' , '10.0.0.1' , '100.100.100.1' ,
237
- tunnel_map_ids , tunnel_map_entry_ids , tunnel_ids , tunnel_term_ids )
257
+ tunnel_map_ids , tunnel_map_entry_ids , tunnel_ids , tunnel_term_ids , loopback_id )
238
258
239
259
create_vxlan_tunnel_entry (dvs , 'tunnel_1' , 'entry_1' , tunnel_map_map ['tunnel_1' ], 'Vlan50' , '850' ,
240
260
tunnel_map_ids , tunnel_map_entry_ids , tunnel_ids , tunnel_term_ids )
241
261
242
262
tunnel_map_map ['tunnel_2' ] = create_vxlan_tunnel (dvs , 'tunnel_2' , '11.0.0.2' , '101.101.101.2' ,
243
- tunnel_map_ids , tunnel_map_entry_ids , tunnel_ids , tunnel_term_ids )
263
+ tunnel_map_ids , tunnel_map_entry_ids , tunnel_ids , tunnel_term_ids , loopback_id )
244
264
245
265
create_vxlan_tunnel_entry (dvs , 'tunnel_2' , 'entry_1' , tunnel_map_map ['tunnel_2' ], 'Vlan51' , '851' ,
246
266
tunnel_map_ids , tunnel_map_entry_ids , tunnel_ids , tunnel_term_ids )
247
267
248
268
tunnel_map_map ['tunnel_3' ] = create_vxlan_tunnel (dvs , 'tunnel_3' , '12.0.0.3' , '0.0.0.0' ,
249
- tunnel_map_ids , tunnel_map_entry_ids , tunnel_ids , tunnel_term_ids )
269
+ tunnel_map_ids , tunnel_map_entry_ids , tunnel_ids , tunnel_term_ids , loopback_id )
250
270
251
271
create_vxlan_tunnel_entry (dvs , 'tunnel_3' , 'entry_1' , tunnel_map_map ['tunnel_3' ], 'Vlan52' , '852' ,
252
272
tunnel_map_ids , tunnel_map_entry_ids , tunnel_ids , tunnel_term_ids )
253
273
254
274
tunnel_map_map ['tunnel_4' ] = create_vxlan_tunnel (dvs , 'tunnel_4' , '15.0.0.5' , '0.0.0.0' ,
255
- tunnel_map_ids , tunnel_map_entry_ids , tunnel_ids , tunnel_term_ids , True )
275
+ tunnel_map_ids , tunnel_map_entry_ids , tunnel_ids , tunnel_term_ids , loopback_id , True )
256
276
257
277
create_vxlan_tunnel_entry (dvs , 'tunnel_4' , 'entry_1' , tunnel_map_map ['tunnel_4' ], 'Vlan53' , '853' ,
258
278
tunnel_map_ids , tunnel_map_entry_ids , tunnel_ids , tunnel_term_ids )
0 commit comments