@@ -1354,6 +1354,21 @@ func hdl_post_xfmr_pim_rp_address_del_(inParams *XfmrParams, niName string, retD
1354
1354
log .Info ("After PIM Post-Transformer PIM_GLOBALS_RENDEZVOUS_POINT handler ==> retDbDataMap : " , (* retDbDataMap ))
1355
1355
}
1356
1356
1357
+ func pim_add_null_null_attr_to_pim_globals (pimGblKey string , inParams * XfmrParams ) {
1358
+ resMap := make (map [string ]map [string ]db.Value )
1359
+ pimGblMap := make (map [string ]db.Value )
1360
+ pimGblMap [pimGblKey ] = db.Value {Field : map [string ]string {}}
1361
+ resMap ["PIM_GLOBALS" ] = pimGblMap
1362
+
1363
+ if inParams .subOpDataMap [UPDATE ] != nil && (* inParams.subOpDataMap [UPDATE ])[db.ConfigDB ] != nil {
1364
+ mapCopy ((* inParams.subOpDataMap [UPDATE ])[db.ConfigDB ], resMap )
1365
+ } else {
1366
+ subOpMap := make (map [db.DBNum ]map [string ]map [string ]db.Value )
1367
+ subOpMap [db .ConfigDB ] = resMap
1368
+ inParams .subOpDataMap [UPDATE ] = & subOpMap
1369
+ }
1370
+ }
1371
+
1357
1372
func pim_hdl_post_xfmr (inParams * XfmrParams , retDbDataMap * map [string ]map [string ]db.Value ) error {
1358
1373
var err error
1359
1374
@@ -1399,6 +1414,42 @@ func pim_hdl_post_xfmr(inParams *XfmrParams, retDbDataMap *map[string]map[string
1399
1414
}
1400
1415
}
1401
1416
1417
+ /*
1418
+ For REST-delete @ URI: pim/global to cleanup rendezvous-points as well along with other pim/global containers,
1419
+ PIM_GLOBALS table is expected to have a valid entry in DB. But attributes directly under PIM_GLOBALS are not mandatory.
1420
+ To fix those cases,
1421
+ (1) Adding NULL/NULL attribute to PIM_GLOBALS entry on PIM_GLOBALS_RENDEZVOUS_POINT CRU. This addition internally creates
1422
+ the PIM_GLOBALS entry, if not present in DB
1423
+ (2) Internally adding NULL/NULL attribute to the PIM_GLOBALS entry on leaf delete to
1424
+ make sure PIM_GLOBALS entry is not deleted by infra-code on last-leaf delete.
1425
+ */
1426
+ if (inParams .oper == CREATE || inParams .oper == REPLACE || inParams .oper == UPDATE ) && (retDbDataMap != nil ) {
1427
+ depTblsNeedClnup := []string {"PIM_GLOBALS_RENDEZVOUS_POINT" } /* Add future tables under pim/global container to this list */
1428
+ if _ , ok := (* retDbDataMap )["PIM_GLOBALS" ]; ! ok {
1429
+ addedPimGblKeys := make (map [string ]bool )
1430
+ for _ , depTbl := range depTblsNeedClnup {
1431
+ if depTblData , ok := (* retDbDataMap )[depTbl ]; ok {
1432
+ for depTblKey := range depTblData {
1433
+ keyPtrn := strings .Split (depTblKey , "|" )
1434
+ pimGblKey := keyPtrn [0 ] + "|" + keyPtrn [1 ]
1435
+ if _ , ok := addedPimGblKeys [pimGblKey ]; ! ok {
1436
+ pim_add_null_null_attr_to_pim_globals (pimGblKey , inParams )
1437
+ addedPimGblKeys [pimGblKey ] = true
1438
+ }
1439
+ }
1440
+ }
1441
+ }
1442
+ }
1443
+ } else if (inParams .oper == DELETE ) && (inParams .dbDataMap != nil ) {
1444
+ if pimGblData , ok := (* inParams .dbDataMap )[db .ConfigDB ]["PIM_GLOBALS" ]; ok {
1445
+ for pimGblKey := range pimGblData {
1446
+ if pimGblVal , ok := pimGblData [pimGblKey ]; ok && (len (pimGblVal .Field ) > 0 ) {
1447
+ pim_add_null_null_attr_to_pim_globals (pimGblKey , inParams )
1448
+ }
1449
+ }
1450
+ }
1451
+ }
1452
+
1402
1453
return err
1403
1454
}
1404
1455
0 commit comments