Added service-list command

Change-Id: If5954f6cfb0f367c0334e5d6f0d7483ff05f1d82
This commit is contained in:
aviau
2014-12-22 11:34:56 -05:00
parent 0c5923334e
commit 98b6ce4866

View File

@@ -32,3 +32,26 @@ def do_host_list(sc, args):
'address': lambda x: x['address'],
}
utils.print_list(hosts, cols, formatters=formatters)
def do_service_list(sc, args):
"""List all services."""
services = sc.services.list()
if args.json:
print(utils.json_formatter(services))
else:
cols = [
'service_description',
'host_name',
'check_period',
'contact_groups',
]
formatters = {
'service_description': lambda x: x['service_description'],
'host_name': lambda x: x['host_name'],
'check_period': lambda x: x['check_period'],
'contact_groups': lambda x: x['contact_groups'],
}
utils.print_list(services, cols, formatters=formatters)