CORD-1092: Brought VTR over to xproto
Change-Id: I64ff8a9cc25adf1078c065af132985caa02ff9d8
diff --git a/xos/attic/header.py b/xos/attic/header.py
new file mode 100644
index 0000000..b491059
--- /dev/null
+++ b/xos/attic/header.py
@@ -0,0 +1,24 @@
+from django.db import models
+from core.models import Service, PlCoreBase, Slice, Instance, Tenant, TenantWithContainer, Node, Image, User, Flavor, NetworkParameter, NetworkParameterType, Port, AddressPool
+from core.models.plcorebase import StrippedCharField
+import os
+from django.db import models, transaction
+from django.forms.models import model_to_dict
+from django.db.models import *
+from operator import itemgetter, attrgetter, methodcaller
+from core.models import Tag
+from core.models.service import LeastLoadedNodeScheduler
+from services.volt.models import CordSubscriberRoot
+import traceback
+from xos.exceptions import *
+from xos.config import Config
+from django.contrib.contenttypes.models import ContentType
+from django.contrib.contenttypes.fields import GenericForeignKey
+
+class ConfigurationError(Exception):
+ pass
+
+VTR_KIND = "vTR"
+
+CORD_USE_VTN = getattr(Config(), "networking_use_vtn", False)
+
diff --git a/xos/attic/header.py.orig b/xos/attic/header.py.orig
new file mode 100644
index 0000000..1ba8b4d
--- /dev/null
+++ b/xos/attic/header.py.orig
@@ -0,0 +1,24 @@
+from django.db import models
+from core.models import Service, PlCoreBase, Slice, Instance, Tenant, TenantWithContainer, Node, Image, User, Flavor, NetworkParameter, NetworkParameterType, Port, AddressPool
+from core.models.plcorebase import StrippedCharField
+import os
+from django.db import models, transaction
+from django.forms.models import model_to_dict
+from django.db.models import Q
+from operator import itemgetter, attrgetter, methodcaller
+from core.models import Tag
+from core.models.service import LeastLoadedNodeScheduler
+from services.volt.models import CordSubscriberRoot
+import traceback
+from xos.exceptions import *
+from xos.config import Config
+from django.contrib.contenttypes.models import ContentType
+from django.contrib.contenttypes.fields import GenericForeignKey
+
+class ConfigurationError(Exception):
+ pass
+
+VTR_KIND = "vTR"
+
+CORD_USE_VTN = getattr(Config(), "networking_use_vtn", False)
+
diff --git a/xos/attic/vtrtenant_model.py b/xos/attic/vtrtenant_model.py
new file mode 100644
index 0000000..6d3dba2
--- /dev/null
+++ b/xos/attic/vtrtenant_model.py
@@ -0,0 +1,14 @@
+sync_attributes = ( 'test', 'argument', "scope" )
+
+def __init__(self, *args, **kwargs):
+ vtr_services = VTRService.get_service_objects().all()
+ if vtr_services:
+ self._meta.get_field("provider_service").default = vtr_services[0].id
+ super(VTRTenant, self).__init__(*args, **kwargs)
+
+def save(self, *args, **kwargs):
+ super(VTRTenant, self).save(*args, **kwargs)
+
+def delete(self, *args, **kwargs):
+ super(VTRTenant, self).delete(*args, **kwargs)
+
diff --git a/xos/header.py b/xos/header.py
new file mode 120000
index 0000000..721b5c0
--- /dev/null
+++ b/xos/header.py
@@ -0,0 +1 @@
+attic/header.py
\ No newline at end of file
diff --git a/xos/models.py b/xos/models.py
index cb3ce1f..f272881 100644
--- a/xos/models.py
+++ b/xos/models.py
@@ -1,66 +1,76 @@
-from django.db import models
-from core.models import Service, PlCoreBase, Slice, Instance, Tenant, TenantWithContainer, Node, Image, User, Flavor, NetworkParameter, NetworkParameterType, Port, AddressPool
-from core.models.plcorebase import StrippedCharField
-import os
-from django.db import models, transaction
-from django.forms.models import model_to_dict
-from django.db.models import Q
-from operator import itemgetter, attrgetter, methodcaller
-from core.models import Tag
-from core.models.service import LeastLoadedNodeScheduler
-from services.volt.models import CordSubscriberRoot
-import traceback
-from xos.exceptions import *
-from xos.config import Config
-from django.contrib.contenttypes.models import ContentType
-from django.contrib.contenttypes.fields import GenericForeignKey
+from header import *
-class ConfigurationError(Exception):
- pass
-VTR_KIND = "vTR"
-CORD_USE_VTN = getattr(Config(), "networking_use_vtn", False)
+from core.models import ContentType#from core.models.tenant import Tenant
+from core.models import Tenant
-# -------------------------------------------
-# VOLT
-# -------------------------------------------
-class VTRService(Service):
- KIND = VTR_KIND
- class Meta:
- app_label = "vtr"
+#from core.models.service import Service
+from core.models import Service
+
+
+
+
class VTRTenant(Tenant):
- KIND = VTR_KIND
- class Meta:
- app_label = "vtr"
+ KIND = "vTR"
- TEST_CHOICES = ( ("ping", "Ping"), ("traceroute", "Trace Route"), ("tcpdump", "Tcp Dump"), ("memory", "Memory"), ("bandwidth","Bandwidth") )
- SCOPE_CHOICES = ( ("container", "Container"), ("vm", "VM") )
+ class Meta:
+ app_label = "vtr"
+ name = "vtr"
+ verbose_name = "Virtual Truck Roll Service"
- test = StrippedCharField(help_text="type of test", max_length=30, choices=TEST_CHOICES, null=False, blank=False)
- scope = StrippedCharField(help_text="scope of test", max_length=30, choices=SCOPE_CHOICES, null=False, blank=False)
- argument = StrippedCharField(max_length=40, null=True, blank=True)
- result = models.TextField(blank=True, null=True)
- result_code = StrippedCharField(max_length=32, blank=True, null=True)
- target_type = models.ForeignKey(ContentType)
- target_id = models.PositiveIntegerField()
- target = GenericForeignKey("target_type", "target_id")
+ # Primitive Fields (Not Relations)
+ 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 )
+ scope = StrippedCharField( choices = (('container', 'Container'), ('vm', 'VM')), max_length = 30, blank = False, help_text = "scope of test", null = False, db_index = False )
+ argument = StrippedCharField( db_index = False, max_length = 40, null = True, blank = True )
+ result = TextField( blank = True, null = True, db_index = False )
+ result_code = StrippedCharField( db_index = False, max_length = 32, null = True, blank = True )
+ target_id = IntegerField( blank = False, null = False, db_index = False )
+
- sync_attributes = ( 'test', 'argument', "scope" )
+ # Relations
+
+ target_type = ForeignKey(ContentType, db_index = True, related_name = 'vtrtenant', null = False, blank = False )
- def __init__(self, *args, **kwargs):
- vtr_services = VTRService.get_service_objects().all()
- if vtr_services:
- self._meta.get_field("provider_service").default = vtr_services[0].id
- super(VTRTenant, self).__init__(*args, **kwargs)
+ sync_attributes = ( 'test', 'argument', "scope" )
+
+ def __init__(self, *args, **kwargs):
+ vtr_services = VTRService.get_service_objects().all()
+ if vtr_services:
+ self._meta.get_field("provider_service").default = vtr_services[0].id
+ super(VTRTenant, self).__init__(*args, **kwargs)
+
+ def save(self, *args, **kwargs):
+ super(VTRTenant, self).save(*args, **kwargs)
+
+ def delete(self, *args, **kwargs):
+ super(VTRTenant, self).delete(*args, **kwargs)
+
+ pass
- def save(self, *args, **kwargs):
- super(VTRTenant, self).save(*args, **kwargs)
- def delete(self, *args, **kwargs):
- super(VTRTenant, self).delete(*args, **kwargs)
+
+
+class VTRService(Service):
+
+ KIND = "vTR"
+
+ class Meta:
+ app_label = "vtr"
+ name = "vtr"
+ verbose_name = "Virtual Truck Roll Service"
+
+ # Primitive Fields (Not Relations)
+
+
+ # Relations
+
+
+
+ pass
+
diff --git a/xos/vtr-onboard.yaml b/xos/vtr-onboard.yaml
index 880faa1..e60fff5 100644
--- a/xos/vtr-onboard.yaml
+++ b/xos/vtr-onboard.yaml
@@ -13,7 +13,7 @@
base_url: file:///opt/xos_services/vtr/xos/
# The following will concatenate with base_url automatically, if
# base_url is non-null.
- models: models.py
+ xproto: ./
admin: admin.py
admin_template: templates/vtradmin.html
synchronizer: synchronizer/manifest
diff --git a/xos/vtr.xproto b/xos/vtr.xproto
new file mode 100644
index 0000000..080c3e7
--- /dev/null
+++ b/xos/vtr.xproto
@@ -0,0 +1,17 @@
+option kind="vTR";
+option name="vtr";
+option verbose_name="Virtual Truck Roll Service";
+
+message VTRTenant (Tenant){
+ required string test = 1 [choices = "(('ping', 'Ping'), ('traceroute', 'Trace Route'), ('tcpdump', 'Tcp Dump'), ('memory', 'Memory'), ('bandwidth', 'Bandwidth'))", max_length = 30, content_type = "stripped", blank = False, help_text = "type of test", null = False, db_index = False];
+ required string scope = 2 [choices = "(('container', 'Container'), ('vm', 'VM'))", max_length = 30, content_type = "stripped", blank = False, help_text = "scope of test", null = False, db_index = False];
+ optional string argument = 3 [db_index = False, max_length = 40, null = True, content_type = "stripped", blank = True];
+ optional string result = 4 [db_index = False, null = True, blank = True];
+ optional string result_code = 5 [db_index = False, max_length = 32, null = True, content_type = "stripped", blank = True];
+ required manytoone target_type->ContentType:vtrtenant = 6 [db_index = True, null = False, blank = False];
+ required uint32 target_id = 7 [db_index = False, null = False, blank = False];
+}
+
+
+message VTRService (Service){
+}