set up a spot to onboard exampleservice from
diff --git a/xos/onboard/README.md b/xos/onboard/README.md
new file mode 100644
index 0000000..2030708
--- /dev/null
+++ b/xos/onboard/README.md
@@ -0,0 +1,3 @@
+This directory is a temporary placeholder for services that can be on-boarded.
+
+Once we move to Gerritt and service-per-repo, this directory will be removed.
diff --git a/xos/onboard/exampleservice/admin.py b/xos/onboard/exampleservice/admin.py
new file mode 100644
index 0000000..f679e4e
--- /dev/null
+++ b/xos/onboard/exampleservice/admin.py
@@ -0,0 +1,116 @@
+# admin.py - ExampleService Django Admin
+
+from core.admin import ReadOnlyAwareAdmin, SliceInline
+from core.middleware import get_request
+from core.models import User
+
+from django import forms
+from django.contrib import admin
+
+from services.exampleservice.models import *
+
+class ExampleServiceForm(forms.ModelForm):
+
+ class Meta:
+ model = ExampleService
+
+ def __init__(self, *args, **kwargs):
+ super(ExampleServiceForm, self).__init__(*args, **kwargs)
+
+ if self.instance:
+ self.fields['service_message'].initial = self.instance.service_message
+
+ def save(self, commit=True):
+ self.instance.service_message = self.cleaned_data.get('service_message')
+ return super(ExampleServiceForm, self).save(commit=commit)
+
+class ExampleServiceAdmin(ReadOnlyAwareAdmin):
+
+ model = ExampleService
+ verbose_name = SERVICE_NAME_VERBOSE
+ verbose_name_plural = SERVICE_NAME_VERBOSE_PLURAL
+ form = ExampleServiceForm
+ inlines = [SliceInline]
+
+ list_display = ('backend_status_icon', 'name', 'service_message', 'enabled')
+ list_display_links = ('backend_status_icon', 'name', 'service_message' )
+
+ fieldsets = [(None, {
+ 'fields': ['backend_status_text', 'name', 'enabled', 'versionNumber', 'service_message', 'description',],
+ 'classes':['suit-tab suit-tab-general',],
+ })]
+
+ readonly_fields = ('backend_status_text', )
+ user_readonly_fields = ['name', 'enabled', 'versionNumber', 'description',]
+
+ extracontext_registered_admins = True
+
+ suit_form_tabs = (
+ ('general', 'Example Service Details', ),
+ ('slices', 'Slices',),
+ )
+
+ suit_form_includes = ((
+ 'top',
+ 'administration'),
+ )
+
+ def queryset(self, request):
+ return ExampleService.get_service_objects_by_user(request.user)
+
+admin.site.register(ExampleService, ExampleServiceAdmin)
+
+class ExampleTenantForm(forms.ModelForm):
+
+ class Meta:
+ model = ExampleTenant
+
+ creator = forms.ModelChoiceField(queryset=User.objects.all())
+
+ def __init__(self, *args, **kwargs):
+ super(ExampleTenantForm, self).__init__(*args, **kwargs)
+
+ self.fields['kind'].widget.attrs['readonly'] = True
+ self.fields['kind'].initial = SERVICE_NAME
+
+ self.fields['provider_service'].queryset = ExampleService.get_service_objects().all()
+
+ if self.instance:
+ self.fields['creator'].initial = self.instance.creator
+ self.fields['tenant_message'].initial = self.instance.tenant_message
+
+ if (not self.instance) or (not self.instance.pk):
+ self.fields['creator'].initial = get_request().user
+ if ExampleService.get_service_objects().exists():
+ self.fields['provider_service'].initial = ExampleService.get_service_objects().all()[0]
+
+ def save(self, commit=True):
+ self.instance.creator = self.cleaned_data.get('creator')
+ self.instance.tenant_message = self.cleaned_data.get('tenant_message')
+ return super(ExampleTenantForm, self).save(commit=commit)
+
+
+class ExampleTenantAdmin(ReadOnlyAwareAdmin):
+
+ verbose_name = TENANT_NAME_VERBOSE
+ verbose_name_plural = TENANT_NAME_VERBOSE_PLURAL
+
+ list_display = ('id', 'backend_status_icon', 'instance', 'tenant_message')
+ list_display_links = ('backend_status_icon', 'instance', 'tenant_message', 'id')
+
+ fieldsets = [(None, {
+ 'fields': ['backend_status_text', 'kind', 'provider_service', 'instance', 'creator', 'tenant_message'],
+ 'classes': ['suit-tab suit-tab-general'],
+ })]
+
+ readonly_fields = ('backend_status_text', 'instance',)
+
+ form = ExampleTenantForm
+
+ suit_form_tabs = (('general', 'Details'),)
+
+ def queryset(self, request):
+ return ExampleTenant.get_tenant_objects_by_user(request.user)
+
+admin.site.register(ExampleTenant, ExampleTenantAdmin)
+
diff --git a/xos/onboard/exampleservice/exampleservice-onboard.yaml b/xos/onboard/exampleservice/exampleservice-onboard.yaml
new file mode 100644
index 0000000..0095e44
--- /dev/null
+++ b/xos/onboard/exampleservice/exampleservice-onboard.yaml
@@ -0,0 +1,30 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Onboard the exampleservice
+
+imports:
+ - custom_types/xos.yaml
+
+topology_template:
+ node_templates:
+ exampleservice:
+ type: tosca.nodes.ServiceController
+ base_url: file:/opt/xos/onboard/exampleservice/
+
+ exampleservice_models:
+ type: tosca.nodes.ServiceControllerResource
+ kind: models
+ format: python
+ url: models.py
+
+ exampleservice_admin:
+ type: tosca.nodes.ServiceControllerResource
+ kind: admin
+ format: python
+ url: admin.py
+
+ exampleservice_synchronizer:
+ type: tosca.nodes.ServiceControllerResource
+ kind: synchronizer
+ format: manifest
+ url: synchronizer/manifest
diff --git a/xos/onboard/exampleservice/models.py b/xos/onboard/exampleservice/models.py
new file mode 100644
index 0000000..5d3e258
--- /dev/null
+++ b/xos/onboard/exampleservice/models.py
@@ -0,0 +1,53 @@
+# models.py - ExampleService Models
+
+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'
+
+class ExampleService(Service):
+
+ KIND = SERVICE_NAME
+
+ class Meta:
+ app_label = SERVICE_NAME
+ verbose_name = SERVICE_NAME_VERBOSE
+
+ service_message = models.CharField(max_length=254, help_text="Service Message to Display")
+
+class ExampleTenant(TenantWithContainer):
+
+ KIND = SERVICE_NAME
+
+ class Meta:
+ verbose_name = TENANT_NAME_VERBOSE
+
+ tenant_message = models.CharField(max_length=254, help_text="Tenant Message to Display")
+
+ 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)
+
+
+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()
+