Sapan Bhatia | a46cc4d | 2017-04-21 14:57:54 +0200 | [diff] [blame] | 1 | def __init__(self, *args, **kwargs): |
| 2 | onos_services = ONOSService.get_service_objects().all() |
| 3 | if onos_services: |
| 4 | self._meta.get_field("provider_service").default = onos_services[0].id |
| 5 | super(ONOSApp, self).__init__(*args, **kwargs) |
| 6 | |
| 7 | def save(self, *args, **kwargs): |
| 8 | if not self.creator: |
| 9 | if not getattr(self, "caller", None): |
| 10 | # caller must be set when creating a vCPE since it creates a slice |
| 11 | raise XOSProgrammingError("ONOSApp's self.caller was not set") |
| 12 | self.creator = self.caller |
| 13 | if not self.creator: |
| 14 | raise XOSProgrammingError("ONOSApp's self.creator was not set") |
| 15 | |
| 16 | super(ONOSApp, self).save(*args, **kwargs) |
| 17 | |