added service_message to ExampleService
diff --git a/xos/services/exampleservice/admin.py b/xos/services/exampleservice/admin.py
index d4f6248..f679e4e 100644
--- a/xos/services/exampleservice/admin.py
+++ b/xos/services/exampleservice/admin.py
@@ -9,25 +9,40 @@
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', 'enabled',)
- list_display_links = ('backend_status_icon', 'name', )
+ 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', 'description',],
+ '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',]
- inlines = [SliceInline]
-
extracontext_registered_admins = True
suit_form_tabs = (
diff --git a/xos/services/exampleservice/models.py b/xos/services/exampleservice/models.py
index 6305b54..5d3e258 100644
--- a/xos/services/exampleservice/models.py
+++ b/xos/services/exampleservice/models.py
@@ -16,7 +16,8 @@
class Meta:
app_label = SERVICE_NAME
verbose_name = SERVICE_NAME_VERBOSE
- proxy = True
+
+ service_message = models.CharField(max_length=254, help_text="Service Message to Display")
class ExampleTenant(TenantWithContainer):
diff --git a/xos/synchronizers/exampleservice/steps/exampletenant_playbook.yaml b/xos/synchronizers/exampleservice/steps/exampletenant_playbook.yaml
index 9da06f5..89e4617 100644
--- a/xos/synchronizers/exampleservice/steps/exampletenant_playbook.yaml
+++ b/xos/synchronizers/exampleservice/steps/exampletenant_playbook.yaml
@@ -6,13 +6,11 @@
user: ubuntu
sudo: yes
gather_facts: no
+ vars:
+ - tenant_message: "{{ tenant_message }}"
+ - service_message: "{{ service_message }}"
- tasks:
- - name: install apache
- apt:
- name=apache2
- update_cache=yes
-
- - name: write message
- shell: echo "{{ tenant_message }}" > /var/www/html/index.html
+ roles:
+ - install_apache
+ - create_index
diff --git a/xos/synchronizers/exampleservice/steps/roles/create_index/tasks/main.yml b/xos/synchronizers/exampleservice/steps/roles/create_index/tasks/main.yml
new file mode 100644
index 0000000..91c6029
--- /dev/null
+++ b/xos/synchronizers/exampleservice/steps/roles/create_index/tasks/main.yml
@@ -0,0 +1,7 @@
+---
+
+- name: Write index.html file to apache document root
+ template:
+ src=index.html.j2
+ dest=/var/www/html/index.html
+
diff --git a/xos/synchronizers/exampleservice/steps/roles/create_index/templates/index.html.j2 b/xos/synchronizers/exampleservice/steps/roles/create_index/templates/index.html.j2
new file mode 100644
index 0000000..9cec084
--- /dev/null
+++ b/xos/synchronizers/exampleservice/steps/roles/create_index/templates/index.html.j2
@@ -0,0 +1,4 @@
+ExampleService
+ Service Message: "{{ service_message }}"
+ Tenant Message: "{{ tenant_message }}"
+
diff --git a/xos/synchronizers/exampleservice/steps/roles/install_apache/tasks/main.yml b/xos/synchronizers/exampleservice/steps/roles/install_apache/tasks/main.yml
new file mode 100644
index 0000000..d9a155c
--- /dev/null
+++ b/xos/synchronizers/exampleservice/steps/roles/install_apache/tasks/main.yml
@@ -0,0 +1,7 @@
+---
+
+- name: Install apache using apt
+ apt:
+ name=apache2
+ update_cache=yes
+
diff --git a/xos/synchronizers/exampleservice/steps/sync_exampletenant.py b/xos/synchronizers/exampleservice/steps/sync_exampletenant.py
index bc4169b..fbde96f 100644
--- a/xos/synchronizers/exampleservice/steps/sync_exampletenant.py
+++ b/xos/synchronizers/exampleservice/steps/sync_exampletenant.py
@@ -33,8 +33,23 @@
return objs
+ def get_exampleservice(self, o):
+ if not o.provider_service:
+ return None
+
+ exampleservice = ExampleService.get_service_objects().filter(id=o.provider_service.id)
+
+ if not exampleservice:
+ return None
+
+ return exampleservice[0]
+
# Gets the attributes that are used by the Ansible template but are not
# part of the set of default attributes.
def get_extra_attributes(self, o):
- return {"tenant_message": o.tenant_message}
+ fields = {}
+ fields['tenant_message'] = o.tenant_message
+ exampleservice = self.get_exampleservice(o)
+ fields['service_message'] = exampleservice.service_message
+ return fields