Defined default category in a variable

pull/41656/head
Jose Delarosa 6 years ago
parent 3a13cb9816
commit 7b0a1ed658

@ -115,6 +115,7 @@ CATEGORY_COMMANDS_ALL = {
"Manager": ["GetManagerAttributes", "GetLogs"], "Manager": ["GetManagerAttributes", "GetLogs"],
} }
CATEGORY_DEFAULT = "Systems"
CATEGORY_COMMANDS_DEFAULT = { CATEGORY_COMMANDS_DEFAULT = {
"Systems": "GetSystemInventory", "Systems": "GetSystemInventory",
"Chassis": "GetFanInventory", "Chassis": "GetFanInventory",
@ -151,7 +152,7 @@ def main():
# Build Category list # Build Category list
if not module.params['category']: if not module.params['category']:
# True if we don't specify a category --> use default # True if we don't specify a category --> use default
category_list.append("Systems") category_list.append(CATEGORY_DEFAULT)
elif module.params['category'] == "all": elif module.params['category'] == "all":
for entry in CATEGORY_COMMANDS_ALL: for entry in CATEGORY_COMMANDS_ALL:
category_list.append(entry) category_list.append(entry)
@ -176,10 +177,10 @@ def main():
command_list.append(cmd) command_list.append(cmd)
else: else:
# Fail if even one command given is invalid # Fail if even one command given is invalid
module.fail_json(msg="Invalid Command") module.fail_json(msg="Invalid Command: %s" % cmd)
else: else:
# Fail if even one category given is invalid # Fail if even one category given is invalid
module.fail_json(msg="Invalid Category") module.fail_json(msg="Invalid Category: %s" % category)
# Organize by Categories / Commands # Organize by Categories / Commands
if category == "Systems": if category == "Systems":

Loading…
Cancel
Save