diff options
author | Michael DeHaan <mdehaan@redhat.com> | 2008-05-30 11:42:35 -0400 |
---|---|---|
committer | Michael DeHaan <mdehaan@redhat.com> | 2008-05-30 11:42:35 -0400 |
commit | b38dfee242e2b02082cde8f44f6af87a1a243620 (patch) | |
tree | bc1a8d5a8bf01d110ca07d48d65dcd093e97df5a /cobbler/collection.py | |
parent | a63789be503d43b6f4fa42794a18cfe9b8f2c586 (diff) | |
download | cobbler-b38dfee242e2b02082cde8f44f6af87a1a243620.tar.gz cobbler-b38dfee242e2b02082cde8f44f6af87a1a243620.tar.xz 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.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/cobbler/collection.py b/cobbler/collection.py index 1b509f20..60449938 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 |