Sapan Bhatia | 084c098 | 2017-04-21 14:47:40 +0200 | [diff] [blame^] | 1 | from header import * |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 2 | |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 3 | |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 4 | |
Sapan Bhatia | 084c098 | 2017-04-21 14:47:40 +0200 | [diff] [blame^] | 5 | from core.models import ContentType#from core.models.tenant import Tenant |
| 6 | from core.models import Tenant |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 7 | |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 8 | |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 9 | |
Sapan Bhatia | 084c098 | 2017-04-21 14:47:40 +0200 | [diff] [blame^] | 10 | #from core.models.service import Service |
| 11 | from core.models import Service |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 16 | |
| 17 | class VTRTenant(Tenant): |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 18 | |
Sapan Bhatia | 084c098 | 2017-04-21 14:47:40 +0200 | [diff] [blame^] | 19 | KIND = "vTR" |
Scott Baker | 5db44a9 | 2017-03-06 17:27:52 -0800 | [diff] [blame] | 20 | |
Sapan Bhatia | 084c098 | 2017-04-21 14:47:40 +0200 | [diff] [blame^] | 21 | class Meta: |
| 22 | app_label = "vtr" |
| 23 | name = "vtr" |
| 24 | verbose_name = "Virtual Truck Roll Service" |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 25 | |
Sapan Bhatia | 084c098 | 2017-04-21 14:47:40 +0200 | [diff] [blame^] | 26 | # Primitive Fields (Not Relations) |
| 27 | test = StrippedCharField( choices = (('ping', 'Ping'), ('traceroute', 'Trace Route'), ('tcpdump', 'Tcp Dump'), ('memory', 'Memory'), ('bandwidth', 'Bandwidth')), max_length = 30, blank = False, help_text = "type of test", null = False, db_index = False ) |
| 28 | scope = StrippedCharField( choices = (('container', 'Container'), ('vm', 'VM')), max_length = 30, blank = False, help_text = "scope of test", null = False, db_index = False ) |
| 29 | argument = StrippedCharField( db_index = False, max_length = 40, null = True, blank = True ) |
| 30 | result = TextField( blank = True, null = True, db_index = False ) |
| 31 | result_code = StrippedCharField( db_index = False, max_length = 32, null = True, blank = True ) |
| 32 | target_id = IntegerField( blank = False, null = False, db_index = False ) |
| 33 | |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 34 | |
Sapan Bhatia | 084c098 | 2017-04-21 14:47:40 +0200 | [diff] [blame^] | 35 | # Relations |
| 36 | |
| 37 | target_type = ForeignKey(ContentType, db_index = True, related_name = 'vtrtenant', null = False, blank = False ) |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 38 | |
Sapan Bhatia | 084c098 | 2017-04-21 14:47:40 +0200 | [diff] [blame^] | 39 | sync_attributes = ( 'test', 'argument', "scope" ) |
| 40 | |
| 41 | def __init__(self, *args, **kwargs): |
| 42 | vtr_services = VTRService.get_service_objects().all() |
| 43 | if vtr_services: |
| 44 | self._meta.get_field("provider_service").default = vtr_services[0].id |
| 45 | super(VTRTenant, self).__init__(*args, **kwargs) |
| 46 | |
| 47 | def save(self, *args, **kwargs): |
| 48 | super(VTRTenant, self).save(*args, **kwargs) |
| 49 | |
| 50 | def delete(self, *args, **kwargs): |
| 51 | super(VTRTenant, self).delete(*args, **kwargs) |
| 52 | |
| 53 | pass |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 54 | |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 55 | |
Sapan Bhatia | 084c098 | 2017-04-21 14:47:40 +0200 | [diff] [blame^] | 56 | |
| 57 | |
| 58 | class VTRService(Service): |
| 59 | |
| 60 | KIND = "vTR" |
| 61 | |
| 62 | class Meta: |
| 63 | app_label = "vtr" |
| 64 | name = "vtr" |
| 65 | verbose_name = "Virtual Truck Roll Service" |
| 66 | |
| 67 | # Primitive Fields (Not Relations) |
| 68 | |
| 69 | |
| 70 | # Relations |
| 71 | |
| 72 | |
| 73 | |
| 74 | pass |
| 75 | |
Scott Baker | 171d35e | 2016-06-20 17:36:29 -0700 | [diff] [blame] | 76 | |