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/ActiveTest-onboard.yaml b/xos/ActiveTest-onboard.yaml
new file mode 100644
index 0000000..9afb877
--- /dev/null
+++ b/xos/ActiveTest-onboard.yaml
@@ -0,0 +1,26 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Onboard the ActiveTest
+
+imports:
+   - custom_types/xos.yaml
+
+topology_template:
+  node_templates:
+    activetest:
+      type: tosca.nodes.ServiceController
+      properties:
+          base_url: file:///opt/xos_services/ActiveTest/xos/
+          # The following will concatenate with base_url automatically, if
+          # base_url is non-null.
+          models: models.py
+          admin: admin.py
+          synchronizer: synchronizer/manifest
+          synchronizer_run: activetest-synchronizer.py
+          tosca_custom_types: ActiveTest.yaml
+          tosca_resource: tosca/resources/activetest.py, tosca/resources/activetesttenant.py, tosca/resources/qt600tenant.py, tosca/resources/vpmatenant.py, tosca/resources/vtatenant.py
+          rest_service: api/service/activetest.py
+          rest_tenant: api/tenant/activetesttenant.py
+          private_key: file:///opt/xos/key_import/activetest_rsa
+          public_key: file:///opt/xos/key_import/activetest_rsa.pub
+
diff --git a/xos/ActiveTest.m4 b/xos/ActiveTest.m4
new file mode 100644
index 0000000..15af729
--- /dev/null
+++ b/xos/ActiveTest.m4
@@ -0,0 +1,93 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+# compile this with "m4 ActiveTest.m4 > ActiveTest.yaml"
+
+# include macros
+include(macros.m4)
+
+node_types:
+    tosca.nodes.ActiveTest:
+        derived_from: tosca.nodes.Root
+        description: >
+            ActiveTest Service
+        capabilities:
+            xos_base_service_caps
+        properties:
+            xos_base_props
+            xos_base_service_props
+
+    tosca.nodes.VtaService:
+        derived_from: tosca.nodes.Root
+        description: >
+            VTA Service
+        capabilities:
+            xos_base_service_caps
+        properties:
+            xos_base_props
+            xos_base_service_props
+
+    tosca.nodes.Qt600Service:
+        derived_from: tosca.nodes.Root
+        description: >
+            QT600 Service
+        capabilities:
+            xos_base_service_caps
+        properties:
+            xos_base_props
+            xos_base_service_props
+
+    tosca.nodes.VpmaService:
+        derived_from: tosca.nodes.Root
+        description: >
+            VPMA Service
+        capabilities:
+            xos_base_service_caps
+        properties:
+            xos_base_props
+            xos_base_service_props
+
+    tosca.nodes.ActiveTestTenant:
+        derived_from: tosca.nodes.Root
+        description: >
+            A Tenant of the ActiveTest service
+        properties:
+            xos_base_tenant_props
+
+    tosca.nodes.VtaTenant:
+        derived_from: tosca.nodes.Root
+        description: >
+            A Tenant of the VTA service
+        properties:
+            xos_base_tenant_props
+
+    tosca.nodes.Qt600Tenant:
+        derived_from: tosca.nodes.Root
+        description: >
+            A Tenant of the QT600 service
+        properties:
+            xos_base_tenant_props
+            is_reflector:
+                type: boolean
+                required: false
+            is_initiator:
+                type: boolean
+                required: false
+            reflector:
+                type: string
+                required: false
+
+    tosca.nodes.VpmaTenant:
+        derived_from: tosca.nodes.Root
+        description: >
+            A Tenant of the VPMA service
+        properties:
+            xos_base_tenant_props
+            is_reflector:
+                type: boolean
+                required: false
+            is_initiator:
+                type: boolean
+                required: false
+            reflector:
+                type: string
+                required: false
diff --git a/xos/ActiveTest.yaml b/xos/ActiveTest.yaml
new file mode 100644
index 0000000..6c36501
--- /dev/null
+++ b/xos/ActiveTest.yaml
@@ -0,0 +1,328 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+# compile this with "m4 ActiveTest.m4 > ActiveTest.yaml"
+
+# include macros
+# Note: Tosca derived_from isn't working the way I think it should, it's not
+#    inheriting from the parent template. Until we get that figured out, use
+#    m4 macros do our inheritance
+
+
+# Service
+
+
+# Subscriber
+
+
+
+
+# end m4 macros
+
+
+
+node_types:
+    tosca.nodes.ActiveTest:
+        derived_from: tosca.nodes.Root
+        description: >
+            ActiveTest Service
+        capabilities:
+            scalable:
+                type: tosca.capabilities.Scalable
+            service:
+                type: tosca.capabilities.xos.Service
+        properties:
+            no-delete:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to delete this object
+            no-create:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to create this object
+            no-update:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
+            kind:
+                type: string
+                default: generic
+                description: Type of service.
+            view_url:
+                type: string
+                required: false
+                description: URL to follow when icon is clicked in the Service Directory.
+            icon_url:
+                type: string
+                required: false
+                description: ICON to display in the Service Directory.
+            enabled:
+                type: boolean
+                default: true
+            published:
+                type: boolean
+                default: true
+                description: If True then display this Service in the Service Directory.
+            public_key:
+                type: string
+                required: false
+                description: Public key to install into Instances to allows Services to SSH into them.
+            private_key_fn:
+                type: string
+                required: false
+                description: Location of private key file
+            versionNumber:
+                type: string
+                required: false
+                description: Version number of Service.
+
+    tosca.nodes.VtaService:
+        derived_from: tosca.nodes.Root
+        description: >
+            VTA Service
+        capabilities:
+            scalable:
+                type: tosca.capabilities.Scalable
+            service:
+                type: tosca.capabilities.xos.Service
+        properties:
+            no-delete:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to delete this object
+            no-create:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to create this object
+            no-update:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
+            kind:
+                type: string
+                default: generic
+                description: Type of service.
+            view_url:
+                type: string
+                required: false
+                description: URL to follow when icon is clicked in the Service Directory.
+            icon_url:
+                type: string
+                required: false
+                description: ICON to display in the Service Directory.
+            enabled:
+                type: boolean
+                default: true
+            published:
+                type: boolean
+                default: true
+                description: If True then display this Service in the Service Directory.
+            public_key:
+                type: string
+                required: false
+                description: Public key to install into Instances to allows Services to SSH into them.
+            private_key_fn:
+                type: string
+                required: false
+                description: Location of private key file
+            versionNumber:
+                type: string
+                required: false
+                description: Version number of Service.
+
+    tosca.nodes.Qt600Service:
+        derived_from: tosca.nodes.Root
+        description: >
+            QT600 Service
+        capabilities:
+            scalable:
+                type: tosca.capabilities.Scalable
+            service:
+                type: tosca.capabilities.xos.Service
+        properties:
+            no-delete:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to delete this object
+            no-create:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to create this object
+            no-update:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
+            kind:
+                type: string
+                default: generic
+                description: Type of service.
+            view_url:
+                type: string
+                required: false
+                description: URL to follow when icon is clicked in the Service Directory.
+            icon_url:
+                type: string
+                required: false
+                description: ICON to display in the Service Directory.
+            enabled:
+                type: boolean
+                default: true
+            published:
+                type: boolean
+                default: true
+                description: If True then display this Service in the Service Directory.
+            public_key:
+                type: string
+                required: false
+                description: Public key to install into Instances to allows Services to SSH into them.
+            private_key_fn:
+                type: string
+                required: false
+                description: Location of private key file
+            versionNumber:
+                type: string
+                required: false
+                description: Version number of Service.
+
+    tosca.nodes.VpmaService:
+        derived_from: tosca.nodes.Root
+        description: >
+            VPMA Service
+        capabilities:
+            scalable:
+                type: tosca.capabilities.Scalable
+            service:
+                type: tosca.capabilities.xos.Service
+        properties:
+            no-delete:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to delete this object
+            no-create:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to create this object
+            no-update:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
+            kind:
+                type: string
+                default: generic
+                description: Type of service.
+            view_url:
+                type: string
+                required: false
+                description: URL to follow when icon is clicked in the Service Directory.
+            icon_url:
+                type: string
+                required: false
+                description: ICON to display in the Service Directory.
+            enabled:
+                type: boolean
+                default: true
+            published:
+                type: boolean
+                default: true
+                description: If True then display this Service in the Service Directory.
+            public_key:
+                type: string
+                required: false
+                description: Public key to install into Instances to allows Services to SSH into them.
+            private_key_fn:
+                type: string
+                required: false
+                description: Location of private key file
+            versionNumber:
+                type: string
+                required: false
+                description: Version number of Service.
+
+    tosca.nodes.ActiveTestTenant:
+        derived_from: tosca.nodes.Root
+        description: >
+            A Tenant of the ActiveTest service
+        properties:
+            kind:
+                type: string
+                default: generic
+                description: Kind of tenant
+            service_specific_id:
+                type: string
+                required: false
+                description: Service specific ID opaque to XOS but meaningful to service
+
+    tosca.nodes.VtaTenant:
+        derived_from: tosca.nodes.Root
+        description: >
+            A Tenant of the VTA service
+        properties:
+            kind:
+                type: string
+                default: generic
+                description: Kind of tenant
+            service_specific_id:
+                type: string
+                required: false
+                description: Service specific ID opaque to XOS but meaningful to service
+
+    tosca.nodes.Qt600Tenant:
+        derived_from: tosca.nodes.Root
+        description: >
+            A Tenant of the QT600 service
+        properties:
+            kind:
+                type: string
+                default: generic
+                description: Kind of tenant
+            service_specific_id:
+                type: string
+                required: false
+                description: Service specific ID opaque to XOS but meaningful to service
+            is_reflector:
+                type: boolean
+                required: false
+            is_initiator:
+                type: boolean
+                required: false
+            reflector:
+                type: string
+                required: false
+
+    tosca.nodes.VpmaTenant:
+        derived_from: tosca.nodes.Root
+        description: >
+            A Tenant of the VPMA service
+        properties:
+            kind:
+                type: string
+                default: generic
+                description: Kind of tenant
+            service_specific_id:
+                type: string
+                required: false
+                description: Service specific ID opaque to XOS but meaningful to service
+            is_reflector:
+                type: boolean
+                required: false
+            is_initiator:
+                type: boolean
+                required: false
+            reflector:
+                type: string
+                required: false
diff --git a/xos/admin.py b/xos/admin.py
new file mode 100644
index 0000000..f525e69
--- /dev/null
+++ b/xos/admin.py
@@ -0,0 +1,266 @@
+# admin.py - ActiveTest 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.activetest.models import *
+
+class ActiveTestForm(forms.ModelForm):
+
+    class Meta:
+        model = ActiveTestService
+        fields = '__all__'
+
+class ActiveTestAdmin(ReadOnlyAwareAdmin):
+
+    model = ActiveTestService
+    verbose_name = ACTIVETEST_SERVICE_NAME_VERBOSE
+    verbose_name_plural = ACTIVETEST_SERVICE_NAME_VERBOSE_PLURAL
+    form = ActiveTestForm
+    inlines = [SliceInline]
+
+    list_display = ('backend_status_icon', 'name', 'enabled')
+    list_display_links = ('backend_status_icon', 'name' )
+
+    fieldsets = [(None, {
+        'fields': ['backend_status_text', 'name', 'enabled', 'versionNumber', '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', 'ActiveTest Details', ),
+        ('slices', 'Slices',),
+        )
+
+    suit_form_includes = ((
+        'top',
+        'administration'),
+        )
+
+    def get_queryset(self, request):
+        return ActiveTestService.get_service_objects_by_user(request.user)
+
+admin.site.register(ActiveTestService, ActiveTestAdmin)
+
+class ActiveTestTenantForm(forms.ModelForm):
+
+    class Meta:
+        model = ActiveTestTenant
+        fields = '__all__'
+
+    creator = forms.ModelChoiceField(queryset=User.objects.all())
+
+    def __init__(self, *args, **kwargs):
+        super(ActiveTestTenantForm, self).__init__(*args, **kwargs)
+
+        self.fields['kind'].widget.attrs['readonly'] = True
+        self.fields['kind'].initial = ACTIVETEST_KIND
+
+        self.fields['provider_service'].queryset = ActiveTestService.get_service_objects().all()
+
+        if self.instance:
+            self.fields['creator'].initial = self.instance.creator
+
+        if (not self.instance) or (not self.instance.pk):
+            self.fields['creator'].initial = get_request().user
+            if ActiveTestService.get_service_objects().exists():
+                self.fields['provider_service'].initial = ActiveTestService.get_service_objects().all()[0]
+
+    def save(self, commit=True):
+        self.instance.creator = self.cleaned_data.get('creator')
+        return super(ActiveTestTenantForm, self).save(commit=commit)
+
+
+class ActiveTestTenantAdmin(ReadOnlyAwareAdmin):
+
+    verbose_name = ACTIVETEST_TENANT_NAME_VERBOSE
+    verbose_name_plural = ACTIVETEST_TENANT_NAME_VERBOSE_PLURAL
+
+    list_display = ('id', 'backend_status_icon', 'instance')
+    list_display_links = ('backend_status_icon', 'instance', 'id')
+
+    fieldsets = [(None, {
+        'fields': ['backend_status_text', 'kind', 'provider_service', 'instance', 'creator'],
+        'classes': ['suit-tab suit-tab-general'],
+        })]
+
+    readonly_fields = ('backend_status_text', 'instance',)
+
+    form = ActiveTestTenantForm
+
+    suit_form_tabs = (('general', 'Details'),)
+
+    def get_queryset(self, request):
+        return ActiveTestTenant.get_tenant_objects_by_user(request.user)
+
+admin.site.register(ActiveTestTenant, ActiveTestTenantAdmin)
+
+########################################################################################
+"""
+class VpmaForm(forms.ModelForm):
+
+    class Meta:
+        model = VpmaService
+        fields = '__all__'
+
+class VpmaAdmin(ReadOnlyAwareAdmin):
+
+    model = VpmaService
+    verbose_name = VPMA_SERVICE_NAME_VERBOSE
+    verbose_name_plural = VPMA_SERVICE_NAME_VERBOSE_PLURAL
+    form = VpmaForm
+    inlines = [SliceInline]
+
+    list_display = ('backend_status_icon', 'name', 'enabled')
+    list_display_links = ('backend_status_icon', 'name' )
+
+    fieldsets = [(None, {
+        'fields': ['backend_status_text', 'name', 'enabled', 'versionNumber', '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', 'Vpma Details', ),
+        ('slices', 'Slices',),
+        )
+
+    suit_form_includes = ((
+        'top',
+        'administration'),
+        )
+
+    def get_queryset(self, request):
+        return VpmaService.get_service_objects_by_user(request.user)
+
+admin.site.register(VpmaService, VpmaAdmin)
+"""
+class Qt600TenantForm(forms.ModelForm):
+
+    class Meta:
+        model = Qt600Tenant
+        fields = '__all__'
+
+    creator = forms.ModelChoiceField(queryset=User.objects.all())
+
+    def __init__(self, *args, **kwargs):
+        super(Qt600TenantForm, self).__init__(*args, **kwargs)
+
+        self.fields['kind'].widget.attrs['readonly'] = True
+        self.fields['kind'].initial = ACTIVETEST_KIND
+
+        self.fields['provider_service'].queryset = Qt600Service.get_service_objects().all()
+
+        if self.instance:
+            self.fields['creator'].initial = self.instance.creator
+            self.fields['is_reflector'].initial = self.instance.is_reflector
+            self.fields['is_initiator'].initial = self.instance.is_initiator
+            self.fields['reflector'].initial = self.instance.reflector
+
+        if (not self.instance) or (not self.instance.pk):
+            self.fields['creator'].initial = get_request().user
+            if Qt600Service.get_service_objects().exists():
+                self.fields['provider_service'].initial = Qt600Service.get_service_objects().all()[0]
+
+    def save(self, commit=True):
+        self.instance.creator = self.cleaned_data.get('creator')
+        self.instance.is_reflector = self.cleaned_data.get('is_reflector')
+        self.instance.is_initiator = self.cleaned_data.get('is_initiator')
+        self.instance.reflector = self.cleaned_data.get('reflector')
+        return super(Qt600TenantForm, self).save(commit=commit)
+
+class Qt600TenantAdmin(ReadOnlyAwareAdmin):
+
+    verbose_name = QT600_TENANT_NAME_VERBOSE
+    verbose_name_plural = QT600_TENANT_NAME_VERBOSE_PLURAL
+
+    list_display = ('id', 'backend_status_icon', 'instance', 'is_reflector', 'is_initiator', 'reflector')
+    list_display_links = ('backend_status_icon', 'instance', 'is_reflector', 'is_initiator', 'reflector', 'id')
+
+    fieldsets = [(None, {
+        'fields': ['backend_status_text', 'kind', 'provider_service', 'instance', 'creator', 'is_reflector', 'is_initiator', 'reflector'],
+        'classes': ['suit-tab suit-tab-general'],
+        })]
+
+    readonly_fields = ('backend_status_text', 'instance',)
+
+    form = Qt600TenantForm
+
+    suit_form_tabs = (('general', 'Details'),)
+
+    def get_queryset(self, request):
+        return Qt600Tenant.get_tenant_objects_by_user(request.user)
+
+admin.site.register(Qt600Tenant, Qt600TenantAdmin)
+
+class VpmaTenantForm(forms.ModelForm):
+
+    class Meta:
+        model = VpmaTenant
+        fields = '__all__'
+
+    creator = forms.ModelChoiceField(queryset=User.objects.all())
+
+    def __init__(self, *args, **kwargs):
+        super(VpmaTenantForm, self).__init__(*args, **kwargs)
+
+        self.fields['kind'].widget.attrs['readonly'] = True
+        self.fields['kind'].initial = ACTIVETEST_KIND
+
+        self.fields['provider_service'].queryset = VpmaService.get_service_objects().all()
+
+        if self.instance:
+            self.fields['creator'].initial = self.instance.creator
+            self.fields['is_reflector'].initial = self.instance.is_reflector
+            self.fields['is_initiator'].initial = self.instance.is_initiator
+            self.fields['reflector'].initial = self.instance.reflector
+
+        if (not self.instance) or (not self.instance.pk):
+            self.fields['creator'].initial = get_request().user
+            if VpmaService.get_service_objects().exists():
+                self.fields['provider_service'].initial = VpmaService.get_service_objects().all()[0]
+
+    def save(self, commit=True):
+        self.instance.creator = self.cleaned_data.get('creator')
+        self.instance.is_reflector = self.cleaned_data.get('is_reflector')
+        self.instance.is_initiator = self.cleaned_data.get('is_initiator')
+        self.instance.reflector = self.cleaned_data.get('reflector')
+        return super(VpmaTenantForm, self).save(commit=commit)
+
+
+class VpmaTenantAdmin(ReadOnlyAwareAdmin):
+
+    verbose_name = VPMA_TENANT_NAME_VERBOSE
+    verbose_name_plural = VPMA_TENANT_NAME_VERBOSE_PLURAL
+
+    list_display = ('id', 'backend_status_icon', 'instance', 'is_reflector', 'is_initiator', 'reflector')
+    list_display_links = ('backend_status_icon', 'instance', 'is_reflector', 'is_initiator', 'reflector', 'id')
+
+    fieldsets = [(None, {
+        'fields': ['backend_status_text', 'kind', 'provider_service', 'instance', 'creator', 'is_reflector', 'is_initiator', 'reflector'],
+        'classes': ['suit-tab suit-tab-general'],
+        })]
+
+    readonly_fields = ('backend_status_text', 'instance',)
+
+    form = VpmaTenantForm
+
+    suit_form_tabs = (('general', 'Details'),)
+
+    def get_queryset(self, request):
+        return VpmaTenant.get_tenant_objects_by_user(request.user)
+
+admin.site.register(VpmaTenant, VpmaTenantAdmin)
diff --git a/xos/api/service/activetest.py b/xos/api/service/activetest.py
new file mode 100644
index 0000000..8492d93
--- /dev/null
+++ b/xos/api/service/activetest.py
@@ -0,0 +1,108 @@
+from rest_framework.decorators import api_view
+from rest_framework.response import Response
+from rest_framework.reverse import reverse
+from rest_framework import serializers
+from rest_framework import generics
+from rest_framework import viewsets
+from rest_framework import status
+from rest_framework.decorators import detail_route, list_route
+from rest_framework.views import APIView
+from core.models import *
+from django.forms import widgets
+from django.conf.urls import patterns, url
+from api.xosapi_helpers import PlusModelSerializer, XOSViewSet, ReadOnlyField
+from django.shortcuts import get_object_or_404
+from xos.apibase import XOSListCreateAPIView, XOSRetrieveUpdateDestroyAPIView, XOSPermissionDenied
+from xos.exceptions import *
+import json
+import subprocess
+from services.activetest.models import ActiveTestService, VpmaService, Qt600Service
+
+class ActiveTestSerializer(PlusModelSerializer):
+        id = ReadOnlyField()
+        humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
+
+        class Meta:
+            model = ActiveTestService
+            fields = ('humanReadableName',
+                      'id')
+
+        def getHumanReadableName(self, obj):
+            return obj.__unicode__()
+
+class ActiveTestViewSet(XOSViewSet):
+    base_name = "activetest"
+    method_name = "activetest"
+    method_kind = "viewset"
+    queryset = ActiveTestService.get_service_objects().all()
+    serializer_class = ActiveTestSerializer
+
+    @classmethod
+    def get_urlpatterns(self, api_path="^"):
+        patterns = super(ActiveTestViewSet, self).get_urlpatterns(api_path=api_path)
+        return patterns
+
+    def list(self, request):
+        object_list = self.filter_queryset(self.get_queryset())
+        serializer = self.get_serializer(object_list, many=True)
+        return Response(serializer.data)
+
+############################################################################################
+
+class VpmaSerializer(PlusModelSerializer):
+        id = ReadOnlyField()
+        humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
+
+        class Meta:
+            model = VpmaService
+            fields = ('humanReadableName',
+                      'id')
+
+        def getHumanReadableName(self, obj):
+            return obj.__unicode__()
+
+class VpmaViewSet(XOSViewSet):
+    base_name = "vpma"
+    method_name = "vpma"
+    method_kind = "viewset"
+    queryset = VpmaService.get_service_objects().all()
+    serializer_class = VpmaSerializer
+
+    @classmethod
+    def get_urlpatterns(self, api_path="^"):
+        patterns = super(VpmaViewSet, self).get_urlpatterns(api_path=api_path)
+        return patterns
+
+    def list(self, request):
+        object_list = self.filter_queryset(self.get_queryset())
+        serializer = self.get_serializer(object_list, many=True)
+        return Response(serializer.data)
+
+class Qt600Serializer(PlusModelSerializer):
+        id = ReadOnlyField()
+        humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
+
+        class Meta:
+            model = Qt600Service
+            fields = ('humanReadableName',
+                      'id')
+
+        def getHumanReadableName(self, obj):
+            return obj.__unicode__()
+
+class Qt600ViewSet(XOSViewSet):
+    base_name = "qt600"
+    method_name = "qt600"
+    method_kind = "viewset"
+    queryset = Qt600Service.get_service_objects().all()
+    serializer_class = Qt600Serializer
+
+    @classmethod
+    def get_urlpatterns(self, api_path="^"):
+        patterns = super(Qt600ViewSet, self).get_urlpatterns(api_path=api_path)
+        return patterns
+
+    def list(self, request):
+        object_list = self.filter_queryset(self.get_queryset())
+        serializer = self.get_serializer(object_list, many=True)
+        return Response(serializer.data)
diff --git a/xos/api/tenant/activetesttenant.py b/xos/api/tenant/activetesttenant.py
new file mode 100644
index 0000000..3da66dd
--- /dev/null
+++ b/xos/api/tenant/activetesttenant.py
@@ -0,0 +1,201 @@
+from rest_framework.decorators import api_view
+from rest_framework.response import Response
+from rest_framework.reverse import reverse
+from rest_framework import serializers
+from rest_framework import generics
+from rest_framework import status
+from core.models import *
+from django.forms import widgets
+from xos.apibase import XOSListCreateAPIView, XOSRetrieveUpdateDestroyAPIView, XOSPermissionDenied
+from api.xosapi_helpers import PlusModelSerializer, XOSViewSet, ReadOnlyField
+
+from services.activetest.models import ActiveTestTenant, ActiveTestService, VpmaService, VpmaTenant, Qt600Service, Qt600Tenant
+
+def get_default_activetest_service():
+    activetest_services = ActiveTestService.get_service_objects().all()
+    if activetest_services:
+        return activetest_services[0]
+    return None
+
+class ActiveTestTenantSerializer(PlusModelSerializer):
+        id = ReadOnlyField()
+        provider_service = serializers.PrimaryKeyRelatedField(queryset=ActiveTestService.get_service_objects().all(), default=get_default_activetest_service)
+        backend_status = ReadOnlyField()
+
+        humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
+
+        class Meta:
+            model = ActiveTestTenant
+            fields = ('humanReadableName', 'id', 'provider_service', 'backend_status')
+
+        def getHumanReadableName(self, obj):
+            return obj.__unicode__()
+
+class ActiveTestTenantViewSet(XOSViewSet):
+    base_name = "activetesttenant"
+    method_name = "activetesttenant"
+    method_kind = "viewset"
+    queryset = ActiveTestTenant.get_tenant_objects().all()
+    serializer_class = ActiveTestTenantSerializer
+
+
+    def list(self, request):
+        queryset = self.filter_queryset(self.get_queryset())
+        serializer = self.get_serializer(queryset, many=True)
+        return Response(serializer.data)
+
+#####################################################################################################################
+
+def get_default_vpma_service():
+    vpma_services = VpmaService.get_service_objects().all()
+    if vpma_services:
+        return vpma_services[0]
+    return None
+
+class VpmaTenantSerializer(PlusModelSerializer):
+        id = ReadOnlyField()
+        provider_service = serializers.PrimaryKeyRelatedField(queryset=VpmaService.get_service_objects().all(), default=get_default_vpma_service)
+        backend_status = ReadOnlyField()
+        is_reflector = serializers.BooleanField(required=False)
+        is_initiator = serializers.BooleanField(required=False)
+        reflector = serializers.CharField(required=False)
+
+        humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
+
+        class Meta:
+            model = VpmaTenant
+            fields = ('humanReadableName', 'id', 'provider_service', 'is_reflector', 'is_initiator', 'reflector', 'backend_status')
+
+        def getHumanReadableName(self, obj):
+            return obj.__unicode__()
+
+class VpmaTenantViewSet(XOSViewSet):
+    base_name = "vpmatenant"
+    method_name = "vpmatenant"
+    method_kind = "viewset"
+    queryset = VpmaTenant.get_tenant_objects().all()
+    serializer_class = VpmaTenantSerializer
+
+    @classmethod
+    def get_urlpatterns(self, api_path="^"):
+        patterns = super(VpmaTenantViewSet, self).get_urlpatterns(api_path=api_path)
+
+        # example to demonstrate adding a custom endpoint
+        patterns.append( self.detail_url("is_initiator/$", {"get": "get_is_initiator", "put": "set_is_initiator"}, "is_initiator") )
+        patterns.append( self.detail_url("is_reflector/$", {"get": "get_is_reflector", "put": "set_is_reflector"}, "is_reflector") )
+        patterns.append( self.detail_url("reflector/$", {"get": "get_reflector", "put": "set_reflector"}, "reflector") )
+
+        return patterns
+
+    def list(self, request):
+        queryset = self.filter_queryset(self.get_queryset())
+        serializer = self.get_serializer(queryset, many=True)
+        return Response(serializer.data)
+
+    def get_is_initiator(self, request, pk=None):
+        vpma_tenant = self.get_object()
+        return Response({"is_initiator": vpma_tenant.is_initiator})
+
+    def set_is_initiator(self, request, pk=None):
+        vpma_tenant = self.get_object()
+        vpma_tenant.is_initiator = request.data["is_initiator"]
+        vpma_tenant.save()
+        return Response({"is_initiator": vpma_tenant.is_initiator})
+
+    def get_is_reflector(self, request, pk=None):
+        vpma_tenant = self.get_object()
+        return Response({"is_reflector": vpma_tenant.is_reflector})
+
+    def set_is_reflector(self, request, pk=None):
+        vpma_tenant = self.get_object()
+        vpma_tenant.is_reflector = request.data["is_reflector"]
+        vpma_tenant.save()
+        return Response({"is_reflector": vpma_tenant.is_reflector})
+
+    def get_reflector(self, request, pk=None):
+        vpma_tenant = self.get_object()
+        return Response({"reflector": vpma_tenant.reflector})
+
+    def set_reflector(self, request, pk=None):
+        vpma_tenant = self.get_object()
+        vpma_tenant.reflector = request.data["reflector"]
+        vpma_tenant.save()
+        return Response({"reflector": vpma_tenant.reflector})
+
+#####################################################################################################################
+
+def get_default_qt600_service():
+    qt600_services = Qt600Service.get_service_objects().all()
+    if qt600_services:
+        return qt600_services[0]
+    return None
+
+class Qt600TenantSerializer(PlusModelSerializer):
+        id = ReadOnlyField()
+        provider_service = serializers.PrimaryKeyRelatedField(queryset=Qt600Service.get_service_objects().all(), default=get_default_qt600_service)
+        backend_status = ReadOnlyField()
+        is_reflector = serializers.BooleanField(required=False)
+        is_initiator = serializers.BooleanField(required=False)
+        reflector = serializers.CharField(required=False)
+
+        humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
+
+        class Meta:
+            model = Qt600Tenant
+            fields = ('humanReadableName', 'id', 'provider_service', 'is_reflector', 'is_initiator', 'reflector', 'backend_status')
+
+        def getHumanReadableName(self, obj):
+            return obj.__unicode__()
+
+class Qt600TenantViewSet(XOSViewSet):
+    base_name = "qt600tenant"
+    method_name = "qt600tenant"
+    method_kind = "viewset"
+    queryset = Qt600Tenant.get_tenant_objects().all()
+    serializer_class = Qt600TenantSerializer
+
+    @classmethod
+    def get_urlpatterns(self, api_path="^"):
+        patterns = super(Qt600TenantViewSet, self).get_urlpatterns(api_path=api_path)
+
+        # example to demonstrate adding a custom endpoint
+        patterns.append( self.detail_url("is_initiator/$", {"get": "get_is_initiator", "put": "set_is_initiator"}, "is_initiator") )
+        patterns.append( self.detail_url("is_reflector/$", {"get": "get_is_reflector", "put": "set_is_reflector"}, "is_reflector") )
+        patterns.append( self.detail_url("reflector/$", {"get": "get_reflector", "put": "set_reflector"}, "reflector") )
+
+        return patterns
+
+    def list(self, request):
+        queryset = self.filter_queryset(self.get_queryset())
+        serializer = self.get_serializer(queryset, many=True)
+        return Response(serializer.data)
+
+    def get_is_initiator(self, request, pk=None):
+        qt600_tenant = self.get_object()
+        return Response({"is_initiator": qt600_tenant.is_initiator})
+
+    def set_is_initiator(self, request, pk=None):
+        qt600_tenant = self.get_object()
+        qt600_tenant.is_initiator = request.data["is_initiator"]
+        qt600_tenant.save()
+        return Response({"is_initiator": qt600_tenant.is_initiator})
+
+    def get_is_reflector(self, request, pk=None):
+        qt600_tenant = self.get_object()
+        return Response({"is_reflector": qt600_tenant.is_reflector})
+
+    def set_is_reflector(self, request, pk=None):
+        qt600_tenant = self.get_object()
+        qt600_tenant.is_reflector = request.data["is_reflector"]
+        qt600_tenant.save()
+        return Response({"is_reflector": qt600_tenant.is_reflector})
+
+    def get_reflector(self, request, pk=None):
+        qt600_tenant = self.get_object()
+        return Response({"reflector": qt600_tenant.reflector})
+
+    def set_reflector(self, request, pk=None):
+        qt600_tenant = self.get_object()
+        qt600_tenant.reflector = request.data["reflector"]
+        qt600_tenant.save()
+        return Response({"reflector": qt600_tenant.reflector})
diff --git a/xos/macros.m4 b/xos/macros.m4
new file mode 100644
index 0000000..1f48f10
--- /dev/null
+++ b/xos/macros.m4
@@ -0,0 +1,84 @@
+# Note: Tosca derived_from isn't working the way I think it should, it's not
+#    inheriting from the parent template. Until we get that figured out, use
+#    m4 macros do our inheritance
+
+define(xos_base_props,
+            no-delete:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to delete this object
+            no-create:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to create this object
+            no-update:
+                type: boolean
+                default: false
+                description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object)
+# Service
+define(xos_base_service_caps,
+            scalable:
+                type: tosca.capabilities.Scalable
+            service:
+                type: tosca.capabilities.xos.Service)
+define(xos_base_service_props,
+            kind:
+                type: string
+                default: generic
+                description: Type of service.
+            view_url:
+                type: string
+                required: false
+                description: URL to follow when icon is clicked in the Service Directory.
+            icon_url:
+                type: string
+                required: false
+                description: ICON to display in the Service Directory.
+            enabled:
+                type: boolean
+                default: true
+            published:
+                type: boolean
+                default: true
+                description: If True then display this Service in the Service Directory.
+            public_key:
+                type: string
+                required: false
+                description: Public key to install into Instances to allows Services to SSH into them.
+            private_key_fn:
+                type: string
+                required: false
+                description: Location of private key file
+            versionNumber:
+                type: string
+                required: false
+                description: Version number of Service.)
+# Subscriber
+define(xos_base_subscriber_caps,
+            subscriber:
+                type: tosca.capabilities.xos.Subscriber)
+define(xos_base_subscriber_props,
+            kind:
+                type: string
+                default: generic
+                description: Kind of subscriber
+            service_specific_id:
+                type: string
+                required: false
+                description: Service specific ID opaque to XOS but meaningful to service)
+define(xos_base_tenant_props,
+            kind:
+                type: string
+                default: generic
+                description: Kind of tenant
+            service_specific_id:
+                type: string
+                required: false
+                description: Service specific ID opaque to XOS but meaningful to service)
+
+# end m4 macros
+
diff --git a/xos/make_synchronizer_manifest.sh b/xos/make_synchronizer_manifest.sh
new file mode 100644
index 0000000..4058982
--- /dev/null
+++ b/xos/make_synchronizer_manifest.sh
@@ -0,0 +1,2 @@
+#! /bin/bash
+find synchronizer -type f | cut -b 14- > synchronizer/manifest 
diff --git a/xos/models.py b/xos/models.py
new file mode 100644
index 0000000..664762b
--- /dev/null
+++ b/xos/models.py
@@ -0,0 +1,335 @@
+# models.py -  ExampleService Models
+
+from core.models import Service, TenantWithContainer
+from django.db import models, transaction
+
+ACTIVETEST_KIND = 'ActiveTest'
+ACTIVETEST_SERVICE_NAME = 'activetest'
+ACTIVETEST_SERVICE_NAME_VERBOSE = 'ACTIVETEST Service'
+ACTIVETEST_SERVICE_NAME_VERBOSE_PLURAL = 'ACTIVETEST Services'
+ACTIVETEST_TENANT_NAME_VERBOSE = 'ACTIVETEST Tenant'
+ACTIVETEST_TENANT_NAME_VERBOSE_PLURAL = 'ACTIVETEST Tenants'
+
+QT600_SERVICE_NAME = 'qt600'
+QT600_SERVICE_NAME_VERBOSE = 'QT600 Service'
+QT600_SERVICE_NAME_VERBOSE_PLURAL = 'QT600 Services'
+QT600_TENANT_NAME_VERBOSE = 'QT600 Tenant'
+QT600_TENANT_NAME_VERBOSE_PLURAL = 'QT600 Tenants'
+
+VPMA_SERVICE_NAME = 'vpma'
+VPMA_SERVICE_NAME_VERBOSE = 'VPMA Service'
+VPMA_SERVICE_NAME_VERBOSE_PLURAL = 'VPMA Services'
+VPMA_TENANT_NAME_VERBOSE = 'VPMA Tenant'
+VPMA_TENANT_NAME_VERBOSE_PLURAL = 'VPMA Tenants'
+
+VTA_SERVICE_NAME = 'vta'
+VTA_SERVICE_NAME_VERBOSE = 'VTA Service'
+VTA_SERVICE_NAME_VERBOSE_PLURAL = 'VTA Services'
+VTA_TENANT_NAME_VERBOSE = 'VTA Tenant'
+VTA_TENANT_NAME_VERBOSE_PLURAL = 'VTA Tenants'
+
+class ActiveTestService(Service):
+
+    KIND = ACTIVETEST_KIND
+
+    class Meta:
+        app_label = ACTIVETEST_SERVICE_NAME
+        verbose_name = ACTIVETEST_SERVICE_NAME_VERBOSE
+        proxy = True
+
+class Qt600Service(Service):
+
+    KIND = ACTIVETEST_KIND
+    class Meta:
+        app_label = QT600_SERVICE_NAME
+        verbose_name = QT600_SERVICE_NAME_VERBOSE
+        proxy = True
+
+class VpmaService(Service):
+
+    KIND = ACTIVETEST_KIND
+    class Meta:
+        app_label = VPMA_SERVICE_NAME
+        verbose_name = VPMA_SERVICE_NAME_VERBOSE
+        proxy = True
+
+class VtaService(Service):
+
+    KIND = ACTIVETEST_KIND
+    class Meta:
+        app_label = VTA_SERVICE_NAME
+        verbose_name = VTA_SERVICE_NAME_VERBOSE
+        proxy = True
+
+class ActiveTestTenant(TenantWithContainer):
+
+    KIND = ACTIVETEST_KIND
+
+    class Meta:
+        verbose_name = ACTIVETEST_TENANT_NAME_VERBOSE
+
+    def __init__(self, *args, **kwargs):
+        activetestservice = ActiveTestService.get_service_objects().all()
+        if activetestservice:
+            self._meta.get_field('provider_service').default = activetestservice[0].id
+        super(ActiveTestTenant, self).__init__(*args, **kwargs)
+
+    def save(self, *args, **kwargs):
+        super(ActiveTestTenant, self).save(*args, **kwargs)
+        model_policy_activetesttenant(self.pk)
+
+    def delete(self, *args, **kwargs):
+        self.cleanup_container()
+        super(ActiveTestTenant, self).delete(*args, **kwargs)
+
+    @property
+    def public_ip(self):
+        for port in self.instance.ports.all():
+            if "public" in port.network.name.lower():
+                return port.ip
+        return None
+
+def model_policy_activetesttenant(pk):
+    with transaction.atomic():
+        tenant = ActiveTestTenant.objects.select_for_update().filter(pk=pk)
+        if not tenant:
+            return
+        tenant = tenant[0]
+        tenant.manage_container()
+
+class Qt600Tenant(TenantWithContainer):
+
+    KIND = ACTIVETEST_KIND
+    sync_attributes = ["is_reflector","is_initiator","reflector_ip","reflector_public_ip","private_ip","public_ip"]
+    
+    is_reflector = models.BooleanField(default=False,help_text="True if this tenant should be a TWAMP reflector")
+    is_initiator = models.BooleanField(default=False,help_text="True if this tenant should be a TWAMP initiator")
+    reflector = models.CharField(max_length=254,default="", blank=True, help_text="The reflector node to use for the test")
+
+    class Meta:
+        verbose_name = QT600_TENANT_NAME_VERBOSE
+
+    def __init__(self, *args, **kwargs):
+        service = Qt600Service.get_service_objects().all()
+        if service:
+            self._meta.get_field('provider_service').default = service[0].id
+        super(Qt600Tenant, self).__init__(*args, **kwargs)
+
+    def save(self, *args, **kwargs):
+        super(Qt600Tenant, self).save(*args, **kwargs)
+        model_policy_qt600tenant(self.pk)
+
+    def delete(self, *args, **kwargs):
+        self.cleanup_container()
+        super(Qt600TenantTenant, self).delete(*args, **kwargs)
+
+    @property
+    def private_ip(self):
+        for port in self.instance.ports.all():
+            if "test_network" in port.network.name.lower():
+                return port.ip
+        return None
+
+    @property
+    def public_ip(self):
+        for port in self.instance.ports.all():
+            if "public" in port.network.name.lower():
+                return port.ip
+        return None
+
+    def get_reflector_vm(self):
+        service = [s for s in ActiveTestService.get_service_objects().all() if "qt600" in s.name.lower()]
+        if service and self.reflector:
+            slices = service[0].slices.all()
+            for slice in slices:
+                instance = [i for i in slice.instances.all() if self.reflector in i.instance_name.lower()]
+                if len(instance) > 0:
+                    return instance[0]
+        return None
+        
+    @property
+    def reflector_ip(self):
+        instance = self.get_reflector_vm()
+        if instance:
+            for port in instance.ports.all():
+                if "test_network" in port.network.name.lower():
+                    return port.ip
+        return None
+
+    @property
+    def reflector_public_ip(self):
+        instance = self.get_reflector_vm()
+        if instance:
+            for port in instance.ports.all():
+                if "public" in port.network.name.lower():
+                    return port.ip
+        return None
+
+    @property
+    def controller_ip(self):
+        service = [s for s in ActiveTestService.get_service_objects().all() if "activetest" in s.name.lower()]
+        if service:
+            slices = service[0].slices.all()
+            for slice in slices:
+                for instance in slice.instances.all():
+                    for port in instance.ports.all():
+                        if "public" in port.network.name.lower():
+                            return port.ip
+        return None
+
+
+def model_policy_qt600tenant(pk):
+    with transaction.atomic():
+        tenant = Qt600Tenant.objects.select_for_update().filter(pk=pk)
+        if not tenant:
+            return
+        tenant = tenant[0]
+        tenant.manage_container()
+
+class VpmaTenant(TenantWithContainer):
+
+    KIND = ACTIVETEST_KIND
+    sync_attributes = ["is_reflector","is_initiator","reflector_ip","reflector_public_ip","private_ip","public_ip"]
+    
+    is_reflector = models.BooleanField(default=False,help_text="True if this tenant should be a TWAMP reflector")
+    is_initiator = models.BooleanField(default=False,help_text="True if this tenant should be a TWAMP initiator")
+    reflector = models.CharField(max_length=254,default="", blank=True, help_text="The reflector node to use for the test")
+
+    class Meta:
+        verbose_name = VPMA_TENANT_NAME_VERBOSE
+
+    def __init__(self, *args, **kwargs):
+        service = VpmaService.get_service_objects().all()
+        if service:
+            self._meta.get_field('provider_service').default = service[0].id
+        super(VpmaTenant, self).__init__(*args, **kwargs)
+
+    def save(self, *args, **kwargs):
+        super(VpmaTenant, self).save(*args, **kwargs)
+        model_policy_vpmatenant(self.pk)
+
+    def delete(self, *args, **kwargs):
+        self.cleanup_container()
+        super(VpmaTenantTenant, self).delete(*args, **kwargs)
+
+    @property
+    def private_ip(self):
+        for port in self.instance.ports.all():
+            if "test_network" in port.network.name.lower():
+                return port.ip
+        return None
+
+    @property
+    def public_ip(self):
+        for port in self.instance.ports.all():
+            if "public" in port.network.name.lower():
+                return port.ip
+        return None
+
+    def get_reflector_vm(self):
+        service = [s for s in ActiveTestService.get_service_objects().all() if "vpma" in s.name.lower()]
+        if service and self.reflector:
+            slices = service[0].slices.all()
+            for slice in slices:
+                instance = [i for i in slice.instances.all() if self.reflector in i.instance_name.lower()]
+                if len(instance) > 0:
+                    return instance[0]
+        return None
+        
+    @property
+    def reflector_ip(self):
+        instance = self.get_reflector_vm()
+        if instance:
+            for port in instance.ports.all():
+                if "test_network" in port.network.name.lower():
+                    return port.ip
+        return None
+
+    @property
+    def reflector_public_ip(self):
+        instance = self.get_reflector_vm()
+        if instance:
+            for port in instance.ports.all():
+                if "public" in port.network.name.lower():
+                    return port.ip
+        return None
+
+    @property
+    def controller_ip(self):
+        service = [s for s in ActiveTestService.get_service_objects().all() if "activetest" in s.name.lower()]
+        if service:
+            slices = service[0].slices.all()
+            for slice in slices:
+                for instance in slice.instances.all():
+                    for port in instance.ports.all():
+                        if "public" in port.network.name.lower():
+                            return port.ip
+        return None
+
+
+def model_policy_vpmatenant(pk):
+    with transaction.atomic():
+        tenant = VpmaTenant.objects.select_for_update().filter(pk=pk)
+        if not tenant:
+            return
+        tenant = tenant[0]
+        tenant.manage_container()
+
+class VtaTenant(TenantWithContainer):
+
+    KIND = ACTIVETEST_KIND
+    sync_attributes = ["private_ip"]
+
+    class Meta:
+        verbose_name = VTA_TENANT_NAME_VERBOSE
+
+    def __init__(self, *args, **kwargs):
+        service = VtaService.get_service_objects().all()
+        if service:
+            self._meta.get_field('provider_service').default = service[0].id
+        super(VtaTenant, self).__init__(*args, **kwargs)
+
+    def save(self, *args, **kwargs):
+        super(VtaTenant, self).save(*args, **kwargs)
+        model_policy_vtatenant(self.pk)
+
+    def delete(self, *args, **kwargs):
+        self.cleanup_container()
+        super(VtaTenantTenant, self).delete(*args, **kwargs)
+
+    @property
+    def private_ip(self):
+        for port in self.instance.ports.all():
+            if "test_network" in port.network.name.lower():
+                return port.ip
+        return None
+
+    @property
+    def public_ip(self):
+        for port in self.instance.ports.all():
+            if "public" in port.network.name.lower():
+                return port.ip
+        return None
+
+    @property
+    def controller_ip(self):
+        service = [s for s in ActiveTestService.get_service_objects().all() if "activetest" in s.name.lower()]
+        if service:
+            slices = service[0].slices.all()
+            for slice in slices:
+                for instance in slice.instances.all():
+                    for port in instance.ports.all():
+                        if "public" in port.network.name.lower():
+                            return port.ip
+        return None
+
+def model_policy_vtatenant(pk):
+    with transaction.atomic():
+        tenant = VtaTenant.objects.select_for_update().filter(pk=pk)
+        if not tenant:
+            return
+        tenant = tenant[0]
+        tenant.manage_container()
+
+
+
diff --git a/xos/synchronizer/activetest-synchronizer.py b/xos/synchronizer/activetest-synchronizer.py
new file mode 100644
index 0000000..90d2c98
--- /dev/null
+++ b/xos/synchronizer/activetest-synchronizer.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+
+# Runs the standard XOS synchronizer
+
+import importlib
+import os
+import sys
+
+synchronizer_path = os.path.join(os.path.dirname(
+    os.path.realpath(__file__)), "../../synchronizers/base")
+sys.path.append(synchronizer_path)
+mod = importlib.import_module("xos-synchronizer")
+mod.main()
+
diff --git a/xos/synchronizer/activetest-synchronizer.yaml b/xos/synchronizer/activetest-synchronizer.yaml
new file mode 100644
index 0000000..f2ffa56
--- /dev/null
+++ b/xos/synchronizer/activetest-synchronizer.yaml
@@ -0,0 +1,14 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: This recipe provides additional configuration for the onboarded services.
+
+imports:
+   - custom_types/xos.yaml
+
+topology_template:
+  node_templates:
+    servicecontroller#activetest:
+      type: tosca.nodes.ServiceController
+      properties:
+        no-create: true
+        synchronizer_config: /root/setup/files/activetest_config
diff --git a/xos/synchronizer/activetest_config b/xos/synchronizer/activetest_config
new file mode 100644
index 0000000..2051d04
--- /dev/null
+++ b/xos/synchronizer/activetest_config
@@ -0,0 +1,29 @@
+# Required by XOS
+[db]
+name=xos
+user=postgres
+password=password
+host=localhost
+port=5432
+
+# Required by XOS
+[api]
+nova_enabled=True
+
+# Sets options for the synchronizer
+[observer]
+name=activetest
+dependency_graph=/opt/xos/synchronizers/activetest/model-deps
+steps_dir=/opt/xos/synchronizers/activetest/steps
+sys_dir=/opt/xos/synchronizers/activetest/sys
+logfile=/var/log/xos_backend.log
+pretend=False
+backoff_disabled=True
+save_ansible_output=True
+proxy_ssh=True
+proxy_ssh_key=/root/setup/node_key
+proxy_ssh_user=root
+
+[networking]
+use_vtn=True
+
diff --git a/xos/synchronizer/manifest b/xos/synchronizer/manifest
new file mode 100644
index 0000000..5d6d01c
--- /dev/null
+++ b/xos/synchronizer/manifest
@@ -0,0 +1,19 @@
+manifest
+steps/roles/setup_controller/tasks/main.yml
+steps/roles/setup_qt600/tasks/main.yml
+steps/roles/setup_vpma/tasks/main.yml
+steps/roles/setup_vta/tasks/main.yml
+steps/roles/setup_ma/tasks/main.yml
+steps/roles/setup_ma/files/fusion_controller.py
+steps/sync_activetesttenant.py
+steps/sync_qt600tenant.py
+steps/sync_vpmatenant.py
+steps/sync_vtatenant.py
+steps/activetesttenant_playbook.yaml
+steps/qt600tenant_playbook.yaml
+steps/vpmatenant_playbook.yaml
+steps/vtatenant_playbook.yaml
+model-deps
+activetest_config
+activetest-synchronizer.py
+run.sh
diff --git a/xos/synchronizer/model-deps b/xos/synchronizer/model-deps
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/xos/synchronizer/model-deps
@@ -0,0 +1 @@
+{}
diff --git a/xos/synchronizer/run.sh b/xos/synchronizer/run.sh
new file mode 100755
index 0000000..2ec126d
--- /dev/null
+++ b/xos/synchronizer/run.sh
@@ -0,0 +1,2 @@
+export XOS_DIR=/opt/xos
+python activetest-synchronizer.py  -C $XOS_DIR/synchronizers/activetest/activetest_config
diff --git a/xos/synchronizer/steps/activetesttenant_playbook.yaml b/xos/synchronizer/steps/activetesttenant_playbook.yaml
new file mode 100644
index 0000000..0a7eaba
--- /dev/null
+++ b/xos/synchronizer/steps/activetesttenant_playbook.yaml
@@ -0,0 +1,13 @@
+---
+# activetesttenant_playbook - sets up the controller
+
+- hosts: "{{ instance_name }}"
+  connection: ssh
+  user: root
+  sudo: no
+  gather_facts: no
+  vars:
+    - public_ip: "{{ public_ip }}"
+
+  roles:
+    - setup_controller
diff --git a/xos/synchronizer/steps/qt600tenant_playbook.yaml b/xos/synchronizer/steps/qt600tenant_playbook.yaml
new file mode 100644
index 0000000..8218a36
--- /dev/null
+++ b/xos/synchronizer/steps/qt600tenant_playbook.yaml
@@ -0,0 +1,20 @@
+---
+# activetesttenant_playbook - sets up the controller
+
+- hosts: "{{ instance_name }}"
+  connection: ssh
+  user: root
+  sudo: no
+  gather_facts: no
+  vars:
+    - private_ip: "{{ private_ip }}"
+    - public_ip: "{{ public_ip }}"
+    - controller_ip: "{{ controller_ip }}"
+    - reflector_ip: "{{ reflector_ip }}"
+    - reflector_public_ip: "{{ reflector_public_ip }}"
+    - is_initiator: {{ is_initiator }}
+    - is_reflector: {{ is_reflector }}
+
+  roles:
+    - setup_ma
+    - setup_qt600
diff --git a/xos/synchronizer/steps/roles/setup_controller/tasks/main.yml b/xos/synchronizer/steps/roles/setup_controller/tasks/main.yml
new file mode 100644
index 0000000..86d1c96
--- /dev/null
+++ b/xos/synchronizer/steps/roles/setup_controller/tasks/main.yml
@@ -0,0 +1,29 @@
+---
+
+- name: check if need to set up controller
+  command: grep "localhost.fusion-controller" /etc/hosts
+  register: result
+  ignore_errors: True
+
+- name: setup /etc/hosts - delete default entry
+  shell: sed -i "/localhost.fusion-controller/d" /etc/hosts
+  when: result.rc == 0
+
+- name: setup /etc/hostname - set hostname
+  shell: sed -i "/localhost.fusion-controller/d" /etc/hostname
+  when: result.rc == 0
+
+- name: setup /etc/hosts - delete default entry
+  shell: echo "{{ public_ip }} $(hostname)" >> /etc/hosts
+  when: result.rc == 0
+
+- name: set controller ip in ui config
+  shell: |
+    python -c "import json as j;f='/ada/NTCtestui/config.json';d=j.load(open(f));d['fusion-controller']['hostname']='{{ public_ip }}';d['fusion-collector']['hostname']='{{ public_ip }}';j.dump(d,open(f,'w'))"
+  when: result.rc == 0
+
+- name: start fusion services
+  shell: /etc/init.d/npiu_adatdce restart
+  when: result.rc == 0
+
+   
diff --git a/xos/synchronizer/steps/roles/setup_ma/files/fusion_controller.py b/xos/synchronizer/steps/roles/setup_ma/files/fusion_controller.py
new file mode 100644
index 0000000..d1a8531
--- /dev/null
+++ b/xos/synchronizer/steps/roles/setup_ma/files/fusion_controller.py
@@ -0,0 +1,103 @@
+#!/usr/bin/python
+import requests, copy, json, datetime, os
+
+REFLECTOR_ID_FILE="/root/reflector_id"
+INITIATOR_ID_FILE="/root/initiator_id"
+
+##############################################################################################################################################################3
+
+start_reflector_template={u'agent': {u'primary': {u'config': u'primaryConfig',
+                                                  u'id': u'vpma1',
+                                                  u'type': u'inventory'}},
+                          u'config': [{u'primaryConfig': {u'ietf-lmap-control:lmap': {u'schedules': {u'schedule': [{u'action': [{u'name': u'TWAMP-REFLECTOR-PM-PROBE0-action',
+                                                                                                                                 u'option': [{u'id': u'source-ip',
+                                                                                                                                              u'value': u'10.0.0.0'},
+                                                                                                                                             {u'id': u'subnet',
+                                                                                                                                              u'value': u'255.255.255.0'},
+                                                                                                                                             {u'id': u'gateway',
+                                                                                                                                              u'value': u'0.0.0.0'},
+                                                                                                                                             {u'id': u'twamp',
+                                                                                                                                              u'value': u'{"ietf-twamp:twamp":{"twamp-server":{"server-admin-state":true,"server-tcp-port":"862","dscp":0,"mode":"bits.unauthenticated"}}}'}],
+                                                                                                                                 u'task': u'twamp-reflector'}],
+                                                                                                                    u'name': u'TWAMP-REFLECTOR-PM-PROBE0',
+                                                                                                                    u'start': u'immediate'}]}}}}],
+                          u'test': {}}
+
+##############################################################################################################################################################3
+
+start_initiator_template=u'{"agent":{"primary":{"type":"inventory","id":"%(initiator_name)s","config":"primaryConfig"}},"test":{"extended-config":{"test":{"nameOnProbe":"twamp-initiator","selected":true,"testType":"twamp","testTypeLabel":"TWAMP Initiator"},"testPoints":[{"ip":"%(initiator_ip)s","model":"vPMA","name":"%(initiator_name)s","port":"80","selected":true,"tag":"Test Point A","type":"inventory","vendor":"viavi","version":"1.0"},{"model":"vPMA","name":"Test Point B","selected":false,"tag":"Test Point B","type":"inventory","vendor":"viavi","version":"1.0"}],"pluginConfig":{"setup":{"version":"2","schedMode":"immediate","periodicDuration":"00:05:00","periodicInterval":"00:15:00","pmInterval":"1","enableRandomStart":"false","randomOffset":"00:10:00","enableRt":"true","rtInterval":"%(interval)s","srcIPAddress":"%(initiator_src_ip)s","srcNetmask":"255.255.255.0","gatewayIPAddress":"192.168.2.1","srcStartingPort":"50000","configToServicesMap":{},"serviceParamToConfigMap":{}},"connections":{"version":"2","connections":[{"version":"2","name":"My Session","enabled":"true","source":null,"destination":{"version":"2","ipv4DestMgmtAddr":"%(reflector_src_ip)s","dstMgmtPort":"862"},"network":null,"numFlows":1,"flows":[{"version":"1","flowName":"Flow 1","flowInUse":"true","flowIpv4DiffServVal":"0","flowPad":"483","flowUdpPort":"50000","flowTxInterval":"10","flowReflWaitTimeout":"2"}]}]}},"testInfo":{"comments":"","name":"Lorna-%(test_name)s"}},"test-list-data":{"customer":{}}},"config":[{"primaryConfig":{"ietf-lmap-control:lmap":{"schedules":{"schedule":[{"name":"Lorna-%(test_name)s","start":"immediate","action":[{"name":"Lorna-%(test_name)s-action","task":"twamp-initiator","option":[{"id":"subnet","value":"255.255.255.0"},{"id":"gateway","value":"0.0.0.0"},{"id":"twamp","value":"{\\"ietf-twamp:twamp\\":{\\"twamp-client\\":{\\"client-admin-state\\":true,\\"mode-preference-chain\\":[{\\"priority\\":1,\\"mode\\":\\"bits.unauthenticated\\"}],\\"twamp-client-ctrl-connection\\":[{\\"ctrl-connection-name\\":\\"My Session\\",\\"client-ip\\":\\"%(initiator_src_ip)s\\",\\"server-ip\\":\\"%(reflector_src_ip)s\\",\\"server-tcp-port\\":862,\\"dscp\\":0,\\"twamp-session-request\\":[{\\"test-session-name\\":\\"Flow 1\\",\\"sender-ip\\":\\"%(initiator_src_ip)s\\",\\"sender-udp-port\\":\\"50000\\",\\"reflector-ip\\":\\"%(reflector_src_ip)s\\",\\"reflector-udp-port\\":\\"50000\\",\\"timeout\\":\\"2\\",\\"padding-length\\":\\"483\\",\\"dscp\\":\\"0\\"}]}],\\"twamp-session-sender\\":{\\"session-sender-admin-state\\":true,\\"twamp-sender-test-session\\":[{\\"test-session-name\\":\\"Flow 1\\",\\"fill-mode\\":\\"fill-mode.zero\\",\\"periodic-interval\\":\\"10\\",\\"periodic-interval-units\\":\\"milliseconds\\"}]}}}}"}],"destination":["Lorna-%(test_name)s-results-periodic-pm","Lorna-%(test_name)s-results-periodic-rt"]}]},{"name":"Lorna-%(test_name)s-results-periodic-pm","start":"Lorna-%(test_name)s-results-periodic-pm-event","action":[{"name":"Lorna-%(test_name)s-results-periodic-pm-action","task":"results","option":[{"id":"result-type","value":"pm"},{"id":"channel","value":"http://%(controller_ip)s:26088/restconf/operations/ietf-lmap-report:report"}]}]},{"name":"Lorna-%(test_name)s-results-periodic-rt","start":"Lorna-%(test_name)s-results-periodic-rt-event","action":[{"name":"Lorna-%(test_name)s-results-periodic-rt-action","task":"results","option":[{"id":"result-type","value":"rt"},{"id":"channel","value":"http://%(controller_ip)s:26088/restconf/operations/ietf-lmap-report:report"}]}]}]},"events":{"event":[{"name":"Lorna-%(test_name)s-results-periodic-pm-event","periodic":{"interval":60}},{"name":"Lorna-%(test_name)s-results-periodic-rt-event","periodic":{"interval":5}}]}}}}]}'
+
+class FusionController:
+    def __init__(self,inventory_ip):
+        self.ip = inventory_ip
+        self.i_url="http://%s:30100"%self.ip # inventory url
+        self.c_url="http://%s:8080"%self.ip  # controller url
+        self.h = {"Content-Type":"application/json"}
+    def get_ma(self,ma_ip):
+        inventory = requests.post("%s/vibe/inventory/v2/queryDevices"%self.i_url, headers=self.h).json()
+        return [ma for ma in inventory if ma_ip in ma['connections'][0]['uri']][0]
+        
+    def start_reflector(self, reflector_ip, reflector_source_ip):
+        ma = self.get_ma(reflector_ip)
+        data = copy.deepcopy(start_reflector_template)
+        data['agent']['primary']['id']=ma['name']
+        config_options=data['config'][0]['primaryConfig']['ietf-lmap-control:lmap']['schedules']['schedule'][0]['action'][0]['option']
+        config_options[0]['value']=reflector_source_ip
+        r=requests.post("%s/sbi/restconf/data/ietf-lmap-control:lmap"%self.c_url,headers=self.h,data=json.dumps(data))
+        open(REFLECTOR_ID_FILE,"w").write(r.json()["id"])
+
+    def start_initiator(self, initiator_ip, initiator_source_ip, reflector_ip, reflector_source_ip, interval="1"):
+        reflector = self.get_ma(reflector_ip)
+        initiator = self.get_ma(initiator_ip)
+        
+	now = datetime.datetime.now()
+	timestamp = '{}-{}-{}-{}:{}'.format(now.year, now.month, now.day, now.hour, now.minute)
+        config_options={"initiator_name":initiator["name"],"initiator_ip":initiator_ip,"initiator_src_ip":initiator_source_ip,
+                        "reflector_name":reflector["name"],"reflector_ip":reflector_ip,"reflector_src_ip":reflector_source_ip,
+                        "interval":interval,"test_name":timestamp,"controller_ip":self.ip}
+        r=requests.post("%s/sbi/restconf/data/ietf-lmap-control:lmap"%self.c_url,headers=self.h,data=start_initiator_template%config_options)
+        open(INITIATOR_ID_FILE,"w").write(r.json()["id"])
+
+    def stop_test(self, id):
+       print("%s/sbi/restconf/operations/action/lmap?scheduleid=%s"%(self.c_url,id))
+       requests.post("%s/sbi/restconf/operations/action/lmap?scheduleid=%s"%(self.c_url,id),headers=self.h,data=json.dumps({'action':'cancel'}))
+
+
+def start_reflector(options):
+    f = FusionController(options.controller_ip)
+    f.start_reflector(options.reflector_ip,options.reflector_src_ip)
+
+def start_initiator(options):
+    f = FusionController(options.controller_ip)
+    f.start_initiator(options.initiator_ip,options.initiator_src_ip,options.reflector_ip,options.reflector_src_ip,options.results_interval)
+
+def stop_test(options,id_file):
+    if os.path.exists(id_file):
+        f = FusionController(options.controller_ip)
+        f.stop_test(open(id_file).read())
+        os.remove(id_file)
+
+if __name__=="__main__":
+    import argparse
+    parser = argparse.ArgumentParser()
+    parser.add_argument('--controller-ip', help='IP of the Server', default='172.27.0.3')
+    parser.add_argument('--results-interval', help='Results Interval', default='5')
+    parser.add_argument('--reflector-ip', help='IP of the Agent to use as Reflector', default='10.0.6.4')
+    parser.add_argument('--reflector-src-ip', help='Source IP of the reflector', default='10.0.7.3')
+    parser.add_argument('--initiator-ip', help='IP of the Agent to use as initiator', default='10.0.6.5')
+    parser.add_argument('--initiator-src-ip', help='Source IP of the reflector', default='10.0.7.4')
+    parser.add_argument("--start-reflector", help="start reflector", action="store_true")
+    parser.add_argument("--start-initiator", help="start initiator", action="store_true")
+    parser.add_argument("--stop-reflector", help="stop reflector", action="store_true")
+    parser.add_argument("--stop-initiator", help="stop initiator", action="store_true")
+
+    options = parser.parse_args()
+    if options.start_reflector:
+        start_reflector(options)
+    if options.start_initiator:
+        start_initiator(options)
+    if options.stop_reflector:
+        stop_test(options,REFLECTOR_ID_FILE)
+    if options.stop_initiator:
+        stop_test(options,INITIATOR_ID_FILE)
+    
diff --git a/xos/synchronizer/steps/roles/setup_ma/tasks/main.yml b/xos/synchronizer/steps/roles/setup_ma/tasks/main.yml
new file mode 100644
index 0000000..abd98ee
--- /dev/null
+++ b/xos/synchronizer/steps/roles/setup_ma/tasks/main.yml
@@ -0,0 +1,4 @@
+---
+
+- name: copy test controller script
+  copy: src=fusion_controller.py dest=/root/fusion_controller.py mode=0755
diff --git a/xos/synchronizer/steps/roles/setup_qt600/tasks/main.yml b/xos/synchronizer/steps/roles/setup_qt600/tasks/main.yml
new file mode 100644
index 0000000..a8ef516
--- /dev/null
+++ b/xos/synchronizer/steps/roles/setup_qt600/tasks/main.yml
@@ -0,0 +1,59 @@
+---
+
+- name: check if work should be done
+  stat: path=/tmp/init_completed
+  register: result
+
+- name: get interface of private_ip
+  register: private_interface
+  shell: |
+    ip addr | awk '/^[0-9]+:/ {   sub(/:/,"",$2); iface=$2 } /^[[:space:]]*inet / {   split($2, a, "/");  print iface" : "a[1] }' | grep "{{ private_ip }}" | cut -d " " -f 1
+  when: result.stat.exists == False
+
+- name: run vnf-setup 
+  shell: vnf-setup --controller-address {{controller_ip}} --controller-port 30500 --test-interface {{ private_interface.stdout }} --enable-single-test-mode
+  when: result.stat.exists == False
+
+- name: rm dhcp cache
+  shell: rm /var/lib/dhcp/dhclient.leases
+  when: result.stat.exists == False
+
+- name: rm test interface from /etc/network/interfaces
+  shell: |
+    sed -i '/{{ private_interface.stdout }}/d' /etc/network/interfaces
+  when: result.stat.exists == False
+
+- name: reset test interface ip
+  shell: ifconfig {{ private_interface.stdout }} 0.0.0.0
+  when: result.stat.exists == False
+
+- name: stop qt services
+  shell: /etc/init.d/vqt_startup stop
+  when: result.stat.exists == False
+
+- name: start apache service
+  shell: /etc/init.d/apache2 start
+  when: result.stat.exists == False
+
+- name: start qt services
+  shell: /etc/init.d/vqt_startup start
+  when: result.stat.exists == False
+
+- name: record task completed
+  shell: echo "done" > /tmp/init_completed
+#
+# - name: run reflector
+#   command: python /root/fusion_controller.py --start-reflector --controller-ip "{{ controller_ip }}" --reflector-ip "{{ public_ip }}"  --reflector-src-ip "{{ private_ip }}"
+#   when: is_reflector
+# 
+# - name: run initiator
+#   command: python /root/fusion_controller.py --start-initiator  --controller-ip "{{ controller_ip }}" --initiator-ip "{{ public_ip }}"  --initiator-src-ip "{{ private_ip }}" --reflector-ip "{{ reflector_public_ip }}"  --reflector-src-ip "{{ reflector_ip }}" 
+#   when: is_initiator
+# 
+# - name: stop reflector
+#   command: python /root/fusion_controller.py --stop-reflector --controller-ip "{{ controller_ip }}"
+#   when: is_reflector == False
+# 
+# - name: stop initiator
+#   command: python /root/fusion_controller.py --stop-initiator  --controller-ip "{{ controller_ip }}"
+#   when: is_initiator == False
diff --git a/xos/synchronizer/steps/roles/setup_vpma/tasks/main.yml b/xos/synchronizer/steps/roles/setup_vpma/tasks/main.yml
new file mode 100644
index 0000000..f26f827
--- /dev/null
+++ b/xos/synchronizer/steps/roles/setup_vpma/tasks/main.yml
@@ -0,0 +1,51 @@
+---
+
+- name: check if work should be done
+  stat: path=/tmp/init_completed
+  register: result
+
+- name: get interface of private_ip
+  register: private_interface
+  shell: |
+    ip addr | awk '/^[0-9]+:/ {   sub(/:/,"",$2); iface=$2 } /^[[:space:]]*inet / {   split($2, a, "/");  print iface" : "a[1] }' | grep "{{ private_ip }}" | cut -d " " -f 1
+  when: result.stat.exists == False
+
+- name: run vnf-setup 
+  shell: vnf-setup --controller-address {{controller_ip}} --controller-port 30500 --test-interface {{ private_interface.stdout }} --enable-single-test-mode
+  when: result.stat.exists == False
+
+- name: rm dhcp cache
+  shell: rm /var/lib/dhcp/dhclient.leases
+  when: result.stat.exists == False
+
+- name: rm test interface from /etc/network/interfaces
+  shell: |
+    sed -i '/{{ private_interface.stdout }}/d' /etc/network/interfaces
+  when: result.stat.exists == False
+
+- name: reset test interface ip
+  shell: ifconfig {{ private_interface.stdout }} 0.0.0.0
+  when: result.stat.exists == False
+
+- name: restart qt services
+  shell: /etc/init.d/vqt_startup restart
+  when: result.stat.exists == False
+
+- name: record task completed
+  shell: echo "done" > /tmp/init_completed
+
+- name: run reflector
+  command: python /root/fusion_controller.py --start-reflector --controller-ip "{{ controller_ip }}" --reflector-ip "{{ public_ip }}"  --reflector-src-ip "{{ private_ip }}"
+  when: is_reflector
+
+- name: run initiator
+  command: python /root/fusion_controller.py --start-initiator  --controller-ip "{{ controller_ip }}" --initiator-ip "{{ public_ip }}"  --initiator-src-ip "{{ private_ip }}" --reflector-ip "{{ reflector_public_ip }}"  --reflector-src-ip "{{ reflector_ip }}" 
+  when: is_initiator
+
+- name: stop reflector
+  command: python /root/fusion_controller.py --stop-reflector --controller-ip "{{ controller_ip }}"
+  when: is_reflector == False
+
+- name: stop initiator
+  command: python /root/fusion_controller.py --stop-initiator  --controller-ip "{{ controller_ip }}"
+  when: is_initiator == False
\ No newline at end of file
diff --git a/xos/synchronizer/steps/roles/setup_vta/tasks/main.yml b/xos/synchronizer/steps/roles/setup_vta/tasks/main.yml
new file mode 100644
index 0000000..8a00676
--- /dev/null
+++ b/xos/synchronizer/steps/roles/setup_vta/tasks/main.yml
@@ -0,0 +1,36 @@
+---
+
+- name: check if work should be done
+  stat: path=/tmp/init_completed
+  register: result
+
+- name: get interface of private_ip
+  register: private_interface
+  shell: |
+    ip addr | awk '/^[0-9]+:/ {   sub(/:/,"",$2); iface=$2 } /^[[:space:]]*inet / {   split($2, a, "/");  print iface" : "a[1] }' | grep "{{ private_ip }}" | cut -d " " -f 1
+  when: result.stat.exists == False
+
+- name: get interface of public_ip
+  register: public_interface
+  shell: |
+    ip addr | awk '/^[0-9]+:/ {   sub(/:/,"",$2); iface=$2 } /^[[:space:]]*inet / {   split($2, a, "/");  print iface" : "a[1] }' | grep "{{ public_ip }}" | cut -d " " -f 1
+  when: result.stat.exists == False
+
+- name: get gateway of private_ip
+  register: private_gateway
+  shell: |
+    echo {{ private_ip }} | cut -d '.' -f 1,2,3 | sed '/.*/ s/$/.1/'
+  when: result.stat.exists == False
+
+- name: setup vta
+  shell: |
+    vnf-setup --test-network {{private_interface.stdout}},{{private_ip}},255.255.255.0,{{private_gateway.stdout}} --management-interface {{public_interface.stdout}} --io-virtualization VIRTIO --test-speed 1G --tagging UNTAGGED --mtu-size 1450 --controller-address {{ controller_ip }}
+  when: result.stat.exists == False
+
+- name: record task completed
+  shell: echo "done" > /tmp/init_completed
+
+- name: restart vta
+  shell: reboot
+  when: result.stat.exists == False
+
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 }
+
+
diff --git a/xos/synchronizer/steps/sync_qt600tenant.py b/xos/synchronizer/steps/sync_qt600tenant.py
new file mode 100644
index 0000000..216cb13
--- /dev/null
+++ b/xos/synchronizer/steps/sync_qt600tenant.py
@@ -0,0 +1,48 @@
+import os
+import sys
+from django.db.models import Q, F
+from services.activetest.models import Qt600Tenant
+from synchronizers.base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
+
+parentdir = os.path.join(os.path.dirname(__file__), "..")
+sys.path.insert(0, parentdir)
+
+class SyncQt600Tenant(SyncInstanceUsingAnsible):
+
+    provides = [Qt600Tenant]
+
+    observes = Qt600Tenant
+
+    requested_interval = 0
+
+    template_name = "qt600tenant_playbook.yaml"
+
+    service_key_name = "/opt/xos/synchronizers/activetest/activetest_private_key"
+
+    def __init__(self, *args, **kwargs):
+        super(SyncQt600Tenant, self).__init__(*args, **kwargs)
+
+    def fetch_pending(self, deleted):
+
+        if (not deleted):
+            objs = Qt600Tenant.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 = Qt600Tenant.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 { "private_ip":o.private_ip,
+                 "public_ip":o.public_ip,
+                 "controller_ip":o.controller_ip,
+                 "reflector_ip":o.reflector_ip,
+                 "reflector_public_ip":o.reflector_public_ip,
+                 "is_reflector":o.is_reflector,
+                 "is_initiator":o.is_initiator
+             }
+
+
diff --git a/xos/synchronizer/steps/sync_vpmatenant.py b/xos/synchronizer/steps/sync_vpmatenant.py
new file mode 100644
index 0000000..52b5e32
--- /dev/null
+++ b/xos/synchronizer/steps/sync_vpmatenant.py
@@ -0,0 +1,48 @@
+import os
+import sys
+from django.db.models import Q, F
+from services.activetest.models import VpmaTenant
+from synchronizers.base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
+
+parentdir = os.path.join(os.path.dirname(__file__), "..")
+sys.path.insert(0, parentdir)
+
+class SyncVpmaTenant(SyncInstanceUsingAnsible):
+
+    provides = [VpmaTenant]
+
+    observes = VpmaTenant
+
+    requested_interval = 0
+
+    template_name = "vpmatenant_playbook.yaml"
+
+    service_key_name = "/opt/xos/synchronizers/activetest/activetest_private_key"
+
+    def __init__(self, *args, **kwargs):
+        super(SyncVpmaTenant, self).__init__(*args, **kwargs)
+
+    def fetch_pending(self, deleted):
+
+        if (not deleted):
+            objs = VpmaTenant.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 = VpmaTenant.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 { "private_ip":o.private_ip,
+                 "public_ip":o.public_ip,
+                 "controller_ip":o.controller_ip,
+                 "reflector_ip":o.reflector_ip,
+                 "reflector_public_ip":o.reflector_public_ip,
+                 "is_reflector":o.is_reflector,
+                 "is_initiator":o.is_initiator
+             }
+
+
diff --git a/xos/synchronizer/steps/sync_vtatenant.py b/xos/synchronizer/steps/sync_vtatenant.py
new file mode 100644
index 0000000..1406e4b
--- /dev/null
+++ b/xos/synchronizer/steps/sync_vtatenant.py
@@ -0,0 +1,44 @@
+import os
+import sys
+from django.db.models import Q, F
+from services.activetest.models import VtaTenant
+from synchronizers.base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
+
+parentdir = os.path.join(os.path.dirname(__file__), "..")
+sys.path.insert(0, parentdir)
+
+class SyncVtaTenant(SyncInstanceUsingAnsible):
+
+    provides = [VtaTenant]
+
+    observes = VtaTenant
+
+    requested_interval = 0
+
+    template_name = "vtatenant_playbook.yaml"
+
+    service_key_name = "/opt/xos/synchronizers/activetest/activetest_private_key"
+
+    def __init__(self, *args, **kwargs):
+        super(SyncVtaTenant, self).__init__(*args, **kwargs)
+
+    def fetch_pending(self, deleted):
+
+        if (not deleted):
+            objs = VtaTenant.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 = VtaTenant.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 { "private_ip":o.private_ip,
+                 "public_ip":o.public_ip,
+                 "controller_ip":o.controller_ip
+             }
+
+
diff --git a/xos/synchronizer/steps/vpmatenant_playbook.yaml b/xos/synchronizer/steps/vpmatenant_playbook.yaml
new file mode 100644
index 0000000..26a12a1
--- /dev/null
+++ b/xos/synchronizer/steps/vpmatenant_playbook.yaml
@@ -0,0 +1,20 @@
+---
+# activetesttenant_playbook - sets up the controller
+
+- hosts: "{{ instance_name }}"
+  connection: ssh
+  user: root
+  sudo: no
+  gather_facts: no
+  vars:
+    - private_ip: "{{ private_ip }}"
+    - public_ip: "{{ public_ip }}"
+    - controller_ip: "{{ controller_ip }}"
+    - reflector_ip: "{{ reflector_ip }}"
+    - reflector_public_ip: "{{ reflector_public_ip }}"
+    - is_initiator: {{ is_initiator }}
+    - is_reflector: {{ is_reflector }}
+
+  roles:
+    - setup_ma
+    - setup_vpma
diff --git a/xos/synchronizer/steps/vtatenant_playbook.yaml b/xos/synchronizer/steps/vtatenant_playbook.yaml
new file mode 100644
index 0000000..fa036fb
--- /dev/null
+++ b/xos/synchronizer/steps/vtatenant_playbook.yaml
@@ -0,0 +1,16 @@
+---
+# activetesttenant_playbook - sets up the controller
+
+- hosts: "{{ instance_name }}"
+  connection: ssh
+  user: root
+  sudo: no
+  gather_facts: no
+  vars:
+    - private_ip: "{{ private_ip }}"
+    - public_ip: "{{ public_ip }}"
+    - controller_ip: "{{ controller_ip }}"
+
+  roles:
+    - setup_ma
+    - setup_vta
diff --git a/xos/tosca/resources/activetest.py b/xos/tosca/resources/activetest.py
new file mode 100644
index 0000000..9b734b5
--- /dev/null
+++ b/xos/tosca/resources/activetest.py
@@ -0,0 +1,105 @@
+from core.models import Service,User,CoarseTenant
+from services.activetest.models import ActiveTestService, Qt600Service, VpmaService, VtaService
+
+from xosresource import XOSResource
+
+class XOSActiveTestService(XOSResource):
+    provides = "tosca.nodes.ActiveTest"
+    xos_model = ActiveTestService
+    copyin_props = ["view_url", "icon_url", "enabled", "published", "public_key", "private_key_fn", "versionNumber"]
+
+    def postprocess(self, obj):
+        for provider_service_name in self.get_requirements("tosca.relationships.TenantOfService"):
+            provider_service = self.get_xos_object(ActiveTestService, name=provider_service_name)
+
+            existing_tenancy = CoarseTenant.get_tenant_objects().filter(provider_service = provider_service, subscriber_service = obj)
+            if existing_tenancy:
+                self.info("Tenancy relationship from %s to %s already exists" % (str(obj), str(provider_service)))
+            else:
+                tenancy = CoarseTenant(provider_service = provider_service,
+                                       subscriber_service = obj)
+                tenancy.save()
+
+                self.info("Created Tenancy relationship  from %s to %s" % (str(obj), str(provider_service)))
+
+    def can_delete(self, obj):
+        if obj.slices.exists():
+            self.info("Service %s has active slices; skipping delete" % obj.name)
+            return False
+        return super(XOSActiveTestService, self).can_delete(obj)
+
+class XOSQt600Service(XOSResource):
+    provides = "tosca.nodes.Qt600Service"
+    xos_model = Qt600Service
+    copyin_props = ["view_url", "icon_url", "enabled", "published", "public_key", "private_key_fn", "versionNumber"]
+
+    def postprocess(self, obj):
+        for provider_service_name in self.get_requirements("tosca.relationships.TenantOfService"):
+            provider_service = self.get_xos_object(Qt600Service, name=provider_service_name)
+
+            existing_tenancy = CoarseTenant.get_tenant_objects().filter(provider_service = provider_service, subscriber_service = obj)
+            if existing_tenancy:
+                self.info("Tenancy relationship from %s to %s already exists" % (str(obj), str(provider_service)))
+            else:
+                tenancy = CoarseTenant(provider_service = provider_service,
+                                       subscriber_service = obj)
+                tenancy.save()
+
+                self.info("Created Tenancy relationship  from %s to %s" % (str(obj), str(provider_service)))
+
+    def can_delete(self, obj):
+        if obj.slices.exists():
+            self.info("Service %s has active slices; skipping delete" % obj.name)
+            return False
+        return super(XOSQt600Service, self).can_delete(obj)
+
+class XOSVpmaService(XOSResource):
+    provides = "tosca.nodes.VpmaService"
+    xos_model = VpmaService
+    copyin_props = ["view_url", "icon_url", "enabled", "published", "public_key", "private_key_fn", "versionNumber"]
+
+    def postprocess(self, obj):
+        for provider_service_name in self.get_requirements("tosca.relationships.TenantOfService"):
+            provider_service = self.get_xos_object(VpmaService, name=provider_service_name)
+
+            existing_tenancy = CoarseTenant.get_tenant_objects().filter(provider_service = provider_service, subscriber_service = obj)
+            if existing_tenancy:
+                self.info("Tenancy relationship from %s to %s already exists" % (str(obj), str(provider_service)))
+            else:
+                tenancy = CoarseTenant(provider_service = provider_service,
+                                       subscriber_service = obj)
+                tenancy.save()
+
+                self.info("Created Tenancy relationship  from %s to %s" % (str(obj), str(provider_service)))
+
+    def can_delete(self, obj):
+        if obj.slices.exists():
+            self.info("Service %s has active slices; skipping delete" % obj.name)
+            return False
+        return super(XOSVpmaService, self).can_delete(obj)
+
+class XOSVtaService(XOSResource):
+    provides = "tosca.nodes.VtaService"
+    xos_model = VtaService
+    copyin_props = ["view_url", "icon_url", "enabled", "published", "public_key", "private_key_fn", "versionNumber"]
+
+    def postprocess(self, obj):
+        for provider_service_name in self.get_requirements("tosca.relationships.TenantOfService"):
+            provider_service = self.get_xos_object(VtaService, name=provider_service_name)
+
+            existing_tenancy = CoarseTenant.get_tenant_objects().filter(provider_service = provider_service, subscriber_service = obj)
+            if existing_tenancy:
+                self.info("Tenancy relationship from %s to %s already exists" % (str(obj), str(provider_service)))
+            else:
+                tenancy = CoarseTenant(provider_service = provider_service,
+                                       subscriber_service = obj)
+                tenancy.save()
+
+                self.info("Created Tenancy relationship  from %s to %s" % (str(obj), str(provider_service)))
+
+    def can_delete(self, obj):
+        if obj.slices.exists():
+            self.info("Service %s has active slices; skipping delete" % obj.name)
+            return False
+        return super(XOSVtaService, self).can_delete(obj)
+
diff --git a/xos/tosca/resources/activetesttenant.py b/xos/tosca/resources/activetesttenant.py
new file mode 100644
index 0000000..7b1a09d
--- /dev/null
+++ b/xos/tosca/resources/activetesttenant.py
@@ -0,0 +1,29 @@
+from core.models import Tenant, Service
+from services.activetest.models import ActiveTestTenant, ACTIVETEST_KIND as ACTIVETESTTENANT_KIND
+
+from xosresource import XOSResource
+
+class XOSActiveTestTenant(XOSResource):
+    provides = "tosca.nodes.ActiveTestTenant"
+    xos_model = ActiveTestTenant
+    name_field = "service_specific_id"
+    copyin_props = ("tenant_message",)
+
+    def get_xos_args(self, throw_exception=True):
+        args = super(XOSActiveTestTenant, self).get_xos_args()
+
+        # ActiveTestTenant must always have a provider_service
+        provider_name = self.get_requirement("tosca.relationships.TenantOfService", throw_exception=True)
+        if provider_name:
+            args["provider_service"] = self.get_xos_object(Service, throw_exception=True, name=provider_name)
+
+        return args
+
+    def get_existing_objs(self):
+        args = self.get_xos_args(throw_exception=False)
+        return ActiveTestTenant.get_tenant_objects().filter(provider_service=args["provider_service"], service_specific_id=args["service_specific_id"])
+        return []
+
+    def can_delete(self, obj):
+        return super(XOSActiveTestTenant, self).can_delete(obj)
+
diff --git a/xos/tosca/resources/qt600tenant.py b/xos/tosca/resources/qt600tenant.py
new file mode 100644
index 0000000..e223428
--- /dev/null
+++ b/xos/tosca/resources/qt600tenant.py
@@ -0,0 +1,28 @@
+from core.models import Tenant, Service
+from services.activetest.models import Qt600Tenant
+
+from xosresource import XOSResource
+
+class XOSQt600Tenant(XOSResource):
+    name_field = "service_specific_id"
+    provides = "tosca.nodes.Qt600Tenant"
+    copyin_props = ("is_reflector","is_initiator","reflector",)
+    xos_model = Qt600Tenant
+
+    def get_xos_args(self, throw_exception=True):
+        args = super(XOSQt600Tenant, self).get_xos_args()
+
+        # Qt600Tenant must always have a provider_service
+        provider_name = self.get_requirement("tosca.relationships.TenantOfService", throw_exception=True)
+        if provider_name:
+            args["provider_service"] = self.get_xos_object(Service, throw_exception=True, name=provider_name)
+
+        return args
+
+    def can_delete(self, obj):
+        return super(XOSQt600Tenant, self).can_delete(obj)
+
+    def get_existing_objs(self):
+        args = self.get_xos_args(throw_exception=False)
+        return Qt600Tenant.get_tenant_objects().filter(provider_service=args["provider_service"], service_specific_id=args["service_specific_id"])
+        return []
diff --git a/xos/tosca/resources/vpmatenant.py b/xos/tosca/resources/vpmatenant.py
new file mode 100644
index 0000000..3e45e26
--- /dev/null
+++ b/xos/tosca/resources/vpmatenant.py
@@ -0,0 +1,28 @@
+from core.models import Tenant, Service
+from services.activetest.models import VpmaTenant
+
+from xosresource import XOSResource
+
+class XOSVpmaTenant(XOSResource):
+    name_field = "service_specific_id"
+    provides = "tosca.nodes.VpmaTenant"
+    copyin_props = ("is_reflector","is_initiator","reflector",)
+    xos_model = VpmaTenant
+
+    def get_xos_args(self, throw_exception=True):
+        args = super(XOSVpmaTenant, self).get_xos_args()
+
+        # VpmaTenant must always have a provider_service
+        provider_name = self.get_requirement("tosca.relationships.TenantOfService", throw_exception=True)
+        if provider_name:
+            args["provider_service"] = self.get_xos_object(Service, throw_exception=True, name=provider_name)
+
+        return args
+
+    def can_delete(self, obj):
+        return super(XOSVpmaTenant, self).can_delete(obj)
+
+    def get_existing_objs(self):
+        args = self.get_xos_args(throw_exception=False)
+        return VpmaTenant.get_tenant_objects().filter(provider_service=args["provider_service"], service_specific_id=args["service_specific_id"])
+        return []
diff --git a/xos/tosca/resources/vtatenant.py b/xos/tosca/resources/vtatenant.py
new file mode 100644
index 0000000..e2ecf25
--- /dev/null
+++ b/xos/tosca/resources/vtatenant.py
@@ -0,0 +1,27 @@
+from core.models import Tenant, Service
+from services.activetest.models import VtaTenant
+
+from xosresource import XOSResource
+
+class XOSVtaTenant(XOSResource):
+    name_field = "service_specific_id"
+    provides = "tosca.nodes.VtaTenant"
+    xos_model = VtaTenant
+
+    def get_xos_args(self, throw_exception=True):
+        args = super(XOSVtaTenant, self).get_xos_args()
+
+        # VtaTenant must always have a provider_service
+        provider_name = self.get_requirement("tosca.relationships.TenantOfService", throw_exception=True)
+        if provider_name:
+            args["provider_service"] = self.get_xos_object(Service, throw_exception=True, name=provider_name)
+
+        return args
+
+    def can_delete(self, obj):
+        return super(XOSVtaTenant, self).can_delete(obj)
+
+    def get_existing_objs(self):
+        args = self.get_xos_args(throw_exception=False)
+        return VtaTenant.get_tenant_objects().filter(provider_service=args["provider_service"], service_specific_id=args["service_specific_id"])
+        return []