CORD-880: Fix ansible tags when using apiaccessor

Change-Id: If0b77204b0d5036c055a4f5d616831cf2c463b7d
diff --git a/xos/synchronizers/new_base/SyncInstanceUsingAnsible.py b/xos/synchronizers/new_base/SyncInstanceUsingAnsible.py
index 1e037d2..e4e6119 100644
--- a/xos/synchronizers/new_base/SyncInstanceUsingAnsible.py
+++ b/xos/synchronizers/new_base/SyncInstanceUsingAnsible.py
@@ -209,7 +209,7 @@
 
                 fields = self.get_ansible_fields(instance)
 
-        fields["ansible_tag"] =  o.__class__.__name__ + "_" + str(o.id)
+        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.
@@ -256,7 +256,7 @@
             # sync to an XOS instance
             fields = self.get_ansible_fields(instance)
 
-            fields["ansible_tag"] =  o.__class__.__name__ + "_" + str(o.id)
+            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.
@@ -348,7 +348,7 @@
 
             #Run ansible playbook to update the routing table entries in the instance
             fields = self.get_ansible_fields(instance)
-            fields["ansible_tag"] =  obj.__class__.__name__ + "_" + str(obj.id) + "_service_composition"
+            fields["ansible_tag"] = getattr(obj, "ansible_tag", obj.__class__.__name__ + "_" + str(obj.id)) + "_service_composition"
             fields["src_intf_ip"] = src_ip
             fields["target_subnet"] = target_subnet
             #Template file is available under .../synchronizers/shared_templates
diff --git a/xos/xos_client/xosapi/orm.py b/xos/xos_client/xosapi/orm.py
index 69d37b0..1de0693 100644
--- a/xos/xos_client/xosapi/orm.py
+++ b/xos/xos_client/xosapi/orm.py
@@ -169,6 +169,10 @@
 
         return d
 
+    @property
+    def ansible_tag(self):
+        return "%s_%s" % (self._wrapped_class.__class__.__name__, self.id)
+
 class ORMQuerySet(list):
     """ Makes lists look like django querysets """
     def first(self):
@@ -286,6 +290,7 @@
         self.model_name = model_name
         self.objects = ORMObjectManager(stub, model_name, package_name)
 
+    @property
     def __name__(self):
         return self.model_name