If the default option is not in the option list, add it.

Most notably, this adds '<<inherit>>' as a choice to many options with
a fixed list of choices.

Signed-off-by: John Morris <[email protected]>
---
 cobbler/utils.py |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/cobbler/utils.py b/cobbler/utils.py
index 34de8dd..c48d527 100644
--- a/cobbler/utils.py
+++ b/cobbler/utils.py
@@ -1964,6 +1964,8 @@ def add_options_from_fields(object_type, parser, fields, 
object_action):
                     aliasopt.append("--%s" % deprecated_field)
 
             if isinstance(choices, list) and len(choices) != 0:
+                if default not in choices:
+                    choices.append(default)
                 desc = desc + " (valid options: %s)" % ",".join(choices)    
                 parser.add_option(niceopt, dest=k, help=desc, choices=choices)
                 for alias in aliasopt:
-- 
1.7.1

_______________________________________________
cobbler mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/cobbler

Reply via email to