@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>',<EOL>action='<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>')<EOL>def do_alarm_definition_list(mc, args):
fields = {}<EOL>if args.name:<EOL><INDENT>fields['<STR_LIT:name>'] = args.name<EOL><DEDENT>if args.dimensions:<EOL><INDENT>fields['<STR_LIT>'] = utils.format_dimensions_query(args.dimensions)<EOL><DEDENT>if args.severity:<EOL><INDENT>if not _validate_severity(args.severity):<EOL><INDENT>return<EOL><DEDENT>fields['<STR_LIT>'] = args.severity<EOL><DEDENT>if args.sort_by:<EOL><INDENT>sort_by = args.sort_by.split('<STR_LIT:U+002C>')<EOL>for field in sort_by:<EOL><INDENT>field_values = field.split()<EOL>if len(field_values) > <NUM_LIT:2>:<EOL><INDENT>print("<STR_LIT>".format(field))<EOL><DEDENT>if field_values[<NUM_LIT:0>] not in allowed_definition_sort_by:<EOL><INDENT>print("<STR_LIT>".format(field_values[<NUM_LIT:0>],<EOL>allowed_definition_sort_by))<EOL>return<EOL><DEDENT>if len(field_values) > <NUM_LIT:1> and field_values[<NUM_LIT:1>] not in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>print("<STR_LIT>".format(field_values[<NUM_LIT:1>]))<EOL><DEDENT><DEDENT>fields['<STR_LIT>'] = args.sort_by<EOL><DEDENT>if args.limit:<EOL><INDENT>fields['<STR_LIT>'] = args.limit<EOL><DEDENT>if args.offset:<EOL><INDENT>fields['<STR_LIT>'] = args.offset<EOL><DEDENT>try:<EOL><INDENT>alarm = mc.alarm_definitions.list(**fields)<EOL><DEDENT>except (osc_exc.ClientException, k_exc.HttpError) as he:<EOL><INDENT>raise osc_exc.CommandError('<STR_LIT>' % (he.message, he.details))<EOL><DEDENT>else:<EOL><INDENT>if args.json:<EOL><INDENT>print(utils.json_formatter(alarm))<EOL>return<EOL><DEDENT>cols = ['<STR_LIT:name>', '<STR_LIT:id>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>formatters = {<EOL>'<STR_LIT:name>': lambda x: x['<STR_LIT:name>'],<EOL>'<STR_LIT:id>': lambda x: x['<STR_LIT:id>'],<EOL>'<STR_LIT>': lambda x: x['<STR_LIT>'],<EOL>'<STR_LIT>': lambda x: utils.format_list(x['<STR_LIT>']),<EOL>'<STR_LIT>': lambda x: x['<STR_LIT>'],<EOL>}<EOL>if isinstance(alarm, list):<EOL><INDENT>utils.print_list(alarm, cols, formatters=formatters)<EOL><DEDENT>else:<EOL><INDENT>alarm_list = list()<EOL>alarm_list.append(alarm)<EOL>utils.print_list(alarm_list, cols, formatters=formatters)<EOL><DEDENT><DEDENT>
List alarm definitions for this tenant.