Sapan Bhatia | a46cc4d | 2017-04-21 14:57:54 +0200 | [diff] [blame^] | 1 | from header import * |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 2 | |
Sapan Bhatia | a46cc4d | 2017-04-21 14:57:54 +0200 | [diff] [blame^] | 3 | |
| 4 | |
| 5 | from core.models import User#from core.models.tenant import Tenant |
| 6 | from core.models import Tenant |
| 7 | |
| 8 | |
| 9 | |
| 10 | #from core.models.service import Service |
| 11 | from core.models import Service |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | class 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 Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 56 | |
| 57 | class ONOSService(Service): |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 58 | |
Sapan Bhatia | a46cc4d | 2017-04-21 14:57:54 +0200 | [diff] [blame^] | 59 | KIND = "onos" |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 60 | |
Sapan Bhatia | a46cc4d | 2017-04-21 14:57:54 +0200 | [diff] [blame^] | 61 | class Meta: |
| 62 | app_label = "onos" |
| 63 | name = "onos" |
| 64 | verbose_name = "ONOS Service" |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 65 | |
Sapan Bhatia | a46cc4d | 2017-04-21 14:57:54 +0200 | [diff] [blame^] | 66 | # 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 Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 72 | |
Sapan Bhatia | a46cc4d | 2017-04-21 14:57:54 +0200 | [diff] [blame^] | 73 | # Relations |
| 74 | |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 75 | |
Sapan Bhatia | a46cc4d | 2017-04-21 14:57:54 +0200 | [diff] [blame^] | 76 | |
| 77 | pass |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 78 | |
| 79 | |