@utils.arg('<STR_LIT:name>', 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>'<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>'<STR_LIT>',<EOL>action='<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>'<EOL>'<STR_LIT>',<EOL>action='<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>'<EOL>'<STR_LIT>',<EOL>action='<STR_LIT>')<EOL>def do_alarm_definition_create(mc, args):
fields = {}<EOL>fields['<STR_LIT:name>'] = args.name<EOL>if args.description:<EOL><INDENT>fields['<STR_LIT:description>'] = args.description<EOL><DEDENT>fields['<STR_LIT>'] = args.expression<EOL>if args.alarm_actions:<EOL><INDENT>fields['<STR_LIT>'] = args.alarm_actions<EOL><DEDENT>if args.ok_actions:<EOL><INDENT>fields['<STR_LIT>'] = args.ok_actions<EOL><DEDENT>if args.undetermined_actions:<EOL><INDENT>fields['<STR_LIT>'] = args.undetermined_actions<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.match_by:<EOL><INDENT>fields['<STR_LIT>'] = args.match_by.split('<STR_LIT:U+002C>')<EOL><DEDENT>try:<EOL><INDENT>alarm = mc.alarm_definitions.create(**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>print(jsonutils.dumps(alarm, indent=<NUM_LIT:2>))<EOL><DEDENT>
Create an alarm definition.