Skip to content

Commit d7900dd

Browse files
authored
[config][generic-update] Implementing patch sorting (2nd attempt) (sonic-net#1794)
#### What I did Implemented [JSON Patch Ordering using YANG Models Design Doc](https://github.com/Azure/SONiC/blob/master/doc/config-generic-update-rollback/Json_Patch_Ordering_using_YANG_Models_Design.md) #### How to verify it Unit-Tests **NOTE: The code in this PR was [reverted](github.com/Azure/sonic-utilities/commit/0a145e8027380e8d4decb36bdfc647062c722612) before because of some [build issues](sonic-net/sonic-utilities#1761). Build issues have been fixed [here](sonic-net#8632). To check the original PR comments please go [here](sonic-net/sonic-utilities#1599
1 parent 7ed9a91 commit d7900dd

24 files changed

Lines changed: 4077 additions & 23 deletions

generic_config_updater/generic_updater.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from enum import Enum
44
from .gu_common import GenericConfigUpdaterError, ConfigWrapper, \
55
DryRunConfigWrapper, PatchWrapper
6+
from .patch_sorter import PatchSorter
67

78
CHECKPOINTS_DIR = "/etc/sonic/checkpoints"
89
CHECKPOINT_EXT = ".cp.json"
@@ -16,11 +17,6 @@ def release_lock(self):
1617
# TODO: Implement ConfigLock
1718
pass
1819

19-
class PatchSorter:
20-
def sort(self, patch):
21-
# TODO: Implement patch sorter
22-
raise NotImplementedError("PatchSorter.sort(patch) is not implemented yet")
23-
2420
class ChangeApplier:
2521
def apply(self, change):
2622
# TODO: Implement change applier
@@ -36,7 +32,7 @@ def __init__(self,
3632
changeapplier=None,
3733
config_wrapper=None,
3834
patch_wrapper=None):
39-
self.patchsorter = patchsorter if patchsorter is not None else PatchSorter()
35+
self.patchsorter = patchsorter if patchsorter is not None else PatchSorter(config_wrapper, patch_wrapper)
4036
self.changeapplier = changeapplier if changeapplier is not None else ChangeApplier()
4137
self.config_wrapper = config_wrapper if config_wrapper is not None else ConfigWrapper()
4238
self.patch_wrapper = patch_wrapper if patch_wrapper is not None else PatchWrapper()

0 commit comments

Comments
 (0)