ActiveTest Service Creation.

Onboarding is done by running 'make activetest'. fusion.img, qt600.img, vta.img, and vpma.img
should be in the corresponding service_profile's image/ folder in order for images to be
uploaded in glance.

The measurement agents can be created through the different agents tenants. For example, to
create a VPMA tenant, run 'make vpma 1' where '1' can be any numberical identifier for the
tenant to be created.

Measurement agents will automatically register with the fusion controller through the use of
the synchronizer. Furthermore, tests can be orchestrated through XOS by modifying the models
for the vpma agents.

Change-Id: I69bab4b5f771c87126781799217bb36fda478fd3
diff --git a/xos/synchronizer/steps/sync_activetesttenant.py b/xos/synchronizer/steps/sync_activetesttenant.py
new file mode 100644
index 0000000..e97fbda
--- /dev/null
+++ b/xos/synchronizer/steps/sync_activetesttenant.py
@@ -0,0 +1,52 @@
+import os
+import sys
+from django.db.models import Q, F
+from services.activetest.models import ActiveTestService, ActiveTestTenant
+from synchronizers.base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
+
+parentdir = os.path.join(os.path.dirname(__file__), "..")
+sys.path.insert(0, parentdir)
+
+class SyncActiveTestTenant(SyncInstanceUsingAnsible):
+
+    provides = [ActiveTestTenant]
+
+    observes = ActiveTestTenant
+
+    requested_interval = 0
+
+    template_name = "activetesttenant_playbook.yaml"
+
+    service_key_name = "/opt/xos/synchronizers/activetest/activetest_private_key"
+
+    def __init__(self, *args, **kwargs):
+        super(SyncActiveTestTenant, self).__init__(*args, **kwargs)
+
+    def fetch_pending(self, deleted):
+
+        if (not deleted):
+            objs = ActiveTestTenant.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 = ActiveTestTenant.get_deleted_tenant_objects()
+
+        return objs
+
+    def get_activetestservice(self, o):
+        if not o.provider_service:
+            return None
+
+        activetestservice = ActiveTestService.get_service_objects().filter(id=o.provider_service.id)
+
+        if not activetestservice:
+            return None
+
+        return activetestservice[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 { "public_ip": o.public_ip }
+
+