#NEWLINE# @ utils . arg ( 'name' , metavar = '<ALARM_DEFINITION_NAME>' , help = 'Name of the alarm definition to create.' ) #NEWLINE# @ utils . arg ( '--description' , metavar = '<DESCRIPTION>' , help = 'Description of the alarm.' ) #NEWLINE# @ utils . arg ( 'expression' , metavar = '<EXPRESSION>' , help = 'The alarm expression to evaluate. Quoted.' ) #NEWLINE# @ utils . arg ( '--severity' , metavar = '<SEVERITY>' , help = 'Severity is one of [LOW, MEDIUM, HIGH, CRITICAL].' ) #NEWLINE# @ utils . arg ( '--match-by' , metavar = '<DIMENSION_KEY1,DIMENSION_KEY2,...>' , help = 'The metric dimensions to match to the alarm dimensions. One or more dimension key names separated by a comma. Key names need quoting when they contain special chars [&,(,),{,},>,<] that confuse the CLI parser.' ) #NEWLINE# @ utils . arg ( '--alarm-actions' , metavar = '<NOTIFICATION-ID>' , help = 'The notification method to use when an alarm state is ALARM. This param may be specified multiple times.' , action = 'append' ) #NEWLINE# @ utils . arg ( '--ok-actions' , metavar = '<NOTIFICATION-ID>' , help = 'The notification method to use when an alarm state is OK. This param may be specified multiple times.' , action = 'append' ) #NEWLINE# @ utils . arg ( '--undetermined-actions' , metavar = '<NOTIFICATION-ID>' , help = 'The notification method to use when an alarm state is UNDETERMINED. This param may be specified multiple times.' , action = 'append' ) #NEWLINE# def do_alarm_definition_create( mc , args ) : #NEWLINE# #INDENT# 'Create an alarm definition.' #NEWLINE# fields = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# fields [ 'name' ] = args . name #NEWLINE# if args . description : #NEWLINE# #INDENT# fields [ 'description' ] = args . description #NEWLINE# #UNINDENT# fields [ 'expression' ] = args . expression #NEWLINE# if args . alarm_actions : #NEWLINE# #INDENT# fields [ 'alarm_actions' ] = args . alarm_actions #NEWLINE# #UNINDENT# if args . ok_actions : #NEWLINE# #INDENT# fields [ 'ok_actions' ] = args . ok_actions #NEWLINE# #UNINDENT# if args . undetermined_actions : #NEWLINE# #INDENT# fields [ 'undetermined_actions' ] = args . undetermined_actions #NEWLINE# #UNINDENT# if args . severity : #NEWLINE# #INDENT# if ( not _validate_severity ( args . severity ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# fields [ 'severity' ] = args . severity #NEWLINE# #UNINDENT# if args . match_by : #NEWLINE# #INDENT# fields [ 'match_by' ] = args . match_by . split ( ',' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# alarm = mc . alarm_definitions . create ( ** fields ) #NEWLINE# #UNINDENT# except exc . HTTPException as he : #NEWLINE# #INDENT# raise exc . CommandError ( ( 'HTTPException code=%s message=%s' % ( he . code , he . message ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# print ( jsonutils . dumps ( fields , indent = 2 ) )