add ability to replace objects using tosca
diff --git a/xos/tosca/custom_types/xos.m4 b/xos/tosca/custom_types/xos.m4
index e6d77f1..e83a22f 100644
--- a/xos/tosca/custom_types/xos.m4
+++ b/xos/tosca/custom_types/xos.m4
@@ -16,7 +16,11 @@
             no-update:
                 type: boolean
                 default: false
-                description: Do not allow Tosca to update this object)
+                description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object)
 # Service
 define(xos_base_service_caps,
             scalable:
diff --git a/xos/tosca/custom_types/xos.yaml b/xos/tosca/custom_types/xos.yaml
index 2bca51e..b41a6c7 100644
--- a/xos/tosca/custom_types/xos.yaml
+++ b/xos/tosca/custom_types/xos.yaml
@@ -41,6 +41,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             kind:
                 type: string
                 default: generic
@@ -117,6 +121,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             kind:
                 type: string
                 default: generic
@@ -288,6 +296,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             kind:
                 type: string
                 default: generic
@@ -352,6 +364,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             kind:
                 type: string
                 default: generic
@@ -410,6 +426,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             kind:
                 type: string
                 default: generic
@@ -464,6 +484,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             kind:
                 type: string
                 default: generic
@@ -518,6 +542,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             kind:
                 type: string
                 default: generic
@@ -603,6 +631,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             kind:
                 type: string
                 default: generic
@@ -657,6 +689,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             kind:
                 type: string
                 default: generic
@@ -806,6 +842,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             password:
                 type: string
                 required: false
@@ -864,6 +904,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
 
         capabilities:
             network_parameter_type:
@@ -893,6 +937,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             visibility:
                 type: string
                 required: false
@@ -942,7 +990,11 @@
             no-update:
                 type: boolean
                 default: false
-                description: Do not allow Tosca to update this object

+                description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object

             ip_version:

               type: integer

               required: no

@@ -1046,6 +1098,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             accessControl:
                 type: string
                 default: allow all
@@ -1075,6 +1131,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             addresses:
                 type: string
                 required: false
@@ -1138,6 +1198,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             backend_type:
                 type: string
                 required: false
@@ -1199,6 +1263,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             display_name:
                 type: string
                 required: false
@@ -1244,6 +1312,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             enabled:
                 type: boolean
                 default: true
@@ -1290,6 +1362,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
         capabilities:
             node:
                 type: tosca.capabilities.xos.Node
@@ -1311,6 +1387,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
         capabilities:
             node:
                 type: tosca.capabilities.xos.NodeLabel
@@ -1332,6 +1412,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             flavor:
                 type: string
                 required: false
@@ -1357,6 +1441,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
         capabilities:
             siterole:
                 type: tosca.capabilities.xos.SiteRole
@@ -1378,6 +1466,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
         capabilities:
             slicerole:
                 type: tosca.capabilities.xos.SliceRole
@@ -1399,6 +1491,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
         capabilities:
             tenantrole:
                 type: tosca.capabilities.xos.TenantRole
@@ -1420,6 +1516,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
         capabilities:
             deploymentrole:
                 type: tosca.capabilities.xos.DeploymentRole
@@ -1444,6 +1544,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             enabled:
                 type: boolean
                 default: true
@@ -1469,6 +1573,10 @@
                 type: boolean
                 default: false
                 description: Do not allow Tosca to update this object
+            replaces:
+                type: string
+                required: false
+                descrption: Replaces/renames this object
             name:
                 type: string
                 required: true
diff --git a/xos/tosca/resources/xosresource.py b/xos/tosca/resources/xosresource.py
index 82514c9..012f814 100644
--- a/xos/tosca/resources/xosresource.py
+++ b/xos/tosca/resources/xosresource.py
@@ -2,6 +2,7 @@
 import pdb
 import json
 import subprocess
+import sys
 
 from core.models import User
 
@@ -90,6 +91,13 @@
             return None
         return objs[0]
 
+    def get_replaces_objs(self):
+        replaces = self.get_property_default("replaces", None)
+        if replaces:
+            return self.xos_model.objects.filter(**{self.name_field: replaces})
+        else:
+            return []
+
     def get_existing_objs(self):
         return self.xos_model.objects.filter(**{self.name_field: self.obj_name})
 
@@ -97,7 +105,25 @@
         return self.xos_model.__name__
 
     def create_or_update(self):
+        replaces_objs = self.get_replaces_objs()
         existing_objs = self.get_existing_objs()
+
+        if (replaces_objs and existing_objs):
+            ro = replaces_objs[0]
+            self.info("deleting %s:%s" % (self.get_model_class_name(), getattr(ro,self.name_field)))
+            ro.delete()
+
+            # in case we wanted to throw an error instead...
+            #self.error("CRITICAL ERROR: Both %s and %s exist!" % (getattr(ro,self.name_field), self.obj_name))
+            #sys.exit(-1)
+
+        if (replaces_objs and not existing_objs):
+            ro = replaces_objs[0]
+            self.info("renaming %s:%s to %s" % (self.get_model_class_name(), getattr(ro,self.name_field), self.obj_name))
+            setattr(ro, self.name_field, self.obj_name)
+            ro.save()
+            existing_objs = self.get_existing_objs()
+
         if existing_objs:
             if self.get_property_default("no-update", False):
                 self.info("%s:%s (%s) already exists. Skipping update due to 'no-update' property" % (self.get_model_class_name(), self.obj_name, self.full_name))