[CORD-2640] Creating and deleting eNodeB

Change-Id: I5acc72415acfb29e096337cff450441878383e6a
diff --git a/xos/models/models.py b/xos/models/models.py
index 2e7df7b..594255a 100644
--- a/xos/models/models.py
+++ b/xos/models/models.py
@@ -15,6 +15,14 @@
 class ProgranService(ProgranService_decl):
     class Meta:
         proxy = True
+    def save(self, *args, **kwargs):
+
+        existing_services = ProgranService.objects.all()
+
+        if len(existing_services) > 0 and not self.delete:
+            raise XOSValidationError("A ProgranService already exists, you should not have more than one")
+
+        super(ProgranService, self).save(*args, **kwargs)
 
 
 class ENodeB(ENodeB_decl):
@@ -33,19 +41,18 @@
 
     def save(self, *args, **kwargs):
         # NOTE someone is setting owner_id, so just override it for now
-        # if not self.owner_id:
-        services = Service.objects.all()
-        services = [s for s in services if s.name.lower() == 'progran']
-
-        # NOTE select the correct owner
         try:
-            progran_service = services[0]
+            # NOTE we allow just one ProgranService
+            progran_service = ProgranService.objects.all()[0]
             self.owner_id = progran_service.id
         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)