From e348b5507c24f599cf1560e928e3b3dfd07dc683 Mon Sep 17 00:00:00 2001 From: Abukar Mohamed Date: Mon, 12 Oct 2020 05:22:42 +0000 Subject: [PATCH] Send POLICY_UPDATE when updating existing policy instance Change-Id: I01c2e717eec96cb212e6a6f4bdddfa9931fe4385 Signed-off-by: Abukar Mohamed --- a1/controller.py | 4 ++-- a1/data.py | 4 ++++ container-tag.yaml | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/a1/controller.py b/a1/controller.py index 9de9c00..e00946a 100644 --- a/a1/controller.py +++ b/a1/controller.py @@ -176,10 +176,10 @@ def create_or_replace_policy_instance(policy_type_id, policy_instance_id): validate(instance=instance, schema=schema) # store the instance - data.store_policy_instance(policy_type_id, policy_instance_id, instance) + operation = data.store_policy_instance(policy_type_id, policy_instance_id, instance) # queue rmr send (best effort) - a1rmr.queue_instance_send(("CREATE", policy_type_id, policy_instance_id, instance)) + a1rmr.queue_instance_send((operation, policy_type_id, policy_instance_id, instance)) return "", 202 diff --git a/a1/data.py b/a1/data.py index a9301d8..436912f 100644 --- a/a1/data.py +++ b/a1/data.py @@ -204,8 +204,10 @@ def store_policy_instance(policy_type_id, policy_instance_id, instance): creation_timestamp = time.time() # store the instance + operation = "CREATE" key = _generate_instance_key(policy_type_id, policy_instance_id) if SDL.get(A1NS, key) is not None: + operation = "UPDATE" # Reset the statuses because this is a new policy instance, even if it was overwritten _clear_handlers(policy_type_id, policy_instance_id) # delete all the handlers SDL.set(A1NS, key, instance) @@ -213,6 +215,8 @@ def store_policy_instance(policy_type_id, policy_instance_id, instance): metadata_key = _generate_instance_metadata_key(policy_type_id, policy_instance_id) SDL.set(A1NS, metadata_key, {"created_at": creation_timestamp, "has_been_deleted": False}) + return operation + def get_policy_instance(policy_type_id, policy_instance_id): """ diff --git a/container-tag.yaml b/container-tag.yaml index 5781531..8464b13 100644 --- a/container-tag.yaml +++ b/container-tag.yaml @@ -1,4 +1,4 @@ # The Jenkins job uses this string for the tag in the image name # for example nexus3.o-ran-sc.org:10004/my-image-name:my-tag --- -tag: 2.2.0 +tag: 2.3.0 -- 2.16.6