Document observer
diff --git a/xos/observers/helloworldservice/helloworldservice-observer.py b/xos/observers/helloworldservice/helloworldservice-observer.py
index 6f86202..91bbe96 100755
--- a/xos/observers/helloworldservice/helloworldservice-observer.py
+++ b/xos/observers/helloworldservice/helloworldservice-observer.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# This imports and runs ../../xos-observer.py
+# Runs te standard XOS observer
import importlib
import os
diff --git a/xos/observers/helloworldservice/helloworldservice_config b/xos/observers/helloworldservice/helloworldservice_config
index 9afe406..ab0024d 100644
--- a/xos/observers/helloworldservice/helloworldservice_config
+++ b/xos/observers/helloworldservice/helloworldservice_config
@@ -44,7 +44,7 @@
# We want to output from ansible to be logged
save_ansible_output=True
# This determines how we SSH to a client, if this is set to True then we try
-# to ssh using the instance name as a proxy, if this is disabled we ssh using
+# to ssh using the instance name as a proxy, if this is disabled we ssh using
# the NAT IP of the instance. On CloudLab the first option will fail so we must
# set this to False
proxy_ssh=False
diff --git a/xos/observers/helloworldservice/run.sh b/xos/observers/helloworldservice/run.sh
index 7b0ca1e..0fc5670 100755
--- a/xos/observers/helloworldservice/run.sh
+++ b/xos/observers/helloworldservice/run.sh
@@ -1,2 +1,3 @@
+# Runs the XOS observer using helloworldservice_config
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
index c032ec2..e971a96 100644
--- a/xos/observers/helloworldservice/steps/sync_helloworldtenant.py
+++ b/xos/observers/helloworldservice/steps/sync_helloworldtenant.py
@@ -7,28 +7,47 @@
parentdir = os.path.join(os.path.dirname(__file__), "..")
sys.path.insert(0, parentdir)
-
+# Class to define how we sync a tenant. Using SyncInstanceUsingAnsible we
+# indicate where the find the YAML for ansible, where to find the SSH key,
+# and the logic for determining what tenant needs updating, what additional
+# attributes are needed, and how to delete an instance.
class SyncHelloWorldServiceTenant(SyncInstanceUsingAnsible):
+ # Indicates the position in the data model, this will run when XOS needs to
+ # enact a HelloWorldTenant
provides = [HelloWorldTenant]
+ # The actual model being enacted, usually the same as provides.
observes = HelloWorldTenant
+ # Number of miliseconds between interruptions of the observer
requested_interval = 0
+ # The ansible template to run
template_name = "sync_helloworldtenant.yaml"
+ # The location of the SSH private key to use when ansible connects to
+ # instances.
service_key_name = "/opt/xos/observers/helloworldservice/helloworldservice_private_key"
def __init__(self, *args, **kwargs):
super(SyncHelloWorldServiceTenant, self).__init__(*args, **kwargs)
+ # Defines the logic for determining what HelloWorldTenants need to be
+ # enacted.
def fetch_pending(self, deleted):
+ # If the update is not a deletion, then we get all of the instnaces that
+ # have been updated or have not been enacted.
if (not deleted):
objs = HelloWorldTenant.get_tenant_objects().filter(
Q(enacted__lt=F('updated')) | Q(enacted=None), Q(lazy_blocked=False))
else:
+ # If this is a deletion we get all of the deleted tenants..
objs = HelloWorldTenant.get_deleted_tenant_objects()
return objs
+ # 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 {"display_message": o.display_message}
+ # Defines how to delete a HelloWorldTenant, since we don't have anyhting
+ # special to cleanup or dependencies we do nothing.
def delete_record(self, m):
return
diff --git a/xos/observers/helloworldservice/stop.sh b/xos/observers/helloworldservice/stop.sh
index 8a6f727..76e68d9 100755
--- a/xos/observers/helloworldservice/stop.sh
+++ b/xos/observers/helloworldservice/stop.sh
@@ -1 +1,2 @@
+# Kill the observer
pkill -9 -f helloworldservice-observer.py