[SEBA-742] Adding methods to validate subscriber tech_profile association
Change-Id: I4287f7021fa2c3cac6f025ac829ab280bf09e8ba
diff --git a/xos/synchronizer/models/models.py b/xos/synchronizer/models/models.py
index 643b5d3..5114871 100644
--- a/xos/synchronizer/models/models.py
+++ b/xos/synchronizer/models/models.py
@@ -26,6 +26,7 @@
from models_decl import ANIPort_decl, ANIPort
from models_decl import UNIPort_decl, UNIPort
from models_decl import TechnologyProfile_decl
+from django.core.exceptions import ObjectDoesNotExist
import json
@@ -41,6 +42,36 @@
except IndexError, e:
return False
+ def get_olt_technology_from_unu_sn(self, onu_sn):
+ """
+ Return the technology assigned to an OLT Device given and ONU Serial Number
+ example usage:
+ volt = VOLTService.objects.first()
+ sn = volt.get_olt_technology_from_unu_sn("BRCM12345678")
+ # "XGSPON"
+
+ Arguments:
+ onu_sn {string} -- The ONU Serial Number
+
+ Returns:
+ string -- Technology
+ """
+ try:
+ onu = ONUDevice.objects.get(serial_number=onu_sn)
+ olt = onu.pon_port.olt_device
+ return olt.technology
+ except ObjectDoesNotExist:
+ raise XOSNotFound("Can't find OLT for %s" % onu_sn, serial_number=onu_sn)
+
+ def get_tech_profile(self, technology, profile_id):
+ """
+ Returns a Technology profiles or raise an Exception (DoesNotExist)
+ :param technology: string
+ :param profile_id: int
+ :return: TechnologyProfile
+ """
+ return TechnologyProfile.objects.get(technology=technology, profile_id=profile_id)
+
class OLTDevice(OLTDevice_decl):
class Meta:
proxy = True