blob: f3f9f2b259515a50e22de5164319a7d6fd1abb7f [file] [log] [blame]
Scott Baker171d35e2016-06-20 17:36:29 -07001from django.db import models
2from core.models import Service, PlCoreBase, Slice, Instance, Tenant, TenantWithContainer, Node, Image, User, Flavor, Subscriber, NetworkParameter, NetworkParameterType, Port, AddressPool
3from core.models.plcorebase import StrippedCharField
4import os
5from django.db import models, transaction
6from django.forms.models import model_to_dict
7from django.db.models import Q
8from operator import itemgetter, attrgetter, methodcaller
9from core.models import Tag
10from core.models.service import LeastLoadedNodeScheduler
11from services.volt.models import CordSubscriberRoot
12import traceback
13from xos.exceptions import *
14from xos.config import Config
Scott Baker5db44a92017-03-06 17:27:52 -080015from django.contrib.contenttypes.models import ContentType
16from django.contrib.contenttypes.fields import GenericForeignKey
Scott Baker171d35e2016-06-20 17:36:29 -070017
18class ConfigurationError(Exception):
19 pass
20
21VTR_KIND = "vTR"
22
23CORD_USE_VTN = getattr(Config(), "networking_use_vtn", False)
24
25# -------------------------------------------
26# VOLT
27# -------------------------------------------
28
29class VTRService(Service):
30 KIND = VTR_KIND
31
32 class Meta:
33 app_label = "vtr"
Scott Baker171d35e2016-06-20 17:36:29 -070034
35class VTRTenant(Tenant):
Scott Baker171d35e2016-06-20 17:36:29 -070036 KIND = VTR_KIND
37
Scott Baker5db44a92017-03-06 17:27:52 -080038 class Meta:
39 app_label = "vtr"
40
Scott Baker171d35e2016-06-20 17:36:29 -070041 TEST_CHOICES = ( ("ping", "Ping"), ("traceroute", "Trace Route"), ("tcpdump", "Tcp Dump") )
42 SCOPE_CHOICES = ( ("container", "Container"), ("vm", "VM") )
43
Scott Baker5db44a92017-03-06 17:27:52 -080044 test = StrippedCharField(help_text="type of test", max_length=30, choices=TEST_CHOICES, null=False, blank=False)
45 scope = StrippedCharField(help_text="scope of test", max_length=30, choices=SCOPE_CHOICES, null=False, blank=False)
46 argument = StrippedCharField(max_length=40, null=True, blank=True)
47 result = models.TextField(blank=True, null=True)
48 result_code = StrippedCharField(max_length=32, blank=True, null=True)
49 target_type = models.ForeignKey(ContentType)
50 target_id = models.PositiveIntegerField()
51 target = GenericForeignKey("target_type", "target_id")
Scott Baker171d35e2016-06-20 17:36:29 -070052
53 sync_attributes = ( 'test', 'argument', "scope" )
54
55 def __init__(self, *args, **kwargs):
56 vtr_services = VTRService.get_service_objects().all()
57 if vtr_services:
58 self._meta.get_field("provider_service").default = vtr_services[0].id
59 super(VTRTenant, self).__init__(*args, **kwargs)
60
Scott Baker171d35e2016-06-20 17:36:29 -070061 def save(self, *args, **kwargs):
62 super(VTRTenant, self).save(*args, **kwargs)
63
64 def delete(self, *args, **kwargs):
65 super(VTRTenant, self).delete(*args, **kwargs)
66