@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>@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_count(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.group_by:<EOL><INDENT>group_by = args.group_by.split('<STR_LIT:U+002C>')<EOL>if not set(group_by).issubset(set(group_by_types)):<EOL><INDENT>errmsg = ('<STR_LIT>' +<EOL>'<STR_LIT:U+002C>'.join(group_by_types) + '<STR_LIT:]>')<EOL>print(errmsg)<EOL>return<EOL><DEDENT>fields['<STR_LIT>'] = args.group_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>counts = mc.alarms.count(**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(counts))<EOL>return<EOL><DEDENT>cols = counts['<STR_LIT>']<EOL>utils.print_list(counts['<STR_LIT>'], [i for i in range(len(cols))],<EOL>field_labels=cols)<EOL><DEDENT>
Count alarms.