From 7c9889b386f22ba032303c28cb2b74471ceb467a Mon Sep 17 00:00:00 2001 From: Roman Dodin Date: Fri, 6 Dec 2024 21:29:05 +0200 Subject: [PATCH] delete->replace->update ordering --- plugins/modules/config.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/modules/config.py b/plugins/modules/config.py index 1b2ed3f..a7565ab 100644 --- a/plugins/modules/config.py +++ b/plugins/modules/config.py @@ -176,15 +176,21 @@ def main(): yang_models = module.params.get("yang_models") confirm_timeout = module.params.get("confirm_timeout") + # since operations are modelled as a dict in this collection + # an ordering is implied when multiple operations are provided. + # we add all deletes, followed by replaces, and then followed by updates. + # this ordering should satisfy most use cases where multiple operations + # are bundled in a single request, where deletes are processed first and then + # replaces and updates can be used to enact new config values. commands = [] - for obj in updates: - obj["action"] = "update" + for obj in deletes: + obj["action"] = "delete" commands += [obj] for obj in replaces: obj["action"] = "replace" commands += [obj] - for obj in deletes: - obj["action"] = "delete" + for obj in updates: + obj["action"] = "update" commands += [obj] diff_resp = {}