diff --git a/xos/synchronizer/model_policies/model_policy_vegtenant.py b/xos/synchronizer/model_policies/model_policy_vegtenant.py
new file mode 100644
index 0000000..30b7113
--- /dev/null
+++ b/xos/synchronizer/model_policies/model_policy_vegtenant.py
@@ -0,0 +1,193 @@
+# 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 synchronizers.new_base.modelaccessor import *
+from synchronizers.new_base.model_policies.model_policy_tenantwithcontainer import TenantWithContainerPolicy, LeastLoadedNodeScheduler
+from synchronizers.new_base.exceptions import *
+
+class VEGTenantPolicy(TenantWithContainerPolicy):
+    model_name = "VEGTenant"
+
+    def handle_create(self, tenant):
+        return self.handle_update(tenant)
+
+    def handle_update(self, tenant):
+        self.manage_container(tenant)
+        self.manage_address_service_instance(tenant)
+        self.cleanup_orphans(tenant)
+
+    def handle_delete(self, tenant):
+        if tenant.address_service_instance:
+            tenant.address_service_instance.delete()
+
+    def manage_address_service_instance(self, tenant):
+        if tenant.deleted:
+            return
+
+<<<<<<< HEAD:xos/synchronizer/model_policies/model_policy_vegtenant.py
+        if tenant.vrouter is None:
+            vrouter = self.allocate_public_service_instance(address_pool_name="addresses_veg", subscriber_tenant=tenant)
+            vrouter.save()
+
+
+    def cleanup_orphans(self, tenant):
+        # ensure vEG only has one AddressManagerServiceInstance
+        cur_asi = tenant.address_service_instance
+        for link in tenant.subscribed_links.all():
+            # TODO: hardcoded dependency
+            # cast from ServiceInstance to AddressManagerServiceInstance
+            asis = AddressManagerServiceInstance.objects.filter(id = link.provider_service_instance.id)
+            for asi in asis:
+                if (not cur_asi) or (asi.id != cur_asi.id):
+                    asi.delete()
+
+    def get_veg_service(self, tenant):
+        return VEGService.objects.get(id=tenant.owner.id)
+
+    def find_instance_for_s_tag(self, s_tag):
+        tags = Tag.objects.filter(name="s_tag", value=s_tag)
+        if tags:
+            return tags[0].content_object
+
+        return None
+
+    def find_or_make_instance_for_s_tag(self, tenant, s_tag):
+        instance = self.find_instance_for_s_tag(tenant.volt.s_tag)
+        if instance:
+            if instance.no_sync:
+                # if no_sync is still set, then perhaps we failed while saving it and need to retry.
+                self.save_instance(tenant, instance)
+            return instance
+
+        desired_image = self.get_image(tenant)
+
+        flavors = Flavor.objects.filter(name="m1.small")
+        if not flavors:
+            raise SynchronizerConfigurationError("No m1.small flavor")
+
+        slice = tenant.owner.slices.first()
+
+        (node, parent) = LeastLoadedNodeScheduler(slice, label=self.get_veg_service(tenant).node_label).pick()
+
+        assert (slice is not None)
+        assert (node is not None)
+        assert (desired_image is not None)
+        assert (tenant.creator is not None)
+        assert (node.site_deployment.deployment is not None)
+        assert (desired_image is not None)
+
+        instance = Instance(slice=slice,
+                            node=node,
+                            image=desired_image,
+                            creator=tenant.creator,
+                            deployment=node.site_deployment.deployment,
+                            flavor=flavors[0],
+                            isolation=slice.default_isolation,
+                            parent=parent)
+
+        self.save_instance(tenant, instance)
+
+        return instance
+
+    def manage_container(self, tenant):
+        if tenant.deleted:
+            return
+
+        if not tenant.volt:
+            raise SynchronizerConfigurationError("This VEG container has no volt")
+
+        if tenant.instance:
+            # We're good.
+            return
+
+        instance = self.find_or_make_instance_for_s_tag(tenant, tenant.volt.s_tag)
+        tenant.instance = instance
+        # TODO: possible for partial failure here?
+        tenant.save()
+
+    def find_or_make_port(self, instance, network, **kwargs):
+        port = Port.objects.filter(instance_id=instance.id, network_id=network.id)
+        if port:
+            port = port[0]
+        else:
+            port = Port(instance=instance, network=network, **kwargs)
+            port.save()
+        return port
+
+    def get_lan_network(self, tenant, instance):
+        slice = tenant.owner.slices.all()[0]
+        # there should only be one network private network, and its template should not be the management template
+        lan_networks = [x for x in slice.networks.all() if
+                        x.template.visibility == "private" and (not "management" in x.template.name)]
+        if len(lan_networks) > 1:
+            raise SynchronizerProgrammingError("The vEG slice should only have one non-management private network")
+        if not lan_networks:
+            raise SynchronizerProgrammingError("No lan_network")
+        return lan_networks[0]
+
+    def port_set_parameter(self, port, name, value):
+        pt = NetworkParameterType.objects.get(name=name)
+        existing_params = NetworkParameter.objects.filter(parameter_id=pt.id, content_type=port.self_content_type_id, object_id=port.id)
+
+        if existing_params:
+            p = existing_params[0]
+            p.value = str(value)
+            p.save()
+        else:
+            p = NetworkParameter(parameter=pt, content_type=port.self_content_type_id, object_id=port.id, value=str(value))
+            p.save()
+
+    def save_instance(self, tenant, instance):
+        instance.volumes = "/etc/dnsmasq.d,/etc/ufw"
+        instance.no_sync = True   # prevent instance from being synced until we're done with it
+        super(VEGTenantPolicy, self).save_instance(instance)
+        try:
+            if instance.isolation in ["container", "container_vm"]:
+                raise Exception("Not supported")
+
+            if instance.isolation in ["vm"]:
+                lan_network = self.get_lan_network(tenant, instance)
+                port = self.find_or_make_port(instance, lan_network)
+                self.port_set_parameter(port, "c_tag", tenant.volt.c_tag)
+                self.port_set_parameter(port, "s_tag", tenant.volt.s_tag)
+                self.port_set_parameter(port, "neutron_port_name", "stag-%s" % tenant.volt.s_tag)
+                port.save()
+
+            # tag the instance with the s-tag, so we can easily find the
+            # instance later
+            if tenant.volt and tenant.volt.s_tag:
+                tags = Tag.objects.filter(name="s_tag", value=tenant.volt.s_tag)
+                if not tags:
+                    tag = Tag(service=tenant.owner, content_type=instance.self_content_type_id, object_id=instance.id, name="s_tag", value=str(tenant.volt.s_tag))
+                    tag.save()
+
+            # VTN-CORD needs a WAN address for the VM, so that the VM can
+            # be configured.
+            tags = Tag.objects.filter(content_type=instance.self_content_type_id, object_id=instance.id, name="vm_vrouter_tenant")
+            if not tags:
+                address_service_instance = self.allocate_public_service_instance(address_pool_name="addresses_veg",
+                                                                                 subscriber_service=tenant.owner)
+                address_service_instance.set_attribute("tenant_for_instance_id", instance.id)
+                address_service_instance.save()
+                # TODO: potential partial failure
+                tag = Tag(service=tenant.owner, content_type=instance.self_content_type_id, object_id=instance.id, name="vm_vrouter_tenant", value="%d" % address_service_instance.id)
+                tag.save()
+
+            instance.no_sync = False   # allow the synchronizer to run now
+            super(VEGTenantPolicy, self).save_instance(instance)
+        except:
+            # need to clean up any failures here
+            raise
+
+
diff --git a/xos/synchronizer/model_policies/test_config.yaml b/xos/synchronizer/model_policies/test_config.yaml
new file mode 100644
index 0000000..07fe519
--- /dev/null
+++ b/xos/synchronizer/model_policies/test_config.yaml
@@ -0,0 +1,19 @@
+# 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.
+
+name: test-model-policies
+accessor:
+  username: xosadmin@opencord.org
+  password: "sample"
+  kind: "testframework"
diff --git a/xos/synchronizer/model_policies/test_model_policy_vegtenant.py b/xos/synchronizer/model_policies/test_model_policy_vegtenant.py
new file mode 100644
index 0000000..e7d1f4e
--- /dev/null
+++ b/xos/synchronizer/model_policies/test_model_policy_vegtenant.py
@@ -0,0 +1,495 @@
+# 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 unittest
+from mock import patch
+import mock
+
+import os, sys
+sys.path.append("../../..")
+config = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/test_config.yaml")
+from xosconfig import Config
+Config.init(config, 'synchronizer-config-schema.yaml')
+
+import synchronizers.new_base.modelaccessor
+
+import synchronizers.new_base.model_policies.model_policy_tenantwithcontainer
+import model_policy_vegtenant
+from model_policy_vegtenant import VEGTenantPolicy
+from synchronizers.new_base.model_policies.model_policy_tenantwithcontainer import LeastLoadedNodeScheduler
+
+MockObjectStores = {}
+
+class MockObjectList:
+    item_list = None
+
+    def __init__(self, initial=None):
+        self.id_counter = 0
+        if initial:
+            self.item_list=initial
+        elif self.item_list is None:
+            self.item_list=[]
+
+    def get_items(self):
+        return self.item_list
+
+    def count(self):
+        return len(self.get_items())
+
+    def first(self):
+        return self.get_items()[0]
+
+    def all(self):
+        return self.get_items()
+
+    def filter(self, **kwargs):
+        items = self.get_items()
+        for (k,v) in kwargs.items():
+            items = [x for x in items if getattr(x,k) == v]
+        return items
+
+    def get(self, **kwargs):
+        objs = self.filter(**kwargs)
+        if not objs:
+            raise Exception("No objects matching %s" % str(kwargs))
+        return objs[0]
+
+class MockObjectStore(MockObjectList):
+    def save(self, o):
+        if (not hasattr(o,"id")) or (not o.id):
+            for item in self.get_items():
+                if item.id >= self.id_counter:
+                    self.id_counter = item.id + 1
+
+            o.id = self.id_counter
+            self.id_counter = self.id_counter + 1
+
+        for item in self.get_items():
+            if item.id == o.id:
+                item = o
+                break
+        else:
+            self.get_items().append(o)
+
+class MockObject(object):
+    objects = None
+    id = None
+    def __init__(self, **kwargs):
+        for (k,v) in kwargs.items():
+            setattr(self,k,v)
+    @property
+    def self_content_type_id(self):
+        return self.__class__.__name__
+    def save(self):
+        if self.objects:
+            self.objects.save(self)
+    def delete(self):
+        pass
+
+def get_MockObjectStore(x):
+    return globals()["Mock%sObjects" % x]()
+
+class MockFlavorObjects(MockObjectStore): pass
+class MockFlavor(MockObject):
+    objects = get_MockObjectStore("Flavor")
+    name = None
+
+class MockInstanceObjects(MockObjectStore): pass
+class MockInstance(MockObject):
+    objects = get_MockObjectStore("Instance")
+    name = None
+
+class MockDeploymentObjects(MockObjectStore): pass
+class MockDeployment(MockObject):
+    objects = get_MockObjectStore("Deployment")
+    name = None
+
+class MockUserObjects(MockObjectStore): pass
+class MockUser(MockObject):
+    objects = get_MockObjectStore("User")
+    email = None
+
+class MockSliceObjects(MockObjectStore): pass
+class MockSlice(MockObject):
+    objects = get_MockObjectStore("Slice")
+    name = None
+    default_node = None
+    networks = None
+
+class MockNodeObjects(MockObjectStore): pass
+class MockNode(MockObject):
+    objects = get_MockObjectStore("Node")
+    hostname = None
+    site_deployment = None
+
+class MockImageObjects(MockObjectStore): pass
+class MockImage(MockObject):
+    objects = get_MockObjectStore("Image")
+    name = None
+
+class MockTagObjects(MockObjectStore): pass
+class MockTag(MockObject):
+    objects = get_MockObjectStore("Tag")
+    name = None
+    value = None
+
+class MockNetworkTemplateObjects(MockObjectStore): pass
+class MockNetworkTemplate(MockObject):
+    objects = get_MockObjectStore("NetworkTemplate")
+    name = None
+    visibility = None
+
+class MockNetworkParameterTypeObjects(MockObjectStore): pass
+class MockNetworkParameterType(MockObject):
+    objects = get_MockObjectStore("NetworkParameterType")
+    name = None
+
+class MockNetworkParameterObjects(MockObjectStore): pass
+class MockNetworkParameter(MockObject):
+    objects = get_MockObjectStore("NetworkParameter")
+    value = None
+    parameter_id = None
+
+class MockNetworkObjects(MockObjectStore): pass
+class MockNetwork(MockObject):
+    objects = get_MockObjectStore("Network")
+    name = None
+    template = None
+
+class MockPortObjects(MockObjectStore): pass
+class MockPort(MockObject):
+    objects = get_MockObjectStore("Port")
+    name = None
+    def set_parameter(self, name, value):
+        pass
+
+class MockAddressManagerServiceInstanceObjects(MockObjectStore): pass
+class MockAddressManagerServiceInstance(MockObject):
+    objects = get_MockObjectStore("AddressManagerServiceInstance")
+    public_ip = None
+    public_mac = None
+    address_pool_id = None
+    def set_attribute(self, name, value):
+        pass
+
+class MockVoltTenantObjects(MockObjectStore): pass
+class MockVoltTenant(MockObject):
+    objects = get_MockObjectStore("VoltTenant")
+    c_tag = None
+    s_tag = None
+
+class MockVEGServiceObjects(MockObjectStore): pass
+class MockVEGService(MockObject):
+    objects = get_MockObjectStore("VEGService")
+    name = None
+    node_label = None
+    slices = None
+    def __init__(self, **kwargs):
+        super(MockVEGService, self).__init__(**kwargs)
+
+class MockVEGTenantObjects(MockObjectStore): pass
+class MockVEGTenant(MockObject):
+    objects = get_MockObjectStore("VEGTenant")
+    owner = None
+    deleted = False
+    instance = None
+    creator = None
+    volt = None
+    service_specific_attribute = {}
+
+    def get_image(self):
+        return None
+
+class TestModelPolicyVegTenant(unittest.TestCase):
+    def setUp(self):
+        self.policy = VEGTenantPolicy()
+        self.tenant = MockVEGTenant()
+        self.user = MockUser(email="testadmin@test.org")
+        self.tenant = MockVEGTenant(creator=self.user, id=1)
+        self.flavor = MockFlavor(name="m1.small")
+        self.npt_ctag = MockNetworkParameterType(name="c_tag", id=1)
+        self.npt_stag = MockNetworkParameterType(name="s_tag", id=2)
+        self.npt_neutron_port_name = MockNetworkParameterType(name="neutron_port_name", id=3)
+        self.node = MockNode(hostname="my.node.com")
+        self.slice = MockSlice(name="mysite_test1", default_flavor=self.flavor, default_isolation="vm")
+        self.priv_template = MockNetworkTemplate(name="access_network", visibility="private")
+        self.priv_network = MockNetwork(name="mysite_test1_private", template=self.priv_template)
+        self.image = MockImage(name="trusty-server-multi-nic")
+        self.deployment = MockDeployment(name="testdeployment")
+        synchronizers.new_base.model_policies.model_policy_tenantwithcontainer.Instance = MockInstance
+        synchronizers.new_base.model_policies.model_policy_tenantwithcontainer.Flavor = MockFlavor
+        synchronizers.new_base.model_policies.model_policy_tenantwithcontainer.Tag = MockTag
+        synchronizers.new_base.model_policies.model_policy_tenantwithcontainer.Node = MockNode
+        model_policy_vegtenant.Instance = MockInstance
+        model_policy_vegtenant.Flavor = MockFlavor
+        model_policy_vegtenant.Tag = MockTag
+        model_policy_vegtenant.VEGService = MockVEGService
+        model_policy_vegtenant.Node = MockNode
+        model_policy_vegtenant.Port = MockPort
+        model_policy_vegtenant.NetworkParameterType = MockNetworkParameterType
+        model_policy_vegtenant.NetworkParameter = MockNetworkParameter
+
+    @patch.object(VEGTenantPolicy, "manage_container")
+    @patch.object(VEGTenantPolicy, "manage_address_service_instance")
+    @patch.object(VEGTenantPolicy, "cleanup_orphans")
+    def test_handle_create(self, cleanup_orphans, manage_address_service_instance, manage_container):
+        self.policy.handle_create(self.tenant)
+        manage_container.assert_called_with(self.tenant)
+        manage_address_service_instance.assert_called_with(self.tenant)
+        cleanup_orphans.assert_called_with(self.tenant)
+
+    @patch.object(VEGTenantPolicy, "manage_container")
+    @patch.object(VEGTenantPolicy, "manage_address_service_instance")
+    @patch.object(VEGTenantPolicy, "cleanup_orphans")
+    def test_handle_update(self, cleanup_orphans, manage_address_service_instance, manage_container):
+        self.policy.handle_create(self.tenant)
+        manage_container.assert_called_with(self.tenant)
+        manage_address_service_instance.assert_called_with(self.tenant)
+        cleanup_orphans.assert_called_with(self.tenant)
+
+    @patch.object(MockAddressManagerServiceInstance, "delete")
+    def test_handle_delete_asi_exist(self, amsi_delete):
+        vrtenant = MockAddressManagerServiceInstance()
+        self.tenant.address_service_instance = vrtenant
+        self.policy.handle_delete(self.tenant)
+        amsi_delete.assert_called()
+
+    @patch.object(MockAddressManagerServiceInstance, "delete")
+    def test_handle_delete_asi_noexist(self, amsi_delete):
+        self.tenant.address_service_instance = None
+        self.policy.handle_delete(self.tenant)
+        amsi_delete.assert_not_called()
+
+    @patch.object(MockAddressManagerServiceInstanceObjects, "get_items")
+    @patch.object(MockAddressManagerServiceInstance, "delete")
+    def test_cleanup_orphans(self, amsi_delete, amsi_objects):
+        vrtenant = MockAddressManagerServiceInstance(id=1)
+        self.tenant.address_service_instance = vrtenant
+        some_other_vrtenant = MockAddressManagerServiceInstance(id=2, subscriber_tenant_id = self.tenant.id)
+        amsi_objects.get_items = [some_other_vrtenant]
+        self.policy.handle_delete(self.tenant)
+        amsi_delete.assert_called()
+
+    @patch.object(MockTag, "objects")
+    def test_find_instance_for_s_tag_noexist(self, tag_objects):
+        tag_objects.filter.return_value = []
+        instance = self.policy.find_instance_for_s_tag(3)
+        self.assertEqual(instance, None)
+
+    @patch.object(MockTag, "objects")
+    def test_find_instance_for_s_tag(self, tag_objects):
+        tagged_instance = MockInstance()
+        tag = MockTag(content_object = tagged_instance)
+        tag_objects.filter.return_value = [tag]
+        instance = self.policy.find_instance_for_s_tag(3)
+        self.assertEqual(instance, tagged_instance)
+
+    def test_manage_container_no_volt(self):
+        with self.assertRaises(Exception) as e:
+            self.policy.manage_container(self.tenant)
+        self.assertEqual(e.exception.message, "This VEG container has no volt")
+
+    @patch.object(VEGTenantPolicy, "find_or_make_instance_for_s_tag")
+    @patch.object(MockVEGTenant, "save")
+    @patch.object(MockVEGTenant, "volt")
+    def test_manage_container_noinstance(self, volt, tenant_save, find_or_make_instance_for_s_tag):
+        instance = MockInstance()
+        volt.s_tag=222
+        volt.c_tag=111
+        find_or_make_instance_for_s_tag.return_value = instance
+        self.policy.manage_container(self.tenant)
+        self.assertEqual(self.tenant.instance, instance)
+        tenant_save.assert_called()
+
+    @patch.object(VEGTenantPolicy, "find_or_make_instance_for_s_tag")
+    @patch.object(MockVEGTenant, "save")
+    @patch.object(MockVEGTenant, "volt")
+    def test_manage_container_hasinstance(self, volt, tenant_save, find_or_make_instance_for_s_tag):
+        instance = MockInstance()
+        volt.s_tag=222
+        volt.c_tag=111
+        self.tenant.instance = instance
+        self.policy.manage_container(self.tenant)
+        find_or_make_instance_for_s_tag.assert_not_called()
+        self.assertEqual(self.tenant.instance, instance)
+        tenant_save.assert_not_called()
+
+    @patch.object(VEGTenantPolicy, "find_or_make_instance_for_s_tag")
+    @patch.object(MockVEGTenant, "save")
+    @patch.object(MockVEGTenant, "volt")
+    def test_manage_container_deleted(self, volt, tenant_save, find_or_make_instance_for_s_tag):
+        self.tenant.deleted = True
+        self.policy.manage_container(self.tenant)
+        find_or_make_instance_for_s_tag.assert_not_called()
+        tenant_save.assert_not_called()
+
+    @patch.object(MockPort, "save")
+    @patch.object(MockPort, "objects")
+    def test_find_or_make_port_noexist(self, port_objects, port_save):
+        instance = MockInstance(id=123)
+        network = MockInstance(id=456)
+        port_objects.filter.return_value = []
+        port=self.policy.find_or_make_port(instance, network)
+        self.assertNotEqual(port, None)
+        port_save.assert_called()
+
+    @patch.object(MockPort, "save")
+    @patch.object(MockPort, "objects")
+    def test_find_or_make_port_exists(self, port_objects, port_save):
+        someport = MockPort()
+        def mock_port_filter(network_id, instance_id):
+            if (network_id==456) and (instance_id==123):
+                return [someport]
+            return None
+        instance = MockInstance(id=123)
+        network = MockInstance(id=456)
+        port_objects.filter.side_effect = mock_port_filter
+        port=self.policy.find_or_make_port(instance, network)
+        self.assertEqual(port, someport)
+        port_save.assert_not_called()
+
+    @patch.object(MockVEGServiceObjects, "get_items")
+    def test_get_lan_network_noexist(self, vegservice_objects):
+        vegservice=MockVEGService(name="myvegservice", id=1, slices=MockObjectList(initial=[self.slice]))
+        vegservice_objects.return_value = [vegservice]
+        self.tenant.owner = vegservice
+        self.slice.networks = MockObjectList()
+        with self.assertRaises(Exception) as e:
+            self.policy.get_lan_network(self.tenant, None)
+        self.assertEqual(e.exception.message, "No lan_network")
+
+    @patch.object(MockVEGServiceObjects, "get_items")
+    def test_get_lan_network(self, vegservice_objects):
+        vegservice=MockVEGService(name="myvegservice", id=1, slices=MockObjectList(initial=[self.slice]))
+        vegservice_objects.return_value = [vegservice]
+        self.tenant.owner = vegservice
+        self.slice.networks = MockObjectList([self.priv_network])
+        lan_network = self.policy.get_lan_network(self.tenant, None)
+        self.assertEqual(lan_network, self.priv_network)
+
+    @patch.object(MockVEGServiceObjects, "get_items")
+    def test_get_lan_network_toomany(self, vegservice_objects):
+        some_other_network = MockNetwork(name="mysite_test1_private", template=self.priv_template)
+        vegservice=MockVEGService(name="myvegservice", id=1, slices=MockObjectList(initial=[self.slice]))
+        vegservice_objects.return_value = [vegservice]
+        self.tenant.owner = vegservice
+        self.slice.networks = MockObjectList([self.priv_network, some_other_network])
+        with self.assertRaises(Exception) as e:
+            lan_network = self.policy.get_lan_network(self.tenant, None)
+        self.assertEqual(e.exception.message, "The vEG slice should only have one non-management private network")
+
+    @patch.object(MockNetworkParameterTypeObjects, "get_items")
+    def test_port_set_parameter_noparamexist(self, npt_objects):
+        npt_objects.return_value = [self.npt_stag]
+        port = MockPort()
+        self.policy.port_set_parameter(port, "s_tag", "123")
+        self.assertNotEqual(MockNetworkParameter.objects.all(), [])
+        param = MockNetworkParameter.objects.first()
+        self.assertEqual(param.value, "123")
+        self.assertEqual(param.parameter, self.npt_stag)
+
+    @patch.object(MockNetworkParameterTypeObjects, "get_items")
+    @patch.object(MockNetworkParameterObjects, "get_items")
+    def test_port_set_parameter_paramexist(self, np_objects, npt_objects):
+        port = MockPort(id=1)
+        np_orig = MockNetworkParameter(parameter_id=self.npt_stag.id, value="456", object_id=port.id, content_type=port.self_content_type_id)
+        np_objects.return_value = [np_orig]
+        npt_objects.return_value = [self.npt_stag]
+        self.policy.port_set_parameter(port, "s_tag", "123")
+        self.assertEqual(MockNetworkParameter.objects.count(), 1)
+        param = MockNetworkParameter.objects.first()
+        self.assertEqual(param.value, "123")
+
+    @patch.object(MockNetworkParameterTypeObjects, "get_items")
+    @patch.object(MockNodeObjects, "get_items")
+    @patch.object(MockFlavorObjects, "get_items")
+    @patch.object(MockVEGServiceObjects, "get_items")
+    @patch.object(MockVEGTenant, "volt")
+    @patch.object(MockVEGTenant, "save")
+    @patch.object(VEGTenantPolicy, "get_image")
+    @patch.object(VEGTenantPolicy, "allocate_public_service_instance")
+    @patch.object(LeastLoadedNodeScheduler, "pick")
+    @patch.object(MockNode, "site_deployment")
+    @patch.object(MockInstance, "save")
+    @patch.object(MockInstance, "delete")
+    @patch.object(VEGTenantPolicy, "port_set_parameter")
+    def test_find_or_make_instance_for_s_tag(self, port_set_parameter, instance_delete, instance_save, site_deployment,
+                              pick, get_psi, get_image, tenant_save, volt,
+                              vegservice_objects, flavor_objects, node_objects, npt_objects):
+        # setup mocks
+        vrtenant = MockAddressManagerServiceInstance(public_ip="1.2.3.4", public_mac="01:02:03:04:05:06")
+        vegservice=MockVEGService(name="myvegservice", id=1, slices=MockObjectList(initial=[self.slice]))
+        vegservice_objects.return_value = [vegservice]
+        self.tenant.owner = vegservice
+        volt.s_tag=222
+        volt.c_tag=111
+        get_image.return_value = self.image
+        get_psi.return_value = vrtenant
+        pick.return_value = (self.node, None)
+        site_deployment.deployment = self.deployment
+        flavor_objects.return_value=[self.flavor]
+        node_objects.return_value=[self.node]
+        npt_objects.return_value=[self.npt_stag, self.npt_ctag, self.npt_neutron_port_name]
+        self.slice.networks = MockObjectList([self.priv_network])
+        # done setup mocks
+
+        # call the function under test
+        instance = self.policy.find_or_make_instance_for_s_tag(self.tenant, self.tenant.volt.s_tag)
+
+        # make sure Instance was created
+        self.assertNotEqual(instance, None)
+        self.assertEqual(instance.creator.email, "testadmin@test.org")
+        self.assertEqual(instance.image.name, "trusty-server-multi-nic")
+        self.assertEqual(instance.flavor.name, "m1.small")
+        self.assertEqual(instance.isolation, "vm")
+        self.assertEqual(instance.node.hostname, "my.node.com")
+        self.assertEqual(instance.slice.name, "mysite_test1")
+        self.assertEqual(instance.parent, None)
+        instance_save.assert_called()
+        instance_delete.assert_not_called()
+
+        # Access Network Port should have tags to c-tag and s-tag
+        port = MockPort.objects.first()
+        self.assertEqual(port.instance, instance)
+        self.assertEqual(port.network, self.priv_network)
+        port_set_parameter.assert_has_calls([mock.call(port, "c_tag", 111),
+                                             mock.call(port, "s_tag", 222),
+                                             mock.call(port, "neutron_port_name", "stag-222")])
+
+        # The instance should be tagged with the s-tag
+        tag = MockTag.objects.get(name="s_tag")
+        self.assertEqual(tag.value, "222")
+        self.assertEqual(tag.object_id, instance.id)
+
+        # The instance should have a tag pointing to its address_service_instance
+        tag = MockTag.objects.get(name="vm_vrouter_tenant")
+        self.assertNotEqual(tag.value, vrtenant.id)
+        self.assertEqual(tag.object_id, instance.id)
+
+        # Allocate_public_service_instance should have been called
+        get_psi.assert_called()
+
+    @patch.object(VEGTenantPolicy, "allocate_public_service_instance")
+    def test_manage_address_service_instance(self, get_psi):
+        vrtenant = MockAddressManagerServiceInstance(public_ip="1.2.3.4", public_mac="01:02:03:04:05:06")
+        get_psi.return_value = vrtenant
+
+        self.tenant.address_service_instance = None
+
+        self.policy.manage_address_service_instance(self.tenant)
+
+        get_psi.assert_called_with(address_pool_name="addresses_veg", subscriber_tenant=self.tenant)
+
+if __name__ == '__main__':
+    unittest.main()
+
