@@ -718,6 +718,8 @@ func CreateAppProfile(obj *AppProfile) error {
718
718
return errors .New ("Invalid object type" )
719
719
}
720
720
721
+ saveObj := obj
722
+
721
723
// Check if object already exists
722
724
if collections .appProfiles [obj .Key ] != nil {
723
725
// Perform Update callback
@@ -726,6 +728,9 @@ func CreateAppProfile(obj *AppProfile) error {
726
728
log .Errorf ("AppProfileUpdate retruned error for: %+v. Err: %v" , obj , err )
727
729
return err
728
730
}
731
+
732
+ // save the original object after update
733
+ saveObj = collections .appProfiles [obj .Key ]
729
734
} else {
730
735
// save it in cache
731
736
collections .appProfiles [obj .Key ] = obj
@@ -740,9 +745,9 @@ func CreateAppProfile(obj *AppProfile) error {
740
745
}
741
746
742
747
// Write it to modeldb
743
- err = obj .Write ()
748
+ err = saveObj .Write ()
744
749
if err != nil {
745
- log .Errorf ("Error saving appProfile %s to db. Err: %v" , obj .Key , err )
750
+ log .Errorf ("Error saving appProfile %s to db. Err: %v" , saveObj .Key , err )
746
751
return err
747
752
}
748
753
@@ -952,6 +957,8 @@ func CreateEndpointGroup(obj *EndpointGroup) error {
952
957
return errors .New ("Invalid object type" )
953
958
}
954
959
960
+ saveObj := obj
961
+
955
962
// Check if object already exists
956
963
if collections .endpointGroups [obj .Key ] != nil {
957
964
// Perform Update callback
@@ -960,6 +967,9 @@ func CreateEndpointGroup(obj *EndpointGroup) error {
960
967
log .Errorf ("EndpointGroupUpdate retruned error for: %+v. Err: %v" , obj , err )
961
968
return err
962
969
}
970
+
971
+ // save the original object after update
972
+ saveObj = collections .endpointGroups [obj .Key ]
963
973
} else {
964
974
// save it in cache
965
975
collections .endpointGroups [obj .Key ] = obj
@@ -974,9 +984,9 @@ func CreateEndpointGroup(obj *EndpointGroup) error {
974
984
}
975
985
976
986
// Write it to modeldb
977
- err = obj .Write ()
987
+ err = saveObj .Write ()
978
988
if err != nil {
979
- log .Errorf ("Error saving endpointGroup %s to db. Err: %v" , obj .Key , err )
989
+ log .Errorf ("Error saving endpointGroup %s to db. Err: %v" , saveObj .Key , err )
980
990
return err
981
991
}
982
992
@@ -1186,6 +1196,8 @@ func CreateGlobal(obj *Global) error {
1186
1196
return errors .New ("Invalid object type" )
1187
1197
}
1188
1198
1199
+ saveObj := obj
1200
+
1189
1201
// Check if object already exists
1190
1202
if collections .globals [obj .Key ] != nil {
1191
1203
// Perform Update callback
@@ -1194,6 +1206,9 @@ func CreateGlobal(obj *Global) error {
1194
1206
log .Errorf ("GlobalUpdate retruned error for: %+v. Err: %v" , obj , err )
1195
1207
return err
1196
1208
}
1209
+
1210
+ // save the original object after update
1211
+ saveObj = collections .globals [obj .Key ]
1197
1212
} else {
1198
1213
// save it in cache
1199
1214
collections .globals [obj .Key ] = obj
@@ -1208,9 +1223,9 @@ func CreateGlobal(obj *Global) error {
1208
1223
}
1209
1224
1210
1225
// Write it to modeldb
1211
- err = obj .Write ()
1226
+ err = saveObj .Write ()
1212
1227
if err != nil {
1213
- log .Errorf ("Error saving global %s to db. Err: %v" , obj .Key , err )
1228
+ log .Errorf ("Error saving global %s to db. Err: %v" , saveObj .Key , err )
1214
1229
return err
1215
1230
}
1216
1231
@@ -1438,6 +1453,8 @@ func CreateBgp(obj *Bgp) error {
1438
1453
return errors .New ("Invalid object type" )
1439
1454
}
1440
1455
1456
+ saveObj := obj
1457
+
1441
1458
// Check if object already exists
1442
1459
if collections .Bgps [obj .Key ] != nil {
1443
1460
// Perform Update callback
@@ -1446,6 +1463,9 @@ func CreateBgp(obj *Bgp) error {
1446
1463
log .Errorf ("BgpUpdate retruned error for: %+v. Err: %v" , obj , err )
1447
1464
return err
1448
1465
}
1466
+
1467
+ // save the original object after update
1468
+ saveObj = collections .Bgps [obj .Key ]
1449
1469
} else {
1450
1470
// save it in cache
1451
1471
collections .Bgps [obj .Key ] = obj
@@ -1460,9 +1480,9 @@ func CreateBgp(obj *Bgp) error {
1460
1480
}
1461
1481
1462
1482
// Write it to modeldb
1463
- err = obj .Write ()
1483
+ err = saveObj .Write ()
1464
1484
if err != nil {
1465
- log .Errorf ("Error saving Bgp %s to db. Err: %v" , obj .Key , err )
1485
+ log .Errorf ("Error saving Bgp %s to db. Err: %v" , saveObj .Key , err )
1466
1486
return err
1467
1487
}
1468
1488
@@ -1692,6 +1712,8 @@ func CreateNetwork(obj *Network) error {
1692
1712
return errors .New ("Invalid object type" )
1693
1713
}
1694
1714
1715
+ saveObj := obj
1716
+
1695
1717
// Check if object already exists
1696
1718
if collections .networks [obj .Key ] != nil {
1697
1719
// Perform Update callback
@@ -1700,6 +1722,9 @@ func CreateNetwork(obj *Network) error {
1700
1722
log .Errorf ("NetworkUpdate retruned error for: %+v. Err: %v" , obj , err )
1701
1723
return err
1702
1724
}
1725
+
1726
+ // save the original object after update
1727
+ saveObj = collections .networks [obj .Key ]
1703
1728
} else {
1704
1729
// save it in cache
1705
1730
collections .networks [obj .Key ] = obj
@@ -1714,9 +1739,9 @@ func CreateNetwork(obj *Network) error {
1714
1739
}
1715
1740
1716
1741
// Write it to modeldb
1717
- err = obj .Write ()
1742
+ err = saveObj .Write ()
1718
1743
if err != nil {
1719
- log .Errorf ("Error saving network %s to db. Err: %v" , obj .Key , err )
1744
+ log .Errorf ("Error saving network %s to db. Err: %v" , saveObj .Key , err )
1720
1745
return err
1721
1746
}
1722
1747
@@ -1944,6 +1969,8 @@ func CreatePolicy(obj *Policy) error {
1944
1969
return errors .New ("Invalid object type" )
1945
1970
}
1946
1971
1972
+ saveObj := obj
1973
+
1947
1974
// Check if object already exists
1948
1975
if collections .policys [obj .Key ] != nil {
1949
1976
// Perform Update callback
@@ -1952,6 +1979,9 @@ func CreatePolicy(obj *Policy) error {
1952
1979
log .Errorf ("PolicyUpdate retruned error for: %+v. Err: %v" , obj , err )
1953
1980
return err
1954
1981
}
1982
+
1983
+ // save the original object after update
1984
+ saveObj = collections .policys [obj .Key ]
1955
1985
} else {
1956
1986
// save it in cache
1957
1987
collections .policys [obj .Key ] = obj
@@ -1966,9 +1996,9 @@ func CreatePolicy(obj *Policy) error {
1966
1996
}
1967
1997
1968
1998
// Write it to modeldb
1969
- err = obj .Write ()
1999
+ err = saveObj .Write ()
1970
2000
if err != nil {
1971
- log .Errorf ("Error saving policy %s to db. Err: %v" , obj .Key , err )
2001
+ log .Errorf ("Error saving policy %s to db. Err: %v" , saveObj .Key , err )
1972
2002
return err
1973
2003
}
1974
2004
@@ -2178,6 +2208,8 @@ func CreateRule(obj *Rule) error {
2178
2208
return errors .New ("Invalid object type" )
2179
2209
}
2180
2210
2211
+ saveObj := obj
2212
+
2181
2213
// Check if object already exists
2182
2214
if collections .rules [obj .Key ] != nil {
2183
2215
// Perform Update callback
@@ -2186,6 +2218,9 @@ func CreateRule(obj *Rule) error {
2186
2218
log .Errorf ("RuleUpdate retruned error for: %+v. Err: %v" , obj , err )
2187
2219
return err
2188
2220
}
2221
+
2222
+ // save the original object after update
2223
+ saveObj = collections .rules [obj .Key ]
2189
2224
} else {
2190
2225
// save it in cache
2191
2226
collections .rules [obj .Key ] = obj
@@ -2200,9 +2235,9 @@ func CreateRule(obj *Rule) error {
2200
2235
}
2201
2236
2202
2237
// Write it to modeldb
2203
- err = obj .Write ()
2238
+ err = saveObj .Write ()
2204
2239
if err != nil {
2205
- log .Errorf ("Error saving rule %s to db. Err: %v" , obj .Key , err )
2240
+ log .Errorf ("Error saving rule %s to db. Err: %v" , saveObj .Key , err )
2206
2241
return err
2207
2242
}
2208
2243
@@ -2471,6 +2506,8 @@ func CreateService(obj *Service) error {
2471
2506
return errors .New ("Invalid object type" )
2472
2507
}
2473
2508
2509
+ saveObj := obj
2510
+
2474
2511
// Check if object already exists
2475
2512
if collections .services [obj .Key ] != nil {
2476
2513
// Perform Update callback
@@ -2479,6 +2516,9 @@ func CreateService(obj *Service) error {
2479
2516
log .Errorf ("ServiceUpdate retruned error for: %+v. Err: %v" , obj , err )
2480
2517
return err
2481
2518
}
2519
+
2520
+ // save the original object after update
2521
+ saveObj = collections .services [obj .Key ]
2482
2522
} else {
2483
2523
// save it in cache
2484
2524
collections .services [obj .Key ] = obj
@@ -2493,9 +2533,9 @@ func CreateService(obj *Service) error {
2493
2533
}
2494
2534
2495
2535
// Write it to modeldb
2496
- err = obj .Write ()
2536
+ err = saveObj .Write ()
2497
2537
if err != nil {
2498
- log .Errorf ("Error saving service %s to db. Err: %v" , obj .Key , err )
2538
+ log .Errorf ("Error saving service %s to db. Err: %v" , saveObj .Key , err )
2499
2539
return err
2500
2540
}
2501
2541
@@ -2705,6 +2745,8 @@ func CreateServiceInstance(obj *ServiceInstance) error {
2705
2745
return errors .New ("Invalid object type" )
2706
2746
}
2707
2747
2748
+ saveObj := obj
2749
+
2708
2750
// Check if object already exists
2709
2751
if collections .serviceInstances [obj .Key ] != nil {
2710
2752
// Perform Update callback
@@ -2713,6 +2755,9 @@ func CreateServiceInstance(obj *ServiceInstance) error {
2713
2755
log .Errorf ("ServiceInstanceUpdate retruned error for: %+v. Err: %v" , obj , err )
2714
2756
return err
2715
2757
}
2758
+
2759
+ // save the original object after update
2760
+ saveObj = collections .serviceInstances [obj .Key ]
2716
2761
} else {
2717
2762
// save it in cache
2718
2763
collections .serviceInstances [obj .Key ] = obj
@@ -2727,9 +2772,9 @@ func CreateServiceInstance(obj *ServiceInstance) error {
2727
2772
}
2728
2773
2729
2774
// Write it to modeldb
2730
- err = obj .Write ()
2775
+ err = saveObj .Write ()
2731
2776
if err != nil {
2732
- log .Errorf ("Error saving serviceInstance %s to db. Err: %v" , obj .Key , err )
2777
+ log .Errorf ("Error saving serviceInstance %s to db. Err: %v" , saveObj .Key , err )
2733
2778
return err
2734
2779
}
2735
2780
@@ -2939,6 +2984,8 @@ func CreateTenant(obj *Tenant) error {
2939
2984
return errors .New ("Invalid object type" )
2940
2985
}
2941
2986
2987
+ saveObj := obj
2988
+
2942
2989
// Check if object already exists
2943
2990
if collections .tenants [obj .Key ] != nil {
2944
2991
// Perform Update callback
@@ -2947,6 +2994,9 @@ func CreateTenant(obj *Tenant) error {
2947
2994
log .Errorf ("TenantUpdate retruned error for: %+v. Err: %v" , obj , err )
2948
2995
return err
2949
2996
}
2997
+
2998
+ // save the original object after update
2999
+ saveObj = collections .tenants [obj .Key ]
2950
3000
} else {
2951
3001
// save it in cache
2952
3002
collections .tenants [obj .Key ] = obj
@@ -2961,9 +3011,9 @@ func CreateTenant(obj *Tenant) error {
2961
3011
}
2962
3012
2963
3013
// Write it to modeldb
2964
- err = obj .Write ()
3014
+ err = saveObj .Write ()
2965
3015
if err != nil {
2966
- log .Errorf ("Error saving tenant %s to db. Err: %v" , obj .Key , err )
3016
+ log .Errorf ("Error saving tenant %s to db. Err: %v" , saveObj .Key , err )
2967
3017
return err
2968
3018
}
2969
3019
@@ -3181,6 +3231,8 @@ func CreateVolume(obj *Volume) error {
3181
3231
return errors .New ("Invalid object type" )
3182
3232
}
3183
3233
3234
+ saveObj := obj
3235
+
3184
3236
// Check if object already exists
3185
3237
if collections .volumes [obj .Key ] != nil {
3186
3238
// Perform Update callback
@@ -3189,6 +3241,9 @@ func CreateVolume(obj *Volume) error {
3189
3241
log .Errorf ("VolumeUpdate retruned error for: %+v. Err: %v" , obj , err )
3190
3242
return err
3191
3243
}
3244
+
3245
+ // save the original object after update
3246
+ saveObj = collections .volumes [obj .Key ]
3192
3247
} else {
3193
3248
// save it in cache
3194
3249
collections .volumes [obj .Key ] = obj
@@ -3203,9 +3258,9 @@ func CreateVolume(obj *Volume) error {
3203
3258
}
3204
3259
3205
3260
// Write it to modeldb
3206
- err = obj .Write ()
3261
+ err = saveObj .Write ()
3207
3262
if err != nil {
3208
- log .Errorf ("Error saving volume %s to db. Err: %v" , obj .Key , err )
3263
+ log .Errorf ("Error saving volume %s to db. Err: %v" , saveObj .Key , err )
3209
3264
return err
3210
3265
}
3211
3266
@@ -3415,6 +3470,8 @@ func CreateVolumeProfile(obj *VolumeProfile) error {
3415
3470
return errors .New ("Invalid object type" )
3416
3471
}
3417
3472
3473
+ saveObj := obj
3474
+
3418
3475
// Check if object already exists
3419
3476
if collections .volumeProfiles [obj .Key ] != nil {
3420
3477
// Perform Update callback
@@ -3423,6 +3480,9 @@ func CreateVolumeProfile(obj *VolumeProfile) error {
3423
3480
log .Errorf ("VolumeProfileUpdate retruned error for: %+v. Err: %v" , obj , err )
3424
3481
return err
3425
3482
}
3483
+
3484
+ // save the original object after update
3485
+ saveObj = collections .volumeProfiles [obj .Key ]
3426
3486
} else {
3427
3487
// save it in cache
3428
3488
collections .volumeProfiles [obj .Key ] = obj
@@ -3437,9 +3497,9 @@ func CreateVolumeProfile(obj *VolumeProfile) error {
3437
3497
}
3438
3498
3439
3499
// Write it to modeldb
3440
- err = obj .Write ()
3500
+ err = saveObj .Write ()
3441
3501
if err != nil {
3442
- log .Errorf ("Error saving volumeProfile %s to db. Err: %v" , obj .Key , err )
3502
+ log .Errorf ("Error saving volumeProfile %s to db. Err: %v" , saveObj .Key , err )
3443
3503
return err
3444
3504
}
3445
3505
0 commit comments