CORD-1092: Example service ported over to xproto

Change-Id: I3edd49d1c1e87c800b5bc8cb2316cb8bc19f4bc2
diff --git a/xos/attic/exampletenant_bottom.py b/xos/attic/exampletenant_bottom.py
new file mode 100644
index 0000000..7ac737e
--- /dev/null
+++ b/xos/attic/exampletenant_bottom.py
@@ -0,0 +1,8 @@
+def model_policy_exampletenant(pk):
+    with transaction.atomic():
+        tenant = ExampleTenant.objects.select_for_update().filter(pk=pk)
+        if not tenant:
+            return
+        tenant = tenant[0]
+        tenant.manage_container()
+
diff --git a/xos/attic/exampletenant_model.py b/xos/attic/exampletenant_model.py
new file mode 100644
index 0000000..ad69d03
--- /dev/null
+++ b/xos/attic/exampletenant_model.py
@@ -0,0 +1,14 @@
+def __init__(self, *args, **kwargs):
+    exampleservice = ExampleService.get_service_objects().all()
+    if exampleservice:
+        self._meta.get_field('provider_service').default = exampleservice[0].id
+    super(ExampleTenant, self).__init__(*args, **kwargs)
+
+def save(self, *args, **kwargs):
+    super(ExampleTenant, self).save(*args, **kwargs)
+    model_policy_exampletenant(self.pk)
+
+def delete(self, *args, **kwargs):
+    self.cleanup_container()
+    super(ExampleTenant, self).delete(*args, **kwargs)
+
diff --git a/xos/attic/header.py b/xos/attic/header.py
new file mode 100644
index 0000000..d7fcd1e
--- /dev/null
+++ b/xos/attic/header.py
@@ -0,0 +1,11 @@
+# models.py -  ExampleService Models
+
+from core.models import Service, TenantWithContainer
+from django.db import transaction
+from django.db.models import *
+
+SERVICE_NAME = 'exampleservice'
+SERVICE_NAME_VERBOSE = 'Example Service'
+SERVICE_NAME_VERBOSE_PLURAL = 'Example Services'
+TENANT_NAME_VERBOSE = 'Example Tenant'
+TENANT_NAME_VERBOSE_PLURAL = 'Example Tenants'
diff --git a/xos/exampleservice-onboard.yaml b/xos/exampleservice-onboard.yaml
index 777174b..4bdb44d 100644
--- a/xos/exampleservice-onboard.yaml
+++ b/xos/exampleservice-onboard.yaml
@@ -13,7 +13,7 @@
           base_url: file:///opt/xos_services/exampleservice/xos/
           # The following will concatenate with base_url automatically, if
           # base_url is non-null.
-          models: models.py
+          xproto: ./
           admin: admin.py
           synchronizer: synchronizer/manifest
           synchronizer_run: exampleservice-synchronizer.py
diff --git a/xos/exampleservice.xproto b/xos/exampleservice.xproto
new file mode 100644
index 0000000..0d5a70b
--- /dev/null
+++ b/xos/exampleservice.xproto
@@ -0,0 +1,13 @@
+option name = "exampleservice";
+option verbose_name = "Example Service";
+
+message ExampleService (Service){
+    required string service_message = 1 [help_text = "Service Message to Display", max_length = 254, null = False, db_index = False, blank = False];
+}
+
+
+message ExampleTenant (TenantWithContainer){
+     option name = "exampletenant";
+     option verbose_name = "Example Tenant";
+     required string tenant_message = 1 [help_text = "Tenant Message to Display", max_length = 254, null = False, db_index = False, blank = False];
+}
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 5d3e258..af8cdb5 100644
--- a/xos/models.py
+++ b/xos/models.py
@@ -1,47 +1,72 @@
-# models.py -  ExampleService Models
+from header import *
 
-from core.models import Service, TenantWithContainer
-from django.db import models, transaction
 
-SERVICE_NAME = 'exampleservice'
-SERVICE_NAME_VERBOSE = 'Example Service'
-SERVICE_NAME_VERBOSE_PLURAL = 'Example Services'
-TENANT_NAME_VERBOSE = 'Example Tenant'
-TENANT_NAME_VERBOSE_PLURAL = 'Example Tenants'
+
+#from core.models.service import Service
+from core.models import Service
+
+
+
+#from core.models.tenantwithcontainer import TenantWithContainer
+from core.models import TenantWithContainer
+
+
+
+
 
 class ExampleService(Service):
 
-    KIND = SERVICE_NAME
+  KIND = "exampleservice"
 
-    class Meta:
-        app_label = SERVICE_NAME
-        verbose_name = SERVICE_NAME_VERBOSE
+  class Meta:
+      app_label = "exampleservice"
+      name = "exampleservice"
+      verbose_name = "Example Service"
 
-    service_message = models.CharField(max_length=254, help_text="Service Message to Display")
+  # Primitive Fields (Not Relations)
+  service_message = CharField( help_text = "Service Message to Display", max_length = 254, null = False, db_index = False, blank = False )
+  
+
+  # Relations
+  
+
+  
+  pass
+
+
+
 
 class ExampleTenant(TenantWithContainer):
 
-    KIND = SERVICE_NAME
+  KIND = "exampleservice"
 
-    class Meta:
-        verbose_name = TENANT_NAME_VERBOSE
+  class Meta:
+      app_label = "exampleservice"
+      name = "exampletenant"
+      verbose_name = "Example Tenant"
 
-    tenant_message = models.CharField(max_length=254, help_text="Tenant Message to Display")
+  # Primitive Fields (Not Relations)
+  tenant_message = CharField( help_text = "Tenant Message to Display", max_length = 254, null = False, db_index = False, blank = False )
+  
 
-    def __init__(self, *args, **kwargs):
-        exampleservice = ExampleService.get_service_objects().all()
-        if exampleservice:
-            self._meta.get_field('provider_service').default = exampleservice[0].id
-        super(ExampleTenant, self).__init__(*args, **kwargs)
+  # Relations
+  
 
-    def save(self, *args, **kwargs):
-        super(ExampleTenant, self).save(*args, **kwargs)
-        model_policy_exampletenant(self.pk)
-
-    def delete(self, *args, **kwargs):
-        self.cleanup_container()
-        super(ExampleTenant, self).delete(*args, **kwargs)
-
+  def __init__(self, *args, **kwargs):
+      exampleservice = ExampleService.get_service_objects().all()
+      if exampleservice:
+          self._meta.get_field('provider_service').default = exampleservice[0].id
+      super(ExampleTenant, self).__init__(*args, **kwargs)
+  
+  def save(self, *args, **kwargs):
+      super(ExampleTenant, self).save(*args, **kwargs)
+      model_policy_exampletenant(self.pk)
+  
+  def delete(self, *args, **kwargs):
+      self.cleanup_container()
+      super(ExampleTenant, self).delete(*args, **kwargs)
+  
+  pass
 
 def model_policy_exampletenant(pk):
     with transaction.atomic():
@@ -51,3 +76,4 @@
         tenant = tenant[0]
         tenant.manage_container()
 
+