[CORD-2640] Storing active enodeb relation in the datamodel and not in memory

Change-Id: I950dacc6ace738e2816f6e949400e633cc8554a5
diff --git a/xos/models/models.py b/xos/models/models.py
index bf9161f..692b1aa 100644
--- a/xos/models/models.py
+++ b/xos/models/models.py
@@ -64,21 +64,14 @@
         except IndexError:
             raise XOSValidationError("Service Progran cannot be found, please make sure that the model exists.")
 
-        # NOTE if the instance is new, check that the name is not duplicated
-        instances_with_same_name = None
-        # FIXME This may leave us vulnerable to someone changing the name at a later time and causing a conflict.
-        # If that's important to prevent, we could prevent that case when `self.pk!=None`,
-        # filter for ProgranServiceInstance with the same name but `pk!=self.pk`.
-        if self.pk is None:
-            try:
-                instances_with_same_name = ProgranServiceInstance.objects.get(name=self.name)
-            except self.DoesNotExist:
-                # it's ok not to find anything here
-                pass
+        # prevent name duplicates
+        try:
+            instances_with_same_name = ProgranServiceInstance.objects.get(name=self.name)
 
-        if instances_with_same_name:
-            raise XOSValidationError("A ProgranServiceInstance with name '%s' already exists" % self.name)
-
+            if (not self.pk and instances_with_same_name) or (self.pk and self.pk != instances_with_same_name.pk):
+                raise XOSValidationError("A ProgranServiceInstance with name '%s' already exists" % self.name)
+        except self.DoesNotExist:
+            pass
 
         # TODO when saving set status to "in progress"
         super(ProgranServiceInstance, self).save(*args, **kwargs)
diff --git a/xos/models/progran.xproto b/xos/models/progran.xproto
index ad0a378..5b1a54c 100644
--- a/xos/models/progran.xproto
+++ b/xos/models/progran.xproto
@@ -50,6 +50,7 @@
     required string SubsProfile = 13 [ db_index = False, null = True, blank = True];
     optional manytoone enodeb->ENodeB:profiles = 14 [null = True, blank = True];
     required manytoone handover->Handover:profiles = 15 [null = False, blank = False];
+    optional int32 active_enodeb_id = 16 [null = True, blank = True, gui_hidden = True];
 }