summaryrefslogtreecommitdiffstats
path: root/cobbler/collection.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-06-12 15:14:43 -0400
committerMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-06-12 15:14:43 -0400
commit297f85a192483a61d921a35b6f7938d3c52e466f (patch)
treeb5362c5c9d6203512d4804358a36c1d2e9b3ef93 /cobbler/collection.py
parentd3dfa949cba586ac3226486f763cba5140a90be7 (diff)
downloadcobbler-297f85a192483a61d921a35b6f7938d3c52e466f.tar.gz
cobbler-297f85a192483a61d921a35b6f7938d3c52e466f.tar.xz
cobbler-297f85a192483a61d921a35b6f7938d3c52e466f.zip
Add code for generation of object downlinks during config parsing.
Reasonably efficient, and allows for faster display/searching, with the ability to do arbitrary nesting for config display when we have inheritable profiles implemented.
Diffstat (limited to 'cobbler/collection.py')
-rw-r--r--cobbler/collection.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/cobbler/collection.py b/cobbler/collection.py
index 6a8c7879..a6a39915 100644
--- a/cobbler/collection.py
+++ b/cobbler/collection.py
@@ -60,10 +60,11 @@ class Collection(serializable.Serializable):
no objects can be found.
"""
n1 = name.lower()
- for key in self.listing.keys():
- if key.lower() == n1:
- return self.listing[key]
- return None
+ listing = self.listing
+ if listing.has_key(n1):
+ return self.listing[n1]
+ else:
+ return None
def to_datastruct(self):
"""
@@ -99,13 +100,15 @@ class Collection(serializable.Serializable):
raise CX(_("invalid parameter"))
if not with_copy:
# don't need to run triggers, so add it already ...
- self.listing[ref.name] = ref
+ self.listing[ref.name.lower()] = ref
+
# perform filesystem operations
if with_copy:
# failure of a pre trigger will prevent the object from being added
self._run_triggers(ref,"/var/lib/cobbler/triggers/add/%s/pre/*" % self.collection_type())
- self.listing[ref.name] = ref
+ self.listing[ref.name.lower()] = ref
+ self.config.api.serialize()
lite_sync = action_litesync.BootLiteSync(self.config)
if isinstance(ref, item_system.System):
lite_sync.add_single_system(ref.name)
@@ -117,9 +120,12 @@ class Collection(serializable.Serializable):
print _("Internal error. Object type not recognized: %s") % type(ref)
# save the tree, so if neccessary, scripts can examine it.
- self.config.api.serialize()
self._run_triggers(ref,"/var/lib/cobbler/triggers/add/%s/post/*" % self.collection_type())
-
+
+ # update children cache in parent object
+ parent = ref.get_parent()
+ if parent != None:
+ parent.children[ref.name] = ref
return True