Send POLICY_UPDATE when updating existing policy instance 31/4831/3
authorAbukar Mohamed <abukar.mohamed@nokia.com>
Mon, 12 Oct 2020 05:22:42 +0000 (05:22 +0000)
committerAbukar Mohamed <abukar.mohamed@nokia.com>
Tue, 13 Oct 2020 05:47:05 +0000 (05:47 +0000)
Change-Id: I01c2e717eec96cb212e6a6f4bdddfa9931fe4385
Signed-off-by: Abukar Mohamed <abukar.mohamed@nokia.com>
a1/controller.py
a1/data.py
container-tag.yaml

index 9de9c00..e00946a 100644 (file)
@@ -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
 
index a9301d8..436912f 100644 (file)
@@ -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):
     """
index 5781531..8464b13 100644 (file)
@@ -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