5
5
DryRunConfigWrapper , PatchWrapper , genericUpdaterLogging
6
6
from .patch_sorter import StrictPatchSorter , NonStrictPatchSorter , ConfigSplitter , \
7
7
TablesWithoutYangConfigSplitter , IgnorePathsFromYangConfigSplitter
8
- from .change_applier import ChangeApplier
8
+ from .change_applier import ChangeApplier , DryRunChangeApplier
9
9
10
10
CHECKPOINTS_DIR = "/etc/sonic/checkpoints"
11
11
CHECKPOINT_EXT = ".cp.json"
@@ -299,9 +299,13 @@ class GenericUpdateFactory:
299
299
def create_patch_applier (self , config_format , verbose , dry_run , ignore_non_yang_tables , ignore_paths ):
300
300
self .init_verbose_logging (verbose )
301
301
config_wrapper = self .get_config_wrapper (dry_run )
302
+ change_applier = self .get_change_applier (dry_run , config_wrapper )
302
303
patch_wrapper = PatchWrapper (config_wrapper )
303
304
patch_sorter = self .get_patch_sorter (ignore_non_yang_tables , ignore_paths , config_wrapper , patch_wrapper )
304
- patch_applier = PatchApplier (config_wrapper = config_wrapper , patchsorter = patch_sorter , patch_wrapper = patch_wrapper )
305
+ patch_applier = PatchApplier (config_wrapper = config_wrapper ,
306
+ patchsorter = patch_sorter ,
307
+ patch_wrapper = patch_wrapper ,
308
+ changeapplier = change_applier )
305
309
306
310
if config_format == ConfigFormat .CONFIGDB :
307
311
pass
@@ -320,9 +324,13 @@ def create_config_replacer(self, config_format, verbose, dry_run, ignore_non_yan
320
324
self .init_verbose_logging (verbose )
321
325
322
326
config_wrapper = self .get_config_wrapper (dry_run )
327
+ change_applier = self .get_change_applier (dry_run , config_wrapper )
323
328
patch_wrapper = PatchWrapper (config_wrapper )
324
329
patch_sorter = self .get_patch_sorter (ignore_non_yang_tables , ignore_paths , config_wrapper , patch_wrapper )
325
- patch_applier = PatchApplier (config_wrapper = config_wrapper , patchsorter = patch_sorter , patch_wrapper = patch_wrapper )
330
+ patch_applier = PatchApplier (config_wrapper = config_wrapper ,
331
+ patchsorter = patch_sorter ,
332
+ patch_wrapper = patch_wrapper ,
333
+ changeapplier = change_applier )
326
334
327
335
config_replacer = ConfigReplacer (patch_applier = patch_applier , config_wrapper = config_wrapper )
328
336
if config_format == ConfigFormat .CONFIGDB :
@@ -342,9 +350,13 @@ def create_config_rollbacker(self, verbose, dry_run=False, ignore_non_yang_table
342
350
self .init_verbose_logging (verbose )
343
351
344
352
config_wrapper = self .get_config_wrapper (dry_run )
353
+ change_applier = self .get_change_applier (dry_run , config_wrapper )
345
354
patch_wrapper = PatchWrapper (config_wrapper )
346
355
patch_sorter = self .get_patch_sorter (ignore_non_yang_tables , ignore_paths , config_wrapper , patch_wrapper )
347
- patch_applier = PatchApplier (config_wrapper = config_wrapper , patchsorter = patch_sorter , patch_wrapper = patch_wrapper )
356
+ patch_applier = PatchApplier (config_wrapper = config_wrapper ,
357
+ patchsorter = patch_sorter ,
358
+ patch_wrapper = patch_wrapper ,
359
+ changeapplier = change_applier )
348
360
349
361
config_replacer = ConfigReplacer (config_wrapper = config_wrapper , patch_applier = patch_applier )
350
362
config_rollbacker = FileSystemConfigRollbacker (config_wrapper = config_wrapper , config_replacer = config_replacer )
@@ -363,6 +375,12 @@ def get_config_wrapper(self, dry_run):
363
375
else :
364
376
return ConfigWrapper ()
365
377
378
+ def get_change_applier (self , dry_run , config_wrapper ):
379
+ if dry_run :
380
+ return DryRunChangeApplier (config_wrapper )
381
+ else :
382
+ return ChangeApplier ()
383
+
366
384
def get_patch_sorter (self , ignore_non_yang_tables , ignore_paths , config_wrapper , patch_wrapper ):
367
385
if not ignore_non_yang_tables and not ignore_paths :
368
386
return StrictPatchSorter (config_wrapper , patch_wrapper )
0 commit comments