Fixed issue where some properties would be None

Change-Id: Ie3b4985ce2ff5066d97c91644de96364d6409852
This commit is contained in:
aviau
2015-06-09 20:43:55 -04:00
committed by Vincent Fournier
parent 1188567bb5
commit cbe1c6a217
2 changed files with 14 additions and 13 deletions

View File

@@ -84,8 +84,8 @@ def print_item(objs, properties):
list.append({'prop': property, 'value': val_lines}) list.append({'prop': property, 'value': val_lines})
formatters = { formatters = {
'Property': lambda x: x['prop'], 'Property': lambda x: x.get('prop', ''),
'Value': lambda x: x['value'] 'Value': lambda x: x.get('value', ''),
} }
print_list(list, cols, formatters=formatters) print_list(list, cols, formatters=formatters)

View File

@@ -41,8 +41,8 @@ def do_config_host_list(sc, args):
] ]
formatters = { formatters = {
'host_name': lambda x: x['host_name'], 'host_name': lambda x: x.get('host_name', ''),
'address': lambda x: x['address'], 'address': lambda x: x.get('address', '')
} }
utils.print_list(hosts, cols, formatters=formatters) utils.print_list(hosts, cols, formatters=formatters)
@@ -145,10 +145,10 @@ def do_config_service_list(sc, args):
] ]
formatters = { formatters = {
'service_description': lambda x: x['service_description'], 'service_description': lambda x: x.get('service_description', ''),
'host_name': lambda x: x['host_name'], 'host_name': lambda x: x.get('host_name', ''),
'check_period': lambda x: x['check_period'], 'check_period': lambda x: x.get('check_period', ''),
'contact_groups': lambda x: x['contact_groups'], 'contact_groups': lambda x: x.get('contact_groups', ''),
} }
utils.print_list(services, cols, formatters=formatters) utils.print_list(services, cols, formatters=formatters)
@@ -204,9 +204,10 @@ def do_config_checkmodulation_list(sc, args):
] ]
formatters = { formatters = {
'check_command': lambda x: x['check_command'], 'check_command': lambda x: x.get('check_command', ''),
'check_period': lambda x: x['check_period'], 'check_period': lambda x: x.get('check_period', ''),
'checkmodulation_name': lambda x: x['checkmodulation_name'] 'checkmodulation_name': lambda x: x.get('checkmodulation_name',
''),
} }
utils.print_list(checkmodulations, cols, formatters=formatters) utils.print_list(checkmodulations, cols, formatters=formatters)
@@ -242,8 +243,8 @@ def do_config_command_list(sc, args):
] ]
formatters = { formatters = {
'command_name': lambda x: x['command_name'], 'command_name': lambda x: x.get('command_name', ''),
'command_line': lambda x: x['command_line'] 'command_line': lambda x: x.get('command_line', ''),
} }
utils.print_list(commands, cols, formatters=formatters) utils.print_list(commands, cols, formatters=formatters)