[SEBA-547] TP NEM Integration

Change-Id: I6c0dab752f4728d5f6a777ea297321ebb75de769
diff --git a/xos/synchronizer/models/models.py b/xos/synchronizer/models/models.py
index 4d5b8b8..59b6e66 100644
--- a/xos/synchronizer/models/models.py
+++ b/xos/synchronizer/models/models.py
@@ -25,6 +25,9 @@
 from models_decl import ONUDevice_decl
 from models_decl import PONONUPort_decl
 from models_decl import UNIPort_decl
+from models_decl import TechnologyProfile_decl
+
+import json
 
 class VOLTService(VOLTService_decl):
     class Meta:
@@ -116,3 +119,28 @@
     class Meta:
         proxy = True
 
+class TechnologyProfile(TechnologyProfile_decl):
+    class Meta:
+        proxy = True
+
+    def save(self, *args, **kwargs):
+
+        caller_kind = None
+        if "caller_kind" in kwargs:
+            caller_kind = kwargs.get("caller_kind")
+
+        # only synchronizer is allowed to update the model
+        if not self.is_new and caller_kind != "synchronizer":
+            if not self.deleted:
+                existing = TechnologyProfile.objects.filter(id=self.id)
+                raise XOSValidationError('Modification operation is not allowed on Technology Profile [/%s/%s]. Delete it and add again' % (existing[0].technology, existing[0].profile_id))
+
+        # validate if technology profile value is valid JSON format string
+        if self.profile_value != None:
+            try:
+                tp_json_val = json.loads(self.profile_value)
+            except ValueError as e:
+                raise XOSValidationError('Technology Profile value not in valid JSON format')
+
+        super(TechnologyProfile, self).save(*args, **kwargs)
+