CORD-1908: cleanup VSG service

Change-Id: Ib7fa0a68dbba185b30d7cd1ea1b425ad3d33a8d3
diff --git a/xos/synchronizer/model_policies/model_policy_vsgtenant.py b/xos/synchronizer/model_policies/model_policy_vsgserviceinstance.py
similarity index 62%
rename from xos/synchronizer/model_policies/model_policy_vsgtenant.py
rename to xos/synchronizer/model_policies/model_policy_vsgserviceinstance.py
index 33b8877..e5a0562 100644
--- a/xos/synchronizer/model_policies/model_policy_vsgtenant.py
+++ b/xos/synchronizer/model_policies/model_policy_vsgserviceinstance.py
@@ -18,56 +18,56 @@
 from synchronizers.new_base.model_policies.model_policy_tenantwithcontainer import TenantWithContainerPolicy, LeastLoadedNodeScheduler
 from synchronizers.new_base.exceptions import *
 
-class VSGTenantPolicy(TenantWithContainerPolicy):
-    model_name = "VSGTenant"
+class VSGServiceInstancePolicy(TenantWithContainerPolicy):
+    model_name = "VSGServiceInstance"
 
-    def handle_create(self, tenant):
-        return self.handle_update(tenant)
+    def handle_create(self, service_instance):
+        return self.handle_update(service_instance)
 
-    def handle_update(self, tenant):
-        if (tenant.link_deleted_count>0) and (not tenant.provided_links.exists()):
+    def handle_update(self, service_instance):
+        if (service_instance.link_deleted_count>0) and (not service_instance.provided_links.exists()):
             # if the last provided_link has just gone away, then self-destruct
-            self.logger.info("The last provided link has been deleted -- self-destructing.");
+            self.logger.info("The last provided link has been deleted -- self-destructing.")
             # TODO: We shouldn't have to call handle_delete ourselves. The model policy framework should handle this
-            #       for us, but it isn't. I think that's happening is that tenant.delete() isn't setting a new
+            #       for us, but it isn't. I think that's happening is that serviceinstance.delete() isn't setting a new
             #       updated timestamp, since there's no way to pass `always_update_timestamp`, and therefore the
             #       policy framework doesn't know that the object has changed and needs new policies. For now, the
             #       workaround is to just call handle_delete ourselves.
-            self.handle_delete(tenant)
-            # Note that if we deleted the Instance in handle_delete, then django may have cascade-deleted the tenant
-            # by now. Thus we have to guard our delete, to check that the tenant still exists.
-            if VSGTenant.objects.filter(id=tenant.id).exists():
-                tenant.delete()
+            self.handle_delete(service_instance)
+            # Note that if we deleted the Instance in handle_delete, then django may have cascade-deleted the service
+            # instance by now. Thus we have to guard our delete, to check that the service instance still exists.
+            if VSGServiceInstance.objects.filter(id=service_instance.id).exists():
+                service_instance.delete()
             else:
-                self.logger.info("Tenant %s is already deleted" % tenant)
+                self.logger.info("Tenant %s is already deleted" % service_instance)
             return
 
-        self.manage_container(tenant)
-        self.manage_address_service_instance(tenant)
-        self.cleanup_orphans(tenant)
+        self.manage_container(service_instance)
+        self.manage_address_service_instance(service_instance)
+        self.cleanup_orphans(service_instance)
 
-    def handle_delete(self, tenant):
-        if tenant.instance and (not tenant.instance.deleted):
-            all_tenants_this_instance = VSGTenant.objects.filter(instance_id=tenant.instance.id)
-            other_tenants_this_instance = [x for x in all_tenants_this_instance if x.id != tenant.id]
-            if (not other_tenants_this_instance):
-                self.logger.info("VSG Instance %s is now unused -- deleting" % tenant.instance)
-                self.delete_instance(tenant, tenant.instance)
+    def handle_delete(self, service_instance):
+        if service_instance.instance and (not service_instance.instance.deleted):
+            all_service_instances_this_instance = VSGServiceInstance.objects.filter(instance_id=service_instance.instance.id)
+            other_service_instances_this_instance = [x for x in all_service_instances_this_instance if x.id != service_instance.id]
+            if (not other_service_instances_this_instance):
+                self.logger.info("VSG Instance %s is now unused -- deleting" % service_instance.instance)
+                self.delete_instance(service_instance, service_instance.instance)
             else:
-                self.logger.info("VSG Instance %s has %d other service instances attached" % (tenant.instance, len(other_tenants_this_instance)))
+                self.logger.info("VSG Instance %s has %d other service instances attached" % (service_instance.instance, len(other_service_instances_this_instance)))
 
-    def manage_address_service_instance(self, tenant):
-        if tenant.deleted:
+    def manage_address_service_instance(self, service_instance):
+        if service_instance.deleted:
             return
 
-        if tenant.address_service_instance is None:
-            address_service_instance = self.allocate_public_service_instance(address_pool_name="addresses_vsg", subscriber_tenant=tenant)
+        if service_instance.address_service_instance is None:
+            address_service_instance = self.allocate_public_service_instance(address_pool_name="addresses_vsg", subscriber_tenant=service_instance)
             address_service_instance.save()
 
-    def cleanup_orphans(self, tenant):
+    def cleanup_orphans(self, service_instance):
         # ensure vSG only has one AddressManagerServiceInstance
-        cur_asi = tenant.address_service_instance
-        for link in tenant.subscribed_links.all():
+        cur_asi = service_instance.address_service_instance
+        for link in service_instance.subscribed_links.all():
             # TODO: hardcoded dependency
             # cast from ServiceInstance to AddressManagerServiceInstance
             asis = AddressManagerServiceInstance.objects.filter(id = link.provider_service_instance.id)
@@ -75,8 +75,8 @@
                 if (not cur_asi) or (asi.id != cur_asi.id):
                     asi.delete()
 
-    def get_vsg_service(self, tenant):
-        return VSGService.objects.get(id=tenant.owner.id)
+    def get_vsg_service(self, service_instance):
+        return VSGService.objects.get(id=service_instance.owner.id)
 
     def find_instance_for_s_tag(self, s_tag):
         tags = Tag.objects.filter(name="s_tag", value=s_tag)
@@ -85,59 +85,59 @@
 
         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)
+    def find_or_make_instance_for_s_tag(self, service_instance):
+        instance = self.find_instance_for_s_tag(service_instance.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)
+                self.save_instance(service_instance, instance)
             return instance
 
-        desired_image = self.get_image(tenant)
+        desired_image = self.get_image(service_instance)
 
         flavors = Flavor.objects.filter(name="m1.small")
         if not flavors:
             raise SynchronizerConfigurationError("No m1.small flavor")
 
-        slice = tenant.owner.slices.first()
+        slice = service_instance.owner.slices.first()
 
-        (node, parent) = LeastLoadedNodeScheduler(slice, label=self.get_vsg_service(tenant).node_label).pick()
+        (node, parent) = LeastLoadedNodeScheduler(slice, label=self.get_vsg_service(service_instance).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 (service_instance.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,
+                            creator=service_instance.creator,
                             deployment=node.site_deployment.deployment,
                             flavor=flavors[0],
                             isolation=slice.default_isolation,
                             parent=parent)
 
-        self.save_instance(tenant, instance)
+        self.save_instance(service_instance, instance)
 
         return instance
 
-    def manage_container(self, tenant):
-        if tenant.deleted:
+    def manage_container(self, service_instance):
+        if service_instance.deleted:
             return
 
-        if not tenant.volt:
+        if not service_instance.volt:
             raise SynchronizerConfigurationError("This VSG container has no volt")
 
-        if tenant.instance:
+        if service_instance.instance:
             # We're good.
             return
 
-        instance = self.find_or_make_instance_for_s_tag(tenant, tenant.volt.s_tag)
-        tenant.instance = instance
+        instance = self.find_or_make_instance_for_s_tag(service_instance)
+        service_instance.instance = instance
         # TODO: possible for partial failure here?
-        tenant.save()
+        service_instance.save()
 
     def find_or_make_port(self, instance, network, **kwargs):
         port = Port.objects.filter(instance_id=instance.id, network_id=network.id)
@@ -148,8 +148,8 @@
             port.save()
         return port
 
-    def get_lan_network(self, tenant, instance):
-        slice = tenant.owner.slices.all()[0]
+    def get_lan_network(self, service_instance, instance):
+        slice = service_instance.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)]
@@ -171,9 +171,9 @@
             p = NetworkParameter(parameter=pt, content_type=port.self_content_type_id, object_id=port.id, value=str(value))
             p.save()
 
-    def delete_instance(self, tenant, instance):
+    def delete_instance(self, service_instance, instance):
         # delete the `s_tag` tags
-        tags = Tag.objects.filter(service_id=tenant.owner.id, content_type=instance.self_content_type_id,
+        tags = Tag.objects.filter(service_id=service_instance.owner.id, content_type=instance.self_content_type_id,
                                   object_id=instance.id, name="s_tag")
         for tag in tags:
             tag.delete()
@@ -192,28 +192,28 @@
 
         instance.delete()
 
-    def save_instance(self, tenant, instance):
+    def save_instance(self, service_instance, instance):
         instance.volumes = "/etc/dnsmasq.d,/etc/ufw"
         instance.no_sync = True   # prevent instance from being synced until we're done with it
-        super(VSGTenantPolicy, self).save_instance(instance)
+        super(VSGServiceInstancePolicy, 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)
+                lan_network = self.get_lan_network(service_instance, 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)
+                self.port_set_parameter(port, "c_tag", service_instance.volt.c_tag)
+                self.port_set_parameter(port, "s_tag", service_instance.volt.s_tag)
+                self.port_set_parameter(port, "neutron_port_name", "stag-%s" % service_instance.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 service_instance.volt and service_instance.volt.s_tag:
+                tags = Tag.objects.filter(name="s_tag", value=service_instance.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 = Tag(service=service_instance.owner, content_type=instance.self_content_type_id, object_id=instance.id, name="s_tag", value=str(service_instance.volt.s_tag))
                     tag.save()
 
             # VTN-CORD needs a WAN address for the VM, so that the VM can
@@ -221,15 +221,15 @@
             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_vsg",
-                                                                                 subscriber_service=tenant.owner)
+                                                                                 subscriber_service=service_instance.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 = Tag(service=service_instance.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(VSGTenantPolicy, self).save_instance(instance)
+            super(VSGServiceInstancePolicy, self).save_instance(instance)
         except:
             # need to clean up any failures here
             raise
diff --git a/xos/synchronizer/model_policies/test_model_policy_vsgtenant.py b/xos/synchronizer/model_policies/test_model_policy_vsgserviceinstance.py
similarity index 87%
rename from xos/synchronizer/model_policies/test_model_policy_vsgtenant.py
rename to xos/synchronizer/model_policies/test_model_policy_vsgserviceinstance.py
index 4fb4542..365604a 100644
--- a/xos/synchronizer/model_policies/test_model_policy_vsgtenant.py
+++ b/xos/synchronizer/model_policies/test_model_policy_vsgserviceinstance.py
@@ -27,8 +27,8 @@
 import synchronizers.new_base.modelaccessor
 
 import synchronizers.new_base.model_policies.model_policy_tenantwithcontainer
-import model_policy_vsgtenant
-from model_policy_vsgtenant import VSGTenantPolicy
+import model_policy_vsgserviceinstance
+from model_policy_vsgserviceinstance import VSGServiceInstancePolicy
 from synchronizers.new_base.model_policies.model_policy_tenantwithcontainer import LeastLoadedNodeScheduler
 
 # ---------------------------------------------------------------------------------------------------------------------
@@ -227,9 +227,9 @@
     def __init__(self, **kwargs):
         super(MockVSGService, self).__init__(**kwargs)
 
-class MockVSGTenantObjects(MockObjectStore): pass
-class MockVSGTenant(MockObject):
-    objects = get_MockObjectStore("VSGTenant")
+class MockVSGServiceInstanceObjects(MockObjectStore): pass
+class MockVSGServiceInstance(MockObject):
+    objects = get_MockObjectStore("VSGServiceInstance")
     owner = None
     deleted = False
     instance = None
@@ -247,15 +247,15 @@
 
 class TestModelPolicyVsgTenant(unittest.TestCase):
     def setUp(self):
-        # Some of the functions we call have side-effects. For example, creating a VSGTenant may lead to creation of
+        # Some of the functions we call have side-effects. For example, creating a VSGServiceInstance may lead to creation of
         # tags. Ideally, this wouldn't happen, but it does. So make sure we reset the world.
         for store in AllMockObjectStores:
             store.items = []
 
-        self.policy = VSGTenantPolicy()
-        self.tenant = MockVSGTenant()
+        self.policy = VSGServiceInstancePolicy()
+        self.tenant = MockVSGServiceInstance()
         self.user = MockUser(email="testadmin@test.org")
-        self.tenant = MockVSGTenant(creator=self.user, id=1)
+        self.tenant = MockVSGServiceInstance(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)
@@ -270,32 +270,32 @@
         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_vsgtenant.Instance = MockInstance
-        model_policy_vsgtenant.Flavor = MockFlavor
-        model_policy_vsgtenant.Tag = MockTag
-        model_policy_vsgtenant.VSGService = MockVSGService
-        model_policy_vsgtenant.VSGTenant = MockVSGTenant
-        model_policy_vsgtenant.Node = MockNode
-        model_policy_vsgtenant.Port = MockPort
-        model_policy_vsgtenant.NetworkParameterType = MockNetworkParameterType
-        model_policy_vsgtenant.NetworkParameter = MockNetworkParameter
-        model_policy_vsgtenant.ServiceInstance = MockServiceInstance
-        model_policy_vsgtenant.AddressManagerServiceInstance = MockAddressManagerServiceInstance
+        model_policy_vsgserviceinstance.Instance = MockInstance
+        model_policy_vsgserviceinstance.Flavor = MockFlavor
+        model_policy_vsgserviceinstance.Tag = MockTag
+        model_policy_vsgserviceinstance.VSGService = MockVSGService
+        model_policy_vsgserviceinstance.VSGServiceInstance = MockVSGServiceInstance
+        model_policy_vsgserviceinstance.Node = MockNode
+        model_policy_vsgserviceinstance.Port = MockPort
+        model_policy_vsgserviceinstance.NetworkParameterType = MockNetworkParameterType
+        model_policy_vsgserviceinstance.NetworkParameter = MockNetworkParameter
+        model_policy_vsgserviceinstance.ServiceInstance = MockServiceInstance
+        model_policy_vsgserviceinstance.AddressManagerServiceInstance = MockAddressManagerServiceInstance
 
         MockTag.objects.item_list = []
 
-    @patch.object(VSGTenantPolicy, "manage_container")
-    @patch.object(VSGTenantPolicy, "manage_address_service_instance")
-    @patch.object(VSGTenantPolicy, "cleanup_orphans")
+    @patch.object(VSGServiceInstancePolicy, "manage_container")
+    @patch.object(VSGServiceInstancePolicy, "manage_address_service_instance")
+    @patch.object(VSGServiceInstancePolicy, "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(VSGTenantPolicy, "manage_container")
-    @patch.object(VSGTenantPolicy, "manage_address_service_instance")
-    @patch.object(VSGTenantPolicy, "cleanup_orphans")
+    @patch.object(VSGServiceInstancePolicy, "manage_container")
+    @patch.object(VSGServiceInstancePolicy, "manage_address_service_instance")
+    @patch.object(VSGServiceInstancePolicy, "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)
@@ -317,10 +317,10 @@
         self.policy.handle_delete(self.tenant)
         amsi_delete.assert_not_called()
 
-    @patch.object(MockVSGTenantObjects, "get_items")
+    @patch.object(MockVSGServiceInstanceObjects, "get_items")
     @patch.object(MockInstanceObjects, "get_items")
     @patch.object(MockInstance, "delete")
-    def test_handle_delete_cleanup_instance(self, instance_delete, instance_objects, vsgtenant_objects):
+    def test_handle_delete_cleanup_instance(self, instance_delete, instance_objects, vsgserviceinstance_objects):
         vsg_service = MockVSGService()
         instance = MockInstance(id=1)
         instance_objects.return_value = [instance]
@@ -328,14 +328,14 @@
         self.tenant.instance = instance
         self.tenant.instance_id = instance.id
         self.tenant.owner = vsg_service
-        vsgtenant_objects.return_value = [self.tenant]
+        vsgserviceinstance_objects.return_value = [self.tenant]
         self.policy.handle_delete(self.tenant)
         instance_delete.assert_called()
 
-    @patch.object(MockVSGTenantObjects, "get_items")
+    @patch.object(MockVSGServiceInstanceObjects, "get_items")
     @patch.object(MockInstanceObjects, "get_items")
     @patch.object(MockInstance, "delete")
-    def test_handle_delete_cleanup_instance_live(self, instance_delete, instance_objects, vsgtenant_objects):
+    def test_handle_delete_cleanup_instance_live(self, instance_delete, instance_objects, vsgserviceinstance_objects):
         # Make sure if an Instance still has active VSG Tenants, that we don't clean it up
         vsg_service = MockVSGService()
         instance = MockInstance(id=1)
@@ -345,13 +345,13 @@
         self.tenant.instance_id = instance.id
         self.tenant.owner = vsg_service
 
-        other_tenant = MockVSGTenant()
+        other_tenant = MockVSGServiceInstance()
         other_tenant.address_service_instance = None
         other_tenant.instance = instance
         other_tenant.instance_id = instance.id
         other_tenant.owner = vsg_service
 
-        vsgtenant_objects.return_value = [self.tenant, other_tenant]
+        vsgserviceinstance_objects.return_value = [self.tenant, other_tenant]
 
         self.policy.handle_delete(self.tenant)
         instance_delete.assert_not_called()
@@ -359,13 +359,13 @@
     @patch.object(MockServiceInstanceObjects, "get_items")
     @patch.object(MockAddressManagerServiceInstanceObjects, "get_items")
     @patch.object(MockTagObjects, "get_items")
-    @patch.object(MockVSGTenantObjects, "get_items")
+    @patch.object(MockVSGServiceInstanceObjects, "get_items")
     @patch.object(MockInstanceObjects, "get_items")
     @patch.object(MockAddressManagerServiceInstance, "delete")
     @patch.object(MockTag, "delete")
     @patch.object(MockInstance, "delete")
     def test_handle_delete_cleanup_instance_and_tags_and_stuff(self, instance_delete, tag_delete, amsi_delete,
-                                                            instance_objects, vsgtenant_objects, tag_objects,
+                                                            instance_objects, vsgserviceinstance_objects, tag_objects,
                                                             amsi_objects, si_objects):
         vsg_service = MockVSGService()
         am_instance = MockAddressManagerServiceInstance()
@@ -377,7 +377,7 @@
         self.tenant.instance = instance
         self.tenant.instance_id = instance.id
         self.tenant.owner = vsg_service
-        vsgtenant_objects.return_value = [self.tenant]
+        vsgserviceinstance_objects.return_value = [self.tenant]
         stag_tag = MockTag(service_id=self.tenant.owner.id, content_type=instance.self_content_type_id,
                        object_id=instance.id, name="s_tag")
         vrouter_tag = MockTag(service_id=self.tenant.owner.id, content_type=instance.self_content_type_id,
@@ -420,9 +420,9 @@
             self.policy.manage_container(self.tenant)
         self.assertEqual(e.exception.message, "This VSG container has no volt")
 
-    @patch.object(VSGTenantPolicy, "find_or_make_instance_for_s_tag")
-    @patch.object(MockVSGTenant, "save")
-    @patch.object(MockVSGTenant, "volt")
+    @patch.object(VSGServiceInstancePolicy, "find_or_make_instance_for_s_tag")
+    @patch.object(MockVSGServiceInstance, "save")
+    @patch.object(MockVSGServiceInstance, "volt")
     def test_manage_container_noinstance(self, volt, tenant_save, find_or_make_instance_for_s_tag):
         instance = MockInstance()
         volt.s_tag=222
@@ -432,9 +432,9 @@
         self.assertEqual(self.tenant.instance, instance)
         tenant_save.assert_called()
 
-    @patch.object(VSGTenantPolicy, "find_or_make_instance_for_s_tag")
-    @patch.object(MockVSGTenant, "save")
-    @patch.object(MockVSGTenant, "volt")
+    @patch.object(VSGServiceInstancePolicy, "find_or_make_instance_for_s_tag")
+    @patch.object(MockVSGServiceInstance, "save")
+    @patch.object(MockVSGServiceInstance, "volt")
     def test_manage_container_hasinstance(self, volt, tenant_save, find_or_make_instance_for_s_tag):
         instance = MockInstance()
         volt.s_tag=222
@@ -445,9 +445,9 @@
         self.assertEqual(self.tenant.instance, instance)
         tenant_save.assert_not_called()
 
-    @patch.object(VSGTenantPolicy, "find_or_make_instance_for_s_tag")
-    @patch.object(MockVSGTenant, "save")
-    @patch.object(MockVSGTenant, "volt")
+    @patch.object(VSGServiceInstancePolicy, "find_or_make_instance_for_s_tag")
+    @patch.object(MockVSGServiceInstance, "save")
+    @patch.object(MockVSGServiceInstance, "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)
@@ -535,15 +535,15 @@
     @patch.object(MockNodeObjects, "get_items")
     @patch.object(MockFlavorObjects, "get_items")
     @patch.object(MockVSGServiceObjects, "get_items")
-    @patch.object(MockVSGTenant, "volt")
-    @patch.object(MockVSGTenant, "save")
-    @patch.object(VSGTenantPolicy, "get_image")
-    @patch.object(VSGTenantPolicy, "allocate_public_service_instance")
+    @patch.object(MockVSGServiceInstance, "volt")
+    @patch.object(MockVSGServiceInstance, "save")
+    @patch.object(VSGServiceInstancePolicy, "get_image")
+    @patch.object(VSGServiceInstancePolicy, "allocate_public_service_instance")
     @patch.object(LeastLoadedNodeScheduler, "pick")
     @patch.object(MockNode, "site_deployment")
     @patch.object(MockInstance, "save")
     @patch.object(MockInstance, "delete")
-    @patch.object(VSGTenantPolicy, "port_set_parameter")
+    @patch.object(VSGServiceInstancePolicy, "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,
                               vsgservice_objects, flavor_objects, node_objects, npt_objects):
@@ -565,7 +565,7 @@
         # 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)
+        instance = self.policy.find_or_make_instance_for_s_tag(self.tenant)
 
         # make sure Instance was created
         self.assertNotEqual(instance, None)
@@ -600,7 +600,7 @@
         # Allocate_public_service_instance should have been called
         get_psi.assert_called()
 
-    @patch.object(VSGTenantPolicy, "allocate_public_service_instance")
+    @patch.object(VSGServiceInstancePolicy, "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