blob: 085dbf994c7788182ca5b4fee72ffb7c9eab118d [file] [log] [blame]
Sapan Bhatiaa46cc4d2017-04-21 14:57:54 +02001from header import *
Scott Baker7a327592016-06-20 17:34:06 -07002
Sapan Bhatiaa46cc4d2017-04-21 14:57:54 +02003
4
5from core.models import User#from core.models.tenant import Tenant
6from core.models import Tenant
7
8
9
10#from core.models.service import Service
11from core.models import Service
12
13
14
15
16
17class ONOSApp(Tenant):
18
19 KIND = "onos"
20
21 class Meta:
22 app_label = "onos"
23 name = "onos"
24 verbose_name = "ONOS Service"
25
26 # Primitive Fields (Not Relations)
27 install_dependencies = TextField( blank = True, null = True, db_index = False )
28 dependencies = TextField( blank = True, null = True, db_index = False )
29
30
31 # Relations
32
33 creator = ForeignKey(User, db_index = True, related_name = 'onos_apps', null = True, blank = True )
34
35 def __init__(self, *args, **kwargs):
36 onos_services = ONOSService.get_service_objects().all()
37 if onos_services:
38 self._meta.get_field("provider_service").default = onos_services[0].id
39 super(ONOSApp, self).__init__(*args, **kwargs)
40
41 def save(self, *args, **kwargs):
42 if not self.creator:
43 if not getattr(self, "caller", None):
44 # caller must be set when creating a vCPE since it creates a slice
45 raise XOSProgrammingError("ONOSApp's self.caller was not set")
46 self.creator = self.caller
47 if not self.creator:
48 raise XOSProgrammingError("ONOSApp's self.creator was not set")
49
50 super(ONOSApp, self).save(*args, **kwargs)
51
52 pass
53
54
55
Scott Baker7a327592016-06-20 17:34:06 -070056
57class ONOSService(Service):
Scott Baker7a327592016-06-20 17:34:06 -070058
Sapan Bhatiaa46cc4d2017-04-21 14:57:54 +020059 KIND = "onos"
Scott Baker7a327592016-06-20 17:34:06 -070060
Sapan Bhatiaa46cc4d2017-04-21 14:57:54 +020061 class Meta:
62 app_label = "onos"
63 name = "onos"
64 verbose_name = "ONOS Service"
Scott Baker7a327592016-06-20 17:34:06 -070065
Sapan Bhatiaa46cc4d2017-04-21 14:57:54 +020066 # Primitive Fields (Not Relations)
67 rest_hostname = StrippedCharField( db_index = False, max_length = 255, null = True, blank = True )
68 rest_port = IntegerField( default = 8181, null = False, blank = False, db_index = False )
69 no_container = BooleanField( default = False, null = False, blank = True, db_index = False )
70 node_key = StrippedCharField( db_index = False, max_length = 1024, null = True, blank = True )
71
Scott Baker7a327592016-06-20 17:34:06 -070072
Sapan Bhatiaa46cc4d2017-04-21 14:57:54 +020073 # Relations
74
Scott Baker7a327592016-06-20 17:34:06 -070075
Sapan Bhatiaa46cc4d2017-04-21 14:57:54 +020076
77 pass
Scott Baker7a327592016-06-20 17:34:06 -070078
79