From 7b6922a1da2654874d14ba97340e95ab88eff202 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Wed, 14 May 2008 16:15:21 -0400 Subject: Added the ability to undefine a symbol that is defined in a parent object. This means that if a kernel option is set for a profile, and you want it unset in a child system, you can say --kopts='!foo' to undefine the foo. Similarly you can add symbols and undefine others at the same time... --kopts='bar !foo baz=3' and so on. This is relatively fringe usage but was previously not possible. --- cobbler/utils.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'cobbler') diff --git a/cobbler/utils.py b/cobbler/utils.py index 007b96c..455a7e3 100644 --- a/cobbler/utils.py +++ b/cobbler/utils.py @@ -446,6 +446,24 @@ def __consolidate(node,results): else: results[field] = data_item + # now if we have any "!foo" results in the list, delete corresponding + # key entry "foo", and also the entry "!foo", allowing for removal + # of kernel options set in a distro later in a profile, etc. + + hash_removals(results,"kernel_options") + hash_removals(results,"ks_meta") + +def hash_removals(results,subkey): + if not results.has_key(subkey): + return + scan = results[subkey].keys() + for k in scan: + if k.startswith("!") and k != "!": + remove_me = k[1:] + if results[subkey].has_key(remove_me): + del results[subkey][remove_me] + del results[subkey][k] + def hash_to_string(hash): """ Convert a hash to a printable string. -- cgit