#NEWLINE# def monitored( name , **params ) : #NEWLINE# #INDENT# '\n    Makes sure an URL is monitored by uptime. Checks if URL is already\n    monitored, and if not, adds it.\n\n    ' #NEWLINE# ret = { #NEWLINE# #INDENT# 'name' : name , #NEWLINE# 'changes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'result' : None , #NEWLINE# 'comment' : '' , #NEWLINE# #UNINDENT# } #NEWLINE# if __salt__ [ 'uptime.check_exists' ] ( name = name ) : #NEWLINE# #INDENT# ret [ 'result' ] = True #NEWLINE# ret [ 'comment' ] = 'URL {0} is already monitored' . format ( name ) #NEWLINE# ret [ 'changes' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# return ret #NEWLINE# #UNINDENT# if ( not __opts__ [ 'test' ] ) : #NEWLINE# #INDENT# url_monitored = __salt__ [ 'uptime.create' ] ( name , ** params ) #NEWLINE# if url_monitored : #NEWLINE# #INDENT# ret [ 'result' ] = True #NEWLINE# msg = 'Successfully added the URL {0} to uptime' #NEWLINE# ret [ 'comment' ] = msg . format ( name ) #NEWLINE# ret [ 'changes' ] = { #NEWLINE# #INDENT# 'url_monitored' : url_monitored , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ret [ 'result' ] = False #NEWLINE# ret [ 'comment' ] = 'Failed to add {0} to uptime' . format ( name ) #NEWLINE# ret [ 'changes' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# msg = 'URL {0} is going to be added to uptime' #NEWLINE# ret . update ( result = None , comment = msg . format ( name ) ) #NEWLINE# #UNINDENT# return ret