CORD-1092: Ported ONOS over to xproto
Change-Id: I416957ddb1431de41d1103210a2ba651e4e012b4
diff --git a/xos/attic/header.py b/xos/attic/header.py
new file mode 100644
index 0000000..deadcaf
--- /dev/null
+++ b/xos/attic/header.py
@@ -0,0 +1,13 @@
+from django.db import models
+from core.models import Service, PlCoreBase, Slice, Instance, Tenant, TenantWithContainer, Node, Image, User, Flavor
+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
+import traceback
+from xos.exceptions import *
+from core.models import SlicePrivilege, SitePrivilege
+from sets import Set
+
diff --git a/xos/attic/onosapp_model.py b/xos/attic/onosapp_model.py
new file mode 100644
index 0000000..5366952
--- /dev/null
+++ b/xos/attic/onosapp_model.py
@@ -0,0 +1,17 @@
+def __init__(self, *args, **kwargs):
+ onos_services = ONOSService.get_service_objects().all()
+ if onos_services:
+ self._meta.get_field("provider_service").default = onos_services[0].id
+ super(ONOSApp, self).__init__(*args, **kwargs)
+
+def save(self, *args, **kwargs):
+ if not self.creator:
+ if not getattr(self, "caller", None):
+ # caller must be set when creating a vCPE since it creates a slice
+ raise XOSProgrammingError("ONOSApp's self.caller was not set")
+ self.creator = self.caller
+ if not self.creator:
+ raise XOSProgrammingError("ONOSApp's self.creator was not set")
+
+ super(ONOSApp, self).save(*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 abec34a..085dbf9 100644
--- a/xos/models.py
+++ b/xos/models.py
@@ -1,59 +1,79 @@
-from django.db import models
-from core.models import Service, PlCoreBase, Slice, Instance, Tenant, TenantWithContainer, Node, Image, User, Flavor
-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
-import traceback
-from xos.exceptions import *
-from core.models import SlicePrivilege, SitePrivilege
-from sets import Set
+from header import *
-ONOS_KIND = "onos"
+
+
+from core.models import User#from core.models.tenant import Tenant
+from core.models import Tenant
+
+
+
+#from core.models.service import Service
+from core.models import Service
+
+
+
+
+
+class ONOSApp(Tenant):
+
+ KIND = "onos"
+
+ class Meta:
+ app_label = "onos"
+ name = "onos"
+ verbose_name = "ONOS Service"
+
+ # Primitive Fields (Not Relations)
+ install_dependencies = TextField( blank = True, null = True, db_index = False )
+ dependencies = TextField( blank = True, null = True, db_index = False )
+
+
+ # Relations
+
+ creator = ForeignKey(User, db_index = True, related_name = 'onos_apps', null = True, blank = True )
+
+ def __init__(self, *args, **kwargs):
+ onos_services = ONOSService.get_service_objects().all()
+ if onos_services:
+ self._meta.get_field("provider_service").default = onos_services[0].id
+ super(ONOSApp, self).__init__(*args, **kwargs)
+
+ def save(self, *args, **kwargs):
+ if not self.creator:
+ if not getattr(self, "caller", None):
+ # caller must be set when creating a vCPE since it creates a slice
+ raise XOSProgrammingError("ONOSApp's self.caller was not set")
+ self.creator = self.caller
+ if not self.creator:
+ raise XOSProgrammingError("ONOSApp's self.creator was not set")
+
+ super(ONOSApp, self).save(*args, **kwargs)
+
+ pass
+
+
+
class ONOSService(Service):
- KIND = ONOS_KIND
- class Meta:
- app_label = "onos"
- verbose_name = "ONOS Service"
+ KIND = "onos"
- rest_hostname = StrippedCharField(max_length=255, null=True, blank=True)
- rest_port = models.IntegerField(default=8181)
- no_container = models.BooleanField(default=False)
- node_key = StrippedCharField(max_length=1024, null=True, blank=True)
+ class Meta:
+ app_label = "onos"
+ name = "onos"
+ verbose_name = "ONOS Service"
-class ONOSApp(Tenant): # aka 'ONOSTenant'
- class Meta:
- app_label = "onos"
+ # Primitive Fields (Not Relations)
+ rest_hostname = StrippedCharField( db_index = False, max_length = 255, null = True, blank = True )
+ rest_port = IntegerField( default = 8181, null = False, blank = False, db_index = False )
+ no_container = BooleanField( default = False, null = False, blank = True, db_index = False )
+ node_key = StrippedCharField( db_index = False, max_length = 1024, null = True, blank = True )
+
- KIND = ONOS_KIND
+ # Relations
+
- install_dependencies = models.TextField(null=True, blank=True)
- dependencies = models.TextField(null=True, blank=True)
-
- # why is this necessary?
- creator = models.ForeignKey(User, related_name='onos_apps', blank=True, null=True)
-
- def __init__(self, *args, **kwargs):
- onos_services = ONOSService.get_service_objects().all()
- if onos_services:
- self._meta.get_field("provider_service").default = onos_services[0].id
- super(ONOSApp, self).__init__(*args, **kwargs)
-
- def save(self, *args, **kwargs):
- if not self.creator:
- if not getattr(self, "caller", None):
- # caller must be set when creating a vCPE since it creates a slice
- raise XOSProgrammingError("ONOSApp's self.caller was not set")
- self.creator = self.caller
- if not self.creator:
- raise XOSProgrammingError("ONOSApp's self.creator was not set")
-
- super(ONOSApp, self).save(*args, **kwargs)
-
-
+
+ pass
diff --git a/xos/onos-onboard.yaml b/xos/onos-onboard.yaml
index 9c0e5c4..108f46c 100644
--- a/xos/onos-onboard.yaml
+++ b/xos/onos-onboard.yaml
@@ -13,7 +13,7 @@
base_url: file:///opt/xos_services/onos-service/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/onosadmin.html
synchronizer: synchronizer/manifest
diff --git a/xos/onos.xproto b/xos/onos.xproto
new file mode 100644
index 0000000..24345ea
--- /dev/null
+++ b/xos/onos.xproto
@@ -0,0 +1,17 @@
+option kind="onos";
+option name="onos";
+option verbose_name="ONOS Service";
+
+message ONOSApp (Tenant){
+ optional string install_dependencies = 1 [db_index = False, null = True, blank = True];
+ optional string dependencies = 2 [db_index = False, null = True, blank = True];
+ optional manytoone creator->User:onos_apps = 3 [db_index = True, null = True, blank = True];
+}
+
+
+message ONOSService (Service){
+ optional string rest_hostname = 1 [db_index = False, max_length = 255, null = True, content_type = "stripped", blank = True];
+ required int32 rest_port = 2 [default = 8181, null = False, db_index = False, blank = False];
+ required bool no_container = 3 [default = False, null = False, db_index = False, blank = True];
+ optional string node_key = 4 [db_index = False, max_length = 1024, null = True, content_type = "stripped", blank = True];
+}