Fixing merge conflicts
diff --git a/xos/configurations/devel/Dockerfile.devel b/xos/configurations/devel/Dockerfile.devel
index 115b731..a253f3f 100644
--- a/xos/configurations/devel/Dockerfile.devel
+++ b/xos/configurations/devel/Dockerfile.devel
@@ -4,6 +4,7 @@
ADD xos/configurations/common/flat_net_name /root/setup/
ADD xos/configurations/common/cloudlab-nodes.yaml /opt/xos/configurations/commmon/
ADD xos/configurations/common/id_rsa.pub /root/setup/padmin_public_key
+ADD xos/configurations/common/id_rsa /opt/xos/observers/helloworldservice/helloworldservice_private_key
ADD xos/configurations/common/node_key.pub /root/setup/node_key.pub
ADD xos/configurations/common/node_key /root/setup/node_key
ADD xos/configurations/common/ceilometer_url /root/setup/ceilometer_url
diff --git a/xos/configurations/devel/Makefile b/xos/configurations/devel/Makefile
index 3ce188b..2cbc1d0 100644
--- a/xos/configurations/devel/Makefile
+++ b/xos/configurations/devel/Makefile
@@ -5,7 +5,7 @@
test: common_cloudlab
echo "# Autogenerated -- do not edit" > Dockerfile
cat ../common/Dockerfile.common Dockerfile.devel >> Dockerfile
- cd ../../..; sudo docker build -t xos -f xos/configurations/devel/Dockerfile .
+ cd ../../..; sudo docker build --no-cache -t xos -f xos/configurations/devel/Dockerfile .
sudo docker run -d --add-host="ctl:$(MYIP)" -p 9999:8000 xos
bash ../common/wait_for_xos.sh
diff --git a/xos/helloworldservice/__init__.py b/xos/helloworldservice/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/xos/helloworldservice/__init__.py
diff --git a/xos/helloworldservice/admin.py b/xos/helloworldservice/admin.py
new file mode 100644
index 0000000..926fb4e
--- /dev/null
+++ b/xos/helloworldservice/admin.py
@@ -0,0 +1,78 @@
+from django.contrib import admin
+
+from helloworldservice.models import HelloWorldService, HelloWorldTenant, HELLO_WORLD_KIND
+from django import forms
+from core.models import User
+from core.admin import SliceInline, ServiceAttrAsTabInline, ReadOnlyAwareAdmin, ServicePrivilegeInline
+
+from core.middleware import get_request
+
+class HelloWorldServiceAdmin(ReadOnlyAwareAdmin):
+ model = HelloWorldService
+ verbose_name = "Hello World Service"
+ verbose_name_plural = "Hello World Service"
+ list_display = ("backend_status_icon", "name", "enabled")
+ list_display_links = ('backend_status_icon', 'name', )
+ fieldsets = [(None, {'fields': ['backend_status_text', 'name','enabled','versionNumber', 'description',"view_url","icon_url" ], 'classes':['suit-tab suit-tab-general']})]
+ readonly_fields = ('backend_status_text', )
+ inlines = [SliceInline, ServiceAttrAsTabInline, ServicePrivilegeInline]
+
+ extracontext_registered_admins = True
+
+ user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
+
+ suit_form_tabs =(('general', 'Hello World Service Details'),
+ ('administration', 'Administration'),
+ ('slices','Slices'),
+ ('serviceattrs','Additional Attributes'),
+ ('serviceprivileges','Privileges'),
+ )
+
+ suit_form_includes = (('helloworldserviceadmin.html', 'top', 'administration'),
+ )
+ def queryset(self, request):
+ return HelloWorldService.get_service_objects_by_user(request.user)
+
+class HelloWorldTenantForm(forms.ModelForm):
+ creator = forms.ModelChoiceField(queryset=User.objects.all())
+ display_message = forms.CharField(required=False)
+ def __init__(self,*args,**kwargs):
+ super (HelloWorldTenantForm,self ).__init__(*args,**kwargs)
+ self.fields['kind'].widget.attrs['readonly'] = True
+ self.fields['provider_service'].queryset = HelloWorldService.get_service_objects().all()
+ if self.instance:
+ # fields for the attributes
+ self.fields['creator'].initial = self.instance.creator
+ self.fields['display_message'].initial = self.instance.display_message
+ if (not self.instance) or (not self.instance.pk):
+ # default fields for an 'add' form
+ self.fields['kind'].initial = HELLO_WORLD_KIND
+ self.fields['creator'].initial = get_request().user
+ if HelloWorldService.get_service_objects().exists():
+ self.fields["provider_service"].initial = HelloWorldService.get_service_objects().all()[0]
+
+
+ def save(self, commit=True):
+ self.instance.creator = self.cleaned_data.get("creator")
+ self.instance.display_message = self.cleaned_data.get("display_message")
+ return super(HelloWorldTenantForm, self).save(commit=commit)
+
+ class Meta:
+ model = HelloWorldTenant
+
+class HelloWorldTenantAdmin(ReadOnlyAwareAdmin):
+ list_display = ('backend_status_icon', 'id', )
+ list_display_links = ('backend_status_icon', 'id')
+ fieldsets = [ (None, {'fields': ['backend_status_text', 'kind', 'provider_service', 'service_specific_attribute',
+ 'instance', 'creator', 'display_message'],
+ 'classes':['suit-tab suit-tab-general']})]
+ readonly_fields = ('backend_status_text', 'instance', 'service_specific_attribute', )
+ form = HelloWorldTenantForm
+
+ suit_form_tabs = (('general','Details'),)
+
+ def queryset(self, request):
+ return HelloWorldTenant.get_tenant_objects_by_user(request.user)
+
+admin.site.register(HelloWorldService, HelloWorldServiceAdmin)
+admin.site.register(HelloWorldTenant, HelloWorldTenantAdmin)
diff --git a/xos/helloworldservice/models.py b/xos/helloworldservice/models.py
new file mode 100644
index 0000000..c830b9f
--- /dev/null
+++ b/xos/helloworldservice/models.py
@@ -0,0 +1,53 @@
+from core.models import Service, TenantWithContainer
+from django.db import transaction
+
+HELLO_WORLD_KIND = "helloworldservice"
+
+class HelloWorldService(Service):
+ KIND = HELLO_WORLD_KIND
+
+ class Meta:
+ proxy = True
+ app_label = "helloworldservice"
+ verbose_name = "Hello World Service"
+
+class HelloWorldTenant(TenantWithContainer):
+ class Meta:
+ proxy = True
+
+ KIND = HELLO_WORLD_KIND
+ sync_attributes = ("private_ip", "private_mac",
+ "nat_ip", "nat_mac",)
+
+ default_attributes = {'display_message': 'Hello World!'}
+ def __init__(self, *args, **kwargs):
+ helloworld_services = HelloWorldService.get_service_objects().all();
+ if helloworld_services:
+ self._meta.get_field("provider_service").default = helloworld_services[0].id
+ super(HelloWorldTenant, self).__init__(*args, **kwargs)
+
+ def save(self, *args, **kwargs):
+ super(HelloWorldTenant, self).save(*args, **kwargs)
+ model_policy_helloworld_tenant(self.pk)
+
+ def delete(self, *args, **kwargs):
+ self.cleanup_container()
+ super(HelloWorldTenant, self).delete(*args, **kwargs)
+
+ @property
+ def display_message(self):
+ return self.get_attribute(
+ "display_message",
+ self.default_attributes['display_message'])
+
+ @display_message.setter
+ def display_message(self, value):
+ self.set_attribute("display_message", value)
+
+def model_policy_helloworld_tenant(pk):
+ with transaction.atomic():
+ tenant = HelloWorldTenant.objects.select_for_update().filter(pk=pk)
+ if not tenant:
+ return
+ tenant = tenant[0]
+ tenant.manage_container()
diff --git a/xos/helloworldservice/templates/helloworldserviceadmin.html b/xos/helloworldservice/templates/helloworldserviceadmin.html
new file mode 100644
index 0000000..eb8ec35
--- /dev/null
+++ b/xos/helloworldservice/templates/helloworldserviceadmin.html
@@ -0,0 +1,5 @@
+<div class = "left-nav">
+<ul>
+<li><a href="/admin/helloworldservice/helloworldtenant/">Hello World Tenants</a></li>
+</ul>
+</div>
diff --git a/xos/observers/helloworldservice/helloworldservice-observer.py b/xos/observers/helloworldservice/helloworldservice-observer.py
new file mode 100755
index 0000000..d6a71ff
--- /dev/null
+++ b/xos/observers/helloworldservice/helloworldservice-observer.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+
+# This imports and runs ../../xos-observer.py
+
+import importlib
+import os
+import sys
+observer_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),"../..")
+sys.path.append(observer_path)
+mod = importlib.import_module("xos-observer")
+mod.main()
diff --git a/xos/observers/helloworldservice/helloworldservice_config b/xos/observers/helloworldservice/helloworldservice_config
new file mode 100644
index 0000000..c14dff4
--- /dev/null
+++ b/xos/observers/helloworldservice/helloworldservice_config
@@ -0,0 +1,44 @@
+[plc]
+name=plc
+deployment=plc
+
+[db]
+name=xos
+user=postgres
+password=password
+host=localhost
+port=5432
+
+[api]
+host=localhost
+port=8000
+ssl_key=None
+ssl_cert=None
+ca_ssl_cert=None
+ratelimit_enabled=0
+omf_enabled=0
+mail_support_address=support@localhost
+nova_enabled=True
+logfile=/var/log/xos.log
+
+[nova]
+admin_user=admin@domain.com
+admin_password=admin
+admin_tenant=admin
+url=http://localhost:5000/v2.0/
+default_image=None
+default_flavor=m1.small
+default_security_group=default
+ca_ssl_cert=/etc/ssl/certs/ca-certificates.crt
+
+[observer]
+pretend=False
+backoff_disabled=False
+images_directory=/opt/xos/images
+dependency_graph=/opt/xos/observers/helloworldservice/model-deps
+logfile=/var/log/xos_backend.log
+steps_dir=/opt/xos/observers/helloworldservice/steps
+save_ansible_output=True
+
+[gui]
+disable_minidashboard=True
diff --git a/xos/observers/helloworldservice/model-deps b/xos/observers/helloworldservice/model-deps
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/xos/observers/helloworldservice/model-deps
@@ -0,0 +1 @@
+{}
diff --git a/xos/observers/helloworldservice/run.sh b/xos/observers/helloworldservice/run.sh
new file mode 100755
index 0000000..7b0ca1e
--- /dev/null
+++ b/xos/observers/helloworldservice/run.sh
@@ -0,0 +1,2 @@
+export XOS_DIR=/opt/xos
+python helloworldservice-observer.py -C $XOS_DIR/observers/helloworldservice/helloworldservice_config
diff --git a/xos/observers/helloworldservice/steps/sync_helloworldtenant.py b/xos/observers/helloworldservice/steps/sync_helloworldtenant.py
new file mode 100644
index 0000000..356be36
--- /dev/null
+++ b/xos/observers/helloworldservice/steps/sync_helloworldtenant.py
@@ -0,0 +1,32 @@
+import os
+import sys
+from django.db.models import Q, F
+from helloworldservice.models import HelloWorldService, HelloWorldTenant
+from observers.base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
+
+parentdir = os.path.join(os.path.dirname(__file__), "..")
+sys.path.insert(0, parentdir)
+
+class SyncHelloWorldServiceTenant(SyncInstanceUsingAnsible):
+ provides = [HelloWorldTenant]
+ observes = HelloWorldTenant
+ requested_interval = 0
+ template_name = "sync_helloworldtenant.yaml"
+ service_key_name = "/opt/xos/observers/helloworldservice/helloworldservice_private_key"
+
+ def __init__(self, *args, **kwargs):
+ super(SyncHelloWorldServiceTenant, self).__init__(*args, **kwargs)
+
+ def fetch_pending(self, deleted):
+ if (not deleted):
+ objs = HelloWorldTenant.get_tenant_objects().filter(Q(enacted__lt=F('updated')) | Q(enacted=None),Q(lazy_blocked=False))
+ else:
+ objs = HelloWorldTenant.get_deleted_tenant_objects()
+
+ return objs
+
+ def get_extra_attributes(self, o):
+ return {"display_message": o.display_message}
+
+ def delete_record(self, m):
+ return
diff --git a/xos/observers/helloworldservice/steps/sync_helloworldtenant.yaml b/xos/observers/helloworldservice/steps/sync_helloworldtenant.yaml
new file mode 100644
index 0000000..ae472f8
--- /dev/null
+++ b/xos/observers/helloworldservice/steps/sync_helloworldtenant.yaml
@@ -0,0 +1,20 @@
+---
+- hosts: {{ instance_name }}
+ gather_facts: False
+ connection: ssh
+ user: ubuntu
+ sudo: yes
+ vars:
+ display_message: {{ display_message }}
+ tasks:
+ - name: install apache
+ apt: name=apache2 state=present
+
+ - name: write message
+ shell: cat "{{ display_message }}" > "/var/www/html/{{ instance_name }}.html"
+
+ - name: stop apache
+ service: name=apache2 state=stopped
+
+ - name: start apache
+ service: name=apache2 state=started
diff --git a/xos/observers/helloworldservice/stop.sh b/xos/observers/helloworldservice/stop.sh
new file mode 100755
index 0000000..8a6f727
--- /dev/null
+++ b/xos/observers/helloworldservice/stop.sh
@@ -0,0 +1 @@
+pkill -9 -f helloworldservice-observer.py
diff --git a/xos/scripts/opencloud b/xos/scripts/opencloud
index 189a673..7e27da4 100755
--- a/xos/scripts/opencloud
+++ b/xos/scripts/opencloud
@@ -144,6 +144,7 @@
python ./manage.py makemigrations syndicate_storage
python ./manage.py makemigrations cord
python ./manage.py makemigrations ceilometer
+ python ./manage.py makemigrations helloworldservice
python ./manage.py makemigrations onos
#python ./manage.py makemigrations servcomp
}
diff --git a/xos/xos/settings.py b/xos/xos/settings.py
index 3e64d15..d7ec5e7 100644
--- a/xos/xos/settings.py
+++ b/xos/xos/settings.py
@@ -9,7 +9,7 @@
GEOIP_PATH = "/usr/share/GeoIP"
XOS_DIR = "/opt/xos"
-DEBUG = False
+DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
@@ -154,6 +154,7 @@
'core',
'hpc',
'cord',
+ 'helloworldservice',
'services.onos',
'ceilometer',
'requestrouter',