[CORD-2639] Moving Progran to 5.0
Change-Id: Ia838ade6b7cd8e7b4c04ae939e27d5b2dbf16896
diff --git a/xos/models/models.py b/xos/models/models.py
new file mode 100644
index 0000000..2e7df7b
--- /dev/null
+++ b/xos/models/models.py
@@ -0,0 +1,60 @@
+from core.models import Service
+from xos.exceptions import XOSValidationError
+
+from models_decl import ProgranService_decl
+from models_decl import ENodeB_decl
+from models_decl import Handover_decl
+from models_decl import ProgranServiceInstance_decl
+
+
+
+
+
+
+
+class ProgranService(ProgranService_decl):
+ class Meta:
+ proxy = True
+
+
+class ENodeB(ENodeB_decl):
+ class Meta:
+ proxy = True
+
+
+class Handover(Handover_decl):
+ class Meta:
+ proxy = True
+
+
+class ProgranServiceInstance(ProgranServiceInstance_decl):
+ class Meta:
+ proxy = True
+
+ 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]
+ 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
+ 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
+
+ if instances_with_same_name:
+ raise XOSValidationError("A ProgranServiceInstance with name '%s' already exists" % self.name)
+ super(ProgranServiceInstance, self).save(*args, **kwargs)
+
+
diff --git a/xos/models/progran.xproto b/xos/models/progran.xproto
new file mode 100644
index 0000000..14206ac
--- /dev/null
+++ b/xos/models/progran.xproto
@@ -0,0 +1,50 @@
+option app_label = "progran";
+option name = "progran";
+option legacy = "True";
+
+message ProgranService (Service){
+ option verbose_name = "Progran Service";
+ required string onos_address = 1 [help_text = "Address of the progran ONOS", default = "onos-progran", max_length = 254, null = False, db_index = False, blank = False];
+ required string onos_port = 2 [help_text = "Port of the progran ONOS", default = "8183", max_length = 254, null = False, db_index = False, blank = False];
+ required string onos_username = 3 [help_text = "Username of the progran ONOS", default = "karaf", max_length = 254, null = False, db_index = False, blank = False];
+ required string onos_password = 4 [help_text = "Password of the progran ONOS", default = "karaf", max_length = 254, null = False, db_index = False, blank = False];
+}
+
+message ENodeB (XOSBase){
+ option verbose_name = "eNodeB";
+ required string description = 1 [db_index = False, max_length = 256, null = False, blank = False];
+ required string enbId = 2 [help_text = "ID of this enodeb", db_index = False, max_length = 256, null = False, blank = False];
+ required string ipAddr = 3 [help_text = "IP address of this enodeb", db_index = False, max_length = 256, null = False, blank = False];
+}
+
+message Handover (XOSBase){
+ option verbose_name = "Handover";
+ required int32 A3offset = 1 [default = 2, db_index = False, null = False, blank = False];
+ required int32 HysteresisA3 = 2 [default = 1, db_index = False, null = False, blank = False];
+ required int32 A3TriggerQuantity = 3 [default = 0, db_index = False, null = False, blank = False];
+ required int32 A5TriggerType = 4 [default = 0, db_index = False, null = False, blank = False];
+ required int32 A5Thresh1Rsrp = 5 [default = -97, db_index = False, null = False, blank = False];
+ required int32 A5Thresh1Rsrq = 6 [default = -10, db_index = False, null = False, blank = False];
+ required int32 A5Thresh2Rsrp = 7 [default = -95, db_index = False, null = False, blank = False];
+ required int32 A5Thresh2Rsrq = 8 [default = -8, db_index = False, null = False, blank = False];
+ required int32 HysteresisA5 = 9 [default = 1, db_index = False, null = False, blank = False];
+ required int32 A5TriggerQuantity = 10 [default = 0, db_index = False, null = False, blank = False];
+}
+
+message ProgranServiceInstance (ServiceInstance){
+ option verbose_name = "Progran Service Instance";
+ option description = "Represent a Profile in the Progran ONOS Application";
+
+ required string DlSchedType = 1 [default = "vm", choices = "(('RR', 'Round Robin'),)", max_length = 30, blank = False, null = False, db_index = False];
+ required int32 DlAllocRBRate = 2 [db_index = False, null = False, blank = False];
+ required string UlSchedType = 3 [default = "vm", choices = "(('RR', 'Round Robin'),)", max_length = 30, blank = False, null = False, db_index = False];
+ required int32 UlAllocRBRate = 4 [db_index = False, null = False, blank = False];
+ required string start = 5 [content_type = "date", null = False, blank = True];
+ required string end = 6 [content_type = "date", null = False, blank = True];
+ required string AdmControl = 7 [default = "0", choices = "(('0', 'ALL'), ('1', 'Voice Only'), ('2', 'Data Only'))", max_length = 1, blank = False, null = False, db_index = False];
+ required int32 CellIndividualOffset = 8 [db_index = False, null = False, blank = False];
+ required manytoone enodeb->ENodeB:profiles = 9 [db_index = True, null = False, blank = False];
+ required manytoone handover->Handover:profiles = 10 [db_index = True, null = True, blank = False];
+}
+
+