summaryrefslogtreecommitdiffstats
path: root/cobbler/collection.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-05-30 11:42:35 -0400
committerMichael DeHaan <mdehaan@redhat.com>2008-05-30 11:42:35 -0400
commitb38dfee242e2b02082cde8f44f6af87a1a243620 (patch)
treebc1a8d5a8bf01d110ca07d48d65dcd093e97df5a /cobbler/collection.py
parenta63789be503d43b6f4fa42794a18cfe9b8f2c586 (diff)
downloadthird_party-cobbler-b38dfee242e2b02082cde8f44f6af87a1a243620.tar.gz
third_party-cobbler-b38dfee242e2b02082cde8f44f6af87a1a243620.tar.xz
third_party-cobbler-b38dfee242e2b02082cde8f44f6af87a1a243620.zip
This change makes triggers that are registered for addition and removal of objects to now run when they are renamed or copied. In the case of a copy, only the add triggers are re-run against the new name. In the case of rename, first the add triggers are called on the newname, then the remove triggers are called on the oldname as that is how things are implemented. In the case of renaming an object that has child objects, the child objects are updated, so the add triggers will then be called on each to notify that those objects themselves have changed, this last bit of the behavior I'm not sure if it's a good thing or not, though we can refine it if that is not desirable.
Diffstat (limited to 'cobbler/collection.py')
-rw-r--r--cobbler/collection.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/cobbler/collection.py b/cobbler/collection.py
index 1b509f2..6044993 100644
--- a/cobbler/collection.py
+++ b/cobbler/collection.py
@@ -100,7 +100,7 @@ class Collection(serializable.Serializable):
self.add(item)
- def rename(self,ref,newname,with_sync=True,with_triggers=False):
+ def rename(self,ref,newname,with_sync=True,with_triggers=True):
"""
Allows an object "ref" to be given a newname without affecting the rest
of the object tree.
@@ -110,7 +110,7 @@ class Collection(serializable.Serializable):
oldname = ref.name
newref = ref.make_clone()
newref.set_name(newname)
- self.add(newref)
+ self.add(newref, with_triggers=with_triggers,save=True)
# now descend to any direct ancestors and point them at the new object allowing
# the original object to be removed without orphanage. Direct ancestors
@@ -126,17 +126,17 @@ class Collection(serializable.Serializable):
k.set_parent(newname)
else:
k.set_distro(newname)
- self.api.profiles().add(k, save=True, with_sync=with_sync, with_triggers=with_triggers)
+ self.api.profiles().add(k, save=True, with_sync=with_sync, with_triggers=with_triggers,save=True)
elif k.COLLECTION_TYPE == "system":
k.set_profile(newname)
- self.api.systems().add(k, save=True, with_sync=with_sync, with_triggers=with_triggers)
+ self.api.systems().add(k, save=True, with_sync=with_sync, with_triggers=with_triggers,save=True)
elif k.COLLECTION_TYPE == "repo":
raise CX(_("internal error, not expected to have repo child objects"))
else:
raise CX(_("internal error, unknown child type (%s), cannot finish rename" % k.COLLECTION_TYPE))
# now delete the old version
- self.remove(oldname, with_delete=True)
+ self.remove(oldname, with_delete=True, with_triggers=with_triggers)
return True