Merge "CORD-2685 Rename xos_new_tosca_config_templates -> xos_tosca_config_templates"
diff --git a/xos/models/models.py b/xos/models/models.py
index 3a7ed58..6d9b60d 100644
--- a/xos/models/models.py
+++ b/xos/models/models.py
@@ -23,4 +23,13 @@
except IndexError:
raise XOSValidationError("Service MCORD cannot be found, please make sure that the model exists.")
+ # prevent IMSI duplicate
+ try:
+ instance_with_same_imsi = MCordSubscriberInstance.objects.get(imsi_number=self.imsi_number)
+
+ if (not self.pk and instance_with_same_imsi) or (self.pk and self.pk != instance_with_same_imsi.pk):
+ raise XOSValidationError("An MCORDSubscriber with imsi_number '%s' already exists" % self.imsi_number)
+ except self.DoesNotExist:
+ pass
+
super(MCordSubscriberInstance, self).save(*args, **kwargs)