diff --git a/VERSION b/VERSION
index bda8fbe..5bc1cc4 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.2.6
+2.2.7
diff --git a/containers/chameleon/Dockerfile.chameleon b/containers/chameleon/Dockerfile.chameleon
index ee2ddbe..059ef0a 100644
--- a/containers/chameleon/Dockerfile.chameleon
+++ b/containers/chameleon/Dockerfile.chameleon
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # xosproject/chameleon
-FROM xosproject/xos-base:2.2.6
+FROM xosproject/xos-base:2.2.7
 
 # xos-base already has protoc and dependencies installed
 
diff --git a/containers/xos/Dockerfile.client b/containers/xos/Dockerfile.client
index f7fcd50..b5b3fcd 100644
--- a/containers/xos/Dockerfile.client
+++ b/containers/xos/Dockerfile.client
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # xosproject/xos-client
-FROM xosproject/xos-libraries:2.2.6
+FROM xosproject/xos-libraries:2.2.7
 
 # Install XOS client
 COPY lib/xos-api /tmp/xos-api
diff --git a/containers/xos/Dockerfile.libraries b/containers/xos/Dockerfile.libraries
index a7ecf03..1c034b5 100644
--- a/containers/xos/Dockerfile.libraries
+++ b/containers/xos/Dockerfile.libraries
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # xosproject/xos-libraries
-FROM xosproject/xos-base:2.2.6
+FROM xosproject/xos-base:2.2.7
 
 # Add libraries
 COPY lib /opt/xos/lib
diff --git a/containers/xos/Dockerfile.synchronizer-base b/containers/xos/Dockerfile.synchronizer-base
index 64dd9cb..f219574 100644
--- a/containers/xos/Dockerfile.synchronizer-base
+++ b/containers/xos/Dockerfile.synchronizer-base
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # xosproject/xos-synchronizer-base
-FROM xosproject/xos-client:2.2.6
+FROM xosproject/xos-client:2.2.7
 
 COPY xos/synchronizers/new_base /opt/xos/synchronizers/new_base
 COPY xos/xos/logger.py /opt/xos/xos/logger.py
diff --git a/containers/xos/Dockerfile.xos-core b/containers/xos/Dockerfile.xos-core
index c1aa1d0..687ed08 100644
--- a/containers/xos/Dockerfile.xos-core
+++ b/containers/xos/Dockerfile.xos-core
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 # xosproject/xos-core
-FROM xosproject/xos-libraries:2.2.6
+FROM xosproject/xos-libraries:2.2.7
 
 # Install XOS
 ADD xos /opt/xos
diff --git a/lib/xos-synchronizer/xossynchronizer/model_policies/model_policy_tenantwithcontainer.py b/lib/xos-synchronizer/xossynchronizer/model_policies/model_policy_tenantwithcontainer.py
deleted file mode 100644
index 3db1395..0000000
--- a/lib/xos-synchronizer/xossynchronizer/model_policies/model_policy_tenantwithcontainer.py
+++ /dev/null
@@ -1,318 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-from xossynchronizer.modelaccessor import *
-from xossynchronizer.model_policies.policy import Policy
-from xossynchronizer.exceptions import *
-
-
-class Scheduler(object):
-    # XOS Scheduler Abstract Base Class
-    # Used to implement schedulers that pick which node to put instances on
-
-    def __init__(self, slice, label=None, constrain_by_service_instance=False):
-        self.slice = slice
-        self.label = label  # Only pick nodes with this label
-        # Apply service-instance-based constraints
-        self.constrain_by_service_instance = constrain_by_service_instance
-
-    def pick(self):
-        # this method should return a tuple (node, parent)
-        #    node is the node to instantiate on
-        #    parent is for container_vm instances only, and is the VM that will
-        #      hold the container
-
-        raise Exception("Abstract Base")
-
-
-class LeastLoadedNodeScheduler(Scheduler):
-    # This scheduler always return the node with the fewest number of
-    # instances.
-
-    def pick(self):
-        set_label = False
-
-        nodes = []
-        if self.label:
-            nodes = Node.objects.filter(nodelabels__name=self.label)
-            if not nodes:
-                set_label = self.constrain_by_service_instance
-
-        if not nodes:
-            if self.slice.default_node:
-                # if slice.default_node is set, then filter by default_node
-                nodes = Node.objects.filter(name=self.slice.default_node)
-            else:
-                nodes = Node.objects.all()
-
-        # convert to list
-        nodes = list(nodes)
-
-        # sort so that we pick the least-loaded node
-        nodes = sorted(nodes, key=lambda node: node.instances.count())
-
-        if not nodes:
-            raise Exception("LeastLoadedNodeScheduler: No suitable nodes to pick from")
-
-        picked_node = nodes[0]
-
-        if set_label:
-            nl = NodeLabel(name=self.label)
-            nl.node.add(picked_node)
-            nl.save()
-
-        # TODO: logic to filter nodes by which nodes are up, and which
-        #   nodes the slice can instantiate on.
-        return [picked_node, None]
-
-
-class TenantWithContainerPolicy(Policy):
-    # This policy is abstract. Inherit this class into your own policy and override model_name
-    model_name = None
-
-    def handle_create(self, tenant):
-        return self.handle_update(tenant)
-
-    def handle_update(self, service_instance):
-        if (service_instance.link_deleted_count > 0) and (
-            not service_instance.provided_links.exists()
-        ):
-            model = globals()[self.model_name]
-            self.log.info(
-                "The last provided link has been deleted -- self-destructing."
-            )
-            self.handle_delete(service_instance)
-            if model.objects.filter(id=service_instance.id).exists():
-                service_instance.delete()
-            else:
-                self.log.info("Tenant %s is already deleted" % service_instance)
-            return
-        self.manage_container(service_instance)
-
-    #    def handle_delete(self, tenant):
-    #        if tenant.vcpe:
-    #            tenant.vcpe.delete()
-
-    def save_instance(self, instance):
-        # Override this function to do custom pre-save or post-save processing,
-        # such as creating ports for containers.
-        instance.save()
-
-    def ip_to_mac(self, ip):
-        (a, b, c, d) = ip.split(".")
-        return "02:42:%02x:%02x:%02x:%02x" % (int(a), int(b), int(c), int(d))
-
-    def allocate_public_service_instance(self, **kwargs):
-        """ Get a ServiceInstance that provides public connectivity. Currently this means to use AddressPool and
-            the AddressManager Service.
-
-            Expect this to be refactored when we break hard-coded service dependencies.
-        """
-        address_pool_name = kwargs.pop("address_pool_name")
-
-        am_service = AddressManagerService.objects.all()  # TODO: Hardcoded dependency
-        if not am_service:
-            raise Exception("no addressing services")
-        am_service = am_service[0]
-
-        ap = AddressPool.objects.filter(
-            name=address_pool_name, service_id=am_service.id
-        )
-        if not ap:
-            raise Exception("Addressing service unable to find addresspool %s" % name)
-        ap = ap[0]
-
-        ip = ap.get_address()
-        if not ip:
-            raise Exception("AddressPool '%s' has run out of addresses." % ap.name)
-
-        ap.save()  # save the AddressPool to account for address being removed from it
-
-        subscriber_service = None
-        if "subscriber_service" in kwargs:
-            subscriber_service = kwargs.pop("subscriber_service")
-
-        subscriber_service_instance = None
-        if "subscriber_tenant" in kwargs:
-            subscriber_service_instance = kwargs.pop("subscriber_tenant")
-        elif "subscriber_service_instance" in kwargs:
-            subscriber_service_instance = kwargs.pop("subscriber_service_instance")
-
-        # TODO: potential partial failure -- AddressPool address is allocated and saved before addressing tenant
-
-        t = None
-        try:
-            t = AddressManagerServiceInstance(
-                owner=am_service, **kwargs
-            )  # TODO: Hardcoded dependency
-            t.public_ip = ip
-            t.public_mac = self.ip_to_mac(ip)
-            t.address_pool_id = ap.id
-            t.save()
-
-            if subscriber_service:
-                link = ServiceInstanceLink(
-                    subscriber_service=subscriber_service, provider_service_instance=t
-                )
-                link.save()
-
-            if subscriber_service_instance:
-                link = ServiceInstanceLink(
-                    subscriber_service_instance=subscriber_service_instance,
-                    provider_service_instance=t,
-                )
-                link.save()
-        except BaseException:
-            # cleanup if anything went wrong
-            ap.put_address(ip)
-            ap.save()  # save the AddressPool to account for address being added to it
-            if t and t.id:
-                t.delete()
-            raise
-
-        return t
-
-    def get_image(self, tenant):
-        slice = tenant.owner.slices.all()
-        if not slice:
-            raise SynchronizerProgrammingError("provider service has no slice")
-        slice = slice[0]
-
-        # If slice has default_image set then use it
-        if slice.default_image:
-            return slice.default_image
-
-        raise SynchronizerProgrammingError(
-            "Please set a default image for %s" % self.slice.name
-        )
-
-    """ get_legacy_tenant_attribute
-        pick_least_loaded_instance_in_slice
-        count_of_tenants_of_an_instance
-
-        These three methods seem to be used by A-CORD. Look for ways to consolidate with existing methods and eliminate
-        these legacy ones
-    """
-
-    def get_legacy_tenant_attribute(self, tenant, name, default=None):
-        if tenant.service_specific_attribute:
-            attributes = json.loads(tenant.service_specific_attribute)
-        else:
-            attributes = {}
-        return attributes.get(name, default)
-
-    def pick_least_loaded_instance_in_slice(self, tenant, slices, image):
-        for slice in slices:
-            if slice.instances.all().count() > 0:
-                for instance in slice.instances.all():
-                    if instance.image != image:
-                        continue
-                    # Pick the first instance that has lesser than 5 tenants
-                    if self.count_of_tenants_of_an_instance(tenant, instance) < 5:
-                        return instance
-        return None
-
-    # TODO: Ideally the tenant count for an instance should be maintained using a
-    # many-to-one relationship attribute, however this model being proxy, it does
-    # not permit any new attributes to be defined. Find if any better solutions
-    def count_of_tenants_of_an_instance(self, tenant, instance):
-        tenant_count = 0
-        for tenant in self.__class__.objects.all():
-            if (
-                self.get_legacy_tenant_attribute(tenant, "instance_id", None)
-                == instance.id
-            ):
-                tenant_count += 1
-        return tenant_count
-
-    def manage_container(self, tenant):
-        if tenant.deleted:
-            return
-
-        desired_image = self.get_image(tenant)
-
-        if (tenant.instance is not None) and (
-            tenant.instance.image.id != desired_image.id
-        ):
-            tenant.instance.delete()
-            tenant.instance = None
-
-        if tenant.instance is None:
-            if not tenant.owner.slices.count():
-                raise SynchronizerConfigurationError("The service has no slices")
-
-            new_instance_created = False
-            instance = None
-            if self.get_legacy_tenant_attribute(
-                tenant, "use_same_instance_for_multiple_tenants", default=False
-            ):
-                # Find if any existing instances can be used for this tenant
-                slices = tenant.owner.slices.all()
-                instance = self.pick_least_loaded_instance_in_slice(
-                    tenant, slices, desired_image
-                )
-
-            if not instance:
-                slice = tenant.owner.slices.first()
-
-                flavor = slice.default_flavor
-                if not flavor:
-                    flavors = Flavor.objects.filter(name="m1.small")
-                    if not flavors:
-                        raise SynchronizerConfigurationError("No m1.small flavor")
-                    flavor = flavors[0]
-
-                if slice.default_isolation == "container_vm":
-                    raise Exception("Not implemented")
-                else:
-                    scheduler = getattr(self, "scheduler", LeastLoadedNodeScheduler)
-                    constrain_by_service_instance = getattr(
-                        self, "constrain_by_service_instance", False
-                    )
-                    tenant_node_label = getattr(tenant, "node_label", None)
-                    (node, parent) = scheduler(
-                        slice,
-                        label=tenant_node_label,
-                        constrain_by_service_instance=constrain_by_service_instance,
-                    ).pick()
-
-                assert slice is not None
-                assert node is not None
-                assert desired_image is not None
-                assert tenant.creator is not None
-                assert flavor is not None
-
-                try:
-                    instance = Instance(
-                        slice=slice,
-                        node=node,
-                        image=desired_image,
-                        creator=tenant.creator,
-                        flavor=flavor,
-                        isolation=slice.default_isolation,
-                        parent=parent,
-                    )
-                    self.save_instance(instance)
-                    new_instance_created = True
-
-                    tenant.instance = instance
-                    tenant.save()
-                except BaseException:
-                    # NOTE: We don't have transactional support, so if the synchronizer crashes and exits after
-                    #       creating the instance, but before adding it to the tenant, then we will leave an
-                    #       orphaned instance.
-                    if new_instance_created:
-                        instance.delete()
-                    raise
diff --git a/lib/xos-synchronizer/xossynchronizer/steps/SyncInstanceUsingAnsible.py b/lib/xos-synchronizer/xossynchronizer/steps/SyncInstanceUsingAnsible.py
deleted file mode 100644
index 1bc54ce..0000000
--- a/lib/xos-synchronizer/xossynchronizer/steps/SyncInstanceUsingAnsible.py
+++ /dev/null
@@ -1,319 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-import hashlib
-import os
-import socket
-import sys
-import base64
-import time
-from xosconfig import Config
-
-from xossynchronizer.steps.syncstep import SyncStep, DeferredException
-from xossynchronizer.ansible_helper import run_template_ssh
-
-
-class SyncInstanceUsingAnsible(SyncStep):
-    # All of the following should be defined for classes derived from this
-    # base class. Examples below use VSGTenant.
-
-    # provides=[VSGTenant]
-    # observes=VSGTenant
-    # requested_interval=0
-    # template_name = "sync_vcpetenant.yaml"
-
-    def __init__(self, **args):
-        SyncStep.__init__(self, **args)
-
-    def skip_ansible_fields(self, o):
-        # Return True if the instance processing and get_ansible_fields stuff
-        # should be skipped. This hook is primarily for the OnosApp
-        # sync step, so it can do its external REST API sync thing.
-        return False
-
-    def defer_sync(self, o, reason):
-        # zdw, 2017-02-18 - is raising the exception here necessary? - seems like
-        # it's just logging the same thing twice
-        self.log.info("defer object", object=str(o), reason=reason, **o.tologdict())
-        raise DeferredException("defer object %s due to %s" % (str(o), reason))
-
-    def get_extra_attributes(self, o):
-        # This is a place to include extra attributes that aren't part of the
-        # object itself.
-
-        return {}
-
-    def get_instance(self, o):
-        # We need to know what instance is associated with the object. Let's
-        # assume 'o' has a field called 'instance'. If the field is called
-        # something else, or if custom logic is needed, then override this
-        # method.
-
-        return o.instance
-
-    def get_external_sync(self, o):
-        hostname = getattr(o, "external_hostname", None)
-        container = getattr(o, "external_container", None)
-        if hostname and container:
-            return (hostname, container)
-        else:
-            return None
-
-    def run_playbook(self, o, fields, template_name=None):
-        if not template_name:
-            template_name = self.template_name
-        tStart = time.time()
-        run_template_ssh(template_name, fields, object=o)
-        self.log.info(
-            "playbook execution time", time=int(time.time() - tStart), **o.tologdict()
-        )
-
-    def pre_sync_hook(self, o, fields):
-        pass
-
-    def post_sync_hook(self, o, fields):
-        pass
-
-    def sync_fields(self, o, fields):
-        self.run_playbook(o, fields)
-
-    def prepare_record(self, o):
-        pass
-
-    def get_node(self, o):
-        return o.node
-
-    def get_node_key(self, node):
-        # NOTE `node_key` is never defined, does it differ from `proxy_ssh_key`? the value looks to be the same
-        return Config.get("node_key")
-
-    def get_key_name(self, instance):
-        if instance.isolation == "vm":
-            if (
-                instance.slice
-                and instance.slice.service
-                and instance.slice.service.private_key_fn
-            ):
-                key_name = instance.slice.service.private_key_fn
-            else:
-                raise Exception("Make sure to set private_key_fn in the service")
-        elif instance.isolation == "container":
-            node = self.get_node(instance)
-            key_name = self.get_node_key(node)
-        else:
-            # container in VM
-            key_name = instance.parent.slice.service.private_key_fn
-
-        return key_name
-
-    def get_ansible_fields(self, instance):
-        # return all of the fields that tell Ansible how to talk to the context
-        # that's setting up the container.
-
-        if instance.isolation == "vm":
-            # legacy where container was configured by sync_vcpetenant.py
-
-            fields = {
-                "instance_name": instance.name,
-                "hostname": instance.node.name,
-                "instance_id": instance.instance_id,
-                "username": "ubuntu",
-                "ssh_ip": instance.get_ssh_ip(),
-            }
-
-        elif instance.isolation == "container":
-            # container on bare metal
-            node = self.get_node(instance)
-            hostname = node.name
-            fields = {
-                "hostname": hostname,
-                "baremetal_ssh": True,
-                "instance_name": "rootcontext",
-                "username": "root",
-                "container_name": "%s-%s" % (instance.slice.name, str(instance.id))
-                # ssh_ip is not used for container-on-metal
-            }
-        else:
-            # container in a VM
-            if not instance.parent:
-                raise Exception("Container-in-VM has no parent")
-            if not instance.parent.instance_id:
-                raise Exception("Container-in-VM parent is not yet instantiated")
-            if not instance.parent.slice.service:
-                raise Exception("Container-in-VM parent has no service")
-            if not instance.parent.slice.service.private_key_fn:
-                raise Exception("Container-in-VM parent service has no private_key_fn")
-            fields = {
-                "hostname": instance.parent.node.name,
-                "instance_name": instance.parent.name,
-                "instance_id": instance.parent.instance_id,
-                "username": "ubuntu",
-                "ssh_ip": instance.parent.get_ssh_ip(),
-                "container_name": "%s-%s" % (instance.slice.name, str(instance.id)),
-            }
-
-        key_name = self.get_key_name(instance)
-        if not os.path.exists(key_name):
-            raise Exception("Node key %s does not exist" % key_name)
-
-        key = file(key_name).read()
-
-        fields["private_key"] = key
-
-        # Now the ceilometer stuff
-        # Only do this if the instance is not being deleted.
-        if not instance.deleted:
-            cslice = ControllerSlice.objects.get(slice_id=instance.slice.id)
-            if not cslice:
-                raise Exception(
-                    "Controller slice object for %s does not exist"
-                    % instance.slice.name
-                )
-
-            cuser = ControllerUser.objects.get(user_id=instance.creator.id)
-            if not cuser:
-                raise Exception(
-                    "Controller user object for %s does not exist" % instance.creator
-                )
-
-            fields.update(
-                {
-                    "keystone_tenant_id": cslice.tenant_id,
-                    "keystone_user_id": cuser.kuser_id,
-                    "rabbit_user": getattr(instance.controller, "rabbit_user", None),
-                    "rabbit_password": getattr(
-                        instance.controller, "rabbit_password", None
-                    ),
-                    "rabbit_host": getattr(instance.controller, "rabbit_host", None),
-                }
-            )
-
-        return fields
-
-    def sync_record(self, o):
-        self.log.info("sync'ing object", object=str(o), **o.tologdict())
-
-        self.prepare_record(o)
-
-        if self.skip_ansible_fields(o):
-            fields = {}
-        else:
-            if self.get_external_sync(o):
-                # sync to some external host
-
-                # UNTESTED
-
-                (hostname, container_name) = self.get_external_sync(o)
-                fields = {
-                    "hostname": hostname,
-                    "baremetal_ssh": True,
-                    "instance_name": "rootcontext",
-                    "username": "root",
-                    "container_name": container_name,
-                }
-                key_name = self.get_node_key(node)
-                if not os.path.exists(key_name):
-                    raise Exception("Node key %s does not exist" % key_name)
-
-                key = file(key_name).read()
-
-                fields["private_key"] = key
-                # TO DO: Ceilometer stuff
-            else:
-                instance = self.get_instance(o)
-                # sync to an XOS instance
-                if not instance:
-                    self.defer_sync(o, "waiting on instance")
-                    return
-
-                if not instance.instance_name:
-                    self.defer_sync(o, "waiting on instance.instance_name")
-                    return
-
-                fields = self.get_ansible_fields(instance)
-
-        fields["ansible_tag"] = getattr(
-            o, "ansible_tag", o.__class__.__name__ + "_" + str(o.id)
-        )
-
-        # If 'o' defines a 'sync_attributes' list, then we'll copy those
-        # attributes into the Ansible recipe's field list automatically.
-        if hasattr(o, "sync_attributes"):
-            for attribute_name in o.sync_attributes:
-                fields[attribute_name] = getattr(o, attribute_name)
-
-        fields.update(self.get_extra_attributes(o))
-
-        self.sync_fields(o, fields)
-
-        o.save()
-
-    def delete_record(self, o):
-        try:
-            # TODO: This may be broken, as get_controller() does not exist in convenience wrapper
-            controller = o.get_controller()
-            controller_register = json.loads(
-                o.node.site_deployment.controller.backend_register
-            )
-
-            if controller_register.get("disabled", False):
-                raise InnocuousException(
-                    "Controller %s is disabled" % o.node.site_deployment.controller.name
-                )
-        except AttributeError:
-            pass
-
-        instance = self.get_instance(o)
-
-        if not instance:
-            # the instance is gone. There's nothing left for us to do.
-            return
-
-        if instance.deleted:
-            # the instance is being deleted. There's nothing left for us to do.
-            return
-
-        if isinstance(instance, basestring):
-            # sync to some external host
-
-            # XXX - this probably needs more work...
-
-            fields = {
-                "hostname": instance,
-                "instance_id": "ubuntu",  # this is the username to log into
-                "private_key": service.key,
-            }
-        else:
-            # sync to an XOS instance
-            fields = self.get_ansible_fields(instance)
-
-            fields["ansible_tag"] = getattr(
-                o, "ansible_tag", o.__class__.__name__ + "_" + str(o.id)
-            )
-
-        # If 'o' defines a 'sync_attributes' list, then we'll copy those
-        # attributes into the Ansible recipe's field list automatically.
-        if hasattr(o, "sync_attributes"):
-            for attribute_name in o.sync_attributes:
-                fields[attribute_name] = getattr(o, attribute_name)
-
-        if hasattr(self, "map_delete_inputs"):
-            fields.update(self.map_delete_inputs(o))
-
-        fields["delete"] = True
-        res = self.run_playbook(o, fields)
-
-        if hasattr(self, "map_delete_outputs"):
-            self.map_delete_outputs(o, res)
diff --git a/xos/core/models/controller.py b/xos/core/models/controller.py
deleted file mode 100644
index 90af736..0000000
--- a/xos/core/models/controller.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from xos.exceptions import *
-from controller_decl import *
-
-
-class Controller(Controller_decl):
-    class Meta:
-        proxy = True
diff --git a/xos/core/models/controllerimages.py b/xos/core/models/controllerimages.py
deleted file mode 100644
index 4ae0ce8..0000000
--- a/xos/core/models/controllerimages.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from xos.exceptions import *
-from controllerimages_decl import *
-
-
-class ControllerImages(ControllerImages_decl):
-    class Meta:
-        proxy = True
diff --git a/xos/core/models/controllernetwork.py b/xos/core/models/controllernetwork.py
deleted file mode 100644
index ac40575..0000000
--- a/xos/core/models/controllernetwork.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from xos.exceptions import *
-from controllernetwork_decl import *
-
-
-class ControllerNetwork(ControllerNetwork_decl):
-    class Meta:
-        proxy = True
-
-    def tologdict(self):
-        d = super(ControllerNetwork, self).tologdict()
-        try:
-            d["network_name"] = self.network.name
-            d["controller_name"] = self.controller.name
-        except BaseException:
-            pass
-        return d
diff --git a/xos/core/models/controllerrole.py b/xos/core/models/controllerrole.py
deleted file mode 100644
index f01d958..0000000
--- a/xos/core/models/controllerrole.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from xos.exceptions import *
-from controllerrole_decl import *
-
-
-class ControllerRole(ControllerRole_decl):
-    class Meta:
-        proxy = True
diff --git a/xos/core/models/controllersite.py b/xos/core/models/controllersite.py
deleted file mode 100644
index 178c014..0000000
--- a/xos/core/models/controllersite.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from xos.exceptions import *
-from controllersite_decl import *
-
-
-class ControllerSite(ControllerSite_decl):
-    class Meta:
-        proxy = True
diff --git a/xos/core/models/controllersiteprivilege.py b/xos/core/models/controllersiteprivilege.py
deleted file mode 100644
index e4283d5..0000000
--- a/xos/core/models/controllersiteprivilege.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from xos.exceptions import *
-from controllersiteprivilege_decl import *
-
-
-class ControllerSitePrivilege(ControllerSitePrivilege_decl):
-    class Meta:
-        proxy = True
diff --git a/xos/core/models/controllerslice.py b/xos/core/models/controllerslice.py
deleted file mode 100644
index 0e48dc9..0000000
--- a/xos/core/models/controllerslice.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from xos.exceptions import *
-from controllerslice_decl import *
-
-
-class ControllerSlice(ControllerSlice_decl):
-    class Meta:
-        proxy = True
-
-    def tologdict(self):
-        d = super(ControllerSlice, self).tologdict()
-        try:
-            d["slice_name"] = self.slice.name
-            d["controller_name"] = self.controller.name
-        except BaseException:
-            pass
-        return d
diff --git a/xos/core/models/controllersliceprivilege.py b/xos/core/models/controllersliceprivilege.py
deleted file mode 100644
index 9fa9ca5..0000000
--- a/xos/core/models/controllersliceprivilege.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from xos.exceptions import *
-from controllersliceprivilege_decl import *
-
-
-class ControllerSlicePrivilege(ControllerSlicePrivilege_decl):
-    class Meta:
-        proxy = True
diff --git a/xos/core/models/controlleruser.py b/xos/core/models/controlleruser.py
deleted file mode 100644
index c64cd26..0000000
--- a/xos/core/models/controlleruser.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from xos.exceptions import *
-from controlleruser_decl import *
-
-
-class ControllerUser(ControllerUser_decl):
-    class Meta:
-        proxy = True
diff --git a/xos/core/models/deployment.py b/xos/core/models/deployment.py
deleted file mode 100644
index 84b2ba6..0000000
--- a/xos/core/models/deployment.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from xos.exceptions import *
-from deployment_decl import *
-
-
-class Deployment(Deployment_decl):
-    class Meta:
-        proxy = True
diff --git a/xos/core/models/imagedeployments.py b/xos/core/models/imagedeployments.py
deleted file mode 100644
index 5c62569..0000000
--- a/xos/core/models/imagedeployments.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from xos.exceptions import *
-from imagedeployments_decl import *
-
-
-class ImageDeployments(ImageDeployments_decl):
-    class Meta:
-        proxy = True
diff --git a/xos/core/models/instance.py b/xos/core/models/instance.py
deleted file mode 100644
index a742d94..0000000
--- a/xos/core/models/instance.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from xos.exceptions import *
-from instance_decl import *
-
-
-class Instance(Instance_decl):
-    class Meta:
-        proxy = True
-
-    def tologdict(self):
-        d = super(Instance, self).tologdict()
-        try:
-            d["slice_name"] = self.slice.name
-            d["controller_name"] = self.get_controller().name
-        except BaseException:
-            pass
-        return d
-
-    def save(self, *args, **kwargs):
-        if not self.name:
-            self.name = self.slice.name
-        if not self.creator and hasattr(self, "caller"):
-            self.creator = self.caller
-
-        super(Instance, self).save(*args, **kwargs)
diff --git a/xos/core/models/sitedeployment.py b/xos/core/models/sitedeployment.py
deleted file mode 100644
index dbac66d..0000000
--- a/xos/core/models/sitedeployment.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from xos.exceptions import *
-from sitedeployment_decl import *
-
-
-class SiteDeployment(SiteDeployment_decl):
-    class Meta:
-        proxy = True
diff --git a/xos/core/models/siteprivilege.py b/xos/core/models/siteprivilege.py
deleted file mode 100644
index ab450b9..0000000
--- a/xos/core/models/siteprivilege.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from xos.exceptions import *
-from siteprivilege_decl import *
-
-
-class SitePrivilege(SitePrivilege_decl):
-    class Meta:
-        proxy = True
diff --git a/xos/core/models/siterole.py b/xos/core/models/siterole.py
deleted file mode 100644
index e38c0a4..0000000
--- a/xos/core/models/siterole.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from xos.exceptions import *
-from siterole_decl import *
-
-
-class SiteRole(SiteRole_decl):
-    class Meta:
-        proxy = True
diff --git a/xos/core/models/sliceprivilege.py b/xos/core/models/sliceprivilege.py
deleted file mode 100644
index 26832f7..0000000
--- a/xos/core/models/sliceprivilege.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from xos.exceptions import *
-from sliceprivilege_decl import *
-
-
-class SlicePrivilege(SlicePrivilege_decl):
-    class Meta:
-        proxy = True
diff --git a/xos/core/models/slicerole.py b/xos/core/models/slicerole.py
deleted file mode 100644
index 957c2e1..0000000
--- a/xos/core/models/slicerole.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from xos.exceptions import *
-from slicerole_decl import *
-
-
-class SliceRole(SliceRole_decl):
-    class Meta:
-        proxy = True
diff --git a/xos/core/models/tenantwithcontainer.py b/xos/core/models/tenantwithcontainer.py
deleted file mode 100644
index d645a63..0000000
--- a/xos/core/models/tenantwithcontainer.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# Copyright 2017-present Open Networking Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from xos.exceptions import *
-from tenantwithcontainer_decl import *
-
-
-class TenantWithContainer(TenantWithContainer_decl):
-    class Meta:
-        proxy = True
-
-    def __init__(self, *args, **kwargs):
-        super(TenantWithContainer, self).__init__(*args, **kwargs)
-
-        # vSG service relies on knowing when instance id has changed
-        self.orig_instance_id = self.get_attribute("instance_id")
-
-    # vSG service relies on instance_id attribute
-    def get_attribute(self, name, default=None):
-        if name == "instance_id":
-            if self.instance:
-                return self.instance.id
-            else:
-                return None
-        else:
-            return super(TenantWithContainer, self).get_attribute(name, default)
-
-    # Services may wish to override the image() function to return different
-    # images based on criteria in the tenant object. For example,
-    #    if (self.has_feature_A):
-    #        return Instance.object.get(name="image_with_feature_a")
-    #    elif (self.has_feature_B):
-    #        return Instance.object.get(name="image_with_feature_b")
-    #    else:
-    #        return super(MyTenantClass,self).image()
-
-    @property
-    def image(self):
-        from core.models import Image
-
-        # Implement the logic here to pick the image that should be used when
-        # instantiating the VM that will hold the container.
-
-        slice = self.provider_service.slices.all()
-        if not slice:
-            raise XOSProgrammingError("provider service has no slice")
-        slice = slice[0]
-
-        # If slice has default_image set then use it
-        if slice.default_image:
-            return slice.default_image
-
-        raise XOSProgrammingError("Please set a default image for %s" % self.slice.name)
-
-    def save(self, *args, **kwargs):
-        if (not self.creator) and (hasattr(self, "caller")) and (self.caller):
-            self.creator = self.caller
-
-        super(TenantWithContainer, self).save(*args, **kwargs)
