@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<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>'<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>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<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>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>'<EOL>'<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_list(mc, args):
fields = {}<EOL>if args.alarm_definition_id:<EOL><INDENT>fields['<STR_LIT>'] = args.alarm_definition_id<EOL><DEDENT>if args.metric_name:<EOL><INDENT>fields['<STR_LIT>'] = args.metric_name<EOL><DEDENT>if args.metric_dimensions:<EOL><INDENT>fields['<STR_LIT>'] = utils.format_dimensions_query(args.metric_dimensions)<EOL><DEDENT>if args.state:<EOL><INDENT>if args.state.upper() not in state_types:<EOL><INDENT>errmsg = ('<STR_LIT>' +<EOL>'<STR_LIT:U+002CU+0020>'.join(state_types) + '<STR_LIT:]>')<EOL>print(errmsg)<EOL>return<EOL><DEDENT>fields['<STR_LIT:state>'] = args.state<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.state_updated_start_time:<EOL><INDENT>fields['<STR_LIT>'] = args.state_updated_start_time<EOL><DEDENT>if args.lifecycle_state:<EOL><INDENT>fields['<STR_LIT>'] = args.lifecycle_state<EOL><DEDENT>if args.link:<EOL><INDENT>fields['<STR_LIT>'] = args.link<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>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.lower().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_alarm_sort_by:<EOL><INDENT>print("<STR_LIT>".format(field_values[<NUM_LIT:0>],<EOL>allowed_alarm_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>try:<EOL><INDENT>alarm = mc.alarms.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:id>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT:state>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', "<STR_LIT>"]<EOL>formatters = {<EOL>'<STR_LIT:id>': lambda x: x['<STR_LIT:id>'],<EOL>'<STR_LIT>': lambda x: x['<STR_LIT>']['<STR_LIT:id>'],<EOL>'<STR_LIT>': lambda x: x['<STR_LIT>']['<STR_LIT:name>'],<EOL>'<STR_LIT>': lambda x: format_metric_name(x['<STR_LIT>']),<EOL>'<STR_LIT>': lambda x: format_metric_dimensions(x['<STR_LIT>']),<EOL>'<STR_LIT>': lambda x: x['<STR_LIT>']['<STR_LIT>'],<EOL>'<STR_LIT:state>': lambda x: x['<STR_LIT:state>'],<EOL>'<STR_LIT>': lambda x: x['<STR_LIT>'],<EOL>'<STR_LIT>': lambda x: x['<STR_LIT>'],<EOL>'<STR_LIT>': lambda x: x['<STR_LIT>'],<EOL>'<STR_LIT>': lambda x: 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 alarms for this tenant.