From 6305a1a70d9bbcd1f393bafc2c9e390d2066cf66 Mon Sep 17 00:00:00 2001
From: Andre Mauricio Zelak <andre.zelak@windriver.com>
Date: Fri, 10 Feb 2023 14:18:53 -0300
Subject: [PATCH] Use all-caps state in O-RAN timing notification

All synchronization states of LOCKED, HOLDOVER, and FREERUN need to be
all-caps in the state change event notifications. This is a requirement
of O-Cloud Notification API Specification for Event Consumers -
O-RAN.WG6.O-Cloud Notification API-v03.00.

Changed the JSON message body of the Sync OS clock, Sync Sync State,
GNSS sync status and Sync PTP Lock State to ensure all caps.

Updated ptp-notification V2 documentation to reflect the notification
message changes.

Test Plan:
PASS: Build container image
PASS: Manually deploy image and test with v2 client
PASS: Clycled through states
PASS: Restarted ptp-notification application and v2 client
received the events after starting the PTP notification pods.
PASS: ptp-tracking unit tests

Closes-bug: 2006941

Signed-off-by: Andre Mauricio Zelak <andre.zelak@windriver.com>
Change-Id: I351242504eb0dc79c0b17908609b8a8482f9cad6
---
 .../source/api_ptp_notifications_definition_v2.rst   | 12 ++++++------
 .../trackingfunctionsdk/services/daemon.py           | 10 +++++-----
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/api-ref/source/api_ptp_notifications_definition_v2.rst b/api-ref/source/api_ptp_notifications_definition_v2.rst
index b4dc77e..c25c920 100644
--- a/api-ref/source/api_ptp_notifications_definition_v2.rst
+++ b/api-ref/source/api_ptp_notifications_definition_v2.rst
@@ -275,7 +275,7 @@ This operation does not accept a request body.
                "data_type": "notification",
                "ResourceAddress": "/././sync/sync-status/sync-state",
                "value_type": "enumeration",
-               "value": "Locked"
+               "value": "LOCKED"
             }
          ]
       }
@@ -320,7 +320,7 @@ This operation does not accept a request body.
                   "data_type": "notification",
                   "ResourceAddress": "/././sync/ptp-status/lock-state",
                   "value_type": "enumeration",
-                  "value": "Locked"
+                  "value": "LOCKED"
                }
             ]
          }
@@ -343,7 +343,7 @@ This operation does not accept a request body.
                   "data_type": "notification",
                   "ResourceAddress": "/././sync/sync-status/os-clock-sync-state",
                   "value_type": "enumeration",
-                  "value": "Locked"
+                  "value": "LOCKED"
                }
             ]
          }
@@ -366,7 +366,7 @@ This operation does not accept a request body.
                   "data_type": "notification",
                   "ResourceAddress": "/././sync/sync-status/sync-state",
                   "value_type": "enumeration",
-                  "value": "Locked"
+                  "value": "LOCKED"
                }
             ]
          }
@@ -389,7 +389,7 @@ This operation does not accept a request body.
                   "data_type": "notification",
                   "ResourceAddress": "/././sync/gnss-status/gnss-sync-status",
                   "value_type": "enumeration",
-                  "value": "Locked"
+                  "value": "LOCKED"
                }
             ]
          }
@@ -461,7 +461,7 @@ badRequest (400), itemNotFound (404), tiemout(408)
                "data_type": "notification",
                "ResourceAddress": "/././sync/sync-status/sync-state",
                "value_type": "enumeration",
-               "value": "Holdover"
+               "value": "HOLDOVER"
             }
          ]
       }
diff --git a/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/services/daemon.py b/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/services/daemon.py
index 50af9d6..eb4f57b 100644
--- a/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/services/daemon.py
+++ b/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/services/daemon.py
@@ -109,7 +109,7 @@ class PtpWatcherDefault:
                             'data_type': data_type,
                             'ResourceAddress': resource_address,
                             'value_type': value_type,
-                            'value': sync_state
+                            'value': sync_state.upper()
                         }
                     ]
                 }
@@ -552,7 +552,7 @@ class PtpWatcherDefault:
                             'data_type': constants.DATA_TYPE_NOTIFICATION,
                             'ResourceAddress': resource_address,
                             'value_type': constants.VALUE_TYPE_ENUMERATION,
-                            'value': sync_state
+                            'value': sync_state.upper()
                         }
                     ]
                 }
@@ -598,7 +598,7 @@ class PtpWatcherDefault:
                             'data_type': constants.DATA_TYPE_NOTIFICATION,
                             'ResourceAddress': resource_address,
                             'value_type': constants.VALUE_TYPE_ENUMERATION,
-                            'value': sync_state
+                            'value': sync_state.upper()
                         }
                     ]
                 }
@@ -656,7 +656,7 @@ class PtpWatcherDefault:
                                 'data_type': constants.DATA_TYPE_NOTIFICATION,
                                 'ResourceAddress': resource_address,
                                 'value_type': constants.VALUE_TYPE_ENUMERATION,
-                                'value': sync_state
+                                'value': sync_state.upper()
                             }
                         ]
                     }
@@ -729,7 +729,7 @@ class PtpWatcherDefault:
                                 'data_type': constants.DATA_TYPE_NOTIFICATION,
                                 'ResourceAddress': resource_address,
                                 'value_type': constants.VALUE_TYPE_ENUMERATION,
-                                'value': sync_state
+                                'value': sync_state.upper()
                             }
                         ]
                     }